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] = input().split()
    w[i], v[i] = int(w[i]), int(v[i])

def func(N, W):
    dp = [0] * (W+1)
    for i in range(N):
        for j in range(W, w[i]-1, -1):
            a = dp[j-w[i]] + v[i]
            if dp[j] < a:
                dp[j] = a
    return dp[W]

print(func(N, W))

Fixed submission:
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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())

def func(N, W):
    dp = [0] * (W+1)
    for i in range(N):
        for j in range(W, w[i]-1, -1):
            a = dp[j-w[i]] + v[i]
            if dp[j] < a:
                dp[j] = a
    return dp[W]

print(func(N, W))

Fixed submission:
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])

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())

def func(N, W):
    dp = [0] * (W+1)
    for i in range(N):
        for j in range(W, w[i]-1, -1):
            a = dp[j-w[i]] + v[i]
            if dp[j] < a:
                dp[j] = a
    return dp[W]

print(func(N, W))

Fixed submission:
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])

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):
    for j in range(W, w[i]-1, -1):
        a = dp[j-w[i]] + v[i]
        if dp[j] < a:
            dp[j] = a

print(dp[W])

Fixed submission:
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])

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):
    for j in range(W, w[i]-1, -1):
        dp[j] = max(dp[j], dp[j-w[i]] + v[i])

print(dp[W])

Fixed submission:
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())

dp = [0] * (W+1)
wv = [tuple(map(int, input().split())) for _ in range(N)]
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(dp[W])

Fixed submission:
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w]+v)

print(dp[W])

Fixed submission:
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = list(map(lambda x: int(x), input().split()))

wV = [list(map(lambda x: int(x), input().split())) for _ in range(N)]

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

for i in range(N):
	for j in range(W + 1):
		if j + wV[i][0] <= W:
			dp[i + 1][j + wV[i][0]] = dp[i][j] + wV[i][1]
		
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
		
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])