Buggy python submission (verdict: Time Limit Exceeded):
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

C.sort(reverse=True)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(map(str, ans[:K])))


Fixed submission:
X, Y, X, K = 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)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, X, K = 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)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))


Fixed submission:
X, Y, X, K = 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)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []

AA = sorted(A, key=lambda a: -a)
BB = sorted(B, key=lambda a: -a)
CC = sorted(C, key=lambda a: -a)
for a in AA:
    for b in BB:
        for c in CC:
            ans.append(a+b+c)

for an in sorted(ans, key=lambda p: -p)[:K]:
    print(an)

Fixed submission:
X, Y, X, K = 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)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []

AA = sorted(A, key=lambda a: -a)
BB = sorted(B, key=lambda a: -a)
CC = sorted(C, key=lambda a: -a)
for a in AA:
    for b in BB:
        for c in CC:
            ans.append(a+b+c)

for an in sorted(ans, key=lambda p: -p)[:K]:
    print(an)

Fixed submission:
X, Y, X, K = 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)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))

Buggy python submission (verdict: Runtime Error):
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []

AA = sorted(A, key=lambda a: -a)
BB = sorted(B, key=lambda a: -a)
CC = sorted(C, key=lambda a: -a)
for a in AA:
    for b in BB:
        for c in CC:
            if len(ans) > 1000_000:
                for an in sorted(ans, key=lambda p: -p)[:K]:
                    print(an)
                    exit()
            ans.append(a+b+c)

for an in sorted(ans, key=lambda p: -p)[:K]:
    print(an)


Fixed submission:
X, Y, X, K = 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)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))

Buggy python submission (verdict: Runtime Error):
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []

AA = sorted(A, key=lambda a: -a)
BB = sorted(B, key=lambda a: -a)
CC = sorted(C, key=lambda a: -a)
for a in AA:
    for b in BB:
        for c in CC:
            if len(ans) > 1000_000:
                break
            ans.append(a+b+c)

print('\n'.join(list(map(str, sorted(ans, key=lambda p: -p)[:K]))))


Fixed submission:
X, Y, X, K = 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)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))

Buggy python submission (verdict: Runtime Error):
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []

AA = sorted(A, key=lambda a: -a)
BB = sorted(B, key=lambda a: -a)
CC = sorted(C, key=lambda a: -a)
for a in AA:
    for b in BB:
        for c in CC:
            if len(ans) > 1000_000:
                break
            ans.append(a+b+c)

print('\n'.join(list(map(str, sorted(ans, key=lambda p: -p)[:K]))))


Fixed submission:
X, Y, X, K = 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)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))