Buggy python submission (verdict: Time Limit Exceeded):
class Sum_Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def get_sum(self, i=None):
        if i is None:
            i = self.size
        m = 0  # -INF
        while i > 0:
            m += self.tree[i]
            i -= i & -i
        return m

    def update(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
X = [0]*N
X[0] = A[0]-K
for i in range(1,N):
    X[i] = X[i-1] + A[i] - K

Y = sorted(X)
dic, i = {}, 1
while len(Y):
    y = Y.pop(0)
    dic[y] = i
    if len(Y) >= 1 and Y[0] > y:
        i += 1
Z = list(map(lambda x: dic[x], X))

BIT = Sum_Bit(N)
ans = 0
for i in range(N):
    ans += BIT.get_sum(Z[i])
    if X[i] >= 0: ans += 1
    BIT.update(Z[i], 1)
    
print(ans)


Fixed submission:
class Sum_Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def get_sum(self, i=None):
        if i is None:
            i = self.size
        m = 0  # -INF
        while i > 0:
            m += self.tree[i]
            i -= i & -i
        return m

    def update(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
X = [0]*N
X[0] = A[0]-K
for i in range(1,N):
    X[i] = X[i-1] + A[i] - K

Y = sorted(set(X))
dic = {y:i+1 for i,y in enumerate(Y)}

BIT = Sum_Bit(N)
ans = 0
for i in range(N):
    ans += BIT.get_sum(dic[X[i]])
    if X[i] >= 0: ans += 1
    BIT.update(dic[X[i]], 1)
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
class Sum_Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def get_sum(self, i=None):
        if i is None:
            i = self.size
        m = 0  # -INF
        while i > 0:
            m += self.tree[i]
            i -= i & -i
        return m

    def update(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
X = [0]*N
X[0] = A[0]-K
for i in range(1,N):
    X[i] = X[i-1] + A[i] - K

Y = sorted(X)
dic, i = {}, 1
while len(Y):
    y = Y.pop(0)
    dic[y] = i
    if len(Y) >= 1 and Y[0] > y:
        i += 1
Z = list(map(lambda x: dic[x], X))

BIT = Sum_Bit(N)
ans = 0
for i in range(N):
    ans += BIT.get_sum(Z[i])
    if X[i] >= 0: ans += 1
    BIT.update(Z[i], 1)
    
print(ans)


Fixed submission:
class Sum_Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def get_sum(self, i=None):
        if i is None:
            i = self.size
        m = 0  # -INF
        while i > 0:
            m += self.tree[i]
            i -= i & -i
        return m

    def update(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
X = [0]*N
X[0] = A[0]-K
for i in range(1,N):
    X[i] = X[i-1] + A[i] - K

Y = sorted(set(X))
dic = {y:i+1 for i,y in enumerate(Y)}

BIT = Sum_Bit(N)
ans = 0
for i in range(N):
    ans += BIT.get_sum(dic[X[i]])
    if X[i] >= 0: ans += 1
    BIT.update(dic[X[i]], 1)
    
print(ans)