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


def solve(k, ax, bx, cx):
    ab = []
    for a in ax:
        for b in bx:
            ab.append(a+b)

    ab.sort(reverse=True)
    abk = ab[:k]

    ans = []
    for c in cx:
        for abi in abk:
            ans.append(c+abi)

    return sorted(ans, reverse=True)[:k]


if __name__ == '__main__':
    _, _, _, k = map(int, input().split())
    ax = list(map(int, sys.stdin.readline().split()))
    bx = list(map(int, sys.stdin.readline().split()))
    cx = list(map(int, sys.stdin.readline().split()))

    ans = solve(k, ax, bx, cx)

    for a in ans:
        print(a)


Fixed submission:
import sys


def solve(k, ax, bx, cx):
    ab = []
    for a in ax:
        for b in bx:
            ab.append(a+b)

    ab.sort(reverse=True)
    abk = ab[:k]

    ans = []
    for c in cx:
        for abi in abk:
            ans.append(c+abi)

    return sorted(ans, reverse=True)[:k]


if __name__ == '__main__':
    _, _, _, k = map(int, input().split())
    ax = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
    bx = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
    cx = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)

    ans = solve(k, ax, bx, cx)

    print(*ans, sep="\n")

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


def solve(k, ax, bx, cx):
    ab = sorted([a + b for a in ax for b in bx], reverse=True)[:k]
    abc = sorted([abi + c for abi in ab for c in cx], reverse=True)[:k]

    return abc


if __name__ == '__main__':
    _, _, _, k = map(int, input().split())
    *ax, = map(int, sys.stdin.readline().split())
    *bx, = map(int, sys.stdin.readline().split())
    *cx, = map(int, sys.stdin.readline().split())

    ans = solve(k, ax, bx, cx)

    for a in ans:
        print(a)


Fixed submission:
import sys


def solve(k, ax, bx, cx):
    ab = []
    for a in ax:
        for b in bx:
            ab.append(a+b)

    ab.sort(reverse=True)
    abk = ab[:k]

    ans = []
    for c in cx:
        for abi in abk:
            ans.append(c+abi)

    return sorted(ans, reverse=True)[:k]


if __name__ == '__main__':
    _, _, _, k = map(int, input().split())
    ax = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
    bx = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
    cx = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)

    ans = solve(k, ax, bx, cx)

    print(*ans, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
def solve(k,ax,bx,cx):
    ab = []
    for a in ax:
        for b in bx:
            ab.append(a+b)

    ab.sort(reverse=True)
    abk = ab[:k]

    ans = []
    for c in cx:
        for abi in abk:
            ans.append(c+abi)

    return sorted(ans, reverse=True)

if __name__ == '__main__':
    _,_,_,k = map(int, input().split())
    ax = list(map(int,input().split()))
    bx = list(map(int,input().split()))
    cx = list(map(int,input().split()))
    ans = solve(k,ax,bx,cx)
    for a in ans[:k]:
        print(a)


Fixed submission:
import sys


def solve(k, ax, bx, cx):
    ab = []
    for a in ax:
        for b in bx:
            ab.append(a+b)

    ab.sort(reverse=True)
    abk = ab[:k]

    ans = []
    for c in cx:
        for abi in abk:
            ans.append(c+abi)

    return sorted(ans, reverse=True)[:k]


if __name__ == '__main__':
    _, _, _, k = map(int, input().split())
    ax = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
    bx = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
    cx = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)

    ans = solve(k, ax, bx, cx)

    print(*ans, sep="\n")