Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
read = sys.stdin.read

N, W, *wv = map(int, read().split())
dp = np.zeros((W + 1, N + 1), np.int64)
idx = 1

for w, v in zip(*[iter(wv)] * 2):
    dp[:, idx] = dp[:, idx - 1]
    if w <= W:
        dp[w:, idx] = np.maximum(dp[w:, idx], dp[:-w, idx] + v)
    idx += 1

print(dp[-1, -1])

Fixed submission:
import sys
from itertools import accumulate, product
from operator import itemgetter
read = sys.stdin.read

N, W, *wv = map(int, read().split())
w1 = wv[0]
V = [[0] for _ in range(4)]

for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True):
    V[w - w1].append(v)


V = list(map(list, map(accumulate, V)))
n = [len(V[i]) for i in range(4)]
answer = 0
for a, b, c, d in product(range(n[0]), range(n[1]), range(n[2]), range(n[3])):
    if b + c * 2 + d * 3 + (a + b + c + d) * w1 > W:
        continue

    v = V[0][a] + V[1][b] + V[2][c] + V[3][d]
    if v > answer:
        answer = v

print(answer)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
read = sys.stdin.read

N, W, *wv = map(int, read().split())
dp = np.zeros((W + 1, N + 1), np.int64)
idx = 1

for w, v in zip(*[iter(wv)] * 2):
    if w > W:
        continue

    dp[:, idx] = dp[:, idx - 1]
    dp[w:, idx] = np.maximum(dp[w:, idx], dp[:-w, idx] + v)
    idx += 1

print(dp[-1, -1])

Fixed submission:
import sys
from itertools import accumulate, product
from operator import itemgetter
read = sys.stdin.read

N, W, *wv = map(int, read().split())
w1 = wv[0]
V = [[0] for _ in range(4)]

for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True):
    V[w - w1].append(v)


V = list(map(list, map(accumulate, V)))
n = [len(V[i]) for i in range(4)]
answer = 0
for a, b, c, d in product(range(n[0]), range(n[1]), range(n[2]), range(n[3])):
    if b + c * 2 + d * 3 + (a + b + c + d) * w1 > W:
        continue

    v = V[0][a] + V[1][b] + V[2][c] + V[3][d]
    if v > answer:
        answer = v

print(answer)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
read = sys.stdin.read

N, W, *wv = map(int, read().split())
dp = np.zeros((W + 1, N + 1), np.int64)
idx = 1

for w, v in zip(*[iter(wv)] * 2):
    if w > W:
        continue

    dp[:, idx] = dp[:, idx - 1]
    dp[w:, idx] = np.maximum(dp[w:, idx], dp[:W - w + 1, idx] + v)
    idx += 1

print(dp[-1, -1])

Fixed submission:
import sys
from itertools import accumulate, product
from operator import itemgetter
read = sys.stdin.read

N, W, *wv = map(int, read().split())
w1 = wv[0]
V = [[0] for _ in range(4)]

for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True):
    V[w - w1].append(v)


V = list(map(list, map(accumulate, V)))
n = [len(V[i]) for i in range(4)]
answer = 0
for a, b, c, d in product(range(n[0]), range(n[1]), range(n[2]), range(n[3])):
    if b + c * 2 + d * 3 + (a + b + c + d) * w1 > W:
        continue

    v = V[0][a] + V[1][b] + V[2][c] + V[3][d]
    if v > answer:
        answer = v

print(answer)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
read = sys.stdin.read

N, W, *wv = map(int, read().split())
dp = np.zeros((W + 1, N + 1), np.int64)
idx = 1

for w, v in zip(*[iter(wv)] * 2):
    dp[:, idx] = dp[:, idx - 1]
    dp[w:, idx] = np.maximum(dp[w:, idx], dp[:W - w + 1, idx] + v)
    idx += 1

print(dp[-1, -1])

Fixed submission:
import sys
from itertools import accumulate, product
from operator import itemgetter
read = sys.stdin.read

N, W, *wv = map(int, read().split())
w1 = wv[0]
V = [[0] for _ in range(4)]

for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True):
    V[w - w1].append(v)


V = list(map(list, map(accumulate, V)))
n = [len(V[i]) for i in range(4)]
answer = 0
for a, b, c, d in product(range(n[0]), range(n[1]), range(n[2]), range(n[3])):
    if b + c * 2 + d * 3 + (a + b + c + d) * w1 > W:
        continue

    v = V[0][a] + V[1][b] + V[2][c] + V[3][d]
    if v > answer:
        answer = v

print(answer)