Buggy python submission (verdict: Time Limit Exceeded):
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
c = []
for i in range(n):
    a, b = map(int, input().split())
    c += [a]*min(b,m)
c.sort()
print(sum(c[:m]))

Fixed submission:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ab = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a,b))
ab = sorted(ab)
for c, d in ab:
    if m >= d:
        ans += c*d
        m -= d
    else:
        ans += c*m
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
c = []
for i in range(n):
    a, b = map(int, input().split())
    c += [a]*min(b,m)
c.sort()
print(sum(c[:m]))

Fixed submission:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ab = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a,b))
ab = sorted(ab)
for c, d in ab:
    if m >= d:
        ans += c*d
        m -= d
    else:
        ans += c*m
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
match = 0
ans = 0
mini = min(a)

for j in range(n):
    for k in range(b[a.index(mini)]):
        if m <= match:
            break
        ans += mini
        match += 1
    
    b.pop(a.index(mini))
    a.remove(mini)
    mini = min(a)
print(ans)

Fixed submission:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ab = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a,b))
ab = sorted(ab)
for c, d in ab:
    if m >= d:
        ans += c*d
        m -= d
    else:
        ans += c*m
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
match = 0
ans = 0

for j in min(a):
    for k in range(b[a.index(j)]):
        if m <= match:
            break
        ans += j
        match += 1
    
    b.pop(a.index(j))
    a.remove(j)
print(ans)

Fixed submission:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ab = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a,b))
ab = sorted(ab)
for c, d in ab:
    if m >= d:
        ans += c*d
        m -= d
    else:
        ans += c*m
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
match = 0
ans = 0
mini = 0

for j in range(n):
    mini = min(a)
    
    for k in range(b[a.index(mini)]):
        if m <= match:
            break
        ans += mini
        match += 1
    
    b.pop(a.index(mini))
    a.remove(mini)
print(ans)

Fixed submission:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ab = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a,b))
ab = sorted(ab)
for c, d in ab:
    if m >= d:
        ans += c*d
        m -= d
    else:
        ans += c*m
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
match = 0
ans = 0
mini = 0

while 1:
    mini = min(a)
    
    for j in range(b[a.index(mini)]):
        ans += mini
        match += 1
        if m == match:
            break
    
    a.remove(mini)
print(ans)

Fixed submission:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ab = []
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a,b))
ab = sorted(ab)
for c, d in ab:
    if m >= d:
        ans += c*d
        m -= d
    else:
        ans += c*m
        break
print(ans)