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

dp = [[0]*(W+1) for i in range(N+1)]

for i in range(N):
    for g in range(W+1):
        if g >= w[i]:
            dp[i+1][g] = max(dp[i][g-w[i]]+v[i], dp[i][g])
        else:
            dp[i+1][g] = dp[i][g]

print(dp[N][W])


Fixed submission:
N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for i in range(N)]
 
dp=[[0]*(W+1) for i in range(N+1)]
 
for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]
 
 
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(N)]

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

for w in range(W+1):
    for n in range(N):
        if wv[n][0]<=w:
            dp[n+1][w]+=max(wv[n][1]+dp[n][w-wv[n][0]],dp[n][w])
        else:
            dp[n+1][w]=dp[n][w]

print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for i in range(N)]
 
dp=[[0]*(W+1) for i in range(N+1)]
 
for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]
 
 
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for i in range(N)]

dp=np.zeros([N+1, W+1])

for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1, w] = max(dp[n, w-wv[n][0]]+wv[n][1], dp[n, w])
        else:
            dp[n+1,w] = dp[n,w]
print(int(dp[N][W]))

Fixed submission:
N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for i in range(N)]
 
dp=[[0]*(W+1) for i in range(N+1)]
 
for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]
 
 
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
def DP():
    N, W = map(int, input().split())
    wv = [[int(i) for i in input().split()] for i in range(N)]

    dp=[[0]*(W+1) for i in range(N+1)]

    for w in range(W+1):
        for n in range(N):
            if wv[n][0] <= w:
                dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
            else:
                dp[n+1][w] = dp[n][w]
    print(dp[N][W])
DP()

Fixed submission:
N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for i in range(N)]
 
dp=[[0]*(W+1) for i in range(N+1)]
 
for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]
 
 
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
def DP():
    N, W = map(int, input().split())
    wv = [[int(i) for i in input().split()] for i in range(N)]

    dp=[[0]*(W+1) for i in range(N+1)]

    for w in range(W+1):
        for n in range(N):
            if wv[n][0] <= w:
                dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
            else:
                dp[n+1][w] = dp[n][w]
    return dp[N][W]


print(DP())

Fixed submission:
N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for i in range(N)]
 
dp=[[0]*(W+1) for i in range(N+1)]
 
for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]
 
 
print(dp[N][W])

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

dp=[[0]*(W+1) for i in range(N+1)]

for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]


print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for i in range(N)]
 
dp=[[0]*(W+1) for i in range(N+1)]
 
for w in range(W+1):
    for n in range(N):
        if wv[n][0] <= w:
            dp[n+1][w] = max(dp[n][w-wv[n][0]] + wv[n][1], dp[n][w])
        else:
            dp[n+1][w] = dp[n][w]
 
 
print(dp[N][W])