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

Fixed submission:
s = input()
print (s[0:3])

Buggy submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if (b >= a):
  aa=a+v*t
  bb=b+w*t
  if (bb-aa >=0):
    print ('NO')
  else:
    print ('YES')
else:
  aa=a-v*t
  bb=b-w*t
  if (bb-aa <=0):
    print ('NO')
  else:
    print ('YES')
Problem p02683 (python)

Fixed submission:
import itertools
import numpy as np

n, m, x= map(int, input().split())
a = [input().split() for l in range(n)]
npa=np.array(a, dtype=int)

hon=-1
for i in range(1,n+1):
  base = list(itertools.combinations(range(0,n),i))
#  print (base)
  
  for j in base:
    totalv=np.sum(npa[j,], axis=0)
#    print (totalv, min(totalv[1:-1]))
    
    if (min(totalv[1:m+1]) >= x):
      if (hon == -1): hon=totalv[0]
      if (hon >= totalv[0]): hon=totalv[0]
#      print (hon)
      
print (hon)

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

n, m, x= map(int, input().split())
a = [input().split() for l in range(n)]
npa=np.array(a, dtype=int)

hon=-1
for i in range(1,n+1):
  base = list(itertools.combinations(range(0,n),i))
#  print (base)
  
  for j in base:
    totalv=np.sum(npa[j,], axis=0)
#    print (totalv, min(totalv[1:-1]))
    
    if (min(totalv[1:-1]) >= x):
      if (hon == -1): hon=totalv[0]
      if (hon >= totalv[0]): hon=totalv[0]
#      print (hon)
      
print (hon)

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

n, m, x= map(int, input().split())
a = [input().split() for l in range(n)]
npa=np.array(a, dtype=int)

#print (npa)

hon=-1
for i in range(1,n+1):
  base = list(itertools.combinations(range(0,n),i))
#  print (base)
  
  for j in base:
    totalv=np.sum(npa[j,], axis=0)
#    print (totalv, min(totalv[1:-1]))
    
    if (min(totalv[1:-1]) >= x):
      if (hon < 0): hon=totalv[0]
      if (hon >= totalv[0]): hon=totalv[0]
#      print (hon)
      
print (hon)
Problem p02696 (python)

Fixed submission:
import math
a, b, n = map(int, input().split())

if (b != 1):
  if (n >=b):
    x=math.floor(n/b)*b-1
    print (math.floor(a*x/b)-a*math.floor(x/b))
  else:
    print (math.floor(a*n/b)-a*math.floor(n/b))
else:
  print (0)

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

if (n >=b):
  x=math.floor(n/b)*b-1
  print (math.floor(a*x/b)-a*math.floor(x/b))
#  print (int(a*(int(n/b)-1./b))-a*int(int(n/b)-1./b))
else:
#  xmax=0
#  for x in range(1,n+1):
#    atai=int(a*x/b)-a*int(x/b)
#    if (atai >= xmax): xmax=atai
#  print (xmax)
  print (math.floor(a*n/b)-a*math.floor(n/b))
Problem p02705 (python)

Fixed submission:
import numpy as np
i = int(input())
pi = np.pi
print (2*pi*i)

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

play=n-sum(a)
if play < 0: play=-1
 

print (play)
Problem p02741 (python)

Fixed submission:
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = input()
ki=int(k)-1
print(array[ki])

Buggy submission (verdict: Runtime Error):
i = list(map(int, input().split()))
HH = i[0]
WW = i[1]
atai = HH*WW
amari=divmod(atai,2)
ans = int(atai/2) + amari[1]
print (ans)

Buggy submission (verdict: Runtime Error):
i = list(map(int, input().split()))
HH = i[0]
WW = i[1]
atai = HH*WW
#ans = int(atai/2) + (atai % 2)
amari=divmod(atai,2)
ans = int(atai/2) + amari[1]
print (ans)
Problem p02584 (python)

Fixed submission:
from sys import stdin


def f(x, k, d):
    if k == 0:
        return x

    absX = abs(x)
    tmp = absX // d

    if tmp > k:
        return absX - d * k
    else:
        absX = absX - d * tmp
        k = k - tmp
        if k % 2 == 0:
            return absX
        else:
            return abs(absX - d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(f(X, K, D))

Buggy submission (verdict: Runtime Error):
from sys import stdin


def f(x, k, d):
    if k == 0:
        return x

    if x == 0:
        if k % 2 == 0:
            return 0
        elif k % 2 == 1:
            return d
    elif x > 0:
        tmp = abs(x) / d
        if d * tmp > d * k:
            return x - d * k
        else:
            return f((x-d*tmp), (k-tmp), d)
    elif x < 0:
        tmp = abs(x) / d
        if d * tmp > d * k:
            return x + d * k
        else:
            return f((x+d*tmp), (k-tmp), d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(abs(f(X, K, D)))

Buggy submission (verdict: Runtime Error):
from sys import stdin
from functools import lru_cache


@lru_cache(maxsize=100)
def f(x, k, d):
    if k == 0:
        return x

    if x == 0:
        if k % 2 == 0:
            return 0
        if k % 2 == 1:
            return d
    if x > 0:
        return f(x-d, k-1, d)
    if x < 0:
        return f(x+d, k-1, d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(abs(f(X, K, D)))

Buggy submission (verdict: Runtime Error):
from sys import stdin
from functools import lru_cache


@lru_cache(maxsize=1000)
def f(x, k, d):
    if k == 0:
        return x

    if x == 0:
        if k % 2 == 0:
            return 0
        if k % 2 == 1:
            return d
    if x > 0:
        return f(x-d, k-1, d)
    if x < 0:
        return f(x+d, k-1, d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(abs(f(X, K, D)))
Problem p02999 (python)

Fixed submission:
from sys import stdin

X, A = [int(x) for x in stdin.readline().rstrip().split()]

if X < A:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

if __name__ == '__main__':
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    a = [int(x) for x in stdin.readline().rstrip().split()]

    # 総組み合わせ数(nCr + N)の計算 n=N, r=2
    # N は数字を一つだけ選ぶパターン
    max = (factorial(N) // factorial(2) // factorial(N - 2)) + N

    # 条件を満たさないパターンを総当たりで計算
    count = 0
    for i in range(N):
        for j in range(N):
            if i > j:
                continue

            tmp = sum(a[i:j+1])

            if tmp < K:
                count = count + 1
            else:
                break

    print(max - count)
Problem p02600 (python)

Fixed submission:
x = int(input())

if x >= 1800:
    ans = 1
elif x >= 1600:
    ans = 2
elif x >= 1400:
    ans = 3
elif x >= 1200:
    ans = 4
elif x >= 1000:
    ans = 5
elif x >= 800:
    ans = 6
elif x >= 600:
    ans = 7
else:
    ans = 8

print(str(int(ans)))

Buggy submission (verdict: Runtime Error):
x = int(input())

if x >= 1800:
    ans = 1
elif x >= 1600:
    ans = 2
elif x >= 1400:
    ans = 3
elif x >= 1200:
    ans = 4
elif x >= 1000:
    ans = 5
elif x >= 800:
    ans = 6
elif x >= 600:
    ans = 7
else:
    x = 8

print(str(int(ans)))
Problem p02615 (python)

Fixed submission:
N = int(input())
A = sorted(map(int, input().split()))
ans = 0
for k in range(1, N):
    ans += A[N - 1 - k // 2]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
N = int(input())
A = sorted(map(int, input().split()))
q = deque()
a = a.pop()
b = a.pop()
ans = a + b
q.append((a,b))
q.append((a,b))
while A:
    c = A.pop()
    a,b = q.popleft()
    ans += min(a,b)
    q.append((a,c))
    q.append((c,b))
print(ans)
Problem p02617 (python)

Fixed submission:
N = int(input())
M = 0
for _ in range(N - 1):
    u, v = sorted(map(int, input().split()))
    M += u * (N - v + 1)
V = 0
for r in range(1, N + 1):
    V += r * (N - r + 1)
print(V - M)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
m = np.zeros((N + 2, N + 2), dtype='int64')
for _ in range(N - 1):
    u, v = sorted(map(int, input().split()))
    np.add(m[:u + 1, v:], 1, out=m[:u + 1, v:])
ans = 0
for L in range(1, N + 1):
    for R in range(L, N + 1):
        ans += R - L + 1 - m[L, R]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
m = np.zeros((N + 1, N + 1), dtype='int64')
for _ in range(N - 1):
    u, v = sorted(map(int, input().split()))
    np.add(m[:u + 1, v:], 1,out=m[:u + 1, v:])
ans = 0
for L in range(1, N + 1):
    for R in range(L, N + 1):
        ans += R - L + 1 - m[L, R]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
m = np.zeros((N + 1, N + 1), dtype='int32')
for _ in range(N - 1):
    u, v = sorted(map(int, input().split()))
    np.add(m[:u + 1, v:], 1,out=m[:u + 1, v:])
ans = 0
for L in range(1, N + 1):
    for R in range(L, N + 1):
        ans += R - L + 1 - m[L, R]
print(ans)
Problem p02677 (python)

Fixed submission:
from math import cos, radians
A, B, H, M = map(int, input().split())
t = 30 * (H + M / 60) - 6 * M
t = radians(t)
print((A**2 + B**2 - 2*A*B*cos(t)) ** .5)

Buggy submission (verdict: Runtime Error):
from math import cos
A, B, H, M = map(int, input().split())
t = 30 * A - 6 * B
print((A**2 + B**2 - 2*a*b*cos(t) ** .5)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
G = [[] for _ in range(N)]
for i, a in enumerate(map(int, input().split())):
    G[i] = a - 1
now = 0
seen = set()
#ループが始まる町とそれまでの移動回数iを求める
for i in range(1, K+1):
    seen.add(now)
    now = G[now]
    if now in seen:
        break
K -= i
if K > 0:
    #ループの移動回数jを求める。
    seen = set()
    for j in range(1,K+1):
        seen.add(now)
        now = G[now]
        if now in seen:
            break
    #ループの長さで割った余りｒを求める。
    r = K % j
    for _ in range(r):
        now = G[now]
print(now + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M, X = map(int, input().split())
A = []
C = []
for _ in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)
A = np.array(A,dtype=int)
ans = 10 ** 7
for bit in range(2 ** N):
    B = np.zeros(M, dtype=int)
    cost = 0
    for i in range(N):
        if bit & (1<<i):
            B += A[i]
            cost += C[i]
    if np.all(B >= X):
        ans = min(ans, cost)
print(ans if ans < 10**7 else -1)
Problem p02694 (python)

Fixed submission:
X = int(input())
i = 0
money = 100
r = 101
while money < X:
    money *= r
    money //= 100
    i += 1
print(i)

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = map(int, input().split())
XK = list(x * K for x in range(1, 1000//K + 1))
for i in XK:
    if (A <= i) & (i <= B):
        print('OK')
        break
else:
    print('NG')
Problem p02818 (python)

Fixed submission:
A, B, K = map(int, input().split())
a = max(0, A - K)
b = B
if K - A > 0:
    b = max(0, B - K + A)
print(a, b)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
a = max(0, A - K)
if K - A > 0:
    b = max(0, B - K + A)
print(a, b)
Problem p02838 (python)

Fixed submission:
N = int(input())
aaa = list(map(int, input().split()))
bbb = [format(a, '061b') for a in aaa]

zero = [0] * 61
one = [0] * 61
for i in range(61):
    s = ''.join(list(b[-(i+1)] for b in bbb))
    zero[i] = s.count('0')
    one[i] = s.count('1')
ans = 0
MOD = 1_000_000_007
for i, o, l in zip(range(61), zero, one):
    ans += 2**i * o * l
    ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
aaa = map(int, input().split())
ans = 0
MOD = 1_000_000_007
for i in range(N-1):
    for j in range(i + 1, N):
        ans += aaa[i] ^ aaa[j]
        ans %= MOD
print(ans)
Problem p03014 (python)

Fixed submission:
def main ():
    H, W = map(int, input().split())
    MAP = [list('#' for i in range(W + 2)) for j in range(H + 2)]
    for i in range(H):
        line = list(input())
        for j, dot in enumerate(line):
            MAP[i + 1][j + 1] = dot
    L = [[0 for j in range(W + 2)] for i in range(H + 2)]


    def line(MAP):
        for i in range(1, H + 2):
            before = 0
            for j in range(1, W + 2):
                if MAP[i][j] == '#':
                    for x in range(before + 1, j):
                        L[i][x] = j - before - 1
                    before = j


    def column(MAP2):
        ans = 0
        for j in range(1, W + 2):
            before = 0
            for i in range(1, H + 2):
                if MAP2[i][j] == '#':
                    for y in range(before + 1, i):
                        ans = max(ans, i - before - 1 + L[y][j])
                    before = i
        return ans - 1

    line(MAP)
    column(MAP)
    print(column(MAP))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
MAP = [list('#' for i in range(W + 2)) for j in range(H + 2)]
for i in range(H):
    line = list(input())
    for j, dot in enumerate(line):
        MAP[i + 1][j + 1] = dot
L = [[0 for j in range(W + 2)] for i in range(H + 2)]


def line(MAP):
    for i in range(1, H + 2):
        before = 0
        for j in range(1, W + 2):
            if MAP[i][j] == '#':
                for x in range(before + 1, j):
                    L[i][x] = j - before - 1
                before = j


def column(MAP2):
    for j in range(1, W + 2):
        before = 0
        for i in range(1, H + 2):
            if MAP2[i][j] == '#':
                for y in range(before + 1, i):
                    global ans
                    ans = max(ans, i - before - 1 + L[y][j])
                before = i


line(MAP)
ans = 0
column(MAP)
print(ans - 1)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
MAP = [list('#' + input() + '#') for j in range(H)]
MAP.insert(0, ['#' for i in range(W + 2)])
MAP.append(['#' for i in range(W + 2)])
MAP2 = copy.deepcopy(MAP)


def line(MAP):
    for i in range(1, H + 2):
        before = 0
        for j in range(1, W + 2):
            if MAP[i][j] == '#':
                for x in range(before + 1, j):
                    MAP[i][x] = j - before - 1
                before = j


def column(MAP2):
    for j in range(1, W + 2):
        before = 0
        for i in range(1, H + 2):
            if MAP2[i][j] == '#':
                for y in range(before + 1, i):
                    global ans
                    ans = max(ans, i - before - 1 + MAP[y][j])
                before = i


line(MAP)
ans = 0
column(MAP2)
print(ans - 1)
Problem p03061 (python)

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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 0
L = [0]*(n)
R = [0]*(n+1)
for i in range(n-1):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], A[-i-1])
for l, r in zip(L[::-1],R):
    ans = max(ans, gcd(l, r))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

if len(A) == 2:
    print(gcd(A[0], A[1]))
    exit()
b = set()
for i in range(2):
    a = 0
    for j in range(n):
        a = gcd(A[i],A[j])
        b.add(a)
b = sorted(b)
print(b[1])
Problem p03074 (python)

Fixed submission:
n, k = map(int, input().split())
S = input()
start =[]
end = [0]
if S[0] == "0":
    start.append(0)
for i in range(n):
    if S[i:i+2] == "10":
        start.append(i+1)
    elif S[i:i+2] == "01":
        end.append(i+1)

if len(start) <= k:
    print(len(S))
else:
    start.append(len(S))
    ans = []
    for i in range(len(start) - k):
        ans.append(start[i + k] - end[i])
    print(max(ans))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
S = input()
start =[]
end = []
if S[0] == "0":
    start.appned(0)
else:
    end.append(0)
for i in range(n):
    if S[i:i+2] == "10":
        start.append(i+1)
    elif S[i:i+2] == "01":
        end.append(i+1)
if len(start) <= k:
    print(len(S))
else:
    start.append(len(S))
    ans = []
    for i in range(len(start) - k):
        ans.append(start[i + k] - end[i])
    print(max(ans))
Problem p03087 (python)

Fixed submission:
n, q = map(int, input().split())
S = input()
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if S[i : i+2] == "AC" else 0)

for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
import re
lines = sys.stdin.readlines()
for line in lines[2:]:
    l, r = map(int, line.split())
    match = re.findall("(AC)", lines[1][l-1:r])
    print(len(match))
Problem p03103 (python)

Fixed submission:
import sys
import numpy as np

n, m = map(float, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
lines.sort()
price = 0
for line in lines:
    if m - line[1] > 0:
        price += line[0] * line[1]
        m -= line[1]
    else:
        price += line[0] * m
        break
print(int(price))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
import pandas as pd

n, m = map(int, sys.stdin.readline().rstrip().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
df = pd.DataFrame(lines,
                  columns = ["price", "stock"],
                  dtype = float
                  )
df = df.sort_values(by="price")
price = 0
for i in range(n):
    if m - df.iloc[i]["stock"] > 0:
        price += df.iloc[i]["price"] * df.iloc[i]["stock"]
        m -= df.iloc[i]["stock"]
    else:
        price += df.iloc[i]["price"] * m
        break
print(int(price))

Buggy submission (verdict: Runtime Error):
import sys
import os

import numpy as np
import pandas as pd

n, m = map(int, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
df = pd.DataFrame(lines,
                  columns = ["price", "stock"],
                  dtype = float
                  )
df = df.sort_values(by="price")
price = 0
for i in range(n):
    if m - df.iloc[i]["stock"] > 0:
        price += df.iloc[i]["price"] * df.iloc[i]["stock"]
        m -= df.iloc[i]["stock"]
    else:
        price += df.iloc[i]["price"] * m
        break
print(int(price))

Buggy submission (verdict: Runtime Error):
import sys

import numpy as np
import pandas as pd

n, m = map(int, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
df = pd.DataFrame(lines,
                  columns = ["price", "stock"],
                  dtype = float
                  )
df = df.sort_values(by="price")
price = 0
for i in range(n):
    if m - df.iloc[i]["stock"] > 0:
        price += df.iloc[i]["price"] * df.iloc[i]["stock"]
        m -= df.iloc[i]["stock"]
    else:
        price += df.iloc[i]["price"] * m
        break
print(int(price))

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

n, m = map(int, input().split())
lines = sys.stdin.readlines()
lines = [list(map(float, line.strip().split())) for line in lines]
df = pd.DataFrame(lines,
                  columns = ["price", "stock"],
                  dtype = float
                  )
df = df.sort_values(by="price")
price = 0
for i in range(n):
    if m - df.iloc[i]["stock"] > 0:
        price += df.iloc[i]["price"] * df.iloc[i]["stock"]
        m -= df.iloc[i]["stock"]
    else:
        price += df.iloc[i]["price"] * m
        break
print(int(price))
Problem p03106 (python)

Fixed submission:
import math
a, b, k =map(int, input().split())
divesor_list = []
c = min(a, b)
if c == 1:
    divesor_list = [1]
else:
    for i in range(c, 0, -1):
            if (a % i == 0) & (b % i == 0):
                divesor_list.append(i)
print(divesor_list[k-1])

Buggy submission (verdict: Runtime Error):
import math
a, b, k =map(int, input().split())
divesor_list = []
if min(a, b) == 1:
    divesor_list = [1]
else:
    for i in range(min(a, b), 0, -1):
            if gcd % i == 0:
                divesor_list.append(i)
print(divesor_list[k-1])

Buggy submission (verdict: Runtime Error):
import math
a, b, k =map(int, input().split())
gcd = math.gcd(a,b)
divesor_list = []
if gcd == 1:
    divesor_list = [gcd]
else:
    for i in range(gcd, 0, -1):
        if gcd % i == 0:
            divesor_list.append(i)
print(divesor_list[k-1])
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
dict = dict(zip([i for i in range(1, 10)], [2, 5, 5, 4, 5, 6, 3, 7, 6]))
INF = 10 ** (N // 2 + 1)
dp = [-INF for i in range(N + 21)]
for a in A:
    dp[dict[a]] = max(dp[dict[a]], a)
for i in range(N + 1):
    for j in range(1, 10):
        dp[i] = max(dp[i], dp[i - j] * 10 + dp[j], dp[j] * 10 + dp[i - j])
print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
dict = dict(zip([i for i in range(1, 10)], [2,5,5,4,5,6,3,7,6]))
INF = 10 ** (N // 2 + 1)
dp = [-INF for i in range(N + 1)]
for a in A:
    dp[dict[a]] = max(dp[dict[a]] , a)
for i in range(N + 1):
    for j in range(1, 10):
        dp[i] = max(dp[i], dp[i - j] * 10 + dp[j], dp[j] * 10 +dp[i - j])
print(dp[N])
Problem p03163 (python)

Fixed submission:
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int64)
for _ in range(N):
    w,v = map(int, input().split())
    np.maximum(dp[w:], dp[:-w] + v , dp[w:])
print(max(dp))

Buggy submission (verdict: Runtime Error):
mport numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int64)
for _ in range(N):
    w,v = map(int, input().split())
    np.maximum(dp[w:], dp[:-w] + v , dp[w:])
print(max(dp))
Problem p03164 (python)

Fixed submission:
def main():
    N, W = map(int, input().split())
    #dp[v] vとなる最小のＷ
    dp = [10**9+1 for _ in range(10**5+1)]
    for _ in range(N):
        w,v = map(int, input().split())
        for val in range(10**5, 1, -1):
            if val - v < 1:
                break
            dp[val] = min(dp[val], dp[val - v] + w)
        if dp[v] > w:
            dp[v] = w
    ans = 0
    for v, w in enumerate(dp):
        if w <= W:
            ans = max(ans, v)
    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
def main():
    N, W = map(int, input().split())
    #dp[v] vとなる最小のＷ
    dp = np.full(10**5+1, 10**9+1, dtype=np.int64)
    for _ in range(N):
        w,v = map(int, input().split())
        for val in range(10**5, 1, -1):
            if val - v < 1:
                break
            dp[val] = min(dp[val], dp[val - v] + w)
        if dp[v] > w:
            dp[v] = w
    print(max(np.where(dp <= W)[0]))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
N, W = map(int, input().split())
#dp[v] vとなる最小のＷ
dp = np.full(10**5+1, 10**9+1, dtype=np.int64)
for _ in range(N):
    w,v = map(int, input().split())
    for val in range(10**5, 1, -1):
        if val - v < 1:
            break
        dp[val] = min(dp[val], dp[val - v] + w)
    if dp[v] > w:
        dp[v] = w
print(max(np.where(dp <= W)[0]))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int64)
for _ in range(N):
    w,v = map(int, input().split())
    np.maximum(dp[w:], dp[:-w] + v , dp[w:])
print(max(dp))