Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = list(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=True)
B.sort(reverse=True)
C.sort(reverse=True)

# 美味しさ P 以上の組が K 個以上あるか
def is_exist_K_tuples(P):
    cnt = 0
    for i in range(X):
        for j in range(Y):
            for k in range(Z):
                if A[i] + B[j] + C[k] >= P:
                    cnt += 1
                if cnt >= K:
                    return True
    return False

# 二部探索で K 個以上の組がギリギリ存在する美味しさのラインをサーチ
left = 0
right = A[0] + B[0] + C[0]
while left <= right:
    border = (left + right) // 2
    if is_exist_K_tuples(border):
        left = border + 1
    else:
        right = border - 1
else:
    # 最後の border で K 個あるかは保証されていないので再チェックしてダメなら補正
    if not is_exist_K_tuples(border):
        border -= 1

# 枝刈り全探索で border + 1 以上の美味しさを列挙
result = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if A[i] + B[j] + C[k] >= border + 1:
                result.append(A[i] + B[j] + C[k])
            else:
                break

# 残りがあればそれはすべて border のはず
remains = K - len(result)
for _ in range(remains):
    result.append(border)

result.sort(reverse=True)
for r in result:
    print(r)

Fixed submission:
from itertools import product

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

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = list(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=True)
B.sort(reverse=True)
C.sort(reverse=True)

# 美味しさ P 以上の組が K 個以上あるか
def is_exist_K_tuples(P):
    cnt = 0
    for i in range(X):
        for j in range(Y):
            for k in range(Z):
                if A[i] + B[j] + C[k] >= P:
                    cnt += 1
                if cnt >= K:
                    return True
    return False

# 二部探索で K 個以上の組がギリギリ存在する美味しさのラインをサーチ
left = 0
right = A[0] + B[0] + C[0]
while left <= right:
    border = (left + right) // 2
    if is_exist_K_tuples(border):
        left = border + 1
    else:
        right = border - 1
else:
    # 最後の border で K 個あるかは保証されていないので再チェックしてダメなら補正
    if not is_exist_K_tuples(border):
        border -= 1

# 枝刈り全探索で border + 1 以上の美味しさを列挙
result = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if A[i] + B[j] + C[k] >= border + 1:
                result.append(A[i] + B[j] + C[k])
            else:
                break

# 残りがあればそれはすべて border のはず
remains = K - len(result)
for _ in range(remains):
    result.append(border)

result.sort(reverse=True)
for r in result:
    print(r)

Fixed submission:
from itertools import product

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

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

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

X, Y, Z, K = list(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=True)
B.sort(reverse=True)
C.sort(reverse=True)

candidates = []
for i, j, k in product(range(len(A)), range(len(B)), range(len(C))):
    if i * j * k <= K:
        candidates.append(A[i] + B[j] + C[k])
candidates.sort(reverse=True)

for c in candidates[:K]:
    print(c)

Fixed submission:
from itertools import product

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

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

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

X, Y, Z, K = list(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=True)
B.sort(reverse=True)
C.sort(reverse=True)

candidates = []
for i, j, k in product(range(len(A)), range(len(B)), range(len(C))):
    if i * j * k <= K:
        candidates.append(A[i] + B[j] + C[k])
candidates.sort(reverse=True)

for c in candidates[:K]:
    print(c)

Fixed submission:
from itertools import product

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

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

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


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

AB = [a + b for (a, b) in list(itertools.product(A, B))]
AB.sort(reverse=True)
ans = [ab + c for (ab, c) in list(itertools.product(AB[:min(3000, X*Y*Z)], C))]
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
from itertools import product

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

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
 
X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)
 
ABC = [ab + c for ab, c in product(AB[:min(3000, X*Y*Z)], C)]
ABC.sort(reverse=True)
 
for abc in ABC[:K]:
    print(abc)

Fixed submission:
from itertools import product

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

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

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

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

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

Fixed submission:
from itertools import product

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

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)