Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
y,m,d = input().split("/")
flag = False
if(int(y) > 2019) :
  flag = True
elif(int(y) == 2019):
  if(m>=5):
    flag = True
print("TBD" if flag else "Heisei")

Fixed submission:
y,m,d = input().split("/")
flag = False
if(int(y) > 2019) :
  flag = True
elif(int(y) == 2019):
  if(int(m)>=5):
    flag = True
print("TBD" if flag else "Heisei")
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split(" "))
if (b%a == 0):
  print(a-b)
else :
  print(b-a)

Fixed submission:
a,b = map(int,input().split(" "))
if (b%a == 0):
  print(a+b)
else :
  print(b-a)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input.split(" "))
print((a*b)/2)

Fixed submission:
a,b,c = map(int,input().split(" "))
print(int((a*b)/2))

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input.split(" "))
print((a*b)/c)

Fixed submission:
a,b,c = map(int,input().split(" "))
print(int((a*b)/2))
Buggy python submission (verdict: Runtime Error):
#coding : UTF-8
x,y = input.split()
print(int(x)+int(y/2))

Fixed submission:
#coding : UTF-8
x,y = map(int,input().split())
print(int(x+y/2))
Buggy python submission (verdict: Runtime Error):
a,b=int(input())
print(":("if a>8 or b>8 else "Yay!")

Fixed submission:
a,b=map(int,input().split(" "))
print(":("if a>8 or b>8 else "Yay!")
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 = int(input().split(" "))
print("Even" (a*b)%2==0 else "Odd")

Fixed submission:
a,b = map(int,input().split(" "))
print("Even" if (a*b)%2==0 else "Odd")
Buggy python submission (verdict: Runtime Error):
y,m,d = input().split("/")
print("2018/"+m"/"+d if y == "2017" else y+"/"+m"/"+d)

Fixed submission:
y,m,d = input().split("/")
print("2018/"+m+"/"+d if y == "2017" else y+"/"+m+"/"+d)
Buggy python submission (verdict: Runtime Error):
s = input()
flag = False
for n in s :
	m = s.find(n)
	if s[m] == s[m+1] == s[m+2] :
		flag = True
		break
print("Yes" if flag else "No")

Fixed submission:
s = input()
flag = False
for n in s :
	m = s.find(n)
	if m < len(s)-2 and s[m] == s[m+1] == s[m+2] :
		flag = True
		break
print("Yes" if flag else "No")
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
print("<" a<b else ">")

Fixed submission:
a,b = input().split()
print("<" if a<b else ">" if a>b else "=")
Buggy python submission (verdict: Runtime Error):
a,*b,c=list(input().split())
print(a+str(len(b))+c)

Fixed submission:
a,*b,c=input()
print(a+str(len(b))+c)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
m = min(a,b,c)
n = min([a,b,c].remove(m))
print(m+n)

Fixed submission:
s = list(map(int,input().split()))
m = min(s)
s.remove(m)
print(m+min(s))
Buggy python submission (verdict: Runtime Error):
n = [int(inout()) for _ in [0]*3]
print( int(((n[0]+n[1])*n[2])/2) )

Fixed submission:
n = [int(input()) for _ in [0]*3]
print( int(((n[0]+n[1])*n[2])/2) )
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
H = input().split()

count = 0
max = 0
flag = []
for i in (range(int(N)-1)):
  if(int(H[i]) >= int(H[i+1])):
    flag.append(i)
  else:
    continue

H.append(10000000000)

for i in flag:
  for j in range(i,int(N)):
    if(max > int(N) - i):
      count = j - i
      break
    
    if(max > int(N) - j):
      count = j - i 
      break

    if(int(H[j]) >= int(H[j+1])):
      continue
    else:
      count = j - i
      break

  if (max < count):
    max = count
    count = 0

print(max)
~              

Fixed submission:
n = int(input())
L = list(map(int,input().split()))
 
count = 0
mcount = 0
for i in range(1,n):
      if L[i - 1] >= L[i]:
            count += 1
            if count >= mcount:
                  mcount = count
      else:
            count = 0
print(mcount)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
H = input().split()

count = 0
max = 0
flag = []
for i in (range(int(N)-1)):
  if(int(H[i]) >= int(H[i+1])):
    flag.append(i)
  else:
    continue

H.append(10000000000)

for i in flag:
  for j in range(i,int(N)):
    if(int(H[j]) >= int(H[j+1])):
      continue
    else:
      count = j - i
      break

  if (max < count):
    max = count
    count = 0

print(max)


Fixed submission:
n = int(input())
L = list(map(int,input().split()))
 
count = 0
mcount = 0
for i in range(1,n):
      if L[i - 1] >= L[i]:
            count += 1
            if count >= mcount:
                  mcount = count
      else:
            count = 0
print(mcount)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
H = input().split()

count = 0
max = 0
flag = []
for i in (range(int(N)-1)):
  if(int(H[i]) >= int(H[i+1])):
    flag.append(i)
  else:
    continue

for i in flag:
  for j in range(i,int(N)):
    if(j == int(N)-1):
      count = j - i
      break

    if(int(H[j]) >= int(H[j+1])):
      continue
    else:
      count = j - i
      break

  if (max < count):
    max = count
    count = 0

print(max)

Fixed submission:
n = int(input())
L = list(map(int,input().split()))
 
count = 0
mcount = 0
for i in range(1,n):
      if L[i - 1] >= L[i]:
            count += 1
            if count >= mcount:
                  mcount = count
      else:
            count = 0
print(mcount)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Thu Oct  3 07:43:37 2019

@author: avina
"""

import heapq

class Maxheap():
    
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)
    
    def push(self, value):
        heapq.heappush(self.heap, -value)
    
    def pop(self):
        return -heapq.heappop(self.heap)

n,t = map(int, input().split())

l = list(map(int, input().split()))
a = Maxheap(l)
for i in range(l):
    b = a.pop()//2
    a.push(b)
    
sums = 0
for i in range(n):
    sums += a.pop()
print(sums)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Oct  2 07:56:16 2019

@author: avina
"""
from queue import PriorityQueue as Q
n,t = map(int,input().split())

q = Q()
for i in input().split():
    a = -1*int(i)
    q.put(a)

while t >0:
    a = -1*(q.get())
    a = -1*(a//2)
    q.put(a)
    t-=1

ans = 0
while q.qsize()>0:
    ans += q.get()
print(-1*ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
a -=1
if a == 0:
  print(0)
else:
	ans = (ans*(ans-1))//2
	print(ans)

Fixed submission:
a = int(input())
a= (a*(a-1))//2
print(a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = {}
for i in range(n):
  a = input();k = 0
  for j in range(10):
    k+= ord(a[j]) - 95
  if k not in d:
    d[k] = 1
  else:
    d[k]+=1
if len(d) == 0:
  print(0)
else:
  print(max(d.values())

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 25 08:58:11 2019

@author: avina
"""

n = int(input())
d = {}
for i in range(n):
  a = list(input())
  a.sort()
  a = ''.join(a)
  if a not in d:
    d[a] = 1
  else:
    d[a]+=1
ans = 0
for i in d:
    ans += ((d[i])*(d[i]-1))//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 28 20:37:55 2019

@author: avina
"""

l,r = map(int, input().split())
k = 2020

for i in range(l,r+1):
   for j in range(i+1,r+1):
       k = min(k, (i*j)%2019)
       if k == 0:
           break
print(k)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 28 20:37:55 2019

@author: avina
"""

l,r = map(int, input().split())
k = 2020

for i in range(l,r+1):
   for j in range(i+1,r+1):
       k = min(k, (i*j)%2019)
       if k == 0:
           print(k)
           exit()
print(k)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 09:49:38 2019

@author: avina
"""

from math import gcd
n = int(input())
l = list(map(int, input().strip().split()))
maxe = 0
     
for i in range(n):
    for j in range(n):
        if i != j:
            g = gcd(l[i],l[j])
            maxe = max(maxe, g)
print(maxe)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
X1 = [0] * (N+2)
X2 = [0] * (N+2)
 
for i in range(N):
    X1[i+1] = gcd(X1[i], A[i])
for i in range(N,0,-1):
    X2[i] = gcd(X2[i+1], A[i-1])

k = []
for i in range(N):
    k.append(gcd(X1[i],X2[i+2]))

print(max(k))

Buggy python submission (verdict: Runtime Error):
def GCD(x, y): 
   if y > x:
      y,x = x,y
    while(y): 
       x, y = y, x % y 
  
   return x 
n = int(input())
l = list(map(int, input().strip().split()))
maxe = -1
     
for i in range(n):
    for j in range(n):
        if i != j:
            g = GCD(l[i],l[j])
            maxe = max(maxe, g)
print(maxe)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
X1 = [0] * (N+2)
X2 = [0] * (N+2)
 
for i in range(N):
    X1[i+1] = gcd(X1[i], A[i])
for i in range(N,0,-1):
    X2[i] = gcd(X2[i+1], A[i-1])

k = []
for i in range(N):
    k.append(gcd(X1[i],X2[i+2]))

print(max(k))

Buggy python submission (verdict: Runtime Error):
from math import gcd
n = int(input())
l = list(map(int, input().strip().split()))
maxe = -1
     
for i in range(n):
    for j in range(n):
        if i != j:
            g = gcd(l[i],l[j])
            maxe = max(maxe, g)
print(maxe)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
X1 = [0] * (N+2)
X2 = [0] * (N+2)
 
for i in range(N):
    X1[i+1] = gcd(X1[i], A[i])
for i in range(N,0,-1):
    X2[i] = gcd(X2[i+1], A[i-1])

k = []
for i in range(N):
    k.append(gcd(X1[i],X2[i+2]))

print(max(k))

Buggy python submission (verdict: Runtime Error):
from math import gcd
n = int(input())
l = list(map(int, input().strip().split()))
maxe = -1

for i in range(n):
  for j in range(n):
    g = gcd(l[i],l[j])
    maxe = max(maxe, g)
print(maxe)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
X1 = [0] * (N+2)
X2 = [0] * (N+2)
 
for i in range(N):
    X1[i+1] = gcd(X1[i], A[i])
for i in range(N,0,-1):
    X2[i] = gcd(X2[i+1], A[i-1])

k = []
for i in range(N):
    k.append(gcd(X1[i],X2[i+2]))

print(max(k))
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().strip().split()))
dp = [[0,0] for i in range(N+1)]
if L[0] >= 0:
    dp[0][1] = -L[0]
else:
    dp[0][1] = L[0]
for i in range(N):
    dp[i+1][0] = max(dp[i][0] + L[i], dp[i][1] - L[i])
    dp[i+1][1] = max(dp[i][1] + L[i], dp[i][0] - L[i])

print(min(dp[N][0]))

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue May 14 10:45:22 2019

@author: avina
"""

N = int(input())
L = list(map(int, input().strip().split()))
dp = [[0,0] for i in range(N+1)]
dp[0][1] = -1e7
for i in range(N):
    dp[i+1][0] = max(dp[i][0] + L[i], dp[i][1] - L[i])
    dp[i+1][1] = max(dp[i][1] + L[i], dp[i][0] - L[i])

print(dp[N][0])
Buggy python submission (verdict: Runtime Error):
a,b =map(int, input().strip().split())
if a == b:
  s = 2*b
else:
  e = max(a,b)
  s = 2*e - 1
print(e)
  


Fixed submission:
a,b =map(int, input().strip().split())
if a == b:
  s = 2*b
else:
  e = max(a,b)
  s = 2*e - 1
print(s)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 09:24:23 2019

@author: avina
"""

s = input().strip()

k = s[0]
cnt_1 = 0;cnt_2 = 1
for i in range(1,len(s)):
    if k == s[i] and i%2 !=0:
        cnt_1+=1
    
    if i%2 ==0 and k != s[i]:
        cnt_1+=1
        e =s[i]

for i in range(1,len(s)):
    
    if e != s[i] and i%2 ==0:
        cnt_2 +=1
    
    if e == s[i] and i%2 != 0:
        cnt_2+=1

print(min(cnt_1, cnt_2))

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 09:24:23 2019

@author: avina
"""

s = input().strip()

k = s[0]
cnt_1 = 0;cnt_2 = 1
for i in range(1,len(s)):
    if k == s[i] and i%2 !=0:
        cnt_1+=1
    
    if i%2 ==0 and k != s[i]:
        cnt_1+=1
if k == '1':
    e = '0'
else :
    e = '1'

for i in range(1,len(s)):
    
    if e != s[i] and i%2 ==0:
        cnt_2 +=1
    
    if e == s[i] and i%2 != 0:
        cnt_2+=1

print(min(cnt_1, cnt_2))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().strip().split())
s = input().strip()
d = {}
for i in range(n):
  for j in range(i,n):
    d[i+1,j+1] = s[i:j+1].count('AC')
    
for i in range(m):
  a,b = map(int, input().strip().split())
  print(d[a,b])

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 17:55:54 2019

@author: avina
"""

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
N, M, C = map(int , input().strip().split())
B = list(map(int , input().strip().split()))
l = [];cnt = 0
for i in range(m):
  g = list(map(int , input().strip().split()))
  l.append(g)

for i in range(m):
  sums = 0
  for j in range(n):
    sums += l[i][j]*B[j]
  if sums + C >:
    cnt+=1
print(cnt)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 18:16:09 2019

@author: avina
"""

N, M, C = map(int , input().strip().split())
B = list(map(int , input().strip().split()))
l = [];cnt = 0
for i in range(N):
  g = list(map(int , input().strip().split()))
  l.append(g)
for i in range(N):
  sums = 0
  for j in range(M):
    sums += l[i][j]*B[j]
  if sums + C > 0:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
min(A*N,B)

Fixed submission:
N,A,B = list(map(int, input().split(" ")))
print(min(A*N,B))
Buggy python submission (verdict: Runtime Error):
tasks=sorted(list(map(int,input().split()))

cost=0                                   
             
for i in range(1,len(tasks)):                      
    cost+=tasks[i]-tasks[i-1]
                                    
print(cost)

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

cost=0                                   
             
for i in range(1,len(tasks)):                      
    cost+=tasks[i]-tasks[i-1]
                                    
print(cost)
Buggy python submission (verdict: Runtime Error):
N=int(input())

red=[]
blue=[]

for i in range(N):
    a,b=map(int,input().split())
    red.append((a,b))

for i in range(N):
    c,d=map(int,input().split())
    blue.append((c,d))

red=sorted(red,key=lambda x:-x[1])
blue=sorted(blue,key=lambda x:x[0])

answer=0
for i,b in enumerate(blue):
    for j,r in enumerate(red):
        if red[0]<blue[0] and red[1]<blue[1]:
            answer+=1
            red.pop(j)
            break

print(answer)

Fixed submission:
N=int(input())

red=[]
blue=[]

for i in range(N):
    a,b=map(int,input().split())
    red.append((a,b))

for i in range(N):
    c,d=map(int,input().split())
    blue.append((c,d))

red=sorted(red,key=lambda x:-x[1])
blue=sorted(blue,key=lambda x:x[0])

answer=0
for i,b in enumerate(blue):
    for j,r in enumerate(red):
        if r[0]<b[0] and r[1]<b[1]:
            answer+=1
            red.pop(j)
            break

print(answer)

Buggy python submission (verdict: Runtime Error):
N=int(input())

red=[]
blue=[]

for i in range(N):
    a,b=map(int,input().split())
    red.append((a,b))

for i in range(N):
    c,d=map(int,input().split())
    blue.append((c,d))

red=sorted(red,key=lambda x:-x[1])
blue=sorted(blue,key=lambda x:x[0])

answer=0
for i,b in enumerate(b):
    for j,r in enumerate(r):
        if red[0]<blue[0] and red[1]<blue[1]:
            answer+=1
            red.pop(j)
            break

print(answer)

Fixed submission:
N=int(input())

red=[]
blue=[]

for i in range(N):
    a,b=map(int,input().split())
    red.append((a,b))

for i in range(N):
    c,d=map(int,input().split())
    blue.append((c,d))

red=sorted(red,key=lambda x:-x[1])
blue=sorted(blue,key=lambda x:x[0])

answer=0
for i,b in enumerate(blue):
    for j,r in enumerate(red):
        if r[0]<b[0] and r[1]<b[1]:
            answer+=1
            red.pop(j)
            break

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

A_max = max(A)
for i in range(n):
    if A[i] == A_max:
        print(max(A[0:i] + A[i+1:n]))
    else:
        print(A_max)


Fixed submission:
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

A_max = max(A)
A_max_2 = sorted(A)[-2]
for i in range(n):
    if A[i] == A_max:
        print(A_max_2)
    else:
        print(A_max)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
A = [int(i) * 2 for i in input().split()]

L1 = [[0] * n for _ in range(n)]
for i in range(n):
    if i + 1 <= n-1:
        L1[i][i] = 1
        L1[i][i+1] = 1
    else:
        L1[i][i] = 1
        L1[i][0] = 1
        
L1 = np.linalg.inv(L1)
L2 = np.array(A)
ans = list(np.dot(L1, L2))
print(" ".join([str(int(n)) for n in ans]))

Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]

x1 = sum(A)
for i in range(n):
    if i % 2 != 0:
        x1 -= 2 * A[i]
ans = [x1]
for i in range(n-1):
    tmp = 2 * A[i] - ans[i]
    ans.append(tmp)

print(" ".join([str(int(n)) for n in ans]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
A = [int(i) * 2 for i in input().split()]

L1 = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    if i + 1 <= n-1:
        L1[i][i] = 1
        L1[i][i+1] = 1
    else:
        L1[i][i] = 1
        L1[i][0] = 1
        
L1 = np.linalg.inv(L1) 
L2 = np.array(A)
ans = list(np.dot(L1, L2))
print(" ".join([str(int(n)) for n in ans]))

Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]

x1 = sum(A)
for i in range(n):
    if i % 2 != 0:
        x1 -= 2 * A[i]
ans = [x1]
for i in range(n-1):
    tmp = 2 * A[i] - ans[i]
    ans.append(tmp)

print(" ".join([str(int(n)) for n in ans]))
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
import math
ans = 0
for i in range(math.ceil(n / r)+1):
    for j in range(math.ceil(n / g)+1):
        if n - r * i - g * j < 0:
            break
        if  (n - r * i - g * j) % b == 0:
            ans += 1
print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())

import math
ans = 0
for i in range(math.ceil(n / r)+1):
    for j in range(math.ceil(n / g)+1):
        if n - r * i - g * j < 0:
            break
        if  (n - r * i - g * j) % b == 0:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())

ans = 0
for i in range(3001):
    for j in range(3001):
        if n - r * i - g * j < 0:
            break
        if  (n - r * i - g * j) % b == 0 and n - r * i - g * j >= 0:
            ans += 1
print(ans)

Fixed submission:
r, g, b, n = map(int, input().split())

import math
ans = 0
for i in range(math.ceil(n / r)+1):
    for j in range(math.ceil(n / g)+1):
        if n - r * i - g * j < 0:
            break
        if  (n - r * i - g * j) % b == 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())

S = str(input())

L = []
for i in range(Q):
    l,r = map(int, input().split())
    L.append((l-1,r-1))
    
    
check = []
for i in range(N-1):
    if S[i:i+2] == "AC":
        check.append(i)
        
for i in L:
    print(bisect_right(check, i[1]-1)-bisect_left(check, i[0]))

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

S = str(input())

L = []
for i in range(Q):
    l,r = map(int, input().split())
    L.append((l-1,r-1))
    
check = []
for i in range(N-1):
    if S[i:i+2] == "AC":
        check.append(i)
        
from bisect import bisect_left,bisect_right
for i in L:
    print(bisect_right(check, i[1]-1)-bisect_left(check, i[0]))
Buggy python submission (verdict: Runtime Error):
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 100 90 80\n"
     ]
    }
   ],
   "source": [
    "N,A,B,C = map(int, input().split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "98\n",
      "40\n",
      "30\n",
      "21\n",
      "80\n"
     ]
    }
   ],
   "source": [
    "l = []\n",
    "for i in range(n):\n",
    "    l.append(int(input()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "23\n"
     ]
    }
   ],
   "source": [
    "INF = 10 ** 9\n",
    "def dfs(cur, a, b, c):\n",
    "    if cur == n:\n",
    "        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a,b,c) > 0 else INF\n",
    "    ret0 = dfs(cur + 1, a, b, c)\n",
    "    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10\n",
    "    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10\n",
    "    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10\n",
    "    return min(ret0, ret1, ret2, ret3)\n",
    "\n",
    "print(dfs(0, 0, 0, 0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}


Fixed submission:
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

import itertools
m = 4
n = N
bit_list = list(itertools.product([i for i in range(m)], repeat=n))

res = 10 ** 18
for b in bit_list:
    tmp1 = 0
    tmp2 = 0
    tmp3 = 0
    check1 = False
    check2 = False
    check3 = False
    cost = 0
    for i in range(n):
        if b[i] == 1:
            tmp1 += L[i]
            if check1:
                cost += 10
            check1 = True       
            
        if b[i] == 2:
            tmp2 += L[i]
            if check2:
                cost += 10
            check2 = True
            
        if b[i] == 3:
            tmp3 += L[i]
            if check3:
                cost += 10
            check3 = True
    if min(tmp1, tmp2, tmp3) != 0:
        res = min(res, abs(tmp1 - A)+abs(tmp2 - B)+abs(tmp3 - C)+cost)
print(res)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
a = []
for i in range(n-2):
    a.append(h[i+k-1] - h[i])
print(min(a))

Fixed submission:
n, k = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
a = []
for i in range(n-k+1):
    a.append(h[i+k-1] - h[i])
print(min(a))

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

h = []
for i in range(n):
    h.append(int(input()))
h.sort()
ans = 1000000000000000000000000000
for i in range(n-2):
    a = h[i+k-1] - h[i] 
    ans = min(ans, a)
print(ans)

Fixed submission:
n, k = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
a = []
for i in range(n-k+1):
    a.append(h[i+k-1] - h[i])
print(min(a))