Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys

def input():
    return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
price = [a[i][0] for i in range(N)]
stock = [a[i][1] for i in range(N)]
min_num = 0
min_place = 0
bought = 0
total_price = 0

for i in range(N):
    min_num = min(price)
    min_place = price.index(min_num)
    if bought + stock[min_place] <= M:
        total_price += stock[min_place] * min_num
        bought += stock[min_place]
    else:
        total_price += (M - bought) * min_num
        break
    stock.pop(min_place)
    price.pop(min_place)
print(total_price)

Fixed submission:
# coding: utf-8
# Your code here!

import sys

def input():
    return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort()
price = [a[i][0] for i in range(N)]
stock = [a[i][1] for i in range(N)]
bought = 0
total_price = 0

for i in range(N):
    if bought + stock[i] <= M:
        total_price += price[i] * stock[i]
        bought += stock[i]
    else:
        total_price += price[i] * (M - bought)
        break
print(total_price)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys

def input():
    return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
price = [a[i][0] for i in range(N)]
min_num = 0
min_place = 0
bought = 0
total_price = 0

for i in range(N):
    min_num = min(price)
    min_place = price.index(min_num)
    if bought + a[min_place][1] <= M:
        total_price += a[min_place][0] * a[min_place][1]
        bought += a[min_place][1]
    else:
        total_price += (M - bought) * a[min_place][0]
        break
    a.pop(min_place)
    price.pop(min_place)
print(total_price)

Fixed submission:
# coding: utf-8
# Your code here!

import sys

def input():
    return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort()
price = [a[i][0] for i in range(N)]
stock = [a[i][1] for i in range(N)]
bought = 0
total_price = 0

for i in range(N):
    if bought + stock[i] <= M:
        total_price += price[i] * stock[i]
        bought += stock[i]
    else:
        total_price += price[i] * (M - bought)
        break
print(total_price)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys

def input():
    return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
price = [a[i][0] for i in range(N)]
min_num = 0
min_place = 0
bought = 0
total_price = 0

for i in range(N):
    min_num = min(price)
    min_place = price.index(min_num)
    if bought + a[min_place][1] <= M:
        total_price += a[min_place][0] * a[min_place][1]
        bought += a[min_place][1]
    else:
        total_price += (M - bought) * a[min_place][0]
        break
    a.pop(min_place)
    price.pop(min_place)
print(total_price)

Fixed submission:
# coding: utf-8
# Your code here!

import sys

def input():
    return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
a.sort()
price = [a[i][0] for i in range(N)]
stock = [a[i][1] for i in range(N)]
bought = 0
total_price = 0

for i in range(N):
    if bought + stock[i] <= M:
        total_price += price[i] * stock[i]
        bought += stock[i]
    else:
        total_price += price[i] * (M - bought)
        break
print(total_price)