Buggy python submission (verdict: Time Limit Exceeded):
import itertools
X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

D = []
for a, b in itertools.product(A, B):
    d = a + b
    D.append(d)
D.sort(reverse = True)

E = []
for c, d in itertools.product(C, D[:K]):
    e = c + d
    E.append(e)
    
E.sort(reverse = True)
for e in E[:K]:
    print(e)

Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse = True)
B = sorted([int(i) for i in input().split()], reverse = True)
C = sorted([int(i) for i in input().split()], reverse = True)

D = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            D.append(A[i] + B[j] + C[k])
            #print(A[i] + B[j] + C[k], i, j, k)
            
D.sort(reverse = True)
for d in D[:K]:
    print(d)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

D = []
for a, b in itertools.product(A, B):
    d = a + b
    D.append(d)

E = []
for c, d in itertools.product(C, D):
    e = c + d
    E.append(e)
    
E.sort(reverse = True)
for e in E[:K]:
    print(e)

Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse = True)
B = sorted([int(i) for i in input().split()], reverse = True)
C = sorted([int(i) for i in input().split()], reverse = True)

D = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            D.append(A[i] + B[j] + C[k])
            #print(A[i] + B[j] + C[k], i, j, k)
            
D.sort(reverse = True)
for d in D[:K]:
    print(d)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse = True)[:200]
B = sorted([int(i) for i in input().split()], reverse = True)[:200]
C = sorted([int(i) for i in input().split()], reverse = True)[:200]

D = []
for a, b, c in itertools.product(A, B, C):
    d = a + b + c
    D.append(d)
    
D.sort(reverse = True)
for d in D[:K]:
    print(d)

Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse = True)
B = sorted([int(i) for i in input().split()], reverse = True)
C = sorted([int(i) for i in input().split()], reverse = True)

D = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            D.append(A[i] + B[j] + C[k])
            #print(A[i] + B[j] + C[k], i, j, k)
            
D.sort(reverse = True)
for d in D[:K]:
    print(d)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

D = []
for a, b, c in itertools.product(A, B, C):
    d = a + b + c
    D.append(d)
    
D.sort(reverse = True)
for d in D[:K]:
    print(d)

Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse = True)
B = sorted([int(i) for i in input().split()], reverse = True)
C = sorted([int(i) for i in input().split()], reverse = True)

D = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            D.append(A[i] + B[j] + C[k])
            #print(A[i] + B[j] + C[k], i, j, k)
            
D.sort(reverse = True)
for d in D[:K]:
    print(d)