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

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

li=[]
for i in a:
  for j in b:
    li.append(i+j)
li.sort(reverse=True)
 
ansli=[]
for i in c:
  for j in range(min(k,len(li))):
    ansli.append(i+li[j])
ansli.sort(reverse=True)
 
for i in range(k):
  print(ansli[i])

Fixed submission:
from heapq import *

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)

q=[]
li=[]
heappush(q,((a[0]+b[0]+c[0]) * (-1),0,0,0))

for i in range(k):
  node=heappop(q)
  
  print(node[0]*-1)
  if node[1]+1 != x:
    node_a = ((a[node[1]+1]+b[node[2]]+c[node[3]])*(-1), node[1]+1, node[2], node[3])
    if node_a not in q:
      heappush(q,node_a)
  
  if node[2]+1 != y:
    node_b = ((a[node[1]]+b[node[2]+1]+c[node[3]])*(-1), node[1], node[2]+1, node[3])
    if node_b not in q:
      heappush(q,node_b)
  
  if node[3]+1 != z:
    node_c = ((a[node[1]]+b[node[2]]+c[node[3]+1])*(-1), node[1], node[2], node[3]+1)
    if node_c not in q:
      heappush(q,node_c)

Buggy python submission (verdict: Runtime Error):
    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()))
      
    li=[]
    for i in a:
      for j in b:
        li.append(i+j)
    li.sort(reverse=True)
     
    ansli=[]
    for i in c:
      for j in range(min(k,len(li))):
        ansli.append(i+li[j])
    ansli.sort(reverse=True)
     
    for i in range(k):
      print(ansli[i])

Fixed submission:
from heapq import *

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)

q=[]
li=[]
heappush(q,((a[0]+b[0]+c[0]) * (-1),0,0,0))

for i in range(k):
  node=heappop(q)
  
  print(node[0]*-1)
  if node[1]+1 != x:
    node_a = ((a[node[1]+1]+b[node[2]]+c[node[3]])*(-1), node[1]+1, node[2], node[3])
    if node_a not in q:
      heappush(q,node_a)
  
  if node[2]+1 != y:
    node_b = ((a[node[1]]+b[node[2]+1]+c[node[3]])*(-1), node[1], node[2]+1, node[3])
    if node_b not in q:
      heappush(q,node_b)
  
  if node[3]+1 != z:
    node_c = ((a[node[1]]+b[node[2]]+c[node[3]+1])*(-1), node[1], node[2], node[3]+1)
    if node_c not in q:
      heappush(q,node_c)

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)

li=[]
for i in a:
  for j in b:
    li.append(i+j)
li.sort(reverse=True)

ansli=[]
for i in c:
  for j in range(min(k,len(li))):
    ansli.append(i+li[j])
ansli.sort(reverse=True)

for i in range(k):
  print(ansli[i])

Fixed submission:
from heapq import *

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)

q=[]
li=[]
heappush(q,((a[0]+b[0]+c[0]) * (-1),0,0,0))

for i in range(k):
  node=heappop(q)
  
  print(node[0]*-1)
  if node[1]+1 != x:
    node_a = ((a[node[1]+1]+b[node[2]]+c[node[3]])*(-1), node[1]+1, node[2], node[3])
    if node_a not in q:
      heappush(q,node_a)
  
  if node[2]+1 != y:
    node_b = ((a[node[1]]+b[node[2]+1]+c[node[3]])*(-1), node[1], node[2]+1, node[3])
    if node_b not in q:
      heappush(q,node_b)
  
  if node[3]+1 != z:
    node_c = ((a[node[1]]+b[node[2]]+c[node[3]+1])*(-1), node[1], node[2], node[3]+1)
    if node_c not in q:
      heappush(q,node_c)