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

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]
for i, (item_weight, item_value) in enumerate(items):  # i番目の品
    for total_weight in range(W):                      # 重さの合計
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        dp[i+1][total_weight + item_weight] = \
            max(dp[i][total_weight] + item_value, dp[i+1][total_weight + item_weight])
          
print(dp[N][W])

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

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]

for i, (item_weight, item_value) in enumerate(items):
    for total_weight in range(W+1):
        if (total_weight-item_weight) >= 0:
            dp[i+1][total_weight] = max(dp[i][total_weight-item_weight] + item_value, dp[i+1][total_weight])
        dp[i+1][total_weight] = max(dp[i+1][total_weight], dp[i][total_weight])
        
print(dp[N][W])

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

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]
for i, (item_weight, item_value) in enumerate(items):  # i番目の品
    for total_weight in range(W):                      # 重さの合計
        dp[i+1][total_weight+item_weight] = max(dp[i][total_weight]+item_value, dp[i+1][total_weight+item_weight])
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        
print(dp[N][W])

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

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]

for i, (item_weight, item_value) in enumerate(items):
    for total_weight in range(W+1):
        if (total_weight-item_weight) >= 0:
            dp[i+1][total_weight] = max(dp[i][total_weight-item_weight] + item_value, dp[i+1][total_weight])
        dp[i+1][total_weight] = max(dp[i+1][total_weight], dp[i][total_weight])
        
print(dp[N][W])

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

dp = [[0 for _ in range(W+100)] for _ in range(N+10)]
dp[0][0] = 0
for i, (item_weight, item_value) in enumerate(items): 
    for total_weight in range(W+10):                   
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        dp[i+1][total_weight+item_weight] = max(dp[i][total_weight]+item_value, dp[i+1][total_weight+item_weight])
        
print(dp[N][W])

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

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]

for i, (item_weight, item_value) in enumerate(items):
    for total_weight in range(W+1):
        if (total_weight-item_weight) >= 0:
            dp[i+1][total_weight] = max(dp[i][total_weight-item_weight] + item_value, dp[i+1][total_weight])
        dp[i+1][total_weight] = max(dp[i+1][total_weight], dp[i][total_weight])
        
print(dp[N][W])

Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]
 
 
dp = [[float('-inf') for _ in range(1000)] for _ in range(110)]
dp[0][0] = 0
for i, (item_weight, item_value) in enumerate(items):  # i番目の品
    for total_weight in range(W+10):                   # 重さの合計
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        dp[i+1][total_weight+item_weight] = max(dp[i][total_weight]+item_value, dp[i+1][total_weight+item_weight])
        
print(dp[N][W])

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

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]

for i, (item_weight, item_value) in enumerate(items):
    for total_weight in range(W+1):
        if (total_weight-item_weight) >= 0:
            dp[i+1][total_weight] = max(dp[i][total_weight-item_weight] + item_value, dp[i+1][total_weight])
        dp[i+1][total_weight] = max(dp[i+1][total_weight], dp[i][total_weight])
        
print(dp[N][W])

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


dp = [[float('-inf') for _ in range(1000)] for _ in range(10)]
dp[0][0] = 0
for i, (item_weight, item_value) in enumerate(items):  # i番目の品
    for total_weight in range(W+10):                   # 重さの合計
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        dp[i+1][total_weight+item_weight] = max(dp[i][total_weight]+item_value, dp[i+1][total_weight+item_weight])
        
print(dp[N][W])

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

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]

for i, (item_weight, item_value) in enumerate(items):
    for total_weight in range(W+1):
        if (total_weight-item_weight) >= 0:
            dp[i+1][total_weight] = max(dp[i][total_weight-item_weight] + item_value, dp[i+1][total_weight])
        dp[i+1][total_weight] = max(dp[i+1][total_weight], dp[i][total_weight])
        
print(dp[N][W])