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

DP = [0] * (W + 1)
for w, v in wvList:
    for rj in range(W, w - 1, -1):
        num = DP[rj - w] + v
        if num > DP[rj]:
            DP[rj] = num

print(max(DP))


Fixed submission:
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))

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

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    w, v = map(int, input().split())
    for rj in range(W, w - 1, -1):
        num = DP[rj - w] + v
        if num > DP[rj]:
            DP[rj] = num

print(max(DP))


Fixed submission:
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))


Fixed submission:
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(max(DP[j - w] + v, element))
        else:
            dp.append(element)
    DP = dp

print(max(DP))


Fixed submission:
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))

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

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, input().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(max(DP[j - w] + v, element))
        else:
            dp.append(element)
    DP = dp.copy()

print(max(DP))


Fixed submission:
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))

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

ans = 0
dp = [[0] * (W + 1) for _ in range(2)]
for i, wv in enumerate(wvList):
    for j in range(1, W + 1):
        numi = 0
        if i % 2 == 0:
            numi = 1
        if j - wv[0] >= 0:
            dp[numi][j] = max(dp[numi-1][j-wv[0]] + wv[1], dp[numi-1][j])
        else:
            dp[numi][j] = dp[numi-1][j]
        ans = max(dp[numi][j], ans)

print(ans)

Fixed submission:
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))

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

dp = [[0] * (W + 1) for _ in range(N)]
for i, wv in enumerate(wvList):
    for j in range(1, W + 1):
        if j - wv[0] >= 0:
            dp[i][j] = max(dp[i-1][j-wv[0]] + wv[1], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

ans = 0
for numList in dp:
    num = max(numList)
    ans = max(ans, num)

print(ans)


Fixed submission:
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))