Buggy python submission (verdict: Runtime Error):
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))

ab=[]
for i in range(_x):
  for j in range(_y):
    ab.append(aa[i]+bb[j])

ab.sort()
hq=[]
for z in range(_z):
  for l in range(_x*_y):
    temp = cc[z] + ab[l] 
    if len(hq) < k:
      heapq.heappush(hq,temp)
    else:
      heapq.heapreplace[hq,temp]
hq.sort()
for i in range(k):
  print(hq[k-1-i])

Fixed submission:
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))
 
ar = []
history = set()
 
 
def push(x, y, z):
    if (x, y, z) in history:
        pass
    else:
        v = aa[x] + bb[y] + cc[z]
        heapq.heappush(ar, (-v, x, y, z))
        history.add((x, y, z))
 
 
def pop():
    (v, x, y, z) = heapq.heappop(ar)
    return (-v, x, y, z)
 
 
push(0, 0, 0)
for _ in range(k):
    (total, x, y, z) = pop()
    print(total)
    if x + 1 < len(aa):
        push(x + 1, y, z)
    if y + 1 < len(bb):
        push(x, y + 1, z)
    if z + 1 < len(cc):
        push(x, y, z + 1)

Buggy python submission (verdict: Runtime Error):
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))

ab=[]
for i in range(_x):
  for j in range(_y):
    ab.append(aa[i]+bb[j])

ab.sort()
hq=[]
for z in range(_z):
  for l in range(_x*_y):
    temp = cc[z] + ab[l] 
    if len(hq) < k:
      heapq.heappush(hq,temp)
    else:
      heapq.heapreplace[hq,temp]
for i in range(k):
  print(hq[k-1-i])

Fixed submission:
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))
 
ar = []
history = set()
 
 
def push(x, y, z):
    if (x, y, z) in history:
        pass
    else:
        v = aa[x] + bb[y] + cc[z]
        heapq.heappush(ar, (-v, x, y, z))
        history.add((x, y, z))
 
 
def pop():
    (v, x, y, z) = heapq.heappop(ar)
    return (-v, x, y, z)
 
 
push(0, 0, 0)
for _ in range(k):
    (total, x, y, z) = pop()
    print(total)
    if x + 1 < len(aa):
        push(x + 1, y, z)
    if y + 1 < len(bb):
        push(x, y + 1, z)
    if z + 1 < len(cc):
        push(x, y, z + 1)

Buggy python submission (verdict: Runtime Error):
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))

ab=[]
for i in range(_x):
  for j in range(_y):
    ab.append(aa[i]+bb[j])

ab.sort()
hq=[]
for z in range(_z):
  for l in range(_x*_y):
    temp = cc[z] + ab[l] 
    if len(hq) < k:
      heapq.heappush(hq,temp)
    else:
      heapq.heapreplace[hq,temp]
for i in range(k):
  print(hq[k-i])

Fixed submission:
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))
 
ar = []
history = set()
 
 
def push(x, y, z):
    if (x, y, z) in history:
        pass
    else:
        v = aa[x] + bb[y] + cc[z]
        heapq.heappush(ar, (-v, x, y, z))
        history.add((x, y, z))
 
 
def pop():
    (v, x, y, z) = heapq.heappop(ar)
    return (-v, x, y, z)
 
 
push(0, 0, 0)
for _ in range(k):
    (total, x, y, z) = pop()
    print(total)
    if x + 1 < len(aa):
        push(x + 1, y, z)
    if y + 1 < len(bb):
        push(x, y + 1, z)
    if z + 1 < len(cc):
        push(x, y, z + 1)

Buggy python submission (verdict: Runtime Error):
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))

ab=[]
for i in range(_x):
  for j in range(_y):
    ab.append(aa[i]+bb[j])

ab.sort()
hq=[]
for z in range(_z):
  for l in range(_x*_y):
    temp = cc[z] + ab[l] 
    if hq.size() < k:
      heapq.push(hq,temp)
    else:
      heapq.heapreplace[hq,temp]
for i in range(k):
  print(hq[k-i])

Fixed submission:
import heapq
 
_x, _y, _z, k = map(int, input().split())
aa = list(reversed(sorted(map(int, input().split()))))
bb = list(reversed(sorted(map(int, input().split()))))
cc = list(reversed(sorted(map(int, input().split()))))
 
ar = []
history = set()
 
 
def push(x, y, z):
    if (x, y, z) in history:
        pass
    else:
        v = aa[x] + bb[y] + cc[z]
        heapq.heappush(ar, (-v, x, y, z))
        history.add((x, y, z))
 
 
def pop():
    (v, x, y, z) = heapq.heappop(ar)
    return (-v, x, y, z)
 
 
push(0, 0, 0)
for _ in range(k):
    (total, x, y, z) = pop()
    print(total)
    if x + 1 < len(aa):
        push(x + 1, y, z)
    if y + 1 < len(bb):
        push(x, y + 1, z)
    if z + 1 < len(cc):
        push(x, y, z + 1)