Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    import heapq
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    h = []
    heapq.heappush(h, [-(A[0]+B[0]+C[0]), 0, 0, 0])
    ans = []
    used = [[[False for _ in range(K)] for _ in range(K)] for _ in range(K)]
    used[0][0][0] = True
    for _ in range(K):
        e, i, j, k = heapq.heappop(h)
        ans.append(-e)
        if i+1 < X and not used[i+1][j][k]:
            used[i+1][j][k] = True
            heapq.heappush(h, [-(A[i+1]+B[j]+C[k]), i+1, j, k])
        if j+1 < Y and not used[i][j+1][k]:
            used[i][j+1][k] = True
            heapq.heappush(h, [-(A[i]+B[j+1]+C[k]), i, j+1, k])
        if k+1 < Z and not used[i][j][k+1]:
            used[i][j][k+1] = True
            heapq.heappush(h, [-(A[i]+B[j]+C[k+1]), i, j, k+1])
    for elem in ans:
        print(elem)





#def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
#    AB = []
#    for a in A:
#        for b in B:
#            AB.append(a+b)
#    AB.sort(reverse=True)
#    C.sort(reverse=True)
#    AB = AB[:K]
#    C = C[:K]
#    ABC = []
#    for ab in AB:
#        for c in C:
#            ABC.append(ab+c)
#    ABC.sort(reverse=True)
#    for i in range(K):
#        print(ABC[i])
#    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    AB.sort(reverse=True)
    C.sort(reverse=True)
    AB = AB[:K]
    C = C[:K]
    ABC = []
    for ab in AB:
        for c in C:
            ABC.append(ab+c)
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    import heapq
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    h = []
    heapq.heappush(h, [-(A[0]+B[0]+C[0]), 0, 0, 0])
    ans = []
    used = [[[False for _ in range(Z)] for _ in range(Y)] for _ in range(X)]
    used[0][0][0] = True
    for _ in range(K):
        e, i, j, k = heapq.heappop(h)
        ans.append(-e)
        if i+1 < X and not used[i+1][j][k]:
            used[i+1][j][k] = True
            heapq.heappush(h, [-(A[i+1]+B[j]+C[k]), i+1, j, k])
        if j+1 < Y and not used[i][j+1][k]:
            used[i][j+1][k] = True
            heapq.heappush(h, [-(A[i]+B[j+1]+C[k]), i, j+1, k])
        if k+1 < Z and not used[i][j][k+1]:
            used[i][j][k+1] = True
            heapq.heappush(h, [-(A[i]+B[j]+C[k+1]), i, j, k+1])
    for elem in ans:
        print(elem)





#def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
#    AB = []
#    for a in A:
#        for b in B:
#            AB.append(a+b)
#    AB.sort(reverse=True)
#    C.sort(reverse=True)
#    AB = AB[:K]
#    C = C[:K]
#    ABC = []
#    for ab in AB:
#        for c in C:
#            ABC.append(ab+c)
#    ABC.sort(reverse=True)
#    for i in range(K):
#        print(ABC[i])
#    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    AB.sort(reverse=True)
    C.sort(reverse=True)
    AB = AB[:K]
    C = C[:K]
    ABC = []
    for ab in AB:
        for c in C:
            ABC.append(ab+c)
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    import heapq
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    h = heapq.heapify([])
    h = []
    heapq.heappush(h, [-(A[0]+B[0]+C[0]), 0, 0, 0])
    ans = []
    used = [[[False for _ in range(Z)] for _ in range(Y)] for _ in range(X)]
    used[0][0][0] = True
    while len(ans) < K:
        e, i, j, k = heapq.heappop(h)
        ans.append(-e)
        if i+1 < X and not used[i+1][j][k]:
            used[i+1][j][k] = True
            heapq.heappush(h, [-(A[i+1]+B[j]+C[k]), i+1, j, k])
        if j+1 < Y and not used[i][j+1][k]:
            used[i][j+1][k] = True
            heapq.heappush(h, [-(A[i]+B[j+1]+C[k]), i, j+1, k])
        if k+1 < Z and not used[i][j][k+1]:
            used[i][j][k+1] = True
            heapq.heappush(h, [-(A[i]+B[j]+C[k+1]), i, j, k+1])
    for elem in ans:
        print(elem)





#def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
#    AB = []
#    for a in A:
#        for b in B:
#            AB.append(a+b)
#    AB.sort(reverse=True)
#    C.sort(reverse=True)
#    AB = AB[:K]
#    C = C[:K]
#    ABC = []
#    for ab in AB:
#        for c in C:
#            ABC.append(ab+c)
#    ABC.sort(reverse=True)
#    for i in range(K):
#        print(ABC[i])
#    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    AB.sort(reverse=True)
    C.sort(reverse=True)
    AB = AB[:K]
    C = C[:K]
    ABC = []
    for ab in AB:
        for c in C:
            ABC.append(ab+c)
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    import heapq
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    h = heapq.heapify([])
    h = []
    heapq.heappush(h, [-(A[0]+B[0]+C[0]), 0, 0, 0])
    ans = []
    used = [[[False for _ in range(Z)] for _ in range(Y)] for _ in range(X)]
    used[0][0][0] = True
    while len(ans) < K:
        e, i, j, k = heapq.heappop(h)
        ans.append(-e)
        if i+1 < X and not used[i+1][j][k]:
            used[i+1][j][k] = True
            heapq.heappush(h, [-(A[i+1]+B[j]+C[k]), i+1, j, k])
        if j+1 < Y and not used[i][j+1][k]:
            used[i][j+1][k] = True
            heapq.heappush(h, [-(A[i]+B[j+1]+C[k]), i, j+1, k])
        if k+1 < Z and not used[i][j][k+1]:
            used[i][j][k+1] = True
            heapq.heappush(h, [-(A[i]+B[j]+C[k+1]), i, j, k+1])
    for elem in ans:
        print(elem)





#def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
#    AB = []
#    for a in A:
#        for b in B:
#            AB.append(a+b)
#    AB.sort(reverse=True)
#    C.sort(reverse=True)
#    AB = AB[:K]
#    C = C[:K]
#    ABC = []
#    for ab in AB:
#        for c in C:
#            ABC.append(ab+c)
#    ABC.sort(reverse=True)
#    for i in range(K):
#        print(ABC[i])
#    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    AB.sort(reverse=True)
    C.sort(reverse=True)
    AB = AB[:K]
    C = C[:K]
    ABC = []
    for ab in AB:
        for c in C:
            ABC.append(ab+c)
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    # A.sort(reverse=True)
    # B.sort(reverse=True)
    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    AB.sort(reverse=True)
    C.sort(reverse=True)
    AB = AB[:K]
    C = C[:K]
    ABC = []
    for ab in AB:
        for c in C:
            ABC.append(ab+c)
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int, Z: int, K: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    AB.sort(reverse=True)
    C.sort(reverse=True)
    AB = AB[:K]
    C = C[:K]
    ABC = []
    for ab in AB:
        for c in C:
            ABC.append(ab+c)
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(X)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(Y)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(Z)]  # type: "List[int]"
    solve(X, Y, Z, K, A, B, C)

if __name__ == '__main__':
    main()