qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#119-A
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
s=input().split("/")
s=s[0]+s[1]+s[2]
s=int(s)
if s<=2019430:
    print("Heisei")
else:
    print("TBD")

Fixed code:
#119-A
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
s=input().split("/")
s=s[0]+s[1]+s[2]
s=int(s)
if s<=20190430:
    print("Heisei")
else:
    print("TBD")
Buggy code:
s=list(map(int,input().split(/)))

if s[0]<=2018:
  print(Heisei)
elif s[0]=2019 and s[1]<5:
  print(Heisei)
else:
  print(TBD)


Fixed code:
s=list(map(int,input().split("/")))
 
if s[0]<=2018:
  print("Heisei")
elif s[0]==2019 and s[1]<5:
  print("Heisei")
else:
  print("TBD")
Buggy code:
a = int(input())
if a <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")

Fixed code:
a = input()
if a <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")
Buggy code:
year, month, day = map(int, input().split('/'))

if year <= 4:
    print("Heisei")
else:
    print('TBD')


Fixed code:
year, month, day = map(int, input().split('/'))

if month <= 4:
    print("Heisei")
else:
    print('TBD')
Buggy code:
y,m,d = map(int,input().split('/'))

if y < 2019:
	print("Heisei")
elif y > 2019:
	print("TBD")
elif m < 3:
	print("Heisei")
elif m >= 4:
	print("TBD")


Fixed code:
y,m,d = map(int,input().split('/'))

if y < 2019:
	print("Heisei")
elif y > 2019:
	print("TBD")
elif m <= 4:
	print("Heisei")
elif m >= 5:
	print("TBD")
Buggy code:
S = input().split('/')
if int(S[0])>=2019:
    if int(S[1])>=5:
        print('TBD')
else:
    print('Heisei')


Fixed code:
S = input().split('/')
if int(S[0])>=2019:
    if int(S[1])>=5:
        print('TBD')
    else:
      print('Heisei')
else:
    print('Heisei')
Buggy code:
s = input()
s = s.split("/")

if s[0] >= 2019 and s[1] >= 5:
  print("TBD")
else:
  print("Heisei")

Fixed code:
s = input()
s = s.split("/")

if int(s[0]) >= 2019 and int(s[1]) >= 5:
  print("TBD")
else:
  print("Heisei")
Buggy code:
S = input()
y = int(S[0:4])
m = int(S[6:7])

import sys

if y<2019:
    print("Heisei")
    sys.exit()
if y==2019:
    if m<=4:
        print("Heisei")
        sys.exit()
print("TBD")

Fixed code:
S = input()
y = int(S[0:4])
m = int(S[5:7])

import sys

if y<2019:
    print("Heisei")
    sys.exit()
if y==2019:
    if m<=4:
        print("Heisei")
        sys.exit()
print("TBD")
Buggy code:
S = input().split("/")
print("Heisei" if int(S[1]) >= 5 else "TBD")

Fixed code:

S = input().split("/")
print("Heisei" if int(S[1]) < 5 else "TBD")
Buggy code:
def main():
    import sys
    input = sys.stdin.readline

    s = input()
    if int(''.join(s.split('/'))) < 20190430:
        print('Heisei')
    else:
        print('TBD')
    
if __name__ == '__main__':
    main()



Fixed code:
def main():
    #import sys
    #input = sys.stdin.readline

    s = input()
    if int(''.join(s.split('/'))) <= 20190430:
        print('Heisei')
    else:
        print('TBD')
    
if __name__ == '__main__':
    main()
Buggy code:
a,b,c=map(int,input().split("/"))
print(["TBD","Heisei"][(a>=2019) & (b>=5)])

Fixed code:
a,b,c=map(int,input().split("/"))
print(["Heisei","TBD"][(a>=2019) & (b>=5)])
Buggy code:
S = input().split("/")
if S[1]<=4:
    print("Heisei")
else:
    print("TBD")

Fixed code:
S = input().split("/")
if int(S[1])<=4:
    print("Heisei")
else:
    print("TBD")
Buggy code:
S = map(int, input().split("/"))
if S[1] > 4:
  print("TBD")
else:
  print("Heisei")

Fixed code:
S = list(map(int, input().split("/")))
if S[1] > 4:
  print("TBD")
else:
  print("Heisei")
Buggy code:
a, b, c = map(int, input().split("/"))
print("heisei") if b <= 4 else print("TBD")

Fixed code:
a, b, c = map(int, input().split("/"))
print("Heisei") if b <= 4 else print("TBD")
Buggy code:
s = input()
m = int(s[5:7])
if m <=4:
  print("Heisei")
else:
  prit("TBD")

Fixed code:
s = input()
m = int(s[5:7])
if m <=4:
  print("Heisei")
else:
  print("TBD")
Buggy code:
a = input()
b = a.split("/")
c = [int(n) for n in b]

if c[0] > 2019:
    print("PBD")
elif c[0] < 2019:
    print("Heisei")
else:
    if c[1] >=5:
        print("PBD")
    else:
        print("Heisei")

Fixed code:
a = input()
b = a.split("/")
c = [int(n) for n in b]

if c[0] > 2019:
    print("TBD")
elif c[0] < 2019:
    print("Heisei")
else:
    if c[1] >=5:
        print("TBD")
    else:
        print("Heisei")
Buggy code:
y, m, d = map(int, input().split("/"))
print(y, m, d)
if m >= 5:
    print("TBD")
else:
    print("Heisei")


Fixed code:
y, m, d = map(int, input().split("/"))
if m >= 5:
    print("TBD")
else:
    print("Heisei")
Buggy code:
S=input()
N,M,T=S.split("/")
N=int(N)
M=int(M)
T=int(T)
if(N<2019):
    print("Heisei")
elif(N==2019):
    if(M<=4):
        print("Heisei")
    else:
        print("TDB")
else:
    print("TDB")

Fixed code:
S=input()
N,M,T=S.split("/")
N=int(N)
M=int(M)
T=int(T)
if(N<2019):
    print("Heisei")
elif(N==2019):
    if(M<=4):
        print("Heisei")
    else:
        print("TBD")
else:
    print("TBD")
Buggy code:
year, month, day = [int(item) for item in S.split('/')]

if (int(year) >= 2019) & (int(month) >= 5):
	print('TBD')
else:
	print('Heisei')

Fixed code:
S = input()

year, month, day = [int(item) for item in S.split('/')]

if (int(year) >= 2019) & (int(month) >= 5):
	print('TBD')
else:
	print('Heisei')
Buggy code:
L = list(map(int, input().split("/")))
print("Heisesi" if L[1] >= 5 else "TBD")

Fixed code:
L = list(map(int, input().split("/")))
print("TBD" if L[1] >= 5 else "Heisei")
Buggy code:
txt = input()
if txt >= "2019/04/30":
    print("TBD")
else:
    print("Heisei")

Fixed code:
txt = input()
if txt > "2019/04/30":
    print("TBD")
else:
    print("Heisei")
Buggy code:
s = list((map(int, input().split("/"))))

if s[0] == 2019:
    if s[1] == 4:
        if s[2] <=30:
            print("Heisei")  
        else:
            print("TDB")        
    if s[1] > 4:
        print("TDB")     
    if s[1] < 4:   
        print("Heisei")  
        
elif s[0]> 2019:
    print("TDB")     

elif s[0] < 2019:
    print("Heisei")  


Fixed code:
s = list((map(int, input().split("/"))))

if s[0] == 2019:
    if s[1] == 4:
        if s[2] <=30:
            print("Heisei")  
        else:
            print("TBD")        
    if s[1] > 4:
        print("TBD")     
    if s[1] < 4:   
        print("Heisei")  
        
elif s[0]> 2019:
    print("TBD")     

elif s[0] < 2019:
    print("Heisei")
Buggy code:
a=list(map(int,input().split('/')))
if int(a[1])<5:
  print('Heisei')
else:
  print('TDB')
  

Fixed code:
a=list(map(int,input().split('/')))
if int(a[1])<5:
  print('Heisei')
else:
  print('TBD')
Buggy code:
s = input()
year, month = int(s[0:4]), int(s[5:7])
print(year, month)

if year > 2019 or (year == 2019 and month > 4):
	print("TBD")
else:
	print("Heisei")

Fixed code:
s = input()
year, month = int(s[0:4]), int(s[5:7])
#print(year, month)

if year > 2019 or (year == 2019 and month > 4):
	print("TBD")
else:
	print("Heisei")
Buggy code:
l=list(map(int,input().split('/')))
if(l[1]>4):
    print('Heisei')
else:
    print('TBD')

Fixed code:
l=list(map(int,input().split('/')))
if(l[1]<=4):
    print('Heisei')
else:
    print('TBD')
Buggy code:
S=input().split("/")
if int(S[0])>=2019 and int(S[1])>=5:
    print("TBD")
else:
    print("heisei")

Fixed code:
S=input().split("/")
if int(S[0])>=2019 and int(S[1])>=5:
  print("TBD")
else:
  print("Heisei")
Buggy code:
S = input()
year = int(S[:4])
month = int(S[5:7])
if year < 2019:
    print('Heisei')
elif year == 2019:
    if month > 4:
        print('TBD')
    else:
        print('Heisei')
else:
    print('TBD'

Fixed code:
S = input()
year = int(S[:4])
month = int(S[5:7])
if year < 2019:
    print('Heisei')
elif month < 5:
    print('Heisei')
else:
    print('TBD')
Buggy code:
N,A,B,C = map(int, input().split())

bms = [int(input()) for _ in Range(N)]

def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))

Fixed code:
N,A,B,C = map(int, input().split())

bms = [int(input()) for _ in range(N)]

def dfs(cur,a,b,c):
    if cur == N:
        s = abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c) > 0 else 10**9
        return s
    s_0 = dfs(cur+1,a,b,c)
    s_a = dfs(cur+1,a+bms[cur],b,c) + 10
    s_b = dfs(cur+1,a,b+bms[cur],c) + 10
    s_c = dfs(cur+1,a,b,c+bms[cur]) + 10
    return min(s_0,s_a,s_b,s_c)

print(dfs(0,0,0,0))
Buggy code:
n,a,b,c=map(int,input().split())
l = [int(input()) for _ in range(n)]
ans = 100000000
for i in range(4**n):
  x,y,z=0,0,0
  s,t,u=0,0,0
  for j in range(n):
    t = i % 4
    if t == 0:
      x += l[j]
      s += 1
    elif t == 1:
      y += l[j]
      t += 1
    elif t == 2:
      z += l[j]
      u += 1
  if s == 0 or t == 0 or u == 0:
    continue
  k = (s + t + u - 3) * 10
  k += abs(a - x)
  k += abs(b - y)
  k += abs(c - z)
  ans = min(ans, k)
print(ans)

Fixed code:
n,a,b,c=map(int,input().split())
l = [int(input()) for _ in range(n)]
ans = 100000000
for i in range(4**n):
  x,y,z=0,0,0
  s,t,u=0,0,0
  for j in range(n):
    if i % 4 == 0:
      x += l[j]
      s += 1
    elif i % 4 == 1:
      y += l[j]
      t += 1
    elif i % 4  == 2:
      z += l[j]
      u += 1
    i //= 4
  if s == 0 or t == 0 or u == 0:
    continue
  k = (s + t + u - 3) * 10
  k += abs(a - x)
  k += abs(b - y)
  k += abs(c - z)
  ans = min(ans, k)
print(ans)
Buggy code:
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
op=[[0],[1],[2]]
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
        tmp.append(j+[2])
    op=tmp
ans=1000000000
for i in op:
    ta=0
    tb=0
    tc=0
    for j in range(len(i)):
        if i[j]==0:
            ta+=l[j]
        elif i[j]==1:
            tb+=l[j]
        else:
            tc+=l[j]
    mp=abs(a-ta)+abs(b-tb)+abs(c-tc)
    if ta==0 or tb==0 or tc==0:
        mp=1000000000
    ans=min(ans,mp)
print(ans)

Fixed code:
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
op=[[0],[1],[2],[3]]
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
        tmp.append(j+[2])
        tmp.append(j+[3])
    op=tmp
ans=1000000000
for i in op:
    ta=0
    tb=0
    tc=0
    mp=0
    for j in range(len(i)):
        if i[j]==0:
            if ta!=0:
                mp+=10
            ta+=l[j]        
        elif i[j]==1:
            if tb!=0:
                mp+=10
            tb+=l[j]
        elif i[j]==2:
            if tc!=0:
                mp+=10
            tc+=l[j]
    mp+=abs(a-ta)+abs(b-tb)+abs(c-tc)
    if ta==0 or tb==0 or tc==0:
        mp=1000000000
    ans=min(ans,mp)
print(ans)
Buggy code:
def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else 10*9+7
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
print(dfs(0,0,0,0))

Fixed code:
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9
def dfs(cur,a,b,c):
  if cur==N:
    return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
  ret0 = dfs(cur+1,a,b,c)
  ret1 = dfs(cur+1,a+l[cur],b,c)+10
  ret2 = dfs(cur+1,a,b+l[cur],c)+10
  ret3 = dfs(cur+1,a,b,c+l[cur])+10
  return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))
Buggy code:
N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1,a+l[cur],b,c) +10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Fixed code:
N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1,a+l[cur],b,c) +10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))
Buggy code:
tgt_b = int(str_in[2])
tgt_c = int(str_in[3])

source = [int(input()) for i in range(num)]

mp = float('inf')

for i in range(1,2**num):

  sum_a = 0
  len_a = 0
  
  bin_i = format(i,'0256b')  
  for t in range(1,num+1):
    sum_a += int(bin_i[-t])
    len_a += int(bin_i[-t]) * source[t-1]
    
  for j in range(1,2**num):
 
    sum_b = 0
    len_b = 0

    if (i & j) > 0:
      continue
    
    bin_j = format(j,'0256b')
    for t in range(1,num+1):
      sum_b += int(bin_j[-t])
      len_b += int(bin_j[-t]) * source[t-1]

    for k in range(1,2**num):

      sum_c = 0
      len_c = 0
      
      if (i & k) > 0:
        continue
      elif(j & k) > 0:
        continue
        
      bin_k = format(k,'08b')        
      
      for t in range(1,num+1):
        sum_c += int(bin_k[-t])
        len_c += int(bin_k[-t]) * source[t-1]
        
      mp_try = abs(len_a - tgt_a) + abs(len_b - tgt_b) + abs(len_c - tgt_c) + (sum_a + sum_b + sum_c - 3) * 10 
      if(mp > mp_try):
        mp = mp_try

print (mp)


Fixed code:
str_in = input().split()
num   = int(str_in[0])
tgt_a = int(str_in[1])
tgt_b = int(str_in[2])
tgt_c = int(str_in[3])

source = [int(input()) for i in range(num)]

mp = float('inf')

for i in range(1,2**num):

  sum_a = 0
  len_a = 0
  
  bin_i = format(i,'08b')  
  for t in range(1,num+1):
    sum_a += int(bin_i[-t])
    len_a += int(bin_i[-t]) * source[t-1]
    
  for j in range(1,2**num):
 
    sum_b = 0
    len_b = 0

    if (i & j) > 0:
      continue
    
    bin_j = format(j,'08b')
    for t in range(1,num+1):
      sum_b += int(bin_j[-t])
      len_b += int(bin_j[-t]) * source[t-1]

    for k in range(1,2**num):

      sum_c = 0
      len_c = 0
      
      if (i & k) > 0:
        continue
      elif(j & k) > 0:
        continue
        
      bin_k = format(k,'08b')        
      
      for t in range(1,num+1):
        sum_c += int(bin_k[-t])
        len_c += int(bin_k[-t]) * source[t-1]
        
      mp_try = abs(len_a - tgt_a) + abs(len_b - tgt_b) + abs(len_c - tgt_c) + (sum_a + sum_b + sum_c - 3) * 10 
      if(mp > mp_try):
        mp = mp_try

print (mp)
Buggy code:
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(N**4):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-6
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=2
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
print(ans)

Fixed code:
N,A,B,C=map(int,input().split())
L=[int(input()) for i in range(N)]
R=[0]*N
ans=10**9
def myadd(i):
    if R[i]==3:
        R[i]=0
        myadd(i+1)
    else:
        R[i]+=1
for i in range(4**N-1):
    myadd(0)
    if 1 in R and 2 in R and 3 in R:
        tmp=-30
        t1,t2,t3=0,0,0
        for j in range(N):
            if R[j]==0:
                continue
            if R[j]==1:
                t1+=L[j]
            elif R[j]==2:
                t2+=L[j]
            elif R[j]==3:
                t3+=L[j]
            tmp+=10
        tmp+=abs(A-t1)+abs(B-t2)+abs(C-t3)
        ans=min(tmp,ans)
print(ans)
Buggy code:
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

min_mp = 10**10

for i in range(4**n):
    mp = 0
    li = [0]*4
    count_li = [0]*4
    s = Base_10_to_n(i,4).zfill(n)
    for j,k in enumerate(s):
        li[int(k)] += l[j]
        count_li[int(k)] += 1
    if 0 in li[:-1]:
        continue
    mp += abs(a-li[0])
    mp += abs(b-li[1])
    mp += abs(c-li[2])
    for item in count_li:
        if item >= 2:
            mp += 10*(item-1)
    min_mp = min(min_mp,mp)
    
print(min_mp)

Fixed code:
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

min_mp = 10**10

for i in range(4**n):
    mp = 0
    li = [0]*4
    count_li = [0]*4
    s = Base_10_to_n(i,4).zfill(n)

    for j,k in enumerate(s):
        li[int(k)] += l[j]
        count_li[int(k)] += 1

    if 0 in li[:-1]:
        continue

    mp += abs(a-li[0])
    mp += abs(b-li[1])
    mp += abs(c-li[2])

    for item in count_li[:3]:
        if item >= 2:
            mp += 10*(item-1)
            
    min_mp = min(min_mp,mp)

print(min_mp)
Buggy code:
    N, A, B, C = map(int, input().split())
    l = [int(input()) for _ in range(N)]

    def dfs(i, a, b, c, x):
        if i == N:
            return (abs(A - a) + abs(B - b) + abs(C - c) + 10 * (x - 3)) if a * b * c != 0 else 10 ** 9
        ret1 = dfs(i + 1, a, b, c, x)
        ret2 = dfs(i + 1, a + l[i], b, c, x + 1)
        ret3 = dfs(i + 1, a, b + l[i], c, x + 1)
        ret4 = dfs(i + 1, a, b, c + l[i], x + 1)
        return (min(ret1, ret2, ret3, ret4))


Fixed code:
N,A,B,C=map(int,input().split())
l=[int(input())for _ in range(N)]
def dfs(i,a,b,c,x):
    if i==N:
        return(abs(A-a)+abs(B-b)+abs(C-c)+10*(x-3))if a*b*c!=0 else 10**9
    ret1=dfs(i+1,a,b,c,x)
    ret2=dfs(i+1,a+l[i],b,c,x+1)
    ret3=dfs(i+1,a,b+l[i],c,x+1)
    ret4=dfs(i+1,a,b,c+l[i],x+1)
    return(min(ret1,ret2,ret3,ret4))
print(dfs(0,0,0,0,0))
Buggy code:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
  return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Fixed code:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
 
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))
Buggy code:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return float('inf')
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + [cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))


Fixed code:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return float('inf')
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))
Buggy code:
read = input
read = Read(False, """


8 1000 800 100
300
333
400
444
500
555
600
666

""").read
tmp = read()
tmp = list(map(int, tmp.split(' ')))
N,A,B,C = tmp
opt = list(map(int, map(lambda x: read(), range(N))))
def dfs(n,a,b,c):
    ret = 10**7
    if(n == N):
        if(min(a,b,c) == 0):
            return ret
        return abs(A - a) + abs(B - b) + abs(C - c) - 30
    cur = opt[n]
    ret = min(ret, dfs(n+1, a + cur, b, c) + 10)
    ret = min(ret, dfs(n+1, a, b + cur, c) + 10)
    ret = min(ret, dfs(n+1, a, b ,c + cur) + 10)
    ret = min(ret, dfs(n+1, a, b ,c ) + 0)
    return ret
print(dfs(0, 0, 0, 0))

Fixed code:
read = input
# read = Read(False, """


# 8 1000 800 100
# 300
# 333
# 400
# 444
# 500
# 555
# 600
# 666

# """).read
tmp = read()
tmp = list(map(int, tmp.split(' ')))
N,A,B,C = tmp
opt = list(map(int, map(lambda x: read(), range(N))))
def dfs(n,a,b,c):
    ret = 10**7
    if(n == N):
        if(min(a,b,c) == 0):
            return ret
        return abs(A - a) + abs(B - b) + abs(C - c) - 30
    cur = opt[n]
    ret = min(ret, dfs(n+1, a + cur, b, c) + 10)
    ret = min(ret, dfs(n+1, a, b + cur, c) + 10)
    ret = min(ret, dfs(n+1, a, b ,c + cur) + 10)
    ret = min(ret, dfs(n+1, a, b ,c ) + 0)
    return ret
print(dfs(0, 0, 0, 0))
Buggy code:
from itertools import product
N,*ABC=map(int,input().split())
L=[int(input()) for i in range(N)]
MP=10**9
for P in product([0,1,2,3],repeat=N):
    if {0,1,2}<=set(P):
        m=[0,0,0]
        for p,l in zip(P,L):
            if p!=3:m[p]+=l
            cost1=sum(abs(m-l) for m,l in zip(m,ABC))
            cost2=sum(1 for i in P if i!=3)-3
            MP=min(MP,cost1+cost2*10)
print(MP)

Fixed code:
from itertools import product
N,*ABC=map(int,input().split())
L=[int(input()) for i in range(N)]
MP=10**9
for P in product([0,1,2,3],repeat=N):
    if {0,1,2}<=set(P):
        m=[0,0,0]
        for p,l in zip(P,L):
            if p!=3:m[p]+=l
        cost1=sum(abs(m-l) for m,l in zip(m,ABC))
        cost2=sum(1 for i in P if i!=3)-3
        MP=min(MP,cost1+cost2*10)
print(MP)
Buggy code:
n,A,B,C = map(int,input().split())
l = list(int(input())for _ in range(n))
def dfs(depth,a,b,c):
    if depth == n:
        return abs(a-A)+abs(b-B)*abs(c-C)-30  if min(a,b,c) >0 else 10**9
    x = dfs(depth+1,a,b,c)
    y = dfs(depth+1,a+l[depth],b,c) +10
    z = dfs(depth+1,a,b+l[depth],c) +10
    w = dfs(depth+1,a,b,c+l[depth]) +10
    return min(x,y,z,w)
dfs(0,0,0,0)
    
        

Fixed code:
n,A,B,C = map(int,input().split())
l = list(int(input())for _ in range(n))
def dfs(depth,a,b,c):
    if depth == n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30  if min(a,b,c) >0 else 10**9
    x = dfs(depth+1,a,b,c)
    y = dfs(depth+1,a+l[depth],b,c) +10
    z = dfs(depth+1,a,b+l[depth],c) +10
    w = dfs(depth+1,a,b,c+l[depth]) +10
    return min(x,y,z,w)
print(dfs(0,0,0,0))
Buggy code:
N, A, B, C = map(int, input().split())
l = [int(input() for i in range(n))]
inf = 10**4

def bamboo_connect(i, a, b, c):
    if i == N:
        if all(a, b, c):
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else:
            return inf
    no_connect = bamboo_connect(i+1, a, b, c)
    choice_a = bamboo_connect(i+1, a+l[i], b, c) + 10
    choice_b = bamboo_connect(i+1, a, b+l[i], c) + 10
    choice_c = bamboo_connect(i+1, a, b, c+l[i]) + 10
    return min(no_connect, choice_a, choice_b, choice_c)

print(bamboo_connect(0, 0, 0, 0))

Fixed code:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
inf = 10**4

def bamboo_connect(i, a, b, c):
    if i == N:
        if all((a, b, c)):
            return abs(a-A) + abs(b-B) + abs(c-C) - 30
        else:
            return inf
    no_connect = bamboo_connect(i+1, a, b, c)
    choice_a = bamboo_connect(i+1, a+l[i], b, c) + 10
    choice_b = bamboo_connect(i+1, a, b+l[i], c) + 10
    choice_c = bamboo_connect(i+1, a, b, c+l[i]) + 10
    return min(no_connect, choice_a, choice_b, choice_c)

print(bamboo_connect(0, 0, 0, 0))