Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
if N % K == 0:
    print(0)

else:
    while True:
        delta = abs(N - K)
        if delta <N:
            N = delta

        else:
            print(N)
            break



Fixed submission:
N, K = map(int, input().split())
if N % K == 0:
    print(0)

else:
    num = N//K
    delta = abs(N-num*K)
    if delta > abs(delta-K):
        print(abs(delta-K))
    else:
        print(delta)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

while True:
    delta = abs(N - K)
    if delta <N:
        N = delta

    else:
        print(N)
        break



Fixed submission:
N, K = map(int, input().split())
if N % K == 0:
    print(0)

else:
    num = N//K
    delta = abs(N-num*K)
    if delta > abs(delta-K):
        print(abs(delta-K))
    else:
        print(delta)
Buggy python submission (verdict: Runtime Error):
S = list(input())
N = len(S)

mae = S[:(N-1)/2]
ushiro = S[(N+3)/2:]


for i in range(N):
    if S[i] == S[-(i+1)]:
        for j in range(len(mae)):
            if mae[j] != mae[-(j + 1)] or ushiro[j] != ushiro[-(j + 1)]:
                print("No")
                break


            else:
                print("Yes")
                break
        break




    else:
        print("No")
        break










Fixed submission:
s = input()

#全体として回文になっているか
if s != s[::-1]:
    print("No")
    exit()

mae = s[:len(s)//2]#前半部分
ushiro = s[(len(s)+1)//2:]#後半部分

#前部分が回文になっているか
if mae != mae[::-1]:
    print("No")
    exit()

#後ろ部分が回文になっているか
if ushiro != ushiro[::-1]:
    print("No")
    exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
X = list(map(int, input().split()))

Mini = min(X)
Max = max(X)

H_list = []
for i in range(Mini, Max):
    P_list = np.full(N,i)
    H = sum((P_list-np.array(X))**2)
    H_list.append(H)

print(min(H_list))

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

HP = []
for p in range(1, 101, 1):
    P = [p] * len(X)
    delta = sum([(i - j) ** 2 for (i, j) in zip(X, P)])
    HP.append(delta)

print(min(HP))
Buggy python submission (verdict: Runtime Error):
N, M = int(input())
if N == M:
  print("Yes")
else:
  print("No")

Fixed submission:
N, M = map(int,input().split())
if N == M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

import fractions

G = A[0]
for i in range(N):
    G = G * A[i] // fractions.gcd(G, A[i])

ans = 0
for j in range(N):
    ans += G / A[j]

print(ans % (10 ** 9 + 7))

Fixed submission:
from fractions import gcd
from functools import reduce
mod=10**9+7
n=int(input())
a=[int(i) for i in input().split()]
l=reduce(lambda x,y:x//gcd(x,y)*y,a)
ans=sum(map(lambda x:l//x,a))
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

import fractions

G = A[0]
for i in range(N):
    G = G * A[i] // fractions.gcd(G, A[i])

ans = 0
for j in range(N):
    ans += G / A[j]

print(int(ans % (10**9 +7)))

Fixed submission:
from fractions import gcd
from functools import reduce
mod=10**9+7
n=int(input())
a=[int(i) for i in input().split()]
l=reduce(lambda x,y:x//gcd(x,y)*y,a)
ans=sum(map(lambda x:l//x,a))
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

import math


gcd = A[0]
for i in range(N):
    gcd = gcd * A[i] // math.gcd(gcd, A[i])

ans = 0
for j in range(N):
    ans += gcd / A[j]

print(int(ans % (10**9 +7)))

Fixed submission:
from fractions import gcd
from functools import reduce
mod=10**9+7
n=int(input())
a=[int(i) for i in input().split()]
l=reduce(lambda x,y:x//gcd(x,y)*y,a)
ans=sum(map(lambda x:l//x,a))
print(ans%mod)

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

N = int(input())
A = [int(x) for x in input().split()]

gcd = A[0]
for i in range(N):
    gcd = gcd * A[i] // math.gcd(gcd, A[i])

ans = 0
for j in range(N):
    ans += gcd / A[j]

print(int(ans % (10**9 +7)))

Fixed submission:
from fractions import gcd
from functools import reduce
mod=10**9+7
n=int(input())
a=[int(i) for i in input().split()]
l=reduce(lambda x,y:x//gcd(x,y)*y,a)
ans=sum(map(lambda x:l//x,a))
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())

sP = {}
WA =0
AC =0
number_list =[]
for _ in range(M):
    data = input()
    number, result = data.split()
    if number not in number_list:
        number_list.append(number)

    if data not in sP:
        if number + " AC" not in sP:
            if result == "WA":
                sP[data] = 1
                WA += 1

            elif result == "AC":
                sP[data] = 1
                AC += 1
        else:
            pass
    else:
        sP[data] += 1
        if number + " AC" not in sP:
            if result == "WA":
                WA += 1

            elif result == "AC":
                AC += 1
        else:
            pass

for num in number_list:
    num_res = str(num) + " AC"
    if num_res not in sP:
        WA -= sP[str(num) + " WA"]


print(AC, WA)

Fixed submission:
n, m = map(int, input().split())
ACc = [0 for i in range(n)]
WAc = [0 for i in range(n)]

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if ACc[p - 1] == 0:
            ACc[p - 1] += 1
    else:
        if ACc[p - 1] != 1:
            WAc[p - 1] += 1
for j in range(n):
    if ACc[j] == 0:
        WAc[j] = 0

print(sum(ACc), sum(WAc))
Buggy python submission (verdict: Runtime Error):
import math
X = int(input())

half = int(X/2)
i = X
while i >=X:
    for j in range(2,int(i/2)):
        if math.gcd(i,j) == 1:
            pass

        else:
            i += 1
            continue

    print(i)
    exit()




Fixed submission:
import fractions
X = int(input())

half = int(X/2)
i = X
while i >=X:
    for j in range(2,int(i/2)):
        if fractions.gcd(i,j) == 1:
            pass

        else:
            i += 1
            continue

    print(i)
    exit()
Buggy python submission (verdict: Runtime Error):
date = input()
A ={"SUN":0, "SAT":6, "FRI":5, "TUE":4, "WED":3, "THU":2, "FRI":1}

print(7 - A[date])

Fixed submission:
s = input()
week = ["SAT","FRI","THU","WED","TUE","MON","SUN"]
days = week.index(s) + 1
print(days)

Buggy python submission (verdict: Runtime Error):
date = input()
dic ={"SUN":0, "SAT":6, "FRI":5, "TUE":4, "WED":3, "THU":2, "FRI":1}

print(7 - dic[date])

Fixed submission:
s = input()
week = ["SAT","FRI","THU","WED","TUE","MON","SUN"]
days = week.index(s) + 1
print(days)

Buggy python submission (verdict: Runtime Error):
dic ={"SUN":0, "SAT":6, "FRI":5, "TUE":4, "WED":3, "THU":2, "FRI":1}

print(7 - dic[input()])

Fixed submission:
s = input()
week = ["SAT","FRI","THU","WED","TUE","MON","SUN"]
days = week.index(s) + 1
print(days)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))

HP = []
for p in range(1, 101, 1):
    P = [p] * len(X)
    delta = sum([(i - j) ** 2 for (i, j) in zip(X, P)])
    HP.append(delta)

print(min(HP))


Fixed submission:
N, A, B = map(int, input().split())
S = str(input())

AB = A + B

count_all = 0
count_abroad = 0
for i in range(N):
    if S[i] == "a" and count_all < AB:
        count_all += 1
        print("Yes")

    elif S[i] == "b" and count_abroad < B and count_all <AB:
        count_all += 1
        count_abroad += 1
        print("Yes")

    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
str = input()
  if str=='ABC':
    print('ARC')
  else:
    print('ABC)

Fixed submission:
str = input()
if str=='ABC':
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Runtime Error):
x = int(input())

moto = 100

for i in range(100000):
    moto = int(moto*1.01)
    if moto >= x:
        ans = i+1
        break
print(ans])


Fixed submission:
x = int(input())

moto = 100

for i in range(100000):
    moto = int(moto*1.01)
    if moto >= x:
        ans = i+1
        break
print(ans)

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

moto = 100

for i in range(100000):
    moto = int(moto*1.01)
    if moto >= x:
        ans = i+1
        break
print(ans])


Fixed submission:
x = int(input())

moto = 100

for i in range(100000):
    moto = int(moto*1.01)
    if moto >= x:
        ans = i+1
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a = [int(i) for i in input().split()]
mod = 10**9+7
ans = 3

red=1
gre=0
blu=0
for i in range(1,n):
    temp=0
    if a[i] == red:
        temp+=1
    if a[i] == gre:
        temp+=1        
    if a[i] == blu:
        temp+=1
    ans*=temp
    ans=ans%mod
    if a[i]==red:
        red+=1
        continue
    if a[i]==gre:
        gre+=1
        continue
    if a[i]==blu:
        blu+=1
        continue
    print(asdf)
    
print(ans)

Fixed submission:
n=int(input())
a = [int(i) for i in input().split()]
mod = 10**9+7
ans = 3

red=1
gre=0
blu=0
for i in range(1,n):
    temp=0
    if a[i] == red:
        temp+=1
    if a[i] == gre:
        temp+=1        
    if a[i] == blu:
        temp+=1
    if temp!=0:
        ans*=temp
    
        ans=ans%mod
    if a[i]==red:
        red+=1
        continue
    if a[i]==gre:
        gre+=1
        continue
    if a[i]==blu:
        blu+=1
        continue
    else:
      ans=0
    
if a[0]!=0:
  ans=0
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lr=[[int(i) for i in input().split()] for j in range(n)]
lr=sorted(lr)
li_test=[]

for x,y in lr:
    li_test.append(y)

li=[li_test[0]]
for i in range(1,n):
    a=min(li_test[:i+1])
    li.append(a)

li_test=li_test[::-1]
li2=[li_test[0]]
for i in range(1,n):
    a=min(li_test[:i+1])
    li2.append(a)
li2=li2[::-1]
    
ans=0
maxi=lr[-1][0]
for i in range(n-1):
    one = max(0,li[i]-lr[i][0]+1)
    two = max(0,li2[i+1]-maxi+1)
    ans=max(ans,one+two)
print(ans)
    
    

Fixed submission:
n=int(input())
lr=[[int(i) for i in input().split()] for j in range(n)]
lr=sorted(lr)
li_test=[]

for x,y in lr:
    li_test.append(y)

li=[li_test[0]]
a=li_test[0]
for i in range(1,n):
    a=min(li_test[i],a)
    li.append(a)

li_test=li_test[::-1]
li2=[li_test[0]]
a=li_test[0]
for i in range(1,n):
    a=min(li_test[i],a)
    li2.append(a)
li2=li2[::-1]
    
ans=0


maxi=lr[-1][0]
for i in range(n-1):
    one = max(0,li[i]-lr[i][0]+1)
    two = max(0,li2[i+1]-maxi+1)
    tokubetu=lr[i][1]-lr[i][0]+1
    tokubetu2=max(0,li2[0]-maxi+1)
    check=max(one+two,tokubetu+tokubetu2)
    ans=max(ans,check)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
n=int(input())
li=[int(i) for i in input().split()]

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            a=li[i]
            b=li[j]
            c=li[k]
            if a<b+c and b<a+c and c<a+b:
                ans+=1
                  
print(ans)
        


Fixed submission:
import bisect
n=int(input())
li=[int(i) for i in input().split()]
li.sort()

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        a=li[i]
        b=li[j]
        c=bisect.bisect_left(li,a+b)
        ans+=c-j-1
                  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
n=int(input())
l=[int(i) for i in input().split()]

ans=0
for i,j,k in permutations(l,3):
    if i<j+k and j<i+k and k<i+j:
        ans+=1
print(ans//6)
        


Fixed submission:
import bisect
n=int(input())
li=[int(i) for i in input().split()]
li.sort()

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        a=li[i]
        b=li[j]
        c=bisect.bisect_left(li,a+b)
        ans+=c-j-1
                  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,m=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort(reverse=True)

for i in range(m):
    a[0]=a[0]//2
    a.sort(reverse=True)
print(sum(a))

Fixed submission:
import numpy as np
import bisect
import heapq

n,m=map(int,input().split())
a=np.array([int(i) for i in input().split()])
a=a*(-1)
a.sort()
a=list(a)

for i in range(m):
    check=-(-heapq.heappop(a)//2)
    heapq.heappush(a,check)
print(sum(a)*(-1))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        if sorted(s[i])==sorted(s[j]):
            ans+=1
print(ans)

Fixed submission:
n=int(input())
s = [input() for _ in range(n)]

dic={}

for i in  s:
    i = sorted(i)
    i = ''.join(i)
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1

ans =0
for i in dic.values():
    if i==1:
        continue
    else:
        ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        if sorted(s[i])==sorted(s[j]):
            ans+=1
print(ans)

Fixed submission:
n=int(input())
s = [input() for _ in range(n)]

dic={}

for i in  s:
    i = sorted(i)
    i = ''.join(i)
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1

ans =0
for i in dic.values():
    if i==1:
        continue
    else:
        ans+=i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import heapq
n,m=map(int,input().split())
dic=defaultdict(list)
for i in range(n):
    a,b=map(int,input().split())
    dic[a]+=(-b)
    
li=[]
ans=0

for i in range(1,m+1):
    if dic[i]:
        for j in dic[i]:
            heapq.heappush(li,j)
    if li:
        ans+=heapq.heappop(li)
print(-ans)

Fixed submission:
from collections import defaultdict
import heapq
n,m=map(int,input().split())
dic=defaultdict(list)
for i in range(n):
    a,b=map(int,input().split())
    dic[a].append(-b)
    
li=[]
ans=0

for i in range(1,m+1):
    if dic[i]:
        for j in dic[i]:
            heapq.heappush(li,j)
    if li:
        ans+=heapq.heappop(li)
print(-ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1):
    if h[i] - h[i+1] >= 2:
        ans = 'No'
        break
    elif h[i] - h[i+1] == 1:
        h[i] -= 1
        continue
    else:
        ans = 'Yes'
print(ans)

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

ans='Yes'
for i in range(n-1):
    if h[i+1]-h[i] >=2:
        ans = 'No'
        break
    elif h[i+1]-h[i] ==1:
        h[i+1]-=1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
ll=l%2019
rr=r%2019

ans=float('inf')
for i in range(ll,rr):
    for j in range(i+1,rr+1):
        ans=min(ans,i*j%2019)
print(ans)

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
ma=max(a)
aa=sorted(a,reverse=True)
for i in a:
    if i !=ma:
        print(ma)
    else:
        print(aa[1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
ma=max(a)
aa=sorted(a,reverse=True)
for i in a:
    if i !=ma:
        print(a[i])
    else:
        print(aa[1])

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
ma=max(a)
aa=sorted(a,reverse=True)
for i in a:
    if i !=ma:
        print(ma)
    else:
        print(aa[1])
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())

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

Fixed submission:
l,r=map(int,input().split())

ans=2020
if r-l>=2019:
    ans=0
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = min(ans,i*j%2019)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())

f1=math.gcd(c,d)
f2=c*d//f1

a=a-1
aa=a-a//c-a//d+a//f2
bb=b-b//c-b//d+b//f2

print(bb-aa)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())

f1=fractions.gcd(c,d)
f2=c*d//f1

a=a-1
aa=a-a//c-a//d+a//f2
bb=b-b//c-b//d+b//f2

print(bb-aa)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

a,b,c,d=map(int,input().split())

f=fractions.gcd(c,d)
f2=c*d//f


ans = (f2-(f2//c+f2//d-1))*(b//f2)

for i in range(1,b%f2+1):
    if i%c!=0 and i%d!=0:
        ans+=1

ans -= (f2-(f2//c+f2//d-1))*(a//f2)
for i in range(a%f2):
    if i%c!=0 and i%d!=0:
        ans-=1
print(ans)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())

f1=fractions.gcd(c,d)
f2=c*d//f1

a=a-1
aa=a-a//c-a//d+a//f2
bb=b-b//c-b//d+b//f2

print(bb-aa)
Buggy python submission (verdict: Runtime Error):
x, a = map(int, input())
if x < a:
    print(0)
else:
    print(10)

Fixed submission:
x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())

elif w/2==x and h/2==y:
    ans=1

else:
    ans=0


print(w*h/2,ans)

Fixed submission:
w,h,x,y=map(int,input().split())

if w/2==x and h/2==y:
    ans=1

else:
    ans=0


print(w*h/2,ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = list(map(int, input().split()))

mini = foat('inf')

for i in range(n):
    s1 = sum(w[0:i+1])
    s2 = sum(w[i+1:n])
    
    mini = min(abs(s2-s1),mini)
        
print(mini)

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

mini = float('inf')

for i in range(n):
    s1 = sum(w[0:i+1])
    s2 = sum(w[i+1:n])
    
    mini = min(abs(s2-s1),mini)
        
print(mini)

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

s = sum(w)
ans = 0
for i in range(n):
    ans += w[i]
    if ans > s / 2:
        j = i
        break

aa = abs(sum[:j] - sum[j:])
bb = abs(sum[:j+1] - sum[j+1:])

print(min(aa, bb))

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

mini = float('inf')

for i in range(n):
    s1 = sum(w[0:i+1])
    s2 = sum(w[i+1:n])
    
    mini = min(abs(s2-s1),mini)
        
print(mini)

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

s = sum(w)
ans = 0
for i in range(n):
    ans += w[i]
    if ans > s / 2:
        j = i
        break

aa = abs(sum[:j] - sum[j:])
bb = abs(sum[:j+1] - sum[j+1:])

print(min(aa, bb))

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

mini = float('inf')

for i in range(n):
    s1 = sum(w[0:i+1])
    s2 = sum(w[i+1:n])
    
    mini = min(abs(s2-s1),mini)
        
print(mini)
Buggy python submission (verdict: Runtime Error):
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])

if a = 0 or b = 0:
    print('NA')
elif a>=13 and b >=13:
    print('NA')
elif a >= 13:
    print('YYMM')
elif b >= 13:
    print('MMYY')
else:
    print('AMBIGUOUS')

Fixed submission:
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])

if  1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1<= b <= 12:
    print('YYMM')
elif 1<= a <= 12:
    print('MMYY')
else:
    print('NA')
Buggy python submission (verdict: Runtime Error):
n=int(input())
edge=[[]for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    if c%2==0:
        edge[a].append((b,1))
        edge[b].append((a,1))
    else:
        edge[a].append((b,-1))
        edge[b].append((a,-1))
        

ans=[None]*(n+1)
check=[None]*(n+1)
check[1]=1


for i in range(1,n+1):
    for j in edge[i]:
        if ans[j[0]] is None:
            ans[j[0]]=check[i]*j[1]
            check[j[0]]=check[i]*j[1]
            
for i in ans[1:]:
    print((i+1)//2)
    

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n=int(input())

edge=[[] for _ in range(n+1)]

for i in range(n-1):
    v1,v2,w=map(int,input().split())
    if w%2!=0:
        edge[v1].append((v2,-1))
        edge[v2].append((v1,-1))
    else:
        edge[v1].append((v2,1))
        edge[v2].append((v1,1))

color=[None]*(n+1)        
def set_color(x,col):
    color[x]=col
    
    for i,j in edge[x]:
        if color[i] is None:
            set_color(i,j*col)
set_color(1,1)

for x in color[1:]:
    print((x+1)//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

mi=min(a,b,c,d,e)
if n%mi != 0
    print((n//mi)+1+4)
else:
    print((n//mi)+4)

Fixed submission:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

mi=min(a,b,c,d,e)
if n%mi != 0:
    print((n//mi)+1+4)
else:
    print((n//mi)+4)
Buggy python submission (verdict: Runtime Error):
import heapq
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

li=[]
push=heapq.heappush
pop=heapq.heappop

push(li,(-a[0]-b[0]-c[0],0,0,0))
ans=[]
used=set()

for _ in range(k):
    value,i,j,l=pop(li)
    ans.append(-value)
    if i<x-1 and (i+1,j,l) not in used:
        push(li,(-a[i+1]-b[j]-c[l],i+1,j,l))
        used.add((i+1,j,l))
    if j<y-1 and (i,j+1,l) not in used:
        push(li,(-a[i]-b[j+1]-c[l],i,j+1,l))
        used.add((i,j+1,l))
    if k<z-1 and (i,j,l+1) not in used:
        push(li,(-a[i]-b[j]-c[l+1],i,j,l+1))
        used.add((i,j,l+1))
for i in ans:
    print(i)

Fixed submission:
import heapq
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

li=[]
push=heapq.heappush
pop=heapq.heappop

push(li,(-a[0]-b[0]-c[0],0,0,0))
ans=[]
used=set()

for _ in range(k):
    value,i,j,l=pop(li)
    ans.append(-value)
    if i<x-1 and (i+1,j,l) not in used:
        push(li,(-a[i+1]-b[j]-c[l],i+1,j,l))
        used.add((i+1,j,l))
    if j<y-1 and (i,j+1,l) not in used:
        push(li,(-a[i]-b[j+1]-c[l],i,j+1,l))
        used.add((i,j+1,l))
    if l<z-1 and (i,j,l+1) not in used:
        push(li,(-a[i]-b[j]-c[l+1],i,j,l+1))
        used.add((i,j,l+1))
for i in ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
import heapq
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

li=[]
push=heapq.heappush
pop=heapq.heappop

push(li,(-a[0]-b[0]-c[0],0,0,0))
ans=[]
used=set()

for _ in range(k):
    value,i,j,l=pop(li)
    ans.append(-value)
    if i<x-1 and (i+1,j,l) not in used:
        push(li,(-a[i+1]-b[j]-c[l],i+i,j,l))
        used.add((i+1,j,l))
    if j<y-1 and (i,j+1,l) not in used:
        push(li,(-a[i]-b[j+1]-c[l],i,j+1,l))
        used.add((i,j+1,l))
    if k<z-1 and (i,j,l+1) not in used:
        push(li,(-a[i]-b[j]-c[l+1],i,j,l+1))
        used.add((i,j,l+1))
for i in ans:
    print(i)

Fixed submission:
import heapq
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

li=[]
push=heapq.heappush
pop=heapq.heappop

push(li,(-a[0]-b[0]-c[0],0,0,0))
ans=[]
used=set()

for _ in range(k):
    value,i,j,l=pop(li)
    ans.append(-value)
    if i<x-1 and (i+1,j,l) not in used:
        push(li,(-a[i+1]-b[j]-c[l],i+1,j,l))
        used.add((i+1,j,l))
    if j<y-1 and (i,j+1,l) not in used:
        push(li,(-a[i]-b[j+1]-c[l],i,j+1,l))
        used.add((i,j+1,l))
    if l<z-1 and (i,j,l+1) not in used:
        push(li,(-a[i]-b[j]-c[l+1],i,j,l+1))
        used.add((i,j,l+1))
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
b = input()
if b = 'A':
    print('T')
elif b = 'C':
    print('G')
elif b = 'G':
    print('C')
else:
    print('A')

Fixed submission:
b=input()
print('T' if b=='A' else 'A' if b=='T' else 'G' if b=='C' else 'C')