Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, K = map(int, input().split())
K = min(x * y * z, K)
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)


def check(p):
    cnt = 0
    for i in a:
        for j in b:
            for k in c:
                if i + j + k < p:
                    break
                cnt += 1
                if cnt >= K:
                    return True
    return False


left = 10**10 * 3
right = 0

while left - right > 1:
    center = (left + right) // 2
    if check(center):
        tmp = center
        right = center
    else:
        left = center

cnt = 0
results = []
for i in a:
    for j in b:
        for k in c:
            ijk = i + j + k
            if ijk < tmp:
                break
            results.append(ijk)
            cnt += 1
            if cnt >= K:
                print("\n".join(map(str, sorted(results, reverse=True))))
                exit()


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, K = map(int, input().split())
K = min(x * y * z, K)
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)


def check(p, return_array=False):
    cnt = 0
    results = []
    for i in a:
        for j in b:
            for k in c:
                ijk = i + j + k
                if ijk < p:
                    break
                results.append(ijk)
                cnt += 1
                if cnt >= K:
                    return True, results
    return False, results


left = 10**10 * 3
right = 0

while left - right > 1:
    center = (left + right) // 2
    flg, results = check(center)
    if flg:
        tmp = results
        right = center
    else:
        left = center

print("\n".join(map(str, sorted(tmp, reverse=True))))


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = list(map(int, input().split()))[:k]
b = list(map(int, input().split()))[:k]
c = list(map(int, input().split()))[:k]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
def f(a, b):
    return [i + j for i in a for j in b]
ab_results = f(a, b)
ab_results.sort(reverse=True)
results = f(c, ab_results[:k])
results.sort(reverse=True)

print("\n".join(map(str, results[:k])))


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = sorted(list(map(int, input().split())), reverse=True)[:k]
b = sorted(list(map(int, input().split())), reverse=True)[:k]
c = sorted(list(map(int, input().split())), reverse=True)[:k]
def f(a, b):
    results = []
    cnt = 0
    for i in a:
        for j in b:
            cnt += 1
            results.append(i + j)
    return results
ab_results = sorted(f(a, b), reverse=True)
results = sorted(f(c, ab_results[:k]), reverse=True)

print("\n".join(map(str, results[:k])))


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
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)
a = a[:k]
b = b[:k]
c = c[:k]

def f(a, b):
    results = []
    cnt = 0
    for i in a:
        for j in b:
            cnt += 1
            results.append(i + j)
    return results
ab_results = f(a, b)
ab_results.sort(reverse=True)

results = f(c, ab_results[:k])
results.sort(reverse=True)

print("\n".join(map(str, results[:k])))


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
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)

def f(a, b):
    results = []
    cnt = 0
    for i in a:
        for j in b:
            cnt += 1
            results.append(i + j)
    return results
ab_results = f(a, b)
ab_results.sort(reverse=True)

results = f(c, ab_results[:k])
results.sort(reverse=True)

print("\n".join(map(str, results[:k])))


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
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)

def f(a, b):
    results = []
    cnt = 0
    for i in a:
        for j in b:
            cnt += 1
            results.append(i + j)
    return results
ab_results = f(a, b)
ab_results.sort(reverse=True)

results = f(c, ab_results[:k])
results.sort(reverse=True)
list(map(print, results[:k]))


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab_results = [i + j for i in a for j in b]
ab_results.sort(reverse=True)

ab_results = ab_results[:k]
results = [i + j for i in c for j in ab_results]
results.sort(reverse=True)
list(map(print, results[:k]))


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab_results = []
for i in a:
    for j in b:
        ab_results.append(i + j)
ab_results.sort(reverse=True)

ab_results = ab_results[:k]
results = []
for i in c:
    for j in ab_results:
        results.append(i + j)
results.sort(reverse=True)
list(map(print, results[:k]))


Fixed submission:
import numpy as np
x, y, z, k = map(int, input().split())
k = min(x * y * z, k)
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))

ab = np.ravel(a + b[:, None])
ab.sort()
abc = np.ravel(c + ab[-k:, None])
abc.sort()
print(np.sum(abc[-k:][::-1].astype(str).astype(object) + "\n"), end="")