classSolution: defnumSubseq(self, nums: List[int], target: int) -> int: n = len(nums) P = 10**9 + 7 f = [1] + [0] * (n - 1) for i inrange(1, n): f[i] = f[i - 1] * 2 % P
nums.sort() ans = 0 for i, num inenumerate(nums): if nums[i] * 2 > target: break maxValue = target - nums[i] pos = bisect.bisect_right(nums, maxValue) - 1 contribute = f[pos - i] if pos >= i else0 ans += contribute return ans % P