Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#for  _ in range(int(input())):
    #n, k = map(int, input().split())

n = int(input())

arr = list(map(int, input().split()))
ans=1
i=0
j=n-1
while i<=j:
    if i==j:
        ans=ans*arr[i]
    else:

        ans=ans*arr[i]*arr[j]
    j-=1
    i+=1

if ans>10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
#for  _ in range(int(input())):
    #n, k = map(int, input().split())

n = int(input())

arr = list(map(int, input().split()))
arr.sort()
if arr[0]==0:
    print(0)
else:
    arr=arr[::-1]
    ans=1
    for i in range(n):
        ans*=arr[i]
        if ans>10**18:
            ans=-1
            break
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#for  _ in range(int(input())):
    #n, k = map(int, input().split())

n = int(input())

arr = list(map(int, input().split()))
ans=1
for i in range(n):
    ans=ans*arr[i]
if ans>10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
#for  _ in range(int(input())):
    #n, k = map(int, input().split())

n = int(input())

arr = list(map(int, input().split()))
arr.sort()
if arr[0]==0:
    print(0)
else:
    arr=arr[::-1]
    ans=1
    for i in range(n):
        ans*=arr[i]
        if ans>10**18:
            ans=-1
            break
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

def input():
    return sys.stdin.readline().strip()


n,k=map(int,input().split())
cst=list(map(int,input().split()))
arr=[0]*n
arr[1]=abs(cst[1]-cst[0])
for i in range(2, n):
    arr[i]=min(abs(cst[j]-cst[i])+arr[j] for j in  range(max(i-k,0),i))
print(arr[n-1])

#print(arr)

Fixed submission:
n=int(input())
cst=list(map(int,input().split()))
arr=[0]*10**5
arr[0]=0
arr[1]=abs(cst[1]-cst[0])
if n==2:
    print(arr[1])
else:
    for i in range(2, n):
        arr[i] = min(abs(cst[i - 1] - cst[i]) + arr[i - 1], abs(cst[i - 2] - cst[i]) + arr[i - 2])
    print(arr[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())
inputs = [int(i) for i in input().split()]

for i in range(1, N):
    if inputs[i-1] > inputs[i] and inputs[i-1] >= 1:
        inputs[i-1] -= 1

if inputs[-1] < inputs[-2] and inputs[-1] >= 1:
    inputs[-2] -= 1

for i in range(1, N):
    if inputs[i-1] > inputs[i]:
        print('No')
        break
else:
    print('Yes')

Fixed submission:
N = int(input())
inputs = [int(i) for i in input().split()]

for i in range(N-1, 1, -1):
    if inputs[i-1] > inputs[i]:
        inputs[i-1] -= 1

for i in range(1, N):
    if inputs[i-1] > inputs[i]:
        print('No')
        break
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = int(matn.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)

Fixed submission:
import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = math.ceil(math.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

S = int(input())

ans = [0, 0]
seki = S + 10 ** 9
for i in range(10 ** 4, 10**9):
    div = seki % i
    if div == 0:
        if seki // i > 10 ** 9:
            continue
        ans += [i, 1, 10 ** 9, seki // i]
        print(*ans)
        exit()


Fixed submission:
import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = math.ceil(math.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

S = int(input())

ans = [0, 0]
seki = S + 10 ** 6
for i in range(1, 10**9):
    div = seki % i
    if div == 0:
        if seki // i > 10 ** 9:
            continue
        ans += [i, 1, 10 ** 6, seki // i]
        print(*ans)
        exit()


Fixed submission:
import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = math.ceil(math.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)

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

S = int(input())

ans = [0, 0]
limit = 10 ** 9
seki = S + 10 ** 6
for i in range(1, 10**9):
    div = seki % j
    if div == 0:
        if j > limit or seki // j > limit:
            continue
        ans += [j, 1, 10 ** 9, seki // j]
        print(*ans)
        exit()


Fixed submission:
import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = math.ceil(math.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

S = int(input())

ans = [0, 0]
limit = 10 ** 9
for i in range(1, 10**9):
    seki = S + i ** 2
    for j in range(1, 10**9):
        div = seki % j
        if div == 0:
            if j > limit or seki // j > limit:
                continue
            ans += [j, i, i, seki // j]
            print(*ans)
            exit()


Fixed submission:
import math

S = int(input())

ans = [0, 0]
if S <= 10 ** 9:
    ans += [S, 0, 0, 1]
else:
    root = math.ceil(math.sqrt(S))
    ans += [root ** 2 - S, root, root, 1]

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
inputs = [int(input()) for _ in range(N)]

for i in range(N):
    sorted_inputs = sorted(inputs, reverse=True)
    if sorted_inputs[0] == inputs[i]:
        print(sorted_inputs[1])
    else:
        print(sorted_inputs[0])


Fixed submission:
N = int(input())
inputs = [int(input()) for _ in range(N)]

sorted_inputs = sorted(inputs, reverse=True)
for i in range(N):
    if sorted_inputs[0] == inputs[i]:
        print(sorted_inputs[1])
    else:
        print(sorted_inputs[0])
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

mod = 2019
ans = 10 ** 7
results = [False for _ in range(2019)]
for low in range(L, R+1):
    for up in range(low+1, R+1):
        ans = min(ans, low * up % mod)
        results[low * up % mod] = True
        if all(results):
            print(ans)
            exit()
print(ans)


Fixed submission:
L, R = map(int, input().split())

mod = 2019
ans = 10 ** 7
results = [False for _ in range(2019)]
for low in range(L, R+1):
    for up in range(low+1, R+1):
        ans = min(ans, low * up % mod)
        if ans == 0:
            print(ans)
            exit()
        # results[low * up % mod] = True
        # if all(results):
        #     print(ans)
        #     exit()
print(ans)

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

mod = 2019
ans = 10 ** 7
for low in range(L, R+1):
    for up in range(low+1, R+1):
        ans = min(ans, low * up % mod)

print(ans)


Fixed submission:
L, R = map(int, input().split())

mod = 2019
ans = 10 ** 7
results = [False for _ in range(2019)]
for low in range(L, R+1):
    for up in range(low+1, R+1):
        ans = min(ans, low * up % mod)
        if ans == 0:
            print(ans)
            exit()
        # results[low * up % mod] = True
        # if all(results):
        #     print(ans)
        #     exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) # 奇数
inputs = [int(i) for i in input().split()]

double_inputs = list(map(lambda x: x * 2, inputs))
ans = [0 for _ in range(N)]
for i in range(N):
    total = sum(inputs)
    if i == 0:
        for j in range((N - 1) // 2):
            total -= double_inputs[(i+1+2*j)%N]
            ans[i] = total
    elif i == N - 1:
        ans[i] = double_inputs[-1] - ans[0]
    else:
        ans[i] = double_inputs[i-1] - ans[i-1]

print(' ' .join(map(str, ans)))


Fixed submission:
N = int(input()) # 奇数
inputs = [int(i) for i in input().split()]

double_inputs = list(map(lambda x: x * 2, inputs))
ans = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        ans[i] = sum(inputs) - sum(double_inputs[1::2])
    elif i == N - 1:
        ans[i] = double_inputs[-1] - ans[0]
    else:
        ans[i] = double_inputs[i-1] - ans[i-1]

print(' ' .join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) # 奇数
inputs = [int(i) for i in input().split()]

double_inputs = list(map(lambda x: x * 2, inputs))
for i in range(N):
    total = sum(inputs)
    for j in range((N - 1) // 2):
        total -= double_inputs[(i+1+2*j)%N]
    print(total)

Fixed submission:
N = int(input()) # 奇数
inputs = [int(i) for i in input().split()]

double_inputs = list(map(lambda x: x * 2, inputs))
ans = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        ans[i] = sum(inputs) - sum(double_inputs[1::2])
    elif i == N - 1:
        ans[i] = double_inputs[-1] - ans[0]
    else:
        ans[i] = double_inputs[i-1] - ans[i-1]

print(' ' .join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

N, K = map(int, input().split())

mod = 10 ** 9 + 7

def compute(x, y):
    return comb(x-1, y-1, exact=True)

for i in range(1, K+1):
    blue = compute(K, i)
    red_count = N - K
    red = compute(red_count, i-1) + 2 * compute(red_count, i) + compute(red_count, i+1)
    print(blue * red % mod)


Fixed submission:
from scipy.misc import comb

N, K = map(int, input().split())

mod = 10**9 + 7

for i in range(1, K+1):
    blue = comb(K-1, i-1, exact=True)
    red_count = N - K
    red = comb(red_count+1, i, exact=True)
    print(blue * red % mod)
Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

ans = [min(x, W - x) * H, min(y, H - y) * W]

if (x == 0 and y == 0) or (x == W and y == 0) or (x == 0 and y == H) or (x == W and y == H):
    print(W * H / 2, 0)
elif y / x == H / W:
    if x == W / 2 and y == H / 2:
        print(W * H / 2, 1)
    else:
        print(W * H / 2, 0)
else:
    print(max(ans), int(ans[0] == ans[1]))


Fixed submission:
W, H, x, y = map(int, input().split())

print(W * H / 2, 1 if W / 2 == x and H / 2 == y else 0)

Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

ans = [min(x, W - x) * H, min(y, H - y) * W]

if y / x == H / W:
    print(W * H / 2, 1)
elif (x == 0 and y == 0) or (x == W and y == 0) or (x == 0 and y == H) or (x == W and y == H):
    print(W * H / 2, 0)
else:
    print(max(ans), int(ans[0] == ans[1]))


Fixed submission:
W, H, x, y = map(int, input().split())

print(W * H / 2, 1 if W / 2 == x and H / 2 == y else 0)

Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

ans = [min(x, W - x) * H, min(y, H - y) * W]

if (x == 0 and y == 0) or (x == 1 and y == 0) or (x == 0 and y == 1) or (x == 1 and y == 1):
    print(W * H / 2, 0)
elif W == 
else:
    print(max(ans), int(ans[0] == ans[1]))


Fixed submission:
W, H, x, y = map(int, input().split())

print(W * H / 2, 1 if W / 2 == x and H / 2 == y else 0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
inputs = [[int(i) for i in input().split()] for _ in range(N)]

ans = 1
rates = {}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        vector = (inputs[i][0] - inputs[j][0], inputs[i][1] - inputs[j][1])
        rates[vector] = rates.get(vector, 0) + 1

print(N - max(rates.values()))


Fixed submission:
N = int(input())
inputs = [[int(i) for i in input().split()] for _ in range(N)]

ans = 1
rates = {0: 0}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        vector = (inputs[i][0] - inputs[j][0], inputs[i][1] - inputs[j][1])
        rates[vector] = rates.get(vector, 0) + 1

print(N - max(rates.values()))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
inputs = [int(input()) for _ in range(M)]

mod = 10 ** 9 + 7
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1, N+1):
    if i in inputs:
        continue
    if i == 1:
        dp[i] = dp[i-1]
    else:
        if i - 1 not in inputs:
            dp[i] += dp[i-1]
        if i - 2 not in inputs:
            dp[i] += dp[i-2]

print(dp[-1] % mod)


Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
inputs = [int(input()) for _ in range(M)]

set_inputs = set(inputs)
mod = 10 ** 9 + 7
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1, N+1):
    if i in set_inputs:
        continue
    if i == 1:
        dp[i] = dp[i-1]
    else:
        if i - 1 not in set_inputs:
            dp[i] += dp[i-1]
        if i - 2 not in set_inputs:
            dp[i] += dp[i-2]

print(dp[-1] % mod)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

N, M = map(int, input().split())
inputs = [int(input()) for _ in range(M)]

mod = 10 ** 9 + 7
def dfs(count):
    if count in inputs or count > N:
        return 0
    if count == N:
        return 1
    return dfs(count+1) + dfs(count+2)

print(dfs(0) % mod)


Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
inputs = [int(input()) for _ in range(M)]

set_inputs = set(inputs)
mod = 10 ** 9 + 7
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(1, N+1):
    if i in set_inputs:
        continue
    if i == 1:
        dp[i] = dp[i-1]
    else:
        if i - 1 not in set_inputs:
            dp[i] += dp[i-1]
        if i - 2 not in set_inputs:
            dp[i] += dp[i-2]

print(dp[-1] % mod)
Buggy python submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif D < C:
    pass

print('Yes' if flag else 'No')

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-2, D-1):
        if inputs[index] != '#' and inputs[index+1] != '#' and inputs[index+2] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')

Buggy python submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and B < C:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif B < C < D:
    pass
elif D < C:
    pass

print('Yes' if flag else 'No')

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-2, D-1):
        if inputs[index] != '#' and inputs[index+1] != '#' and inputs[index+2] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')
Buggy python submission (verdict: Runtime Error):
import datetime

a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days

print('Heisei' a >= 0 else 'TBD')


Fixed submission:
import datetime

# if not (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')):
#     print('Heisei')
# else:
#     print('TBD')
a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days
if a >= 0:
    print('Heisei')
else:
    print('TBD')

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

a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days

print('Heisei'a >= 0 else 'TBD')


Fixed submission:
import datetime

# if not (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')):
#     print('Heisei')
# else:
#     print('TBD')
a  = (datetime.datetime.strptime('2019/04/30', '%Y/%m/%d') - datetime.datetime.strptime(input(), '%Y/%m/%d')).days
if a >= 0:
    print('Heisei')
else:
    print('TBD')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in inputs:
    ans &= set(inputs[1:])

print(len(ans))


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

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in range(N):
    ans = ans & set(inputs[item][1:])

print(len(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
inputs = [list(map(int, input().split())) for _ in range(N)]

dicts = {}
for i in range(N):
    dicts[i] = sum(inputs[i])

ans = ~
count = 0
for key, value in sorted(dicts.items(), key=lambda x: -x[1]):
    if count % 2 == 0:
        ans += inputs[key][0]
    else:
        ans -= inputs[key][1]
    count += 1

print(ans)


Fixed submission:
N = int(input())
inputs = [list(map(int, input().split())) for _ in range(N)]

dicts = {}
for i in range(N):
    dicts[i] = sum(inputs[i])

t = 0
a = 0
count = 0
for key, value in sorted(dicts.items(), key=lambda x: -x[1]):
    if count % 2 == 0:
        t += inputs[key][0]
    else:
        a += inputs[key][1]
    count += 1

print(t - a)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations

N, K = map(int, input().split())
inputs = [[int(i) for i in input().split()] for _ in range(N)]

ans = 0
for items in permutations(inputs, K):
    tmp = 0
    sets = set()
    for i in range(K):
        tmp += items[i][1]
        sets.add(items[i][0])
    tmp += len(sets) * len(sets)
    ans = max(ans, tmp)

print(ans)


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

inputs = []
priority_queue = []
queue = []
sets = set()

for _ in range(N):
    key, value = map(int, input().split())
    inputs.append((value, key))

inputs.sort(reverse=True) # valueで降順のソートをかけてる

for i in range(K):
    value, key = inputs[i]
    if key in sets:
        queue.append(value)
    else:
        priority_queue.append(value)
        sets.add(key)

sum_priority_queue = sum(priority_queue)
sum_queue = sum(queue)
kinds = len(sets)
ans = sum_priority_queue + sum_queue + kinds ** 2
for i in range(K, N):
    if not queue:
        break
    value, key = inputs[i]
    if key in sets:
        continue
    sets.add(key)
    sum_queue -= queue.pop()
    sum_priority_queue += value
    kinds += 1
    ans = max(ans, sum_priority_queue + sum_queue + kinds ** 2)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()

S = 'keyence'
index = 0
for item in N:
    if S[index] == item:
        index += 1

print('YES' if index == len(S) else 'NO')


Fixed submission:
N = input()

S = 'keyence'
if S == N[:len(S)]:
    print('YES')
elif S == N[-len(S):]:
    print('YES')
else:
    for index in range(len(S)):
        if S[:index] == N[:index] and S[-(len(S) - index):] == N[-(len(S) - index):]:
            print('YES')
            break
    else:
        print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
inputs = [[int(i) for i in input().split()] for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    tmp_dp = [0 for _ in range(W+1)]
    for w in range(W+1):
        if w - weight >= 0:
            tmp_dp[w] = max(dp[n-1][w], dp[n-1][w-weight] + value)
        else:
            tmp_dp[w] = dp[n-1][w]
    dp[n] = tmp_dp

print(dp[-1][-1])


Fixed submission:
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= 

Fixed submission:
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= W)))

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])

Fixed submission:
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= W)))

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])

Fixed submission:
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= W)))

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])


Fixed submission:
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= W)))