Buggy python submission (verdict: Runtime Error):
inport bisect

N = int(input())
A = [int(i) for i in input().split()]

B = [0]
X = [0]
ans = 0

for i in range(N):
    X.append(X[i]+A[i])
    insert_index = bisect.bisect_left(B,X[i+1])
    for j in range(insert_index,i+1):
        if B[j] == X[i+1]:
            ans += 1
        else:
            break

    B.insert(insert_index,X[i+1])

print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
 
N = int(input())
A = [int(i) for i in input().split()]
 
B = [0]
X = [0]
ans = 0
for i in range(N):
    X.append(X[i]+A[i])
    insert_index = bisect.bisect_left(B,X[i+1])
    ans += bisect.bisect_right(B,X[i+1])-insert_index
    B.insert(insert_index,X[i+1])
 
print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect

N = int(input())
A = [int(i) for i in input().split()]
 
B = [0]
X = [0]
ans = 0
for i in range(N):
    X.append(X[i]+A[i])
    insert_index = bisect.bisect_left(B,X[i+1])
    ans += bisect.bisect_right(B,X[i+1])-insert_incex
    B.insert(insert_index,X[i+1])
 
print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
 
B = [0]
[B.append(B[i]+A[i]) for i in range(N)]
B.sort()
 
ans = 0
for i in range(N):
    for j in range(i+1,N+1):
        if B[i] == B[j]:
            ans += 1
        else:
            break
 
print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
 
B = [0]
ans = 0
for i in range(N):
    ans += B.count(B[i]+A[i])
    B.append(B[i]+A[i])

print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

B = [0]
[B.append(B[i]+A[i]) for i in range(N)]
B.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N+1):
        if B[i] == B[j]:
            ans += 1
        else:
            break

print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

print(sum([sum(A[i:j])==0 for i in range(0,N) for j in range(i+1,N+1)]))

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

print(sum([sum(A[i:j])==0 for i in range(0,N) for j in range(i+1,N+1)]))


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

ans = 0

for i in range(0,N):
 for j in range(i+1,N+1):
  if sum(A[i:j])==0:
   ans +=1

print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split())]

ans = 0

for i in range(0,N-1):
 for j in range(i+1,N):
  if sum(A[i:j])==0:
   ans +=1

print(ans)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

B = {}
B[0] = 1

s = 0
ans = 0

for a in A:
    s += a
    ans += B.get(s,0)
    B[s] = B.get(s,0)+1

print(ans)