Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random
import time
import math

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

n=int(input())
a=list(map(int,input().split()))
S=[sum(a[:i])for i in range(n+1)]
s=set(S)
c=0
for i in s:
    nu=S.count(i)
    if(nu>1):c+=comb(nu,2)
print(c)

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
    
S.sort()
c=0
ch=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        ch+=1
        c+=(ch*(ch-1))//2
        ch=0
    else:ch+=1
if(ch!=0):
    ch+=1
    c+=(ch*(ch-1))//2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random
import time
import math

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

n=int(input())
a=list(map(int,input().split()))
S=[sum(a[:i])for i in range(n+1)]
s=set(S)
c=0
for i in s:
    nu=S.count(i)
    if(nu>1):c+=comb(nu,2)
print(c)

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
    
S.sort()
c=0
ch=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        ch+=1
        c+=(ch*(ch-1))//2
        ch=0
    else:ch+=1
if(ch!=0):
    ch+=1
    c+=(ch*(ch-1))//2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random
import time
import math

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

n=int(input())
a=list(map(int,input().split()))
S=[sum(a[:i])for i in range(n+1)]
C=Counter(S)

c=0
for k,v in C.items():
    if(v>1):c+=comb(v,2)
print(c)

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
    
S.sort()
c=0
ch=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        ch+=1
        c+=(ch*(ch-1))//2
        ch=0
    else:ch+=1
if(ch!=0):
    ch+=1
    c+=(ch*(ch-1))//2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
dp=[[0 for _ in range(n)]for _ in range(n)]
dp[0][0]=a[0]
c=0
for i in range(n):
    for j in range(i+1):
        dp[i][j]=dp[i-1][j]+a[i]
        if(dp[i][j]==0):c+=1
print(c)
#for i in dp:print(i)

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
    
S.sort()
c=0
ch=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        ch+=1
        c+=(ch*(ch-1))//2
        ch=0
    else:ch+=1
if(ch!=0):
    ch+=1
    c+=(ch*(ch-1))//2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
#for i in S:print(i)
m=n+1
c=0
for i in range(1,m):
    c+=S[:i].count(S[i])
print(c)

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
    
S.sort()
c=0
ch=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        ch+=1
        c+=(ch*(ch-1))//2
        ch=0
    else:ch+=1
if(ch!=0):
    ch+=1
    c+=(ch*(ch-1))//2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random
import time

n=int(input())
a=list(map(int,input().split()))
S=[sum(a[:i])for i in range(n+1)]
m=n+1
c=0
for i in range(1,m):
    for j in range(i):
        if(S[i]==S[j]):c+=1
print(c)

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
    
S.sort()
c=0
ch=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        ch+=1
        c+=(ch*(ch-1))//2
        ch=0
    else:ch+=1
if(ch!=0):
    ch+=1
    c+=(ch*(ch-1))//2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[sum(a[:i])for i in range(n+1)]
m=n+1
c=0
for i in range(1,m):
    for j in range(i):
        if(S[i]==S[j]):c+=1
print(c)

Fixed submission:
import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
    
S.sort()
c=0
ch=0
for i in range(len(S)-1):
    if(S[i]!=S[i+1]):
        ch+=1
        c+=(ch*(ch-1))//2
        ch=0
    else:ch+=1
if(ch!=0):
    ch+=1
    c+=(ch*(ch-1))//2
print(c)