Buggy python submission (verdict: Time Limit Exceeded):

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

N,W = map(int,input().split())
wv = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N

# dp[i][w] = "番号 i 以下の商品でバッグの重さが w 以下になるように最適に詰めた場合"
dp = np.array([[0]*(W+1)]*(N+1),dtype=np.int64)

# for i in range(1,N+1):
#     for w in range(1,W+1):
#         if w-wv[i-1][0] >= 0:
#             dp[i][w] = max(dp[i-1][w-wv[i-1][0]]+wv[i-1][1] , dp[i-1][w])
#         else:
#             dp[i][w] = dp[i-1][w]

for i in range(1,N+1):
    for w in range(wv[i-1,0],W+1):
        dp[i,w] = max(dp[i-1,w-wv[i-1,0]]+wv[i-1,1] , dp[i-1,w])
    dp[i,1:wv[i-1,0]] = dp[i-1,1:wv[i-1,0]]

print(dp[N][W])


Fixed submission:
def e():
    import numpy as np

    N, W = map(int, input().split())

    dp = np.zeros(W+1, dtype=np.int64)

    for _ in range(N):
        w, v = map(int, input().split())
        np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

    print(dp[-1])


##########
if __name__ == "__main__":
    e()

Buggy python submission (verdict: Time Limit Exceeded):

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

N,W = map(int,input().split())
wv = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N

# dp[i][w] = "番号 i 以下の商品でバッグの重さが w 以下になるように最適に詰めた場合"
dp = np.array([[0]*(W+1)]*(N+1))

# for i in range(1,N+1):
#     for w in range(1,W+1):
#         if w-wv[i-1][0] >= 0:
#             dp[i][w] = max(dp[i-1][w-wv[i-1][0]]+wv[i-1][1] , dp[i-1][w])
#         else:
#             dp[i][w] = dp[i-1][w]

for i in range(1,N+1):
    for w in range(wv[i-1][0],W+1):
        dp[i][w] = max(dp[i-1][w-wv[i-1][0]]+wv[i-1][1] , dp[i-1][w])
    dp[i,1:wv[i-1][0]] = dp[i-1,1:wv[i-1][0]]

print(dp[N][W])


Fixed submission:
def e():
    import numpy as np

    N, W = map(int, input().split())

    dp = np.zeros(W+1, dtype=np.int64)

    for _ in range(N):
        w, v = map(int, input().split())
        np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

    print(dp[-1])


##########
if __name__ == "__main__":
    e()

Buggy python submission (verdict: Time Limit Exceeded):

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

N,W = map(int,input().split())
wv = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N

# dp[i][w] = "番号 i 以下の商品でバッグの重さが w 以下になるように最適に詰めた場合"
dp = np.array([[0]*(W+1)]*(N+1))

for i in range(1,N+1):
    for w in range(1,W+1):
        if w-wv[i-1][0] >= 0:
            dp[i][w] = max(dp[i-1][w-wv[i-1][0]]+wv[i-1][1] , dp[i-1][w])
        else:
            dp[i][w] = dp[i-1][w]

print(dp[N][W])


Fixed submission:
def e():
    import numpy as np

    N, W = map(int, input().split())

    dp = np.zeros(W+1, dtype=np.int64)

    for _ in range(N):
        w, v = map(int, input().split())
        np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

    print(dp[-1])


##########
if __name__ == "__main__":
    e()