Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque
H,W=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
Ch-=1
Cw-=1
Dh-=1
Dw-=1

S=[]
for i in range(H):
  s=list(input())
  S.append([-1 if i =="." else i for i in s])

dq = deque()
dq.append((Ch,Cw))
S[Ch][Cw]=0

while dq:
  a=dq.pop()
  if a[0]-1>=0 and (S[a[0]-1][a[1]]==-1 or (S[a[0]-1][a[1]]!="#" and S[a[0]-1][a[1]]>S[a[0]][a[1]])):
    S[a[0]-1][a[1]]=S[a[0]][a[1]]
    dq.appendleft((a[0]-1,a[1]))
  if a[0]+1<H and (S[a[0]+1][a[1]]==-1 or (S[a[0]+1][a[1]]!="#" and S[a[0]+1][a[1]]>S[a[0]][a[1]])):
    S[a[0]+1][a[1]]=S[a[0]][a[1]]
    dq.appendleft((a[0]+1,a[1]))
  if a[1]-1>=0 and (S[a[0]][a[1]-1]==-1 or (S[a[0]][a[1]-1]!="#" and S[a[0]][a[1]-1]>S[a[0]][a[1]])):
    S[a[0]][a[1]-1]=S[a[0]][a[1]]
    dq.appendleft((a[0],a[1]-1))
  if a[1]+1<W and (S[a[0]][a[1]+1]==-1 or (S[a[0]][a[1]+1]!="#" and S[a[0]][a[1]+1]>S[a[0]][a[1]])):
    S[a[0]][a[1]+1]=S[a[0]][a[1]]
    dq.appendleft((a[0],a[1]+1))
  for i in range(5):
    for j in range(5):
      if a[0]-2+i>=0 and a[0]-2+i<H and a[1]-2+j>=0 and a[1]-2+j<W and (S[a[0]-2+i][a[1]-2+j]==-1 or (S[a[0]-2+i][a[1]-2+j]!="#" and S[a[0]-2+i][a[1]-2+j]>=S[a[0]][a[1]]+1)):
        S[a[0]-2+i][a[1]-2+j]=S[a[0]][a[1]]+1
        dq.append((a[0]-2+i,a[1]-2+j))

print(S[Dh][Dw])

Fixed submission:
N,X,T=map(int,input().split())
print(((N-1)//X+1)*T)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

dummy=set()
loop=[]
X=set(range(N))
while len(dummy)!=N:
  a=[]
  k=min(X-dummy)
  a.append(k)
  dummy.add(k)
  l=P[k]-1
  while l!=k:
    a.append(l)
    dummy.add(l)
    l=P[l]-1
  loop.append(a)

ans=-(10**300)
for l in loop:
  temp=0
  s=len(l)
  ssum=0
  k=0
  for i in range(s):
    ssum+=C[l[i]]
  if ssum>0:
    temp+=((K-1)//s)*ssum
    k=K-((K-1)//s)*s
  else:
    k=min(K,s)
  kmax=-(10**300)
  for ii in range(s):
    tempscore=temp
    for jj in range(1,k+1):
      tempscore+=C[l[(ii+jj)%s]]
      if tempscore>kmax:
        kmax=tempscore
  if kmax>ans:
    ans=kmax
print(ans)


Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

dummy=set()
loop=[]
X=set(range(N))
while len(dummy)!=N:
  a=[]
  k=min(X-dummy)
  a.append(k)
  dummy.add(k)
  l=P[k]-1
  while l!=k:
    a.append(l)
    dummy.add(l)
    l=P[l]-1
  loop.append(a)

ans=-(10**300)
for l in loop:
  temp=0
  s=len(l)
  ssum=0
  k=0
  for i in range(s):
    ssum+=C[l[i]]
  if ssum>0:
    temp+=((K-1)//s)*ssum
    k=K-((K-1)//s)*s
  else:
    k=min(K,s)
  kmax=-(10**300)
  for ii in range(s):
    tempscore=temp
    for jj in range(1,k+1):
      tempscore+=C[l[(ii+jj)%s]]
      if tempscore>kmax:
        kmax=tempscore
  if kmax>ans:
    ans=kmax
print(ans)

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

dummy=set()
loop=[]
X=set(range(N))
while len(dummy)!=N:
  a=[]
  k=min(X-dummy)
  a.append(k)
  dummy.add(k)
  l=P[k]-1
  while l!=k:
    a.append(l)
    dummy.add(l)
    l=P[l]-1
  loop.append(a)

ans=-(10**300)
for l in loop:
  temp=0
  s=len(l)
  ssum=0
  k=0
  for i in range(s):
    ssum+=C[l[i]]
  if ssum>0:
    temp+=((K-1)//s)*ssum
    k=K-((K-1)//s)*s
  else:
    k=min(K,s)
  kmax=-(10**300)
  for ii in range(1,k+1):
    for jj in range(s):
      tempscore=temp
      for kk in range(ii):
        tempscore+=C[l[(jj+kk)%s]]
      if tempscore>kmax:
        kmax=tempscore
  if kmax>ans:
    ans=kmax
print(ans)


Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

dummy=set()
loop=[]
X=set(range(N))
while len(dummy)!=N:
  a=[]
  k=min(X-dummy)
  a.append(k)
  dummy.add(k)
  l=P[k]-1
  while l!=k:
    a.append(l)
    dummy.add(l)
    l=P[l]-1
  loop.append(a)

ans=-(10**300)
for l in loop:
  temp=0
  s=len(l)
  ssum=0
  k=0
  for i in range(s):
    ssum+=C[l[i]]
  if ssum>0:
    temp+=((K-1)//s)*ssum
    k=K-((K-1)//s)*s
  else:
    k=min(K,s)
  kmax=-(10**300)
  for ii in range(s):
    tempscore=temp
    for jj in range(1,k+1):
      tempscore+=C[l[(ii+jj)%s]]
      if tempscore>kmax:
        kmax=tempscore
  if kmax>ans:
    ans=kmax
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C=map(int,input().split())
K=int(input())
while K>0:
  while B<=A:
    B*=2
    K-=1
  while C<=B:
    C*=2
    K-=1
if K>=0:
  print("Yes")
else:
  print("No")

Fixed submission:
A,B,C=map(int,input().split())
K=int(input())
while B<=A:
  B*=2
  K-=1
while C<=B:
  C*=2
  K-=1
if K>=0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
NN=int(input())
A=[0]*N
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if x**2+y**2+z**2+x*y+y*z+z*x<=N:
        A[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
for i in range(N):
  print(A[i])

Fixed submission:
N=int(input())
A=[0]*N
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if x**2+y**2+z**2+x*y+y*z+z*x<=N:
        A[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
for i in range(N):
  print(A[i])

Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
def f(n):
  ans=0
  K=int(math.sqrt(n))
  K2=int(math.sqrt(n/6))
  for x in range(K2,K+1):
    L=min(x,int(math.sqrt(n-x**2)))
    L2=int(math.sqrt((n-x**2)/5))
    for y in range(L2,L+1):
      z=min(y,round(math.sqrt(n-x**2-y**2-x*y+(x+y)**2/4)-(x+y)/2))
      if x**2+y**2+z**2+x*y+y*z+z*x==n and z>=1:
        if x==z:
          ans+=1
        elif x==y or y==z:
          ans+=3
        else:
          ans+=6
  return ans

for i in range(1,N+1):
  print(f(i))

Fixed submission:
N=int(input())
A=[0]*N
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if x**2+y**2+z**2+x*y+y*z+z*x<=N:
        A[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
for i in range(N):
  print(A[i])
Buggy python submission (verdict: Runtime Error):
D=int(input())
C=list(map(int,input().split()))
import sys
S=sys.stdin.readlines()
A=[0]*26
B=[0]*D
k=0
for i in range(26):
  k+=1/C[i]
for i in range(26):
  if i<25:
    A[i]=int(1/C[i]/k*365)
  else:
    A[i]=365-sum(A[:25])

for i in range(25):
  for j in range(A[i]):
    B[D//A[i]*j]=i+1

for i in range(D):
  if B[i]==0:
    B[i]=26

for i in range(D):
  print(B[i])

Fixed submission:
D=int(input())
C=list(map(int,input().split()))
import sys
S=sys.stdin.readlines()
A=[0]*26
B=[0]*D
k=0
for i in range(26):
  if C[i]!=0:
    k+=C[i]
for i in range(26):
  if i<25:
    A[i]=int(C[i]/k*D)
  else:
    A[i]=D-sum(A[:25])

for i in range(25):
  for j in range(A[i]):
    B[D//A[i]*j]=i+1

for i in range(D):
  if B[i]==0:
    B[i]=26


for i in range(D):
  print(B[i])
Buggy python submission (verdict: Runtime Error):
L=set("A","B")
print(L)

Fixed submission:
L={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
a=input()
if a in L:
  print("A")
else:
  print("a")
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
A=np.zeros(11,dtype=int)
for i in range(11):
  A[i]=(26**(i+1))
B=np.cumsum(A)
for i in range(11):
  if N<=B[i]:
    name=[" "]*(i+1)
    if i==0:
      N=N
    else:
      N-B[i-1]
    for j in reversed(range(i+1)):
      if j>=1:
        if N==0:
          name[i-j]="z"
        else:
          name[i-j]=a[(N-1)//A[j-1]-1]
        N-=N//A[j-1]*A[j-1]
      else:
        if N==0:
          name[i-j]="z"
        else:
          name[i-j]=a[N-1]
    break

print(''.join(name))

Fixed submission:
import numpy as np
N=int(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
A=np.zeros(11,dtype=int)
for i in range(11):
  A[i]=(26**(i+1))
B=np.cumsum(A)
for i in range(11):
  if N<=B[i]:
    name=[" "]*(i+1)
    if i==0:
      N=N
    else:
      N-=B[i-1]
    for j in reversed(range(i+1)):
      if j>=1:
        if N==0:
          name[i-j]="z"
        else:
          name[i-j]=a[(N-1)//A[j-1]]
        N-=N//A[j-1]*A[j-1]
      else:
        if N==0:
          name[i-j]="z"
        else:
          name[i-j]=a[N-1]
    break

print(''.join(name))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
A=np.zeros(11,dtype=int)
for i in range(11):
  A[i]=(26**(i+1))
B=np.cumsum(A)
for i in range(11):
  if N<=B[i]:
    name=[" "]*(i+1)
    if i==0:
      N=N
    else:
      N-B[i-1]
    for j in reversed(range(i+1)):
      if j>=1:
        name[i-j]=a[N//A[j-1]-1]
        N-=N//A[j-1]*A[j-1]
      else:
        name[i-j]=a[N-1]
    break

print(''.join(name))

Fixed submission:
import numpy as np
N=int(input())
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
A=np.zeros(11,dtype=int)
for i in range(11):
  A[i]=(26**(i+1))
B=np.cumsum(A)
for i in range(11):
  if N<=B[i]:
    name=[" "]*(i+1)
    if i==0:
      N=N
    else:
      N-=B[i-1]
    for j in reversed(range(i+1)):
      if j>=1:
        if N==0:
          name[i-j]="z"
        else:
          name[i-j]=a[(N-1)//A[j-1]]
        N-=N//A[j-1]*A[j-1]
      else:
        if N==0:
          name[i-j]="z"
        else:
          name[i-j]=a[N-1]
    break

print(''.join(name))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
M=collections.Counter(A)
for i in range(Q):
  B,C=map(int,input().split())
  M[C]+=M[B]
  M[B]=0
  ans=0
  for j in M.items():
    ans+=j[0]*j[1]
  print(ans)

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
M=collections.Counter(A)
ans=0
for j in M.items():
  ans+=j[0]*j[1]
for i in range(Q):
  B,C=map(int,input().split())
  ans+=(C-B)*M[B]
  M[C]+=M[B]
  M[B]=0
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
B=set(A)
A.sort()
ans=[1]*max(A)
for i in range(len(A)):
  if ans[A[i]-1]!=0:
    if i>0 and A[i]==A[i-1]:
      ans[A[i]-1]=0
    for j in range(A[i]*2,max(A)+1,A[i]):
      ans[j-1]=0
k=0
for i in A:
  if ans[i-1]==1:
    k+=1
print(k)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=set(A)
A.sort()
S=max(A)
ans=[1]*S
for i in range(len(A)):
  if ans[A[i]-1]!=0:
    if i>0 and A[i]==A[i-1]:
      ans[A[i]-1]=0
    for j in range(A[i]*2,S+1,A[i]):
      ans[j-1]=0
k=0
for i in A:
  if ans[i-1]==1:
    k+=1
print(k)
Buggy python submission (verdict: Runtime Error):
import math
import decimal
A,B=input().split()
print(Decimal(A)*Decimal(B)//1)

Fixed submission:
A,B=input().split()
A=int(A)
B=int(B[0])*100+int(B[2:4])
C=A*B
if len(str(C))<3:
  print(0)
else:
  print(int(str(C)[0:len(str(C))-2]))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
A=np.zeros(N+1)
a=list(map(int,input().split()))
for i in range(N+1):
  A[i]=a[i]
v=0
j=0
k=0
B=np.zeros(N+1)
for i in range(N+1):
  B[i]=N-i
for i in reversed(range(0, N+1)):
  j+=A[i]/(2**i)
  if i==N:
    k=A[i]
  else:
    k=min(k+A[i],2**i-np.sum(A[0:i]*(2**(B[0:i]-(N-i)))))
  v+=k

if j>1:
  print(-1)
else:
  print(int(v))

Fixed submission:
import numpy as np
N,M,X=map(int,input().split())
C=np.zeros(N,dtype=int)
A=np.zeros([N,M],dtype=int)
for i in range(N):
    T=list(map(int,input().split()))
    C[i]=T[0]
    for j in range(M):
        A[i,j]=T[j+1]
a=np.zeros(N,dtype=int)
ans=-1
while a.all()!=1:
  if ((a@A)>=X).all():
    if ans==-1:
        ans=a@(C.T)
    elif a@(C.T)<ans:
        ans=a@(C.T)
  for i in range(N):
    if a[N-i-1]==0:
      a[N-i-1]=1
      break
    else:
      a[N-i-1]=0

if ((a@A)>=X).all():
  if ans==-1:
      ans=a@(C.T)
  elif a@(C.T)<ans:
      ans=a@(C.T)

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M,X=map(int,input().split())
C=np.zeros(N,dtype=int)
A=np.zeros([N,M],dtype=int)
for i in range(N):
    T=list(map(int,input().split()))
    C[i]=T[0]
    for j in range(M):
        A[i,j]=T[j+1]
a=np.zeros(N,dtype=int)
ans=-1
while a.all()!=1:
  if ((a@A)>X).all():
    if ans==-1:
        ans=a@(C.T)
    elif a@(C.T)<ans:
        ans=a@(C.T)
  for i in range(N):
    if a[N-i-1]==0:
      a[N-i-1]=1
      break
    else:
      a[N-i-1]=0

a=np.array([0,1,1])
if ((a@A)>=X).all():
  if ans==-1:
      ans=a@(C.T)
  elif a@(C.T)<ans:
      ans=a@(C.T)

print(ans)

Fixed submission:
import numpy as np
N,M,X=map(int,input().split())
C=np.zeros(N,dtype=int)
A=np.zeros([N,M],dtype=int)
for i in range(N):
    T=list(map(int,input().split()))
    C[i]=T[0]
    for j in range(M):
        A[i,j]=T[j+1]
a=np.zeros(N,dtype=int)
ans=-1
while a.all()!=1:
  if ((a@A)>=X).all():
    if ans==-1:
        ans=a@(C.T)
    elif a@(C.T)<ans:
        ans=a@(C.T)
  for i in range(N):
    if a[N-i-1]==0:
      a[N-i-1]=1
      break
    else:
      a[N-i-1]=0

if ((a@A)>=X).all():
  if ans==-1:
      ans=a@(C.T)
  elif a@(C.T)<ans:
      ans=a@(C.T)

print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
if S="ABC":
  print("ARC")
else:
  print("ABC")

Fixed submission:
S=input()
if S=="ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p=list(map(int,input().split()))

for i in range(N):
  p[i]=(1+p[i])/2
  
ans=[0]*(N-K+1)
for i in range(N-K+1):
  ans[i]=sum(p[i:i+K])

print(max(ans))

Fixed submission:
N, K = map(int, input().split())
p=list(map(int,input().split()))

for i in range(N):
  p[i]=(1+p[i])/2
  
ans=[0]*(N-K+1)
ans[0]=sum(p[:K])
for i in range(1, N-K+1):
  ans[i]=ans[i-1]-p[i-1]+p[i+K-1]

print(max(ans))

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

for i in range(N):
  p[i]=(1+p[i])/2
  
ans=0

for i in range(N-K+1):
  ans=max(ans, sum(p[i:i+K]))

print(ans)

Fixed submission:
N, K = map(int, input().split())
p=list(map(int,input().split()))

for i in range(N):
  p[i]=(1+p[i])/2
  
ans=[0]*(N-K+1)
ans[0]=sum(p[:K])
for i in range(1, N-K+1):
  ans[i]=ans[i-1]-p[i-1]+p[i+K-1]

print(max(ans))
Buggy python submission (verdict: Runtime Error):
import numpy as np
import queue
H,W=map(int,input().split())
S=list()
for m in range(H):
  S.append(input())
ans=0
i,j=7,6
if S[i][j]==".":
    L=[[-1]*W for i in range(H)]
    L[i][j]=0
    q=queue.Queue()
    q.put([i,j])
    while not q.empty():
      r=q.get()
      for k,l in [[1,0],[0,-1],[0,1],[-1,0]]:
        if r[0]+k>=0 and r[0]+k<H and r[1]+l>=0 and r[1]+l<W and S[r[0]+k][r[1]+l]=="." and L[r[0]+k][r[1]+l]==-1:
          L[r[0]+k][r[1]+l]=L[r[0]][r[1]]+1
          q.put([r[0]+k,r[1]+l])
    ans=max(ans,max(list(map(lambda x: max(x),L))))
print(ans)

Fixed submission:
import numpy as np
import queue
H,W=map(int,input().split())
S=list()
for i in range(H):
  S.append(input())
ans=0
  
for i in range(H):
  for j in range(W):
    if S[i][j]==".":
      L=[[-1]*W for i in range(H)]
      L[i][j]=0
      q=queue.Queue()
      q.put([i,j])
      while not q.empty():
        r=q.get()
        for k,l in [[1,0],[0,-1],[0,1],[-1,0]]:
          if r[0]+k>=0 and r[0]+k<H and r[1]+l>=0 and r[1]+l<W and S[r[0]+k][r[1]+l]=="." and L[r[0]+k][r[1]+l]==-1:
            L[r[0]+k][r[1]+l]=L[r[0]][r[1]]+1
            q.put([r[0]+k,r[1]+l])
      ans=max(ans,max(list(map(lambda x:max(x),L))))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,W,M = map(int,input().split())
X = [0 for i in range(H)]
Y = [0 for j in range(W)]
combi = []
for k in range(M):
    pos = list(map(int,input().split()))
    X[pos[0]-1]+=1
    Y[pos[1]-1]+=1
    combi.append(pos)
a = max(X)
b = max(Y)
X_max = []
Y_max = []
for l in range(H):
    if X[l] == a:
        X_max.append(l+1)
for m in range(W):
    if Y[m] == b:
        Y_max.append(m+1)
flg = 1
for p in X_max:
    for q in Y_max:
        ls = [p,q]
        if not ls in combi:
            flg = 0
            break
print(a + b - flg)

Fixed submission:
H,W,M = map(int,input().split())
X = [0 for i in range(H)]
Y = [0 for j in range(W)]
combi = []
for k in range(M):
    pos = list(map(int,input().split()))
    X[pos[0]-1]+=1
    Y[pos[1]-1]+=1
    combi.append(1000000007*pos[0]+pos[1])
a = max(X)
b = max(Y)
X_max = [0 for d in range(H)]
Y_max = [0 for e in range(W)]
for l in range(H):
    if X[l] == a:
        X_max[l]+=1
for m in range(W):
    if Y[m] == b:
        Y_max[m]+=1
X_count = X_max.count(1)
Y_count = Y_max.count(1)
chance = X_count*Y_count
flg = 1
for s in combi:
    ans1 = s//1000000007
    ans2 = s % 1000000007
    if X_max[ans1-1]==1 and Y_max[ans2-1]==1:
        chance-=1
if chance > 0:
    flg = 0
print(a + b - flg)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
scores = list(map(int, input().split()))
grades =[]
for i in range(K+1,N+2):
    before = 1
    for j in range(K):
        before = before*scores[i-j-2]
    grades.append(before)

for k in range(N-K):
    if grades[k]>=grades[k+1]:
        print("No")
    else:
        print("Yes")


Fixed submission:
N, K = map(int, input().split())
scores = list(map(int, input().split()))

for k in range(N-K):
    if scores[k] >= scores[k+K]:
        print("No")
    else:
        print("Yes")

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

for i in range(K+1,N+1):
    before = 1
    after = 1
    for j in range(K):
        before = before*scores[i-j-2]
    for k in range(K):
        after = after*scores[i-k-1]
    if before>=after:
        print("No")
    else:
        print("Yes")

Fixed submission:
N, K = map(int, input().split())
scores = list(map(int, input().split()))

for k in range(N-K):
    if scores[k] >= scores[k+K]:
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
price = list(map(int,input().split()))
price.append(0)
stock = 0
money = 1000
for i in range(N):
    if price[i] <= price[i+1]:
        while money >=price[i]:
            stock += 1
            money -= price[i]
    else:
        while stock>0:
            money += price[i]
            stock-=1
print(money)      

Fixed submission:
import math
N = int(input())
price = list(map(int,input().split()))
price.append(0)
stock = 0
money = 1000
for i in range(N):
    if price[i] <= price[i+1]:
        times = math.floor(money/price[i])
        money -= price[i]*times
        stock += times
    else:
        money += price[i]*stock
        stock =0
print(money)
Buggy python submission (verdict: Time Limit Exceeded):
import math
data = input()
num = int(data)
o = input().rstrip().split(" ")
list =[]
for i in o:
    list.append(int(i))
list.sort()
p = input()
times = int(p)
ans = sum(list)
num_count=[list.count(i) for i in range(100001)]
for i in range(times):
    B, C = map(int, input().split(" "))
    a = num_count[B]
    num_count[B] = 0
    num_count[C] += a
    ans += a*(C-B)
    print(ans)

Fixed submission:
import math
data = input()
num = int(data)
o = input().rstrip().split(" ")
list =[]
for i in o:
    list.append(int(i))
p = input()
times = int(p)
ans = sum(list)
num_count=[0 for i in range(100001)]
for i in list:
    num_count[i] += 1
for i in range(times):
    B, C = map(int, input().split(" "))
    a = num_count[B]
    num_count[B] = 0
    num_count[C] += a
    ans += a*(C-B)
    print(ans)

Buggy python submission (verdict: Runtime Error):
import math
data = input()
num = int(data)
o = input().rstrip().split(" ")
list =[]
for i in o:
    list.append(int(i))
list.sort()
p = input()
times = int(p)
num_count=[list.count(i) for i in range(100000)]
for i in range(times):
    B, C = map(int, input().split(" "))
    a = num_count[B]
    num_count[B] = 0
    num_count[C] += a
    ans = 0
    for i in range(100000):
        ans = ans + (i) * num_count[i]
    print(ans)


Fixed submission:
import math
data = input()
num = int(data)
o = input().rstrip().split(" ")
list =[]
for i in o:
    list.append(int(i))
p = input()
times = int(p)
ans = sum(list)
num_count=[0 for i in range(100001)]
for i in list:
    num_count[i] += 1
for i in range(times):
    B, C = map(int, input().split(" "))
    a = num_count[B]
    num_count[B] = 0
    num_count[C] += a
    ans += a*(C-B)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
num = input()
data = input().rstrip().split(" ")
ans = 1
for i in data:
    ans = ans*int(i)
if ans > 1000000000000000000:
    ans = -1
print(ans)

Fixed submission:
num = input()
data = input().rstrip().split(" ")
ans = 1
if "0" in data:
    ans = 0
else:
    for i in data:
        ans = ans*int(i)
        if ans > 1000000000000000000:
            ans = -1
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
data = input().rstrip().split(" ")
tele = input().rstrip().split(" ")
telepo = [int(i) for i in tele]

max = int(data[1])
limit = max
times = 0
pos = 1
experience = [1]
while max > 0:
    pos = telepo[pos - 1]
    max -= 1
    times += 1
    #print(pos)
    if pos in experience:
        length = len(experience) - experience.index(pos)
        max = max % length
        if max == 0:
            break
        while max > 0:
            pos = telepo[pos - 1]
            max -= 1
            times += 1
            #print(pos)
        break
    experience.append(pos)
print(pos)

Fixed submission:
data = input().rstrip().split(" ")
tele = input().rstrip().split(" ")
telepo = [int(i) for i in tele]

max = int(data[1])
limit = max
times = 0
pos = 1
experience = [1]
check = {1}
before = 0
while max > 0:
    pos = telepo[pos - 1]
    max -= 1
    times += 1
    before = len(check)
    check.add(pos)
    if before == len(check):
        length = len(experience) - experience.index(pos)
        max = max % length
        if max == 0:
            break
        while max > 0:
            pos = telepo[pos - 1]
            max -= 1
            times += 1
            #print(pos)
        break
    experience.append(pos)
print(pos)

Buggy python submission (verdict: Runtime Error):
max = int(data[1])
limit = max
times = 0
pos = 1
experience = [1]
while max > 0:
    pos = telepo[pos - 1]
    max -= 1
    times += 1
    #print(pos)
    if pos in experience:
        length = len(experience) - experience.index(pos)
        max = max % length
        if max == 0:
            break
        while max > 0:
            pos = telepo[pos - 1]
            max -= 1
            times += 1
            #print(pos)
        break
    experience.append(pos)
print(pos)

Fixed submission:
data = input().rstrip().split(" ")
tele = input().rstrip().split(" ")
telepo = [int(i) for i in tele]

max = int(data[1])
limit = max
times = 0
pos = 1
experience = [1]
check = {1}
before = 0
while max > 0:
    pos = telepo[pos - 1]
    max -= 1
    times += 1
    before = len(check)
    check.add(pos)
    if before == len(check):
        length = len(experience) - experience.index(pos)
        max = max % length
        if max == 0:
            break
        while max > 0:
            pos = telepo[pos - 1]
            max -= 1
            times += 1
            #print(pos)
        break
    experience.append(pos)
print(pos)
Buggy python submission (verdict: Runtime Error):
r = input()
print(r*2*3.14)

Fixed submission:
r = int(input())
print(r*2*3.14)

Buggy python submission (verdict: Runtime Error):
r = input()
print(r*2*3.14)

Fixed submission:
r = int(input())
print(r*2*3.14)