Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())

for k in range(1,N):
    ans = 0
    for i in range(1,N):
        for j in range(i,N+1):
            min_dis = min((j-i), abs(X-i)+1+abs(j-Y))
            if min_dis == k:
                ans += 1
    print(ans)





Fixed submission:
N, X, Y = map(int, input().split())

memo = [0] *(N)

for i in range(1, N):
    for j in range(i, N + 1):
        min_dis = min((j - i), abs(X - i) + 1 + abs(j - Y))
        memo[min_dis] += 1

for k in range(1,N):
    print(memo[k])

Buggy python submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())

import numpy as np
from scipy.sparse.csgraph import shortest_path

M = np.zeros((N,N))

for i in range(1,N):
    M[i-1][i] = 1
    M[i][i-1] = 1
    M[X-1][Y-1] = 1
    M[Y-1][X-1] = 1

M_diff = shortest_path(M)

for i in range(1,N):
    ans = 0
    for k in range(0,N):
        for l in range(0,N):
            if int(M_diff[k][l]) == i:
                ans += 1
    print(int(ans/2))


Fixed submission:
N, X, Y = map(int, input().split())

memo = [0] *(N)

for i in range(1, N):
    for j in range(i, N + 1):
        min_dis = min((j - i), abs(X - i) + 1 + abs(j - Y))
        memo[min_dis] += 1

for k in range(1,N):
    print(memo[k])
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map( int, input().split())

amr = []
for x in range(l,r+1):
    amr.append(x%2019)
# print(amr)
amr = list(set(amr))
ij_mod = []
for i in range(len(amr)-1):
    for j in range(i+1,len(amr)):
        ij_mod.append((amr[i]*amr[j])%2019)
print(min(ij_mod))




Fixed submission:
l, r = map( int, input().split())

amr = []
for x in range(l,r+1):
    if len(amr) >= 2019:
        break
    amr.append(x%2019)
# print(amr)
amr = list(set(amr))
ij_mod = []
for i in range(len(amr)-1):
    for j in range(i+1,len(amr)):
        ij_mod.append((amr[i]*amr[j])%2019)
print(min(ij_mod))

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map( int, input().split())

amr = []
for x in range(l,r+1):
    amr.append(x%2019)
# print(amr)
ij_mod = []
for i in range(len(amr)-1):
    for j in range(i+1,len(amr)):
        ij_mod.append((amr[i]*amr[j])%2019)
print(min(ij_mod))




Fixed submission:
l, r = map( int, input().split())

amr = []
for x in range(l,r+1):
    if len(amr) >= 2019:
        break
    amr.append(x%2019)
# print(amr)
amr = list(set(amr))
ij_mod = []
for i in range(len(amr)-1):
    for j in range(i+1,len(amr)):
        ij_mod.append((amr[i]*amr[j])%2019)
print(min(ij_mod))
Buggy python submission (verdict: Runtime Error):
import math
#負けを考える

n, k = map(int, input().split())
if k == 1:
    p = 1
    print(p)
else:
    h = math.floor(math.log2(k - 1))

    p = 0

    s = [k - 1]
    for i in range(h):
        s.append(math.floor((k - 1) / (2 ** (i + 1))))
    s = s[::-1]
    t = [s[0]]
    for j in range(h):
        t.append(s[j + 1] - s[j])

    t = t[::-1]
    for i in range(len(t)):
        p += t[i] * ((1 / 2) ** (i + 1)) * (1 / n)

    p += (n + 1 - k) / n

    print(p)





Fixed submission:
n, k = map(int, input().split())

ans = 0

for i in range(1,n+1):
    t = 1
    while i * t < k:
        t *= 2
    ans += 1 / t

print(ans / n)

Buggy python submission (verdict: Runtime Error):
import math
#負けを考える

n, k = map(int, input().split())
h = math.floor(math.log2(k-1))

p = 0

s = [k-1]
for i in range(h):
    s.append(math.floor((k-1) / (2**(i+1))))
s = s[::-1]
t = [s[0]]
for j in range(h):
    t.append(s[j+1] - s[j])

t = t[::-1]
for i in range(len(t)):
    p += t[i] * ((1/2)**(i+1)) * (1/n)

p += (n+1-k)/n

print(p)





Fixed submission:
n, k = map(int, input().split())

ans = 0

for i in range(1,n+1):
    t = 1
    while i * t < k:
        t *= 2
    ans += 1 / t

print(ans / n)
Buggy python submission (verdict: Runtime Error):
from collections import deque

h, w = map(int, input().split())

maze = [list(input()) for _ in range(h)]
step = [[0] * w for _ in range(h)]
direction = [[1,0],[-1,0],[0,1],[0,-1]]

def bfs(maze,h,w):
    start = [0,0]
    #キューで座標保存
    q = deque([start])
    while q:
        x, y = q.popleft()
        for d in direction:
            nx = x + d[0]
            ny = y + d[1]
            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == "." and step[nx][ny] == 0:
                q.append([nx,ny])
                step[nx][ny] = step[x][y] + 1
        if step[h-1][w-1] != 0:
            return step[h-1][w-1]

#壁の数
wall = 0
for i in maze:
    for j in i:
        if j == "#":
            wall += 1

ans = h * w - wall - (bfs(maze,h,w) + 1)
print(ans)


Fixed submission:
from collections import deque

h, w = map(int, input().split())

maze = [list(input()) for _ in range(h)]
step = [[0] * w for _ in range(h)]
direction = [[1,0],[-1,0],[0,1],[0,-1]]

def bfs(maze,h,w):
    start = [0,0]
    #キューで座標保存
    q = deque([start])
    while q:
        x, y = q.popleft()
        for d in direction:
            nx = x + d[0]
            ny = y + d[1]
            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == "." and step[nx][ny] == 0:
                q.append([nx,ny])
                step[nx][ny] = step[x][y] + 1
        if step[h-1][w-1] != 0:
            return step[h-1][w-1]
    return -1

#壁の数
wall = 0
for i in maze:
    for j in i:
        if j == "#":
            wall += 1
if bfs(maze,h,w) >= 0:
    ans = h * w - wall - (bfs(maze,h,w) + 1)
else:
    ans = -1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
print("Even" if (a*b)//2 == 0 else "Odd")


Fixed submission:
a,b = map(int, input().split())
print("Even" if ( a * b ) % 2 == 0 else "Odd")
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

Num = 0
for i in range(N+1):
    list = [int(a) for a in list(str(i))]
    if sum(list) >= A and sum(list) <= B:
        Num += 1



Fixed submission:
N, A, B = map(int, input().split())

Num = 0
for i in range(1, N+1):
    List = [int(a) for a in list(str(i))]
    if A <= sum(List) <= B:
        Num += i

print(Num)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect as bs

n = int(input())

a_l = list(map(int, input().split()))
b_l = list(map(int, input().split()))
c_l = list(map(int, input().split()))

a_l.sort()
b_l.sort()
c_l.sort()

ans = 0
for i in range(n):
    index_1 = bs.bisect_right(b_l,a_l[i])
    for j in range(index_1,n):
        index_2 = bs.bisect_right(c_l,b_l[j])
        ans += (n-index_2)
print(ans)


Fixed submission:
import bisect as bs

n = int(input())

a_l = list(map(int, input().split()))
b_l = list(map(int, input().split()))
c_l = list(map(int, input().split()))

a_l.sort()
b_l.sort()
c_l.sort()

ans = 0
for b in b_l:
    ans += bs.bisect_left(a_l,b) * (n-bs.bisect_right(c_l,b))
print(ans)


'''
以下の方法だと、N*logN*logN
for i in range(n):
    index_1 = bs.bisect_right(b_l,a_l[i])
    for j in range(index_1,n):
        index_2 = bs.bisect_right(c_l,b_l[j])
        ans += (n-index_2)
print(ans)
'''
Buggy python submission (verdict: Runtime Error):
def mss(l,length,k):
    x = 0
    for i in range(length):
        temp = 0
        for j in range(i,i+k-1):
            temp += l[j]
            if temp > x:
                x = temp
    return x

if __name__ == '__main__':
    N,K = map(int,input().split())
    P = [int(p)-1 for p in input().split()]
    C = [int(c) for c in input().split()]
    #閉路の探索
    L_close = []
    Done = [0] * N
    for i in range(N):
        if Done[i] == 1:
            continue
        score = []
        #start
        Done[i] = 1
        #Next
        p = P[i]
        Done[p] = 1
        score.append(C[p])
        while p != i:
            p = P[p]
            Done[p] = 1
            score.append(C[p])
        L_close.append(score)
    #それぞれの閉路に対して
    ans = 0
    for l in L_close:
        total = sum(l)
        length = len(l)
        l = l + l
        if total <= 0:
            ans = max(ans,mss(l,length,K))
        else:
            ans = max(ans,total * (K//length) + mss(l,length,K%length))
    print(ans)

Fixed submission:
def mss(l,length,k):
    x = - 1000000001
    for i in range(length):
        temp = 0
        for j in range(i,i+k):
            temp += l[j]
            if temp > x:
                x = temp
    return x
  
def mss2(l,length,total,k):
    x = - 1000000001
    if k <= length:
      for i in range(length):
          temp = 0
          for j in range(i,i+k):
              temp += l[j]
              if temp > x:
                  x = temp
      return x
    else:
      for i in range(length):
          temp = 0
          for j in range(i,i+length):
              temp += l[j]
              r = j - i + 1
              if temp + (total * ((k-r) // length)) > x:
                  x = temp + (total * ((k-r) // length))
      return x
      

if __name__ == '__main__':
    N,K = map(int,input().split())
    P = [int(p)-1 for p in input().split()]
    C = [int(c) for c in input().split()]
    #閉路の探索
    L_close = []
    Done = [0] * N
    for i in range(N):
        if Done[i] == 1:
            continue
        score = []
        #start
        Done[i] = 1
        #Next
        p = P[i]
        Done[p] = 1
        score.append(C[p])
        while p != i:
            p = P[p]
            Done[p] = 1
            score.append(C[p])
        L_close.append(score)
    #それぞれの閉路に対して
    ans = - 1000000001
    for l in L_close:
        total = sum(l)
        length = len(l)
        l = l + l
        if total <= 0:
            ans = max(ans,mss(l,length,min(K,length)))
        else:
            ans = max(ans,mss2(l,length,total,K))
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

def cut(l,A,K):
    counter = 0
    i = N - 1
    while i >= 0:
        c = A[i] // l
        if c == 0:
            break
        else:
            counter += c
            i -= 1
    if counter <= K:
        return True
    else:
        return False
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    A = [float(a) for a in input().split()]
    A.sort()
    left = 2
    right = math.ceil(A[-1])
    while left <= right:
        middle = (left + right) // 2
        if not cut(middle,A,K):
            left = middle + 1
        else:
            if not cut(middle-1,A,K):
                break
            else:
                right = middle - 1
    print(middle)

Fixed submission:
import math

def cut(l,A,K):
    counter = 0
    i = N - 1
    if l == 0:
        return False
    while i >= 0:
        c = math.ceil(A[i] / l) - 1
        if c == 0:
            break
        else:
            counter += c
            i -= 1
    if counter <= K:
        return True
    else:
        return False
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    A = [float(a) for a in input().split()]
    A.sort()
    left = 0
    right = math.ceil(A[-1])
    while left <= right:
        middle = (left + right) // 2
        if cut(middle,A,K):
            if not cut(middle-1,A,K):
                break
            else:
                right = middle - 1
        else:
            left = middle + 1
    print(middle)

Buggy python submission (verdict: Runtime Error):
import math

def cut(l,A,K):
    counter = 0
    i = N - 1
    while i >= 0:
        c = A[i] // l
        if c == 0:
            break
        else:
            counter += c
            i -= 1
    if counter <= K:
        return True
    else:
        return False
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    A = [float(a) for a in input().split()]
    A.sort()
    left = 2
    right = math.ceil(A[-1])
    while left <= right:
        middle = (left + right) // 2
        print(left,right,middle)
        if not cut(middle,A,K):
            left = middle + 1
        else:
            if not cut(middle-1,A,K):
                break
            else:
                right = middle - 1
    print(middle)

Fixed submission:
import math

def cut(l,A,K):
    counter = 0
    i = N - 1
    if l == 0:
        return False
    while i >= 0:
        c = math.ceil(A[i] / l) - 1
        if c == 0:
            break
        else:
            counter += c
            i -= 1
    if counter <= K:
        return True
    else:
        return False
    
if __name__ == '__main__':
    N,K = map(int,input().split())
    A = [float(a) for a in input().split()]
    A.sort()
    left = 0
    right = math.ceil(A[-1])
    while left <= right:
        middle = (left + right) // 2
        if cut(middle,A,K):
            if not cut(middle-1,A,K):
                break
            else:
                right = middle - 1
        else:
            left = middle + 1
    print(middle)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    l = []
    S = []; X = []; Y = []; P = []
    ans = 0
    for _ in range(N):
        x,y,p = map(int,input().split())
        s = p * min(abs(x),abs(y))
        ans += s
        S.append(s)
        X.append(x); Y.append(y); P.append(p)
    print(ans)
    l_S = []
    for i in range(N*2):
        if i < N:
            x = X[i]
            S_temp = []
            temp = 0
            for j in range(N):
                m = min(S[j],P[j] * (abs(X[j]-x)))
                S_temp.append(m)
                temp += m
            if ans > temp:
                 ans = temp
        else:
            y = Y[i-N]
            S_temp = []
            temp = 0
            for j in range(N):
                m = min(S[j],P[j] * (abs(Y[j]-y)))
                S_temp.append(m)
                temp += m
            if ans > temp:
                 ans = temp
        l_S.append(S_temp)
    print(ans)
    memo = [n for n in range(2 * N)]
    l_S0 = l_S
    for _ in range(N-1):
        if ans == 0:
          print(0)
          continue
        l_S1 = []
        newMemo = []
        for j in range(len(l_S0)):
            for k in range(memo[j]+1, N * 2):
                l = l_S[k]
                l0 = l_S0[j]
                S_temp = []
                temp = 0
                for h in range(N):
                    m = min(l[h],l0[h])
                    S_temp.append(m)
                    temp += m
                if ans > temp:
                     ans = temp
                l_S1.append(S_temp)
                newMemo.append(k)
        memo = newMemo
        l_S0 = l_S1
        print(ans)

Fixed submission:
X = int(input())
print(8 - ((X-400)//200))
Buggy python submission (verdict: Runtime Error):
#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
T = []
for _ in range(D):
    t = int(input()) - 1
    T.append(t)
    
＃スコア計算
score = 0
last_day = [-1] * 26
for t in range(D):
    test = T[t]
    score += S[t][test]
    last_day[test] = t
    for i in range(26):
        score -= (C * (t - last_day[i]))
    print(score)

Fixed submission:
#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
T = []
for _ in range(D):
    t = int(input()) - 1
    T.append(t)
    
#スコア計算
score = 0
last_day = [-1] * 26
for t in range(D):
    test = T[t]
    score += S[t][test]
    last_day[test] = t
    for i in range(26):
        score -= (C[i] * (t - last_day[i]))
    print(score)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
for i in range(M):
    print(str(i+1) + ' ' + str(N-i-1))


Fixed submission:
K = int(input())
A,B = map(int,input().split())
k = (B // K) * K
if A <= k and k <= B:
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in range(N):
    x = input()
    if len(l) == 0:
        l.append(x)
    else:
        good = True
        for j in range(len(l)):
            if x == l[j]:
                good = False
                break
        if good:
            l.append(x)
print(len(l))


Fixed submission:
import collections

N = int(input())
l = [input() for i in range(N)]
print(len(collections.Counter(l)))

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(N):
    x = input()
    if len(l) == 0:
        l.append(x)
    else:
        good = True
        for j in range(len(l)):
            if x == l[j]:
                good = False
                break
        if good:
            l.append(x)
print(c)


Fixed submission:
import collections

N = int(input())
l = [input() for i in range(N)]
print(len(collections.Counter(l)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
c = 0
for i in range(N):
    x = input()
    if c == 0:
        l.append(x)
        c += 1
    else:
        good = True
        for j in range(c):
            if x == l[j]:
                good = False
        if good:
            l.append(x)
            c += 1
print(c)


Fixed submission:
import collections

N = int(input())
l = [input() for i in range(N)]
print(len(collections.Counter(l)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
counter = 0
for i in range((len(a)+1)//2):
  if a[i*2]%2 == 1:
    counter += 1
print(counter)

Fixed submission:
R,L,d = map(int, input().split())
counter = 0
for i in range(R, L+1):
  if i%d == 0:
    counter += 1
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
n = round(N**0.5)
counter = 0
for g in range(1,N+1):
  for i in range(1,n+1):
    for j in range(1,n+1):
      for k in range(1,n+1):
        if i**2+j**2+k**2+i*j+j*k+k*i == g:
          counter += 1
  print(counter)
  counter = 0

Fixed submission:
N = int(input())
n = round(N**0.5)
counter = [0]*N
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      f = i**2+j**2+k**2+i*j+j*k+k*i
      if f <= N:
        counter[f-1] += 1
for i in range(N):
  print(counter[i])
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
if a>= 13:
    print(B)
elif a>=6:
    print(B//2)
else:
    print(0)

Fixed submission:
A,B = map(int, input().split())
if A>= 13:
    print(B)
elif A>=6:
    print(B//2)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a_list = [int(a) for a in input().split()]
a_list.sort()
bc_list = [0 for _ in range(m)]
for i in range(m):
    b,c = map(int, input().split())
    bc_list[i] = [b,c]
bc_list.sort(key= lambda x:x[1],reverse=True)
cur = 0
for i in range(m):
    b,c = bc_list[i][0],bc_list[i][1]
    for j in range(b):
        if a_list[cur]>=c or cur>=n:
            break
        else:
            a_list[cur] = c
            cur += 1
    else:
        continue
    break
print(sum(a_list))

Fixed submission:
n,m = map(int, input().split())
a_list = [int(a) for a in input().split()]
a_list.sort()
bc_list = [0 for _ in range(m)]
for i in range(m):
    b,c = map(int, input().split())
    bc_list[i] = [b,c]
bc_list.sort(key= lambda x:x[1],reverse=True)
cur = 0
for i in range(m):
    b,c = bc_list[i][0],bc_list[i][1]
    for j in range(b):
        if cur >= n:
            break
        if a_list[cur]>=c:
            break
        else:
            a_list[cur] = c
            cur += 1
    else:
        continue
    break
print(sum(a_list))

Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a_list = [int(a) for a in input().split()]
a_list.sort()
bc_list = [0 for _ in range(m)]
for i in range(m):
    b,c = map(int, input().split())
    bc_list[i] = [b,c]
bc_list.sort(key= lambda x:x[1],reverse=True)
cur = 0
for i in range(m):
    b,c = bc_list[i][0],bc_list[i][1]
    for j in range(b):
        if a_list[cur]>=c:
            break
        else:
            a_list[cur] = c
            cur += 1
    else:
        continue
    break
print(sum(a_list))

Fixed submission:
n,m = map(int, input().split())
a_list = [int(a) for a in input().split()]
a_list.sort()
bc_list = [0 for _ in range(m)]
for i in range(m):
    b,c = map(int, input().split())
    bc_list[i] = [b,c]
bc_list.sort(key= lambda x:x[1],reverse=True)
cur = 0
for i in range(m):
    b,c = bc_list[i][0],bc_list[i][1]
    for j in range(b):
        if cur >= n:
            break
        if a_list[cur]>=c:
            break
        else:
            a_list[cur] = c
            cur += 1
    else:
        continue
    break
print(sum(a_list))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
a_list = [int(a) for a in input().split()]
a_list.sort()
for i in range(m):
    b,c = map(int, input().split())
    for j in range(b):
        if a_list[j]<c:
            a_list[j] = c
        else:
            break
    a_list.sort()
print(sum(a_list))

Fixed submission:
n,m = map(int, input().split())
a_list = [int(a) for a in input().split()]
a_list.sort()
bc_list = [0 for _ in range(m)]
for i in range(m):
    b,c = map(int, input().split())
    bc_list[i] = [b,c]
bc_list.sort(key= lambda x:x[1],reverse=True)
cur = 0
for i in range(m):
    b,c = bc_list[i][0],bc_list[i][1]
    for j in range(b):
        if cur >= n:
            break
        if a_list[cur]>=c:
            break
        else:
            a_list[cur] = c
            cur += 1
    else:
        continue
    break
print(sum(a_list))
Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)
total_list = [0 for _ in range(min(106307,X*Y*Z))]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                total_list[i*(Z*Y)+j*Z+k] = (a_list[i] + b_list[j] + c_list[k])
            else:
                break
total_list =  sorted(total_list, reverse = True)
for i in range(K):
    print(total_list[i])

Fixed submission:
a = int(input())
_ = int(input())
_ = int(input())
_ = int(input())
b = int(input())
k = int(input())
if b-a<=k:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_list.sort(reverse = True)
b_list.sort(reverse = True)
c_list.sort(reverse = True)
total_list = [0 for _ in range(min(106307,X*Y*Z))]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                total_list[i*(Z*Y)+j*Z+k] = (a_list[i] + b_list[j] + c_list[k])
            else:
                break
total_list =  sorted(total_list, reverse = True)
for i in range(K):
    print(total_list[i])

Fixed submission:
N,A,B,C,D,E = [int(input()) for _ in range(6)]
times = [A,B,C,D,E]
for i in range(4):
    if times[i] < times[i+1]:
        times[i+1] = times[i]
A,B,C,D,E = times
l = -(-N//A)
m = -(-(N - (l-1)*B)//B)
n = -(-(N - (l+m-2)*C)//C)
p = -(-(N - (l+m+n-3)*D)//D)
q = -(-(N - (l+m+n+p-4)*E)//E)
print(l+m+n+p+q)

Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]
a_b_total = [0 for _ in range(X*Y)]
for i in range(X):
    for j in range(Y):
        a_b_total[i*Y+j] = a_list[i] + b_list[j]
a_b_total.sort(reverse = True)
a_b_c_total = [0 for _ in range(min(K,X*Y)*Z)]
for i in range(min(K,X*Y)):
    for j in range(Z):
        a_b_c_total[i*Z+j] = a_b_total[i] + c_list[j]
a_b_c_total.sort(reverse = True)
for i in range(K):
    print(a_b_c_total[i])

Fixed submission:
N,A,B,C,D,E = [int(input()) for _ in range(6)]
times = [A,B,C,D,E]
for i in range(4):
    if times[i] < times[i+1]:
        times[i+1] = times[i]
A,B,C,D,E = times
l = -(-N//A)
m = -(-(N - (l-1)*B)//B)
n = -(-(N - (l+m-2)*C)//C)
p = -(-(N - (l+m+n-3)*D)//D)
q = -(-(N - (l+m+n+p-4)*E)//E)
print(l+m+n+p+q)