Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n)]

for j in range(k+1):
    if j >= e[0][0]:
      dp[0][j]=e[0][1]

for i in range(1,n):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=dp[i-1][j]
    else:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-e[i][0]]+e[i][1])

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


Fixed submission:
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n-1,-1,-1):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-e[i][0]]+e[i][1])

print(max(dp[0]))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n-1,-1,-1):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-e[i][0]]+e[i][1])

print(max(dp[0]))


Fixed submission:
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n-1,-1,-1):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-e[i][0]]+e[i][1])

print(max(dp[0]))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n-1,-1,-1):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=0
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-e[i][0]]+e[i][1])

print(dp[0][-1])

Fixed submission:
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n-1,-1,-1):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-e[i][0]]+e[i][1])

print(max(dp[0]))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())

w0=[0 for i in range(n+1)]
v0=[0 for i in range(n+1)]
for i in range(1,n+1):
  (w0[i],v0[i]) = (int(i) for i in input().split())
  
w=[0]
v=[0]
for j in range(1,n+1):
    for i in range(len(w)):
        if w[i]+w0[j] <= k:
            w=w+[w[i]+w0[j]]
            v=v+[v[i]+v0[j]]  

#print(n,k,w0,v0)
print(max(v))




Fixed submission:
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n-1,-1,-1):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-e[i][0]]+e[i][1])

print(max(dp[0]))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())

w0=[0 for i in range(n+1)]
v0=[0 for i in range(n+1)]
for i in range(1,n+1):
  (w0[i],v0[i]) = (int(i) for i in input().split())
  
w=[0]
v=[0]
for j in range(1,n+1):
    for i in range(len(w)):
        if w[i]+w0[j] <= k:
            w.append(w[i]+w0[j])
            v.append(v[i]+v0[j])  

#print(n,k,w0,v0)
print(max(v))


Fixed submission:
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n-1,-1,-1):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-e[i][0]]+e[i][1])

print(max(dp[0]))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=(int(i) for i in input().split())

w0=[0 for i in range(n+1)]
v0=[0 for i in range(n+1)]
for i in range(1,n+1):
  (w0[i],v0[i]) = (int(i) for i in input().split())
  
w=[0]
v=[0]
for j in range(1,n+1):
    for i in range(len(w)):
        if w[i]+w0[j] <= k:
            w.append(w[i]+w0[j])
            v.append(v[i]+v0[j])  

#print(n,k,w0,v0)
print(max(v))


Fixed submission:
n,k=(int(i) for i in input().split())

e = [[int(i) for i in input().split()] for j in range(n)]
#print(e)

dp=[[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n-1,-1,-1):
  for j in range(k+1):
    if j < e[i][0]:
      dp[i][j]=dp[i+1][j]
    else:
      dp[i][j]=max(dp[i+1][j],dp[i+1][j-e[i][0]]+e[i][1])

print(max(dp[0]))