Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
ccc = list(map(int, input().split()))

aabb = [a + b for a in aaa for b in bbb]
aabb.sort(reverse=True)
aabb = aabb[:k]

aabbcc = [ab + c for ab in aabb for c in ccc]
aabbcc.sort(reverse=True)
aabbcc = aabbcc[:k]

print('\n'.join(map(str, aabbcc)))


Fixed submission:
x, y, z, k = map(int, input().split())
aaa = sorted(map(int, input().split()), reverse=True)
bbb = sorted(map(int, input().split()), reverse=True)
ccc = sorted(map(int, input().split()), reverse=True)
ma, mb, mc = aaa[0], bbb[0], ccc[0]
cakes = [(ma - a, 0) for a in aaa[1:]]
cakes += [(mb - b, 1) for b in bbb[1:]]
cakes += [(mc - c, 2) for c in ccc[1:]]
cakes.sort()

buf = [[ma], [mb], [mc]]
ans = [ma + mb + mc]

for d, i in cakes:
    if i == 0:
        a = aaa[len(buf[i])]
        if len(ans) == k and ans[-1] >= a + mb + mc:
            break
        buf[i].append(a)
        ans.extend(a + b + c for b in buf[1] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    elif i == 1:
        b = bbb[len(buf[i])]
        if len(ans) == k and ans[-1] >= ma + b + mc:
            break
        buf[i].append(b)
        ans.extend(a + b + c for a in buf[0] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    else:
        c = ccc[len(buf[i])]
        if len(ans) == k and ans[-1] >= ma + mb + c:
            break
        buf[i].append(c)
        ans.extend(a + b + c for a in buf[0] for b in buf[1])
        ans.sort(reverse=True)
        ans = ans[:k]

print('\n'.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
aaa = sorted(map(int, input().split()), reverse=True)
bbb = sorted(map(int, input().split()), reverse=True)
ccc = sorted(map(int, input().split()), reverse=True)
ma, mb, mc = aaa[0], bbb[0], ccc[0]
cakes = [(ma - a, 0) for a in aaa[1:]]
cakes += [(mb - b, 1) for b in bbb[1:]]
cakes += [(mc - c, 2) for c in ccc[1:]]
cakes.sort()

buf = [[ma], [mb], [mc]]
ans = [ma + mb + mc]

for d, i in cakes:
    if i == 0:
        a = aaa[len(buf[i])]
        if len(ans) == k and ans[-1] > a + mb + mc:
            break
        buf[i].append(a)
        ans.extend(a + b + c for b in buf[1] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    elif i == 1:
        b = bbb[len(buf[i])]
        if len(ans) == k and ans[-1] > ma + b + mc:
            break
        buf[i].append(b)
        ans.extend(a + b + c for a in buf[0] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    else:
        c = ccc[len(buf[i])]
        if len(ans) == k and ans[-1] > ma + mb + c:
            break
        buf[i].append(c)
        ans.extend(a + b + c for a in buf[0] for b in buf[1])
        ans.sort(reverse=True)
        ans = ans[:k]

print('\n'.join(map(str, ans)))


Fixed submission:
x, y, z, k = map(int, input().split())
aaa = sorted(map(int, input().split()), reverse=True)
bbb = sorted(map(int, input().split()), reverse=True)
ccc = sorted(map(int, input().split()), reverse=True)
ma, mb, mc = aaa[0], bbb[0], ccc[0]
cakes = [(ma - a, 0) for a in aaa[1:]]
cakes += [(mb - b, 1) for b in bbb[1:]]
cakes += [(mc - c, 2) for c in ccc[1:]]
cakes.sort()

buf = [[ma], [mb], [mc]]
ans = [ma + mb + mc]

for d, i in cakes:
    if i == 0:
        a = aaa[len(buf[i])]
        if len(ans) == k and ans[-1] >= a + mb + mc:
            break
        buf[i].append(a)
        ans.extend(a + b + c for b in buf[1] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    elif i == 1:
        b = bbb[len(buf[i])]
        if len(ans) == k and ans[-1] >= ma + b + mc:
            break
        buf[i].append(b)
        ans.extend(a + b + c for a in buf[0] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    else:
        c = ccc[len(buf[i])]
        if len(ans) == k and ans[-1] >= ma + mb + c:
            break
        buf[i].append(c)
        ans.extend(a + b + c for a in buf[0] for b in buf[1])
        ans.sort(reverse=True)
        ans = ans[:k]

print('\n'.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
aaa = sorted(map(int, input().split()), reverse=True)
bbb = sorted(map(int, input().split()), reverse=True)
ccc = sorted(map(int, input().split()), reverse=True)
ma, mb, mc = aaa[0], bbb[0], ccc[0]
cakes = [(ma - a, 0) for a in aaa[1:]]
cakes += [(mb - b, 1) for b in bbb[1:]]
cakes += [(mc - c, 2) for c in ccc[1:]]
cakes.sort()

buf = [[ma], [mb], [mc]]
ans = [ma + mb + mc]

for d, i in cakes:
    if i == 0:
        a = aaa[len(buf[i])]
        if len(ans) == k and ans[-1] > a + mb + mc:
            break
        buf[i].append(a)
        ans.extend(a + b + c for b in buf[1] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    elif i == 1:
        b = bbb[len(buf[i])]
        if len(ans) == k and ans[-1] > ma + b + mc:
            break
        buf[i].append(b)
        ans.extend(a + b + c for a in buf[0] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    else:
        c = ccc[len(buf[i])]
        if len(ans) == k and ans[-1] > ma + mb + c:
            break
        buf[i].append(c)
        ans.extend(a + b + c for a in buf[0] for b in buf[1])
        ans.sort(reverse=True)
        ans = ans[:k]

print('\n'.join(map(str, ans)))


Fixed submission:
x, y, z, k = map(int, input().split())
aaa = sorted(map(int, input().split()), reverse=True)
bbb = sorted(map(int, input().split()), reverse=True)
ccc = sorted(map(int, input().split()), reverse=True)
ma, mb, mc = aaa[0], bbb[0], ccc[0]
cakes = [(ma - a, 0) for a in aaa[1:]]
cakes += [(mb - b, 1) for b in bbb[1:]]
cakes += [(mc - c, 2) for c in ccc[1:]]
cakes.sort()

buf = [[ma], [mb], [mc]]
ans = [ma + mb + mc]

for d, i in cakes:
    if i == 0:
        a = aaa[len(buf[i])]
        if len(ans) == k and ans[-1] >= a + mb + mc:
            break
        buf[i].append(a)
        ans.extend(a + b + c for b in buf[1] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    elif i == 1:
        b = bbb[len(buf[i])]
        if len(ans) == k and ans[-1] >= ma + b + mc:
            break
        buf[i].append(b)
        ans.extend(a + b + c for a in buf[0] for c in buf[2])
        ans.sort(reverse=True)
        ans = ans[:k]
    else:
        c = ccc[len(buf[i])]
        if len(ans) == k and ans[-1] >= ma + mb + c:
            break
        buf[i].append(c)
        ans.extend(a + b + c for a in buf[0] for b in buf[1])
        ans.sort(reverse=True)
        ans = ans[:k]

print('\n'.join(map(str, ans)))