Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())
list_num = [i for i in range(A, B+1, 1)]
list_num2 = []

for i in range(K):
    if len(list_num) == 0:
        break
    print(list_num[0])
    list_num.pop(0)

for i in range(K):
    if len(list_num) == 0:
        break
    list_num2.append(list_num[-1])
    list_num.pop(-1)
list_num2.sort()
for i in list_num2:
    print(i)


Fixed submission:
A, B, K = map(int, input().split())

list_num = []
a_max = -1
for i in range(K):
    if A+i <= B:
        a_max = A+i
        print(a_max)

tmp = K
for i in range(K):
    if B - tmp + 1 > a_max:
        print(B - tmp + 1)
    tmp -= 1
Buggy python submission (verdict: Runtime Error):
import sys
a, b = map(str, input().split())
x = int(a+b)

for i in range(1001):
    if x == i*i:
        print("Yes")
        sys.exit(1)
print("No")


Fixed submission:
import sys
a, b = map(str, input().split())
x = int(a+b)

for i in range(1001):
    if x == i*i:
        print("Yes")
        sys.exit()
print("No")
Buggy python submission (verdict: Runtime Error):
S = input()
if S[1]==S[2]==S[3]:
    print("Yes")
elif S[2]==S[3]==S[4]:
    print("Yes")
else:
    print("No")


Fixed submission:
S = input()
if S[0]==S[1]==S[2]:
    print("Yes")
elif S[1]==S[2]==S[3]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

def GCD(L):
  while(len(L)>1):
    a=min(L)
    M=map(lambda x: x%a, L)
    L=[a]+list(filter(lambda x: x!=0, M))
  return a

cogcd=[ 0 for i in range(N)]

for i in range(N):
  cogcd[i]=GCD(A[:i]+A[i+1:])

print(max(cogcd))

Fixed submission:
A,B,T=map(int,input().split())
print(int(T/A)*B)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

def GCD(a,b):
  if(a<b): a,b=b,a
  while(b!=0):
    a,b=b,a%b
  return a

cogcd=[0 for i in range(N)]
allgcd=GCD(A[0],A[1])
cogcd[0]=A[1]
cogcd[1]=A[0]

for i in range(2,N):
  for j in range(i):
    cogcd[j]=GCD(cogcd[j],A[i])
  cogcd[i]=allgcd
  allgcd=GCD(allgcd,A[i])
print(max(cogcd))

Fixed submission:
A,B,T=map(int,input().split())
print(int(T/A)*B)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
First=S[0]
Now=First
cnt=0
A=[0]
for s in S:
    if Now=='1' and s=='0':
        A+=[cnt]
        Now='0'
    elif Now=='0' and s=='1':
        A+=[cnt]
        Now='1'
    cnt+=1
A+=[N]
dp=2*K+1
ans=[]

if First=="0":
    p=1
    ans.append(A[min(dp-1,len(A)-1)])
else:
    p=0
    ans.append(A[min(dp,len(A)-1)])

while p+dp<len(A):
	ans.append(A[p+dp]-A[p])
	p+=2

print(A)
print(max(ans))

Fixed submission:
A,B=list(map(int,input().split()))
if A==B:
  print(2*A)
else:
  print(2*max(A,B)-1)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
First=S[0]
Last=S[N-1]

Now=First
cnt=0
A=[0,0]
for s in S:
    if Now=='1' and s=='0':
        A+=[cnt]
        Now='0'
    elif Now=='0' and s=='1':
        A+=[cnt]
        Now='1'
    cnt+=1
A+=[cnt,cnt]

ans=0
dp=2*K+1
if First=="0":
    p=0
else:
    p=1
while p+dp<len(A):
   if A[p+dp]-A[p]>ans:ans=A[p+dp]-A[p]
   p+=2
print(ans)

Fixed submission:
A,B=list(map(int,input().split()))
if A==B:
  print(2*A)
else:
  print(2*max(A,B)-1)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
S=input()
First=S[0]
Last=S[N-1]

Now=First
cnt=0
A=[0,0]
for s in S:
    if Now=='1' and s=='0':
        A+=[cnt]
        Now='0'
    elif Now=='0' and s=='1':
        A+=[cnt]
        Now='1'
    cnt+=1
A+=[cnt,cnt]

ans=0
dp=2*K+1
if First=="0":
    p=0
else:
    p=1
while p+dp<len(A):
   if A[p+dp]-A[p]>ans:ans=A[p+dp]-A[p]
   p+=2
print(ans)

Fixed submission:
A,B=list(map(int,input().split()))
if A==B:
  print(2*A)
else:
  print(2*max(A,B)-1)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate as acc

N,K=map(int,input().split())
S=input()
First=S[0]
Last=S[N-1]
Now=First
cnt=0
Cont=[]
for s in S:    
    if Now=='1' and s=='0':
        Cont+=[cnt]
        cnt=0
        Now='0'
    elif Now=='0' and s=='1':
        Cont+=[cnt]
        cnt=0
        Now='1'
    cnt+=1
Cont+=[cnt]

lenC=len(Cont)
if First=="0":
    A1=[0]+[list(acc(Cont))[i] for i in range(lenC) if i%2==1]
    A0=[0]+[list(acc(Cont))[i] for i in range(lenC) if i%2==0]
else:
    A1=[list(acc(Cont))[i] for i in range(lenC) if i%2==0]
    A0=[0]+[list(acc(Cont))[i] for i in range(lenC) if i%2==1]

if Last=="0":
    A1+=[N]

if First=="0":
    if K<len(A1):
        print(max([A1[i+K]-A0[i] for i in range(len(A1)-K)]))
    else:
        print(A1[len(A1)-1])
else:
    if K<len(A1):
        print(max([A1[i+K]-A0[i] for i in range(len(A1)-K)]))
    else:
        print(A1[len(A1)-1])

Fixed submission:
N,K=map(int,input().split())
S=input()
First=S[0]
Now=First
cnt=0
A=[0]
for s in S:
    if Now=='1' and s=='0':
        A+=[cnt]
        Now='0'
    elif Now=='0' and s=='1':
        A+=[cnt]
        Now='1'
    cnt+=1
A+=[N]
dp=2*K+1
ans=[]

if First=="0":
    p=1
    ans.append(A[min(dp-1,len(A)-1)])
else:
    p=0
    ans.append(A[min(dp,len(A)-1)])

while p+dp<len(A):
	ans.append(A[p+dp]-A[p])
	p+=2
ans.append(N-A[p])
#print(A)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8
#

def main(input_str):
    checker = {}
    checker['a'] = False
    checker['b'] = False
    checker['c'] = False
    
    if 3 != len(list(input_str)):
        print('No')
        return

    for s in list(input_str):
        checker[s] = True
    
    
    if checker['a'] and checker['b'] and checker['c']:
        print('Yes')
        return
    print('No')
    return


if __name__ == '__main__':
    while True:
        try:
            main(input().strip())
        except EOFError:
            pass


Fixed submission:
#!/usr/bin/env python
# coding: utf-8
#

def main(input_str):
    checker = {}
    checker['a'] = False
    checker['b'] = False
    checker['c'] = False
    
    if 3 != len(list(input_str)):
        print('No')
        return

    for s in list(input_str):
        checker[s] = True
    
    
    if checker['a'] and checker['b'] and checker['c']:
        print('Yes')
        return
    print('No')
    return


if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass
Buggy python submission (verdict: Runtime Error):
A,B,T = map(int,input().split())
H = (T + ) // A
print(B * H)

Fixed submission:
A,B,T = map(int,input().split())
H = (T + 0.5) // A
F = B * H // B * H
print(round(B * H))
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().rstrip().split())
if A == B:
    print(A*A)
else:
    print(max(A,B) * (max(A,B) - 1)

Fixed submission:
A,B = map(int,input().rstrip().split())

X = max(A,B)
if A == B:
    G = X * 2
else:
    Y = max(A,B) - 1
    G = X + Y
print(G)

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().rstrip().split())
if A == B:
    print(A*A)
else:
    print(max(A,B) + (max(A,B) - 1)

Fixed submission:
A,B = map(int,input().rstrip().split())

X = max(A,B)
if A == B:
    G = X * 2
else:
    Y = max(A,B) - 1
    G = X + Y
print(G)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().rsplit().split())
h,w = map(int,input().rsplit().split())
print(H * W - h * w)

Fixed submission:
H,W = map(int,input().rstrip().split())
h,w = map(int,input().rstrip().split())
print(H * W - h * W - (H - h) * w)
Buggy python submission (verdict: Runtime Error):
s = int(input())
x = 1
if s == 1 or s == 2:
    print(4)
else:
    while not s == 4:
        if s % 2 != 0:
            s = 3 * s + 1
            x = x + 1
               
        else:
            s = s // 2
            x = x + 1
        
        
print(x + 3)

Fixed submission:
a,b,c = map(int,input().rstrip().split())

print(a * b // 2)
Buggy python submission (verdict: Runtime Error):
X = int(input())
if X == 3,5,7:
  print('YES')
else:
  print('NO')

Fixed submission:
X = int(input())
if X == 3 or X == 5 or X ==7:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
S = input()
max_l = 0
temp_l = 0

for s in S:
    if s == 'A' or s=='G' or s=='C' or s=='T':
        temp_l += 1
        
    else:
      	max_l = max(max_l, temp_l)
        temp_l = 0

print(max_l)


Fixed submission:
S = input()
max_l = 0
temp_l = 0

for s in S:
    if s == 'A' or s=='G' or s=='C' or s=='T':
        temp_l += 1
        max_l = max(max_l, temp_l)
    else:
        temp_l = 0

print(max_l)
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input().split('/')))
flag = 1
if s[0] > 2019:
    flag = 0
elif s[0] == 2019:
    if s[1] > 4:
        flag = 0

ans_list = ['TBD', 'Heisei']
print(ans[flag])


Fixed submission:
strings = input().split('/')
s = list(map(int, strings))
flag = 1
if s[0] > 2019:
    flag = 0
elif s[0] == 2019:
    if s[1] > 4:
        flag = 0

ans_list = ['TBD', 'Heisei']
print(ans_list[flag])
Buggy python submission (verdict: Runtime Error):
rate = 380000
N = int(input())

total = 0
for i in range(N):
    x,u = input()
    val = int(x)
    if u=='BTC':
        val *= rate
    total += val
print(total)


Fixed submission:
rate = 380000
N = int(input())

total = 0
for i in range(N):
    x, u = input().split()
    val = float(x)
    if u=='BTC':
        val *= rate
    total += val
print(total)
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = []
for j in range(N):
  W.append(input())
  j += 1


i = 0
while i < N:
  m = W[i-1]
  n = W[i]
  if m[-1:] == n[:1]:
    i += 1
  else:
    print('No')
    exit()
else:
  W.sort()
  for k in range(N):
      m = W[i]
      n = W[i+1]
      if m == n:
        print('No')
        exit()
print('Yes')

Fixed submission:
N = int(input())
W = [0] * N
for i in range(N):
    W[i] = input()
if len(set(W)) != N:
    print('No')
    exit()
for i in range(N - 1):
    w1 = W[i]
    w2 = W[i+1]
    if w1[-1] != w2[0]:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
ans = 0
for i in range(1,N + 1):
  for j in range(1,N + 1):
    for k in range(1,N + 1):
      if ((i + j) % K == 0) and ((j + k) % K == 0) and ((k + i) % K == 0):
        ans += 1
print(ans)

Fixed submission:
K = int(input())
if K % 2 == 0:
  print(int(K * K / 4))
else:
  print(int((K * K - 1) / 4))
Buggy python submission (verdict: Runtime Error):
S = input()
p = S.count('+')
m = s.count('-')
print(p-m)

Fixed submission:
s = input()
p = s.count('+')
m = s.count('-')
print(p-m)
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if N = 100:
  print((100 ** D) * (101))
else:
  print((100 ** D) * N)


Fixed submission:
D, N = map(int, input().split())
if N == 100:
  print((100 ** D) * (101))
else:
  print((100 ** D) * N)

Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if n = 100:
  print((100 ** D) * (N+1))
else:
  print((100 ** D) * N)

Fixed submission:
D, N = map(int, input().split())
if N == 100:
  print((100 ** D) * (101))
else:
  print((100 ** D) * N)
Buggy python submission (verdict: Runtime Error):
N = int(inut())
if N <= 999:
  print('ABC')
else:
  print('ABD')

Fixed submission:
N = int(input())
if N <= 999:
  print('ABC')
else:
  print('ABD')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max[a*b,a+b,a-b])

Fixed submission:
a,b=map(int,input().split())
print(max(a*b,a+b,a-b))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if A <= X <= A + B:
  print('YES')
else:
  print('NO')

Fixed submission:
A, B, X=map(int,input().split())
if A <= X <= A + B:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if A <= X <= A + B:
  print('YES')
else:
  print('No')

Fixed submission:
A, B, X=map(int,input().split())
if A <= X <= A + B:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int,input(),split())
if a + b <= c:
  print('Yes')
else:
  print('No')

Fixed submission:
a, b, c = map(int, input().split())
if a + b >= c:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
def algo(s):
  if len(s) == 1:
    return 0
  elif len(s) == 2:
    if s[0] != s[1]:
      return 2
    else:
      return 0
  else:
    tmp = ""
    for i in range(1, len(s)-1):
      if s[i] != s[i+1]:
        tmp += s[0:i] + s[i+2:]
        break
    return 2 + algo(tmp)
    
x = input()
ans = algo(x)
print(ans)

Fixed submission:
x = input()
cnt1 = 0
cnt2 = 0
for i in x:
  if i == '1':
    cnt1 += 1
  else:
    cnt2 += 1
print(min(cnt1, cnt2)*2)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
A_s = []
for _ in range(N):
  A_s.append(list(map(int,input().split())))
## Aiの順にsortする
A_s = sorted(A_s,key=lambda x:x[0])
money = 0
num = 0
pre_num = 0
for a_s in A_s:
  num += a_s[1]
  if num <= M:
    money += a_s[1] * a_s[0]
    pre_num += a_s[1]
  else:
    money += (M-pre_num) * a_s[0]
    break
  #print(money)
print(money)

Fixed submission:
import numpy as np
H,W = map(int,input().split())
h,w = map(int,input().split())
matrix = np.ones((H,W))
h_num = np.random.choice(H,h,replace=False)
w_num = np.random.choice(W,w,replace=False)

for _ in h_num:
  matrix[_,:] = 0
for _ in w_num:
  matrix[:,_] = 0

print(int(np.sum(matrix)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
A,B = map(int,input().split())
b = np.arange(A,B+1)
def bin2np(a):
  return list(map(int,list(bin(a)[2:])))
# 1番長い二進数の配列を知る
max_length = len(bin2np(b[-1]))
## ここから、足りない分だけ前に挿入していく
bin2list = []
for a in b:
  c = bin2np(a)
  for _ in range(max_length-len(c)):
    c.insert(0,0)
  #print(c)
  bin2list.append(c)
bin2list = np.array(bin2list)
bin2s = list(map(str,np.where(np.sum(bin2list,axis=0)==1,1,0)))
print(int("".join(bin2s),2))
    

Fixed submission:
import numpy as np
H,W = map(int,input().split())
h,w = map(int,input().split())
matrix = np.ones((H,W))
h_num = np.random.choice(H,h,replace=False)
w_num = np.random.choice(W,w,replace=False)

for _ in h_num:
  matrix[_,:] = 0
for _ in w_num:
  matrix[:,_] = 0

print(int(np.sum(matrix)))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M = map(int,input().split())
A_s = []
for _ in range(N):
  A_s.append(list(map(int,input().split())))
## Aiの順にsortする
A_s = sorted(A_s,key=lambda x:x[0])
## そこまでの合計本数を足したlistを作成？
A_s = np.array(A_s)
nums = []
[nums.append(np.sum(A_s[:k+1,1:])) for k in range(len(A_s))]
#print("num",nums)
## あとは要件を満たす場所を見つけて、そこまではただ掛け算をして、それ以降は足す
## for文をbreakで抜けてもいいか〜〜
#print(nums)
money = 0
pre_num = 0
for a_s,num in zip(A_s,nums):
  if num <= M:
    money += a_s[1] * a_s[0]
    pre_num = num
  else:
    money += (M-pre_num) * a_s[0]
    break
  #print(money)
print(money)

Fixed submission:
import numpy as np
N,M = map(int,input().split())
A_s = []
for _ in range(N):
  A_s.append(list(map(int,input().split())))
## Aiの順にsortする
A_s = sorted(A_s,key=lambda x:x[0])
money = 0
num = 0
pre_num = 0
for a_s in A_s:
  num += a_s[1]
  if num <= M:
    money += a_s[1] * a_s[0]
    pre_num += a_s[1]
  else:
    money += (M-pre_num) * a_s[0]
    break
  #print(money)
print(money)
Buggy python submission (verdict: Runtime Error):
n = input().split()
c = list(input()) 
c[int(n[1] - 1)] = c[int(n[1]) - 1].lower()
print("".join(c))


Fixed submission:
n = input().split()
c = list(input()) 
c[int(n[1]) - 1] = c[int(n[1]) - 1].lower()
print("".join(c))

Buggy python submission (verdict: Runtime Error):
n = input().split()
c = list(input()) 
c[int(n[1])] = c[int(n[1])].lower()
print("".join(c))


Fixed submission:
n = input().split()
c = list(input()) 
c[int(n[1]) - 1] = c[int(n[1]) - 1].lower()
print("".join(c))
Buggy python submission (verdict: Runtime Error):
import copy 

n = int(input())
s = list(input())
k = int(input())

ans = s
for i in range(n):
    if ans[i] != s[k]:
        ans[i] = '*'
print(''.join(ans))



Fixed submission:
import copy 

n = int(input())
s = list(input())
k = int(input())

ans = s
for i in range(n):
    if ans[i] != s[k - 1]:
        ans[i] = '*'
print(''.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = [0 for i in range(n + 1)]

for i in range(n):
    for j in range(n + 1):
        if j <= i:
            if s[i] == '.':
                ans[j] += 1
        else:
            if s[i] == '#':
                ans[j] += 1
print(min(ans))



Fixed submission:

n = int(input())
s = input()

b = 0
w = 0
tb = 0
tw = 0

for i in reversed(range(n)):
    if s[i] == '#':
        tb += 1
        if tb > tw:
            b += tb
            w += tw
            tb = 0
            tw = 0
    else:
        tw += 1
print(tb + w)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = list(input())
lr_list = [0] * Q

for i in range(Q):
    lr_list[i] = list(map(int, input().split()))

a_list = []
for i in range(len(S)):
    if S[i] == "A" and i != len(S) - 1:
        if S[i + 1] == "C":
            a_list.append(i)
counter = 0
for i in range(Q):
    for j in range(len(a_list)):
        if lr_list[i][0] - 1 <= a_list[j] and a_list[j]+1 <= lr_list[i][1]-1:
            counter += 1
    print(counter)
    counter=0


Fixed submission:
N, Q = map(int, input().split())
S = list(input())
lr_list = [0] * Q

a_list = []
for i in range(len(S)):
    if S[i] == "A" and i != len(S) - 1:
        if S[i + 1] == "C":
            S[i]="a"

ti=[0]*N

for i in range(1,N):
    if S[i-1]=="a":
        ti[i]=ti[i-1]+1
    else:
        ti[i]=ti[i-1]

for i in range(Q):
    l,r= list(map(int, input().split()))
    print(ti[r-1]-ti[l-1])
Buggy python submission (verdict: Runtime Error):
N = list(input())
max_N = max(N)

if max_N < sum(N)-max_N :
  print("Yes")
else:
  print("No")

Fixed submission:
Q = int(input())
N = list(map(int, input().split()))
max_N = max(N)

if max_N < sum(N)-max_N :
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

N = int(input())
A = list(map(int, input().split()))
l = []
for i in range(N):
    B = A[:]
    B.pop(i)
    l.append(reduce(fractions.gcd, B))
    
print(max(l))

Fixed submission:
from itertools import*
from fractions import*
n,*a=map(int,open(0).read().split())
b=list(accumulate([0]+a,gcd))
c=list(accumulate([0]+a[::-1],gcd))
print(max(gcd(s,t)for s,t in zip(b,c[::-1][1:])))
Buggy python submission (verdict: Time Limit Exceeded):
#input
N, Q = [int(i) for i in input().split(" ")]
st = input()
lis = []
for i in range(Q):
  lis.append([int(i) for i in input().split(" ")])
  
for i in range(Q):
  print(st[lis[i][0]-1:lis[i][1]].count("AC"))

Fixed submission:
from itertools import accumulate


N, Q = list(map(int, input().split()))
S = input()
A = [list(map(int, input().split())) for i in range(Q)]

flg = []
for i in range(N-1):
    tmp_S = S[i:i+2]
    if tmp_S == 'AC':
        flg.append(1)
    else:
        flg.append(0)

flg2 = [0] + flg
flg2 = list(accumulate(flg2))

for a in A:
    print(flg2[a[1]-1] - flg2[a[0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
#1,0が隣り合ったところを取り出していく　

L = [int(i) for i in list(input())]
N = len(L)
count = 0
flag = 0

k = 0
while 1:
  flag = 0
  i = N - 1
  while (i != 0) and (i > 0) :
    if (((L[i - 1] == 1) and (L[i] == 0)) or ((L[i - 1] == 0) and (L[i] == 1))):
      del L[i - 1:i + 1]
      N = N - 2
      count += 2
      i -= 1
      flag = 1
    i -= 1

  if flag == 0:
    break

print(count)


Fixed submission:
L = [int(i) for i in list(input())]
N = len(L)

one = L.count(1)
zero = L.count(0)

if one < zero :
  print(one * 2)
else :
  print(zero * 2)
Buggy python submission (verdict: Runtime Error):
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 submission:
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 python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

INF = 10 ** 9


def dfs(cursor, a, b, c):  # cursor:カーソル a,b,c:現在の竹の長さ
    if cursor == N:  # cursorが最後まで行ったら終了する。
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) &gt; 0 else INF
    # abs(a - A) + abs(b - B) + abs(c - C) - 30 でなぜ30を減じているのかというと、
    # dfs(0,0,0)
    # dfs(0,0,0,0)で始まる以上、最初に選ばれるa,b,cを決定する際にもコストが10増加してしまうからである。
    # また、全探索を行う中で、a,b,cの初期値が0,0,0である以上、a,b,cのどれかが0のまま終了する場合が存在する。
    # この場合はa,b,cに竹が対応してないと言えるため、解にはならない、そこで三項演算子を利用して
    # その場合についてコストをINFとしている

    # 以下は4**Nで展開される再起処理となる。
    # カーソルの当たっている竹に対して、(A or B or Cに合成する) or (合成しない)の場合に分ける
    no_compound_pattern = dfs(cursor+1, a, b, c)
    compound_a_pattern = dfs(cursor+1, a + L[cursor], b, c)+10
    compound_b_pattern = dfs(cursor+1, a, b + L[cursor], c)+10
    compound_c_pattern = dfs(cursor+1, a, b, c + L[cursor])+10

    # 結果的に以下の値が返るのはそれぞれのパターンのコストが決定されてからなので
    # 以下のコードは最終的なコストの最小値
    return min(no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern)


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


Fixed submission:
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 python submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(' ')]
L = read()
if(L[0] + L[1] == L[2] or L[0] + L[2] == L[1] or L[1] + L[2] == L[3]):
	print('Yes')
else:
	print('No')


Fixed submission:
def read():
	return [int(i) for i in input().split(' ')]
L = read()
if(L[0] + L[1] == L[2] or L[0] + L[2] == L[1] or L[1] + L[2] == L[0]):
	print('Yes')
else:
	print('No')

Buggy python submission (verdict: Runtime Error):
def read():
	return [int(i) for i in input().split(' ')]
L = read()
if(L[0] + L[1] == L[2] or L[0] + L[2] == L[1] or L[1] + L[2] == L[3]):
	print('Yes')
else:
	print('No')


Fixed submission:
def read():
	return [int(i) for i in input().split(' ')]
L = read()
if(L[0] + L[1] == L[2] or L[0] + L[2] == L[1] or L[1] + L[2] == L[0]):
	print('Yes')
else:
	print('No')