Buggy python submission (verdict: Runtime Error):
from collections import deque
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()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=deque()
def dp(l):
  return A[l[0]]+B[l[1]]+C[l[2]]

def priq(a,b,c):
  if [a,b,c] not in pri:
    for i in range(len(pri)):      
      if dp(pri[i])>dp([a,b,c]):
        pri.insert(i,[a,b,c])
        return
    pri.append([a,b,c])
pri.append([0,0,0])
for i in range(K):
  x,y,z=pri.pop()
  print(dp([x,y,z]))
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)



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()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
def dp(x,y,z):
  return A[x]+B[y]+C[z]

def priq(a,b,c):
  d=-dp(a,b,c)
  if tuple([d,a,b,c]) not in pri:
    heapq.heappush(pri,(d,a,b,c))

heapq.heappush(pri,(-dp(0,0,0),0,0,0))

for i in range(K):
  d,x,y,z=heapq.heappop(pri)
  print(-d)
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)

Buggy python submission (verdict: Runtime Error):
from collections import deque
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()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=deque()
def dp(l):
  return A[l[0]]+B[l[1]]+C[l[2]]

def priq(a,b,c):
  if [a,b,c] not in pri:
    for i in range(len(pri)-1,-1,-1):
      
      if dp(pri[i])>dp([a,b,c]):
        pri.insert(i+1,[a,b,c])
        return
    pri.append([a,b,c])

pri.append([0,0,0])
for i in range(K):
  x,y,z=pri.popleft()
  print(dp([x,y,z]))
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)



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()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
def dp(x,y,z):
  return A[x]+B[y]+C[z]

def priq(a,b,c):
  d=-dp(a,b,c)
  if tuple([d,a,b,c]) not in pri:
    heapq.heappush(pri,(d,a,b,c))

heapq.heappush(pri,(-dp(0,0,0),0,0,0))

for i in range(K):
  d,x,y,z=heapq.heappop(pri)
  print(-d)
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)

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()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
def dp(l):
  return A[l[0]]+B[l[1]]+C[l[2]]

def priq(a,b,c):
  if [a,b,c] not in pri:

    for i in range(len(pri)-1,-1,-1):
      if dp(pri[i])<dp([a,b,c]):
        pri.insert(i+1,[a,b,c])
        return
    pri.insert(0,[a,b,c])

pri.append([0,0,0])
for i in range(K):
  x,y,z=pri.pop(-1)
  print(dp([x,y,z]))
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)



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()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
def dp(x,y,z):
  return A[x]+B[y]+C[z]

def priq(a,b,c):
  d=-dp(a,b,c)
  if tuple([d,a,b,c]) not in pri:
    heapq.heappush(pri,(d,a,b,c))

heapq.heappush(pri,(-dp(0,0,0),0,0,0))

for i in range(K):
  d,x,y,z=heapq.heappop(pri)
  print(-d)
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)

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()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
primemo={}
def dp(l):
  return A[l[0]]+B[l[1]]+C[l[2]]

def priq(a,b,c):
  if [a,b,c] not in pri:
    for i in range(len(pri)):
      if dp(pri[i])<dp([a,b,c]):
        pri.insert(i,[a,b,c])
        return
    pri.append([a,b,c])

pri.append([0,0,0])
for i in range(K):
  x,y,z=pri.pop(0)
  print(dp([x,y,z]))
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)



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()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
def dp(x,y,z):
  return A[x]+B[y]+C[z]

def priq(a,b,c):
  d=-dp(a,b,c)
  if tuple([d,a,b,c]) not in pri:
    heapq.heappush(pri,(d,a,b,c))

heapq.heappush(pri,(-dp(0,0,0),0,0,0))

for i in range(K):
  d,x,y,z=heapq.heappop(pri)
  print(-d)
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)