Buggy python submission (verdict: Time Limit Exceeded):
import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)
check_list = [ [ [ False for i in range(x) ] for j in range(y) ]  for l in range(z)]
check_list_x, check_list_y, check_list_z = [ 0 for i in range(x) ], [ 0 for i in range(y) ], [ 0 for i in range(z) ]
cake_list = []

def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)

for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        check_list[0][0][0] = 1
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            check_list[1][0][0] = 1
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            check_list[0][1][0] = 1
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            check_list[0][0][1] = 1
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if check_list[ai+1][bi][ci] == 0:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                check_list[ai+1][bi][ci] = 1
        if bi < y - 1:
            if check_list[ai][bi+1][ci] == 0:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                check_list[ai][bi+1][ci] = 1
        if ci < z - 1:
            if check_list[ai][bi][ci+1] == 0:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                check_list[ai][bi][ci+1] = 1

        print(-di)

Fixed submission:

import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)

cake_list = []
num_set = set([0])

def hash2(a,b,c):
    return 10**8*a+10**4*b+c


def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)

for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            num_set.add(hash2(1,0,0))
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            num_set.add(hash2(0,1,0))
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            num_set.add(hash2(0,0,1))
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if hash2(ai+1,bi,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                num_set.add(hash2(ai+1,bi,ci))
        if bi < y - 1:
            if hash2(ai,bi+1,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                num_set.add(hash2(ai,bi+1,ci))
        if ci < z - 1:
            if hash2(ai,bi,ci+1) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                num_set.add(hash2(ai,bi,ci+1))
        print(-di)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)
check_list = [ [ [ False for i in range(x) ] for j in range(y) ]  for l in range(z)]
cake_list = []
def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)


for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        check_list[0][0][0] = True
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            check_list[1][0][0] = True
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            check_list[0][1][0] = True
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            check_list[0][0][1] = True
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if check_list[ai+1][bi][ci] == False:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                check_list[ai+1][bi][ci] = True
        if bi < y - 1:
            if check_list[ai][bi+1][ci] == False:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                check_list[ai][bi+1][ci] = True
        if ci < z - 1:
            if check_list[ai][bi][ci+1] == False:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                check_list[ai][bi][ci+1] = True

        print(-di)

Fixed submission:

import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)

cake_list = []
num_set = set([0])

def hash2(a,b,c):
    return 10**8*a+10**4*b+c


def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)

for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            num_set.add(hash2(1,0,0))
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            num_set.add(hash2(0,1,0))
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            num_set.add(hash2(0,0,1))
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if hash2(ai+1,bi,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                num_set.add(hash2(ai+1,bi,ci))
        if bi < y - 1:
            if hash2(ai,bi+1,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                num_set.add(hash2(ai,bi+1,ci))
        if ci < z - 1:
            if hash2(ai,bi,ci+1) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                num_set.add(hash2(ai,bi,ci+1))
        print(-di)

Buggy python submission (verdict: Time Limit Exceeded):

import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)
check_list = [ [ [ False for i in range(x) ] for j in range(y) ]  for l in range(z)]
cake_list = []
def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)


for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        check_list[0][0][0] = True
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            check_list[1][0][0] = True
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            check_list[0][1][0] = True
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            check_list[0][0][1] = True
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if check_list[ai+1][bi][ci] == False:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                check_list[ai+1][bi][ci] = True
        if bi < y - 1:
            if check_list[ai][bi+1][ci] == False:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                check_list[ai][bi+1][ci] = True
        if ci < z - 1:
            if check_list[ai][bi][ci+1] == False:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                check_list[ai][bi][ci+1] = True

        print(-di)

Fixed submission:

import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)

cake_list = []
num_set = set([0])

def hash2(a,b,c):
    return 10**8*a+10**4*b+c


def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)

for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            num_set.add(hash2(1,0,0))
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            num_set.add(hash2(0,1,0))
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            num_set.add(hash2(0,0,1))
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if hash2(ai+1,bi,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                num_set.add(hash2(ai+1,bi,ci))
        if bi < y - 1:
            if hash2(ai,bi+1,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                num_set.add(hash2(ai,bi+1,ci))
        if ci < z - 1:
            if hash2(ai,bi,ci+1) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                num_set.add(hash2(ai,bi,ci+1))
        print(-di)

Buggy python submission (verdict: Runtime Error):
x, y, z, k = [ int(v) for v in input().split() ]
a_list = sorted([ -int(v) for v in input().split() ], reverse = True )
b_list = sorted([ -int(v) for v in input().split() ], reverse = True )
c_list = sorted([ -int(v) for v in input().split() ], reverse = True )


def most_dericious(a,b,c):
	return a_list[a] + b_list[b] + c_list[c]
out_cakes_list= []
for i in range(k):
	if i == 0:
		dericious_heap = [ (most_dericious(x-1,y-1,z-1),(x-1,y-1,z-1)) ]
		heapq.heapify(dericious_heap)
	out_cakes = (heapq.heappop(dericious_heap))
	p, q, r = out_cakes[1][0], out_cakes[1][1], out_cakes[1][2]

	if p-1 >= 0 and (most_dericious(p-1,q,r),(p-1,q,r)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p-1,q,r),(p-1,q,r)))
	if q-1 >= 0 and (most_dericious(p,q-1,r),(p,q-1,r)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p,q-1,r),(p,q-1,r)))
	if r-1 >= 0 and (most_dericious(p,q,r-1),(p,q,r-1)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p,q,r-1),(p,q,r-1)))
	out_cakes_list.append(out_cakes)

out_cakes_list = sorted(out_cakes_list)
for i in range(k):
	print(-out_cakes_list[i][0])

Fixed submission:

import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)

cake_list = []
num_set = set([0])

def hash2(a,b,c):
    return 10**8*a+10**4*b+c


def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)

for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            num_set.add(hash2(1,0,0))
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            num_set.add(hash2(0,1,0))
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            num_set.add(hash2(0,0,1))
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if hash2(ai+1,bi,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                num_set.add(hash2(ai+1,bi,ci))
        if bi < y - 1:
            if hash2(ai,bi+1,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                num_set.add(hash2(ai,bi+1,ci))
        if ci < z - 1:
            if hash2(ai,bi,ci+1) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                num_set.add(hash2(ai,bi,ci+1))
        print(-di)