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

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

out = sorted([A[a] + B[b] + C[c] for a, b, c in itertools.product(range(len(A)), range(len(B)), range(len(C))) if (a+1)*(b+1)*(c+1) <= K], reverse=True)

for x in out[:K]:
    print(x)

Fixed submission:
import numpy as np
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

tmp = {(0, 0, 0) : A[0] + B[0] + C[0]}
tmp_keys = [(0, 0 ,0)]
out = []

for i in range(K):
    (a, b, c),  p = max(tmp.items(), key=lambda x : x[1])
    out.append(tmp.pop((a, b, c)))

    keys = []
    if a < X - 1:
        keys.append((a+1, b, c))
    if b < Y - 1:
        keys.append((a, b+1, c))
    if c < Z - 1:
        keys.append((a, b, c+1))
    
    for key in keys:
        if key not in tmp_keys:
            tmp[key] = A[key[0]] + B[key[1]] + C[key[2]]
            tmp_keys.append(key)

for x in out:
    print(x)

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

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

out = sorted([A[a] + B[b] + C[c] for a, b, c in itertools.product(range(len(A)), range(len(B)), range(len(C))) if a*b*c <= K], reverse=True)

for x in out[:K]:
    print(x)

Fixed submission:
import numpy as np
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

tmp = {(0, 0, 0) : A[0] + B[0] + C[0]}
tmp_keys = [(0, 0 ,0)]
out = []

for i in range(K):
    (a, b, c),  p = max(tmp.items(), key=lambda x : x[1])
    out.append(tmp.pop((a, b, c)))

    keys = []
    if a < X - 1:
        keys.append((a+1, b, c))
    if b < Y - 1:
        keys.append((a, b+1, c))
    if c < Z - 1:
        keys.append((a, b, c+1))
    
    for key in keys:
        if key not in tmp_keys:
            tmp[key] = A[key[0]] + B[key[1]] + C[key[2]]
            tmp_keys.append(key)

for x in out:
    print(x)

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

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = sorted([int(x) for x in str(input()).split(' ')], reverse=True)
B = sorted([int(x) for x in str(input()).split(' ')], reverse=True)
C = sorted([int(x) for x in str(input()).split(' ')], reverse=True)

out = sorted([A[a] + B[b] + C[c] for a, b, c in itertools.product(range(len(A)), range(len(B)), range(len(C))) if a*b*c <= K], reverse=True)

for x in out[:K]:
    print(x)

Fixed submission:
import numpy as np
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

tmp = {(0, 0, 0) : A[0] + B[0] + C[0]}
tmp_keys = [(0, 0 ,0)]
out = []

for i in range(K):
    (a, b, c),  p = max(tmp.items(), key=lambda x : x[1])
    out.append(tmp.pop((a, b, c)))

    keys = []
    if a < X - 1:
        keys.append((a+1, b, c))
    if b < Y - 1:
        keys.append((a, b+1, c))
    if c < Z - 1:
        keys.append((a, b, c+1))
    
    for key in keys:
        if key not in tmp_keys:
            tmp[key] = A[key[0]] + B[key[1]] + C[key[2]]
            tmp_keys.append(key)

for x in out:
    print(x)

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

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])
A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True)[:min(X, K)])
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True)[:min(Y, K)])
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True)[:min(Z, K)])

out = sorted([sum(x) for x in itertools.product(A, B, C)], reverse=True)

for x in out[:K]:
    print(x)

Fixed submission:
import numpy as np
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

tmp = {(0, 0, 0) : A[0] + B[0] + C[0]}
tmp_keys = [(0, 0 ,0)]
out = []

for i in range(K):
    (a, b, c),  p = max(tmp.items(), key=lambda x : x[1])
    out.append(tmp.pop((a, b, c)))

    keys = []
    if a < X - 1:
        keys.append((a+1, b, c))
    if b < Y - 1:
        keys.append((a, b+1, c))
    if c < Z - 1:
        keys.append((a, b, c+1))
    
    for key in keys:
        if key not in tmp_keys:
            tmp[key] = A[key[0]] + B[key[1]] + C[key[2]]
            tmp_keys.append(key)

for x in out:
    print(x)

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

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

out = sorted([sum(x) for x in itertools.product(A, B, C)], reverse=True)

for x in out[:K]:
    print(x)


Fixed submission:
import numpy as np
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

tmp = {(0, 0, 0) : A[0] + B[0] + C[0]}
tmp_keys = [(0, 0 ,0)]
out = []

for i in range(K):
    (a, b, c),  p = max(tmp.items(), key=lambda x : x[1])
    out.append(tmp.pop((a, b, c)))

    keys = []
    if a < X - 1:
        keys.append((a+1, b, c))
    if b < Y - 1:
        keys.append((a, b+1, c))
    if c < Z - 1:
        keys.append((a, b, c+1))
    
    for key in keys:
        if key not in tmp_keys:
            tmp[key] = A[key[0]] + B[key[1]] + C[key[2]]
            tmp_keys.append(key)

for x in out:
    print(x)