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

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sorted_A = []
A_q = Heapq(A, True)
for i in range(min(X, K)):
    sorted_A.append(A_q.pop())
sorted_B = []
B_q = Heapq(B, True)
for i in range(min(Y, K)):
    sorted_B.append(B_q.pop())
sorted_C = []
C_q = Heapq(C, True)
for i in range(min(Z, K)):
    sorted_C.append(C_q.pop())
# pop_c_list = []
# pop_b_list = []
#
# max_list = []
# for i in range(min(X, K)):
#     a = A_q.pop()
#     for j in range(min(Y, K)):
#         b = B_q.pop()
#         pop_b_list.append(b)
#         for k in range(min(Z, K)):
#             c = C_q.pop()
#             pop_c_list.append(c)
#             max_list.append(a+b+c)
#         for pop_c in pop_c_list:
#             C_q.push(pop_c)
#     for pop_b in pop_b_list:
#         B_q.push(pop_b)

# A.sort(reverse=True)
# B.sort(reverse=True)
# C.sort(reverse=True)

max_list = []
for a in sorted_A:
    for b in sorted_B:
        for c in sorted_C:
            max_list.append(a + b + c)

max_list_q = Heapq(max_list, True)
for i in range(K):
    print(max_list_q.pop())

Fixed submission:
import heapq

import itertools

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

X, Y, Z, 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)

p = itertools.product(A, B)
A_B_list = [sum(v) for v in itertools.product(A, B)]
A_B_list.sort(reverse=True)
A_B_C_list = [sum(v) for v in itertools.product(A_B_list[:3000], C[:3000])]
A_B_C_list.sort(reverse=True)

for ans in A_B_C_list[:K]:
    print(ans)

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

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sorted_A = []
A_q = Heapq(A, True)
for i in range(X):
    sorted_A.append(A_q.pop())
sorted_B = []
B_q = Heapq(B, True)
for i in range(Y):
    sorted_B.append(B_q.pop())
sorted_C = []
C_q = Heapq(C, True)
for i in range(Z):
    sorted_C.append(C_q.pop())
# pop_c_list = []
# pop_b_list = []
#
# max_list = []
# for i in range(min(X, K)):
#     a = A_q.pop()
#     for j in range(min(Y, K)):
#         b = B_q.pop()
#         pop_b_list.append(b)
#         for k in range(min(Z, K)):
#             c = C_q.pop()
#             pop_c_list.append(c)
#             max_list.append(a+b+c)
#         for pop_c in pop_c_list:
#             C_q.push(pop_c)
#     for pop_b in pop_b_list:
#         B_q.push(pop_b)

# A.sort(reverse=True)
# B.sort(reverse=True)
# C.sort(reverse=True)

max_list = []
for a in sorted_A[:K]:
    for b in sorted_B[:K]:
        for c in sorted_C[:K]:
            max_list.append(a + b + c)

max_list_q = Heapq(max_list, True)
for i in range(K):
    print(max_list_q.pop())

Fixed submission:
import heapq

import itertools

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

X, Y, Z, 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)

p = itertools.product(A, B)
A_B_list = [sum(v) for v in itertools.product(A, B)]
A_B_list.sort(reverse=True)
A_B_C_list = [sum(v) for v in itertools.product(A_B_list[:3000], C[:3000])]
A_B_C_list.sort(reverse=True)

for ans in A_B_C_list[:K]:
    print(ans)

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

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

# A_q = Heapq(A, True)
# B_q = Heapq(B, True)
# C_q = Heapq(C, True)
# pop_c_list = []
# pop_b_list = []
#
# max_list = []
# for i in range(min(X, K)):
#     a = A_q.pop()
#     for j in range(min(Y, K)):
#         b = B_q.pop()
#         pop_b_list.append(b)
#         for k in range(min(Z, K)):
#             c = C_q.pop()
#             pop_c_list.append(c)
#             max_list.append(a+b+c)
#         for pop_c in pop_c_list:
#             C_q.push(pop_c)
#     for pop_b in pop_b_list:
#         B_q.push(pop_b)

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

max_list = []
for a in A[:K]:
    for b in B[:K]:
        for c in C[:K]:
            max_list.append(a + b + c)

max_list_q = Heapq(max_list, True)
for i in range(K):
    print(max_list_q.pop())

Fixed submission:
import heapq

import itertools

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

X, Y, Z, 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)

p = itertools.product(A, B)
A_B_list = [sum(v) for v in itertools.product(A, B)]
A_B_list.sort(reverse=True)
A_B_C_list = [sum(v) for v in itertools.product(A_B_list[:3000], C[:3000])]
A_B_C_list.sort(reverse=True)

for ans in A_B_C_list[:K]:
    print(ans)

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

max_list = []
for a in A[:K]:
    for b in B[:K]:
        for c in C[:K]:
            max_list.append(a+b+c)
max_list.sort(reverse=True)
for max in max_list[:K]:
    print(max)

Fixed submission:
import heapq

import itertools

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

X, Y, Z, 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)

p = itertools.product(A, B)
A_B_list = [sum(v) for v in itertools.product(A, B)]
A_B_list.sort(reverse=True)
A_B_C_list = [sum(v) for v in itertools.product(A_B_list[:3000], C[:3000])]
A_B_C_list.sort(reverse=True)

for ans in A_B_C_list[:K]:
    print(ans)