output_description: Print the number of the non-empty contiguous subsequences with an arithmetic
  mean that is greater than or equal to K.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      a_1
      a_2
      :
      a_N
attempt: from itertools import accumulate
  
  
  def init(As):
      numPow2 = 2 ** (len(As) - 1).bit_length()
      data = [0] * (numPow2 + 1)
      return data, numPow2
  
  
  def addValue(iA, A):
      iA += 1
      while iA <= numPow2:
          data[iA] += A
          iA += iA & -iA
  
  
  def getSum(iA):
      iA += 1
      ans = 0
      while iA > 0:
          ans += data[iA]
          iA -= iA & -iA
      return ans
  
  
  N, K = map(int, input().split())
  As = [int(input()) for _ in range(N)]
  
  Bs = list(accumulate([0] + [A - K for A in As]))
  iBs = list(range(N + 1))
  iBs.sort(key=lambda iB: Bs[iB])
  
  data, numPow2 = init([0] * (N + 1))
  
  ans = 0
  for iB in iBs:
      addValue(iB, 1)
      ans += getSum(iB - 1)
  
  print(ans)
  
problem_description: Statement
  
  You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an
  integer K.
  
  a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤
  l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than
  or equal to K?
samples: [{"input": "3 6\n    7\n    5\n    7", "output": "5\n    \n\nAll the non-empty contiguous subsequences of a are listed below:\n\n  * {a_1} = {7}\n  * {a_1, a_2} = {7, 5}\n  * {a_1, a_2, a_3} = {7, 5, 7}\n  * {a_2} = {5}\n  * {a_2, a_3} = {5, 7}\n  * {a_3} = {7}\n\nTheir means are 7, 6, 19/3, 5, 6 and 7, respectively, and five among them are\n6 or greater. Note that {a_1} and {a_3} are indistinguishable by the values of\ntheir elements, but we count them individually.\n\n* * *"}, {"input": "1 2\n    1", "output": "0\n    \n\n* * *"}, {"input": "7 26\n    10\n    20\n    30\n    40\n    30\n    20\n    10", "output": "13"}]