Problem:
 Score : 300 points    Problem Statement Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i -th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.      Constraints  All values in input are integers.  1 \leq N, M \leq 10^5  1 \leq A_i \leq 10^9  1 \leq B_i \leq 10^5  B_1 + ... + B_N \geq M         Input Input is given from Standard Input in the following format:  N  M  A_1  B_1  A_2  B_2  \vdots  A_N  B_N       Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks.        Sample Input 1 2 5
4 9
2 4      Sample Output 1 12  With 12 yen, we can buy one drink at the first store and four drinks at the second store, for the total of five drinks. However, we cannot buy 5 drinks with 11 yen or less.       Sample Input 2 4 30
6 18
2 5
3 10
7 9      Sample Output 2 130       Sample Input 3 1 100000
1000000000 100000      Sample Output 3 100000000000000  The output may not fit into a 32 -bit integer type.

Solution (Python):
n, m = map(int, input().split())
ne = []
for i in range(n):
    ne.append(list(map(int, input().split())))
ne.sort(key=lambda x: x[0])
ans = 0
for i in range(n):
    if ne[i][1] >= m:
        ans += m * ne[i][0]
        break
    else:
        ans += ne[i][0] * ne[i][1]
        m -= ne[i][1]
print(ans)

Solution (Python):
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(N)]

AB = sorted(AB)

result = 0
c = 0
for a, b in AB:
    d = min(M - c, b)
    c += d
    result += d * a
    if c == M:
        break

print(result)

Solution (Python):
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

AB.sort()

res = 0
for a, b in AB:
    if M > b:
        M -= b
        res += a*b
    else:
        res += a*M
        break

print(res)

Solution (Python):
N, M = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(N)]

ABs.sort()

ans = 0
for A, B in ABs:
    ans += A * min(M, B)
    M -= min(M, B)
print(ans)

Solution (Python):
N,M=map(int,input().split())
X=[tuple(map(int,input().split())) for i in range(N)]
X.sort()
ans=0
tmp=0
for i in range(N):
    if tmp+X[i][1]>M:
        ans+=(M-tmp)*X[i][0]
        break
    ans+=X[i][0]*X[i][1]
    tmp+=X[i][1]
print(ans)

Solution (Python):
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, M = reads()
shop = []
for _ in range(N):
  A, B = reads()
  shop.append((A, B))
shop.sort(); shop.reverse()

count = 0
ans = 0
while count < M:
  A, B = shop.pop()
  m = min(M - count, B)
  count += m
  ans += m * A
print(ans)

Solution (Python):
N, M = list(map(int, input().split()))
ABL = []
for i in range(N):
	ABL.append(list(map(int, input().split())))

ABL = sorted(ABL)

c = 0
for i in range(N):
	if M > ABL[i][1]:
		M -= ABL[i][1]
		c += ABL[i][0] * ABL[i][1]
	else:
		c += M * ABL[i][0]
		break

print(c)

Solution (Python):

import heapq
n, m = map(int, input().split())
que = []
for _ in range(n):
    a, b = map(int, input().split())
    heapq.heappush(que, (a, b))
answer = 0
while m > 0:
    a, b = heapq.heappop(que)
    answer += a * min(m, b)
    m -= b
print(answer)

Solution (Python):
N, M = map(int, input().split())
Drink = [[int(i) for i in input().split()] for _ in range(N)]
Drink.sort()

Need = M
Payment = 0
for i in range(N):
    if Need > Drink[i][1]:
        Payment += Drink[i][0] * Drink[i][1]
        Need -= Drink[i][1]
    else:
        Payment += Drink[i][0] * Need
        break
print(Payment)

Solution (Python):
n, m = map(int, input().split())
ab_list = sorted([list(map(int, input().split())) for _ in range(n)])
money = 0
for a, b in ab_list:
    if m >= b:
        m -= b
        money += a * b
    else:
        money += a * m
        break
print(money)

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007




"""
n,m,c = LI()
b = LI()
a = LIR(n)
ans = 0
for i in range(n):
    d = c
    for k in range(m):
        d += b[k]*a[i][k]
    if d > 0:
        ans += 1
print(ans)
"""



n,m = LI()
v = LIR(n)
v.sort(key = lambda x:x[0])
ans = 0
k = 0
for a,b in v:
    if k+b >= m:
        ans += (m-k)*a
        print(ans)
        quit()
    ans += b*a
    k += b

Solution (Python):
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]
src.sort()
ans = 0
m = 0
for a,b in src:
    if m+b < M:
        m += b
        ans += a*b
    else:
        ans += (M-m)*a
        break
print(ans)

Solution (Python):
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
ans = 0
for a, b in ab:
    if m == 0:
        break
    if m <= b:
        ans += a*m
        m = 0
    else:
        ans += a*b
        m -= b
print(ans)

Solution (Python):
n,m = map(int,input().split())
drink = []
for i in range(n):
    l = list(map(int,input().split()))
    drink.append(l)
drink.sort()

res = 0
piv = 0
while m > 0:
    buy = min(m, drink[piv][1])
    res += buy * drink[piv][0]
    m -= buy
    piv += 1
print(res)

Solution (Python):
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]

AB.sort()
Ans = 0
for i in AB:
  if i[1] >= M:
    Ans += i[0] * M
    break
  else:
    Ans += i[0] * i[1]
    M -= i[1]

print(Ans)

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
ab = defaultdict(int)
for _ in range(n):
    a, b = map(int, input().split())
    ab[a] += b

ans = 0
remain = m
for k in sorted(ab.keys()):
    if remain <= ab[k]:
        ans += k * remain
        break
    ans += k * ab[k]
    remain -= ab[k]
print(ans)

Solution (Python):
N,M = map(int, raw_input().split())
AB = [map(int, raw_input().split()) for _ in range(N)]
AB.sort()
ans = 0
for ab in AB:
  t = min(M, ab[1])
  ans += ab[0]*t
  M -= t
print ans

Solution (Python):
n, m = map(int, input().split())
store = [tuple(map(int, input().split())) for _ in range(n)]
store.sort()
count = 0
cost = 0
for a, b in store:
    if m - count > b:
        count += b
        cost += a*b
    else:
        cost += (m - count) * a
        print(cost)
        exit()

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]
AB=sorted(AB,key=lambda x:x[0])
cnt=0
ans=0
for a,b in AB:
    tmp=cnt
    cnt=min(m,cnt+b)
    ans+=a*(cnt-tmp)
    if cnt==m:
        break
print(ans)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, m = na()
ab = []
for i in range(n):
    ab.append(na())
ab.sort(key=lambda x: x[0])

rem = m
ans = 0
for v in ab:
    buy = min(rem, v[1])
    ans += buy * v[0]
    rem -= buy
print(ans)