Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=[[0 for j in range(m)]for i in range(n)]
B=[[0 for j in range(1)]for i in range(m)]
C=[[0 for j in range(1)]for i in range(n)]
for i in range(n):
  A1,A2,A3,A4=map(int,input().split())
  A[i][0]=A1
  A[i][1]=A2
  A[i][2]=A3
  A[i][3]=A4
for i in range(m):
  B[i][0]=int(input())
S=int(0)
for j in range(n):
  for i in range(m):
    S=S+(A[j][i]*B[i][0])
  C[j][0]=S3
for i in range(n):
  print(C[j][0])


Fixed submission:
#ITP1_6_D
n,m=map(int,input().split())
A=[[0 for j in range(m)]for i in range(n)]
B=[[0 for j in range(1)]for i in range(m)]
C=[[0 for j in range(1)]for i in range(n)]
for i in range(n):
  D=list(map(int,input().split()))
  for j in range(m):
    A[i][j]=D[j]
for i in range(m):
  B[i][0]=int(input())
S=int(0)
for j in range(n):
  for i in range(m):
    S=S+(A[j][i]*B[i][0])
  C[j][0]=S
  S=0
for i in range(n):
  print(C[i][0])

Buggy python submission (verdict: Runtime Error):
#ITP1_6_D
n,m=map(int,input().split())
A=[[0 for j in range(m)]for i in range(n)]
B=[[0 for j in range(1)]for i in range(m)]
C=[[0 for j in range(1)]for i in range(n)]
for i in range(n):
  A1,A2,A3,A4=map(int,input().split())
  A[i][0]=A1
  A[i][1]=A2
  A[i][2]=A3
  A[i][3]=A4
for i in range(m):
  B[i][0]=int(input())
S=int(0)
for j in range(n):
  for i in range(m):
    S=S+(A[j][i]*B[i][0])
  C[j][0]=S
  S=0
for i in range(n):
  print(C[i][0])



Fixed submission:
#ITP1_6_D
n,m=map(int,input().split())
A=[[0 for j in range(m)]for i in range(n)]
B=[[0 for j in range(1)]for i in range(m)]
C=[[0 for j in range(1)]for i in range(n)]
for i in range(n):
  D=list(map(int,input().split()))
  for j in range(m):
    A[i][j]=D[j]
for i in range(m):
  B[i][0]=int(input())
S=int(0)
for j in range(n):
  for i in range(m):
    S=S+(A[j][i]*B[i][0])
  C[j][0]=S
  S=0
for i in range(n):
  print(C[i][0])
Buggy python submission (verdict: Runtime Error):
#ITP1_7_B
a=int(0)
m=int(0)
while True:
  n,x=map(int,input().split())
  if n ==0 and x==0:
    break
  for i in range(n):
    j=i+1
    for j in range(n):
      h=i+2
      for h in range(n):
        if i+k+h==x:
          k=k+1
  print(k)
        
    


Fixed submission:
#ITP1_7_B
m=int(0)
while True:
  m=0
  n,x=map(int,input().split())
  if n ==0 and x==0:
    break
  for a in range(1,n-1):
    for b in range(a+1,n):
      for c in range(b+1,n+1):
        if a+b+c==x:
          m=m+1
  print(m)
Buggy python submission (verdict: Runtime Error):
W, H, x, y, r = map(int, input().split())
if x >= r and x + r <= W and y >= r and  y + r <= H
  print("Yes")
else :
  print("No")



Fixed submission:
W,H,x,y,r = map(int,input().split())

a = x+r
b = y+r
c = x-r
d = y-r

if a<=W and b<=H and c>=0 and d>=0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
W, H, x, y, r = map(int, input().split())
if x >= r and x + r <= W and y >= r and y + r <= H :
print("Yes")
else:
  print("No")


Fixed submission:
W,H,x,y,r = map(int,input().split())

a = x+r
b = y+r
c = x-r
d = y-r

if a<=W and b<=H and c>=0 and d>=0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
input()
x = input()
a = x.split()
b = list(map(int,a))
print("{} {} {}".format(min(b),max(b),sum(b)))


Fixed submission:
k = input()
i = list(map(int,input().split()))
print(min(i),max(i),sum(i))
Buggy python submission (verdict: Runtime Error):
import sys
a=list(map(float,sys.stdin.readline()))
print(max(a)-min(a))


Fixed submission:
x = []
while 1:
    try:
        h = float(input())
        x.append(h)
    except EOFError:
        break
print(max(x)-min(x))
Buggy python submission (verdict: Runtime Error):
n=int(input())
while True:
  if n==0:
    break
  x=[0 for i in range(7)]
  for i in range(n):
    a=int(input())
    if 0<=a<10:
      x[0]+=1
    elif 10<=a<20:
      x[1]+=1
    elif 20<=a<30:
      x[2]+=1
    elif 30<=a<40:
      x[3]+=1
    elif 40<=a<50:
      x[4]+=1 
    elif 50<=a<60:
      x[5]+=1
    else:
      x[6]+=1
  for i in range(7):
    if x[i]==0:
      print(0)
    else:
      print('{}'.format(x[i]))


Fixed submission:
while True:
  x=[0 for i in range(7)]
  n=int(input())
  if n==0:
    break
  for i in range(n):
    a=int(input())
    if 0<=a<10:
      x[0]+=1
    elif 10<=a<20:
      x[1]+=1
    elif 20<=a<30:
      x[2]+=1
    elif 30<=a<40:
      x[3]+=1
    elif 40<=a<50:
      x[4]+=1 
    elif 50<=a<60:
      x[5]+=1
    else:
      x[6]+=1
  for i in range(7):
    print(x[i])

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0 for i in range(7)]
while True:
  if n==0:
    break
  for i in range(n):
    a=int(input())
    if 0<=a<10:
      x[0]+=1
    elif 10<=a<20:
      x[1]+=1
    elif 20<=a<30:
      x[2]+=1
    elif 30<=a<40:
      x[3]+=1
    elif 40<=a<50:
      x[4]+=1 
    elif 50<=a<60:
      x[5]+=1
    else:
      x[6]+=1
  for i in range(7):
    if x[i]==0:
      print(0)
    else:
      print('{}'.format(x[i]))


Fixed submission:
while True:
  x=[0 for i in range(7)]
  n=int(input())
  if n==0:
    break
  for i in range(n):
    a=int(input())
    if 0<=a<10:
      x[0]+=1
    elif 10<=a<20:
      x[1]+=1
    elif 20<=a<30:
      x[2]+=1
    elif 30<=a<40:
      x[3]+=1
    elif 40<=a<50:
      x[4]+=1 
    elif 50<=a<60:
      x[5]+=1
    else:
      x[6]+=1
  for i in range(7):
    print(x[i])

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0 for i in range(7)]
while True:
  if n==0:
    break
  for i in range(n):
    a=int(input())
    if 0<=a<10:
      x[0]+=1
    elif 10<=a<20:
      x[1]+=1
    elif 20<=a<30:
      x[2]+=1
    elif 30<=a<40:
      x[3]+=1
    elif 40<=a<50:
      x[4]+=1 
    elif 50<=a<60:
      x[5]+=1
    else:
      x[6]+=1
  for i in range(7):
    if x[i]==0:
      print(0)
    else:
      print(x[i])


Fixed submission:
while True:
  x=[0 for i in range(7)]
  n=int(input())
  if n==0:
    break
  for i in range(n):
    a=int(input())
    if 0<=a<10:
      x[0]+=1
    elif 10<=a<20:
      x[1]+=1
    elif 20<=a<30:
      x[2]+=1
    elif 30<=a<40:
      x[3]+=1
    elif 40<=a<50:
      x[4]+=1 
    elif 50<=a<60:
      x[5]+=1
    else:
      x[6]+=1
  for i in range(7):
    print(x[i])
Buggy python submission (verdict: Runtime Error):
n=int(input())
while True:
  if n==0:
    break
  for i in range(n):
    m,e,j=map(int,input().split())
    if m==100 or e==100 or j==100:
      print('{}'.format('A'))
    elif (m+e)/2>=90:
       print('{}'.format('A'))
    elif (m+e+j)/3>=80:
       print('{}'.format('A'))
    elif (m+e+j)/3>=70:
       print('{}'.format('B'))
    elif (m+e+j)/3>=50:
      if m>=80 or e>=80:
          print('{}'.format('B'))
      else:
        print('{}'.format('C'))
    else:
      print('{}'.format('C'))


Fixed submission:
while True:
  n=int(input())
  if n==0:
    break
  for i in range(n):
    m,e,j=map(int,input().split())
    if m==100 or e==100 or j==100:
      print('{}'.format('A'))
    elif ((m+e)/2)>=90:
       print('{}'.format('A'))
    elif ((m+e+j)/3)>=80:
       print('{}'.format('A'))
    elif ((m+e+j)/3)>=70:
       print('{}'.format('B'))
    elif ((m+e+j)/3)>=50:
      if m>=80 or e>=80:
          print('{}'.format('B'))
      else:
        print('{}'.format('C'))
    else:
      print('{}'.format('C'))
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0 for i in range(10)]
while True:
  if n==0:
    break
  for i in range(n):
    a=int(input())
    if a==0:
      x[0]+=1
    elif a==1:
      x[1]+=1
    elif a==2:
      x[2]+=1
    elif a==3:
      x[3]+=1
    elif a==4:
      x[4]+=1
    elif a==5:
      x[5]+=1 
    elif a==6:
      x[6]+=1
    elif a==7:
      x[7]+=1
    elif a==8:
      x[8]+=1
    else:
      x[9]+=1
  for i in range(10):
    if x[i]==0:
      print('{}'.format('-')) 
    else:
      print('{}'.format(x[i]*'*'))


Fixed submission:
while 1:
  n = int(input())
  if n == 0:
    break
  x = [0 for i in range(10)] 
  for i in range(n):
    c = int(input())
    x[c] += 1

  for i in range(10):
    count = '*' * x[i] 
    if len(count) == 0:
      print("-")
    else:
      print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0 for i in range(10)]
while True:
  if n==0:
    break
  for i in range(n):
    a=int(input())
    x[a]+=1
  for i in range(10):
    if x[i]==0:
      print('{}'.format('-')) 
    else:
      print('{}'.format(x[i]*'*'))


Fixed submission:
while 1:
  n = int(input())
  if n == 0:
    break
  x = [0 for i in range(10)] 
  for i in range(n):
    c = int(input())
    x[c] += 1

  for i in range(10):
    count = '*' * x[i] 
    if len(count) == 0:
      print("-")
    else:
      print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0 for i in range(10)]
while True:
  if n==0:
    break
  for i in range(n):
    a=int(input())
    x[a]+=1
  for i in range(10):
    if x[i]==0:
      print('{}'.format('-')) 
    else:
      print('{}'.format(x[i]*'*'))


Fixed submission:
while 1:
  n = int(input())
  if n == 0:
    break
  x = [0 for i in range(10)] 
  for i in range(n):
    c = int(input())
    x[c] += 1

  for i in range(10):
    count = '*' * x[i] 
    if len(count) == 0:
      print("-")
    else:
      print(count)
Buggy python submission (verdict: Runtime Error):
while True:
  for i in range(1,31):
    n=int(input())
    if i%7==0:
      print('{}'.format('thu'))
    elif i%7==1:
      print('{}'.format('fri'))
    elif i%7==2:
      print('{}'.format('sat'))
    elif i%7==3:
      print('{}'.format('san'))
    elif i%7==4:
      print('{}'.format('mon'))
    elif i%7==5:
      print('{}'.format('tue'))  
    else:
      print('{}'.format('wed'))


Fixed submission:
x=int(input())
week=["thu","fri","sat","sun","mon","tue","wed"]
print(week[x%7])

Buggy python submission (verdict: Runtime Error):
while True:
  for i in range(1,31):
    n=int(input())
    if n%7==0:
      print('{}'.format('thu'))
    elif n%7==1:
      print('{}'.format('fri'))
    elif n%7==2:
      print('{}'.format('sat'))
    elif n%7==3:
      print('{}'.format('san'))
    elif n%7==4:
      print('{}'.format('mon'))
    elif n%7==5:
      print('{}'.format('tue'))  
    else:
      print('{}'.format('wed'))


Fixed submission:
x=int(input())
week=["thu","fri","sat","sun","mon","tue","wed"]
print(week[x%7])

Buggy python submission (verdict: Runtime Error):
while True:
  n=int(input())
  if n%7==0:
    print('{}'.format('thu'))
  elif n%7==1:
    print('{}'.format('fri'))
  elif n%7==2:
    print('{}'.format('sat'))
  elif n%7==3:
    print('{}'.format('san'))
  elif n%7==4:
    print('{}'.format('mon'))
  elif n%7==5:
    print('{}'.format('tue'))  
  else:
    print('{}'.format('wed'))


Fixed submission:
x=int(input())
week=["thu","fri","sat","sun","mon","tue","wed"]
print(week[x%7])

Buggy python submission (verdict: Runtime Error):
while True:
  n=int(input())
  if n%7==0:
    print('{}'.format('thu'))
  elif n%7==1:
    print('{}'.format('fri'))
  elif n%7==2:
    print('{}'.format('sat'))
  elif n%7==3:
    print('{}'.format('sun'))
  elif n%7==4:
    print('{}'.format('mon'))
  elif n%7==5:
    print('{}'.format('tue'))  
  else:
    print('{}'.format('wed'))


Fixed submission:
x=int(input())
week=["thu","fri","sat","sun","mon","tue","wed"]
print(week[x%7])
Buggy python submission (verdict: Runtime Error):
while True:
  a,b,c,d=map(int,input().split())
  e,f,g,h=map(int,input().split())
  x=a+b+c+d
  y=e+f+g+h
  if x<y:
    print(y)
  else:
    print(x)


Fixed submission:
a=list(map(int, input().split()))
b=list(map(int, input().split()))
if sum(b)<=sum(a):
  print(sum(a))
else:
  print(sum(b))

Buggy python submission (verdict: Runtime Error):
while True:
  a,b,c,d=map(int,input().split())
  e,f,g,h=map(int,input().split())
  x=a+b+c+d
  y=e+f+g+h
  if x<=y:
    print(y)
  else:
    print(x)


Fixed submission:
a=list(map(int, input().split()))
b=list(map(int, input().split()))
if sum(b)<=sum(a):
  print(sum(a))
else:
  print(sum(b))
Buggy python submission (verdict: Runtime Error):
while True:
  l=int(input())
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  if a%c==0 and b%d==0:
    if a/c>=b/d:
      print(l-(a//c))
    else:
      print(l-(b//d))
  else:
    x=(a//c)+1
    y=(b//d)+1
    if x>=y:
      print(l-x)
    else:
      print(l-y)


Fixed submission:
l=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a%c==0 or b%d==0:
  if a/c>=b/d:
    print(l-(a//c))
  else:
    print(l-(b//d))
else:
  x=(a//c)+1
  y=(b//d)+1
  if x>=y:
    print(l-x)
  else:
    print(l-y)
Buggy python submission (verdict: Runtime Error):
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0:
    x=abs(a)*c+d+b*e
    print(x)
  else:
    y=(b-a)*e
    print(y)


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
  x=-a*c+d+b*e
  print(x)
else :
  y=(b-a)*e
  print(y)

Buggy python submission (verdict: Runtime Error):
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0:
    x=abs(a)*c+d+b*e
    print(x)
  elif a>=0:
    y=(b-a)*e
    print(y)
  else:
    pass


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
  x=-a*c+d+b*e
  print(x)
else :
  y=(b-a)*e
  print(y)

Buggy python submission (verdict: Runtime Error):
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0:
    x=abs(a)*c+d+b*e
    print(x)
  else:
    y=(b-a)*e
    print(y)


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
  x=-a*c+d+b*e
  print(x)
else :
  y=(b-a)*e
  print(y)

Buggy python submission (verdict: Runtime Error):
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0 and a<b:
    x=abs(a)*c+d+b*e
    print(x)
  elif a>0 and a<b:
    y=(b-a)*e
    print(y)
  else:
    pass


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
  x=-a*c+d+b*e
  print(x)
else :
  y=(b-a)*e
  print(y)

Buggy python submission (verdict: Runtime Error):
for i in range(5):
  a=int(input())
  b=int(input())
  c=int(input())
  d=int(input())
  e=int(input())
  if a<0 and a<b:
    x=abs(a)*c+d+b*e
    print(x)
  elif a>0 and a<b:
    y=(b-a)*e
    print(y)
  else:
    break


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if a<0:
  x=-a*c+d+b*e
  print(x)
else :
  y=(b-a)*e
  print(y)
Buggy python submission (verdict: Time Limit Exceeded):
from statistics import mean
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=mean(ns):
      c+=1
    else:
      pass
  print(c)


Fixed submission:
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=sum(ns)/n:
      c+=1
  print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import mean
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=mean(ns):
      c+=1
    else:
      pass
  print(c)


Fixed submission:
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=sum(ns)/n:
      c+=1
  print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import mean
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=mean(ns):
      c+=1
    else:
      pass
  print(c)


Fixed submission:
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=sum(ns)/n:
      c+=1
  print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import mean
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=mean(ns):
      c+=1
  print(c)


Fixed submission:
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=sum(ns)/n:
      c+=1
  print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import mean
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=mean(ns):
      c+=1
  print(c)


Fixed submission:
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=sum(ns)/n:
      c+=1
  print(c)
Buggy python submission (verdict: Runtime Error):
S=int(input())
h=S//3600
m=(S-h*3600)//60
m=(S-h*3600)-m*60
print(h,':',m,':',s,  sep='')


Fixed submission:
S=int(input())
h = S//(60**2)
m = (S-h*60**2)//60
s = S-(h*60**2+m*60)
print(f"{h}:{m}:{s}")

Buggy python submission (verdict: Runtime Error):
S=int(input())
h=S//3600
m=(S-h*3600)//60
m=(S-h*3600)-m*60
print(h,':',m,':',s,  sep='')


Fixed submission:
S=int(input())
h = S//(60**2)
m = (S-h*60**2)//60
s = S-(h*60**2+m*60)
print(f"{h}:{m}:{s}")
Buggy python submission (verdict: Runtime Error):
a, op, b=input().split()
a=int(a)
b=int(b)
if op=='+':
  print(a+b)
elif op=='-':
  print(a-b)
elif op=='*':
  print(a*b)
elif op=='/':
  print(a//b)
else:
  break


Fixed submission:
while 1:
  a,op,b = input().split()
  a = int(a)
  b = int(b)
  if op == "?":
    break
  else:
    if op == "+":
      x = a + b
      print(x)
    elif op == "-":
      x = a - b
      print(x)
    elif op == "*":
      x = a * b
      print(x)
    elif op == "/":
      x = a // b
      print(x)
    else:
      pass
Buggy python submission (verdict: Runtime Error):
n=input()
d={}
for i in range(n):
  card=input()
  d[card]=True
  

for c in ["S","H","C","D"]:
  for i in brange(1,13):
    card=c+' '+str(n)
    if not key in d:
      print(key)


Fixed submission:
n=int(input())
d={}
for i in range(n):
  card=input()
  d[card]=True
for c in ["S","H","C","D"]:
  for n in range(1,14):
    key=c+' '+str(n)
    if not key in d:
      print(key)
Buggy python submission (verdict: Time Limit Exceeded):
m,n=map(int,input().split())
print(m**n%(1000000007))


Fixed submission:
x = 1000000007
m,n=map(int,input().split())
print(pow(m,n,x))
Buggy python submission (verdict: Time Limit Exceeded):
r = []

n = int(input())
for i in range(n):
    i = int(input())
    r.append(i)

maxv = r[1] - r[0]

for j in range(1,n):
    for i in range(j):
        maxv = max(maxv, r[j]-r[i])

print(maxv)



Fixed submission:
'''
Rjの最小値を保持することで最大利益の更新判定をn回で終わらせる
'''

r = []

n = int(input())
for i in range(n):
    i = int(input())
    r.append(i)

minv = r[0]
maxv = r[1] - r[0]

for j in range(1,n):
    maxv = max(maxv, r[j]-minv)
    minv = min(minv, r[j])

print(maxv)

Buggy python submission (verdict: Runtime Error):
import math

n=int(input())
t=int(input())
mint=t
t1=int(input())
if t1<t: mint=t1
maxtt=t1-t

for i in range(2,n):
    t=int(input())

    if t-mint>maxtt: maxtt=t-mint
    if t<mint: mint=# TEMP: 

print(int(maxtt))


Fixed submission:
import math

n=int(input())
t=int(input())
mint=t
t1=int(input())
if t1<t: mint=t1
maxtt=t1-t

for i in range(2,n):
    t=int(input())

    if t-mint>maxtt: maxtt=t-mint
    if t<mint: mint=t

print(int(maxtt))
Buggy python submission (verdict: Runtime Error):
def bubble(A):
    flag=True;
    n=len(A)
    i=0
    while flag:
        for j in range(n-1,i,-1):
            if A[j][1]<A[j-1][1]:
                A[j],A[j-1]=A[j-1],A[j]
                flag=True
        i+=1

def selection(A):
    n=len(A)
    for i in range(n):
        minj=i
        for j in range(i,n):
            if A[j][1]<A[minj][1]:
        if i!=minj:
            A[i],A[minj]=A[minj],A[i]


n=int(input())
ss=[x for x in input().split()]
ss2=ss.copy()

bubble(ss)
for i in range(len(ss)-1):
    print(ss[i],end=' ')
print(ss[-1])
print('Stable')

selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i],end=' ')
print(ss2[-1])
if ss=ss2:
    print('Stable')
else:
    print('Not stable')


Fixed submission:
def bubble(A):
    #标记是否需要继续冒泡
    flag =True;
    n=len(A)
    i=0
    while flag:
        flag=False
        for j in range(n-1,i,-1):
           if A[j][1]<A[j-1][1]:
               A[j],A[j-1]=A[j-1],A[j]
               flag=True
        i+=1
 
 
#选择排序法
def selection(A):
    n=len(A)
    for i in range(n):
        minj=i
        for j in range(i,n):
            if A[j][1]<A[minj][1]:
                minj=j
        if i!=minj:
            A[i],A[minj]=A[minj],A[i]
             
   
           
n=int(input())
ss=[x for x in input().split()]     
ss2=ss.copy()
 
 
bubble(ss)
for i in range(len(ss)-1):
    print(ss[i],end=' ')
print(ss[-1])
print('Stable')
    
 
selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i],end=' ')
print(ss2[-1])
if ss==ss2:
    print('Stable')
else:
    print('Not stable')
Buggy python submission (verdict: Runtime Error):
import System
if sys.version_info[0]>=3: raw_input=InputStream

def insertionSort(a,g):
    global cnt
    for i in range(g,len(a)):
        v=a[i]
        j=i-g
        while j>=0 and a[j]>v:
            a[j+g]=a[j]
            j=j-g
            cnt+=1
            a[j+g]=v

def shellSort(a):
    global cnt
    cnt=0
    g=[]
    h=1
    while h <=len(a):
        g.append(h)
        h=3*h+1
    g.reverse()
    m=len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(a,g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)


Fixed submission:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
 
def insertionSort(a,g):
    global cnt
    for i in range(g,len(a)):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt+=1
            a[j+g] = v
 
def shellSort(a):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= len(a):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(a,g[i])
 
a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
x = (a+b)*2
y = a*b

print(y, x)


Fixed submission:
a, b = map(int, input().split())
x = a*b
y = (a+b)*2

print(x, y)

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
x = (a+b)*2
y = a*b

print(y, x)


Fixed submission:
a, b = map(int, input().split())
x = a*b
y = (a+b)*2

print(x, y)

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
x = a*b
y = (a+b)*2

print(x, y)


Fixed submission:
a, b = map(int, input().split())
x = a*b
y = (a+b)*2

print(x, y)

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
x = a*b
y = (a+b)*2

print(x, y)


Fixed submission:
a, b = map(int, input().split())
x = a*b
y = (a+b)*2

print(x, y)
Buggy python submission (verdict: Runtime Error):
p = [x, y, z]
x, y, z = map(int, input().split())

p.sort()
print(p)


Fixed submission:
a = list(map(int, input().split()))

a.sort()
print(a[0], a[1], a[2])

Buggy python submission (verdict: Runtime Error):
p = [x, y, z]
x, y, z = map(int, input().split())

p.sort()
print(p)


Fixed submission:
a = list(map(int, input().split()))

a.sort()
print(a[0], a[1], a[2])