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

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

Fixed submission:
N,W = map(int,input().split())
array = []
for i in range(N):
    wv = list(map(int,input().split()))
    array.append(wv)
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j-array[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j-array[i][0]]+array[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    
    N,W = map(int,input().split())
    wa = []
    va = []
    for i in range(N):
        w,v = map(int,input().split())
        wa.append(w)
        va.append(v)
    dp = [[0 for i in range(W+1)] for j in range(N+1)]
    for i in range(N):
        for j in range(W+1):
            if j-wa[i] >= 0:
                dp[i+1][j] = max(dp[i][j],dp[i][j-wa[i]]+va[i])
            else:
                dp[i+1][j] = dp[i][j]

    print(dp[-1][-1])
main()

Fixed submission:
N,W = map(int,input().split())
array = []
for i in range(N):
    wv = list(map(int,input().split()))
    array.append(wv)
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j-array[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j-array[i][0]]+array[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    
    N,W = map(int,input().split())
    array = []
    for i in range(N):
        wv = list(map(int,input().split()))
        array.append(wv)
    dp = [[0 for i in range(W+1)] for j in range(N+1)]
    for i in range(N):
        for j in range(W+1):
            if j-array[i][0] >= 0:
                dp[i+1][j] = max(dp[i][j],dp[i][j-array[i][0]]+array[i][1])
            else:
                dp[i+1][j] = dp[i][j]

    print(dp[-1][-1])
main()

Fixed submission:
N,W = map(int,input().split())
array = []
for i in range(N):
    wv = list(map(int,input().split()))
    array.append(wv)
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j-array[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j-array[i][0]]+array[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[-1][-1])

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

Fixed submission:
N,W = map(int,input().split())
array = []
for i in range(N):
    wv = list(map(int,input().split()))
    array.append(wv)
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j-array[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j-array[i][0]]+array[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
def main():
    N,W = map(int,input().split())
    wvlist = []
    dp =[[0 for i in range(W+1)] for j in range(N+1)]
    for i in range(N):
        lista = list(map(int,input().split()))
        wvlist.append(lista)
    for i in range(N):
        for j in range(W+1):
            if wvlist[i][0] <= j:
                dp[i+1][j] = max(dp[i+1][j],dp[i][j-wvlist[i][0]]+wvlist[i][1])
            else:
                dp[i+1][j] = dp[i][j]
    print(np.amax(dp))            
        
    
    
main()

Fixed submission:
N,W = map(int,input().split())
array = []
for i in range(N):
    wv = list(map(int,input().split()))
    array.append(wv)
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j-array[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j-array[i][0]]+array[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
def main():
    N,W = map(int,input().split())
    wvlist = []
    dp =[[0 for i in range(W+1)] for j in range(N+1)]
    for i in range(N):
        lista = list(map(int,input().split()))
        wvlist.append(lista)
    sumax = sum(wvlist[i][0] for i in range(N))
    sumin = min(wvlist[i][0] for i in range(N))
    vamax = sum(wvlist[i][1] for i in range(N))
    if sumax <= W:
        print(vamax)
    elif sumin > W:
        print(0)
    else:
        for i in range(N):
            for j in range(W+1):
                if wvlist[i][0] <= j:
                    dp[i+1][j] = max(dp[i+1][j],dp[i][j-wvlist[i][0]]+wvlist[i][1])
                else:
                    dp[i+1][j] = dp[i][j]
        print(np.amax(dp))            
        
    
    
main()

Fixed submission:
N,W = map(int,input().split())
array = []
for i in range(N):
    wv = list(map(int,input().split()))
    array.append(wv)
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j-array[i][0] >= 0:
            dp[i+1][j] = max(dp[i][j],dp[i][j-array[i][0]]+array[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[-1][-1])