Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# your code goes here
def solve(n):
	odd=0;
	even=0;
	if(n==0):
		return 1;
	if(n==1):
		return 0;
	while(n):
		if(n&1):
			odd+=1;
		if(n&2):
			even+=1;
		n=n>>2;
	return solve(abs(even-odd))
n=input()
if(solve(int(n))):
	print("Yes");
else:
	print("No");

Fixed submission:
s=input()
ans=0;
for i in s:
  ans+=int(i)
if(ans%9==0):
	print("Yes");
else:
  print("No");

Buggy python submission (verdict: Time Limit Exceeded):
# your code goes here
def solve(n):
	odd=0;
	even=0;
	if(n==0):
		return 1;
	if(n==1):
		return 0;
	while(n):
		if(n&1):
			odd+=1;
		if(n&2):
			even+=1;
		n=n>>2;
	return solve(abs(even-odd))
n=int(input())
if(solve(n)):
	print("Yes");
else:
	print("No");

Fixed submission:
s=input()
ans=0;
for i in s:
  ans+=int(i)
if(ans%9==0):
	print("Yes");
else:
  print("No");
Buggy python submission (verdict: Time Limit Exceeded):
# F - Strivore
import sys
sys.setrecursionlimit(10**8)
INF = 10**9+7
K = int(input())
S = input()
l = len(S)

def power(x,n):
    global INF
    if n==0:
        return 1
    elif n%2==0:
        return (power(x,n//2)**2)%INF
    else:
        return (x*(power(x,n//2)**2))%INF
    
kakeru = 25
waru = power(26,INF-2)

tmp = power(26,K)
ans = tmp
for i in range(1,K+1):
    tmp = (tmp*kakeru*waru)%INF
    tmp = (tmp*(l-1+i)*power(i,INF-2))%INF
    ans = (ans+tmp)%INF
print(ans)

Fixed submission:
# F - Strivore
import sys
MOD = 10**9+7
K = int(input())
S = input()
l = len(S)
ans = 0

tmp = pow(26,K,MOD)
ans = tmp
waru = pow(26,-1,MOD)

for i in range(1,K+1):
    tmp = (tmp*25*waru)%MOD
    tmp = (tmp*(l-1+i)*pow(i,-1,MOD))%MOD
    ans = (ans+tmp)%MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# F - Strivore
import sys
sys.setrecursionlimit(10**8)
INF = 10**9+7
K = int(input())
S = input()
l = len(S)

def power(x,n):
    global INF
    if n==0:
        return 1
    elif n%2==0:
        return (power(x,n//2)**2)%INF
    else:
        return (x*(power(x,n//2)**2))%INF
    
kakeru = 25
waru = power(26,INF-2)

tmp = power(26,K)
ans = tmp
for i in range(1,K+1):
    tmp = (tmp*kakeru*waru)%INF
    tmp = (tmp*(l-1+i)*power(i,INF-2))%INF
    ans = (ans+tmp)%INF
print(ans)

Fixed submission:
# F - Strivore
import sys
MOD = 10**9+7
K = int(input())
S = input()
l = len(S)
ans = 0

tmp = pow(26,K,MOD)
ans = tmp
waru = pow(26,-1,MOD)

for i in range(1,K+1):
    tmp = (tmp*25*waru)%MOD
    tmp = (tmp*(l-1+i)*pow(i,-1,MOD))%MOD
    ans = (ans+tmp)%MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# F - Strivore
import sys
sys.setrecursionlimit(10**8)
INF = 10**9+7
K = int(input())
S = input()
l = len(S)

def power(x,n):
    global INF
    if n==0:
        return 1
    elif n%2==0:
        return (power(x,n//2)**2)%INF
    else:
        return (x*(power(x,n//2)**2))%INF

def comb(n,k):
    global INF
    ans = 1
    if k>n//2:
        k = n-k
    for i in range(k):
        ans = (ans*(n-i)*power(i+1,INF-2))%INF
    return ans

ans = 0
for i in range(K+1):
    ans = (ans+power(26,i)*comb(K-i+l-1,l-1)*power(25,K-i))%INF
print(ans)

Fixed submission:
# F - Strivore
import sys
MOD = 10**9+7
K = int(input())
S = input()
l = len(S)
ans = 0

tmp = pow(26,K,MOD)
ans = tmp
waru = pow(26,-1,MOD)

for i in range(1,K+1):
    tmp = (tmp*25*waru)%MOD
    tmp = (tmp*(l-1+i)*pow(i,-1,MOD))%MOD
    ans = (ans+tmp)%MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# D - Div Game
from collections import deque

def pf(N):
    ans = deque([])
    p = 2
    while N>1:
        if N%p==0:
            k = 0
            while N%p==0:
                N //= p
                k += 1
            ans.append(k)
        p += 1+(p>2)
    return ans

def func(a):
    tmp = 0
    while True:
        a -= tmp+1
        if a<0:
            return tmp
        else:
            tmp += 1

N = int(input())
ans = 0
l = pf(N)
while len(l)>0:
    ans += func(l.popleft())
print(ans)

Fixed submission:
# D - Div Game
from collections import deque

def pf(N):
    ans = deque([])
    p = 2
    while N>1:
        if N%p==0:
            k = 0
            while N%p==0:
                N //= p
                k += 1
            ans.append(k)
        p += 1+(p>2)
        if p**2>N:
            p = N
    return ans

def func(a):
    tmp = 0
    while True:
        a -= tmp+1
        if a<0:
            return tmp
        else:
            tmp += 1

N = int(input())
ans = 0
l = pf(N)
while len(l)>0:
    ans += func(l.popleft())
print(ans)
Buggy python submission (verdict: Runtime Error):
# A - A?C
S = int(input())
if S=='ABC':
    print('ARC')
else:
    print('ABC')

Fixed submission:
# A - A?C
S = input()
if S=='ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
# E - This Message Will Self-Destruct in 5s
from bisect import *
N = int(input())
A = list(map(int,input().split()))
l = []
ans = 0
for j in range(N):
    tmp = j-A[j]
    ans += bisect_right(l,tmp)-bisect_left(l,tmp)
    insort(l,A[j]+j)
print(ans)

Fixed submission:
# E - This Message Will Self-Destruct in 5s
from bisect import *
N = int(input())
A = list(map(int,input().split()))
l = []
ans = 0
for j in range(N):
    tmp = j-A[j]
    ans += bisect_right(l,tmp)-bisect_left(l,tmp)
    insort(l,A[j]+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# C - gacha
from bisect import *
N = int(input())
ans = []
for _ in range(N):
    S = input()
    i = bisect_left(ans,S)
    if i>=len(ans) or ans[i]!=S:
        insort_left(ans,S)
print(len(ans))

Fixed submission:
# C - gacha
N = int(input())
ans = set()
for _ in range(N):
    S = input()
    ans.add(S)
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# C - gacha
from bisect import *
N = int(input())
ans = []
for _ in range(N):
    S = input()
    i = bisect_left(ans,S)
    if i>=len(ans) or ans[i]!=S:
        insort_left(ans,S)
print(len(ans))

Fixed submission:
# C - gacha
N = int(input())
ans = set()
for _ in range(N):
    S = input()
    ans.add(S)
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# C - gacha
from bisect import *
N = int(input())
ans = []
for _ in range(N):
    S = input()
    i = bisect_left(ans,S)
    if i>=len(ans) or ans[i]!=S:
        ans.insert(i,S)
print(len(ans))

Fixed submission:
# C - gacha
N = int(input())
ans = set()
for _ in range(N):
    S = input()
    ans.add(S)
print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# D - Multiple of 2019
S = input()
mod = [1]+[0]*2018
tmp = 0
for k in range(len(S)):
    tmp = (10**k*int(S[len(S)-1-k])+tmp)%2019
    mod[tmp] += 1
ans = 0
for k in range(2019):
    ans += mod[k]*(mod[k]-1)//2
print(ans)

Fixed submission:
# D - Multiple of 2019
S = input()
mod = [1]+[0]*2018
tmp = 0
seki = 1
for k in range(len(S)):
    tmp = (seki*int(S[len(S)-1-k])+tmp)%2019
    mod[tmp] += 1
    seki = (seki*10)%2019
ans = 0
for k in range(2019):
    ans += mod[k]*(mod[k]-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
# A - Lucky 7
N = input()
if '7' in a:
    print('Yes')
else:
    print('No')

Fixed submission:
# A - Lucky 7
N = input()
if '7' in N:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# C - Sum of gcd of Tuples (Easy)
from math import gcd
K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(a,b,c)
print(ans)

Fixed submission:
# C - Sum of gcd of Tuples (Easy)
from math import gcd
K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(gcd(a,b),c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# D - RGB Triplets
N = int(input())
S = input()
R = []
G = []
B = []
RG = []
GB = []
BR = []
ans = 0
for i in range(N):
    if S[i]=='R':
        R.append(i)
        for j in G:
            RG.append([j,i])
        for j in B:
            BR.append([j,i])
        for j,k in GB:
            if k-j!=i-k:
                ans += 1
    elif S[i]=='G':
        G.append(i)
        for j in B:
            GB.append([j,i])
        for j in R:
            RG.append([j,i])
        for j,k in BR:
            if k-j!=i-k:
                ans += 1
    else:
        B.append(i)
        for j in R:
            BR.append([j,i])
        for j in G:
            GB.append([j,i])
        for j,k in RG:
            if k-j!=i-k:
                ans += 1
print(ans)

Fixed submission:
# D - RGB Triplets
N = int(input())
S = input()
r,b,g = 0,0,0
for i in range(N):
    if S[i]=='R':
        r += 1
    elif S[i]=='G':
        g += 1
    else:
        b += 1
ans = r*g*b
for i in range(N):
    for j in range(i+1,N):
        k = 2*j-i
        if k<N and S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# D - RGB Triplets
N = int(input())
S = input()
R = []
G = []
B = []
RG = []
GB = []
BR = []
ans = 0
for i in range(N):
    if S[i]=='R':
        R.append(i)
        for j in G:
            RG.append([j,i])
        for j in B:
            BR.append([j,i])
        for j,k in GB:
            if k-j!=i-k:
                ans += 1
    elif S[i]=='G':
        G.append(i)
        for j in B:
            GB.append([j,i])
        for j in R:
            RG.append([j,i])
        for j,k in BR:
            if k-j!=i-k:
                ans += 1
    else:
        B.append(i)
        for j in R:
            BR.append([j,i])
        for j in G:
            GB.append([j,i])
        for j,k in RG:
            if k-j!=i-k:
                ans += 1
print(ans)

Fixed submission:
# D - RGB Triplets
N = int(input())
S = input()
r,b,g = 0,0,0
for i in range(N):
    if S[i]=='R':
        r += 1
    elif S[i]=='G':
        g += 1
    else:
        b += 1
ans = r*g*b
for i in range(N):
    for j in range(i+1,N):
        k = 2*j-i
        if k<N and S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# D - Lunlun Number
K = int(input())
lun = [1,2,3,4,5,6,7,8,9]
for i in range(K-1):
    x = lun.pop(0)
    if x%10>0:
        lun.append(10*x+x%10-1)
    lun.append(10*x+x%10)
    if x%10<9:
        lun.append(10*x+x%10+1)
print(lun.pop(0))

Fixed submission:
# D - Lunlun Number
from collections import deque
K = int(input())
lun = deque([1,2,3,4,5,6,7,8,9])
for i in range(K-1):
    x = lun.popleft()
    if x%10>0:
        lun.append(10*x+x%10-1)
    lun.append(10*x+x%10)
    if x%10<9:
        lun.append(10*x+x%10+1)
print(lun.popleft())

Buggy python submission (verdict: Time Limit Exceeded):
# D - Lunlun Number
K = int(input())
lun = [1,2,3,4,5,6,7,8,9]
for i in range(K-1):
    x = lun.pop(0)
    if x%10>0:
        lun.append(10*x+x%10-1)
    lun.append(10*x+x%10)
    if x%10<9:
        lun.append(10*x+x%10+1)
print(lun.pop(0))

Fixed submission:
# D - Lunlun Number
from collections import deque
K = int(input())
lun = deque([1,2,3,4,5,6,7,8,9])
for i in range(K-1):
    x = lun.popleft()
    if x%10>0:
        lun.append(10*x+x%10-1)
    lun.append(10*x+x%10)
    if x%10<9:
        lun.append(10*x+x%10+1)
print(lun.popleft())
Buggy python submission (verdict: Runtime Error):
# A - Coffee
S = int(input())
if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')

Fixed submission:
# A - Coffee
S = input()
if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
# E - Dividing Chocolate
import sys
sys.setrecursionlimit(10000)

H,W,K = map(int,input().split())
S = [input() for _ in range(H)]
ans = 10000

def check(border, num):
    global H,W,K,S
    now = [0]*(num+1)
    add = 0
    for j in range(W):
        tmp = [0]*(num+1)
        for i in range(H):
            now[border[i]] += int(S[i][j])
            tmp[border[i]] += int(S[i][j])
        if max(now)>K:
            add += 1
            now = tmp
    return num+add

def rec(border, num, i):
    global H,W,K,S,ans
    if i<H:
        border[i] = num
        rec(border, num, i+1)
        border[i] = num+1
        rec(border, num+1, i+1)
    else:
        ans = min(ans, check(border, num))

rec([0]*H, 0, 1)
print(ans)

Fixed submission:
# E - Dividing Chocolate
import sys
sys.setrecursionlimit(10000)

H,W,K = map(int,input().split())
S = [input() for _ in range(H)]
ans = 10000

def check(border, num):
    global H,W,K,S
    now = [0]*(num+1)
    add = 0
    for j in range(W):
        tmp = [0]*(num+1)
        for i in range(H):
            now[border[i]] += int(S[i][j])
            tmp[border[i]] += int(S[i][j])
        if max(now)>K:
            add += 1
            now = tmp
        if max(tmp)>K:
            return 10000
    return num+add

def rec(border, num, i):
    global H,W,K,S,ans
    if i<H:
        border[i] = num
        rec(border, num, i+1)
        border[i] = num+1
        rec(border, num+1, i+1)
    else:
        ans = min(ans, check(border, num))

rec([0]*H, 0, 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

######################################################

N,A=ilint()
C=counter()
C.add(-1,3)
ans=1
for a in A:
    C.add(a,1)
    ans*=C[a-1]-C[a]+1
    ans%=MOD
print(ans)

Fixed submission:
# E - Colorful Hats 2
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
count = [0]*N+[3]
used = [0]*(N+1)
ans = 1
for x in A:
    ans = (ans*(count[x-1]-used[x-1]))%MOD
    count[x] += 1
    used[x-1] += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
# A - 01 Matrix
H,W,A,B = map(int,input().split())
if H==1:
    for _ in range(A):
        print(1,end='')
    for _ in range(W-A):
        print(0,end='')
    print('')
elif W==1:
    for _ in range(B):
        print(1)
    for _ in range(H-B):
        print(0)
elif H*A!=W*B:
    print('No')
else:
    for i in range(H):
        for j in range(W):
            if (-A*(i//B)+j)%W<A:
                print(1,end='')
            else:
                print(0,end='')
        print('')

Fixed submission:
# A - 01 Matrix
H,W,A,B = map(int,input().split())
for i in range(H):
    for j in range(W):
        print((int(i<B)+int(j<A))%2,sep='',end='')
    print('')
Buggy python submission (verdict: Runtime Error):
# A - XOR Circle

N = int(input())
a = list(map(int,input().split()))
a.sort()

if a[N-1]==0:
    ans = 'Yes'
elif N%3!=0:
    ans = 'No'
elif a[0]==a[N//3-1] and a[N//3]==a[2*N//3-1] and a[2*N//3]==a[N-1] and x^y^z==0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Fixed submission:
# A - XOR Circle

N = int(input())
a = list(map(int,input().split()))
a.sort()

if a[N-1]==0:
    ans = 'Yes'
elif N%3!=0:
    ans = 'No'
elif a[0]==a[N//3-1] and a[N//3]==a[2*N//3-1] and a[2*N//3]==a[N-1] and a[0]^a[N//3]^a[2*N//3]==0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Buggy python submission (verdict: Runtime Error):
# A - XOR Circle

N = int(input())
a = list(map(int,input().split()))
a.sort()

if a[N-1]==0:
    ans = 'Yes'
elif n%3!=0:
    ans = 'No'
elif a[0]==a[N//3-1] and a[N//3]==a[2*N//3-1] and a[2*N//3]==a[N-1] and x^y^z==0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Fixed submission:
# A - XOR Circle

N = int(input())
a = list(map(int,input().split()))
a.sort()

if a[N-1]==0:
    ans = 'Yes'
elif N%3!=0:
    ans = 'No'
elif a[0]==a[N//3-1] and a[N//3]==a[2*N//3-1] and a[2*N//3]==a[N-1] and a[0]^a[N//3]^a[2*N//3]==0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Buggy python submission (verdict: Runtime Error):
# A - XOR Circle

N = int(input())
a = list(map(int,input().split()))
a.sort()

if a[N-1]==0 and a[N]==a[3*N-1]:
    ans = 'Yes'
elif a[0]==a[N-1] and a[N]==a[2*N-1] and a[2*N]==a[3*N-1] and x^y^z==0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Fixed submission:
# A - XOR Circle

N = int(input())
a = list(map(int,input().split()))
a.sort()

if a[N-1]==0:
    ans = 'Yes'
elif N%3!=0:
    ans = 'No'
elif a[0]==a[N//3-1] and a[N//3]==a[2*N//3-1] and a[2*N//3]==a[N-1] and a[0]^a[N//3]^a[2*N//3]==0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Buggy python submission (verdict: Runtime Error):
# A - XOR Circle

N = int(input())
a = list(map(int,input().split()))
a.sort()

if a[N-1]==0 and a[N]==a[3*N-1]:
    ans = 'Yes'
elif a[0]==a[N-1] and a[N]==a[2*N-1] and a[2*N]==a[3*N-1] and x|y|z==0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Fixed submission:
# A - XOR Circle

N = int(input())
a = list(map(int,input().split()))
a.sort()

if a[N-1]==0:
    ans = 'Yes'
elif N%3!=0:
    ans = 'No'
elif a[0]==a[N//3-1] and a[N//3]==a[2*N//3-1] and a[2*N//3]==a[N-1] and a[0]^a[N//3]^a[2*N//3]==0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)
Buggy python submission (verdict: Runtime Error):
# B - ATCoder
S = int(input())
ans = 0
tmp = 0
for i in range(len(S)):
    if S[i] in ['A','C','G','T']:
        tmp += 1
    else:
        ans = max(ans,tmp)
        tmp = 0
ans = max(ans,tmp)
print(ans)

Fixed submission:
# B - ATCoder
S = input()
ans = 0
tmp = 0
for i in range(len(S)):
    if S[i] in ['A','C','G','T']:
        tmp += 1
    else:
        ans = max(ans,tmp)
        tmp = 0
ans = max(ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
# A - Colorful Subsequence
import numpy as np

N,S = int(input()),input()
count = np.zeros(26)

for i in range(N):
    count[ord(S[i])-ord('a')] += 1

ans = 1
for i in range(N):
    ans *= (count[i]+1)

print((ans-1)%(10**9+7))

Fixed submission:
# A - Colorful Subsequence
import numpy as np

N,S = int(input()),input()
count = np.zeros(26)

for i in range(N):
    count[ord(S[i])-ord('a')] += 1

ans = 1
D =10**9+7

for i in range(26):
    ans = int((ans*(count[i]+1))%D)

print(ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
# A - Zero-Sum Ranges
import numpy as np

N = int(input())
A = list(map(int, input().split()))
S = np.zeros(N)
ans = 0

for j in range(N):
    for i in range(N-j):
        S[i] += A[i+j]
        ans += int(S[i]==0)

print(ans)

Fixed submission:
# A - Zero-Sum Ranges
import numpy as np

N = int(input())
A = list(map(int, input().split()))
S = np.zeros(N+1)
ans = 0

for i in range(N):
    S[i+1] = S[i] + A[i]

S.sort()
tmp = 1

for i in range(N):
    if S[i]==S[i+1]:
        tmp += 1
    else:
        ans += tmp * (tmp-1) // 2
        tmp = 1
ans += tmp * (tmp-1) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,P = ilint()
ans = 0

def swap(i):
    P[i],P[i+1] = P[i+1],P[i]
    ans += 1

for i in range(N-1):
    if P[i]==i+1:
        swap(i)
if P[-1]==N:
    swap(N-1)
print(ans)

Fixed submission:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,P = ilint()
ans = 0

def swap(i):
    global ans
    P[i],P[i+1] = P[i+1],P[i]
    ans += 1

for i in range(N-1):
    if P[i]==i+1:
        swap(i)
if P[-1]==N:
    swap(N-2)
print(ans)
Buggy python submission (verdict: Runtime Error):
# A - Getting Difference
import math
from functools import reduce

N, K = map(int, input().split())
A = list(map(int, input().split()))

gcd = reduce(math.gcd, A) 

if max(A)>=K and K%gcd==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Fixed submission:
# A - Getting Difference
import fractions
from functools import reduce

N, K = map(int, input().split())
A = list(map(int, input().split()))

gcd = reduce(fractions.gcd, A) 

if max(A)>=K and K%gcd==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
# A - A+...+B Problem

N, A, B = map(int, input())

if A>B or (N==1 and A!=B):
    print(0)
else:
    print((N-1)*B+A - (N-1)*A+B + 1)

Fixed submission:
# A - A+...+B Problem

N, A, B = map(int, input().split())

if A>B or (N==1 and A!=B):
    print(0)
else:
    print((N-2)*(B-A)+1)