Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

AB = []

for i in range(0, min(K,lenA)):
  for j in range(0, min(K,lenB)):
      AB.append(A[i]+B[j])
AB.sort(reverse=True)

ABC = []

for j in range(0, min(K,len(AB))):
  for k in range(0, min(K,lenC)):
      ABC.append(AB[j]+C[k])
ABC.sort(reverse=True)

for i in range(K):
  print(ABC[i])


Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

AB = []

for i in range(0, min(K,lenA)):
  for j in range(0, min(K,lenB)):
      AB.append(A[i]+B[j])
AB.sort(reverse=True)

ABC = []

for j in range(0, min(K,len(AB))):
  for k in range(0, min(K,lenC)):
      ABC.append(AB[j]+C[k])
ABC.sort(reverse=True)

for i in range(K):
  print(ABC[i])

Buggy python submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

#差分の配列を作る
difA = []
difB = []
difC = []
for i, a in enumerate(A):
  if i == 0:
    preA = a
    continue #0ならpreAに入れるだけ
  difA.append(preA - a)
  preA = a
for i, b in enumerate(B):
  if i == 0:
    preB = b
    continue #0ならpreBに入れるだけ
  difB.append(preB - b)
  preB = b
for i, c in enumerate(C):
  if i == 0:
    preC = c
    continue #0ならpreCに入れるだけ
  difC.append(preC - c)
  preC = c
#print(difA,difB,difC) #デバッグ用

cntA, cntB, cntC = sum(difA), sum(difB), sum(difC)
cntA, cntB, cntC = (1500*cntA)//(cntA+cntB+cntC),(1500*cntB)//(cntA+cntB+cntC),(1500*cntC)//(cntA+cntB+cntC)

setc = []
for i in range(0, min(cntA,lenA)):
  for j in range(0, min(cntB,lenB)):
    for k in range(0, min(cntC,lenC)):
      setc.append(A[i]+B[j]+C[k])
slist = sorted(setc,reverse=True)

for i in range(K):
  print(slist[i])

Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

AB = []

for i in range(0, min(K,lenA)):
  for j in range(0, min(K,lenB)):
      AB.append(A[i]+B[j])
AB.sort(reverse=True)

ABC = []

for j in range(0, min(K,len(AB))):
  for k in range(0, min(K,lenC)):
      ABC.append(AB[j]+C[k])
ABC.sort(reverse=True)

for i in range(K):
  print(ABC[i])

Buggy python submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

#差分の配列を作る
difA = []
difB = []
difC = []
for i, a in enumerate(A):
  if i == 0:
    preA = a
    continue #0ならpreAに入れるだけ
  difA.append(preA - a)
  preA = a
for i, b in enumerate(B):
  if i == 0:
    preB = b
    continue #0ならpreBに入れるだけ
  difB.append(preB - b)
  preB = b
for i, c in enumerate(C):
  if i == 0:
    preC = c
    continue #0ならpreCに入れるだけ
  difC.append(preC - c)
  preC = c
#print(difA,difB,difC) #デバッグ用

nowsum = A[0]+B[0]+C[0]
print(nowsum)
del A[0]
del B[0]
del C[0]
#ここにi番目の美味しさ合計を入れていく
#初期値は一番美味しいケーキ3種の合計
for i in range(K-1): #[1]~[K-1]についてやればいい
  #delしていくから添字は気にしなくてもいい
  if difA[0] <= min(difB[0], difC[0]):
    nowsum -= difA[0]
    del difA[0]
    del A[0]
    if not difA: difA.append(10e9)
  elif difB[0] <= difC[0]:
    nowsum -= difB[0]
    del difB[0]
    del B[0]
    if not difB: difB.append(10e9)
  else:
    nowsum -= difC[0]
    del difC[0]
    del C[0]
    if not difC: difC.append(10e9)
  print(nowsum)
  

Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

AB = []

for i in range(0, min(K,lenA)):
  for j in range(0, min(K,lenB)):
      AB.append(A[i]+B[j])
AB.sort(reverse=True)

ABC = []

for j in range(0, min(K,len(AB))):
  for k in range(0, min(K,lenC)):
      ABC.append(AB[j]+C[k])
ABC.sort(reverse=True)

for i in range(K):
  print(ABC[i])