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

x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

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

V = [[[0] * x for i in range(y)] for j in range(z)]

Q = []
i = 0
j = 0
l = 0
heapq.heappush(Q, (-(A[0]+B[0]+C[0]), i, j, l))
V[i][j][l] = 1
ans = heapq.heappop(Q)
print(-ans[0])
i = ans[1]
j = ans[2]
l = ans[3]

for ii in range(k-1):
    if i+1 < x and V[i+1][j][l] == 0:
        V[i+1][j][l] = 1
        heapq.heappush(Q, (-(A[i+1]+B[j]+C[l]), i+1, j, l))
    if j+1 < y and V[i][j+1][l] == 0:
        V[i][j+1][l] = 1
        heapq.heappush(Q, (-(A[i]+B[j+1]+C[l]), i, j+1, l))
    if l+1 < z and V[i][j][l+1] == 0:
        V[i][j][l+1] = 1
        heapq.heappush(Q, (-(A[i]+B[j]+C[l+1]), i, j, l+1))
    ans = heapq.heappop(Q)
    print(-ans[0])
    i = ans[1]
    j = ans[2]
    l = ans[3]


Fixed submission:
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

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

D = [0] * (min(k, x) * min(k, y))

for i in range(min(k, x)):
    for j in range(min(k, y)):
        D.append(A[i] + B[j])

D.sort(reverse=1)
E = [0] * (min(k, len(D)) * min(k, z))

for i in range(min(k, len(D))):
    for j in range(min(k, z)):
        E.append(D[i] + C[j])

E.sort(reverse=1)

for i in range(k):
    print(E[i])

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

x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

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

V = [[[0] * x for i in range(y)] for j in range(z)]

Q = []
i = 0
j = 0
l = 0
heapq.heappush(Q, (-(A[0]+B[0]+C[0]), i, j, l))
V[i][j][l] = 1
ans = heapq.heappop(Q)
print(-ans[0])
i = ans[1]
j = ans[2]
l = ans[3]

for ii in range(k-1):
    if i+1 < x and V[i+1][j][l] == 0:
        V[i+1][j][l] = 1
        heapq.heappush(Q, (-(A[i+1]+B[j]+C[l]), i+1, j, l))
    if j+1 < y and V[i][j+1][l] == 0:
        V[i][j+1][l] = 1
        heapq.heappush(Q, (-(A[i]+B[j+1]+C[l]), i, j+1, l))
    if l+1 < z and V[i][j][l+1] == 0:
        V[i][j][l+1] = 1
        heapq.heappush(Q, (-(A[i]+B[j]+C[l+1]), i, j, l+1))
    ans = heapq.heappop(Q)
    print(-ans[0])
    i = ans[1]
    j = ans[2]
    l = ans[3]


Fixed submission:
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

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

D = [0] * (min(k, x) * min(k, y))

for i in range(min(k, x)):
    for j in range(min(k, y)):
        D.append(A[i] + B[j])

D.sort(reverse=1)
E = [0] * (min(k, len(D)) * min(k, z))

for i in range(min(k, len(D))):
    for j in range(min(k, z)):
        E.append(D[i] + C[j])

E.sort(reverse=1)

for i in range(k):
    print(E[i])

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

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

D = [0] * (min(k, x) * min(k, y))

for i in range(min(k, x)):
    for j in range(min(k, y)):
        D.append(A[i] + B[j])

D.sort(reverse=1)
E = [0] * (min(k, len(D)) * min(k, z))

for i in range(min(k, len(D))):
    for j in range(min(k, z)):
        E.append(D[i] + C[j])

E.sort(reverse=1)

for i in range(k):
    print(E[i])

Fixed submission:
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

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

D = [0] * (min(k, x) * min(k, y))

for i in range(min(k, x)):
    for j in range(min(k, y)):
        D.append(A[i] + B[j])

D.sort(reverse=1)
E = [0] * (min(k, len(D)) * min(k, z))

for i in range(min(k, len(D))):
    for j in range(min(k, z)):
        E.append(D[i] + C[j])

E.sort(reverse=1)

for i in range(k):
    print(E[i])

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

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

D = []

for i in range(min(k, x)):
    for j in range(min(k, y)):
        D.append(A[i] + B[j])

D.sort(reverse=1)
E = []

for i in range(min(k, len(D))):
    for j in range(min(k, z)):
        E.append(D[i] + C[j])

E.sort(reverse=1)

for i in range(k):
    print(E[i])

Fixed submission:
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

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

D = [0] * (min(k, x) * min(k, y))

for i in range(min(k, x)):
    for j in range(min(k, y)):
        D.append(A[i] + B[j])

D.sort(reverse=1)
E = [0] * (min(k, len(D)) * min(k, z))

for i in range(min(k, len(D))):
    for j in range(min(k, z)):
        E.append(D[i] + C[j])

E.sort(reverse=1)

for i in range(k):
    print(E[i])