Buggy python submission (verdict: Runtime Error):
N=int(input())
S=["" for i in range(N)]

for i in range(N):
    S[i]=input()

count=0

for l in range(N):
    JUDGE=1
    for j in range(N):
        for k in range(j+1,N):
            
            if S[j][k-l]!=S[k][j-l]:
                JUDGE=0
                break
        if JUDGE==0:
            break

    if JUDGE==1:
        count+=1

print(count*N)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
 
count=0
score=0

SUM=[0 for i in range(N+1)]
SUM[0]=0
 
for i in range(1,N+1):
    SUM[i]=SUM[i-1]+A[i-1]

    
SUM.sort()



for i in range(1,N+1):
    if SUM[i]==SUM[i-1]:
        count=count+1
    else:
        if count!=0:
            score=score+count*(count+1)//2
        count=0
        
if count!=0:
    score=score+count*(count+1)//2

 
print(score)

Buggy python submission (verdict: Time Limit Exceeded):
import math

N=int(input())
A=list(map(int,input().split()))
 
count=0
score=0
SUM=[0]
 
for i in range(N):
    SUM=SUM+[SUM[i]+A[i]]

    
SUM.sort()



for i in range(1,len(SUM)):
    if SUM[i]==SUM[i-1]:
        count=count+1
    else:
        if count!=0:
            score=score+math.factorial(count)
        count=0
        
if count!=0:
    score=score+math.factorial(count)

 
print(score)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
 
count=0
score=0

SUM=[0 for i in range(N+1)]
SUM[0]=0
 
for i in range(1,N+1):
    SUM[i]=SUM[i-1]+A[i-1]

    
SUM.sort()



for i in range(1,N+1):
    if SUM[i]==SUM[i-1]:
        count=count+1
    else:
        if count!=0:
            score=score+count*(count+1)//2
        count=0
        
if count!=0:
    score=score+count*(count+1)//2

 
print(score)

Buggy python submission (verdict: Time Limit Exceeded):
import math

N=int(input())
A=list(map(int,input().split()))
 
count=0
score=0
SUM=[0]
 
for i in range(N):
    SUM=SUM+[SUM[i]+A[i]]

    
SUM.sort()



for i in range(1,len(SUM)):
    if SUM[i]==SUM[i-1]:
        count=count+1
    else:
        if count!=0:
            score=score+math.factorial(count)
        count=0
        
if count!=0:
    score=score+math.factorial(count)

 
print(score)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
 
count=0
score=0

SUM=[0 for i in range(N+1)]
SUM[0]=0
 
for i in range(1,N+1):
    SUM[i]=SUM[i-1]+A[i-1]

    
SUM.sort()



for i in range(1,N+1):
    if SUM[i]==SUM[i-1]:
        count=count+1
    else:
        if count!=0:
            score=score+count*(count+1)//2
        count=0
        
if count!=0:
    score=score+count*(count+1)//2

 
print(score)

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

count=0

SUM=["" for i in range(N)]
SUM[0]=A[0]

for i in range(1,N):
    SUM[i] = SUM[i-1]+A[i]

for i in range(N):
    if SUM[i]==0:
        count=count+1

for i in range(1,N):
    for j in range(i-1):
        if SUM[i]-SUM[j]==0:
            count=count+1


print(count)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
 
count=0
score=0

SUM=[0 for i in range(N+1)]
SUM[0]=0
 
for i in range(1,N+1):
    SUM[i]=SUM[i-1]+A[i-1]

    
SUM.sort()



for i in range(1,N+1):
    if SUM[i]==SUM[i-1]:
        count=count+1
    else:
        if count!=0:
            score=score+count*(count+1)//2
        count=0
        
if count!=0:
    score=score+count*(count+1)//2

 
print(score)