Buggy python submission (verdict: Runtime Error):
import heapq
hq=[]
X, Y, Z, K= map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
B=list(map(int,input().split()))
B.sort(reverse=True)
C=list(map(int,input().split()))
C.sort(reverse=True)
searched={(0,0,0)}
heapq.heappush(hq,(-(A[0]+B[0]+C[0]),0,0,0))
D=[[1,0,0],[0,1,0],[0,0,1]]

for _ in range(K):
    abc,x,y,z=heapq._heappop_max(hq)
    print(-abc)
    for dx,dy,dz in D:
        if x+dx<X and y+dy < Y and z+dz < Z and (x+dx,y+dy,z+dz) not in searched:
            heapq.heappush(hq,(-(A[x+dx]+B[y+dy]+C[z+dz]),x+dx,y+dy,z+dz))
            searched.add((x+dx,y+dy,z+dz))

Fixed submission:
X, Y, Z, K= map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
B=list(map(int,input().split()))
B.sort(reverse=True)
C=list(map(int,input().split()))
C.sort(reverse=True)

ABC=[]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)<=K:
                ABC.append(A[i] + B[j] + C[k])
            else:
                break

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

Buggy python submission (verdict: Runtime Error):
X, Y, Z, K= map(int,input().split())
A=list(map(int,input().split())).sort(reverse=True)
B=list(map(int,input().split())).sort(reverse=True)
C=list(map(int,input().split())).sort(reverse=True)

ABC=[]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            else:
                ABC.append(X[i]+Y[j]+Z[k])
                
ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

Fixed submission:
X, Y, Z, K= map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
B=list(map(int,input().split()))
B.sort(reverse=True)
C=list(map(int,input().split()))
C.sort(reverse=True)

ABC=[]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)<=K:
                ABC.append(A[i] + B[j] + C[k])
            else:
                break

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[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()))

AB=[]
for i in range(X):
    for j in range(Y):
        AB.append(A[i]+B[j])
        
AB.sort(reverse=True)
tmp=AB[0:min(K,len(AB))]

ABC=[]
for i in range(len(tmp)):
    for j in range(Z):
        ABC.append(tmp[i]+C[j])

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

Fixed submission:
X, Y, Z, K= map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
B=list(map(int,input().split()))
B.sort(reverse=True)
C=list(map(int,input().split()))
C.sort(reverse=True)

ABC=[]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)<=K:
                ABC.append(A[i] + B[j] + C[k])
            else:
                break

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[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()))

AB=[]
for i in range(X):
    for j in range(Y):
        AB.append(A[i]+B[j])
        
AB.sort(reverse=True)
tmp=AB[0:min(3001,len(AB))]

ABC=[]
for i in range(len(tmp)):
    for j in range(Z):
        ABC.append(tmp[i]+C[j])

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

Fixed submission:
X, Y, Z, K= map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
B=list(map(int,input().split()))
B.sort(reverse=True)
C=list(map(int,input().split()))
C.sort(reverse=True)

ABC=[]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)<=K:
                ABC.append(A[i] + B[j] + C[k])
            else:
                break

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])