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

AB.sort()

print(sum(AB[:M]))

Fixed submission:
N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort()

ans = 0
cnt = 0

for ab in AB:
    for b in range(ab[1]):
        ans += ab[0]
        cnt += 1
        if cnt==M:
            break
    if cnt==M:
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
N, M = map(int, input().split())
 
AB = []
 
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort(key=lambda x: x[0])
whole = [0]*sum([i[1] for i in AB])
cnt = 0
 
for ab in AB:
    for b in range(ab[1]):
        whole[cnt] = ab[0]
        cnt += 1

ans = list(accumulate(whole))

print(ans[M-1])

Fixed submission:
N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort()

ans = 0
cnt = 0

for ab in AB:
    for b in range(ab[1]):
        ans += ab[0]
        cnt += 1
        if cnt==M:
            break
    if cnt==M:
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
N, M = map(int, input().split())
 
AB = []
 
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort(key=lambda x: x[0])
whole = [None]*sum([i[1] for i in AB])
cnt = 0
 
for ab in AB:
    for b in range(ab[1]):
        whole[cnt] = ab[0]
        cnt += 1

ans = list(accumulate(whole))

print(ans[M-1])

Fixed submission:
N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort()

ans = 0
cnt = 0

for ab in AB:
    for b in range(ab[1]):
        ans += ab[0]
        cnt += 1
        if cnt==M:
            break
    if cnt==M:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
N, M = map(int, input().split())
 
AB = []
 
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort(key=lambda x: x[0])
 
ans = 0
cnt = 0
whole = []
 
for ab in AB:
    for b in range(ab[1]):
        whole.append(ab[0])

ans = list(accumulate(whole))

print(ans[M-1])

Fixed submission:
N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort()

ans = 0
cnt = 0

for ab in AB:
    for b in range(ab[1]):
        ans += ab[0]
        cnt += 1
        if cnt==M:
            break
    if cnt==M:
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())

AB = np.zeros([N, 2], dtype=int)

for i in range(N):
    a, b = map(int, input().split())
    AB[i] = np.array([a, b])

AB = np.sort(AB, axis=0)

cnt = 0
whole = np.zeros(AB[:, 1].sum(), dtype=int)

for ab in AB:
    for b in range(ab[1]):
        whole[cnt] = ab[0]
        cnt += 1

whole = whole.cumsum()

print(int(whole[M-1]))

Fixed submission:
N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort()

ans = 0
cnt = 0

for ab in AB:
    for b in range(ab[1]):
        ans += ab[0]
        cnt += 1
        if cnt==M:
            break
    if cnt==M:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort(key=lambda x: x[0])

ans = 0
cnt = 0
whole = []

for ab in AB:
    for b in range(ab[1]):
        whole.append(ab[0])

whole = np.array(whole)
whole = whole.cumsum()

print(whole[M-1])

Fixed submission:
N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort()

ans = 0
cnt = 0

for ab in AB:
    for b in range(ab[1]):
        ans += ab[0]
        cnt += 1
        if cnt==M:
            break
    if cnt==M:
        break

print(ans)