Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
s=sys.stdin
while 1:
 n=int(s.readline())
 if n==0:break
 a=1;s='123456'
 for _ in[0]*n:
  s=[s[int(e)]for e in{'N':"152304",'E':"310542",'W':"215043",'S':"402351",'R':"024135",'L':"031425"}[s.readline()[0]]]
  a+=int(s[0])
 print(a)


Fixed submission:
import sys
e=sys.stdin.readline
p={'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),
   'S':(4,0,2,3,5,1),'R':(0,2,4,1,3,5),'L':(0,3,1,4,2,5)}
for n in iter(e,'0\n'):
 a=1;s=[1,2,3,4,5,6]
 for _ in[0]*int(n):
  s=[s[i]for i in p[e()[0]]]
  a+=s[0]
 print(a)
Buggy python submission (verdict: Runtime Error):
for e in iter(input,'0'):
while 1:
 b,c=1000-int(e),0
 for i in[500,100,50,10,5]:
  d,b=divmod(b,i)
  c+=d
 print(b+c)


Fixed submission:
for e in iter(input,'0'):
 a,b=0,1000-int(e)
 for i in[500,100,50,10,5]:
  a+=b//i
  b%=i
 print(a+b)
Buggy python submission (verdict: Runtime Error):
import bisect
for e in iter(input,'0'):
 n=int(e)
 c=[sorted(int(input())for _ in[0]*n)]
 c+=[sorted(set(range(1,2*n+1))-set(c[0]))]
 t=f=0
 while 1:
  if not c[t]:break
  x=bisect.bisect(c[t],f)
  f=c[t].pop(x)if x<=len(c[t])else 0
  t^=1
 for i in[1,0]:print(len(c[i]))


Fixed submission:
import bisect
for e in iter(input,'0'):
 n=int(e)
 c=[sorted(int(input())for _ in[0]*n)]
 c+=[sorted(set(range(1,2*n+1))-set(c[0]))]
 t=f=0
 while 1:
  if not c[t]:break
  x=bisect.bisect(c[t],f)
  f=c[t].pop(x)if x<len(c[t])else 0
  t^=1
 for i in[1,0]:print(len(c[i]))
Buggy python submission (verdict: Runtime Error):
import sys
r=sys.stdin.readline
for e in iter(r,'0'):
 R=[[]for _ in[0]*-~int(e)]
 for _ in[0]*int(r()):
  a,b=map(int,r().split())
  R[a]+=[b];R[b]+=[a]
 for m in R[1][:]:R[1]+=R[m]
 print(len({*R[1]}-{1}))


Fixed submission:
def s():
 import sys
 r=sys.stdin.readline
 for e in iter(r,'0\n'):
  R=[[]for _ in[0]*-~int(e)]
  for _ in[0]*int(r()):
   a,b=map(int,r().split())
   R[a]+=[b];R[b]+=[a]
  for m in R[1][:]:R[1]+=R[m]
  print(len({*R[1]}-{1}))
s()
Buggy python submission (verdict: Runtime Error):
from itertools import permutations as P
import sys
r=sys.stdin.readline
for e in iter(r,'0'):
 n,k=int(e),int(r())
 C=[r()for _ in[0]*n]
 print(len(set(''.join(s)for s in P(C,k))))


Fixed submission:
def s():
 from itertools import permutations as P
 for e in iter(input,'0'):
  n,k=int(e),int(input())
  C=[input()for _ in[0]*n]
  print(len(set(''.join(s)for s in P(C,k))))
if'__main__'==__name__:s()
Buggy python submission (verdict: Runtime Error):
for e in iter(input,'0 0'):
 w,h=map(int,e.split())
 M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w]
 for i in range(1,w):
  for j in range(1,h):
   a=M[i-1][j][:2]
   b=M[i][j-1][2:]
   M[i][j]=[b[1],a,a[1],b]
 print((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5)


Fixed submission:
def s():
 for e in iter(input,'0 0'):
  w,h=map(int,e.split())
  M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w]
  for i in range(1,w):
   for j in range(1,h):
    a,b=M[i-1][j][:2]
    c,d=M[i][j-1][2:]
    M[i][j]=[d,a+b,b,c+d]
  print((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5)
s()
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=[0]*N
for _ in[0]*K:
 a,b=map(int,input().split())
 S[a-1]=b
dp=[0]*9
st,nd=S[:2]
if st:
 if nd:dp[~-st*3+~-nd]=1
 else:dp[~-st*3:st*3]=[1]*3
elif nd:dp[~-st::3]=[1]*3
else:dp=[1]*9
for i in range(2,N):
 cur=S[i];tmp=[0]*9
 if cur:
  cur-=1
  for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 else:
  for cur in range(3):
   for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 dp=tmp[:]
print(sum(dp)%10000)


Fixed submission:
N,K=map(int,input().split())
S=[0]*N
for _ in[0]*K:a,b=map(int,input().split());S[a-1]=b
dp=[0]*9
st,nd=S[:2]
if st:
 if nd:dp[st*2+~-nd]=1
 else:dp[st*2:st*3]=[1]*3
elif nd:dp[~-nd::3]=[1]*3
else:dp=[1]*9
for i in range(2,N):
 cur=S[i]-1;tmp=[0]*9
 if cur+1:
  for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 else:
  for cur in range(3):
   for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 dp=tmp[:]
print(sum(dp)%10000)
Buggy python submission (verdict: Runtime Error):
r=a=o=0
while 1:
 l,m,n=sorted(list(map(int,input().split())))
 if l+m<=n:break
 c=l*l+m*m-n*n
 if c>0:a+=1
 elif c<0:o+=1
 else:r+=1
print(sum(r,a,o),r,a,o)


Fixed submission:
r=a=o=0
while 1:
 l,m,n=sorted(list(map(int,input().split())))
 if l+m<=n:break
 c=l*l+m*m-n*n
 if c>0:a+=1
 elif c<0:o+=1
 else:r+=1
print(r+a+o,r,a,o)
Buggy python submission (verdict: Runtime Error):
input()
n=sorted(list(map(int,input().split())))
m=n[0]
a={}
for x in range(1,int(m**.5)+1):
    if m%x==0:a|={x,m//x}
for c in sorted(list(a)):
    for k in n[1:]:
        if k%c:break
    else:print(c)


Fixed submission:
input()
n=sorted(list(map(int,input().split())))
m=n[0]
a=set()
for x in range(1,int(m**.5)+1):
    if m%x==0:a|={x,m//x}
for c in sorted(list(a)):
    for k in n[1:]:
        if k%c:break
    else:print(c)
Buggy python submission (verdict: Runtime Error):
a=sorted([int(input())for _ in[0]*int(input())])[:4]
b=[]
for i in range(3):
 for d in a[i:4]:
  c=a[i]
  b+=[c*10**len(d)+d,d*10**len(c)+c]
print(sorted(b)[2])


Fixed submission:
import itertools
print(sorted(int(f'{a}{b}')for a,b in itertools.permutations(sorted(int(input())for _ in[0]*int(input()))[:4],2))[2])
Buggy python submission (verdict: Runtime Error):
n,m,r=map(int,input().split())
a,b=sorted([n-1,r-m*n])
A=1
for i in range(a):A*=i+1
B=A
for i in range(a,b):B*=i+1
C=B
for i in range(b,a+b):C*=i+1
print(int(C/B/A))


Fixed submission:
n,m,r=map(int,input().split())
r-=m*n
if r<0:print(0)
else:
 d=1
 for i in range(r):d*=i+1
 u=1
 for i in range(r):u*=i+n
 print(u//d)

Buggy python submission (verdict: Runtime Error):
n,m,r=map(int,input().split())
a,b=sorted([n-1,r-m*n])
A=1
for i in range(a):A*=i+1
B=A
for i in range(a,b):B*=i+1
C=B
for i in range(b,a+b):C*=i+1
print([int(C/B/A),0][a<1])


Fixed submission:
n,m,r=map(int,input().split())
r-=m*n
if r<0:print(0)
else:
 d=1
 for i in range(r):d*=i+1
 u=1
 for i in range(r):u*=i+n
 print(u//d)

Buggy python submission (verdict: Runtime Error):
n,m,r=map(int,input().split())
a,b=sorted([n-1,r-m*n])
A=1
for i in range(a):A*=i+1
B=A
for i in range(a,b):B*=i+1
C=B
for i in range(b,a+b):C*=i+1
print(0 if a<1 else int(C/B/A))


Fixed submission:
n,m,r=map(int,input().split())
r-=m*n
if r<0:print(0)
else:
 d=1
 for i in range(r):d*=i+1
 u=1
 for i in range(r):u*=i+n
 print(u//d)

Buggy python submission (verdict: Runtime Error):
n,m,r=map(int,input().split())
r-=m*n
if r<0:print(0)
else:
 a=1
 for i in range(r):a*=i+n/~-i
 print(int(a))


Fixed submission:
n,m,r=map(int,input().split())
r-=m*n
if r<0:print(0)
else:
 d=1
 for i in range(r):d*=i+1
 u=1
 for i in range(r):u*=i+n
 print(u//d)

Buggy python submission (verdict: Runtime Error):
n,m,r=map(int,input().split())
r-=m*n
if r<0:print(0)
else:
 a=1
 for i in range(r):a*=(i+n)/-~i
 print(int(a+.1))


Fixed submission:
n,m,r=map(int,input().split())
r-=m*n
if r<0:print(0)
else:
 d=1
 for i in range(r):d*=i+1
 u=1
 for i in range(r):u*=i+n
 print(u//d)
Buggy python submission (verdict: Time Limit Exceeded):
f=lambda n:f(n-1)+f(n-2)if n>1 else 1
print(f(int(input())))


Fixed submission:
p,n=(1+5**.5)/2,int(input())+1
print(int((p**n-(1-p)**n)/5**.5))

Buggy python submission (verdict: Runtime Error):
f=[1,1]
for _ in[0]*43:f+=[f(-2)+f(-1)]
print(f[int(input())])


Fixed submission:
p,n=(1+5**.5)/2,int(input())+1
print(int((p**n-(1-p)**n)/5**.5))
Buggy python submission (verdict: Runtime Error):
if'__main__'==__name__:s()
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for l in range(2,n):
  for i in range(1,n-l+1):
   j=i+l-1;m[i][j]=1e6
   for k in range(i,j):m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
 print(m[1][n-1])


Fixed submission:
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if not 0<m[r][c]<=x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()

Buggy python submission (verdict: Runtime Error):
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(1,n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if 1>m[r][c]or m[r][c]>x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()


Fixed submission:
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if not 0<m[r][c]<=x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()

Buggy python submission (verdict: Runtime Error):
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(1,n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if 1>m[r][c]or m[r][c]>x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()


Fixed submission:
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if not 0<m[r][c]<=x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()

Buggy python submission (verdict: Runtime Error):
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(1,n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if 1>m[r][c]or m[r][c]>x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()


Fixed submission:
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if not 0<m[r][c]<=x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()
Buggy python submission (verdict: Time Limit Exceeded):
for _ in[0]*int(input()):
 X,Y=' '+input(),' '+input();m,n=len(X),len(Y);c=[[0]*n for _ in[0]*m]
 for i in range(1,m):
  for j in range(1,n):c[i][j]=(max(c[i-1][j],c[i][j-1]),1+c[i-1][j-1])[X[i]==Y[j]]
 print(c[m-1][n-1])


Fixed submission:
def m():
 e=input
 a=''
 for _ in[0]*int(e()):
  X,z=e(),[]
  for y in e():
   s=i=0
   for k in z:
    t=X.find(y,s)+1
    if t<1:break
    if t<k:z[i]=t
    s=k;i+=1
   else:
    t=X.find(y,s)+1
    if t:z+=[t]
  a+=f'\n{len(z)}'
 print(a[1:])
if'__main__'==__name__:m()

Buggy python submission (verdict: Time Limit Exceeded):
for _ in[0]*int(input()):
 X,Y=' '+input(),' '+input();m,n=len(X),len(Y);c=[[0]*n for _ in[0]*m]
 for i in range(1,m):
  for j in range(1,n):c[i][j]=1+c[i-1][j-1]if X[i]==Y[j]else c[i-1][j]if c[i-1][j]>c[i][j-1]else c[i][j-1]
 print(c[m-1][n-1])


Fixed submission:
def m():
 e=input
 a=''
 for _ in[0]*int(e()):
  X,z=e(),[]
  for y in e():
   s=i=0
   for k in z:
    t=X.find(y,s)+1
    if t<1:break
    if t<k:z[i]=t
    s=k;i+=1
   else:
    t=X.find(y,s)+1
    if t:z+=[t]
  a+=f'\n{len(z)}'
 print(a[1:])
if'__main__'==__name__:m()

Buggy python submission (verdict: Runtime Error):
a=[]
for _ in[0]*int(input()):
 X,z=input(),[]
 for y in input():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=[len(z)]
print('\n'.join(a))


Fixed submission:
def m():
 e=input
 a=''
 for _ in[0]*int(e()):
  X,z=e(),[]
  for y in e():
   s=i=0
   for k in z:
    t=X.find(y,s)+1
    if t<1:break
    if t<k:z[i]=t
    s=k;i+=1
   else:
    t=X.find(y,s)+1
    if t:z+=[t]
  a+=f'\n{len(z)}'
 print(a[1:])
if'__main__'==__name__:m()

Buggy python submission (verdict: Runtime Error):
i=input
for _ in[0]*int(i()):
 X,z=i(),[]
 for y in i():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 print(len(z))


Fixed submission:
def m():
 e=input
 a=''
 for _ in[0]*int(e()):
  X,z=e(),[]
  for y in e():
   s=i=0
   for k in z:
    t=X.find(y,s)+1
    if t<1:break
    if t<k:z[i]=t
    s=k;i+=1
   else:
    t=X.find(y,s)+1
    if t:z+=[t]
  a+=f'\n{len(z)}'
 print(a[1:])
if'__main__'==__name__:m()
Buggy python submission (verdict: Runtime Error):
N=int(input())
for _ in[0]*N:
 r=[0]*N
 for i in input().split()[2:]:a[int(i)-1]=1
 print(*a)


Fixed submission:
N=int(input())
for _ in[0]*N:
 r=[0]*N
 for i in input().split()[2:]:r[int(i)-1]=1
 print(*r)
Buggy python submission (verdict: Runtime Error):
def s():
 e=sys.stdin.readline
 n,m=map(int,e().split())
 P=[[]for _ in[0]*n]
 C=[0]*n
 k=0
 for _ in[0]*m:
  s,t=map(int,e().split());P[s]+=[t];P[t]+=[s]
 for i in range(n):
  k+=1
  if C[i]<1:
   s=[i];C[i]=k
   while s:
    u=s.pop()
    for v in P[u]:
     if C[v]<1:C[v]=k;s+=[v]
 for _ in[0]*int(e()):
  a,b=map(int,e().split())
  print(['no','yes'][C[a]==C[b]])
if'__main__'==__name__:s()


Fixed submission:
import sys
def s():
 e=sys.stdin.readline
 n,m=map(int,e().split())
 P=[[]for _ in[0]*n]
 C=[0]*n
 k=0
 for _ in[0]*m:
  s,t=map(int,e().split());P[s]+=[t];P[t]+=[s]
 for i in range(n):
  k+=1
  if C[i]<1:
   s=[i];C[i]=k
   while s:
    u=s.pop()
    for v in P[u]:
     if C[v]<1:C[v]=k;s+=[v]
 for _ in[0]*int(e()):
  a,b=map(int,e().split())
  print(['no','yes'][C[a]==C[b]])
s()
Buggy python submission (verdict: Runtime Error):
import sys
from heapq import*
e=sys.stdin.readline
I=float("inf")
def m():
 n=int(e())
 A=[]
 for _ in[0]*n:
  e=list(map(int,e().split()))
  A+=[zip(e[2::2],e[3::2])]
 d=[0]+[I]*n
 H=[(0,0)]
 while H:
  u=heappop(H)[1]
  for v,c in A[u]:
   t=d[u]+c
   if d[v]>t:
    d[v]=t
    heappush(H,(t,v))
 print('\n'.join(f'{i} {d[i]}'for i in range(n)))
m()


Fixed submission:
from heapq import*
def m():
 n=int(input())
 A=[]
 for _ in[0]*n:
  e=list(map(int,input().split()))
  A+=[zip(e[2::2],e[3::2])]
 d=[0]+[float('inf')]*n
 H=[(0,0)]
 while H:
  u=heappop(H)[1]
  for v,c in A[u]:
   t=d[u]+c
   if d[v]>t:
    d[v]=t
    heappush(H,(t,v))
 print('\n'.join(f'{i} {d[i]}'for i in range(n)))
m()
Buggy python submission (verdict: Runtime Error):
def f(T,P):for i in range(len(T)):P!=T[i:i+len(P)]or print(i)
if'__main__'__name__:f(input(),input())


Fixed submission:
T,P=input(),input()
for i,t in enumerate(T):
 if t==P[0]and P==T[i:i+len(P)]:print(i)

Buggy python submission (verdict: Runtime Error):
def f(T,P):
 for i in range(len(T)):P!=T[i:i+len(P)]or print(i)
if'__main__'__name__:f(input(),input())


Fixed submission:
T,P=input(),input()
for i,t in enumerate(T):
 if t==P[0]and P==T[i:i+len(P)]:print(i)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=input().split()
for i in range(1,n):
 k=int(a[i])
 j=i-1
 while int(a[j])>k:
  a[j+1]=a[j]
  j-=1
 a[j+1]=k
 print(*a)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in range(1, N + 1):
    A[:i] = sorted(A[:i])
    print(*A)
Buggy python submission (verdict: Time Limit Exceeded):
def p(n):
 for i in range(2,n):
  if n%i==0:return 0
 return 1
n=int(input())
print(sum([p(int(input()))for _ in range(n)]))

Fixed submission:
import sys
input()
def s():print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin.readlines())))
if'__main__'==__name__:s()

Buggy python submission (verdict: Runtime Error):
def p(n):
 for i in range(2,x//2):
  if x%i==0:return 0
 return 1
n=int(input())
print(sum([p(int(input()))for _ in range(n)]))

Fixed submission:
import sys
input()
def s():print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin.readlines())))
if'__main__'==__name__:s()

Buggy python submission (verdict: Time Limit Exceeded):
c=0
n=int(input())
for _ in range(n):
 x=int(input())
 for i in range(2,x):
  if x%i==0:c+=1;break
print(n-c)


Fixed submission:
import sys
input()
def s():print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin.readlines())))
if'__main__'==__name__:s()

Buggy python submission (verdict: Time Limit Exceeded):
c=0
n=int(input())
for _ in range(n):
 x=int(input())
 if x!=2 and x%2==0:c+=1;continue
 for i in range(3,x,2):
  if x%i==0:c+=1;break
print(n-c)


Fixed submission:
import sys
input()
def s():print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin.readlines())))
if'__main__'==__name__:s()

Buggy python submission (verdict: Runtime Error):
for _ in[0]*int(input()):
 x=int(input())
 if 2 in[x,pow(2,x,x)]:c+=1
print(c)


Fixed submission:
import sys
input()
def s():print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin.readlines())))
if'__main__'==__name__:s()

Buggy python submission (verdict: Runtime Error):
import sys
input()
print(len(1 for x in map(int,sys.stdin)if 2 in[x,pow(2,x,x)]))


Fixed submission:
import sys
input()
def s():print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin.readlines())))
if'__main__'==__name__:s()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
r=[int(input())for _ in range(n)]
print(max([max(r[i+1:])-r[i]for i in range(n-1)]))

Fixed submission:
import sys
def f():
 s=1e10;b=-s
 input()
 for r in map(int,sys.stdin):
  if b<r-s:b=r-s
  if s>r:s=r
 print(b)
f()

Buggy python submission (verdict: Runtime Error):
import sys
n=int(input())
r=list(map(int,sys.stdin.read())
print(max([max(r[i+1:])-r[i]for i in range(n-1)]))

Fixed submission:
import sys
def f():
 s=1e10;b=-s
 input()
 for r in map(int,sys.stdin):
  if b<r-s:b=r-s
  if s>r:s=r
 print(b)
f()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n=int(input())
r=list(map(int,sys.stdin.read().split()))
print(max([max(r[i+1:])-r[i]for i in range(n-1)]))

Fixed submission:
import sys
def f():
 s=1e10;b=-s
 input()
 for r in map(int,sys.stdin):
  if b<r-s:b=r-s
  if s>r:s=r
 print(b)
f()

Buggy python submission (verdict: Runtime Error):
n=int(input())
r=[int(input())for _ in range(n)]
print(max([max(r[i+1:])-r[i]for i in range(min(r.remove(min(r))),n-1)]))

Fixed submission:
import sys
def f():
 s=1e10;b=-s
 input()
 for r in map(int,sys.stdin):
  if b<r-s:b=r-s
  if s>r:s=r
 print(b)
f()

Buggy python submission (verdict: Runtime Error):
b,s=-1e7,1e7
for _ in range(int(input())):
 r=int(input())
 b,s=max(b,c-s),min(s,c)
print(b)


Fixed submission:
import sys
def f():
 s=1e10;b=-s
 input()
 for r in map(int,sys.stdin):
  if b<r-s:b=r-s
  if s>r:s=r
 print(b)
f()

Buggy python submission (verdict: Runtime Error):
import sys
s=1e10,b=-s
input()
for r in map(int,sys.stdin):
 if b<r-s:b=r-s
 if s>r:s=r
print(b)


Fixed submission:
import sys
def f():
 s=1e10;b=-s
 input()
 for r in map(int,sys.stdin):
  if b<r-s:b=r-s
  if s>r:s=r
 print(b)
f()
Buggy python submission (verdict: Runtime Error):
n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
 for j in range(0,n-i-1):
  if c[j][1]>c[j+1][1]:c[j],c[j+1]=c[j+1],c[j]
 m=i
 for j in range(i,n):
  if b[m][1]>b[j][1]:m=j
 d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d)
print(['Not s','S'][b==s]+'table')


Fixed submission:
n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
 for j in range(n-i-1):
  if c[j][1]>c[j+1][1]:c[j:j+2]=c[j+1],c[j]
 m=i
 for j in range(i,n):
  if d[m][1]>d[j][1]:m=j
 d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d);print(['Not s','S'][c==d]+'table')

Buggy python submission (verdict: Runtime Error):
n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
 for j in range(0,n-i-1):
  if c[j][1]>c[j+1][1]:c[j],c[j+1]=c[j+1],c[j]
 m=i
 for j in range(i,n):
  if d[m][1]>d[j][1]:m=j
 d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d)
print(['Not s','S'][b==s]+'table')


Fixed submission:
n=int(input())
c=input().split();d=c[:]
for i in range(n-1):
 for j in range(n-i-1):
  if c[j][1]>c[j+1][1]:c[j:j+2]=c[j+1],c[j]
 m=i
 for j in range(i,n):
  if d[m][1]>d[j][1]:m=j
 d[i],d[m]=d[m],d[i]
print(*c);print("Stable")
print(*d);print(['Not s','S'][c==d]+'table')
Buggy python submission (verdict: Runtime Error):
s=[]
for p in input().split():
 if p in "+-*":
  b=s.pop()
  a=s.pop()
  s.append(str(eval(a+p+b)))
 else:
  s.append(c)
print(*s)


Fixed submission:
s=[]
for p in input().split():
 s+=[str(eval(s.pop(-2)+p+s.pop()))if p in"+-*"else p]
print(*s)
Buggy python submission (verdict: Runtime Error):
s=[]
for _ in range(int(input())):
 e=input()
 if e[0]=='i':s=[e.split()[1]]+s
 else:
  n=len(s)
  if n==6:s.remove(e.split()[1])
  elif n%2:s=s[1:]
  else:s.pop()
print(*s)


Fixed submission:
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()

Buggy python submission (verdict: Runtime Error):
s=[]
for _ in range(int(input())):
 e=input()
 if'i'==e[0]:s=[e.split()[1]]+s
 else:
  if' '==e[6]:s.remove(e.split()[1])
  elif len(e)%2:s=s[1:]
  else:s.pop()
print(*s)


Fixed submission:
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()

Buggy python submission (verdict: Time Limit Exceeded):
s=[]
for _ in range(int(input())):
 e=input()
 if'i'==e[0]:s=[e.split()[1]]+s
 else:
  if' '==e[6]:
   m=e.split()[1]
   if m in s:s.remove(m)
  elif len(e)%2:s=s[1:]
  else:s.pop()
print(*s)


Fixed submission:
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()

Buggy python submission (verdict: Time Limit Exceeded):
s=[]
for _ in range(int(input())):
 e=input()
 if'i'==e[0]:s=[e.split()[1]]+s
 else:
  if' '==e[6]:
   m=e.split()[1]
   if m in s:s.remove(m)
  elif len(e)%2:s=s[1:]
  else:s.pop()
print(*s)


Fixed submission:
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()
Buggy python submission (verdict: Runtime Error):
s=[]
p=[]
a=i=0
for c in input():
 if"\\"==c:s+=[i]
 elif c=="/"and s:
  j=p.pop()
  t=i-j
  a+=t
  while p and p[-1][0]>j:t+=p[-1][1];p.pop()
  p+=[(j,t)]
 i+=1
print(ans)
if p:print(len(p),*list(zip(*p))[1])
else:print(0)


Fixed submission:
s=[]
p=[]
a=i=0
for c in input():
 if"\\"==c:s+=[i]
 elif"/"==c and s:
  j=s.pop()
  t=i-j
  a+=t
  while p and p[-1][0]>j:t+=p[-1][1];p.pop()
  p+=[(j,t)]
 i+=1
print(a)
if p:print(len(p),*list(zip(*p))[1])
else:print(0)