Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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()))

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

AB.sort(reverse=True)
AB=AB[:K]

ALL=[]

for ab in AB:
    for c in C:
        ALL.append(ab+c)

ALL.sort(reverse=True)

for k in range(K):
    print(ALL[k])


Fixed submission:
import sys
input = sys.stdin.readline

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()))

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

AB.sort(reverse=True)
AB=AB[:K]

ALL=[]

for ab in AB:
    for c in C:
        ALL.append(ab+c)

ALL.sort(reverse=True)

for k in range(K):
    print(ALL[k])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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()))

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

C.sort(reverse=True)
AB.sort(reverse=True)


ABX=[AB[0]-ab for ab in AB]
CX=[C[0]-c for c in C]

ABX.append(float("inf"))
CX.append(float("inf"))

j=0
for i in range(X*Y):
    while j<Z-1 and CX[j]<ABX[i]:
        j+=1

    if (i+1)*(j+1)>K:
        break

#print(i,j)

MIN=AB[i]+C[j]
MAX=AB[0]+C[0]-MIN
LIST=[]

for ii in range(X*Y):
    if AB[0]-AB[ii]>MAX:
        break
    for jj in range(Z):
        if AB[ii]+C[jj]>=MIN:
            LIST.append(AB[ii]+C[jj])
        else:
            break

LIST.sort(reverse=True)

for j in range(K):
    print(LIST[j])

Fixed submission:
import sys
input = sys.stdin.readline

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()))

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

AB.sort(reverse=True)
AB=AB[:K]

ALL=[]

for ab in AB:
    for c in C:
        ALL.append(ab+c)

ALL.sort(reverse=True)

for k in range(K):
    print(ALL[k])

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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()))

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

C.sort(reverse=True)
AB.sort(reverse=True)


ABX=[AB[0]-ab for ab in AB]
CX=[C[0]-c for c in C]

ABX.append(float("inf"))
CX.append(float("inf"))

j=0
for i in range(X*Y):
    while j<Z-1 and CX[j]<ABX[i]:
        j+=1

    if (i+1)*(j+1)>K:
        break

print(i,j)

MIN=AB[i]+C[j]
MAX=AB[0]+C[0]-MIN
LIST=[]

for ii in range(X+Z):
    if AB[0]-AB[ii]>MAX:
        break
    for jj in range(Y):
        if AB[ii]+C[jj]>=MIN:
            LIST.append(AB[ii]+C[jj])
        else:
            break

LIST.sort(reverse=True)

for j in range(K):
    print(LIST[j])

Fixed submission:
import sys
input = sys.stdin.readline

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()))

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

AB.sort(reverse=True)
AB=AB[:K]

ALL=[]

for ab in AB:
    for c in C:
        ALL.append(ab+c)

ALL.sort(reverse=True)

for k in range(K):
    print(ALL[k])

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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=True)
B.sort(reverse=True)
C.sort(reverse=True)

AX=[A[0]-a for a in A]
BX=[B[0]-b for b in B]
CX=[C[0]-c for c in C]

AX.append(float("inf"))
BX.append(float("inf"))
CX.append(float("inf"))


i=0
j=0
k=0

while (i+1)*(j+1)*(k+1)<K:
    MIN=min(AX[i+1],BX[j+1],CX[k+1])

    if MIN==AX[i+1]:
        i+=1
    if MIN==BX[j+1]:
        j+=1
    if MIN==CX[k+1]:
        k+=1

MAX=A[i]+B[i]+C[i]
MIN=A[0]+B[0]+C[0]-MAX

LIST=[]
for i in range(X):
    if A[0]-A[i]>MIN:
        break
    
    for j in range(Y):
        if A[0]+B[0]-A[i]-B[j]>MIN:
            break

        for k in range(Z):
            if A[i]+B[j]+C[k]>=MAX:
                LIST.append(A[i]+B[j]+C[k])
            else:
                break

LIST.sort(reverse=True)

for j in range(K):
    print(LIST[j])
            
    


Fixed submission:
import sys
input = sys.stdin.readline

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()))

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

AB.sort(reverse=True)
AB=AB[:K]

ALL=[]

for ab in AB:
    for c in C:
        ALL.append(ab+c)

ALL.sort(reverse=True)

for k in range(K):
    print(ALL[k])