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

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (A[0]+B[0]+C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (A[i+1]+B[j]+C[k],i,j,k))
		used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (A[i]+B[j+1]+C[k],i,j+1,k))
		used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (A[i]+B[j]+C[k+1],i,j,k+1))
		used.add((i,j,k+1))
        
for v in result:
    print(v)

Fixed submission:
import heapq

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (-A[0]-B[0]-C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(-value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k],i+1,j,k))
        used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k],i,j+1,k))
        used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1],i,j,k+1))
        used.add((i,j,k+1))
        
for v in result:
    print(v)

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

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (A[0]+B[0]+C[0], 0,0,0))

result = []

for _ in range(K):
	value, i,j,k = heapq.heappop(h)
    result.append(value)
    if i < X-1:
    	heapq.heappush(h, (A[i+1]+B[j]+C[k],i,j,k))
    if j < Y-1 and i == 0:
      	heapq.heappush(h, (A[i]+B[j+1]+C[k],i,j+1,k))
    if k < Z-1 and i == 0 and j == 0:
      	heapq.heappush(h, (A[i]+B[j]+C[k+1],i,j,k+1))
        
for v in result:
	print(v)

Fixed submission:
import heapq

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (-A[0]-B[0]-C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(-value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k],i+1,j,k))
        used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k],i,j+1,k))
        used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1],i,j,k+1))
        used.add((i,j,k+1))
        
for v in result:
    print(v)

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

X,Y,Z,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (A[0]+B[0]+C[0], 0,0,0))

result = []

for _ in range(K):
	value, i,j,k = heapq.heappop(h)
    result.append(value)
    if i < X-1:
    	heapq.heappush(h, (A[i+1]+B[j]+C[k],i,j,k))
    if j < Y-1 and i == 0:
      	heapq.heappush(h, (A[i]+B[j+1]+C[k],i,j+1,k))
    if k < Z-1 and i == 0 and j == 0:
      	heapq.heappush(h, (A[i]+B[j]+C[k+1],i,j,k+1))
        
for v in result:
	print(v)

Fixed submission:
import heapq

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (-A[0]-B[0]-C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(-value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k],i+1,j,k))
        used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k],i,j+1,k))
        used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1],i,j,k+1))
        used.add((i,j,k+1))
        
for v in result:
    print(v)

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

X,Y,Z,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (A[0]+B[0]+C[0], 0,0,0))

result = []

for _ in range(K):
	value, i,j,k = h.heappop()
    result.append(value)
    if i < X-1:
    	heapq.heappush(h, (A[i+1]+B[j]+C[k],i,j,k))
    if j < Y-1 and i == 0:
      	heapq.heappush(h, (A[i]+B[j+1]+C[k],i,j+1,k))
    if k < Z-1 and i == 0 and j == 0:
      	heapq.heappush(h, (A[i]+B[j]+C[k+1],i,j,k+1))
        
for v in result:
	print(v)

Fixed submission:
import heapq

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (-A[0]-B[0]-C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(-value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k],i+1,j,k))
        used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k],i,j+1,k))
        used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1],i,j,k+1))
        used.add((i,j,k+1))
        
for v in result:
    print(v)

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

X,Y,Z,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

h.heappush((A[0]+B[0]+C[0], 0,0,0))

result = []

for _ in range(K):
	value, i,j,k = h.heappop()
    result.append(value)
    if i < X-1:
    	h.heappush((A[i+1]+B[j]+C[k],i,j,k))
    if j < Y-1 and i == 0:
      	h.heappush((A[i]+B[j+1]+C[k],i,j+1,k))
    if k < Z-1 and i == 0 and j == 0:
      	h.heappush((A[i]+B[j]+C[k+1],i,j,k+1))
        
for v in result:
	print(v)

Fixed submission:
import heapq

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (-A[0]-B[0]-C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(-value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k],i+1,j,k))
        used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k],i,j+1,k))
        used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1],i,j,k+1))
        used.add((i,j,k+1))
        
for v in result:
    print(v)

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

X,Y,Z,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())


AB = [x+y for x,y in itertools.product(A,B)]
AB.sort(reverse = True)
AB = AB[:3000]

ABC = [x+y for x,y in itertools.product(AB,C)]
ABC.sort(reverse=True)

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

Fixed submission:
import heapq

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (-A[0]-B[0]-C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(-value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k],i+1,j,k))
        used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k],i,j+1,k))
        used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1],i,j,k+1))
        used.add((i,j,k+1))
        
for v in result:
    print(v)

Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())


AB = [x+y for x,y in itertools.product(A,B)]
AB.sort(reverse = True)
AB = AB[:3000]

ABC = [x+y for x,y in itertools.product(AB,C)]
ABC.sort(reverse=True)

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

Fixed submission:
import heapq

X,Y,Z,K = map(int, input().split())
A = [int(x) for x in  input().split()]
B = [int(x) for x in  input().split()]
C = [int(x) for x in  input().split()]

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

h = []

heapq.heappush(h, (-A[0]-B[0]-C[0], 0,0,0))

result = []
used = set()

for _ in range(K):
    value, i,j,k = heapq.heappop(h)
    result.append(-value)
    if i < X-1 and (i+1,j,k) not in used:
        heapq.heappush(h, (-A[i+1]-B[j]-C[k],i+1,j,k))
        used.add((i+1,j,k))
    if j < Y-1 and (i,j+1,k) not in used:
        heapq.heappush(h, (-A[i]-B[j+1]-C[k],i,j+1,k))
        used.add((i,j+1,k))
    if k < Z-1 and (i,j,k+1) not in used:
        heapq.heappush(h, (-A[i]-B[j]-C[k+1],i,j,k+1))
        used.add((i,j,k+1))
        
for v in result:
    print(v)