Buggy python submission (verdict: Runtime Error):
inf = float('inf')

N,W = map(int,input().split())
w, v = [], []
for _ in range(N):
    wi, vi = map(int,input().split())
    w.append(wi)
    v.append(vi)

M = N*sum(v)

dp = [[inf]*(M+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(1,N+1):
    for j in range(M+1):
        if j - v[i-1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1])
        else:
            dp[i][j] = dp[i-1][j]

for j in range(M+1)[::-1]:
    if dp[N][j] <= W:
        ans = j
        break

print(ans)

Fixed submission:
N,W = map(int,input().split())
value,weight = [],[]
def chmin(a,b):
    if (a > b):
        a = b
        return True
    return False
for i in range(N):
    w,v = map(int,input().split())
    value.append(v)
    weight.append(w)
# dp[i][v]: i番目までの品物から価値vを超えるように選んだ時の重さの最小値
dp = [[float("inf")] * (sum(value)+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for v in range(sum(value)+1):
        if v - value[i-1] >= 0:
            dp[i][v] = min(dp[i-1][v-value[i-1]] + weight[i-1],dp[i-1][v])
        else:
            dp[i][v] = dp[i-1][v]
ans = 0
for v in range(sum(value),-1,-1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

Fixed submission:
N,W = map(int,input().split())
value,weight = [],[]
def chmin(a,b):
    if (a > b):
        a = b
        return True
    return False
for i in range(N):
    w,v = map(int,input().split())
    value.append(v)
    weight.append(w)
# dp[i][v]: i番目までの品物から価値vを超えるように選んだ時の重さの最小値
dp = [[float("inf")] * (sum(value)+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for v in range(sum(value)+1):
        if v - value[i-1] >= 0:
            dp[i][v] = min(dp[i-1][v-value[i-1]] + weight[i-1],dp[i-1][v])
        else:
            dp[i][v] = dp[i-1][v]
ans = 0
for v in range(sum(value),-1,-1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecurisonlimit(10**9)
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

Fixed submission:
N,W = map(int,input().split())
value,weight = [],[]
def chmin(a,b):
    if (a > b):
        a = b
        return True
    return False
for i in range(N):
    w,v = map(int,input().split())
    value.append(v)
    weight.append(w)
# dp[i][v]: i番目までの品物から価値vを超えるように選んだ時の重さの最小値
dp = [[float("inf")] * (sum(value)+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for v in range(sum(value)+1):
        if v - value[i-1] >= 0:
            dp[i][v] = min(dp[i-1][v-value[i-1]] + weight[i-1],dp[i-1][v])
        else:
            dp[i][v] = dp[i-1][v]
ans = 0
for v in range(sum(value),-1,-1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

Fixed submission:
N,W = map(int,input().split())
value,weight = [],[]
def chmin(a,b):
    if (a > b):
        a = b
        return True
    return False
for i in range(N):
    w,v = map(int,input().split())
    value.append(v)
    weight.append(w)
# dp[i][v]: i番目までの品物から価値vを超えるように選んだ時の重さの最小値
dp = [[float("inf")] * (sum(value)+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for v in range(sum(value)+1):
        if v - value[i-1] >= 0:
            dp[i][v] = min(dp[i-1][v-value[i-1]] + weight[i-1],dp[i-1][v])
        else:
            dp[i][v] = dp[i-1][v]
ans = 0
for v in range(sum(value),-1,-1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)