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

Fixed submission:
N,W=map(int,input().split())
DP=[[0 for j in range(W+1)]for i in range(N+1)]
for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j>=w:
            DP[i+1][j]=max(DP[i][j-w]+v,DP[i][j])
        else:
            DP[i+1][j]=DP[i][j]
print(DP[N][W])

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

Fixed submission:
N,W=map(int,input().split())
DP=[[0 for j in range(W+1)]for i in range(N+1)]
for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j>=w:
            DP[i+1][j]=max(DP[i][j-w]+v,DP[i][j])
        else:
            DP[i+1][j]=DP[i][j]
print(DP[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
#ナップザック問題
import numpy as np

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


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

Fixed submission:
N,W=map(int,input().split())
DP=[[0 for j in range(W+1)]for i in range(N+1)]
for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j>=w:
            DP[i+1][j]=max(DP[i][j-w]+v,DP[i][j])
        else:
            DP[i+1][j]=DP[i][j]
print(DP[N][W])

Buggy python submission (verdict: Runtime Error):
#ナップザック問題
import numpy as np

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


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

Fixed submission:
N,W=map(int,input().split())
DP=[[0 for j in range(W+1)]for i in range(N+1)]
for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j>=w:
            DP[i+1][j]=max(DP[i][j-w]+v,DP[i][j])
        else:
            DP[i+1][j]=DP[i][j]
print(DP[N][W])

Buggy python submission (verdict: Runtime Error):
#ナップザック問題
import numpy as np

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

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

Fixed submission:
N,W=map(int,input().split())
DP=[[0 for j in range(W+1)]for i in range(N+1)]
for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j>=w:
            DP[i+1][j]=max(DP[i][j-w]+v,DP[i][j])
        else:
            DP[i+1][j]=DP[i][j]
print(DP[N][W])