Buggy python submission (verdict: Runtime Error):
from collections import Counter
from scipy.misc import comb

N = int(input())
A = list(map(int, input().split()))
ans = 0
cumulative_sum = [0] + [sum(A[:i+1]) for i in range(N)]
counts = Counter(cumulative_sum)
ans = 0
for v in counts.values():
    ans += v * (v-1) // 2
    
print(ans)


Fixed submission:
from collections import Counter
import numpy as np

N = int(input())
A = [0]+list(map(int, input().split()))

cumulative_sum = np.cumsum(A)
counts = Counter(cumulative_sum)
ans = 0
for v in counts.values():
    ans += v * (v-1) // 2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from scipy.misc import comb

N = int(input())
A = list(map(int, input().split()))
ans = 0
cumulative_sum = [0] + [sum(A[:i+1]) for i in range(N)]
counts = Counter(cumulative_sum)
ans = 0
for v in counts.values():
    ans += v * (v-1) // 2
    
print(ans)


Fixed submission:
from collections import Counter
import numpy as np

N = int(input())
A = [0]+list(map(int, input().split()))

cumulative_sum = np.cumsum(A)
counts = Counter(cumulative_sum)
ans = 0
for v in counts.values():
    ans += v * (v-1) // 2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from scipy.misc import comb

N = int(input())
A = list(map(int, input().split()))
ans = 0
cumulative_sum = [0] + [sum(A[:i+1]) for i in range(N)]
counts = Counter(cumulative_sum).most_common()
ans = 0
for c in counts:
    if c[1] < 2:
        break
    ans += comb(c[1], 2, exact=True)
    
print(ans)


Fixed submission:
from collections import Counter
import numpy as np

N = int(input())
A = [0]+list(map(int, input().split()))

cumulative_sum = np.cumsum(A)
counts = Counter(cumulative_sum)
ans = 0
for v in counts.values():
    ans += v * (v-1) // 2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
from collections import Counter

def comb(n,r):
    return factorial(n) // factorial(r) // factorial(n - r)
    
N = int(input())
A = list(map(int, input().split()))
ans = 0
cumulative_sum = [0] + [sum(A[:i+1]) for i in range(N)]
counts = Counter(cumulative_sum).most_common()
ans = 0
for c in counts:
    if c[1] < 2:
        break
    ans += comb(c[1], 2)
    
print(ans)


Fixed submission:
from collections import Counter
import numpy as np

N = int(input())
A = [0]+list(map(int, input().split()))

cumulative_sum = np.cumsum(A)
counts = Counter(cumulative_sum)
ans = 0
for v in counts.values():
    ans += v * (v-1) // 2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
N = int(input())
A = list(map(int, input().split()))
ans = 0
# print(A)
sumA = [sum(A[:i+1]) for i in range(N)]
# print(sumA)
countSum = collections.Counter(sumA)
# print(countSum)
for k,v in countSum.items():
    if k == 0:
        ans += math.factorial(v)
        continue
    if v == 1:
        continue
    # print(k)
    # print(v)
    # print(math.factorial(v-1))
    ans += math.factorial(v-1)
print(ans)

Fixed submission:
from collections import Counter
import numpy as np

N = int(input())
A = [0]+list(map(int, input().split()))

cumulative_sum = np.cumsum(A)
counts = Counter(cumulative_sum)
ans = 0
for v in counts.values():
    ans += v * (v-1) // 2
    
print(ans)