Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
w = []
v = []
for i in range(N):
    x,y = map(int,input().split())
    w.append(x)
    v.append(y)

dp = [[0]*(W+1) for j in range(N+1)] # DPテーブルの作成

for i in range(N):
    for j in range(W+1):
        if j < w[i]: # 選ばない時
            dp[i+1][j] = dp[i][j]
        else: # 選ぶ時
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])

print(dp[N][W])

Fixed submission:
N,W=map(int,input().split())
L = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for j in range(110000)] for i in range(110)]
for i in range(1,N+1):
  for j in range(W+1):
    dp[i][j]=dp[i-1][j]
    if j-L[i-1][0]>=0:
      dp[i][j]=max(dp[i][j],dp[i-1][j-L[i-1][0]]+L[i-1][1])
ans=dp[N][W]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,w = map(int,input().split())
wv = [tuple(map(int,input().split())) for i in range(n)]

dp = [0]*(w+1)
for i in range(n):
    for j in range(w,wv[i][0]-1,-1):
        dp[j] = max(dp[j],dp[j-wv[i][0]]+wv[i][1])

print(max(dp))

Fixed submission:
N,W=map(int,input().split())
L = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for j in range(110000)] for i in range(110)]
for i in range(1,N+1):
  for j in range(W+1):
    dp[i][j]=dp[i-1][j]
    if j-L[i-1][0]>=0:
      dp[i][j]=max(dp[i][j],dp[i-1][j-L[i-1][0]]+L[i-1][1])
ans=dp[N][W]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,W=map(int,input().split())
wv=[[int(j) for j in input().split()] for i in range(n)]
dp=[[0]*110000 for i in range(110)]
#print(dp)

for i in range(1,n+1):
  for j in range(W+1):
    dp[i][j]=dp[i-1][j]
    if j-wv[i-1][0]>=0:
      dp[i][j]=max(dp[i][j],
                   dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
      
print(dp[n][W])

Fixed submission:
N,W=map(int,input().split())
L = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for j in range(110000)] for i in range(110)]
for i in range(1,N+1):
  for j in range(W+1):
    dp[i][j]=dp[i-1][j]
    if j-L[i-1][0]>=0:
      dp[i][j]=max(dp[i][j],dp[i-1][j-L[i-1][0]]+L[i-1][1])
ans=dp[N][W]
print(ans)

Buggy python submission (verdict: Runtime Error):
n,W=map(int,input().split())
wv=[[int(j) for j in input().split()] for i in range(n)]
dp=[[0]*110 for i in range(110000)]

for i in range(1,n+1):
  for j in range(W+1):
    dp[i][j]=dp[i-1][j]
    if j-wv[i-1][0]>=0:
      dp[i][j]=max(dp[i][j],
                   dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
      
print(dp[n][W])

Fixed submission:
N,W=map(int,input().split())
L = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for j in range(110000)] for i in range(110)]
for i in range(1,N+1):
  for j in range(W+1):
    dp[i][j]=dp[i-1][j]
    if j-L[i-1][0]>=0:
      dp[i][j]=max(dp[i][j],dp[i-1][j-L[i-1][0]]+L[i-1][1])
ans=dp[N][W]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
L = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for j in range(110000)] for i in range(110)]
for i in range(1,N+1):
  for j in range(W+1):
    dp[i][j]=dp[i-1][j]
    if j-L[i-1][0]>=0:
      dp[i][j]=max(dp[i][j],dp[i-1][j-L[i-1][0]]+L[i-1][1])
ans=dp[N][W]
print(ans)

Fixed submission:
N,W=map(int,input().split())
L = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for j in range(110000)] for i in range(110)]
for i in range(1,N+1):
  for j in range(W+1):
    dp[i][j]=dp[i-1][j]
    if j-L[i-1][0]>=0:
      dp[i][j]=max(dp[i][j],dp[i-1][j-L[i-1][0]]+L[i-1][1])
ans=dp[N][W]
print(ans)