Buggy python submission (verdict: Time Limit Exceeded):
from pprint import pprint
import numpy as np
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)]

wv.sort(key=lambda x:x[1])
#print(wv)
for i in range(n):
  #print("i={}".format(i))    
  for wsum in range(1,w+1):
    #print("重さ：{}".format(wsum))
    if wsum >= wv[i][0]:
        if dp[i+1][wsum] < dp[i][wsum-wv[i][0]]+wv[i][1]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wv[i][0]]+wv[i][1]
    else:
      dp[i+1][wsum] = dp[i][wsum]
    #pprint(dp)


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


Fixed submission:
from pprint import pprint
import numpy as np
import numba as nb
@nb.njit
def Knapsack1(n,w,wl,vl):
  dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
  for wsum in range(1,w+1):
  	#print("i={}".format(i))    
    for i in range(n):
      #print("重さ：{}".format(wsum))
      if wsum >= wl[i]:
        if dp[i][wsum] < dp[i][wsum-wl[i]]+vl[i]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
        else:
          dp[i+1][wsum] = dp[i][wsum]
          
      else:
        dp[i+1][wsum] = dp[i][wsum]
  #print(dp)
  print(dp[-1][-1])

n,w=map(int, input().split())
wv=[list(map(int,input().split()))  for i in  range(n)]
wv.sort(key=lambda x:(x[1],x[0]))
wv=np.array(wv)
wv=wv.T
wl=wv[0]
vl=wv[1]
#print(wl)
#print(vl)
Knapsack1(n,w,wl,vl)

Buggy python submission (verdict: Time Limit Exceeded):
from pprint import pprint
import numpy as np
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 i in range(n):
      #print("重さ：{}".format(wsum))
  for wsum in range(1,w+1):
    #print("i={}".format(i))
    if wsum >= wv[i][0]:
        #print("選ぶ, (重さ：{}, 価値：{})".format(wl[i], vl[i]))
        dp[i][wsum] = max(dp[i-1][wsum], dp[i-1][wsum-wv[i][0]]+wv[i][1])
    else:
      dp[i][wsum] = dp[i-1][wsum]
    #pprint(dp)

dp=np.array(dp)
print(np.max(dp))
      

Fixed submission:
from pprint import pprint
import numpy as np
import numba as nb
@nb.njit
def Knapsack1(n,w,wl,vl):
  dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
  for wsum in range(1,w+1):
  	#print("i={}".format(i))    
    for i in range(n):
      #print("重さ：{}".format(wsum))
      if wsum >= wl[i]:
        if dp[i][wsum] < dp[i][wsum-wl[i]]+vl[i]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
        else:
          dp[i+1][wsum] = dp[i][wsum]
          
      else:
        dp[i+1][wsum] = dp[i][wsum]
  #print(dp)
  print(dp[-1][-1])

n,w=map(int, input().split())
wv=[list(map(int,input().split()))  for i in  range(n)]
wv.sort(key=lambda x:(x[1],x[0]))
wv=np.array(wv)
wv=wv.T
wl=wv[0]
vl=wv[1]
#print(wl)
#print(vl)
Knapsack1(n,w,wl,vl)

Buggy python submission (verdict: Time Limit Exceeded):
from pprint import pprint
import numpy as np
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 i in range(n):
      #print("重さ：{}".format(wsum))
  for wsum in range(1,w+1):
    #print("i={}".format(i))
    if wsum >= wv[i][0]:
        #print("選ぶ, (重さ：{}, 価値：{})".format(wl[i], vl[i]))
        dp[i+1][wsum] = max(dp[i+1][wsum], dp[i][wsum-wv[i][0]]+wv[i][1])
    else:
      dp[i+1][wsum] = dp[i][wsum]
    #pprint(dp)

dp=np.array(dp)
print(np.max(dp))
      

Fixed submission:
from pprint import pprint
import numpy as np
import numba as nb
@nb.njit
def Knapsack1(n,w,wl,vl):
  dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
  for wsum in range(1,w+1):
  	#print("i={}".format(i))    
    for i in range(n):
      #print("重さ：{}".format(wsum))
      if wsum >= wl[i]:
        if dp[i][wsum] < dp[i][wsum-wl[i]]+vl[i]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
        else:
          dp[i+1][wsum] = dp[i][wsum]
          
      else:
        dp[i+1][wsum] = dp[i][wsum]
  #print(dp)
  print(dp[-1][-1])

n,w=map(int, input().split())
wv=[list(map(int,input().split()))  for i in  range(n)]
wv.sort(key=lambda x:(x[1],x[0]))
wv=np.array(wv)
wv=wv.T
wl=wv[0]
vl=wv[1]
#print(wl)
#print(vl)
Knapsack1(n,w,wl,vl)

Buggy python submission (verdict: Time Limit Exceeded):
from pprint import pprint
import numpy as np
n,w=map(int, input().split())
wl,vl=[],[]
wsum=0
for i in range(n):
  wn,v=map(int, input().split())
  wl.append(wn)
  vl.append(v)
  wsum+=w
if wsum<w:
  w=wsum

dp=[[0]*(w+1) for i in range(n+1)]
wmin=min(wl)

for wsum in range(wmin,w+1):
  #print("重さ：{}".format(wsum))
  for i in range(n):
    #print("i={}".format(i))
    if wsum-wl[i]>=0:
      if dp[i+1][wsum] < dp[i][wsum-wl[i]]+vl[i]:
        #print("選ぶ, (重さ：{}, 価値：{})".format(wl[i], vl[i]))
        dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
    else:
      dp[i+1][wsum] = dp[i][wsum]
    #pprint(dp)
dp=np.array(dp)
print(np.max(dp))
      


Fixed submission:
from pprint import pprint
import numpy as np
import numba as nb
@nb.njit
def Knapsack1(n,w,wl,vl):
  dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
  for wsum in range(1,w+1):
  	#print("i={}".format(i))    
    for i in range(n):
      #print("重さ：{}".format(wsum))
      if wsum >= wl[i]:
        if dp[i][wsum] < dp[i][wsum-wl[i]]+vl[i]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
        else:
          dp[i+1][wsum] = dp[i][wsum]
          
      else:
        dp[i+1][wsum] = dp[i][wsum]
  #print(dp)
  print(dp[-1][-1])

n,w=map(int, input().split())
wv=[list(map(int,input().split()))  for i in  range(n)]
wv.sort(key=lambda x:(x[1],x[0]))
wv=np.array(wv)
wv=wv.T
wl=wv[0]
vl=wv[1]
#print(wl)
#print(vl)
Knapsack1(n,w,wl,vl)

Buggy python submission (verdict: Time Limit Exceeded):
from pprint import pprint
import numpy as np
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 wsum in range(1,w+1):
  #print("重さ：{}".format(wsum))
  for i in range(n):
    #print("i={}".format(i))
    if wsum >= wv[i][0]:
        #print("選ぶ, (重さ：{}, 価値：{})".format(wl[i], vl[i]))
        dp[i+1][wsum] = max(dp[i+1][wsum], dp[i][wsum-wv[i][0]]+wv[i][1])
    else:
      dp[i+1][wsum] = dp[i][wsum]
    #pprint(dp)
dp=np.array(dp)
print(np.max(dp))


Fixed submission:
from pprint import pprint
import numpy as np
import numba as nb
@nb.njit
def Knapsack1(n,w,wl,vl):
  dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
  for wsum in range(1,w+1):
  	#print("i={}".format(i))    
    for i in range(n):
      #print("重さ：{}".format(wsum))
      if wsum >= wl[i]:
        if dp[i][wsum] < dp[i][wsum-wl[i]]+vl[i]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
        else:
          dp[i+1][wsum] = dp[i][wsum]
          
      else:
        dp[i+1][wsum] = dp[i][wsum]
  #print(dp)
  print(dp[-1][-1])

n,w=map(int, input().split())
wv=[list(map(int,input().split()))  for i in  range(n)]
wv.sort(key=lambda x:(x[1],x[0]))
wv=np.array(wv)
wv=wv.T
wl=wv[0]
vl=wv[1]
#print(wl)
#print(vl)
Knapsack1(n,w,wl,vl)

Buggy python submission (verdict: Time Limit Exceeded):
from pprint import pprint
import numpy as np
n,w=map(int, input().split())
wl,vl=[],[]
wsum=0
for i in range(n):
  wn,v=map(int, input().split())
  wl.append(wn)
  vl.append(v)
  wsum+=w
if wsum<w:
  w=wsum

dp=[[0]*(w+1) for i in range(n+1)]
wmin=min(wl)

for wsum in range(wmin,w+1):
  #print("重さ：{}".format(wsum))
  for i in range(n):
    #print("i={}".format(i))
    if wsum >= wl[i]:
        #print("選ぶ, (重さ：{}, 価値：{})".format(wl[i], vl[i]))
        dp[i+1][wsum] = max(dp[i+1][wsum], dp[i][wsum-wl[i]]+vl[i])
    else:
      dp[i+1][wsum] = dp[i][wsum]
    #pprint(dp)
dp=np.array(dp)
print(np.max(dp))


Fixed submission:
from pprint import pprint
import numpy as np
import numba as nb
@nb.njit
def Knapsack1(n,w,wl,vl):
  dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
  for wsum in range(1,w+1):
  	#print("i={}".format(i))    
    for i in range(n):
      #print("重さ：{}".format(wsum))
      if wsum >= wl[i]:
        if dp[i][wsum] < dp[i][wsum-wl[i]]+vl[i]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
        else:
          dp[i+1][wsum] = dp[i][wsum]
          
      else:
        dp[i+1][wsum] = dp[i][wsum]
  #print(dp)
  print(dp[-1][-1])

n,w=map(int, input().split())
wv=[list(map(int,input().split()))  for i in  range(n)]
wv.sort(key=lambda x:(x[1],x[0]))
wv=np.array(wv)
wv=wv.T
wl=wv[0]
vl=wv[1]
#print(wl)
#print(vl)
Knapsack1(n,w,wl,vl)

Buggy python submission (verdict: Time Limit Exceeded):
from pprint import pprint
import numpy as np
n,w=map(int, input().split())
wl,vl=[],[]
wsum=0
for i in range(n):
  wn,v=map(int, input().split())
  wl.append(wn)
  vl.append(v)
  wsum+=w
if wsum<w:
  w=wsum

dp=[[0]*(w+1) for i in range(n+1)]
wmin=min(wl)

for wsum in range(wmin,w+1):
  #print("重さ：{}".format(wsum))
  for i in range(n):
    #print("i={}".format(i))
    if wsum-wl[i]>=0:
      if dp[i+1][wsum] < dp[i][wsum-wl[i]]+vl[i]:
        #print("選ぶ, (重さ：{}, 価値：{})".format(wl[i], vl[i]))
        dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
    else:
      dp[i+1][wsum] = dp[i][wsum]
    #pprint(dp)
dp=np.array(dp)
print(np.max(dp))
      

Fixed submission:
from pprint import pprint
import numpy as np
import numba as nb
@nb.njit
def Knapsack1(n,w,wl,vl):
  dp = np.zeros(shape=(n + 1, w + 1), dtype=np.int64)
  for wsum in range(1,w+1):
  	#print("i={}".format(i))    
    for i in range(n):
      #print("重さ：{}".format(wsum))
      if wsum >= wl[i]:
        if dp[i][wsum] < dp[i][wsum-wl[i]]+vl[i]:
          #print("選ぶ, (重さ：{}, 価値：{})".format(wv[i][0], wv[i][1]))
          dp[i+1][wsum] = dp[i][wsum-wl[i]]+vl[i]
        else:
          dp[i+1][wsum] = dp[i][wsum]
          
      else:
        dp[i+1][wsum] = dp[i][wsum]
  #print(dp)
  print(dp[-1][-1])

n,w=map(int, input().split())
wv=[list(map(int,input().split()))  for i in  range(n)]
wv.sort(key=lambda x:(x[1],x[0]))
wv=np.array(wv)
wv=wv.T
wl=wv[0]
vl=wv[1]
#print(wl)
#print(vl)
Knapsack1(n,w,wl,vl)