Buggy python submission (verdict: Time Limit Exceeded):
N,M = list(map(int,input().split()))
A = []
B = []
ans = 0
for _ in range(N):
    i = list(map(int,input().split()))
    A.append(i[0])
    B.append(i[1])
while M != 0:
    ind_ = A.index(min(A))
    if M - B[ind_] > 0:
        M -= B[ind_]
        ans += A[ind_]*B[ind_]
        B[ind_] -= B[ind_]
    else:
        ans += A[ind_]*M
        break
    if B[ind_] <= 0:
        B.pop(ind_)
        A.pop(ind_)
print(ans)

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

AB = [list(map(int,input().split())) for i in range(N)]
AB.sort()
ans = 0
for _ in range(N):
    if AB[_][1] >= M:
        ans += AB[_][0]*M
        break
    else:
        ans += AB[_][0]*AB[_][1]
        M -= AB[_][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = list(map(int,input().split()))
A = []
B = []
ans = 0
for _ in range(N):
    i = list(map(int,input().split()))
    A.append(i[0])
    B.append(i[1])
while M != 0:
    ind_ = A.index(min(A))
    if M - B[ind_] > 0:
        M -= B[ind_]
        ans = ans + A[ind_]*B[ind_]
        B[ind_] -= B[ind_]
    else:
        ans = ans + A[ind_]*M
        M = 0
        B[ind_] = 0
    if B[ind_] <= 0:
        B.pop(ind_)
        A.pop(ind_)
print(ans)

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

AB = [list(map(int,input().split())) for i in range(N)]
AB.sort()
ans = 0
for _ in range(N):
    if AB[_][1] >= M:
        ans += AB[_][0]*M
        break
    else:
        ans += AB[_][0]*AB[_][1]
        M -= AB[_][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = list(map(int,input().split()))
A = []
B = []
ans = 0
for _ in range(N):
    i = list(map(int,input().split()))
    A.append(i[0])
    B.append(i[1])
while M != 0:
    ind_ = A.index(min(A))
    if M - B[ind_] >= 0:
        M -= B[ind_]
        ans = ans + A[ind_]*B[ind_]
        B[ind_] -= B[ind_]
    else:
        ans = ans + A[ind_]*M
        M = 0
        B[ind_] = 0
    if B[ind_] <= 0:
        B.pop(ind_)
        A.pop(ind_)
print(ans)

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

AB = [list(map(int,input().split())) for i in range(N)]
AB.sort()
ans = 0
for _ in range(N):
    if AB[_][1] >= M:
        ans += AB[_][0]*M
        break
    else:
        ans += AB[_][0]*AB[_][1]
        M -= AB[_][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = list(map(int,input().split()))
A = []
B = []
ans = 0
for _ in range(N):
    i = list(map(int,input().split()))
    A.append(i[0])
    B.append(i[1])
while M != 0:
    if M - B[A.index(min(A))] >= 0:
        M -= B[A.index(min(A))]
        ans = ans + A[A.index(min(A))]*B[A.index(min(A))]
        B[A.index(min(A))] -= B[A.index(min(A))]
    else:
        ans = ans + A[A.index(min(A))]*M
        M = 0
        B[A.index(min(A))] = 0
    if B[A.index(min(A))] <= 0:
        B.pop(A.index(min(A)))
        A.pop(A.index(min(A)))
print(ans)

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

AB = [list(map(int,input().split())) for i in range(N)]
AB.sort()
ans = 0
for _ in range(N):
    if AB[_][1] >= M:
        ans += AB[_][0]*M
        break
    else:
        ans += AB[_][0]*AB[_][1]
        M -= AB[_][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = list(map(int,input().split()))
A = []
B = []
ans = 0
for _ in range(N):
    i = list(map(int,input().split()))
    A.append(i[0])
    B.append(i[1])
#print(min(A),'min')
#print(A.index(min(A)),'index')
while M != 0:
    if M - B[A.index(min(A))] >= 0:
        M -= B[A.index(min(A))]
        ans = ans + A[A.index(min(A))]*B[A.index(min(A))]
        B[A.index(min(A))] -= B[A.index(min(A))]
    else:
        ans += min(A)
        M -= 1
        B[A.index(min(A))] -= 1
    if B[A.index(min(A))] <= 0:
        B.pop(A.index(min(A)))
        A.pop(A.index(min(A)))
print(ans)

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

AB = [list(map(int,input().split())) for i in range(N)]
AB.sort()
ans = 0
for _ in range(N):
    if AB[_][1] >= M:
        ans += AB[_][0]*M
        break
    else:
        ans += AB[_][0]*AB[_][1]
        M -= AB[_][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = list(map(int,input().split()))
A = []
B = []
ans = 0
for _ in range(N):
    i = list(map(int,input().split()))
    A.append(i[0])
    B.append(i[1])
while M != 0:
    ans += min(A)
    M -= 1
    B[A.index(min(A))] -= 1
    if B[A.index(min(A))] <= 0:
        B.pop(A.index(min(A)))
        A.pop(A.index(min(A)))
print(ans)

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

AB = [list(map(int,input().split())) for i in range(N)]
AB.sort()
ans = 0
for _ in range(N):
    if AB[_][1] >= M:
        ans += AB[_][0]*M
        break
    else:
        ans += AB[_][0]*AB[_][1]
        M -= AB[_][1]
print(ans)