Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')


Fixed submission:
x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))
bb = sorted(list(map(int, input().split())))
cc = sorted(list(map(int, input().split())))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

x,y,z,k = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab for c in cc)[:-k-1:-1]
print(*abc, sep='\n')


Fixed submission:
x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))
bb = sorted(list(map(int, input().split())))
cc = sorted(list(map(int, input().split())))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

x,y,z,k = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

# A,Bでソート
score_ab = []
for a in aa:
    for b in bb:
        # bisect.insort_right(score_ab, a+b)
        score_ab.append(a+b)
score_ab = sorted(score_ab)[::-1][:k]
# print(score_ab[::-1])
# A,B合計値の上位K個とCでソート
score = []
for s in score_ab:
    for c in cc:
        # bisect.insort_right(score, s+c)
        score.append(s+c)
score = sorted(score)[::-1][:k]
for s in score:
    print(s)

Fixed submission:
x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))
bb = sorted(list(map(int, input().split())))
cc = sorted(list(map(int, input().split())))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

x,y,z,k = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

# A,Bでソート
score_ab = []
for a in aa:
    for b in bb:
        bisect.insort_right(score_ab, a+b)
# print(score_ab[::-1])
# A,B合計値の上位K個とCでソート
score = []
for s in score_ab[::-1][:k]:
    for c in cc:
        bisect.insort_right(score, s+c)
for s in score[::-1][:k]:
    print(s)

Fixed submission:
x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))
bb = sorted(list(map(int, input().split())))
cc = sorted(list(map(int, input().split())))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

x,y,z,k = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

# A,Bでソート
score_ab = []
for a in aa:
    for b in bb:
            bisect.insort_right(score_ab, a+b)
# print(score_ab[::-1])
# A,B合計値の上位K個とCでソート
score = []
for s in score_ab[::-1][:k]:
    for c in cc:
            bisect.insort_right(score, s+c)
for s in score[::-1][:k]:
    print(s)

Fixed submission:
x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))
bb = sorted(list(map(int, input().split())))
cc = sorted(list(map(int, input().split())))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')

Buggy python submission (verdict: Runtime Error):
import bisect

x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))[::-1]
bb = sorted(list(map(int, input().split())))[::-1]
cc = sorted(list(map(int, input().split())))[::-1]

ia,ib,ic = 0,0,0
aa_ = [aa[ia]]
bb_ = [bb[ib]]
cc_ = [cc[ic]]
while len(aa_)*len(bb_)*len(cc_) <=k:
    if ia<x and aa[ia] == min(aa[ia],bb[ib],cc[ic]):
        ia +=1
        aa_ += [aa[ia]]
    if ib<y and bb[ib] == min(aa[ia],bb[ib],cc[ic]):
        ib +=1
        bb_ += [bb[ib]]
    else:
        ic +=1
        cc_ += [cc[ic]]

score = []
for a in aa_:
    for b in bb_:
        for c in cc_:
            bisect.insort_right(score, a+b+c)
for s in score[::-1][:k]:
    print(s)

Fixed submission:
x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))
bb = sorted(list(map(int, input().split())))
cc = sorted(list(map(int, input().split())))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

x,y,z,k = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cc = list(map(int, input().split()))

score = []

for a in aa:
    for b in bb:
        for c in cc:
            bisect.insort_right(score, a+b+c)
for s in score[::-1][:min(k,x*y*z)]:
    print(s)

Fixed submission:
x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))
bb = sorted(list(map(int, input().split())))
cc = sorted(list(map(int, input().split())))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')