Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import copy

def main():
    N, W= map(int, raw_input().split())
    dp = np.zeros(W+1)
 
    for i in range(N):
        w, v = map(int, raw_input().split())
        dp_temp = copy.deepcopy(dp)
        for j in range(W+1):
            dp_pre = dp[j]
            if j-w > -1:
                dp_update = dp[j-w] + v
            else:
                dp_update = 0
            dp_temp[j] = max(dp_pre, dp_update)
 
        dp = dp_temp
 
    print int(dp[-1])

main()

Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, raw_input().split())
dp = [0]*(W+1)
 
for i in xrange(N):
    w, v = map(int, raw_input().split())
    for j in xrange(W, w-1, -1):
        x = dp[j-w] + v
        if x > dp[j]:
            dp[j] = x
 
print dp[-1]

Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, raw_input().split())
a = []
for i in range(N):
    a.append(map(int, raw_input().split()))

dp = [0]*(W+1)

for i in range(N):
    w = a[i][0]
    v = a[i][1]
    for j in range(W, w-1, -1):
        x = dp[j-w] + v
        if x > dp[j]:
            dp[j] = x

print dp[-1]

Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Runtime Error):
, W = map(int, raw_input().split())
a = []
for i in range(N):
    a.append(map(int, raw_input().split()))

dp = [0]*(W+1)

for i in range(N):
    w = a[i][0]
    v = a[i][1]
    for j in range(W, w-1, -1):
        x = dp[j-w] + v
        if x > dp[j]:
            dp[j] = x

print dp[-1]

Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, raw_input().split())
dp = [0]*(W+1)

for i in range(N):
    w, v = map(int, raw_input().split())
    for j in range(W, w-1, -1):
        x = dp[j-w] + v
        if x > dp[j]:
            dp[j] = x

print dp[-1]

Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, raw_input().split())
dp = [0]*(W+1)

for i in range(N):
    w, v = map(int, raw_input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w]+v)

print dp[-1]

Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, W = map(int, raw_input().split())
dp = np.zeros(W+1)

for i in range(N):
    w, v = map(int, raw_input().split())
    for j in range(W, w-1, -1):
        x = dp[j-w]+v
        if x > dp[j]:
            dp[j] = x


print int(dp[-1])



Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, W = map(int, raw_input().split())
dp = np.zeros(W+1)

for i in range(N):
    w, v = map(int, raw_input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w]+v)
 
print int(dp[-1])


Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, W = map(int, raw_input().split())
dp = np.zeros((W+1, N))

for i in range(N):
    w, v = map(int, raw_input().split())
    max_temp = 0
    for j in range(w):
        dp[j][i] = dp[j][i-1]
    for j in range(w, W+1):
        dp[j][i] = max(dp[j][i-1], dp[j-w][i-1]+v, max_temp)
        max_temp = dp[j][i]
 
print int(dp[-1][-1])


Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import copy
 
N, W = map(int, raw_input().split())
dp = np.zeros((W+1, N))

w, v = map(int, raw_input().split())

dp[w][0] = v

for i in range(1, N):
    w, v = map(int, raw_input().split())
    for j in range(W+1):
        dp_pre = dp[j]
        if j-w > -1:
            dp_update = dp[j-w][i-1] + v
        else:
            dp_update = 0
        dp[j][i] = max(dp[j][i-1], dp_update)

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

Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import copy

N, W= map(int, raw_input().split())
dp = np.zeros(W+1)

for i in range(N):
   w, v = map(int, raw_input().split())
   dp_temp = copy.deepcopy(dp)
   for j in range(W+1):
      dp_pre = dp[j]
      if j-w > -1:
         dp_update = dp[j-w] + v
      else:
         dp_update = 0
      dp_temp[j] = max(dp_pre, dp_update)

   dp = dp_temp

print int(dp[-1])

Fixed submission:
def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()