Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
R=min(R, L+673)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))


Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))

Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    mod=(i*j)%2019
    if mod==0:
      break
    li.append(mod)
print(min(li))

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
X = []
for _ in range(n):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    s = sum((X[i][d] - X[j][d])**2 for d in range(d))
      if (s ** .5).is_integer():
        ans += 1
print(ans)


Fixed submission:
n, d = map(int, input().split())
X = []
for _ in range(n):
    X.append([int(x) for x in input().split()])
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        s = sum((X[i][d] - X[j][d])**2 for d in range(d))
        if any(k**2 == s for k in range(1000)):
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      if i*j>=2019**2:
        break
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))


Fixed submission:
L,R=map(int,input().split())
R=min(R, L+2019)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))

Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    while i*j<2019**2:
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))


Fixed submission:
L,R=map(int,input().split())
R=min(R, L+2019)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))

Buggy python submission (verdict: Time Limit Exceeded):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    mod=(i*j)%2019
    li.append(mod)
    if mod==0:
      break
print(min(li))


Fixed submission:
L,R=map(int,input().split())
R=min(R, L+2019)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))

Buggy python submission (verdict: Time Limit Exceeded):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    mod=(i*j)%2019
    li.append(mod)
print(min(li))

Fixed submission:
L,R=map(int,input().split())
R=min(R, L+2019)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))

Buggy python submission (verdict: Time Limit Exceeded):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    q,mod=divmod(i*j, 2019)
    li.append(mod)
    if i ==j:
      break
print(min(li))

Fixed submission:
L,R=map(int,input().split())
R=min(R, L+2019)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))

Buggy python submission (verdict: Time Limit Exceeded):
L,R=map(int,input().split())
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
    q,mod=divmod(i*j, 2019)
    li.append(mod)
    if i ==j:
      break
print(min(li))

Fixed submission:
L,R=map(int,input().split())
R=min(R, L+2019)
li=[]
for i in range(L,R):
  for j in range(i+1,R+1):
      mod=(i*j)%2019
      li.append(mod)
      if mod==0:
        break
print(min(li))
Buggy python submission (verdict: Runtime Error):
N = int(input())
P= [int(x) for x in input().split]

answer=0
for i in range(1,N-1):
  a,b,c=P[i-1:i+2]
  if b != max(a,b,c) and b!= min(a,b,c):
    answer+=1

print(answer)

Fixed submission:
n = input()
s = sorted(list(n))
if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:print("Yes")
else: print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
P= [int(x) for x in input().split]

answer=0
for i in range(1,N-1):
  a,b,c=P[i-1:i+2]
  if b != max(a,b,c) and b!= min(a,b,c):
    answer+=1

print(answer)


Fixed submission:
N = int(input())
P = [int(x) for x in input().split()]
#とりまリストに入れる。
answer = 0
for i in range(1,N-1):
  #iがN-2まででいい理由は次行で最終項目までカバーするから
  a,b,c = P[i-1:i+2]
  if b != min(a,b,c) and b != max(a,b,c):
    #三つのうち真ん中というのは最大でも最小でもないということ。
    answer += 1

print(answer)
Buggy python submission (verdict: Runtime Error):
X, A = map(int,input().split())
print(0) if X < A
print(10) if X >= A

Fixed submission:
X,A = map(int,input().split())
if X < A:print(0)
else:print(10)
Buggy python submission (verdict: Runtime Error):
n=int(input())
list=[]
for i in range(n):
  s,p=input().split()
  list.append((s, -int(p), i+1))
list.sort()
for s,p,i in list:
  print(i)

Fixed submission:
a,p = map(int,input().split())
print((3*a+p)//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
listv=[int(x) for x in input().split()]
listc=[int(y) for y in input().split()]
values=[x - y for (x, y) in zip(listv, listc)]
ans = 0
for i in values:
  if i>0:
    ans+=i
print(ans)

Fixed submission:
a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""

Buggy python submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
c = t // a
if t >= a:print(b*c)
else:print(0)

Fixed submission:
a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""

Buggy python submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
c = t//a
if t >= a:print(b*c)
else:print(0)

Fixed submission:
a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""

Buggy python submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
if t >= a:print((t//a)*b)
else:print(0)

Fixed submission:
a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""

Buggy python submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
if t >= a:print(b*(t//a))
else:print(0)

Fixed submission:
a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""

Buggy python submission (verdict: Runtime Error):
a,b,t=map(int,input.split())
if t > a:print(b*(t//a))
else:print(0)

Fixed submission:
a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
N=int(input())
A=list(map(int,input().split()))
ans=0
def gcd(n):
  return reduce(fractions.gcd, n)

for i in range(N):
  li=A[:i]+A[i+1:]
  x=gcd(li)
  if x>ans:
    ans=x
print(ans)

Fixed submission:
import fractions
N=int(input())
A=list(map(int,input().split()))
ans=0  #更新用
#端っこの処理用
l=[0]*(N+1)
r=[0]*(N+1)
for i in range(N):
  l[i+1]=(fractions.gcd(l[i],A[i]))
  r[N-i-1]=(fractions.gcd(r[N-i],A[N-1-i]))
for j in range(N):
  ans=max(ans,fractions.gcd(l[j],r[j+1]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import copy
from functools import reduce
N=int(input())
A=list(map(int,input().split()))
B=[]
c=0
def gcd(*n):
  return reduce(fractions.gcd, n)
for i in range(N):
  c=copy.deepcopy(A[i])
  A.pop(i)
  B.append(gcd(*A))
  A.insert(i,c)
  c=0
print(max(B))

Fixed submission:
import fractions
N=int(input())
A=list(map(int,input().split()))
ans=0  #更新用
#端っこの処理用
l=[0]*(N+1)
r=[0]*(N+1)
for i in range(N):
  l[i+1]=(fractions.gcd(l[i],A[i]))
  r[N-i-1]=(fractions.gcd(r[N-i],A[N-1-i]))
for j in range(N):
  ans=max(ans,fractions.gcd(l[j],r[j+1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
ans="No"
if A>B:
  if B<C and C<A:
    ans="Yes"
elif A<B:
    if A<C and C<B:
    ans="Yes"
print(ans)  

Fixed submission:
A,B,C=map(int,input().split())
ans="No"
if A>B:
  if B<C and C<A:
    ans="Yes"
elif A<B:
  if A<C and C<B:
    ans="Yes"
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
b=0
w=S.count(".")
ans=b+w
for s in S:
  if s=="#":
    b+=1
  else:
	w-=1
  ans=min(ans, b+w)
print(ans)

Fixed submission:
N=int(input())
S=input()
b=0
w=S.count(".")
ans=b+w
for s in S:
  if s=="#":
    b+=1
  else:
    w-=1
  ans=min(ans, b+w)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
a=[S[:i].count("#")+S[i+1:].count(".") for i in range(N)]
print(min(a))

Fixed submission:
N=int(input())
S=input()
b=0
w=S.count(".")
ans=b+w
for s in S:
  if s=="#":
    b+=1
  else:
    w-=1
  ans=min(ans, b+w)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
a=[S[:i].count("#")+S[i+1:].count(".") for i in range(N)]
print(min(a))

Fixed submission:
N=int(input())
S=input()
b=0
w=S.count(".")
ans=b+w
for s in S:
  if s=="#":
    b+=1
  else:
    w-=1
  ans=min(ans, b+w)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(a+b, 2*a-1, 2*b-1) 

Fixed submission:
a,b = map(int,input().split())
if a== b:print(a+b)
else:print(2*(a+b -min(a,b))-1)

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a!= b:print(2*(a+b -min(a,b))-1)
else:print(2a-1)


Fixed submission:
a,b = map(int,input().split())
if a== b:print(a+b)
else:print(2*(a+b -min(a,b))-1)
Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
S=input()
li=[]
t=0
for i in range(1,N):
  if S[i-1:i+1]=="AC":
      t+=1
  li.append(t)
for _ in range(Q):
  l,r=map(int,input().split())
  print(li[r-1]-li[l-1])


Fixed submission:
dna={"A":"T", "T":"A", "C":"G", "G":"C"}
print(dna[input()])
Buggy python submission (verdict: Runtime Error):
s=input()
list=["A","C","G","T"]
new=[]
a=0
for i in s:
  if i in list:
    a+=1
  if i not in list:
    new.append(a)
    a=0
print(max(new))

Fixed submission:
s=input()
n=len(s)
list=["A","C","G","T"]
new=[]
a=0
for i in range(n):
  if s[i] in list:
    a+=1
    if i == n-1:
      new.append(a)
  if s[i] not in list:
    new.append(a)
    a=0
print(max(new))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
li=[list(map(int,input().split())) for _ in range(Q)]
t=0
li2=[]
for i,j in li:
    if "A" in S[i-1:j]:
      s=S[i-1:j].count("AC")
      li2.append(s)
for l in li2:
  print(l)

Fixed submission:
N,Q=map(int,input().split())
S=input()
li=[0]*N
t=0
for i in range(N-1):
  if S[i:i+2]=="AC":
      t+=1
  li[i+1]=t
for _ in range(Q):
  l,r=map(int,input().split())
  print(li[r-1]-li[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
for i in range(Q):
  l,r=map(int,input().split())
  AC=S[l-1:r]
  print(AC.count("AC") )

Fixed submission:
N,Q=map(int,input().split())
S=input()
li=[0]*N
t=0
for i in range(N-1):
  if S[i:i+2]=="AC":
      t+=1
  li[i+1]=t
for _ in range(Q):
  l,r=map(int,input().split())
  print(li[r-1]-li[l-1])
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(min(b//a, c)

Fixed submission:
a,b,c=map(int,input().split())
print(min(b//a,c))
Buggy python submission (verdict: Runtime Error):
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
  if cur == N:
  return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
ret0 = dfs(cur + 1, a, b, c)
ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Fixed submission:
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy python submission (verdict: Runtime Error):
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
if cur == N:
return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
ret0 = dfs(cur + 1, a, b, c)
ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Fixed submission:
#コピペAC
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=input()
B=input()
C=input()
ans=0
for i in range(N):
  ans+=len(set(A[i],B[i],C[i]))-1
print(ans) 

Fixed submission:
N=int(input())
A=input()
B=input()
C=input()
ans=0
for i in range(N):
  ans+=len(set([A[i],B[i],C[i]]))-1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=int(input())
li=[s]
for i in range(1000000):
  if s%2==0:
    s=s//2
  else:
    s=3*s+1
  if s in li:
    print(i+2)
    break
  li.append(s)


Fixed submission:
ab,bc,ca=map(int,input().split())
print(ab*bc//2)
Buggy python submission (verdict: Runtime Error):
N=int(input())
h=[0]+list(map(int,input().split()))
c=0
for i in range(N):
  c+=max(h[i+1]-l[i],0)
print(c)

Fixed submission:
N=int(input())
h=list(map(int, input().split()))
c=i=0
while sum(h)>0:
  if h[i]>0:
    j=i
    c+=1
    while j<N and h[j]>0:
      h[j]-=1
      j+=1
  else:
    i+=1
print(c)
Buggy python submission (verdict: Runtime Error):
N=int(input())
P=[int(input()) for i in range (N)]
print(sum(N) - max(N)//2)

Fixed submission:
N=int(input())
P=[int(input()) for i in range (N)]
print(sum(P) - max(P)//2)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, S: str, T: str):
    # from math import gcd
    from fractions import gcd

    def lcm(a: int, b: int):
        return (a * b) // gcd(a, b)

    l = lcm(N, M)

    x = [''] * l

    for i in range(N):
        x[i*(l//N)] = S[i]

    for i in range(M):
        if(x[i*(l//M)] != '' and x[i*(l//M)] != T[i]):
            print(-1)
            exit()
        else:
            x[i*(l//M)] = T[i]

    

    print(l)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(N, M, S, T)

if __name__ == '__main__':
    main()


Fixed submission:
N,M=map(int,input().split())
S=input()
T=input()
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
g=gcd(N,M)
L=N*M//g
if all(S[i*N//g]==T[i*M//g]for i in range(g)):
  print(L)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(max(abc)*10 + a + b + c - max(abc))


Fixed submission:
a,b,c=map(int,input().split())
print(max(a,b,c)*10 + a + b + c - max(a,b,c))

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int(input()))
print(max(abc)*10 + a + b + c - max(abc))

Fixed submission:
a,b,c=map(int,input().split())
print(max(a,b,c)*10 + a + b + c - max(a,b,c))
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
l=[input() for i in range(h)]
li=[]
li4=[]
for L in l:
  if (L=="."*w):
    continue
  li.append(L)
  li2=[list(x) for x in zip(*li)]
  ll=len(li2[0])
for i in range(h):
  li3=[''.join(li2[i])]
  for L in li3:
    if (L=="."*ll):
      continue
    li4.append(L)
    li5=[list(x) for x in zip(*li4)]
for i in range(ll):
  li6=[''.join(li5[i])]
  for L in li6:
    print(L)

Fixed submission:
H,W=map(int,input().split())
L=[list(input()) for _ in range(H)]
L=[l for l in L if "#" in l]
#リストの中のリストで#を含まないリストは取り除く
LL=list(zip(*L))
#同じサブインデックスをもつ要素からなる配列を作る
LL=[l for l in LL if "#" in l]
L=list(zip(*LL))
for l in L:
  print("".join(l))
Buggy python submission (verdict: Runtime Error):
S=input()
ans="WA"
if S[0]=="A" and S[2:-1].count("C")==1:
  s=S.find("C",2,-1)-
  SS=S[1:s]+S[s+1:]
  if SS.islower() is True:
    ans="AC"
print(ans)

Fixed submission:
S=input()
ans="WA"
for i in range(len(S)):
  if S[i]=="A" and S[2:-1].count("C")==1:
    s=S.find("C",2,-1)-1
    SS=S[1:]
    SS=SS[:s]+SS[s+1:]
    if SS.islower() is True:
      ans="AC"
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
abc = sorted(list(n))
print(max(abc) - min(abc))

Fixed submission:
a,b,c=map(int,input().split())
print(max(a,b,c) - min(a,b,c))
Buggy python submission (verdict: Runtime Error):
n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(1,n):
  if li[i] == li[i+1]:
    li[i] = 0
    a+=1
print(a)   

Fixed submission:
n=int(input())
li = list(map(int,input().split()))
a=0
for i in range(1,n):
  if li[i] == li[i-1]:
    li[i] = 0
    a+=1
print(a)
Buggy python submission (verdict: Runtime Error):
s=input()
print(count("+") - count("-"))

Fixed submission:
s=input()
print(s.count("+") - s.count("-"))
Buggy python submission (verdict: Runtime Error):
D,N=map(int, input().split())
ans=0
if D==0:
  ans=N
elif D==1:
  ans=100*N
elif D==2:
  ans=10000*N
if N==100 ans D==2:
  ans+=ans
  #N=100の時は100で割り切れてしまうから、N=101にする
print(ans)


Fixed submission:
D,N=map(int, input().split())
x=100**D
ans=x*N
if N==100:
  ans+=x
  #N=100の時は100で割り切れてしまうから、N=101にする
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
a=300000
for i in range(N):
  t=S[:i].count("W")+S[i+1:].count("E")
  if t<a:
    a=t
print(a)

Fixed submission:
N = int(input())
S = input()

W = [0 for k in range(N)]
E = [0 for k in range(N)]

for k in range(1,N):
    if S[k-1] == "W":
        W[k] = W[k-1] + 1
    else:
        W[k] = W[k-1]

for k in range(1,N):
    if S[N-k] == "E":
        E[N-k-1] = E[N-k] + 1
    else:
        E[N-k-1] = E[N-k]

ans = 10**9
for k in range(N):
    ans = min(W[k]+E[k],ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
c=i=0
j=1
while i<N:
  x=sum(A[i:j])
  if x==0:
    c+=1
    j+=1
  else:
    j+=1
  if j==N+1:
    i+=1
    j=i+1
print(c)

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
b=ans=0
c=collections.Counter([0])
for a in A:
  b+=a
  ans+=c[b]
  c[b]+=1
print(ans)

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

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
b=ans=0
c=collections.Counter([0])
for a in A:
  b+=a
  ans+=c[b]
  c[b]+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
A=[int(input()) for _ in range(m)]
start=0
goal=0
for i in range(x, n+1):
  for a in A:
    if i ==a:
      start+=1
for j in range(x):
  for a in A:
    if i ==a:
      goal+=1
print(min(start, goal))

Fixed submission:
n,m,x=map(int,input().split())
A=[int(x) for x in input().split()]
start=0
goal=0
for i in range(x, n+1):
  for a in A:
    if i ==a:
      start+=1
for j in range(x):
  for a in A:
    if j ==a:
      goal+=1
print(min(start, goal))
Buggy python submission (verdict: Time Limit Exceeded):
import statistics
import math
N=int(input())
X=list(map(int,input().split()))
for i in range(N):
  l=X[:i]+X[i+1:]
  med=statistics.median(l)
  print(med)

Fixed submission:
N=int(input())
X=[int(x) for x in input().split()]
XX=sorted(X)
L=XX[N//2-1]
R=XX[N//2]
for x in X:
  print(L if x>=R else R)
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
set(li2)
for ll in li2:
  print(ll)

Fixed submission:
s=sorted(input())
if s == list("abc"):print("Yes")
else:print("No")
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
li3=sorted(set(li2))
for ll in li3:
  print(ll)

Fixed submission:
A,B,K=map(int,input().split())
li=[]  
for i in range(A,A+K):
  li.append(i)
for j in range(B-K+1,B+1):
  li.append(j)
ans=sorted(set(li))
for l in ans:
  if A<=l<=B:
    print(l)

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
set(li2)
for ll in li2:
  print(ll)

Fixed submission:
A,B,K=map(int,input().split())
li=[]  
for i in range(A,A+K):
  li.append(i)
for j in range(B-K+1,B+1):
  li.append(j)
ans=sorted(set(li))
for l in ans:
  if A<=l<=B:
    print(l)

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
for ll in li2:
  print(set(li2))

Fixed submission:
A,B,K=map(int,input().split())
li=[]  
for i in range(A,A+K):
  li.append(i)
for j in range(B-K+1,B+1):
  li.append(j)
ans=sorted(set(li))
for l in ans:
  if A<=l<=B:
    print(l)
Buggy python submission (verdict: Runtime Error):
N=int(input())
n=[input()[0] for _ in range(N)]
m,a,r,c,h=n.count("M"),n.count("A"),n.count("R"),n.count("C"),n.count("H")
print(m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h)

Fixed submission:
print(int(input())//3)

Buggy python submission (verdict: Runtime Error):
N=int(input())
name=[input()[0] for _ in range(N)]
m,a,r,c,h=name.count("M"),name.count("A"),name.count("R"),name.count("C"),name.count("H")
print(m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h)

Fixed submission:
print(int(input())//3)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=int(input())
if n%500 <= A:print("Yes")
else:print("No")

Fixed submission:
n=int(input())
a=int(input())
if n%500 <= a:print("Yes")
else:print("No")
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans= 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      s = 500*i + 100*j + 50*k
      if s==x:
        ans+=1
print(ans)


Fixed submission:
x=int(input())
a=int(input())
b=int(input())
print(x-a-((x-a)//b)*b)
Buggy python submission (verdict: Runtime Error):
a,b=map(int(input().split()))
if a%2==0 or b%2==0:print("Even")
else:print("Odd")


Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:print("Even")
else:print("Odd")

Buggy python submission (verdict: Runtime Error):
a,b=map(int(input().split())
if a%2==0 or b%2==0:print("Even")
else:print("Odd")


Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:print("Even")
else:print("Odd")

Buggy python submission (verdict: Runtime Error):
a,b=map(int(inout().split())
if a%2==0 or b%2==0:print("Even")
else:print("Odd")

Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:print("Even")
else:print("Odd")