Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03082 (python)

Fixed submission:
# -*- coding: utf-8 -*-

from collections import defaultdict


n, X = map(int, input().split())
s = list(map(int, input().split()))
s = sorted(s, reverse=True)

mod = 10 ** 9 + 7

dp = defaultdict(int)
dp[X] = 1

for i in range(n):
    new_dp = defaultdict(int)

    for x in dp:
        mod_x = x % s[i]
        new_dp[x] += dp[x] * (n - i - 1)
        new_dp[mod_x] += dp[x]

    dp = new_dp

total = 0
for x in dp:
    total += dp[x] * x

total %= mod

print(total)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from collections import defaultdict


n, X = map(int, input().split())
s = list(map(int, input().split()))
s = sorted(s, reverse=True)

mod = 10 ** 9 + 7

dp = defaultdict(int)
dp[X] = 1

for i in range(n):
    new_dp = defaultdict(int)

    for x in dp:
        mod_x = x % s[i]
        new_dp[x] += dp[x] * (n - i - 1)
        new_dp[mod_x] += dp[x]
        print("new_dp", new_dp)

    dp = new_dp

total = 0
for x in dp:
    total += dp[x] * x

total %= mod

print(total)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from itertools import permutations
from multiprocessing import Pool
import multiprocessing as multi

n, x = map(int, input().split())
s = list(map(int, input().split()))


def process(s_l):
    xx = x
    for ss in s_l:
        if xx < ss:
            continue
        xx = xx % ss
    return xx


p = Pool(multi.cpu_count())
result = p.map(process, [s_p for s_p in permutations(s)])
p.close()

print(sum(result) % 1000000007)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from itertools import permutations
from multiprocessing import Pool
import multiprocessing as multi

n, x = map(int, input().split())
s = list(map(int, input().split()))


def process(s_l):
    xx = x
    for ss in s_l:
        if xx < ss:
            continue
        xx = xx % ss
    return xx


p = Pool(multi.cpu_count())
result = p.map(process, [s_p for s_p in permutations(s)])
p.close()

print(sum(result) % 1000000007)
Problem p03076 (python)

Fixed submission:
# -*- coding: utf-8 -*-
dct = {}
d = {}
d2 = {}
ll = [0,1,2,3,4]

for i in range(5):
    inp = int(input())
    if inp % 10 != 0:
        d[i] = inp % 10
        d2[i] = inp
        dct[i] = int(inp/10)*10+10
    else:
        dct[i] = inp

if len(d) == 0:
    ans = 0
else:
    last = sorted(d.items(), key=lambda x: x[1])[0][0]
    ll.remove(last)
    ans = d2[last]

for i in ll:
    ans += dct[i]

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
dct = {}
d = {}
d2 = {}
ll = [0,1,2,3,4]

for i in range(5):
    inp = int(input())
    if inp % 10 != 0:
        d[i] = inp % 10
        d2[i] = inp
        dct[i] = int(inp/10)*10+10
    else:
        dct[i] = inp

last = sorted(d.items(), key=lambda x: x[1])[0][0]

ll.remove(last)

ans = d2[last]

for i in ll:
    ans += dct[i]

print(ans)
Problem p03076 (python)

Fixed submission:
A, B, C, D, E = [int(input()) for _ in range(5)]

menu = [A, B, C, D, E]

time_dig = [-(-food // 10) for food in menu]
time_mod_10 = [_ % 10 for _ in menu if _ % 10 != 0]
time_mod_10.append(10)

print((sum(time_dig) - 1) * 10 + min(time_mod_10))

Buggy submission (verdict: Runtime Error):
A, B, C, D, E = [int(input()) for _ in range(5)]

menu = [A, B, C, D, E]

time_dig = [-(-food // 10) for food in menu]
time_min_mod_10 = min([_ % 10 for _ in menu if _ % 10 != 0])

print((sum(time_dig) - 1) * 10 + time_min_mod_10)
Problem p03086 (python)

Fixed submission:
S = input()

AGCT = {"A", "G", "C", "T"}

j = 0
l = 0
l_log = []

while j < len(S):
    if S[j] in AGCT:
        l += 1
        if j == len(S) - 1:
            l_log.append(l)
    else:
        l_log.append(l)
        l = 0
    j += 1

print(max(l_log))

Buggy submission (verdict: Runtime Error):
S = input()

AGCT = {"A", "G", "C", "T"}

j = 0
l = 0
l_log = []

while j < len(S):
    if S[j] in AGCT:
        j += 1
        l += 1
    else:
        l_log.append(l)
        l = 0
        j += 1

print(max(l_log))
Problem p03087 (python)

Fixed submission:
N, Q = [int(_) for _ in input().split()]
S = input()
l_r_list = [[int(_) for _ in input().split()] for _ in range(Q)]

AC_accumulation = [0]

for i in range(1, N):
    if S[i] == "C" and S[i - 1] == "A":
        AC_accumulation.append(AC_accumulation[-1] + 1)
    else:
        AC_accumulation.append(AC_accumulation[-1])


ans = []
for l, r in l_r_list:
    ans.append(str(AC_accumulation[r - 1] - AC_accumulation[l - 1]))

print("\n".join(ans))

Buggy submission (verdict: Runtime Error):
N, Q = [int(_) for _ in input().split()]
S = input()
l_r_list = [[int(_) for _ in input().split()] for _ in range(Q)]

AC_accumulation = [0]

for i in range(1, N + 1):
    if S[i] == "C":
        if S[i - 1] == "A":
            AC_accumulation.append(AC_accumulation[-1] + 1)
    else:
        AC_accumulation.append(AC_accumulation[-1])


ans = []
for l, r in l_r_list:
    ans.append(str(AC_accumulation[r - 1] - AC_accumulation[l - 1]))

print("\n".join(ans))

Buggy submission (verdict: Runtime Error):
N, Q = [int(_) for _ in input().split()]
S = input()
l_r_list = [[int(_) for _ in input().split()] for _ in range(Q)]

AC_accumulation = [0]

for i in range(1, N):
    if S[i] == "C":
        if S[i - 1] == "A":
            AC_accumulation.append(AC_accumulation[-1] + 1)
    else:
        AC_accumulation.append(AC_accumulation[-1])


ans = []
for l, r in l_r_list:
    ans.append(str(AC_accumulation[r - 1] - AC_accumulation[l - 1]))

print("\n".join(ans))
Problem p03095 (python)

Fixed submission:
N = int(input())
S = input()

mod = 10 ** 9 + 7

kind = set(S)
each_char = []

for char in kind:
    each_char.append(S.count(char))

count = 1
for i in each_char:
    count = (count % mod) * ((i + 1) % mod) % mod

print((count - 1) % mod)

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb

N = int(input())
S = input()

kind = set(S)
each_char =[]

for char in kind:
    each_char.append(S.count(char))

length = len(kind)
over_stock = len(S) - len(kind)

count = 0
for i in range(over_stock + 1):
    count += (2 ** (length - i)) * comb(over_stock, i, exact=True) % (10 ** 9 + 7)

print((count - 1) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb

N = int(input())
S = input()

kind = set(S)
each_char =[]

for char in kind:
    each_char.append(S.count(char))

length = len(kind)
over_stock = len(S) - len(kind)

count = 0
for i in range(over_stock + 1):
    count += (2 ** (length - i)) * comb(over_stock, i, exact=True)

print(count - 1)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

N = int(input())
S = input()

kind = set(S)
each_char =[]

for char in kind:
    each_char.append(S.count(char))

length = len(kind)
over_stock = len(S) - len(kind)

count = 0
for i in range(over_stock + 1):
    count += (2 ** (length - i)) * comb(over_stock, i, exact=True)

print(count - 1)
Problem p03148 (python)

Fixed submission:
N, K = [int(_) for _ in input().split()]
t_and_d = [[int(_) for _ in input().split()] for _ in range(N)]
t_and_d.sort(key=lambda x: x[1], reverse=True)

over_stock = []
type_set = set()

for t_i, d_i in t_and_d[:K]:
    if t_i in type_set:
        over_stock += [d_i]
    else:
        type_set.add(t_i)

x = len(type_set)
point = sum([d for t, d in t_and_d[:K]]) + x ** 2
point_max = point

for t_i, d_i in t_and_d[K:]:
    if over_stock:
        if t_i in type_set:
            continue
        else:
            diff = (x + 1) ** 2 - x ** 2 + d_i - over_stock.pop()
            type_set.add(t_i)
            x += 1
            point += diff
            point_max = max(point_max, point)

print(point_max)

Buggy submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
t_and_d = [[int(_) for _ in input().split()] for _ in range(N)]

t_and_d.sort(key=lambda x: x[1], reverse=True)
over_stock = []
type_set = set()

for t_i, d_i in t_and_d[:K]:
    if t_i in type_set:
        over_stock += [d_i]
    else:
        type_set.add(t_i)

x = len(type_set)
point = sum([d for t, d in t_and_d[:K]]) + x ** 2
point_max = point

if over_stock:
    for t_i, d_i in t_and_d[K:]:
        if t_i in type_set:
            continue
        else:
            diff = (x + 1) ** 2 - x ** 2 + d_i - over_stock.pop()
            type_set.add(t_i)
            x += 1
            point += diff
            point_max = max(point_max, point)

print(point_max)

Buggy submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
t_and_d = [[int(_) for _ in input().split()] for _ in range(N)]

t_and_d.sort(key=lambda x: x[1], reverse=True)
over_stock = []
type_set = set()

for t_i, d_i in t_and_d[:K]:
    if t_i in type_set:
        over_stock += [d_i]
    else:
        type_set.add(t_i)

x = len(type_set)
point = sum([d for t, d in t_and_d[:K]]) + x ** 2
point_max = point

if not over_stock:
    print(point)
    quit()

for t_i, d_i in t_and_d[K:]:
    if t_i in type_set:
        continue
    else:
        diff = (x + 1) ** 2 - x ** 2 + d_i - over_stock.pop()
        type_set.add(t_i)
        x += 1
        point += diff
        point_max = max(point_max, point)

print(point_max)

Buggy submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
t_and_d = [[int(_) for _ in input().split()] for _ in range(N)]

t_and_d.sort(key=lambda x: x[1], reverse=True)
over_stock = []
type_set = set()

for t_i, d_i in t_and_d[:K]:
    if t_i in type_set:
        over_stock += [d_i]
    else:
        type_set.add(t_i)

x = len(type_set)
point = sum([d for t, d in t_and_d[:K]]) + x ** 2
point_history = [point]

if not over_stock:
    print(point)
    quit()

for t_i, d_i in t_and_d[K:]:
    if t_i in type_set:
        continue
    else:
        diff = (x + 1) ** 2 - x ** 2 + d_i - over_stock.pop()
        type_set.add(t_i)
        x += 1
        point += diff
        point_history.append(point)

print(max(point_history))
Problem p03472 (python)

Fixed submission:
N, H = [int(_) for _ in input().split()]
katana = [[int(_) for _ in input().split()] for _ in range(N)]

katana.sort(key=lambda x:x[1], reverse=True)
a_max_katana = max(katana)

a_max = a_max_katana[0]
a_max_b = a_max_katana[1]
katana.pop(katana.index(a_max_katana))

count = 0

for katana_use in katana:
    if katana_use[1] > a_max:
        H -= katana_use[1]
        count += 1
        if H > a_max_b:
            continue
        else:
            count += 1
            break
    else:
        count += (H - a_max_b) // a_max + bool((H - a_max_b) % a_max) + 1
        break

else:
    count += (H - a_max_b) // a_max + bool((H - a_max_b) % a_max) + 1

print(count)

Buggy submission (verdict: Runtime Error):
N, H = [int(_) for _ in input().split()]
katana = [[int(_) for _ in input().split()] for _ in range(N)]

katana.sort(key=lambda x:x[1], reverse=True)
a_max_katana = max(katana)

a_max = a_max_katana[0]
a_max_b = a_max_katana[1]
a_max_index = katana.index(a_max_katana)
katana.pop(a_max_index)

count = 0
j = 0

while H > a_max_b:
    katana_use = katana[j]
    if katana_use[1] < a_max or j == N - 2:
        count += max(0, (H - a_max_b) // a_max + bool((H - a_max_b) % a_max)) + 1
        break
    else:
        H -= katana_use[1]
        count += 1
        j += 1
else:
    count += 1

print(count)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]


def lcm(a, b):
    return a * b // gcd(a, b)


def lcm_multi(nums):
    return reduce(lcm, nums)


print(lcm_multi(T))

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]


def lcm(a, b):
    return a * b // gcd(a, b)


def lcm_multi(nums):
    return reduce(lcm, nums)


print(lcm_multi(T))
Problem p03076 (python)

Fixed submission:
l=[input() for i in range(5)]
a=[0, 0, 0, 0, "9"]

for i in range(5):
  if int(a[4][-1]) >= int(l[i][-1]) and not(int(l[i][-1]) == 0):
      a[4] = l[i]

if a[4] is "9":
  a[4] = l[0]

l.remove(a[4])
l = [int(i) for i in l]
l.sort()
for j in range(4):
  while(not(int(l[j]) % 10 is 0)):
    l[j]+=1
  a[j] = int(l[j])
  
a[4] = int(a[4])
print(sum(a))

Buggy submission (verdict: Runtime Error):
l=[input() for i in range(5)]
a=[0, 0, 0, 0, "9"]

for i in range(5):
  if int(a[4][-1]) >= int(l[i][-1]) and not(int(l[i][-1]) == 0):
      a[4] = l[i]

if a[4] is 0:
  a[4] = l[0]

l.remove(a[4])
l = [int(i) for i in l]
l.sort()
for j in range(4):
  while(not(int(l[j]) % 10 is 0)):
    l[j]+=1
  a[j] = int(l[j])
  
a[4] = int(a[4])
print(sum(a))

Buggy submission (verdict: Runtime Error):
l=[input() for i in range(5)]
a=[0, 0, 0, 0, 0]
e=9
for i in range(5):
  if e >= int(l[i][-1]) and not(int(l[i][-1]) == 0):
      a[4] = l[i]

l.remove(a[4])
l = [int(i) for i in l]
for j in range(4):
  while(not(int(l[j]) % 10 is 0)):
    l[j]+=1
  a[j] = int(l[j])
a[4] = int(a[4])
print(sum(a))

Buggy submission (verdict: Runtime Error):
l=[input() for i in range(5)]
a=[0, 0, 0, 0, 0]
e=9
for i in range(5):
  if e >= int(l[i][-1]) and not(int(l[i][-1]) == 0):
      a[4] = l[i]

l.remove(a[4])
l = [int(i) for i in l]
for j in range(4):
  while(not(int(l[j]) % 10 is 0)):
    l[j]+=1
  a[j] = int(l[j])
a[4] = int(a[4])
print(sum(a))
print(a[4])
Problem p03323 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 16 23:09:00 2018

@author: sakas
"""
A, B = map(int, input().split())
if A>=9 or B>=9:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 16 23:09:00 2018

@author: sakas
"""
A = input()
B = input()
if A>=9 or B>=9:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 16 23:09:00 2018

@author: sakas
"""
A = input()
B = input()
if A>9 or B>9:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 16 23:09:00 2018

@author: sakas
"""
A,B = map(int(input()))

if A>9 or B>9:
    print(":(")
else:
    print("Yay!")
Problem p03359 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat May  5 20:54:36 2018

@author: sakas
"""

X, Y = map(int, input().split())

if X > Y:
    print(X - 1)
else:
    print(X)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May  5 20:54:36 2018

@author: sakas
"""

X = int(input().strip())
Y = int(input().strip())

if X > Y:
    print(X - 1)
else:
    print(X)
Problem p03147 (python)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
b = []
inf = 10**10
start = 0
end = 0
ans = 0

for ii in range(inf):
    if max(h) == 0:
        break

    while h[0] == 0:
        del h[0]

    for i in range(len(h)):
        if h[i] == 0:
            end = i
            #print(b)
            break
        end = len(h)
        b.append(h[i])

    #print(b)
    sa = min(b)
    b.clear()
    #print(sa)

    for j in range(end):
        h[j] = h[j] - sa
        #print(h)

    ans = ans + sa
        

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
b = []
inf = 10**10
start = 0
end = 0
ans = 0

for ii in range(inf):
    while h[0] == 0:
        del h[0]

    for i in range(len(h)):
        if h[i] == 0:
            end = i
            #print(b)
            break
        end = len(h)
        b.append(h[i])

    #print(b)
    sa = min(b)
    b.clear()
    #print(sa)

    for j in range(end):
        h[j] = h[j] - sa
        #print(h)

    ans = ans + sa
        
    if max(h) == 0:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
b = []
inf = 10**10
start = 0
end = 0
ans = 0

for ii in range(inf):
    while h[0] == 0:
        del h[0]

    for i in range(len(h)):
        if h[i] == 0:
            end = i
            #print(b)
            break
        end = len(h)
        b.append(h[i])

    #print(b)
    sa = min(b)
    b.clear()
    #print(sa)

    for j in range(end):
        h[j] = h[j] - sa
        #print(h)

    ans = ans + sa
        
    if max(h) == 0:
        break

print(ans)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input(),split())
if(a*b)%2 == 0 :
    print("Odd")

else:
    print("Even")
Problem p03493 (python)

Fixed submission:
print(input().count("1"))

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
flag = 0


for t in range(40):

    for i,j in enumerate(a):
        if j%2 == 0:
            a[i] = j/2

        else:
            flag = 1
            break

    if flag == 1:
        break

print(t)

Buggy submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
flag = 0


for t in range(40):

    for i,j in enumerate(a):
        if j%2 == 0:
            a[i] = j/2

        else:
            flag = 1
            break

    if flag == 1:
        break

print(t)

Buggy submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
flag = 0


for t in range(15):

    for i,j in enumerate(a):
        if j%2 == 0:
            a[i] = j/2

        else:
            flag = 1
            break

    if flag == 1:
        break

print(t)

Buggy submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
flag = 0


for t in range(1000):

    for i,j in enumerate(a):
        if j%2 == 0:
            a[i] = j/2

        else:
            flag = 1
            break

    if flag == 1:
        break

print(t)

Buggy submission (verdict: Runtime Error):
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Buggy submission (verdict: Runtime Error):
print(input().count(1))
Problem p03087 (python)

Fixed submission:
n, q = [int(i) for i in input().split() ]
s = input() #文字列
lr = list([])
count = [0 for i in range(n)]
for i in range(q):
    lr.append([int(i) for i in input().split() ])

ll = list([])
now = 0
for i, c in enumerate(s):
    if((c == "C") and (i>0) and (s[i-1] =="A")):
        now += 1
    count[i] = now

for i in range(q):
    ans = 0
    print(count[lr[i][1]-1] - count[lr[i][0]-1])

Buggy submission (verdict: Runtime Error):
n, q = [int(i) for i in input().split() ]
s = input() #文字列
lr = list([])
for i in range(q):
    lr.append([int(i) for i in input().split() ])

ll = list([])
for i, c in enumerate(s):
    if((c == "A") and (s[i+1] =="C")):
        ll.append(i+1)

for i in range(q):
    ans = 0
    for m in ll:
        if (m >= lr[i][0]) and (m+1 <=lr[i][1]):
            ans += 1
        elif m >= lr[i][1]:
            break
    print(ans)
Problem p03106 (python)

Fixed submission:
a, b, k = [int(i) for i in input().split() ]
i = 0
for j in range(100, 0, -1):
    if ((a%j == 0) and (b%j == 0)):
        i += 1
        if i == k:
            print(j)
            break

Buggy submission (verdict: Runtime Error):
import math
a, b, k = [int(i) for i in input().split() ]
x=math.gcd(a,b)
i = 1
for j in range(2, 101):
    if i == k:
        break
    if x % j == 0:
        x = int(x/j)
        i += 1
print(x)
Problem p03150 (python)

Fixed submission:
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
n = len(s)
if s[0:7] == search:
    print("YES")
elif (s[-7:] == search):
    print("YES")
else:
    for i in range(7):
        if s[0:i+1] == search[0:i+1]:
            #print(s[(-7+i+1):])
            #print(search[i+1:])
            if (s[(-7+i+1):] == search[i+1:]):
                ans = "YES"
                break
    print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
if s.find(search)>=0:
    print("YES")
elif:
    for i in range(7):
        x=s.find(search[0:i+1])
        print("ps=%s, ns=%s, reduce=%s" %(search[0:i+1], search[i+1:], s[x+i+1:]))
        if x == -1:
            break
        if x == 0:
            if s[x+i:].find(search[i+1:])>=0:
                ans = "YES"
                break
    print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
for c in s:
    if c == search[idx]:
        idx += 1
    if idx >= 7:
        flg=True
        break
if flg:
    idx = -1
    for i in range(7):
        x=s.find(search[0:i])
        #print("ps=%s, ns=%s, reduce=%s" %(search[0:i], search[i+1:], s[x+i+i:]))
        if s[x+i+1:].find(search[i+1:]):
            ans = "YES"
            break
    print(ans)
else:
    print(ans)
~

Buggy submission (verdict: Runtime Error):
s = input()
search="keyence"
idx=0
ans="NO"
for c in s:
    if c == search[idx]:
        idx += 1
    if idx >= 7:
        ans = "YES"
print(ans)
Problem p03156 (python)

Fixed submission:
n=int(input())
a,b = list(map(int, input().split()))
p = list(map(int, input().split()))

q = list([0,0,0])
for i in p:
    if i <= a:
        q[0] += 1
    elif i > b:
        q[2] += 1
    else:
        q[1] +=1

print(min(q))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=int(input())
w=int(input())

print((n-h+1)*(n-w+1))
Problem p03078 (python)

Fixed submission:
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()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
SUM=[]
for i in range(X):
  for j in range(Y):
    for k in range(Z):
      if (i+1)*(j+1)*(k+1)<=K:
        SUM.append(A[i]+B[j]+C[k])
      else:
        break
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])

Buggy submission (verdict: Runtime Error):
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()]
A_B=[]
SUM=[]
for i in range(X):
  for j in range(Y):
    A_B.append(A[i]+B[j])
A_B.sort(reverse=True)
for i in range(K):
  for j in range(Z):
    SUM.append(A_B[i]+C[j])
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])

Buggy submission (verdict: Runtime Error):
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()]
C.sort(reverse=True)
A_B=[]
SUM=[]
for i in range(X):
  for j in range(Y):
    A_B.append(A[i]+B[j])
A_B.sort(reverse=True)
for i in range(K):
  for j in range(min(K,Z)):
    SUM.append(A_B[i]+C[j])
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])

Buggy submission (verdict: Runtime Error):
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()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
A_B=[]
SUM=[]
for i in range(min(K,X)):
  for j in range(min(K,Y)):
    A_B.append(A[i]+B[j])
A_B.sort(reverse=True)
for i in range(min(K,X,Y)):
  for j in range(min(K,Z)):
    SUM.append(A_B[i]+C[j])
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])

Buggy submission (verdict: Runtime Error):
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()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
SUM=[]
for a in A:
  for b in B:
    for c in C:
      SUM.append(a+b+c)
      if c < A[min(20,X-1)] or c < B[min(20,Y-1)]:
        break
    if b < A[min(20,X-1)] or b < C[min(20,Z-1)]:
      break
  if a < B[min(20,Y-1)] or a < C[min(20,Z-1)]:
      break
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])

Buggy submission (verdict: Runtime Error):
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()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
SUM=[]
for a in A:
  for b in B:
    for c in C:
      SUM.append(a+b+c)
      if c < A[min(60,X-1)] or c < B[min(60,Y-1)]:
        break
    if b < A[min(60,X-1)] or b < C[min(60,Z-1)]:
      break
  if a < B[min(60,Y-1)] or a < C[min(60,Z-1)]:
      break
SUM.sort(reverse=True)
for i in range(K):
  print(SUM[i])