Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
li = [2,3,4,5,6,7,8,9,10,11,12,1]
a,b = map(int,input().split())
if li.index(a) == li.index(b):
    print("Draw")
elif li.index(a) > li.index(b):
    print("Alice")
else:
    print("Bob")

Fixed submission:
li = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b = map(int,input().split())
if li.index(a) == li.index(b):
    print("Draw")
elif li.index(a) > li.index(b):
    print("Alice")
else:
    print("Bob")

Buggy python submission (verdict: Runtime Error):
li = [2,3,4,5,6,7,8,9,10,11,12,1]
a,b = map(int,input().split())
if li.index(a) == li.index(b):
    print("Draw")
if li.index(a) > li.index(b):
    print("Alice")
else:
    print("Bob")

Fixed submission:
li = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b = map(int,input().split())
if li.index(a) == li.index(b):
    print("Draw")
elif li.index(a) > li.index(b):
    print("Alice")
else:
    print("Bob")
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a + b == c pr a + c == b or b + c == a:
    print("No")
else:
    print("Yes")


Fixed submission:
a,b,c = map(int,input().split())
if a + b == c or a + c == b or b + c == a:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if sum(a,b,c) % 2 == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b,c = map(int,input().split())
if a + b == c or a + c == b or b + c == a:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print((a+b)*h/2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
Buggy python submission (verdict: Time Limit Exceeded):
def PF(n):
    fs = []
    q = int(n ** 0.5) 
    for i in range(2, q + 1):
        if n % i == 0:
            r = 0
            while n % i == 0:
                n //= i
                r += 1
            fs.append([i, r])
    if n != 1:
        fs.append([n, 1])
    return fs

n=int(input())
cnt=0;N=n
j=1;x=n
while j<n:
  num=1
  x=x-j
  V=PF(x)
  for w in range(len(V)):
    num=num*(V[w][1]+1)

  cnt=cnt+num
  
  j=j+1
  x=n
print(cnt)

Fixed submission:
N=int(input())
x=0
for i in range(1,N):
  x=x+(N-1)//i
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
cnt=1;N=n
p=0;q=0;a=1;b=1;c=1
j=1
while j<n:
  N=N-j
  S=[]
  i=1
  while i<N:
    if N%i==0:
      if S.count(i)==0:
        S.append(i)
      if S.count(N//i)==0:
        S.append(N//i)
    i=i+1
  cnt=cnt+len(S)
  #print(j,len(S),S,cnt)
  j=j+1
  N=n
print(cnt)

Fixed submission:
N=int(input())
x=0
for i in range(1,N):
  x=x+(N-1)//i
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
B=[];C=[];S=0
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
for i in range(Q):
  b,c=map(int,input().split())
  B.append(b)
  C.append(c)

#print(A)
#print(B)
#print(C)

for i in range(Q):
  for j in range(N):
    if A[j]==B[i]:
      S=S+C[i]
      A[j]=C[i]
    else:
      S=S+A[j]
  print(S)
  S=0

Fixed submission:
B=[];C=[];S=0
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
for i in range(Q):
  b,c=map(int,input().split())
  B.append(b)
  C.append(c)

X=[0]*(10**5+1)
for i in range(N):
  X[A[i]]+=1
  S=S+A[i]

#print(A)
#print(B)
#print(C)

for i in range(Q):
  X[C[i]]+=X[B[i]]
  S=S+X[B[i]]*(C[i]-B[i])
  X[B[i]]=0
  print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(map(int,input().split()))
if S[0]==0:
  print(0)
else:
  X=S[0]
for i in range(1,N):
  if S[i]==0:
    X=0
    print(0)
    break
  else:
    X=X*S[i]
    #print(X)   
if 0<X<=10**18:
  print(X)
else:
  if X!=0:
    print(-1)

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
if S[0]==0:
  print(0)
else:
  X=S[0]
for i in range(1,N):
  if S[i]==0:
    X=0
    print(0)
    break
  else:
    if X>10**18:
      continue
    else:
      X=X*S[i]
if 0<X<=10**18:
  print(X)
else:
  if X!=0:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N,M,Q=map(int,input().split())
S=[0]*Q;t=0;d=0;A=[0]*10
for i in range(Q):
  a,b,c,d=map(int,input().split())
  S[i]=[a,b,c,d]
#print(S)
for i1 in range(M):
  for i2 in range(M):
    for i3 in range(M):
      for i4 in range(M):
        for i5 in range(M):
          for i6 in range(M):
            for i7 in range(M):
              for i8 in range(M):
                for i9 in range(M):
                  for i10 in range(M):
                    A=[i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                    for i in range(Q):
                      if A[S[i][1]]-A[S[i][0]]==S[i][2]:
                        d=d+S[i][3]
                    t=max(t,d)
                    d=0
print(t)

Fixed submission:
N,M,Q=map(int,input().split())
S=[0]*Q;t=0;d=0;A=[0]*10
for i in range(Q):
  a,b,c,d=map(int,input().split())
  S[i]=[a,b,c,d]
#print(S)
for i1 in range(1,M+1):
  for i2 in range(i1,M+1):
    for i3 in range(i2,M+1):
      for i4 in range(i3,M+1):
        for i5 in range(i4,M+1):
          for i6 in range(i5,M+1):
            for i7 in range(i6,M+1):
              for i8 in range(i7,M+1):
                for i9 in range(i8,M+1):
                  for i10 in range(i9,M+1):
                    d=0
                    A=[i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                    for i in range(Q):
                      if A[S[i][1]-1]-A[S[i][0]-1]==S[i][2]:
                        d=d+S[i][3]
                    t=max(t,d)
                    
print(t)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
x=0
K=int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    for h in range(1,K+1):
      if i==j and j==h:
        x=x+i
      elif i==j or j==h:
        x=x+fractions.gcd(i,h)
      else:
        x=x+fractions.gcd(i,fractions.gcd(j,h))
print(x)

Fixed submission:
import math
x=0;y=0
K=int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    y=math.gcd(i,j)
    for h in range(1,K+1):
      x=x+math.gcd(y,h)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
x=0
K=int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    for h in range(1,K+1):
      if i==j and j==h:
        x=x+i
      elif i==j or j==h:
        x=x+fractions.gcd(i,h)
      else:
        x=x+fractions.gcd(i,fractions.gcd(j,h))
print(x)

Fixed submission:
import math
x=0;y=0
K=int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    y=math.gcd(i,j)
    for h in range(1,K+1):
      x=x+math.gcd(y,h)
print(x)
Buggy python submission (verdict: Runtime Error):
B=[];bingo=0
import numpy as np
A=np.zeros((3,3),dtype=int)
for i in range(3):
  a,b,c=map(int,input().split())
  A[i][0]=a
  A[i][1]=b
  A[i][2]=c
N=int(input())
for i in range(N):
  B.append(int(input()))
#print(A)
#print(B)
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==B[k]:
        A[i][j]=0
#print(A)
for i in range(3):
  if sum(A[i][:])==0:
    bingo=bingo+1
for i in range(3):
  if sum(A[0][i])==0 or sum(A[1][i])==0 or sum(A[2][i])==0:
    bingo=bingo+1
if A[0][0]+A[1][1]+A[2][2]==0:
  bingo=bingo+1
if A[2][0]+A[1][1]+A[0][2]==0:
  bingo=bingo+1
print("Yes" if bingo>=1 else "No")

Fixed submission:
B=[];bingo=0
import numpy as np
A=np.zeros((3,3),dtype=int)
for i in range(3):
  a,b,c=map(int,input().split())
  A[i][0]=a
  A[i][1]=b
  A[i][2]=c
N=int(input())
for i in range(N):
  B.append(int(input()))
#print(A)
#print(B)
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==B[k]:
        A[i][j]=0
#print(A)
for i in range(3):
  if sum(A[i][:])==0:
    bingo=bingo+1
for i in range(3):
  if A[0][i]+A[1][i]+A[2][i]==0:
    bingo=bingo+1
if A[0][0]+A[1][1]+A[2][2]==0:
  bingo=bingo+1
if A[2][0]+A[1][1]+A[0][2]==0:
  bingo=bingo+1
print("Yes" if bingo>=1 else "No")

Buggy python submission (verdict: Runtime Error):
B=[];bingo=0
import numpy as np
A=np.zeros((3,3),dtype=int)
for i in range(3):
  a,b,c=map(int,input().split())
  A[i][0]=a
  A[i][1]=b
  A[i][2]=c
N=int(input())
for i in range(N):
  B.append(int(input()))
#print(A)
#print(B)
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==B[k]:
        A[i][j]=0
#print(A)
for i in range(3):
  if sum(A[i][:])==0:
    bingo=bingo+1
for i in range(3):
  if sum(A[0][i])==0 or sum(A[1][i])==0 or sum(A[2][i])==0:
    bingo=bingo+1
if A[0][0]+A[1][1]+A[2][2]==0:
  bingo=bingo+1
if A[2][0]+A[1][1]+A[0][2]==0:
  bingo=bingo+1
print("Yes" if bingo>=1 else "No")
print(sum(A[:][1]))
print(sum(A[1][:]))
print(bingo)

Fixed submission:
B=[];bingo=0
import numpy as np
A=np.zeros((3,3),dtype=int)
for i in range(3):
  a,b,c=map(int,input().split())
  A[i][0]=a
  A[i][1]=b
  A[i][2]=c
N=int(input())
for i in range(N):
  B.append(int(input()))
#print(A)
#print(B)
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==B[k]:
        A[i][j]=0
#print(A)
for i in range(3):
  if sum(A[i][:])==0:
    bingo=bingo+1
for i in range(3):
  if A[0][i]+A[1][i]+A[2][i]==0:
    bingo=bingo+1
if A[0][0]+A[1][1]+A[2][2]==0:
  bingo=bingo+1
if A[2][0]+A[1][1]+A[0][2]==0:
  bingo=bingo+1
print("Yes" if bingo>=1 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=[]
for i in range(N):
  L.append(int(input()))
S=[]
M=[]
t=0
S=L[1:len(L)]
print(max(S))
M=L[0:len(L)-1]
for i in range(1,len(L)-1):
  S=L[0:i]
  M=L[i+1:len(L)]
  print(max(max(S),max(M)))
M=L[0:len(L)-1]
print(max(M))

Fixed submission:
N=int(input())
L=[]
s,e,s1,e1,t=0,0,0,0,0
for i in range(N):
  L.append(int(input()))
s=L.index(max(L))
e=L[s]
L[s]=0
s1=L.index(max(L))
e1=L[s1]
for i in range(N):
  if i!=s:
    print(e)
  else:
    print(e1)
Buggy python submission (verdict: Time Limit Exceeded):
m=2018
L,R=map(int,input().split())
for i in range(L,R):
  for j in range(i+1,R+1):
    m=min(m,i*j%2019)
print(m)

Fixed submission:
L,R=map(int, input().split())
m=2019
for i in range(L,min(R+1,L+2019)):
  for j in range(i+1,min(R+1,L+2019)):
    m=min(m,i*j%2019)
print(m)

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

Fixed submission:
L,R=map(int, input().split())
m=2019
for i in range(L,min(R+1,L+2019)):
  for j in range(i+1,min(R+1,L+2019)):
    m=min(m,i*j%2019)
print(m)
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
p=1
dt=0
i=1
while dt<=X:
  dt=dt+L[i-1]
  i=i+1
  if dt<=X and p<=N+1:
    p=p+1
  #print(dt)
print(p)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
p=1
dt=0
i=1
for i in range(N):
  dt=dt+L[i]
  if dt<=X:
    p=p+1
  else:
    break
print(p)

Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
p=1
dt=0
i=1
while dt<=X:
  dt=dt+L[i-1]
  i=i+1
  if dt<=X:
    p=p+1
  #print(dt)
print(p)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
p=1
dt=0
i=1
for i in range(N):
  dt=dt+L[i]
  if dt<=X:
    p=p+1
  else:
    break
print(p)
Buggy python submission (verdict: Runtime Error):
N=int(input())
p=1
S=[]
A=[]
U=[]
T=[]
L= [list(map(str,input().split())) for i in range(N)]
for j in range(1,N+1):
  L[j-1].append(j)
L.sort(key=lambda x: x[0])
#print(L)
S=L[:]
S.sort(reverse=True,key=lambda x: int(x[1]))
#print(S)
T.append(L[0][0])
for i in range(1,N-1):
  if L[i-1][0]!=L[i][0]:
    T.append(L[i][0])
#print(T)
for j in range(len(T)):
  for k in range(N):
    if S[k][0]==T[j]:
      A.append(S[k][2])
for i in range(N):
  print(A[i])

Fixed submission:
N=int(input())
p=1
S=[]
A=[]
U=[]
T=[]
L= [list(map(str,input().split())) for i in range(N)]
for j in range(1,N+1):
  L[j-1].append(j)
L.sort(key=lambda x: x[0])
#print(L)
S=L[:]
S.sort(reverse=True,key=lambda x: int(x[1]))
#print(S)
T.append(L[0][0])
for i in range(1,N):
  if L[i-1][0]!=L[i][0]:
    T.append(L[i][0])
#print(T)
for j in range(len(T)):
  for k in range(N):
    if S[k][0]==T[j]:
      A.append(S[k][2])
for i in range(N):
  print(A[i])
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
H=list(map(int,input().split()))
cost =10000
DP=[0]*N
DP[0]=0
DP[1]=abs(H[1]-H[0])
for i in range(2,N):
  cost=10000
  for k in range(1,K+1):
    if (i-k)==-1:
      break
    cost=min(cost,(abs(H[i]-H[i-k])+DP[i-k]))
    #print(H[i],H[i-k],DP[i-k])
    DP[i]=cost
    #print(DP[i],i)
print(DP[N-1])

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
cost=0
t1,t2=0,0
A=[0]*(N)
i=1
while i<N:
  if i==1:
    A[i]=abs(H[i]-H[i-1])
    #print(i,A[i])
  elif i==2:
    t1=abs(H[i]-H[i-2])
    t2=abs(H[i]-H[i-1])+abs(H[i-2]-H[i-1])
    A[i]=min(t1,t2)
    #print(i,A[i],t1,t2)
  else:
    t1=abs(H[i]-H[i-1])+A[i-1]
    t2=abs(H[i]-H[i-2])+A[i-2]
    A[i]=min(t1,t2)
    #print(i,A[i],t1,t2)
  i=i+1
#print(A)
print(A[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
H=list(map(int,input().split()))
DP=[0]*(N)
DP[0]=0
DP[1]=abs(H[1]-H[0])
for i in range(2,N):
  DP[i]=min([abs(H[i]-H[k])+DP[k] for k in range(max(i-K,0),i)])
print(DP[N-1])

Fixed submission:
def a():
    N, K = [int(n) for n in input().split()]
    h = [int(n) for n in input().split()]
    # dp[i]はi番目までたどり着くのに必要な最小コスト
    # dp[0] = 0
    # dp[1] = |h[1] - h[0]|
    # dp[i] = min(dp[0]+h[i]-h[0], dp[1]+h[i]-h[1], ...)
    dp = [0] * N
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min([dp[k] + abs(h[k] - h[i]) for k in range(max(i - K, 0), i)])
    print(dp[N-1])
 
if __name__ == "__main__":
    a()

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
H=list(map(int,input().split()))
cost =200000
DP=[0]*(N+10)
DP[0]=0
DP[1]=abs(H[1]-H[0])
for i in range(2,N):
  DP[i]=min([abs(H[i]-H[k])+DP[k] for k in range(max(i-K,0),i)])
print(DP[N-1])

Fixed submission:
def a():
    N, K = [int(n) for n in input().split()]
    h = [int(n) for n in input().split()]
    # dp[i]はi番目までたどり着くのに必要な最小コスト
    # dp[0] = 0
    # dp[1] = |h[1] - h[0]|
    # dp[i] = min(dp[0]+h[i]-h[0], dp[1]+h[i]-h[1], ...)
    dp = [0] * N
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        dp[i] = min([dp[k] + abs(h[k] - h[i]) for k in range(max(i - K, 0), i)])
    print(dp[N-1])
 
if __name__ == "__main__":
    a()
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==1:
  print("Hello World")
else:
  A,B=map(int,input().split())
  print(A+B)

Fixed submission:
N=int(input())
if N==1:
  print("Hello World")
else:
  A=int(input())
  B=int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
S=list(input())
K=int(input())
#print(S)
i=0;p=0
while S[i]=="1":
  p=p+1
  i=i+1
#print(p)
print(S[p])

Fixed submission:
S=list(input())
K=int(input())
#print(S)
i=0;p=0;q=0
while i!=len(S):
  if S[i]!="1":
    p=1
    q=i
    if K<i+1:
      print("1")
    else:
      print(S[i])
    break
  i=i+1
if p==0:
  print("1")
Buggy python submission (verdict: Runtime Error):
D,N=map(int,input().split())
L=[]
if D==0:
  for i in range(1,100):
    L.append(i)
elif D==1:
  for i in range(100,10000,100):
    L.append(i)
elif D==2:
  for i in range(10000,1000000,10000):
    L.append(i)
print(L[N-1])

Fixed submission:
D,N=map(int,input().split())

if D==0:
  if N!=100:
    print(N)
  else:
    print(101)
elif D==1:
  if N!=100:
    print(N*100)
  else:
    print(10100)
else:
  if N!=100:
    print(N*10000)
  else:
    print(1010000)

Buggy python submission (verdict: Runtime Error):
D,N=map(int,input().split())
s=0
L=[]
if D==0:
  for i in range(1,100):
    L.append(i)
elif D==1:
  for i in range(100,10000,100):
    L.append(i)
elif D==2:
  for i in range(10000,1000000,10000):
    L.append(i)
print(L[N-1])

Fixed submission:
D,N=map(int,input().split())

if D==0:
  if N!=100:
    print(N)
  else:
    print(101)
elif D==1:
  if N!=100:
    print(N*100)
  else:
    print(10100)
else:
  if N!=100:
    print(N*10000)
  else:
    print(1010000)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(map(str,input()))
A=int(input())
V=[]
S=[]
ct=0
for i in range(1,len(s)+1):
  for j in range((len(s)-(i-1))):
    V.append("".join(s[j:j+i]))
S=sorted(set(V))
#print(S)
print(S[A-1])

Fixed submission:
s=list(map(str,input()))
A=int(input())
V=[]
S=[]
ct=0
for i in range(1,A+1):
  for j in range((len(s)-(i-1))):
    V.append("".join(s[j:j+i]))
S=sorted(set(V))
#print(S)
print(S[A-1])

Buggy python submission (verdict: Time Limit Exceeded):
s=list(map(str,input()))
A=int(input())
V=[]
S=[]
ct=0
for i in range(1,len(s)+1):
  for j in range((len(s)-(i-1))):
    V.append("".join(s[j:j+i]))
S=sorted(set(V))
#print(S)
print(S[A-1])

Fixed submission:
s=list(map(str,input()))
A=int(input())
V=[]
S=[]
ct=0
for i in range(1,A+1):
  for j in range((len(s)-(i-1))):
    V.append("".join(s[j:j+i]))
S=sorted(set(V))
#print(S)
print(S[A-1])
Buggy python submission (verdict: Runtime Error):
C=[0]*3;A=[0]*3
d1=0;d2=0;e1=0;e2=0;z=0;p=0
for i in range(3):
  c1,c2,c3=map(int,input().split())
  C[i]=(c1,c2,c3)
  A[i]=(0,0,0)

d1=C[1][0]-C[0][0];d2=C[2][0]-C[0][0]
e1=C[0][1]-C[0][0];e2=C[0][2]-C[0][0]
z=C[0][0]
A[0][0]=z;A[0][1]=z+e1;A[0][2]=z+e2
A[1][0]=z+d1;A[1][1]=z+e1+d1;A[1][2]=z+d1+e2
A[2][0]=z+d2;A[2][1]=z+d2+e1;A[2][2]=z+d2+e2

print(C)
for i in range(3):
  for j in range(3):
    if C[i][j]==A[i][j]:
      p=p+1
print("Yes" if p==9 else "No")

Fixed submission:
C=[0]*3;A=[0]*3
d1=0;d2=0;e1=0;e2=0;z=0;p=0
for i in range(3):
  c1,c2,c3=map(int,input().split())
  C[i]=[c1,c2,c3]
  A[i]=[0,0,0]
 
d1=C[1][0]-C[0][0];d2=C[2][0]-C[0][0]
e1=C[0][1]-C[0][0];e2=C[0][2]-C[0][0]
z=C[0][0]
A[0][0]=z;A[0][1]=z+e1;A[0][2]=z+e2
A[1][0]=z+d1;A[1][1]=z+e1+d1;A[1][2]=z+d1+e2
A[2][0]=z+d2;A[2][1]=z+d2+e1;A[2][2]=z+d2+e2
 
#print(C)
for i in range(3):
  for j in range(3):
    if C[i][j]==A[i][j]:
      p=p+1
print("Yes" if p==9 else "No")
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
sy = 0
sx = 0
gy = H-1
gx = W-1
c = []
d = [[-1 for i in range(W)] for j in range(H)]
d[sy][sx] = 0
cnt=0
for i in range(H):
	c.append(input())
for j in range(H):
  cnt=cnt+c[j].count(".")

dirr = [[1, 0], [0, 1], [-1, 0], [0, -1]]
q = deque()
q.append([sy, sx, 0])
while len(q) != 0:
	y, x, w = q[0]
	if y == gy and x == gx:
		break

	for i in range(4):
		ny, nx = y + dirr[i][0], x + dirr[i][1]
		if ny>=0 and nx>=0 and ny<H and nx<W and d[ny][nx] == -1 and c[ny][nx] != "#":
			q.append([ny, nx, w + 1])
			d[ny][nx] = w + 1

	q.popleft()

if d[gy][gx]==-1:
  print(-1)
else:
  print(cnt-w-1)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
sy = 0
sx = 0
gy = H-1
gx = W-1
c = []
d = [[-1 for i in range(W)] for j in range(H)]
d[sy][sx] = 0
cnt=0
for i in range(H):
	c.append(input())
for j in range(H):
  cnt=cnt+c[j].count(".")

dirr = [[1, 0], [0, 1], [-1, 0], [0, -1]]
q = deque()
q.append([sy, sx, 0])
while len(q) != 0:
	y, x, w = q[0]
	if y == gy and x == gx:
		break

	for i in range(4):
		ny, nx = y + dirr[i][0], x + dirr[i][1]
		if ny>=0 and nx>=0 and ny<H and nx<W and d[ny][nx] == -1 and c[ny][nx] != "#":
			q.append([ny, nx, w + 1])
			d[ny][nx] = w + 1

	q.popleft()

if d[gy][gx]==-1:
  print(-1)
else:
  print(cnt-w-1)
Buggy python submission (verdict: Runtime Error):
A,B,C,D=map(int,input().split())
if (A+B)%2!=0:
  print((A+B)//2+1)
else:
  print((A+B)//2)

Fixed submission:
A,B=map(int,input().split())
if (A+B)%2!=0:
  print((A+B)//2+1)
else:
  print((A+B)//2)

Buggy python submission (verdict: Runtime Error):
A,B,C,D=map(int,input().split())
print((A+B)//2)

Fixed submission:
A,B=map(int,input().split())
if (A+B)%2!=0:
  print((A+B)//2+1)
else:
  print((A+B)//2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
A.sort()
b=A[:]
b=set(b)
cnt=len(A)
for j in b:
  x=A.count(j)
  if x==j:
    x=0
  elif x>j:
    for k in range(1,x-j+1):
      A.remove(j)
  elif x<j:
    for l in range(1,x+1):
      A.remove(j)
print(cnt-len(A))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
C=[0]*100001
cnt=0
for i in range(N):
  if A[i]>10**5:
    cnt +=1
  else:
    C[A[i]] += 1
for j in range(100001):
  if C[j]<j:
    cnt=cnt+C[j]
  elif C[j]>j:
    cnt=cnt+C[j]-j
print(cnt)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
C=[0]*(N);C[0]=abs(A[0]-sum(A[1:]));x=10**9;P=0
for i in range(1,N):
  if N-i==1:
    break
  else:
    C[i]=abs(C[i-1]+A[i]-sum(A[i+1:]))
    if x>C[i]:
      x=C[i]
      p=i
print(abs(C[p-1]+A[p]-sum(A[p+1:])))

Fixed submission:
S=[]
N=int(input())
A=list(map(int,input().split()))
C=[0]*(N);x=10**10;p=0
S.append(A[0])
for i in range(1,N):
  S.append(S[i-1]+A[i])
#print(S)
C[0]=abs(A[0]-(S[-1]-S[0]))
for i in range(1,N-1):
  C[i]=abs(S[i-1]+A[i]-(S[-1]-S[i]))
  if x>(C[i]):
    x=(C[i])
    p=i
print(abs(S[p-1]+A[p]-(S[-1]-S[p])))
Buggy python submission (verdict: Time Limit Exceeded):
b=[]
n=int(input())
a=list(map(str,input().split()))
b.append(a[0])
for i in range(1,n):
  if i%2==0:
    b.append(a[i])
  else:
    b.insert(0,a[i])
if n%2==0:
  print(*b)
else:
  print(*reversed(b))

Fixed submission:
from collections import deque
b=deque([])
n=int(input())
a=list(map(str,input().split()))
b.append(a[0])
for i in range(1,n):
  if i%2==0:
    b.append(a[i])
  else:
    b.appendleft(a[i])
if n%2==0:
  print(*b)
else:
  print(*reversed(b))
Buggy python submission (verdict: Runtime Error):
def d(n):
  return len(str(n))

N=int(input())
i=1
#print(int(N**0.5))
while N%(int(N**0.5)-i)!=0:
  i=i+1
print(max(d(int(N**0.5)-i),d(N//(int(N**0.5)-i))))

Fixed submission:
def d(n):
  return len(str(n))

N=int(input())
if N==1:
  print(1)
else:
  i=0
  #print(int(N**0.5))
  while N%(int(N**0.5)-i)!=0:
    i=i+1
  print(max(d(int(N**0.5)-i),d(N//(int(N**0.5)-i))))
Buggy python submission (verdict: Runtime Error):
P=[0]*1000
x=1
N=int(input())
for i in range(2,N+1):
  A=PF(i)
  for j in range(len(A)):
    P[A[j][0]]=P[A[j][0]]+A[j][1]
P.remove(0)
for i in range(len(P)):
  x=(x*(P[i]+1))%(10**9+7)
print(x)

Fixed submission:
def PF(n):
    fs = []
    q = int(n ** 0.5) 
    for i in range(2, q + 1):
        if n % i == 0:
            r = 0
            while n % i == 0:
                n //= i
                r += 1
            fs.append([i, r])
    if n != 1:
        fs.append([n, 1])
    return fs

P=[0]*1000
x=1
N=int(input())
for i in range(2,N+1):
  A=PF(i)
  for j in range(len(A)):
    P[A[j][0]]=P[A[j][0]]+A[j][1]
P.remove(0)
for i in range(len(P)):
  x=(x*(P[i]+1))%(10**9+7)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
cnt=0
for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      if X+Y+Z==S:
        cnt += 1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt=0
for X in range(K+1):
  for Y in range(K+1):
    if K>=S-(X+Y) and X+Y<=S:
      cnt=cnt+1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=[1]
for i in range(1,N):
  S.append(S[i-1]+i+1)
p=0
j=0
while N>=S[j]:
  j += 1
p=S[j]-N
for i in range(1,j+2):
  if i!=p:
    print(i)

Fixed submission:
N=int(input())
S=[1]
for i in range(1,N):
  S.append(S[i-1]+i+1)
p=0
j=0
if N==1:
  print(1)
else:
  while N>=S[j]:
    j += 1
  p=S[j]-N
  for i in range(1,j+2):
    if i!=p:
      print(i)
Buggy python submission (verdict: Runtime Error):
# -*- coding utf-8 -*-
MOD = 10 ** 9 + 7

a = int(input())
b = input()

if a >= 3200:
    print(s)
else:
    print('red')


Fixed submission:
# -*- coding utf-8 -*-
MOD = 10 ** 9 + 7

a = int(input())
b = input()

if a >= 3200:
    print(b)
else:
    print('red')