Buggy python submission (verdict: Time Limit Exceeded):
import collections
from itertools import accumulate, combinations

n = int(input())
a = list(map(int,input().split()))
ac = [0] + list(accumulate(a))
c = collections.Counter(ac)

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += len(list(combinations(list(range(v)),2)))
print(cnt)

Fixed submission:
import math
from collections import Counter
from itertools import accumulate

def P(n,r):
    return math.factorial(n)//math.factorial(n-r)

def C(n,r):
    return P(n,r)//math.factorial(r)

n = int(input())
a = list(map(int,input().split()))
ac = [0] + list(accumulate(a))
c = Counter(ac)

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += C(v,2)
print(cnt)

Buggy python submission (verdict: Runtime Error):
import collections
from itertools import accumulate
from scipy.special import comb

n = int(input())
a = list(map(int,input().split()))
ac = [0] + list(accumulate(a))
c = collections.Counter(ac)

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += comb(v,2,exact=True)
print(cnt)

Fixed submission:
import math
from collections import Counter
from itertools import accumulate

def P(n,r):
    return math.factorial(n)//math.factorial(n-r)

def C(n,r):
    return P(n,r)//math.factorial(r)

n = int(input())
a = list(map(int,input().split()))
ac = [0] + list(accumulate(a))
c = Counter(ac)

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += C(v,2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(1,n+1):
    for j in range(n-i+1):
        if sum(a[j:j+i]) == 0:
            cnt += 1
print(cnt)

Fixed submission:
import math
from collections import Counter
from itertools import accumulate

def P(n,r):
    return math.factorial(n)//math.factorial(n-r)

def C(n,r):
    return P(n,r)//math.factorial(r)

n = int(input())
a = list(map(int,input().split()))
ac = [0] + list(accumulate(a))
c = Counter(ac)

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += C(v,2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
m = 1
for i in range(n):
    for j in range(m,n+1):
        if sum(a[i:j]) == 0:
            cnt += 1
    m += 1
print(cnt)

Fixed submission:
import math
from collections import Counter
from itertools import accumulate

def P(n,r):
    return math.factorial(n)//math.factorial(n-r)

def C(n,r):
    return P(n,r)//math.factorial(r)

n = int(input())
a = list(map(int,input().split()))
ac = [0] + list(accumulate(a))
c = Counter(ac)

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += C(v,2)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
s = 0
cnt = 0
m = 0
for i in range(n):
    for j in range(m,n):
        s += a[j]
        if s == 0:
            cnt += 1
    m += 1
    s = 0
print(cnt)

Fixed submission:
import math
from collections import Counter
from itertools import accumulate

def P(n,r):
    return math.factorial(n)//math.factorial(n-r)

def C(n,r):
    return P(n,r)//math.factorial(r)

n = int(input())
a = list(map(int,input().split()))
ac = [0] + list(accumulate(a))
c = Counter(ac)

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += C(v,2)
print(cnt)