Problem: The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called _deliciousness_ , as follows:    * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X.   * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y.   * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z.  Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123.   There are X \times Y \times Z such ways to choose three cakes.   We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes.   Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list.

Submission attempts (in order):
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()))

ab_list = []
for a_i in range(x):
    for b_i in range(y):
        ab_list.append(a[a_i]+b[b_i])
ab_list.sort(reverse=True)
sum_list = []
for ab_i in range(k):
    for c_i in range(z):
        sum_list.append(ab_list[ab_i]+c[c_i])
sum_list.sort(reverse=True)
for i in range(k):
    print(sum_list[i])

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()))

ab_list = []
for a_i in range(x):
    for b_i in range(y):
        ab_list.append(a[a_i]+b[b_i])
ab_list.sort().reverse()
sum_list = []
for ab_i in range(k):
    for c_i in range(z):
        sum_list.append(ab_list[ab_i]+c[c_i])
sum_list.sort().reverse()
#sum_list = []
#for a_i in range(x):
#    for b_i in range(y):
#        for c_i in range(z):
#            sum_list.append(a[a_i]+b[b_i]+c[c_i])
#sum_list.sort()
for i in range(k):
    print(sum_list[i])

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()))

sum_list = []
for a_i in range(x):
    for b_i in range(y):
        for c_i in range(z):
            sum_list.append(a[a_i]+b[b_i]+c[c_i])
sum_list.sort
for i in range(k):
    print(sum_list(i))

x,y,z,k = map(int,input().split())
a = list(map(int,input().split())).sort()
b = list(map(int,input().split())).sort()
c = list(map(int,input().split())).sort()

ab_list = []
for a_i in range(x):
    for b_i in range(y):
        ab_list.append(a[a_i]+b[b_i])
ab_list.sort()
sum_list = []
for ab_i in range(k):
    for c_i in range(z):
        sum_list.append(ab_list[ab_i]+c[c_i])
sum_list.sort()
#sum_list = []
#for a_i in range(x):
#    for b_i in range(y):
#        for c_i in range(z):
#            sum_list.append(a[a_i]+b[b_i]+c[c_i])
#sum_list.sort()
for i in range(k):
    print(sum_list[i])

x,y,z,k = map(int,input().split())
a = list(map(int,input().split())).sort(reverse=True)
b = list(map(int,input().split())).sort(reverse=True)
c = list(map(int,input().split())).sort(reverse=True)

sum_list = []
for a_i in range(x):
    for b_i in range(y):
        for c_i in range(z):
            if a_i*b_i*c_i > k:
                continue
            sum_list.append(a[a_i]+b[b_i]+c[c_i])
sum_list.sort(reverse=True)
for i in range(k):
    print(sum_list[i])

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)
sum_list = []
for a_i in range(x):
    for b_i in range(y):
        if a_i*b_i > k:
            break
        for c_i in range(z):
            if a_i*b_i*c_i > k:
                break
            sum_list.append(a[a_i]+b[b_i]+c[c_i])
sum_list.sort(reverse=True)
for i in range(k):
    print(sum_list[i])

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted