Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
dic_S = {0:[0]}
S = 0
ans = 0
for i in range(n):
    S += a[i]
    if S not in dic_S:
        dic_S[S] = []
    else:
        pass
    dic_S[S].append(a[i])
    

for k in dic_S.keys():
    I = len(dic_S[k])
    if 3 <= I:
        ans += (I*(I-1))// *2
    elif I == 2:
        ans += 1
    else:
        pass
print(ans)


Fixed submission:
import math
n = int(input())
a = list(map(int,input().split()))
dic_S = {0:[0]}
S = 0
ans = 0
for i in range(n):
    S += a[i]
    if S not in dic_S:
        dic_S[S] = []
    else:
        pass
    dic_S[S].append(a[i])
    

for k in dic_S.keys():
    I = len(dic_S[k])
    if 3 <= I:
        ans += math.factorial(I) // (math.factorial(I-2)*2)
    elif I == 2:
        ans += 1
    else:
        pass
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
a = list(map(int,input().split()))
list_S = [0]
S = 0
ans = 0
for i in range(n):
    S += a[i]
    list_S.append(S)
S_set = list(set(list_S))
for i in range(len(S_set)):
    I = list_S.count(S_set[i])
    if 3 <= I:
        ans += math.factorial(I) // (math.factorial(I-2)*2)
    elif I == 2:
        ans += 1
    else:
        pass
print(ans)


Fixed submission:
import math
n = int(input())
a = list(map(int,input().split()))
dic_S = {0:[0]}
S = 0
ans = 0
for i in range(n):
    S += a[i]
    if S not in dic_S:
        dic_S[S] = []
    else:
        pass
    dic_S[S].append(a[i])
    

for k in dic_S.keys():
    I = len(dic_S[k])
    if 3 <= I:
        ans += math.factorial(I) // (math.factorial(I-2)*2)
    elif I == 2:
        ans += 1
    else:
        pass
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
a = list(map(int,input().split()))
list_S = []
ans = 0
for i in range(n+1):
    S = sum(a[0:i])
    list_S.append(S)
S_set = list(set(list_S))
for i in range(len(S_set)):
    I = list_S.count(S_set[i])
    if I <= 1:
        pass
    elif I == 2:
        ans += 1
    else:
        ans += math.factorial(I) // (math.factorial(I-2)*2)
print(ans)


Fixed submission:
import math
n = int(input())
a = list(map(int,input().split()))
dic_S = {0:[0]}
S = 0
ans = 0
for i in range(n):
    S += a[i]
    if S not in dic_S:
        dic_S[S] = []
    else:
        pass
    dic_S[S].append(a[i])
    

for k in dic_S.keys():
    I = len(dic_S[k])
    if 3 <= I:
        ans += math.factorial(I) // (math.factorial(I-2)*2)
    elif I == 2:
        ans += 1
    else:
        pass
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0

for i in range(n):
    wa = 0
    for j in range(n-i):
        wa += a[i+j]
        if wa == 0:
            ans += 1
        else:
            pass

print(ans)

Fixed submission:
import math
n = int(input())
a = list(map(int,input().split()))
dic_S = {0:[0]}
S = 0
ans = 0
for i in range(n):
    S += a[i]
    if S not in dic_S:
        dic_S[S] = []
    else:
        pass
    dic_S[S].append(a[i])
    

for k in dic_S.keys():
    I = len(dic_S[k])
    if 3 <= I:
        ans += math.factorial(I) // (math.factorial(I-2)*2)
    elif I == 2:
        ans += 1
    else:
        pass
print(ans)