Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, W = map(int, input().split())
    dp = [[0] * (W+1) for i in range(N+1)]
    #dp[i][j]  iまでをみてjの重さでの最大価値
    for i in range(1,N+1):
        w, v = map(int, input().split())
        dp[i][:] = dp[i-1][:]
        for j in range(w, W+1):
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v)
#    print(dp)
    print(dp[N][W])

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, W = map(int, input().split())
    dp = [[0] * (W+1) for i in range(N+1)]
    #dp[i][j]  iまでをみてjの重さでの最大価値
    for i in range(1,N+1):
        w, v = map(int, input().split())
        for j in range(W+1):
            if j-w>=0:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v)
            else:
                dp[i][j] = dp[i-1][j]
#    print(dp)
    print(dp[N][W])

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N,W=map(int,input().split())
dp=[0]*(W+1)
for i in range(N):
  wi,vi=map(int,input().split())
  for w in range(W,wi-1,-1):
    dp[w]=max(dp[w],dp[w-wi]+vi)
print(dp[W])

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N,W=map(int,input().split())
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
  wi,vi=map(int,input().split())
  for w in range(W+1):
    if w>=wi:
      dp[i+1][w]=max(dp[i][w],dp[i][w-wi]+vi)
    else:
      dp[i+1][w]=dp[i][w]
print(dp[N][W])

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
DP = [[0] * (W+1) for i in range(N+1)]
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  for w in range(1,W+1):
    if w >= wn:
      DP[n][w] = max(DP[n-1][w-wn] + vn, DP[n-1][w])
    else:
      DP[n][w] = DP[n-1][w]
print(DP[N][W])

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])

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

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])

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

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=np.int)
for n in range(1,N+1):
  wn, vn = map(int, input().split())
  dp[wn:]=np.maximum(dp[wn:], dp[:-wn]+vn)
print(dp[W])