<p>Given an integer array&nbsp;<code>nums</code>, return <em>the number of longest increasing subsequences.</em></p>

<p><strong>Notice</strong> that the sequence has to be <strong>strictly</strong> increasing.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,3,5,4,7]
<strong>Output:</strong> 2
<strong>Explanation:</strong> The two longest increasing subsequences are [1, 3, 4, 7] and [1, 3, 5, 7].
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [2,2,2,2,2]
<strong>Output:</strong> 5
<strong>Explanation:</strong> The length of the longest increasing subsequence is 1, and there are 5 increasing subsequences of length 1, so output 5.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 2000</code></li>
	<li><code>-10<sup>6</sup> &lt;= nums[i] &lt;= 10<sup>6</sup></code></li>
	<li>The answer is guaranteed to fit inside a 32-bit integer.</li>
</ul>

import bisect

class Solution:
    def findNumberOfLIS(self, nums: List[int]) -> int:
        longest_increasing_sequences = []
        largest_sequence_count = 0
        for num in nums:
            if not longest_increasing_sequences:
                longest_increasing_sequences.append([[num, 1]])
                largest_sequence_count = 1
            else:
                left = bisect.bisect_left(longest_increasing_sequences, num, key=lambda value: value[-1][0])
                if left == 0:
                    smaller_count = 1
                else:
                    left_index = bisect.bisect_right(longest_increasing_sequences[left - 1], -num, key=lambda value: -value[0]) - 1
                    smaller_count = longest_increasing_sequences[left - 1][-1][1] - (longest_increasing_sequences[left - 1][left_index][1] if left_index != -1 else 0)
                if left == len(longest_increasing_sequences):
                    longest_increasing_sequences.append([[num, smaller_count]])
                    largest_sequence_count = smaller_count
                else:
                    if left == len(longest_increasing_sequences) - 1:
                        largest_sequence_count += smaller_count
                    longest_increasing_sequences[left].append([num, smaller_count + longest_increasing_sequences[left][-1][1]])
        return largest_sequence_count
17000