Buggy python submission (verdict: Time Limit Exceeded):
from itertools import groupby
from operator import itemgetter

x,y,z,k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
# key, group
ga0 = [{'val':key, 'cnt':len(list(group))} for key, group in groupby(a)]
ga = list(reversed(sorted(ga0, key=itemgetter('val'))))
gb = list(reversed(sorted([{'val':key, 'cnt':len(list(group))} for key, group in groupby(b)], key=itemgetter('val'))))
gc = list(reversed(sorted([{'val':key, 'cnt':len(list(group))} for key, group in groupby(c)], key=itemgetter('val'))))

lga, lgb = len(ga), len(gb)
ia,ib = 0,0
ca,cb = ga[0]['cnt'],gb[0]['cnt']
while ca*cb < k:
    if ia == lga-1 and ib == lgb-1:
        break
    elif ia == lga-1:
        ib += 1
        cb += gb[ib]['cnt']
    elif ib == lgb-1:
        ia += 1
        ca += ga[ia]['cnt']
    elif ga[ia+1]['val'] + gb[ib]['val'] >= ga[ia]['val'] + gb[ib+1]['val']:
        ia += 1
        ca += ga[ia]['cnt']
    else:
        ib += 1
        cb += gb[ib]['cnt']
d = []
for va in ga:
    for vb in gb:
        d.append((va['val']+vb['val'],va['cnt']*vb['cnt']))
gd0 = [{'val':key, 'cnt':sum(c_ for _, c_ in list(group))} for key, group in groupby(d,itemgetter(0))]
gd = list(reversed(sorted(gd0, key=itemgetter('val'))))[:k]

lgc, lgd = len(gc), len(gd)
ic,id = 0,0
cc,cd = gc[0]['cnt'],gd[0]['cnt']
while cc*cd < k:
    if ic == lgc-1 and id == lgd-1:
        break
    elif ic == lgc-1:
        id += 1
        cd += gd[id]['cnt']
    elif id == lgd-1:
        ic += 1
        cc += gc[ic]['cnt']
    elif gc[ic+1]['val'] + gd[id]['val'] >= gc[ic]['val'] + gd[id+1]['val']:
        ic += 1
        cc += gc[ic]['cnt']
    else:
        id += 1
        cd += gd[id]['cnt']
r = []
for vc in gc:
    for vd in gd:
        r.append((vc['val']+vd['val'],vc['cnt']*vd['cnt']))
gr0 = [{'val':key, 'cnt':sum(c_ for _, c_ in list(group))} for key, group in groupby(r,itemgetter(0))]
gr = list(reversed(sorted(gr0, key=itemgetter('val'))))[:k]
i = 0
for vr in gr:
    for j in range(vr['cnt']):
        print(vr['val'])
        i += 1
        if i == k:
            exit


Fixed submission:
import heapq
x,y,z,k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
# heap
h = []
g = set()
heapq.heappush(h, (-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    q,ia,ib,ic = heapq.heappop(h)
    print(-q)
    ja,jb,jc = ia+1,ib,ic
    if ja<x and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    ja,jb,jc = ia,ib+1,ic
    if jb<y and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    ja,jb,jc = ia,ib,ic+1
    if jc<z and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))

Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = (int(x) for x in input().split())
a = list(reversed(sorted([int(x) for x in input().split()])))
b = list(reversed(sorted([int(x) for x in input().split()])))
c = list(reversed(sorted([int(x) for x in input().split()])))
ra = [a[0]-x for x in a]
rb = [b[0]-x for x in b]
rc = [c[0]-x for x in c]
ia = 0
ib = 0
ic = 0
while (ia+1)*(ib+1)*(ic+1) < k:
    na = ra[ia+1] if ia+1<x else 10000000001
    nb = rb[ib+1] if ib+1<y else 10000000001
    nc = rc[ic+1] if ic+1<z else 10000000001
    if na <= nb and na <= nc:
        ia += 1
    if nb <= na and nb <= nc:
        ib += 1
    if nc <= na and nc <= nb:
        ic += 1
cp = ra[ia]+rc[ib]+rc[ic]
ca = len([n for n in ra if n <= cp])
cb = len([n for n in rb if n <= cp])
cc = len([n for n in rc if n <= cp])
nums = []
for va in ra[0:ca]:
    for vb in rb[0:cb]:
        for vc in rc[0:cc]:
            nums.append(va+vb+vc)
nums.sort()
mx = a[0]+b[0]+c[0]
for num in nums[0:k]:
    print(mx-num)


Fixed submission:
import heapq
x,y,z,k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
# heap
h = []
g = set()
heapq.heappush(h, (-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    q,ia,ib,ic = heapq.heappop(h)
    print(-q)
    ja,jb,jc = ia+1,ib,ic
    if ja<x and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    ja,jb,jc = ia,ib+1,ic
    if jb<y and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    ja,jb,jc = ia,ib,ic+1
    if jc<z and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))