### countSubarrays 
from itertools import accumulate
from typing import *
def f_gold(nums: List[int], k: int) -> int:
    s = list(accumulate(nums, initial=0))
    ans = 0
    for i in range(1, len(nums) + 1):
        if nums[i - 1] >= k:
            continue
        left, right = 1, i
        while left < right:
            mid = (left + right + 1) >> 1
            if (s[i] - s[i - mid]) * mid < k:
                left = mid
            else:
                right = mid - 1
        ans += left
    return ans