Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(list(map(int, input().split())) for i in range(N))
A.sort()
sumcost = 0
k = 0
t = 0
while M-k>0:
    buy = min(M-k, A[t][1])
    sumcost += A[t][0]*buy
    k += buy
    t += 1


print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
k = 0
t = 0
while M-k>0:
    buy = min(M-k, A[t][0])
    sumcost += A[t][1]*buy
    k += buy
    t += 1


print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
k = 0
t = 0
while M-k>0:
    buy = min(M-k, A[t][0])
    sumcost += A[t][0]*buy
    k += buy
    t += 1


print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
k = 0
for i in range(M):
    if M-k>A[0][1]:
        sumcost += A[0][0]*A[0][1]
        k += A[0][1]
        A.pop(0)
    else:
        sumcost += A[0][0]*(M-k)
        break

print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
k = 0
for i in range(M):
    if M-k>A[0][1]:
        sumcost += A[0][0]*A[0][1]
        k -= A[0][1]
        A.pop(0)
    else:
        sumcost += A[0][0]*(M-k)
        break

print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A=sorted(A)
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
sumcost = 0
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
k = 0
A.sort()
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
sumcost = 0
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
k = 0
A.sort()
while M-k > A[0][1]:
    sumcost += A[0][0]*A[0][1]
    k += A[0][1]
    A.pop(0)
sumcost += A[0][0]*(M-k)

print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
sumcost = 0
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
k = 0
A.sort()
while k < M:
    if A[0][1] >= M-k:
        sumcost += A[0][0]*(M-k)
        break
    else:
        sumcost += A[0][0]*A[0][1]
        k += A[0][1]
        A.pop(0)



print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
sumcost = 0
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
k = 0
A.sort()
while k < M:
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1]<1:
        A.pop(0)
    k += 1



print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
B = []
sumcost = 0
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
k = 0
while k < M:
    min_index = A.index(min(A))
    B[min_index] -= 1
    sumcost += A[min_index]
    if B[min_index]<1:
        del A[min_index]
        del B[min_index]
    k += 1



print(sumcost)

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)