Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().split())
nupList = (map(int, input().split()) for _ in range(N))
dp = [0] * (W + 1)

for w, v in nupList:
    for j in range(W, w - 1, -1 ):
        DP = dp[j - w] + v
        if dp[j] < DP:
            dp[j] = DP

print(dp[W])

Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().split())
dp = [0] * (W + 1)
nupList = (map(int, input().split()) for _ in range(N))

for w, v in nupList:
    for j in range(W, w - 1, -1 ):
        DP = dp[j - w] + v
        if dp[j] < DP:
            dp[j] = DP

print(dp[W])


Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().split())
dp = [0] * (W + 1)
nupList = [map(int, input().split()) for _ in range(N)]

for w, v in nupList:
    for j in range(W, w - 1, -1 ):
        DP = dp[j - w] + v
        if dp[j] < DP:
            dp[j] = DP

print(dp[W])


Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().split())
nupList = [map(int, input().split()) for _ in range(N)]
dp = [0] * (W + 1)

for w, v in nupList:
    for j in range(W, w - 1, -1 ):
        dp[j] = max(dp[j] , dp[j - w] + v)

print(dp[W])

Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

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:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

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

#nupList = [list(map(int, input().split())) for _ in range(N)]

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

for i in range(N):
    w, v = map(int, input().split())

    for j in range(w, W + 1):
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w] + v)
        dp[i + 2][j]  = dp[i + 1][j] 
            

print(dp[N][W])

Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

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

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

for i in range(N):
    w, v = map(int, input().split())

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

print(dp[N][W])

Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())

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

nupList = [list(map(int, input().split())) for _ in range(N)]

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

for i in range(N):

    v = nupList[i][vi]
    w = nupList[i][wi]
    for j in range(W + 1):
        if j < w:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w] + v)

print(dp[N][W])

Fixed submission:
def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)
 
    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())