Buggy python submission (verdict: Runtime Error):
#include<stdio.h>
int max(int a,int b){
    int h=a;
    if(b>a)h=b;
    return h;
}
int set(int n,int w[],int v[],int W){
    if(n==0){
        return 0;
    }else if(w[n-1]>W){
        return set(n-1,w,v,W);
    }else{
        return max(set(n-1,w,v,W),set(n-1,w,v,W-w[n-1])+v[n-1]);
    }
}
int main(void){
    int N,W;
    scanf("%d%d",&N,&W);
    int v[N],w[N];
    for(int i=0;i<N;i++){
        scanf("%d%d",&v[i],&w[i]);
    }
    printf("%d\n",set(N,w,v,W));
    return 0;
}


Fixed submission:
import numpy as np
N,W=map(int,input().split())
w=[0 for i in range(N)]
v=[0 for i in range(N)]
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[0 for i in range(W+1)]
dp=np.array(dp)
for i in range(N):
    dp[w[i]:]=np.maximum(dp[w[i]:],dp[:W-w[i]+1]+v[i])
print(dp.max())

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def solve(i,j,dp,w,v):
    if dp[i][j]!=0:
        return dp[i][j]
    else:
        if i==0:
            dp[i][j]=0
            return dp[i][j]
        if j<w[i-1]:
            dp[i][j]=solve(i-1,j,dp,w,v)
            return dp[i][j]
        else:
            dp[i][j]=max(solve(i-1,j,dp,w,v),solve(i-1,j-w[i-1],dp,w,v)+v[i-1])
            return dp[i][j]
sys.setrecursionlimit(10000000)
N,W=map(int,input().split())
w=[0 for i in range(N)]
v=[0 for i in range(N)]
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[[0 for j in range(W+1)] for i in range(N+1)]
print(solve(N,W,dp,w,v))


Fixed submission:
import numpy as np
N,W=map(int,input().split())
w=[0 for i in range(N)]
v=[0 for i in range(N)]
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[0 for i in range(W+1)]
dp=np.array(dp)
for i in range(N):
    dp[w[i]:]=np.maximum(dp[w[i]:],dp[:W-w[i]+1]+v[i])
print(dp.max())

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


Fixed submission:
import numpy as np
N,W=map(int,input().split())
w=[0 for i in range(N)]
v=[0 for i in range(N)]
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[0 for i in range(W+1)]
dp=np.array(dp)
for i in range(N):
    dp[w[i]:]=np.maximum(dp[w[i]:],dp[:W-w[i]+1]+v[i])
print(dp.max())

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


Fixed submission:
import numpy as np
N,W=map(int,input().split())
w=[0 for i in range(N)]
v=[0 for i in range(N)]
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[0 for i in range(W+1)]
dp=np.array(dp)
for i in range(N):
    dp[w[i]:]=np.maximum(dp[w[i]:],dp[:W-w[i]+1]+v[i])
print(dp.max())