Buggy python submission (verdict: Runtime Error):
import heapq
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())))[::-1]
B=sorted(list(map(int,input().split())))[::-1]
C=sorted(list(map(int,input().split())))[::-1]

default=A[0]+B[0]+C[0]
A=[A[0]-A[i] for i in range(len(A))]
B=[B[0]-B[i] for i in range(len(B))]
C=[C[0]-C[i] for i in range(len(C))]

print(default)
hp=[]
visited=set()
visited.add((0,0,0))
a,b,c=0,0,0
for _ in range(K-1):
  if (a+1,b,c) not in visited and a+1<len(A):
    heapq.heappush(hp,(A[a+1]+B[b]+C[c],(a+1,b,c)))
    visited.add((a+1,b,c))
  if (a,b+1,c) not in visited and b+1<len(B):
    heapq.heappush(hp,(A[a]+B[b+1]+C[c],(a,b+1,c)))
    visited.add((a,b+1,c))
  if (a,b,c+1) not in visited and c+1<len(C):
    heapq.heappush(hp,(A[a]+B[b]+C[c+1],(a,b,c+1)))
    visited.add((a,b,c+1))
  temp=heapq.heappop(hp)
  print(default-temp[1])
  a,b,c=temp[2]

Fixed submission:
import sys

d = [int(i) for i in sys.stdin.read().split('\n') if i != '']
k = d[5]
d = d[:5][::-1]


def check(k, d):
    for i in range(len(d[:4])):
        for j in range(i, len(d)):
            if d[i] - d[j] > k:
                return False
    return True


if check(k, d):
    print('Yay!')
else:
    print(':(')

Buggy python submission (verdict: Runtime Error):
import sys
a=[int(i) for i in sys.stdin.resd().split('\n')]
k=a[5]
a=a[:5][::-1]
def check(a,k):
  for i in range(len(a[:4])):
    for j in range(i,len(a)):
      if a[i]-a[j]>k:
        return False
  return True
if check(a,k):
  print('Yay!')
else:
  print(':(')

Fixed submission:
import sys

d = [int(i) for i in sys.stdin.read().split('\n') if i != '']
k = d[5]
d = d[:5][::-1]


def check(k, d):
    for i in range(len(d[:4])):
        for j in range(i, len(d)):
            if d[i] - d[j] > k:
                return False
    return True


if check(k, d):
    print('Yay!')
else:
    print(':(')

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

xlist = sorted(list(map(int,input().split())), reverse=True)[:min(x, k)]
ylist = sorted(list(map(int,input().split())), reverse=True)[:min(y, k)]
zlist = sorted(list(map(int,input().split())), reverse=True)[:min(z, k)]


anslist = [0]
for i in range(min(x, k)):
    for j in range(min(y, k)):
        for l in range(min(z, k)):
            if (i+1)*(j+1)*(l+1) <= k:
                anslist.append(xlist[i] + ylist[j] + zlist[l])
            else:
                break

anslist = sorted(anslist, reverse=True)
for i in range(k):
    print(anslist[i])


Fixed submission:
import sys

d = [int(i) for i in sys.stdin.read().split('\n') if i != '']
k = d[5]
d = d[:5][::-1]


def check(k, d):
    for i in range(len(d[:4])):
        for j in range(i, len(d)):
            if d[i] - d[j] > k:
                return False
    return True


if check(k, d):
    print('Yay!')
else:
    print(':(')

Buggy python submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
cake1=sort(list(map(int,input().split()),reverse=True))[:max(a,k)]
cake2=sort(list(map(int,input().split()),reverse=True))[:max(b,k)]
cake3=sort(list(map(int,input().split()),reverse=True))[:max(c,k)]
res=[]
for i in range(min(a,k)):
  for j in range(min(b,k)):
    for l in range(min(c,k)):
      if (a+1)*(b+1)*(c+1)<k:
        res.append(cake1[i]+cake2[j]+cake3[l])
res.sort(reverse=True)
for i in range(k):
  print(res[i])


Fixed submission:
import sys

d = [int(i) for i in sys.stdin.read().split('\n') if i != '']
k = d[5]
d = d[:5][::-1]


def check(k, d):
    for i in range(len(d[:4])):
        for j in range(i, len(d)):
            if d[i] - d[j] > k:
                return False
    return True


if check(k, d):
    print('Yay!')
else:
    print(':(')

Buggy python submission (verdict: Runtime Error):
a=[]
for i in range(6):
  a.append(int(input()))
k=a[-1]
if a[-2]-a[0]<=k:
  pring('Yay!')
else:
  print(':(')  

Fixed submission:
import sys

d = [int(i) for i in sys.stdin.read().split('\n') if i != '']
k = d[5]
d = d[:5][::-1]


def check(k, d):
    for i in range(len(d[:4])):
        for j in range(i, len(d)):
            if d[i] - d[j] > k:
                return False
    return True


if check(k, d):
    print('Yay!')
else:
    print(':(')