Buggy python submission (verdict: Time Limit Exceeded):
import itertools
X,Y,Z,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
C=[int(i) for i in input().split(" ")]

AB=[]

A=sorted(A,reverse=True)[:K:]
B=sorted(B,reverse=True)[:K:]
C=sorted(C,reverse=True)[:K:]
for i in itertools.product(A,B):
    a,b=i
    AB.append(a+b)

AB=sorted(AB,reverse=True)[:K:]

ABC=[]
for i in itertools.product(AB,C):
    ab,c=i
    ABC.append(ab+c)

ABC=sorted(ABC,reverse=True)[:K:]


for abc in ABC:
    print(abc)


Fixed submission:
import heapq
X,Y,Z,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
C=[int(i) for i in input().split(" ")]

AB=[]
for a in A:
    for b in B:
        AB.append(a+b)

AB=heapq.nlargest(K,AB)
ABC=[]
for ab in AB:
    for c in C:
        ABC.append(ab+c)

for cake in heapq.nlargest(K,ABC):
    print(cake)

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
C=[int(i) for i in input().split(" ")]

AB=[]

A=sorted(A,reverse=True)[:K:]
B=sorted(B,reverse=True)[:K:]
C=sorted(C,reverse=True)[:K:]
for a in A:
    for b in B:
        AB.append(a+b)

AB=sorted(AB,reverse=True)[:K:]

ABC=[]
for ab in AB:
    for c in C:
        ABC.append(ab+c)

ABC=sorted(ABC,reverse=True)[:K:]


for abc in ABC:
    print(abc)


Fixed submission:
import heapq
X,Y,Z,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
C=[int(i) for i in input().split(" ")]

AB=[]
for a in A:
    for b in B:
        AB.append(a+b)

AB=heapq.nlargest(K,AB)
ABC=[]
for ab in AB:
    for c in C:
        ABC.append(ab+c)

for cake in heapq.nlargest(K,ABC):
    print(cake)

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
C=[int(i) for i in input().split(" ")]

delicious=[]

A=sorted(A,reverse=True)
B=sorted(B,reverse=True)
C=sorted(C,reverse=True)

for i in range(min(K,len(A))):
    for j in range(min(K,len(B))):
        for k in range(min(K,len(C))):
            delicious.append(A[i]+B[j]+C[k])

delicious=sorted(delicious,reverse=True)
for i in range(K):
    print(delicious[i])


Fixed submission:
import heapq
X,Y,Z,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
C=[int(i) for i in input().split(" ")]

AB=[]
for a in A:
    for b in B:
        AB.append(a+b)

AB=heapq.nlargest(K,AB)
ABC=[]
for ab in AB:
    for c in C:
        ABC.append(ab+c)

for cake in heapq.nlargest(K,ABC):
    print(cake)

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
C=[int(i) for i in input().split(" ")]

delicious=[]

for a in A:
    for b in B:
        for c in C:
            delicious.append(a+b+c)

delicious=sorted(delicious,reverse=True)
for i in range(K):
    print(delicious[i])


Fixed submission:
import heapq
X,Y,Z,K=[int(i) for i in input().split(" ")]
A=[int(i) for i in input().split(" ")]
B=[int(i) for i in input().split(" ")]
C=[int(i) for i in input().split(" ")]

AB=[]
for a in A:
    for b in B:
        AB.append(a+b)

AB=heapq.nlargest(K,AB)
ABC=[]
for ab in AB:
    for c in C:
        ABC.append(ab+c)

for cake in heapq.nlargest(K,ABC):
    print(cake)