Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,h=map(int,input().split())
a=[]
for i in range(n):
  b,c=map(int,input().split())
  a.append([b,0]);a.append([c,1])
a.sort(reverse=1)
i=0
ans=0
while h>0:
  if a[i][1]==1:h-=a[i][0];ans+=1
  else h=0:ans+=(h-1)//a[i][0]+1
print(ans)

Fixed submission:
n,h=map(int,input().split())
a=[]
for i in range(n):
  b,c=map(int,input().split())
  a.append([b,0]);a.append([c,1])
a.sort(reverse=1)
i=b=0
while h>0:
  if a[i][1]==1:h-=a[i][0];b+=1
  else:b+=(h-1)//a[i][0]+1;h=0
  i+=1
print(b)

Buggy python submission (verdict: Runtime Error):
n,h=map(int,input().split())
a=[]
for i in range(n):
  b,c=map(int,input().split())
  a.append([b,0]);a.append([c,1])
a.sort(reverse=1)
i=0
ans=0
while h>0:
  if a[i][1]==1:h-=a[i][0];ans+=1
  else:h=0:ans+=(h-1)//a[i][0]+1
print(ans)

Fixed submission:
n,h=map(int,input().split())
a=[]
for i in range(n):
  b,c=map(int,input().split())
  a.append([b,0]);a.append([c,1])
a.sort(reverse=1)
i=b=0
while h>0:
  if a[i][1]==1:h-=a[i][0];b+=1
  else:b+=(h-1)//a[i][0]+1;h=0
  i+=1
print(b)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());c,d=input().split("-");print("Yes"len(c)==a and len(d)==b else"No")

Fixed submission:
a,b=map(int,input().split());s=input().split("-");ans="Yes"
if len(s)!=2:ans="No"
if len(s[0])!=a or len(s[1])!=b:ans="No"
if "--" in s:ans=="No"
print(ans)
Buggy python submission (verdict: Runtime Error):
_,*a=open(0);print(min((int(x)&-int(x)).bit_length()for x in a)-1)

Fixed submission:
n,a=int(input()),list(map(int,input().split()))
ans=0
while 1:
  for i in range(n):
    if a[i]%2==0:a[i]/=2
    else:
      print(ans)
      exit()
  ans+=1
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split()),print(min(n*a,b))

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

Buggy python submission (verdict: Runtime Error):
print(min(int(input())*int(input()),int(input())))

Fixed submission:
n,a,b=map(int,input().split());print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=list(input())
op=lambda i,a:"+" if i&a else "-"
for i in range(8):
  s=a+op(i&1)+e+op(i&2)+c+op(i&4)+d
  if eval(s)==7:print(s+"=7");exit()

Fixed submission:
s=input()
for i in range(2**3):
  b=bin(i)[2:].zfill(3)
  a=s[0]
  for i in range(3):a+=("+"if b[i]=="0"else"-")+s[i+1]
  if eval(a)==7:print(a+"=7");exit()
Buggy python submission (verdict: Runtime Error):
x=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F",]
a,b=input().split();a,b=x.index(a),x.index(b)
if a>b:print(">")
elif a<b:print("<")
else;print("=")

Fixed submission:
x=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F",]
a,b=input().split();a,b=x.index(a),x.index(b)
if a>b:print(">")
elif a<b:print("<")
else:print("=")
Buggy python submission (verdict: Runtime Error):
n,a,b=int(input()),[sorted(list(map(int,input().split())))for i in range(3)],[[],[]]
x=0
for i in range(n):
  while a[2][i]>a[1][x]:
    b[1].append(n-i)
    x+=1
    if x==n:break
  if x==n:break
for i in range(1,n):b[1][n-i-1]+=b[1][n-i]
x=0
for i in range(n):
  while a[1][i]>a[0][x]:
    b[0].append(b[1][i])
    x+=1
    if x==n:break
  if x==n:break
print(sum(b[0]))

Fixed submission:
n,a=int(input()),[sorted(list(map(int,input().split())))for i in range(3)]
b=[[],[]]
x=0
for i in range(n):
  while a[2][i]>a[1][x]:
    b[1].append(n-i)
    x+=1
    if x==n:break
  if x==n:break
for i in range(n-len(b[1])):b[1].append(0)
for i in range(1,n):b[1][n-i-1]+=b[1][n-i]
x=0
for i in range(n):
  while a[1][i]>a[0][x]:
    b[0].append(b[1][i])
    x+=1
    if x==n:break
  if x==n:break
print(sum(b[0]))
Buggy python submission (verdict: Runtime Error):
n,d,m,t,ans=int(input()),list(map(int,input().split())),int(input()),list(map(int,input().split())),"YES"
dn,tn,dc,tc=[],[],[],[]
for i in d:
  if i in dn:dc[dn.index(i)]+=1
  else:dn.append(i);dc.append(1)
for i in t:
  if i in tn:tc[tn.index(i)]+=1
  else:tn.append(i);tc.append(1)
for i in range(len(tn)):
  if tc[i]>dc[dn.index(tn[i])]:ans="NO"
print(ans)

Fixed submission:
from collections import Counter
n,d,m,t,ans=int(input()),Counter(map(int,input().split())),int(input()),Counter(map(int,input().split())),"YES"
for i in t.keys():
  if i in d.keys():
    if d[i]<t[i]:ans="NO"
  else:ans="NO"
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,d,m,t,ans=int(input()),list(map(int,input().split())),int(input()),list(map(int,input().split())),"YES"
for i in t:
  if i in d:del d[d.index(i)]
  else:ans="NO";break
print(ans)

Fixed submission:
from collections import Counter
n,d,m,t,ans=int(input()),Counter(map(int,input().split())),int(input()),Counter(map(int,input().split())),"YES"
for i in t.keys():
  if i in d.keys():
    if d[i]<t[i]:ans="NO"
  else:ans="NO"
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
edge=[[]for _ in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
x=[0]*n
x[0]=1
def dfs(r,node):
  for mode in edge[node]:
    if r==mode:continue
    x[mode]=1^x[node]
    dfs(node,mode)
dfs(-1,0)
print(x.count(0)*x.count(1)-m)


Fixed submission:
# 二部グラフ判定
def bipartite_graph_check(n,edge):
  color = [-1] * n
  for i in range(n):
    if color[i] != -1:
      continue
    stack = [i]
    color[i] = 0
    for node in stack:
      for mode in edge[node]:
        if color[mode] == -1:
          stack.append(mode)
          color[mode] = color[node] ^ 1
        elif color[mode] == color[node]:
          return False
  #return True
  return color
n,m=map(int,input().split())
edge=[[]for _ in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
if bipartite_graph_check(n,edge):
  color=bipartite_graph_check(n,edge)
  print(color.count(0)*color.count(1)-m)
else:
  print(n*(n-1)//2-m)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
edge=[[]for _ in range(n)]
for _ in range(n):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
x=[0]*n
x[0]=1
def dfs(r,node):
  for mode in edge[node]:
    if r==mode:continue
    x[mode]=1^x[node]
    dfs(node,mode)
dfs(-1,0)
print(x.count(0)*x.count(1)-m)

Fixed submission:
# 二部グラフ判定
def bipartite_graph_check(n,edge):
  color = [-1] * n
  for i in range(n):
    if color[i] != -1:
      continue
    stack = [i]
    color[i] = 0
    for node in stack:
      for mode in edge[node]:
        if color[mode] == -1:
          stack.append(mode)
          color[mode] = color[node] ^ 1
        elif color[mode] == color[node]:
          return False
  #return True
  return color
n,m=map(int,input().split())
edge=[[]for _ in range(n)]
for _ in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
if bipartite_graph_check(n,edge):
  color=bipartite_graph_check(n,edge)
  print(color.count(0)*color.count(1)-m)
else:
  print(n*(n-1)//2-m)
Buggy python submission (verdict: Runtime Error):
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    w=(N*h*n)/(4*h*n-N*(h+n))
    if w%1==0:print(h,n,int(w));exit()


Fixed submission:
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    if 1/h+1/n>=4/N:continue
    w=(N*h*n)/(4*h*n-N*(h+n))
    if w==int(w):print(h,n,int(w));exit()
Buggy python submission (verdict: Runtime Error):
s=input()
if len(s)<4:print("No")
elif s[:3]=print("Yes")
else:print("No")

Fixed submission:
s=input()
if len(s)<4:print("No")
elif s[:4]=="YAKI":print("Yes")
else:print("No")
Buggy python submission (verdict: Runtime Error):
n,k,b,ans=int(input()),int(input()),[int(input())for i in range(n)],0
for i in b:ans+=min(i,k-i)*2
print(ans)

Fixed submission:
n,k,b,ans=int(input()),int(input()),list(map(int,input().split())),0
for i in b:ans+=min(i,k-i)*2
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
b=[i.copy() for i in a]
c=[n*[1]for _ in range(n)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      b[i][j]=min(b[i][j],b[i][k]+b[k][j])
      if a[i][j]==a[i][k]+a[k][j]:
        if i!=j and i!=k and j!=k:
          c[i][j]=0
if a!=b:exit(print(-1))
ans=0
for i in range(n):
  for j in range(i):
    if c[i][j]:ans+=a[i][j]
print(ans)

Fixed submission:
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
b=[[j for j in i]for i in a]
c=[n*[1]for _ in range(n)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      b[i][j]=min(b[i][j],b[i][k]+b[k][j])
      if a[i][j]==a[i][k]+a[k][j]:
        if i!=j and i!=k and j!=k:
          c[i][j]=0
if a!=b:exit(print(-1))
ans=0
for i in range(n):
  for j in range(i):
    if c[i][j]:ans+=a[i][j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
b=[i.copy() for i in a]
c=[n*[1]for _ in range(n)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      b[i][j]=min(b[i][j],b[i][k]+b[k][j])
      if a[i][j]==a[i][k]+a[k][j]:
        if i!=j and i!=k and j!=k:
          c[i][j]=0
if a!=b:exit(print(-1))
ans=0
for i in range(n):
  for j in range(i):
    if c[i][j]:ans+=a[i][j]
print(ans)

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

Fixed submission:
n,a=int(input()),list(map(int,input().split()));c=[0]*(max(a)+1)
for i in a:
  if i>0:c[i-1]+=1
  if i<len(c)-1:c[i+1]+=1
  c[i]+=1
print(max(c))
Buggy python submission (verdict: Runtime Error):
s,d=input(),"abcdefghijklmnopqrstuvwxyz"
for i in range(27):
  if not d[i]in s:
    print(d[i])
    exit()
print("None")

Fixed submission:
s,d=input(),"abcdefghijklmnopqrstuvwxyz"
for i in range(26):
  if not d[i]in s:
    print(d[i])
    exit()
print("None")
Buggy python submission (verdict: Runtime Error):
n=int(input())
i=0
while 1:
  if 2**i>n:break
  i+=1
print(2**(i-1))

Fixed submission:
s=input();print(s[0]+str(len(s)-2)+s[-1])

Buggy python submission (verdict: Runtime Error):
import math
n=int(input());print(round(2**(math.log(n,2)//1)))

Fixed submission:
s=input();print(s[0]+str(len(s)-2)+s[-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s,t=set(),set()
for _ in range(m):
  a,b=map(int,input().split())
  if a==1:t.add(b)
  if b==n:s.add(a)
if s%t:print("POSSIBLE")
else:print("IMPOSSIBLE")

Fixed submission:
n,m=map(int,input().split());a=[]
for i in range(m):
  aa,bb=map(int,input().split())
  if aa==1:a.append(bb)
  if bb==n:a.append(aa)
a.sort()
for i in range(len(a)-1):
  if a[i]==a[i+1]:print("POSSIBLE");exit()
print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split());a,b=[],[]
for i in range(m):
  aa,bb=map(int,input().split())
  a.append(aa);b.append(bb)
c=[]
for i in range(m):
  if a[i]==1:c.append(b[i])
for i in range(m):
  if b[i]==n:
    if a[i] in c:print("POSSIBLE");exit()
print("IMPOSSIBLE")

Fixed submission:
n,m=map(int,input().split());a=[]
for i in range(m):
  aa,bb=map(int,input().split())
  if aa==1:a.append(bb)
  if bb==n:a.append(aa)
a.sort()
for i in range(len(a)-1):
  if a[i]==a[i+1]:print("POSSIBLE");exit()
print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
n,k,s=map(int,input().split()),list(map(int,input().split()));s.sort();print(sum(s[-k:]))

Fixed submission:
n,k=map(int,input().split())
s=list(map(int,input().split()));s.sort();print(sum(s[-k:]))
Buggy python submission (verdict: Runtime Error):
a=list(map(inti,input().split()));print(sum(a)-max(a))

Fixed submission:
a=list(map(int,input().split()));print(sum(a)-max(a))
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
if b-a>x:print("dangerous")
elif b-a<=0:print("delicious")
else:print("safe")

Fixed submission:
a,b,c=map(int,input().split())
if b>=c:print("delicious")
elif a<c-b:print("dangerous")
else:print("safe")
Buggy python submission (verdict: Runtime Error):
n,a,b,m=int(input()),[int(input())for i in range(n)],[],1
while m!=2 and m in b:
  b.append(m)
  m=b[m-1]
if m==2:print(len(b))
else:print(-1)

Fixed submission:
n,ans=int(input()),-1
a,m=[int(input())for i in range(n)],1
for i in range(n):
  m=a[m-1]
  if m==2:
    ans=i+1
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
ans=len(s)
def a(s,t):
  ss=""
  a=0
  b=False
  for i in range(len(s)-1):
    if s[i]!=t!=s[i+1]:ss+=s[i];b=True
    else:ss+=t
  if b:a=a(ss,t)
  return a+1
for i in s:ans=min(ans,a(s,i))
print(ans)

Fixed submission:
s=input()
ans=len(s)
for i in "abcdefghijklmnopqrstuvwxyz":
  t=a=0
  for j in s:
    if j==i:a=max(a,t);t=0
    else:t+=1
  a=max(a,t)
  ans=min(ans,a)
print(ans)
Buggy python submission (verdict: Runtime Error):
yes="Yes"
no="No"
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>1:exit(print(no))
if a==[a[0]]*n:
  if a[0]==n-1:print(yes)
  elif 2*a[0]<=n:print(yes)
  else:print(no)
else:
  mi=a.count(min(a))
  ma=n-mi
  if mi<max(a):print(yes)
  elif 2*(max(a)-mi)<=y:print(yes)
  else:print(no)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>=2:exit(print("No"))
if len(set(a))==1:
  m=a[0]
  if m==n-1 or 2*m<=n:print("Yes")
  else:print("No")
else:
  x=a.count(min(a))
  y=n-x
  if x<max(a) and 2*(max(a)-x)<=y:print("Yes")
  else:print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input())
if (b*10+c)%4==0:print("YES")
else:print("NO")

Fixed submission:
a,b,c=map(int,input().split())
if (b*10+c)%4==0:print("YES")
else:print("NO")
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
ans=h*w
for i in range(1,h):ans=min(ans,max(i*w,(h-i)*(w//2),(h-i)*((w-1)//2)+1)-min(i*w,(h-i)*(w//2),(h-i)*((w-1)//2)+1)
for i in range(1,w):ans=min(ans,max(i*h,(w-i)*(h//2),(w-i)*((h-1)//2)+1)-min(i*h,(w-i)*(h//2),(w-i)*((h-1)//2)+1)
print(ans)

Fixed submission:
h,w=map(int,input().split())
ans=h*w
for i in range(1,h):
  a=w*i
  bb=w//2
  cc=(w-1)//2+1
  b=(h-i)*bb
  c=(h-i)*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
  bb=(h-i)//2
  cc=((h-i)-1)//2+1
  b=w*bb
  c=w*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
for i in range(1,w):
  a=h*i
  bb=h//2
  cc=(h-1)//2+1
  b=(w-i)*bb
  c=(w-i)*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
  bb=(w-i)//2
  cc=((w-i)-1)//2+1
  b=h*bb
  c=h*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
print(ans)

Buggy python submission (verdict: Runtime Error):
h,w=map()
ans=h*w
for i in range(1,h):ans=min(ans,max(i*w,(h-i)*w//2)-min(i*w,(h-i)*w//2))
for i in range(1,w):ans=min(ans,max(i*h,(w-i)*h//2)-min(i*h,(w-i)*h//2))
print(ans)

Fixed submission:
h,w=map(int,input().split())
ans=h*w
for i in range(1,h):
  a=w*i
  bb=w//2
  cc=(w-1)//2+1
  b=(h-i)*bb
  c=(h-i)*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
  bb=(h-i)//2
  cc=((h-i)-1)//2+1
  b=w*bb
  c=w*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
for i in range(1,w):
  a=h*i
  bb=h//2
  cc=(h-1)//2+1
  b=(w-i)*bb
  c=(w-i)*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
  bb=(w-i)//2
  cc=((w-i)-1)//2+1
  b=h*bb
  c=h*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[0 for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1]+=1;x[b-1]+=1
for i in range(n):print(n[i])

Fixed submission:
n,m=map(int,input().split())
x=[0 for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1]+=1;x[b-1]+=1
for i in range(n):print(x[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
c=[]
for i in range(n):
  a,b=map(int,input().split())
  c+=[a]*b
c.sort()
print(c[k-1])

Fixed submission:
n,K=map(int,input().split());c={}
for i in range(n):
  a,b=map(int,input().split())
  if a in c:c[a]+=b
  else:c[a]=b
for k,v in sorted(c.items()):
  K-=v
  if K<=0:print(k);exit()
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
ans="NO"
for i in range(b):
  if (a*(i+1))%b==c:ans"YES"
print(ans)

Fixed submission:
a,b,c=map(int,input().split())
ans="NO"
for i in range(b):
  if (a*(i+1))%b==c:ans="YES"
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print("GREATER"if a>b else"LESS"if a<b else"EQUAL")

Fixed submission:
a,b=int(input()),int(input());print("GREATER"if a>b else"LESS"if a<b else"EQUAL")
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
ans=10**15
for i in[-1,1]:
    ansi,sum=0,0
    for a in A:
        sum+=a
        if sum*i<=0:;ansi+=abs(sum-i);sum=i
        i*=-1
    ans=min(ans,ansi)
print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
ans=10**15
for i in[-1,1]:
    ansi,sum=0,0
    for a in A:
        sum+=a
        if sum*i<=0:ansi+=abs(sum-i);sum=i
        i*=-1
    ans=min(ans,ansi)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,a=int(input()),list(map(int,input().split()));ans=0
if a[0]==0:
  bol=True
  for i in range(1,n):
    if a[i-1]!=a[i]:
      bol=False
      if a[i]>0:a[0]=(1if i%2==0else-1)
      else:a[0]=(1if i%2!=0else-1)
    ans+=1;break
  if bol:print(n*2-1);exit()
b=[a[0]];m=("+"if a[0]<0else"-")
for i in range(1,n):
  while b[-1]*(b[-1]+a[i])>=0:
    ans+=1
    a[i]+=eval(m+"1")
  b.append(b[-1]+a[i])
  m=("+"if b[i]<0else"-")
print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
ans=10**15
for i in[-1,1]:
    ansi,sum=0,0
    for a in A:
        sum+=a
        if sum*i<=0:ansi+=abs(sum-i);sum=i
        i*=-1
    ans=min(ans,ansi)
print(ans)
Buggy python submission (verdict: Runtime Error):
a=""
s,t=input(),input()
for i in range(len(s)):a+=s[i]+t[i]
print(a)

Fixed submission:
a,b,s=input(),input(),""
for i in range(len(a)-1):s+=a[i]+b[i]
if len(a)!=len(b):s+=a[-1]
else:s+=a[-1]+b[-1]
print(s)
Buggy python submission (verdict: Runtime Error):
n,a=int(input()),sorted(list(map(int,input().split())))print(sum([a[i]*(i%3==1)for i in range(3*n)]))

Fixed submission:
n,a=int(input()),sorted(list(map(int,input().split())))[::-1];print(sum([a[i]*(i%2==1)for i in range(2*n)]))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
o,p,q,r=[],[],[],[]
def kyori(a,b,c,d):return abs(a-b)+abs(c-d)
for i in range(n):
  a,b=map(int,input().split())
  o.append(a)
  p.append(b)
for i in range(m):
  a,b=map(int,input().split())
  q.append(a)
  r.append(b)
for i in range(n):
  mind=kyori(a[i],b[i],c[0],d[0])
  minn=1
  for j in range(m-1):
    a=kyori(a[i],b[i],c[j+1],d[j+1])
    if a<mind:
      mind=a
      minn=j+2
  print(minn)

Fixed submission:
n,m=map(int,input().split())
o,p,q,r=[],[],[],[]
def kyori(a,b,c,d):return abs(a-c)+abs(b-d)
for i in range(n):
  a,b=map(int,input().split())
  o.append(a)
  p.append(b)
for i in range(m):
  a,b=map(int,input().split())
  q.append(a)
  r.append(b)
for i in range(n):
  mind=kyori(o[i],p[i],q[0],r[0])
  minn=1
  for j in range(m-1):
    a=kyori(o[i],p[i],q[j+1],r[j+1])
    if a<mind:
      mind=a
      minn=j+2
  print(minn)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if b+w<a:print(a-b-w)
else:print(max(0,b-a-w))

Fixed submission:
w,a,b=map(int,input().split())
if b+w<a:print(a-b-w)
else:print(max(0,b-a-w))
Buggy python submission (verdict: Runtime Error):
:cross: 

Fixed submission:
a,b=map(int,input().split());a,b=(a+11)%13,(b+11)%13
if a>b:print("Alice")
elif a==b:print("Draw")
else:print("Bob")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());a,b=(a+11)%13,(b+11)%13
if a>b:print("Alice");else:print("Bob")

Fixed submission:
a,b=map(int,input().split());a,b=(a+11)%13,(b+11)%13
if a>b:print("Alice")
elif a==b:print("Draw")
else:print("Bob")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
edge=[n*[0]for _ in range(n)]
for i in range(m):
	a,b=map(int,input().split())
	a-=1
	b-=1
	edge[a][b]=edge[b][a]=1
from itertools import permutations
ans=0
for i in permutations([j for j in range(1,n)],n-1):
	f=True
	t=[0]+i
	for j in range(1,n):
		if edge[t[j-1]][t[j]]==0:f=False
	if f:ans+=1
print(ans)

Fixed submission:
z,m=map(int,input().split());a=[[],[]];ans=0
for i in range(m):aa,bb=map(int,input().split());a[0].append(aa);a[1].append(bb)
def d(n,nl,ml):
  if sorted(nl+[n])==[i+1for i in range(z)]:return 1
  if n in nl:return 0
  l=len(ml[0]);ans=0
  for i in range(l):
    c=[ml[0][:i]+ml[0][i+1:],ml[1][:i]+ml[1][i+1:]]
    if ml[0][i]==n:ans+=d(ml[1][i],nl+[n],c)
    if ml[1][i]==n:ans+=d(ml[0][i],nl+[n],c)
  return ans
for i in range(m):
  if a[0][i]==1:
    c=[a[0][:i]+a[0][i+1:],a[1][:i]+a[1][i+1:]]
    ans+=d(a[1][i],[1],c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,ma,mb=map(int,input().split())
dp=[[[9999]*401for _ in range(401)]for _ in range(n+1)];dp[0][0][0]=0
sa=sb=0
for i in range(1,n+1):
  a,b,c=map(int,input().split())
  sa+=a;sb+=b
  for j in range(401):
    for k in range(401):
      if j>=a and k>=b:dp[i][j][k]=min(dp[i-1][j-a][k-b]+c,dp[i-1][j][k])
      else:dp[i][j][k]=dp[i-1][j][k]
a=9999
for i in range(1,min(sa//ma,sb//mb)+1):
  if dp[n][ma*i][mb*i]!=9999:a=min(a,dp[n][ma*i][mb*i])
print(-1if a==9999else a)

Fixed submission:
n,ma,mb=map(int,input().split())
dp=[[[5000]*401for _ in range(401)] for _ in range(n+1)]
dp[0][0][0]=0
maa=mab=0
for i in range(1,n+1):
  a,b,c=map(int,input().split())
  maa+=a
  mab+=b
  for j in range(401):
    for k in range(401):dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
ans=5000
for i in range(1,min(maa//ma,mab//mb)+1):
  if dp[n][ma*i][mb*i]!=5000:ans=min(ans,dp[n][ma*i][mb*i])
print(-1if ans==5000else ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,ma,mb=map(int,input().split())
dp=[[[5000]*401for _ in range(401)] for _ in range(n+1)]
dp[0][0][0]=0
maa=mab=0
for i in range(1,n+1):
  a,b,c=map(int,input().split())
  maa+=a
  mab+=b
  for j in range(401):
    for k in range(401):dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
ans=5000
for i in range(1,min(maa//ma,mab//mb)+1):
  if dp[n][ma*i][mb*i]!=5000:ans=min(ans,dp[n][ma*i][mb*i])
print(-1if ans==5000else ans)

Fixed submission:
n,ma,mb=map(int,input().split())
dp=[[[5000]*401for _ in range(401)] for _ in range(n+1)]
dp[0][0][0]=0
maa=mab=0
for i in range(1,n+1):
  a,b,c=map(int,input().split())
  maa+=a
  mab+=b
  for j in range(401):
    for k in range(401):dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-a][k-b]+c)
ans=5000
for i in range(1,min(maa//ma,mab//mb)+1):
  if dp[n][ma*i][mb*i]!=5000:ans=min(ans,dp[n][ma*i][mb*i])
print(-1if ans==5000else ans)