Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_{i} essays. He can raise the exam grade multiple times.

What is the minimum number of essays that Vanya needs to write to get scholarship?


-----Input-----

The first line contains three integers n, r, avg (1 ≤ n ≤ 10^5, 1 ≤ r ≤ 10^9, 1 ≤ avg ≤ min(r, 10^6)) — the number of exams, the maximum grade and the required grade point average, respectively.

Each of the following n lines contains space-separated integers a_{i} and b_{i} (1 ≤ a_{i} ≤ r, 1 ≤ b_{i} ≤ 10^6).


-----Output-----

In the first line print the minimum number of essays.


-----Examples-----
Input
5 5 4
5 2
4 7
3 1
3 2
2 5

Output
4

Input
2 5 4
5 2
5 2

Output
0



-----Note-----

In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point.

In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.

Difficulty: MEDIUM
Tags: Sorting

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
import operator
from sys import stdin, stdout
(n, m, reqAvg) = map(int, stdin.readline().split())
report = []
(curSum, curAvg) = (0, 0)
for i in range(n):
	(avg, grade) = map(int, stdin.readline().split())
	curSum += avg
	report.append([avg, grade])
report.sort(key=operator.itemgetter(1))
curAvg = curSum / n
if curAvg >= reqAvg:
	print(0)
else:
	ans = 0
	for i in range(len(report)):
		(val, grade) = report[i]
		if val < m:
			r = min(reqAvg * n - curSum, m - val)
			curSum += r
			ans += r * grade
			if curSum / n >= reqAvg:
				break
	print(ans)


def second(elem):
	return elem[1]
(n, r, avg) = (int(i) for i in input().split())
l = []
s = 0
for i in range(n):
	(a, b) = (int(i) for i in input().split())
	s += a
	if a != r:
		l.append((a, b))
l.sort(key=second)
diff = n * avg - s
c = 0
i = 0
while diff > 0:
	k = min(diff, r - l[i][0])
	c += k * l[i][1]
	diff -= k
	if k == r - l[i][0]:
		i += 1
print(c)


import sys, os, io

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

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
sys.setrecursionlimit(111111)
INF = 99999999999999999999999999999999

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, r, avg) = ria()
		z = []
		sumreq = avg * n
		sumihave = 0
		for i in range(n):
			(a, b) = ria()
			z.append([b, a])
			sumihave += a
		z = sorted(z)
		cost = 0
		for (b, a) in z:
			if sumihave >= sumreq:
				break
			elif sumihave + (r - a) <= sumreq:
				cost += (r - a) * b
				sumihave += r - a
			else:
				cost += (sumreq - sumihave) * b
				sumihave = sumreq
		print(cost)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


__author__ = 'Ekaterina'
(n, r, avg) = (int(m) for m in input().split())
exams = []
for i in range(n):
	input_i = [int(m) for m in input().split()]
	exams.append([input_i[1], input_i[0]])
exams.sort()
current_sum = exams[0][1]
works_to_do = 0
for x in range(1, n):
	current_sum += exams[x][1]
needed_points = avg * n - current_sum
if needed_points <= 0:
	print(0)
else:
	j = 0
	while needed_points > 0:
		points_subject = r - exams[j][1]
		if needed_points == points_subject:
			works_to_do = works_to_do + exams[j][0] * points_subject
			break
		elif needed_points < points_subject:
			works_to_do = works_to_do + exams[j][0] * needed_points
			break
		elif needed_points > points_subject:
			needed_points = needed_points - points_subject
			works_to_do = works_to_do + exams[j][0] * points_subject
		j += 1
	print(works_to_do)


(n, r, avg) = list(map(int, input().split()))
a = []
cur = 0
for i in range(n):
	(t1, t2) = list(map(int, input().split()))
	cur += t1
	a.append((t2, t1))
a = sorted(a)
ans = 0
avg = avg * n
for i in range(n):
	if cur >= avg:
		break
	need = avg - cur
	temp = min(need, r - a[i][1])
	cur += temp
	ans += temp * a[i][0]
print(ans)


[n, r, avg] = [int(x) for x in input().split()]
data = [[int(x) for x in input().split()] for i in range(n)]
data.sort(key=lambda x: x[1])
leftgrades = n * avg - sum([x[0] for x in data])
essays = 0
if leftgrades > 0:
	for x in data:
		if leftgrades > r - x[0]:
			essays += (r - x[0]) * x[1]
			leftgrades -= r - x[0]
		else:
			essays += leftgrades * x[1]
			break
print(essays)


(n, r, avg) = map(int, input().split())
t = 0
s = 0
l_s = list()
for _ in range(n):
	(a, b) = map(int, input().split())
	s += a
	l_s.append([a, b])
l_s.sort(key=lambda x: x[1])
i = 0
while s / n < avg:
	t += min(r - l_s[i][0], n * avg - s) * l_s[i][1]
	s += min(r - l_s[i][0], n * avg - s)
	i += 1
print(t)


(n, r, avg) = map(int, input().split())
avg *= n
l = []
s = 0
for i in range(n):
	(a, b) = map(int, input().split())
	s += a
	l.append((b, a))
l = sorted(l)
req = 0
i = 0
while i < n and s < avg:
	take = min(r - l[i][1], avg - s)
	s += take
	req += take * l[i][0]
	i += 1
print(req)


(n, r, req_avg) = map(int, input().split())
avgs = []
for _ in range(n):
	(a, b) = map(int, input().split())
	avgs.append((a, b))
required = n * req_avg - sum((x[0] for x in avgs))
if required <= 0:
	print(0)
	exit()
avgs.sort(key=lambda x: x[1])
total = 0
for (curr, cost) in avgs:
	if required <= 0:
		break
	if curr >= r:
		continue
	increment_by = min(r - curr, required)
	required -= increment_by
	total += cost * increment_by
print(total)


(N, R, avg) = map(int, input().split())
q = []
ttla = 0
for i in range(N):
	(a, b) = map(int, input().split())
	ttla += a
	q.append((b, R - a))
rest = N * avg - ttla
q.sort()
ans = 0
for (cost, times) in q:
	if rest <= 0:
		break
	if rest < times:
		ans += cost * rest
		rest = 0
	else:
		ans += cost * times
		rest -= times
print(ans)


import sys
import math
(n, r, avg) = [int(x) for x in sys.stdin.readline().split()]
res = 0
k = []
vsum = 0
for i in range(n):
	(a, b) = [int(x) for x in sys.stdin.readline().split()]
	if a >= r:
		vsum += r
	else:
		vsum += a
		k.append((r - a, b))
k.sort(key=lambda x: x[1])
val = n * avg - vsum
if val <= 0:
	print(0)
	exit()
z = 0
i = 0
while z < val:
	z += k[i][0]
	res += k[i][1] * k[i][0]
	i += 1
i -= 1
if z > val:
	res -= (z - val) * k[i][1]
	print(res)
else:
	print(res)


(n, r, avg) = map(int, input().split())
x = []
s = 0
for i in range(n):
	(a, b) = map(int, input().split())
	s += a
	x.append((a, b))
rem = avg * n - s
x.sort(key=lambda i: i[1])
i = 0
count = 0
while rem > 0:
	if x[i][0] < r:
		v = min(rem, r - x[i][0])
		count += v * x[i][1]
		rem -= v
	i += 1
print(count)


(n, r, avg) = map(int, input().split())
(exams, need, ans) = ([], avg * n, 0)
for x in range(n):
	(a, b) = map(int, input().split())
	exams.append([b, a])
	need -= a
exams.sort()
i = 0
while need > 0 and i < n:
	ans += exams[i][0] * min(r - exams[i][1], need)
	need -= min(r - exams[i][1], need)
	i += 1
print(ans)


from operator import itemgetter
(n, r, avg) = map(int, input().split())
a = []
for _ in range(n):
	(u, v) = map(int, input().split())
	a.append((u, v))
b = sorted(a, key=itemgetter(1, 0))
diff = avg * n - sum([i[0] for i in b])
res = 0
if diff <= 0:
	print(res)
	exit()
else:
	for i in b:
		if diff == 0:
			print(res)
			exit()
		else:
			d = min(diff, r - i[0])
			diff -= d
			res += d * i[1]
	if diff == 0:
		print(res)
		exit()


(n, mx, avg) = map(int, input().split())
total = 0
l = []
for i in range(n):
	(x, y) = map(int, input().split())
	total += x
	l.append((y, mx - x))
l.sort()
count = 0
i = 0
diff = avg * n - total
while diff > 0:
	k = min(l[i][1], diff)
	count += l[i][0] * k
	diff -= k
	i += 1
print(count)


(n, r, avg) = list(map(int, input().split()))
notas = [list(map(int, input().split()))[::-1] for x in range(n)]
notas.sort()
i = 0
soma = [sum(i) for i in zip(*notas)][1]
essays = 0
while soma < avg * n and i < n:
	dif = r - notas[i][1]
	precisa = avg * n - soma
	if dif > precisa:
		dif = precisa
	if dif > 0:
		soma += dif
		notas[i][1] += dif
		essays += dif * notas[i][0]
	else:
		i += 1
print(essays)


sm = 0
(n, r, avg) = map(int, input().split())
marks = []
for i in range(n):
	(a, b) = map(int, input().split())
	marks.append([a, b])
	sm += a
req = avg * n - sm
cost = 0
if req <= 0:
	print(0)
	exit()
marks.sort(key=lambda x: x[1])
for i in range(n):
	if marks[i][0] >= r:
		continue
	if req == 0:
		continue
	rem = r - marks[i][0]
	if req >= rem:
		cost += marks[i][1] * rem
		req -= rem
	elif req < rem:
		cost += marks[i][1] * req
		req = 0
if req:
	print(-1)
else:
	print(cost)


(n, r, a) = map(int, input().split())
ab = []
for i in range(n):
	ab.append(list(map(int, input().split())))

def f(v):
	return v[1]
ab.sort(key=f)
a *= n
for i in ab:
	a -= i[0]
if a <= 0:
	print(0)
else:
	i = 0
	ct = 0
	while a != 0:
		if r - ab[i][0] <= a:
			ct += (r - ab[i][0]) * ab[i][1]
			a -= r - ab[i][0]
		else:
			ct += a * ab[i][1]
			break
		i += 1
	print(ct)


from sys import stdin

def main():
	(n, r, avg) = list(map(int, stdin.readline().strip().split()))
	(aa, bb) = ([], [])
	for _ in range(n):
		(a, b) = list(map(int, stdin.readline().strip().split()))
		aa.append(a)
		bb.append(b)
	now = sum(aa)
	ineed = n * avg
	if now >= ineed:
		return 0
	pref = sorted(list(range(n)), key=bb.__getitem__)
	tot = 0
	for i in pref:
		(a, b) = (aa[i], bb[i])
		delta = min(ineed - now, r - a)
		tot += b * delta
		now += delta
		if now == ineed:
			return tot
print(main())


(n, r, avg) = map(int, input().strip().split())
total = 0
exams = []
for i in range(n):
	(x, y) = map(int, input().strip().split())
	exams.append((y, r - x))
	total += x
exams.sort()
deficit = avg * n - total
count = 0
i = 0
while deficit > 0:
	gap = min(exams[i][1], deficit)
	count += gap * exams[i][0]
	deficit -= gap
	i += 1
print(count)


import math

def getKey(item):
	return item[1]
(n, r, avg) = map(int, input().split())
score = 0
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	score += a
	if a < r:
		l.append([a, b])
essays = 0
needed = n * avg - score
if needed <= 0:
	print(essays)
else:
	l = sorted(l, key=getKey)
	for i in l:
		points = r - i[0]
		if needed >= points:
			essays += points * i[1]
			needed -= points
		else:
			essays += needed * i[1]
			needed = 0
			break
	print(essays)


(n, max_mark, avg) = list(map(int, input().split()))
(a, b) = ([], [])
for i in range(n):
	(ai, bi) = list(map(int, input().split()))
	a.append(ai)
	b.append(bi)
exams = dict(enumerate(zip(a, b)))
marks_needed = round((avg - sum(a) / len(a)) * n)
num_essays = 0
if marks_needed > 0:
	for exam in sorted(exams.values(), key=lambda x: x[1]):
		(cur_exam_mark, cur_essays_per_mark) = exam
		if marks_needed > max_mark - cur_exam_mark:
			num_essays += cur_essays_per_mark * (max_mark - cur_exam_mark)
			marks_needed -= max_mark - cur_exam_mark
		else:
			num_essays += cur_essays_per_mark * marks_needed
			marks_needed = 0
print(num_essays)


(n, r, avg) = map(int, input().split())
p = [[0, 0] for i in range(n)]
for i in range(n):
	(p[i][0], p[i][1]) = map(int, input().split())
s = sum((p[i][0] for i in range(0, n)))
if s >= n * avg:
	print(0)
else:
	t = n * avg - s
	y = 0
	x = 0
	p = sorted(p, key=lambda x: x[1])
	for i in range(0, n):
		p[i][0] = r - p[i][0]
	for i in range(0, n):
		if p[i][0] + y >= t:
			x += (t - y) * p[i][1]
			break
		else:
			x += p[i][0] * p[i][1]
			y += p[i][0]
	print(x)


(n, r, avg) = list(map(int, input().split(' ')))
L = []
for i in range(n):
	x = list(map(int, input().split(' ')))
	L.append(x)
L.sort(key=lambda x: x[1])
s = 0
for i in L:
	s += i[0]
need = avg * n - s
if need <= 0:
	ans = 0
else:
	ans = 0
	start = 0
	while need > 0:
		a = L[start][0]
		b = L[start][1]
		k = r - a
		if k > need:
			ans += need * b
			need = 0
		else:
			ans += k * b
			need -= k
		start += 1
print(ans)


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, r, avg) = map(int, input().split())
exams = []
rn = 0
essays = []
for i in range(n):
	exams.append(list(map(int, input().split())))
	rn += exams[i][0]
	essays.append([exams[i][1], r - exams[i][0]])
essays.sort()
needed = n * avg - rn
c = 0
cnt = 0
while needed > 0:
	if needed > essays[c][1]:
		cnt += essays[c][1] * essays[c][0]
		needed -= essays[c][1]
	else:
		cnt += needed * essays[c][0]
		break
	c += 1
	if c == n:
		break
print(cnt)


(n, r, avg) = map(int, input().split())
total = 0
exams = []
for i in range(n):
	(score, cost) = map(int, input().split())
	total += score
	exams.append((cost, score))
need = n * avg - total
result = 0
exams.sort()
for (cost, score) in exams:
	if need <= 0:
		break
	x = min(need, r - score)
	result += cost * x
	need -= x
print(result)


(n, r, avg) = list(map(int, input().split()))
ls = []
for i in range(n):
	ls.append(list(map(int, input().split())))
ls.sort(key=lambda x: x[1])
req_points = avg * n - sum([i[0] for i in ls])
if req_points <= 0:
	print('0')
else:
	essays = 0
	j = 0
	while req_points > 0:
		i = ls[j]
		points_here = r - i[0]
		if req_points >= points_here:
			req_points -= points_here
			essays += points_here * i[1]
		else:
			essays += req_points * i[1]
			req_points -= points_here
		j += 1
	print(essays)


import sys

def In():
	return map(int, sys.stdin.readline().split())

def exams():
	(n, r, avg) = In()
	req = n * avg
	tol = 0
	l = []
	for _ in range(n):
		(new, m) = In()
		l.append([new, m])
		tol += new
	if tol > req:
		return 0
	l.sort(key=lambda x: x[1])
	ans = 0
	for i in range(n):
		now = l[i]
		if r - now[0] > req - tol:
			ans += (req - tol) * now[1]
			break
		ans += (r - now[0]) * now[1]
		tol += r - now[0]
	return ans
print(exams())


(n, r, avg) = [int(i) for i in input().split()]
a = [0] * n
b = [[0] * 2 for i in range(n)]
for j in range(n):
	(a[j], b[j][0]) = [int(i) for i in input().split()]
	b[j][1] = j
b.sort()
mid = -1
sum1 = sum(a)
res = 0
hod = 0
sumOLD = 0
if sum1 / n < avg:
	while mid < avg:
		sumOLD = sum1
		sum1 += min(r - a[b[hod][1]], avg * n - sumOLD)
		res += b[hod][0] * min(r - a[b[hod][1]], avg * n - sumOLD)
		hod += 1
		mid = sum1 / n
	print(res)
else:
	print(0)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
(n, r, avg) = map(int, input().split())
ls = []
for _ in range(n):
	(a, b) = map(int, input().split())
	ls.append((b, a))
s = 0
for i in range(n):
	s += ls[i][1]
if s >= avg * n:
	print(0)
else:
	needed = avg * n - s
	ls.sort()
	ans = 0
	i = 0
	while needed > 0:
		ans += ls[i][0] * min(needed, r - ls[i][1])
		needed -= min(needed, r - ls[i][1])
		i += 1
	print(ans)


(n, r, avg) = map(int, input().split())
a = []
for i in range(n):
	(p, q) = map(int, input().split())
	a.append((q, p))

def sortFirst(val):
	return val[0]
a.sort(key=sortFirst)
jog = 0
for i in range(n):
	jog += a[i][1]
k = n * avg - jog
if k <= 0:
	print(0)
else:
	ans = 0
	x = 0
	for i in range(n):
		x += r - a[i][1]
		if x <= k:
			ans += (r - a[i][1]) * a[i][0]
		else:
			if i != 0:
				x -= r - a[i][1]
				ans += (k - x) * a[i][0]
			else:
				ans += k * a[i][0]
			break
	print(ans)


from sys import stdin

def bsearch(li, v):
	(l, r) = (0, len(li))
	while l < r:
		m = l + (r - l) // 2
		if li[m] < v:
			l = m + 1
		else:
			r = m
	return l

def solve(tc):
	(n, r, avg) = map(int, stdin.readline().split())
	li = []
	for _ in range(n):
		(a, b) = map(int, stdin.readline().split())
		li.append([a, b])
	li.sort(key=lambda x: [x[1], x[0]])
	tot = 0
	needed = []
	re = []
	for i in range(n):
		tot += li[i][0]
		rem = r - li[i][0]
		needed.append(rem)
		re.append(rem * li[i][1])
		if i > 0:
			needed[-1] += needed[-2]
			re[-1] += re[-2]
	required = n * avg - tot
	idx = bsearch(needed, required)
	res = 0
	if idx > 0:
		res += re[idx - 1]
		required -= needed[idx - 1]
	if required > 0:
		res += required * li[idx][1]
	print(res)
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip()) if LOCAL_TEST else 1
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


import math
(n, r, avg) = [int(x) for x in input().split()]
avg *= n
a = []
avgCur = 0
for i in range(n):
	a.append([int(x) for x in input().split()])
	avgCur += a[i][0]
a.sort(key=lambda x: x[1])
res = 0
i = 0
while avgCur < avg:
	t = min(r - a[i][0], avg - avgCur)
	res += a[i][1] * t
	avgCur += t
	i += 1
print(res)


from sys import stdin
from operator import itemgetter
__author__ = 'artyom'

def read_int_ary():
	return map(int, stdin.readline().strip().split())
(n, r, avg) = read_int_ary()
exs = []
grade = 0
for i in range(n):
	ary = list(read_int_ary())
	exs.append(ary)
	grade += ary[0]
exs = sorted(exs, key=itemgetter(1))
(essays, i, diff) = (0, 0, n * avg - grade)
while diff > 0:
	req = min(r - exs[i][0], diff)
	essays += exs[i][1] * req
	diff -= req
	i += 1
print(essays)


(n, r, a) = map(int, input().split())
l = []
s = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	s += x
	l.append([y, x])
l.sort()
ans = 0
total = n * a
i = 0
while s < total:
	temp = min(total - s, r - l[i][1])
	ans += l[i][0] * temp
	s += temp
	i += 1
print(ans)


(n, r, avg) = [int(i) for i in input().split()]
ls = []
aver = 0
cost = 0
for i in range(n):
	(x, y) = [int(i) for i in input().split()]
	ls.append((x, y))
	aver += x
a = aver // n
if a >= avg:
	print(0)
else:
	br = 1
	ls.sort(key=lambda item: item[1])
	for tup in ls:
		exam = tup[0]
		point = min(r - exam, avg * n - aver)
		exam += point
		cost += point * tup[1]
		aver += point
		if aver // n >= avg:
			br = 0
			break
	print(cost)


(n, r, avg) = map(int, input().split(' '))
exams = [list(map(int, input().split(' '))) for _ in range(n)]
exams.sort(key=lambda x: x[1])
total = n * avg
cur = sum((e[0] for e in exams))
essays = 0
for e in exams:
	if cur >= total:
		break
	its = min(r - e[0], total - cur)
	cur += its
	e[0] += its
	essays += its * e[1]
print(essays)


(n, r, avg) = map(int, input().split())
current_avg = 0
grades = []
for _ in range(n):
	(a, b) = map(int, input().split())
	grades.append([b, a])
	current_avg += a
avg *= n
if avg > current_avg:
	grades.sort()
ans = 0
i = 0
while avg > current_avg:
	if grades[i][1] >= r:
		i += 1
		continue
	ans += grades[i][0] * min(avg - current_avg, r - grades[i][1])
	current_avg += min(avg - current_avg, r - grades[i][1])
	grades[i][1] = r
	i += 1
print(ans)


(n, r, avg) = (int(i) for i in input().split())
exams = []
ref = 0
for i in range(n):
	(a, b) = (int(i) for i in input().split())
	exams.append([r - a, b])
import time
start = time.time()
add = (avg - r) * n + sum((i[0] for i in exams))
if add > 0:
	exams = sorted(exams, key=lambda x: x[::-1])
	ref = 0
	for i in exams:
		if add > i[0]:
			ref += i[0] * i[1]
		else:
			ref += add * i[1]
		add -= i[0]
		if add <= 0:
			break
print(ref)
finish = time.time()


(n, r, avg) = map(int, input().split())
lst = [[0, 0]] * n
score = 0
for x in range(n):
	lst[x] = list(map(int, input().split()))
	score += lst[x][0]
lst.sort(key=lambda x: x[1])
scoreRequird = n * avg - score
essays = 0
i = 0
while scoreRequird > 0 and i < len(lst):
	if lst[i][0] < r:
		increment = min(r - lst[i][0], scoreRequird)
		scoreRequird -= increment
		lst[i][0] += increment
		essays += lst[i][1] * increment
	else:
		i += 1
print(essays)


(n, r, avg) = map(int, input().split())
s = 0
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append([b, a])
	s += a
l.sort()
z = s
yo = n * avg - z
if yo <= 0:
	print(0)
	exit()
ans = 0
for i in range(n):
	(b, a) = l[i]
	if r - a > yo:
		ans += yo * b
		yo = 0
		break
	else:
		ans += (r - a) * b
		yo -= r - a
print(ans)


(n, r, avg) = map(int, input().split())
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
sum = 0
for i in arr:
	sum += i[0]
req = n * avg - sum
if req <= 0:
	print(0)
else:
	ans = []
	for i in range(n):
		if arr[i][0] >= r:
			pass
		else:
			ans.append(arr[i])
	ans.sort(key=lambda ans: ans[1])
	fin = 0
	i = 0
	while req:
		x = r - ans[i][0]
		if x >= req:
			fin += req * ans[i][1]
			req = 0
			break
		else:
			fin += x * ans[i][1]
			req -= x
		if req == 0:
			break
		i += 1
	print(fin)


(n, t, av) = map(int, input().split())
p = []
sum = 0
for i in range(n):
	(a, b) = map(int, input().split())
	p.append((b, a))
	sum += a
p.sort()
col = n * av
col = col - sum
sum = 0
for i in range(len(p)):
	if col == 0:
		print(max(sum, 0))
		break
	if col > t - p[i][1]:
		col -= t - p[i][1]
		sum += (t - p[i][1]) * p[i][0]
	else:
		sum += col * p[i][0]
		print(max(sum, 0))
		break


(n, r, avg) = map(int, input().split())
avg *= n
a = [0] * 1000001
b = [0] * 1000001
av = 0
for i in range(n):
	(c, d) = map(int, input().split())
	av += c
	a[d] += c
	b[d] += 1
es = 0
for i in range(1000001):
	if av < avg and b[i] > 0:
		es += min(b[i] * r - a[i], avg - av) * i
		av += min(b[i] * r - a[i], avg - av)
	elif av >= avg:
		print(es)
		exit(0)
print(es)


(n, r, avg) = map(int, input().split())
s = 0
a = []
for i in range(n):
	z = input().split()
	a.append([int(z[1]), int(z[0])])
	s += a[-1][1]
a.sort()
b = avg * n - s
ans = 0
for x in a:
	if b <= 0:
		break
	tmp = min(r - x[1], b)
	ans += tmp * x[0]
	b -= tmp
print(ans)


(n, r, avg) = map(int, input().split())
cost_mark = []
for _ in range(n):
	(mark, cost) = map(int, input().split())
	cost_mark += [[cost, mark]]
cost_mark = sorted(cost_mark)
current_sum = sum([x[1] for x in cost_mark])
needed_sum = max(n * avg - current_sum, 0)
needed_essays = 0
for (cost, mark) in cost_mark:
	if needed_sum - (r - mark) > 0:
		needed_sum -= r - mark
		needed_essays += (r - mark) * cost
	else:
		needed_essays += needed_sum * cost
		needed_sum = 0
		break
print(needed_essays)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	(n, r, avg) = map(int, input().split(' '))
	ans = 0
	temp = []
	for x in range(n):
		(a, b) = map(int, input().split(' '))
		ans += a
		temp.append([b, a])
	if ans / n >= avg:
		print(0)
	else:
		diff = n * avg - ans
		temp.sort()
		boss = 0
		low = 0
		ans = 0
		while diff > 0:
			if diff >= r - temp[low][1]:
				ans += temp[low][0] * (r - temp[low][1])
				diff -= r - temp[low][1]
				low += 1
			else:
				ans += diff * temp[low][0]
				break
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, r, avg) = map(int, input().split())
a = []
total = 0
for _ in range(n):
	a.append(list(map(int, input().split())))
	total += a[-1][0]
a = sorted(a, key=lambda x: x[1])
i = 0
ans = 0
while total < avg * n:
	tmp = min(avg * n - total, r - a[i][0])
	ans += tmp * a[i][1]
	total += tmp
	i += 1
print(ans)


import sys
(n, r, avg) = list(map(int, input().split()))
L = []
tot = 0
for i in range(n):
	L.append(list(map(int, input().split())))
	(L[i][0], L[i][1]) = (L[i][1], L[i][0])
	tot += L[i][1]
	L[i][1] = r - L[i][1]
req = avg * n
L.sort()
ind = 0
ans = 0
while ind < n and req > tot:
	diff = req - tot
	if L[ind][1] >= diff:
		ans += diff * L[ind][0]
		tot += diff
		L[ind][1] -= diff
	else:
		ans += L[ind][1] * L[ind][0]
		tot += L[ind][1]
		L[ind][1] = 0
	ind += 1
print(ans)


(n, r, a) = [int(x) for x in input().split()]
exams = []
grades = 0
essays = 0
for i in range(n):
	(grade, essay) = [int(x) for x in input().split()]
	grades += grade
	exams.append([grade, essay])
if grades >= n * a:
	print(0)
else:
	exams.sort(key=lambda x: x[1])
	needs = n * a - grades
	while needs > 0:
		for i in exams:
			essays += min(needs, r - i[0]) * i[1]
			needs -= min(needs, r - i[0])
	print(essays)


(n, r, avg) = map(int, input().split())
l = []
sum = 0
for i in range(n):
	(a, b) = map(int, input().split())
	sum += a
	l.append([b, a])
x = avg * n - sum
if x <= 0:
	print('0')
else:
	e = 0
	l.sort()
	i = 0
	while x > 0:
		if l[i][1] < r:
			diff = r - l[i][1]
			if x == diff:
				e += l[i][0] * diff
				break
			elif x > diff:
				e += l[i][0] * diff
				x -= diff
			else:
				e += x * l[i][0]
				break
		i += 1
	print(e)


(n, r, avg) = map(int, input().split())
l = [[*map(int, input().split())] for i in range(n)]
l.sort(key=lambda x: x[1])
total = 0
for i in range(n):
	total += l[i][0]
i = 0
ans = 0
if total // n >= avg:
	print(0)
	exit()
while total // n < avg:
	x = r - l[i][0]
	if (x + total) // n < avg:
		total += x
		ans += x * l[i][1]
	else:
		left = n * avg - total
		ans += left * l[i][1]
		total += left
	i += 1
print(ans)


import sys
input = sys.stdin.readline

def multi_input():
	return map(int, input().split())

def array_print(arr):
	print(' '.join(map(str, arr)))
total = ans = 0
marks = []
(n, r, avg) = multi_input()
req_total = n * avg
for i in range(n):
	(a, b) = multi_input()
	total += a
	marks.append([a, b])
marks.sort(key=lambda item: item[1])
if req_total > total:
	for i in marks:
		if i[0] < r:
			temp = min(r - i[0], req_total - total)
			total += temp
			ans += temp * i[1]
		if req_total == total:
			break
	print(ans)
else:
	print(0)


from sys import stdin

def main():
	(n, r, avg) = map(int, stdin.readline().split())
	g = []
	cr = 0
	for _ in range(n):
		(ta, tb) = map(int, stdin.readline().split())
		cr += ta
		g.append((ta, tb))
	target = max(avg * n - cr, 0)
	ans = 0
	g.sort(key=lambda x: x[1])
	for i in range(n):
		if g[i][0] == r:
			continue
		if target == 0:
			break
		ans += min(r - g[i][0], target) * g[i][1]
		target -= min(r - g[i][0], target)
	print(ans)
main()


from sys import stdin, stdout

class Grade:
	(a, b) = (0, 0)

	def __lt__(self, other):
		return self.b < other.b
(n, r, avg) = map(int, stdin.readline().split())
(grade, add, cnt) = ([Grade() for i in range(n)], 0, 0)
for i in range(n):
	(grade[i].a, grade[i].b) = map(int, stdin.readline().split())
	add += grade[i].a
grade.sort()
add = n * avg - add if n * avg - add > 0 else 0
for i in range(n):
	if add - r + grade[i].a >= 0:
		add -= r - grade[i].a
		cnt += grade[i].b * (r - grade[i].a)
	else:
		cnt += grade[i].b * add
		break
stdout.write('%d' % cnt)


t = input().split()
n = int(t[0])
r = int(t[1])
avg = int(t[2])
a = []
for i in range(n):
	a.append(input().split())
	t = int(a[i][0])
	a[i][0] = int(a[i][1])
	a[i][1] = t
a = sorted(a)
ref = 0
new = 0
for i in range(n):
	new += a[i][1]
new /= n
i = 0
while new < avg and i < n:
	x = min(r - a[i][1], round((avg - new) * n))
	new += 1 / n * x
	ref += a[i][0] * x
	i += 1
print(round(ref))


(n, r, avg) = map(int, input().split())
arr = []
k = 0
for i in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])
diff = avg * n - sum((i[0] for i in arr))
if diff <= 0:
	print(k)
else:
	arr = sorted(arr, key=lambda x: x[1])
	for i in arr:
		if diff == 0:
			break
		else:
			d = min(diff, r - i[0])
			diff -= d
			k += d * i[1]
	if diff == 0:
		print(k)


import sys
lines = sys.stdin.readlines()
(n, r, avg) = list(map(int, lines[0].split()))
pair = []
for l in lines[1:]:
	pair.append(list(map(int, l.split())))
pair.sort(key=lambda x: x[1])
cur_sum = sum([i[0] for i in pair])
req_sum = avg * n
ans = 0
for v in pair:
	if cur_sum >= req_sum:
		break
	inc = min(r - v[0], req_sum - cur_sum)
	cur_sum += inc
	ans += inc * v[1]
print(ans)


def main():
	(n, r, avg) = map(int, input().split())
	exams = []
	total = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		exams.append((a, b))
		total += a
	if total / n >= avg:
		print(0)
		return
	exams = sorted(exams, key=lambda x: x[1])
	ans = 0
	for i in range(n):
		(a, b) = (exams[i][0], exams[i][1])
		x = n * avg - total
		ans += min(x, r - a) * b
		total += min(x, r - a)
		if total / n >= avg:
			break
	print(ans)
main()


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
(n, r, avg) = mp()
v = []
k = res = 0
for _ in range(n):
	(a, b) = mp()
	v += [[a, b]]
	k += a
v.sort(key=lambda x: x[1])
ans = k
d = avg * n - ans
i = 0
while d > 0:
	t = min(r - v[i][0], d)
	res += t * v[i][1]
	d -= t
	i += 1
print(res)


class P:

	def __init__(self, score, count_ref):
		self.score = score
		self.count_ref = count_ref
(n, r, avg) = map(int, input().split())
needed_score = n * avg
current_score = 0
a = []
for _ in range(n):
	(score, count_ref) = map(int, input().split())
	current_score += score
	a.append(P(score, count_ref))
a.sort(key=lambda c: c.count_ref)
ans = 0
for it in a:
	m = min(r - it.score, max(needed_score - current_score, 0))
	current_score += m
	ans += m * it.count_ref
print(ans)


def main():
	(n, r, avg) = map(int, input().split(' '))
	grade = []
	sumIp = 0
	for i in range(n):
		grade.append([int(item) for item in input().split(' ')])
		sumIp += grade[i][0]
	grade.sort(key=takeSecond)
	i = 0
	aimSum = avg * n
	essays = 0
	points = 0
	while sumIp < aimSum and i < n:
		if grade[i][0] < r:
			points = min(r - grade[i][0], aimSum - sumIp)
			essays += points * grade[i][1]
			sumIp += points
		i += 1
	print(essays)

def takeSecond(item):
	return item[1]
main()


import heapq
(n, r, avg) = [int(x) for x in input().split()]
a = []
average = avg * n
essays = 0
for i in range(n):
	(A, B) = [int(x) for x in input().split()]
	a.append((B, A))
	average -= a[i][1]
a.sort()
for x in a:
	if average <= 0:
		break
	k = min(r - x[1], average)
	essays += k * x[0]
	average -= k
print(essays)


first = input().split()
n = int(first[0])
r = int(first[1])
avg = int(first[2])
marks = {}
total = 0
essays = []
for i in range(n):
	inp = input().split()
	inp[0] = int(inp[0])
	inp[1] = int(inp[1])
	total += inp[0]
	essays.append(inp[1])
	if inp[1] in marks:
		marks[inp[1]].append(inp[0])
	else:
		marks[inp[1]] = [inp[0]]
if total / n >= avg:
	print(0)
else:
	out = 0
	essays = list(set(essays))
	essays.sort()
	deficit = avg * n - total
	ind = 0
	while deficit > 0:
		current = essays[ind]
		for i in range(len(marks[current])):
			if marks[current][i] < r:
				x = r - marks[current][i]
				if deficit >= x:
					out += current * x
					deficit -= x
				else:
					out += current * deficit
					deficit = 0
				if deficit == 0:
					break
		ind += 1
	print(out)


__author__ = 'Rakshak.R.Hegde'
(n, r, avg) = map(int, input().split())
ab = []
d = n * avg
for i in range(n):
	(a, b) = map(int, input().split())
	d -= a
	ab.append((b, a))
ab.sort()
cost = 0
for t in ab:
	if d <= 0:
		break
	if t[1] < r:
		m = min(d, r - t[1])
		cost += m * t[0]
		d -= m
print(cost)


(n, r, avg) = map(int, input().split())
exams = sorted([list(map(int, input().split())) for i in range(n)], key=lambda x: x[1])
goal = avg * n
current = sum([exam[0] for exam in exams])
essays = 0
if current < goal:
	for exam in exams:
		(a, b) = exam
		points = r - a
		if current + points <= goal:
			more_essays = points * b
			essays += more_essays
			current += points
		else:
			points = goal - current
			essays += points * b
			break
print(essays)


def main():
	(n, r, a) = map(int, input().split())
	a *= n
	tab = []
	for x in range(n):
		(ga, b) = map(int, input().split())
		tab.append((ga, b))
		a -= ga
	if a <= 0:
		print(0)
		return
	tab.sort(key=lambda x: x[1])
	inc = 0
	for x in range(n):
		if a - (r - tab[x][0]) <= 0:
			inc += a * tab[x][1]
			break
		else:
			inc += (r - tab[x][0]) * tab[x][1]
			a -= r - tab[x][0]
	print(inc)
main()


__author__ = 'PrimuS'
(n, r, a) = (int(x) for x in input().split())
marks = [[0, 0]] * n
s = 0
for i in range(n):
	ss = input()
	marks[i] = [int(x) for x in ss.split()]
	s += marks[i][0]
if s / n >= a:
	print(0)
else:
	x = a * n - s

	def ccmp(b):
		return b[1]
	marks.sort(key=ccmp)
	i = 0
	res = 0
	while x > 0:
		y = min(x, r - marks[i][0])
		x -= y
		res += marks[i][1] * y
		i += 1
	print(res)


(n, r, avg) = map(int, input().split())
x = n * avg
a = []
t = 0
for _ in range(n):
	(k, l) = map(int, input().split())
	t += k
	a.append([l, k])
a = sorted(a)
(an, i) = (0, 0)
while t < x:
	d = min(x - t, r - a[i][1])
	t += d
	an += d * a[i][0]
	i += 1
print(an)


(n, maxMark, avg) = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]
avg *= n
s = 0
for (mark, _) in a:
	s += mark
need = max(avg - s, 0)
a.sort(key=lambda x: x[1])
ret = 0
for (mark, essays) in a:
	if need == 0:
		break
	take = min(need, maxMark - mark)
	ret += take * essays
	need -= take
print(ret)


def main():
	(n, r, avg) = map(int, input().split(' '))
	x = []
	points = 0
	essays = 0
	for i in range(n):
		(a, b) = map(int, input().split(' '))
		if a < r:
			x.append([a, b])
		points += a
	x = sorted(x, key=lambda i: i[1])
	i = 0
	while points < int(avg * n):
		t = min(int(avg * n - points), r - x[i][0])
		essays += int(t * x[i][1])
		points += t
		i += 1
	return essays
print(main())


import sys
input = sys.stdin.readline

def inInt():
	return int(input())

def inStr():
	return input().strip('\n')

def inIList():
	return list(map(int, input().split()))

def inSList():
	return input().split()

def bsearch(nums, target):
	N = len(nums or [])
	l = 0
	r = N - 1
	while l <= r:
		mid = (l + r) // 2
		if nums[mid] < target:
			l = mid + 1
		elif nums[mid] > target:
			r = mid - 1
		else:
			return (None, mid, None)
	return (r if r >= 0 else None, None, l if l <= N - 1 else None)

def yesOrNo(val):
	print('YES' if val else 'NO')

def printSpacedArray(nums):
	print(*nums)
(n, r, avg) = inIList()
ab = []
s = 0
cost = 0
for i in range(n):
	(ia, ib) = inIList()
	s += ia
	ab.append([ib, ia])
ab = sorted(ab, key=lambda x: x[0])
i = 0
while s < avg * n:
	t = min(avg * n - s, r - ab[i][1])
	cost += t * ab[i][0]
	s += t
	i += 1
print(cost)


(n, r, avg) = list(map(int, input().rstrip().split()))
sub = []
mark = 0
for i in range(n):
	(x, y) = list(map(int, input().rstrip().split()))
	sub.append([x, y])
	mark += x
marks = avg * n
sub.sort(key=lambda x: x[1])
i = 0
ans = 0
while mark < marks:
	x = min(marks - mark, r - sub[i][0])
	mark += x
	ans += x * sub[i][1]
	i += 1
print(ans)


(n, r, avg) = map(int, input().split())
arr = []
summ = 0
for i in range(n):
	(a, b) = map(int, input().split())
	summ += a
	arr.append([a, b])
need = n * avg - summ
if need == 0:
	print(0)
else:
	ans1 = 0
	arr = sorted(arr, key=lambda x: x[1])
	for i in range(n):
		if arr[i][0] < r and need > 0:
			add = r - arr[i][0]
			if need >= add:
				need -= add
			else:
				m = add - need
				add -= m
				need -= add
			ans1 += add * arr[i][1]
		if need == 0:
			break
	print(ans1)


def solve(n, r, avg, grades, tot):
	if tot >= avg * n:
		return 0
	p = avg * n - tot
	ans = 0
	i = 0
	while p > 0:
		if p < r - grades[i][1]:
			ans += grades[i][0] * p
			p = 0
		else:
			p -= r - grades[i][1]
			ans += grades[i][0] * (r - grades[i][1])
		i += 1
	return ans
(n, r, avg) = map(int, input().split())
grades = []
tot = 0
for i in range(n):
	(a, b) = map(int, input().split())
	grades.append([b, a])
	tot += a
grades.sort()
print(solve(n, r, avg, grades, tot))


(n, r, avg) = map(int, input().split())
d = []
s = 0
ans = 0
for i in range(n):
	(a, b) = map(int, input().split())
	d.append([b, a])
	s += a
d.sort()
f = n * avg - s
g = f
for i in range(len(d)):
	if f > 0:
		c = r - d[i][1]
		ans += min(c * d[i][0], g * d[i][0])
		f -= 1
		g -= min(c, g)
	else:
		break
print(ans)


(n, r, a) = map(int, input().split(' '))
s = 0
arr = []
for _ in range(n):
	(u, v) = map(int, input().split(' '))
	if u < r:
		arr.append([u, v])
	s = s + u
x = n * a - s
if x <= 0:
	ans = 0
else:
	ans = 0
	arr.sort(key=lambda x: x[1])
	for item in arr:
		if r - item[0] < x:
			ans = ans + (r - item[0]) * item[1]
			x = x - (r - item[0])
		else:
			ans = ans + x * item[1]
			x = 0
		if x == 0:
			break
print(ans)


(n, r, avg) = map(int, input().split())
array = []
s = 0
for index in range(0, n):
	array.append(list(map(int, input().split())))
	s += array[index][0]
array.sort(key=lambda x: x[1])
index = 0
answer = 0
while s // n < avg:
	if s + r - array[index][0] >= avg * n:
		answer += array[index][1] * (avg * n - s)
		break
	s += r - array[index][0]
	answer += array[index][1] * (r - array[index][0])
	index += 1
print(answer)


def f():
	(n, r, t) = map(int, input().split())
	(t, p) = (t * n, {})
	s = k = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		s += a
		if a == r:
			continue
		p[b] = p.get(b, 0) + r - a
	if s < t:
		for b in sorted(p.keys()):
			d = p[b]
			if d < t - s:
				s += d
				k += d * b
			else:
				return k + (t - s) * b
	return 0
print(f())


(n, r, a) = [int(x) for x in input().split()]
m = [[int(x) for x in input().split()] for _ in range(n)]
m.sort(key=lambda x: x[1])
s = n * a
l = sum((m[i][0] for i in range(n)))
c = 0
for j in range(n):
	if l + r - m[j][0] < s:
		c += (r - m[j][0]) * m[j][1]
		l += r - m[j][0]
	else:
		c += max(s - l, 0) * m[j][1]
		break
print(c)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, r, avg) = iia()
arr = []
tot = 0
for i in range(n):
	(a, b) = iia()
	arr.append([b, a])
	tot += a
if tot // n >= avg:
	print(0)
else:
	req = avg * n - tot
	arr.sort()
	res = 0
	for i in arr:
		if r - i[1] <= req:
			res += i[0] * (r - i[1])
			req -= r - i[1]
		else:
			res += i[0] * req
			break
	print(res)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, r, avg) = value()
a = []
for i in range(n):
	a.append(value())
a.sort(key=lambda a: a[1])
cur = sum((i[0] for i in a))
need = avg * n - cur
ans = 0
if need > 0:
	for i in a:
		canAdd = r - i[0]
		added = min(canAdd, need)
		need -= added
		ans += added * i[1]
print(ans)


def exponent_mod(n, p, prime_const=1000000000 + 7):
	res = 1
	if n == 0:
		return 0
	while p > 0:
		if p % 2 == 1:
			res = res * n % prime_const
		p //= 2
		n = n * n % prime_const
	return res

def find_min_essays(n, r, avg, essays):
	times = 0
	count = 0
	s = 0
	required = 0
	for (grade, essay) in essays:
		s += grade
	if s < n * avg:
		required = n * avg - s
	essays.sort(key=lambda x: x[1])
	for (grade, essay) in essays:
		times = min(r - grade, required)
		count += essay * times
		required -= times
	return count
t = 1
while t:
	t -= 1
	prime_const = pow(10, 9) + 7
	values = list(map(int, input().strip().split()))[:3]
	n = values[0]
	r = values[1]
	avg = values[2]
	essays = []
	for i in range(n):
		items = list(map(int, input().strip().split()))[:2]
		essays.append([items[0], items[1]])
	print(find_min_essays(n, r, avg, essays))


def arr_inp():
	return [int(x) for x in stdin.readline().split()]

def get_col(arr, i):
	return [row[i] for row in arr]
from sys import stdin
from operator import itemgetter
(n, r, avg) = arr_inp()
arr = sorted([arr_inp() for i in range(n)], key=itemgetter(1, 0))
(ans, avg1, avg) = (0, sum(get_col(arr, 0)), avg * n)
for i in range(n):
	if avg1 >= avg:
		break
	if avg1 + (r - arr[i][0]) >= avg:
		ans += (avg - avg1) * arr[i][1]
		break
	else:
		avg1 += r - arr[i][0]
		ans += (r - arr[i][0]) * arr[i][1]
print(ans)


import sys
input = sys.stdin.readline
(n, r, avg) = map(int, input().split())
f = []
u = 0
for j in range(n):
	(a, b) = map(int, input().split())
	u += a
	f.append([b, a])
f.sort()
if u / n >= avg:
	print(0)
else:
	req = avg * n - u
	ans = 0
	for j in range(n):
		if f[j][1] < r:
			got = r - f[j][1]
			g = min(got, req)
			ans += g * f[j][0]
			req -= g
			if req == 0:
				print(ans)
				break


import math as ma
import sys
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, sys.stdin.readline().split()))

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(sys.stdin.readline())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(n, r, avg) = num()
a = [0] * n
b = [0] * n
z = 0
for i in range(n):
	(a[i], b[i]) = num()
	z += a[i]
if z >= avg * n:
	print(0)
else:
	avg = avg * n
	cc = avg - z
	ss = sorted(zip(b, a))
	x = 0
	for i in range(n):
		if ss[i][1] >= r:
			continue
		pp = r - ss[i][1]
		xp = min(pp, cc)
		cc -= xp
		x += ss[i][0] * xp
		if cc == 0:
			break
	print(x)


(n, r, avg) = map(int, input().split())
arr = []
for _ in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])

def cmp(x):
	return x[1]
arr.sort(key=cmp)
current_sum = 0
for i in range(len(arr)):
	current_sum += arr[i][0]
need = avg * n - current_sum
if current_sum / n >= avg:
	print(0)
else:
	s = 0
	for i in range(len(arr)):
		if arr[i][0] < r:
			possible = r - arr[i][0]
			if possible >= need:
				s += need * arr[i][1]
				need = 0
				break
			else:
				s += possible * arr[i][1]
				need -= possible
	print(s)


(n, r, p) = map(int, input().split())
t = []
for i in range(n):
	t.append(list(map(int, input().split())))

def func(n):
	return n[1]
t = sorted(t, key=func)
s = 0
e = 0
for i in range(len(t)):
	s += t[i][0]
for i in t:
	if s >= p * n:
		break
	if i[0] < r:
		if s + r - i[0] < p * n:
			s += r - i[0]
			e += (r - i[0]) * i[1]
		else:
			e += (p * n - s) * i[1]
			break
print(e)


import sys
from math import sqrt
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(n, r, avg) = map(int, input().split())
res = 0
array = []
gradeSum = 0
for i in range(n):
	(a, b) = map(int, input().split())
	array.append([a, b])
	gradeSum += a
array = sorted(array, key=lambda x: x[1])
gradeAvg = gradeSum / n
if gradeAvg < avg:
	x = n * avg - gradeSum
	for i in range(len(array)):
		res += min(r - array[i][0], x) * array[i][1]
		x -= min(r - array[i][0], x)
		if x <= 0:
			break
print(res)


line = input().split()
(n, r, avg) = (int(line[0]), int(line[1]), int(line[2]))
exams = []
(total, to_add, points) = (avg * n, avg * n, 0)
for i in range(n):
	ex = input().split()
	exams.append((int(ex[0]), int(ex[1])))
exams = sorted(exams, key=lambda t: t[1])
for exam in exams:
	to_add -= exam[0]
if to_add > 0:
	for exam in exams:
		if to_add > 0:
			points += min(r - exam[0], to_add) * exam[1]
			to_add -= r - exam[0]
		else:
			break
else:
	print('0')
	exit()
print(points)


def mergesort(arr, sup):
	if len(arr) > 1:
		mid = len(arr) // 2
		left = arr[:mid]
		right = arr[mid:]
		leftsup = sup[:mid]
		rightsup = sup[mid:]
		mergesort(left, leftsup)
		mergesort(right, rightsup)
		i = j = k = 0
		while i < len(left) and j < len(right):
			if left[i] < right[j]:
				arr[k] = left[i]
				sup[k] = leftsup[i]
				i += 1
			else:
				arr[k] = right[j]
				sup[k] = rightsup[j]
				j += 1
			k += 1
		while i < len(left):
			arr[k] = left[i]
			sup[k] = leftsup[i]
			i += 1
			k += 1
		while j < len(right):
			arr[k] = right[j]
			sup[k] = rightsup[j]
			j += 1
			k += 1
	return (arr, sup)

def swap(i, j, a, b):
	(a[i], a[j]) = (a[j], a[i])
	(b[i], b[j]) = (b[j], b[i])
try:
	(n, r, avg) = map(int, input().split())
	(a, b) = ([], [])
	(sum, diff, ans) = (0, 0, 0)
	for _ in range(n):
		(ai, bi) = map(int, input().split())
		a.append(ai)
		b.append(bi)
		sum += ai
	if sum >= n * avg:
		print(0)
		exit()
	else:
		diff = n * avg - sum
	(b, a) = mergesort(b, a)
	for i in range(len(a)):
		if diff == 0:
			break
		if r - a[i] > 0:
			if r - a[i] <= diff:
				ans = ans + (r - a[i]) * b[i]
				diff -= r - a[i]
			else:
				ans = ans + diff * b[i]
				diff = 0
	print(ans)
except EOFError as e:
	pass


import sys

def read(line):
	return [int(c) for c in line.strip().split()]

def main():
	test = sys.stdin.readlines()
	(n, r, avg) = read(test[0])
	grades = [read(test[i]) for i in range(1, n + 1)]
	grades.sort(key=lambda x: x[1])
	cur_sum = sum((g[0] for g in grades))
	required_sum = avg * len(grades)
	i = 0
	ans = 0
	while cur_sum < required_sum:
		diff = required_sum - cur_sum
		max_inc = r - grades[i][0]
		if max_inc <= diff:
			ans += grades[i][1] * max_inc
			cur_sum += max_inc
		else:
			ans += grades[i][1] * diff
			break
		i += 1
	print(ans)
main()


(num_exams, max_grade, average_grade) = map(int, input().split())
required_points = average_grade * num_exams
num_essays_to_do = 0
exams = [tuple(map(int, input().split())) for _ in range(num_exams)]
exams.sort(key=lambda exam: exam[1])
for exam in exams:
	required_points -= exam[0]
if required_points > 0:
	for exam in exams:
		points_to_obtain_in_exam = min(required_points, max_grade - exam[0])
		num_essays_to_do += points_to_obtain_in_exam * exam[1]
		required_points -= points_to_obtain_in_exam
		if required_points == 0:
			break
print(num_essays_to_do)


from collections import defaultdict
(n, r, avg) = map(int, input().split())
essayDict = defaultdict(int)
required = 0
for i in range(n):
	(g, b) = map(int, input().split())
	essayDict[b] += r - g
	required += g
required = n * avg - required
essays = 0
key = list(essayDict.keys())
key.sort()
for i in key:
	if required <= 0:
		break
	if essayDict[i] > required:
		essays += i * required
		required = 0
	else:
		essays += i * essayDict[i]
		required -= essayDict[i]
print(essays)


import sys
import itertools
import math
import collections
from collections import Counter
input = sys.stdin.readline

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def flin(d, x, default=-1):
	f = l = -1
	for i in range(len(d)):
		if d[i] == x:
			if f == -1:
				f = i
			l = i
	if f == -1:
		return (default, default)
	else:
		return (f, l)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
(n, r, avg) = mi()
d = []
m = 0
for _ in range(n):
	(x, y) = mi()
	m += x
	d.append([y, x])
d.sort()
need = max(0, avg * n - m)
ans = i = 0
for i in range(n):
	if need == 0:
		break
	if r != d[i][1]:
		t = min(need, r - d[i][1])
		need -= t
		ans += t * d[i][0]
print(ans)


def Sort(sub_li):
	sub_li.sort(key=lambda x: x[1])
	return sub_li
o = input().rstrip().split(' ')
req = int(o[0]) * int(o[2])
total = 0
l = []
for i in range(0, int(o[0])):
	p = input().rstrip().split(' ')
	D = []
	D.append(int(p[0]))
	D.append(int(p[1]))
	l.append(D)
	total += int(p[0])
if total >= req:
	print(0)
else:
	gp = int(o[1])
	l = Sort(l)
	req = req - total
	total = 0
	for i in range(0, len(l)):
		if req > 0:
			T = l[i]
			A = gp - T[0]
			if A > 0:
				if A >= req:
					total += T[1] * req
					break
				else:
					total += A * T[1]
					req -= A
	print(total)


(n, r, avg) = map(int, input().split())
lst = []
c = 0
for i in range(n):
	lst.append(list(map(int, input().split())))

def aver(li):
	s = sum((x for (x, y) in li))
	return s / len(lst)
if aver(lst) < avg:
	lst = sorted(lst, key=lambda x: x[1])
	x = avg * len(lst) - sum((k for (k, p) in lst))
	for (f, s) in lst:
		if r - f < x:
			c += s * (r - f)
			x -= r - f
		else:
			c += x * s
			break
	print(c)
else:
	print(0)


def sort_by_second(n):
	return n[1]
(n, r, avg) = map(int, input().split())
marks = []
s = 0
for i in range(n):
	(a, b) = map(int, input().split())
	marks.append([a, b])
	s += marks[i][0]
to_collect = avg * n - s
collected = 0
answer = 0
marks.sort(key=sort_by_second)
i = 0
while collected < to_collect:
	add = min(r - marks[i][0], to_collect - collected)
	collected += add
	answer += add * marks[i][1]
	i += 1
print(answer)


def solve(n, r, avg, grades):
	grades.sort(key=lambda x: (x[1], x[0]))
	vanyas = sum((a for (a, b) in grades))
	remaining = avg * n - vanyas
	written = 0
	for (a, b) in grades:
		if remaining <= 0:
			break
		else:
			win = int(min(r - a, remaining))
			written += b * win
			remaining -= win
	return written if remaining <= 0 else -1

def main():
	(n, r, avg) = map(int, input().split())
	grades = []
	for _ in range(n):
		(a, b) = map(int, input().split())
		grades.append((a, b))
	res = solve(n, r, avg, grades)
	print(res)
main()


import operator
(n, r, avg) = map(int, input().split())
(x, y) = (0, 0)
s = 0
l = []
for i in range(n):
	(x, y) = map(int, input().split())
	l.append([x, y])
	s += x
l.sort(key=operator.itemgetter(1))
s = n * avg - s
(ans, i) = (0, 0)
while s > 0 and i < n:
	ans += min(s, r - l[i][0]) * l[i][1]
	s -= min(s, r - l[i][0])
	i += 1
print(ans)


(n, r, avg) = [int(x) for x in input().split()]
ls = []
for i in range(n):
	ls.append([int(x) for x in input().split()])
ls.sort(key=lambda x: x[1])
s = sum([x[0] for x in ls])
ans = 0
if s >= avg * n:
	print(0)
else:
	for i in range(n):
		if avg * n - s <= r - ls[i][0]:
			ans += (avg * n - s) * ls[i][1]
			print(ans)
			break
		else:
			ans += (r - ls[i][0]) * ls[i][1]
			s += r - ls[i][0]
			if s >= avg * n:
				print(ans)
				break


__author__ = 'valeriy.shevchuk'
from math import ceil
(n, r, avg) = map(int, input().split())
data = []
sum_v = 0
for i in range(n):
	(a, b) = map(int, input().split())
	sum_v += a
	data.append((a, b))
need = ceil(max(avg * n - sum_v, 0))
data = sorted(data, key=lambda x: x[1])
ref = 0
for i in range(len(data)):
	if need <= 0:
		break
	if data[i][0] < r:
		grades = min(r - data[i][0], need)
		ref += grades * data[i][1]
		need -= grades
print(ref)


import logging
import sys
nivel_log = logging.ERROR
logger_cagada = None

def vania_puta_core(examenes, tope_calificacion, promedio):
	examenes_tam = len(examenes)
	total_de_promedio = examenes_tam * promedio
	chosto_total = 0
	total_inicial = 0
	for (_, calif) in examenes:
		total_inicial += calif
	faltante_para_total_de_promedio = total_de_promedio - min(total_de_promedio, total_inicial)
	for (chosto, calif) in examenes:
		if calif < tope_calificacion and faltante_para_total_de_promedio:
			faltante_calif_para_torpe = tope_calificacion - calif
			putos_a_tomar = min(faltante_para_total_de_promedio, faltante_calif_para_torpe)
			faltante_para_total_de_promedio -= putos_a_tomar
			chosto_total += chosto * putos_a_tomar
			if not faltante_para_total_de_promedio:
				break
	return chosto_total

def vania_puta_main():
	lineas = list(sys.stdin)
	(_, tope_calificacion, promedio) = [int(x) for x in lineas[0].strip().split(' ')]
	examenes = []
	for linea in lineas[1:]:
		(calif, chosto) = [int(x) for x in linea.strip().split(' ')]
		examenes.append((chosto, calif))
	examenes.sort()
	logger_cagada.debug('examenes {}'.format(examenes))
	chosto_total = vania_puta_core(examenes, tope_calificacion, promedio)
	print('{}'.format(chosto_total))
FORMAT = '[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s'
logging.basicConfig(level=nivel_log, format=FORMAT)
logger_cagada = logging.getLogger('asa')
logger_cagada.setLevel(nivel_log)
vania_puta_main()


from sys import stdin
(n, r, avg) = map(int, next(stdin).split())
ab = []
ab_min = []
summ = 0
for e in range(n):
	(a, b) = map(int, next(stdin).split())
	ab.append([a, b])
	if a < r:
		ab_min.append([a, b])
	summ += a
mean = summ / n

def compare_refs(x):
	return x[1]
refs = 0
ab_min = sorted(ab_min, key=compare_refs)
i_a = 0
while mean < avg:
	try_num_points = r - ab_min[i_a][0]
	summ += try_num_points
	if avg * n - summ > 0:
		refs += try_num_points * ab_min[i_a][1]
		i_a += 1
	elif avg * n - summ == 0:
		refs += try_num_points * ab_min[i_a][1]
		break
	else:
		summ -= try_num_points
		refs += (avg * n - summ) * ab_min[i_a][1]
		break
	mean = summ / n
print(refs)


from sys import stdin, stdout
(n, r, arg) = map(int, stdin.readline().split())
a = []
sum = 0
for _ in range(n):
	(x, y) = map(int, stdin.readline().split())
	a.append([y, x])
	sum += x
a.sort()
sum = n * arg - sum
essasy = 0
for element in a:
	if sum <= 0:
		print(essasy)
		exit()
	if r != element[1]:
		z = min(sum, r - element[1])
		sum -= z
		essasy += z * element[0]
stdout.write('%d' % essasy)


(a, b) = ([], [])
m = []
(n, r, ag) = map(int, input().split())
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append([y, r - x])
s = ag * n - sum(a)
b = sorted(b)
count = 0
for i in range(n):
	if s > 0:
		count += b[i][0] * min(s, b[i][1])
		s -= min(s, b[i][1])
print(count)


from collections import defaultdict
(number_of_exams, maximum_grade, average_grade) = map(int, input().strip().split(' '))
(list_of_essays, list_of_grades) = (defaultdict(list), [])
(minimum_number_of_required_essays, total_grade) = (0, 0)
answerIsFound = False
minimum_grade_requirement = average_grade * number_of_exams
for i in range(number_of_exams):
	(grade, required_essay) = map(int, input().strip().split(' '))
	list_of_grades.append(grade)
	list_of_essays[required_essay].append(i)
	total_grade += grade
if total_grade / number_of_exams >= average_grade:
	print(0)
else:
	for key in sorted(list_of_essays.keys()):
		for value in list_of_essays[key]:
			current_grade = list_of_grades[value]
			if total_grade + (maximum_grade - current_grade) < minimum_grade_requirement:
				minimum_number_of_required_essays += (maximum_grade - current_grade) * key
				total_grade += maximum_grade - current_grade
			else:
				minimum_number_of_required_essays += (minimum_grade_requirement - total_grade) * key
				answerIsFound = True
				break
		if answerIsFound:
			break
	print(minimum_number_of_required_essays)


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, r, avg) = map(int, input().split())
mat = []
for i in range(n):
	(a, b) = map(int, input().split())
	mat.append([b, a])
mat.sort()
mark = 0
for i in range(n):
	mark += mat[i][1]
count = 0
i = 0
while mark < avg * n:
	temp = min(avg * n - mark, r - mat[i][1])
	count += temp * mat[i][0]
	mark += temp
	i += 1
print(count)


def vanya_exams():
	from math import ceil
	(n, r, avg) = map(int, input().split())
	arr = []
	points = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		points += a
		if a < r:
			arr.append([a, b])
	my_avg = points / n
	if my_avg >= avg:
		return 0
	points_required = int(ceil(n * avg - n * my_avg))
	count = 0
	arr.sort(key=lambda x: x[1])
	for i in range(len(arr)):
		temp = min(points_required, r - arr[i][0])
		count += temp * arr[i][1]
		points_required -= temp
		if points_required <= 0:
			return count
print(int(vanya_exams()))


(n, r, avg) = map(int, input().split())
avg *= n
a = [0] * n
b = [0] * n
mas = [[0, 0]] * n
summ = 0
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
	summ += a[i]
	mas[i] = [b[i], a[i] - r]
mas.sort()
for i in range(n):
	mas[i][1] *= -1
i = 0
cnt = 0
while i < n and summ < avg:
	cnt += min(mas[i][1], avg - summ) * mas[i][0]
	summ += min(mas[i][1], avg - summ)
	i += 1
print(cnt)


(n, r, avg) = map(int, input().split())
exams = []
sum_exam = 0
for j in range(n):
	(a, b) = map(int, input().split())
	exams.append((a, b))
	sum_exam += a
if sum_exam == n * avg:
	print(0)
else:
	sum = 0
	exams = sorted(exams, key=lambda x: x[1])
	remaining = n * avg - sum_exam
	i = 0
	while i < n and remaining > 0:
		if exams[i][0] < r:
			point_gap = r - exams[i][0]
			essay_i = exams[i][1]
			if point_gap <= remaining:
				sum += point_gap * essay_i
			else:
				sum += remaining * essay_i
			remaining -= point_gap
		i += 1
	print(sum)


(n, r, req) = map(int, input().split())
exams = []
avg = 0
req *= n
essays = 0
for i in range(n):
	(a, b) = map(int, input().split())
	exams.append((a, b))
	avg += a
exams.sort(key=lambda x: x[1])
if req > avg:
	for exam in exams:
		if exam[0] < r:
			essays += exam[1] * min(r - exam[0], req - avg)
			avg += min(r - exam[0], req - avg)
		if avg >= req:
			break
print(essays)


from sys import stdin
(n, r, avg) = map(int, input().split())

def sumy(x):
	s = 0
	for i in x:
		s += i[0]
	return s
exams = [list(map(int, input().split())) for i in range(n)]
s = sumy(exams)
exams.sort(key=lambda x: x[1], reverse=True)
exe = 0
while s / n < avg:
	(a, b) = exams.pop()
	if (s + r - a) / n < avg:
		exe += (r - a) * b
		s += r - a
	else:
		z = avg * n - s
		s += z
		exe += z * b
print(exe)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		(n, r, avg) = LI()
		ab = [LI() for _ in range(n)]
		at = avg * n
		t = 0
		u = []
		for (a, b) in ab:
			t += a
			if a < r:
				u.append((b, r - a))
		u.sort()
		s = 0
		for (b, c) in u:
			if t >= at:
				break
			k = min(c, at - t)
			s += b * k
			t += k
		rr.append(s)
	return JA(rr, '\n')
print(main())


(n, r, mi) = map(int, input().split())
l = []
t = 0
k = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if r - a > 0:
		l.append([b, r - a])
		t = t + a
	if r - a <= 0:
		t = t + a
V = mi * n - t
l = sorted(l)
for x in l:
	if V > 0:
		k = k + min(V, x[1]) * x[0]
		V = V - min(V, x[1])
print(k)


(n, r, avg) = map(int, input().split())
a = [list(reversed(list(map(int, input().split())))) for i in range(n)]
a.sort()
cur = 0
req = avg * n
for i in range(n):
	cur += a[i][1]
i = 0
ans = 0
while i < n and cur < req:
	d = min(req - cur, r - a[i][1])
	ans += min(req - cur, r - a[i][1]) * a[i][0]
	i += 1
	cur += d
print(ans)


(n, r, avg) = map(int, input().split())
ab = [0] * n
for i in range(n):
	(a, b) = map(int, input().split())
	ab[i] = (b, a)
ab.sort()
summ = avg * n
summ1 = 0
res = 0
for i in range(n):
	summ1 += ab[i][1]
for i in range(n):
	dif = summ - summ1
	now = r - ab[i][1]
	if dif <= 0:
		break
	if now >= dif:
		res += dif * ab[i][0]
		summ1 = summ
	else:
		res += now * ab[i][0]
		summ1 = summ1 + now
print(res)


def solve():
	(n, r, avg) = [int(x) for x in input().split(' ')]
	total = 0
	lst = []
	for i in range(n):
		(mark, essay) = [int(x) for x in input().split(' ')]
		total += int(mark)
		if mark != r:
			lst.append((int(mark), int(essay)))
	if total / n >= avg:
		print(0)
	else:
		lst.sort(key=lambda x: x[1])
		target = avg * n - total
		essays_needed = 0
		while target > 0:
			(mark, essay) = lst.pop(0)
			delta = r - mark
			if delta >= target:
				essays_needed += target * essay
				print(essays_needed)
				return
			else:
				essays_needed += delta * essay
				target -= delta
solve()


import sys
(n, r, avg) = map(int, sys.stdin.readline().split())
arr = []
for i in range(n):
	(x, y) = map(int, sys.stdin.readline().split())
	arr.append([y, x])
s = 0
for i in range(n):
	s += arr[i][1]
if s >= avg * n:
	print(0)
else:
	grades_needed = avg * n - s
	arr.sort()
	ans = 0
	i = 0
	while grades_needed > 0:
		t = min(grades_needed, r - arr[i][1])
		ans += t * arr[i][0]
		grades_needed -= t
		i += 1
	print(ans)


(n, r, avg) = map(int, input().split())
needed = n * avg
current = 0
ammo = []
for i in range(n):
	(a, b) = map(int, input().split())
	current += a
	if a < r:
		ammo.append([b, r - a])
needed -= current
written = 0
if needed > 0:
	ammo.sort()
	while needed > 0:
		x = ammo[0][1]
		if needed >= x:
			written += ammo[0][0] * x
			needed -= x
			ammo.pop(0)
		elif 0 < needed <= x:
			written += ammo[0][0] * needed
			break
print(written)


(n, r, avg) = map(int, input().split())
(arr, s) = ([], 0)
for i in range(n):
	arr.append(list(map(int, input().split())))
	s += arr[-1][0]
arr = sorted(arr, key=lambda x: x[1])
res = 0
for i in range(n):
	if min(n * avg - s, r - arr[i][0]) > 0:
		res += min(n * avg - s, r - arr[i][0]) * arr[i][1]
		s += min(n * avg - s, r - arr[i][0])
print(res)


(n, r, avg) = list(map(int, input().split()))
score = []
total = 0
for i in range(n):
	(a, b) = list(map(int, input().split()))
	score.append((b, a))
	total += a
need_point = max(0, avg * n - total)
score.sort()
ans = 0
for (b, a) in score:
	if need_point == 0:
		break
	if a < r:
		ans += b * min(r - a, need_point)
		need_point -= min(r - a, need_point)
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import heapq
(n, r, avg) = map(int, input().split())
g = []
t = 0
for _ in range(n):
	(u, v) = map(int, input().split())
	t += u
	g.append((u, v))
var = avg * n - t
if t // n >= avg:
	print(0)
	exit()
g.sort(key=lambda x: (x[1], x[0]))
cost = 0
for i in range(n):
	val = r - g[i][0]
	if val < var:
		var -= val
		cost += val * g[i][1]
	else:
		cost += var * g[i][1]
		break
print(cost)


import sys
import string
import math
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

def line():
	return sys.stdin.readline().strip()

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

def main():
	(n, r, req_avg) = mi(line())
	avgs = []
	for _ in range(n):
		avgs.append(tmi(line()))
	required = n * req_avg - sum((x[0] for x in avgs))
	if required <= 0:
		print(0)
		return
	avgs.sort(key=lambda x: x[1])
	total = 0
	for (curr, cost) in avgs:
		if required <= 0:
			break
		if curr >= r:
			continue
		increment_by = min(r - curr, required)
		required -= increment_by
		total += cost * increment_by
	print(total)
main()


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
(n, grMax, grAvg) = IL()
grReq = grAvg * n
exams = [IL() for i in range(n)]
emap = {}
for exam in exams:
	if exam[1] not in emap:
		emap[exam[1]] = 0
	emap[exam[1]] += grMax - exam[0]
imprs = sorted(emap.items())
grRem = grReq - sum([i[0] for i in exams])
ans = 0
for impr in imprs:
	if grRem <= 0:
		break
	grImpr = min(impr[1], grRem)
	ans += grImpr * impr[0]
	grRem -= grImpr
print(ans)


(n, r, avg) = [int(i) for i in input().split()]
li = []
for i in range(n):
	tmp = [int(i) for i in input().split()]
	li.append([tmp[1], tmp[0]])
li.sort(reverse=True)
dis = avg * n - sum([i[1] for i in li])
ans = 0
while dis > 0:
	exam = li.pop()
	if dis <= r - exam[1]:
		ans += exam[0] * dis
		dis = 0
	else:
		ans += exam[0] * (r - exam[1])
		dis -= r - exam[1]
print(ans)


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))

def solve():
	(n, r, avg) = read_tuple(int)
	data = []
	for _ in range(n):
		(a_i, b_i) = read_tuple(int)
		data.append((a_i, b_i))
	needed = avg * n
	current = sum((a_i for (a_i, _) in data))
	data_filtered = [(a_i, b_i) for (a_i, b_i) in data if a_i < r]
	data_filtered.sort(key=lambda x: x[1])
	ans = 0
	for (a_i, b_i) in data_filtered:
		available_delta = r - a_i
		if current < needed:
			if current + available_delta < needed:
				current += available_delta
				ans += available_delta * b_i
			else:
				ans += (needed - current) * b_i
				break
	print(ans)
solve()


from math import ceil
import sys
input = sys.stdin.readline
(n, limit, avg) = map(int, input().split())
arr = []
s = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])
	s += a
want = s / n
if want >= avg:
	print(0)
else:
	arr.sort(key=lambda x: (x[1], x[0]))
	score = 0
	ans = 0
	want = avg * n - s
	for i in range(n):
		if score >= want:
			break
		ans += min(want - score, limit - arr[i][0]) * arr[i][1]
		score += min(want - score, limit - arr[i][0])
	print(ans)


(n, r, av) = map(int, input().split())
s = 0
a = []
d = n * av
for i in range(n):
	z = input().split()
	a.append([int(z[1]), int(z[0])])
	d -= a[-1][1]
a.sort()
for x in a:
	if d <= 0:
		break
	k = min(r - x[1], d)
	s += k * x[0]
	d -= k
print(s)


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
input = sys.stdin.buffer.readline
(n, r, avg) = map(int, input().split())
mat = []
for i in range(n):
	(a, b) = map(int, input().split())
	mat.append([b, a])
mat.sort()
mark = 0
for i in range(n):
	mark += mat[i][1]
count = 0
i = 0
while mark < avg * n:
	temp = min(avg * n - mark, r - mat[i][1])
	count += temp * mat[i][0]
	mark += temp
	i += 1
print(count)


import os, sys, heapq
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil
mod = 10 ** 9 + 7
for _ in range(1):
	(n, end_limit, avg) = map(int, input().split())
	info = [[0, 0] for _ in range(n)]
	total_grade = 0
	heap = []
	for _ in range(n):
		(grade, essay) = map(int, input().split())
		total_grade += grade
		if grade < end_limit:
			heapq.heappush(heap, (essay, grade))
	required_grades = n * avg - total_grade
	count = 0
	while required_grades > 0:
		(current_essay, grade) = heap[0]
		heapq.heappop(heap)
		if grade + required_grades <= end_limit:
			count += required_grades * current_essay
			required_grades = 0
		else:
			count += (end_limit - grade) * current_essay
			required_grades -= end_limit - grade
	print(count)


import math
(n, min_g, min_avg) = [int(i) for i in input().split()]
a = []
for i in range(n):
	(a1, b1) = [int(i) for i in input().split()]
	a.append((b1, a1))
a.sort()
s = 0
for i in range(n):
	s += a[i][1]
avg = s / n
diff = min_avg - avg
if diff <= 0:
	print(0)
else:
	req = diff * n
	req = int(req)
	if (s + req) / n < min_avg:
		req += 1
	ans = 0
	for i in range(n):
		possi = min_g - a[i][1]
		possi_1 = min(req, possi)
		ans += possi_1 * a[i][0]
		req -= possi_1
		if req == 0:
			break
	print(ans)


(n, r, avg) = map(int, input().split())
sm = avg * n
sn = 0
scors = []
for _ in range(n):
	(a, b) = map(int, input().split())
	sn += a
	scors.append([a, b])
ans = 0
scors.sort(key=lambda x: x[1])
ind = 0
while sn < sm:
	(a, b) = scors[ind]
	ind += 1
	t = min(r - a, sm - sn)
	sn += t
	ans += b * t
print(ans)


(n, r, avg) = map(int, input().split())
l = []
s = 0
for i in range(n):
	(a, b) = map(int, input().split())
	s = s + a
	l.append((r - a, b))
if s / n >= avg:
	print(0)
else:
	q = avg * n
	s = q - s
	ans = 0
	l = sorted(l, key=lambda x: x[1])
	for i in l:
		if i[0] <= s:
			s = s - i[0]
			ans += i[1] * i[0]
			if s == 0:
				break
		else:
			ans += s * i[1]
			break
	print(ans)


stat = []
(n, r, avg) = map(int, input().split(' '))
for i in range(n):
	(a, b) = map(int, input().split(' '))
	stat.append([a, b, r - a])
req = n * avg
curr = sum([i[0] for i in stat])
need = req - curr
stat.sort(key=lambda x: x[1])
curr = 0
tot = 0
while need > 0:
	if stat[curr][2] <= need:
		tot += stat[curr][2] * stat[curr][1]
		need -= stat[curr][2]
		curr += 1
	else:
		tot += stat[curr][1] * need
		need = 0
print(tot)


(n, r, avg) = map(int, input().split())
exam = []
need_score = n * avg
ret = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	need_score -= a
	if a == r:
		continue
	else:
		exam.append([b, r - a])
exam.sort(key=lambda x: x[0])
for e in exam:
	if need_score <= 0:
		break
	cnt = min(need_score, e[1])
	need_score -= cnt
	ret += cnt * e[0]
print(ret)


(n, r, a) = map(int, input().split())
(l, e, b) = ([], 0, 0)
for i in [1] * n:
	(q, w) = map(int, input().split())
	l += [[w, r - q]]
	e += q
l.sort()
k = n * a - e if n * a > e else 0
for i in l:
	p = i[0] * min(i[1], k)
	b += p
	k -= i[1]
	if k <= 0:
		break
print(b)


(n, r, avg) = map(int, input().split())
a = []
for i in range(n):
	c = list(map(int, input().split()))
	a.append([c[0], c[1]])
s = 0
ans = 0
for i in range(n):
	s += a[i][0]
a.sort(key=lambda x: x[1])
i = 0
while s / n < avg:
	if a[i][0] < r:
		k = min(r - a[i][0], n * avg - s)
		s += k
		ans += k * a[i][1]
	del a[i]
print(ans)


(n, r, avg) = map(int, input().split())
m = []
for i in range(n):
	g = list(map(int, input().split()))
	m.append(g)
total = avg * n
marks = 0
for i in range(n):
	marks += m[i][0]
req = total - marks
if req <= 0:
	print(0)
else:
	b = []
	for i in range(n):
		b.append(m[i][1])
	a = [0] * (max(b) + 1)
	for i in range(n):
		x = r - m[i][0]
		a[m[i][1]] += x
	cnt = 0
	for i in range(max(b) + 1):
		req -= a[i]
		if req > 0:
			cnt += a[i] * i
		else:
			cnt += (a[i] + req) * i
			break
	print(cnt)


(n, r, avg) = map(int, input().split())
(scores, essays) = ([], [])
for _ in range(n):
	(a, b) = map(int, input().split())
	scores.append(a)
	essays.append(b)
now = sum(scores)
ineed = n * avg
essay_cnt = 0
while now < ineed:
	pref = sorted(range(n), key=essays.__getitem__)
	for i in pref:
		(a, b) = (scores[i], essays[i])
		delta = min(ineed - now, r - a)
		essay_cnt += b * delta
		now += delta
print(essay_cnt)


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m, a) = map(int, input().split(' '))
l = []
t = 0
for i in range(n):
	(x, y) = map(int, input().split(' '))
	l.append([y, x])
	t += x
if t >= a * n:
	print(0)
else:
	l.sort()
	req = a * n - t
	c = 0
	for i in range(n):
		if l[i][1] < m:
			pos = m - l[i][1]
			ad = min(req, pos)
			req -= ad
			c += ad * l[i][0]
		if req == 0:
			break
	print(c)


(n, r, avg) = map(int, input().split())
t = avg * n
l = []
num = 0
ans = 0
for i in range(n):
	(a, b) = map(int, input().split())
	num += a
	l.append((b, r - a))
l = sorted(l)
i = 0
while num < t:
	left = t - num
	tmp = min(left, l[i][1])
	ans += tmp * l[i][0]
	num += tmp
	i += 1
print(ans)


(n, limit, avg) = map(int, input().split())
l = []
s = 0
avg *= n
for i in range(n):
	(a, b) = map(int, input().split())
	s += a
	l.append((b, a))
l = sorted(l)
rs = 0
i = 0
while i < n and avg > s:
	x = min(limit - l[i][1], avg - s)
	s += x
	rs += l[i][0] * x
	i += 1
print(rs)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
(n, r, avg) = map(int, input().split())
a = []
b = []
for i in range(n):
	(ai, bi) = get_ints()
	a.append(ai)
	b.append(bi)
if sum(a) >= n * avg:
	print(0)
	sys.exit()
req = []
for i in range(n):
	req.append([b[i], r - a[i]])
req.sort()
rpoints = n * avg - sum(a)
ans = 0
for i in range(n):
	if rpoints == 0:
		break
	if req[i][1] == 0:
		continue
	ans += min(rpoints, req[i][1]) * req[i][0]
	rpoints -= min(rpoints, req[i][1])
print(ans)


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, input().split()))

def ei():
	return map(int, input().split())

def ip():
	return int(stdin.readline())

def op(ans):
	return stdout.write(str(ans) + '\n')
from math import ceil
(n, r, avg) = ei()
marks = []
essay = []
writing = 0
for i in range(n):
	(a, b) = ei()
	marks.append(a)
	essay.append(b)
total_marks = sum(marks)
marks_to_reach = avg * n
need_avg = total_marks / n
final = sorted(zip(marks, essay), key=lambda x: x[1])
for i in final:
	if total_marks >= marks_to_reach:
		break
	if i[0] <= r:
		avail = r - i[0]
		if total_marks + avail <= marks_to_reach:
			total_marks += avail
			writing += avail * i[1]
		else:
			writing += (marks_to_reach - total_marks) * i[1]
			total_marks += marks_to_reach - total_marks
print(writing)


def sum_i(a):
	sum_j = 0
	for i in range(len(a)):
		sum_j = sum_j + a[i][1]
	return sum_j
(n, m, r) = map(int, input().split())
a = []
for i in range(n):
	(v, c) = map(int, input().split())
	a.append([c, v])
a.sort()
s = 0
h = r * n
sum_ = sum_i(a)
if sum_ >= h:
	print('0')
else:
	for i in range(len(a)):
		if sum_ >= h:
			break
		elif a[i][1] < m:
			if sum_ + (m - a[i][1]) == h:
				s = s + a[i][0] * (m - a[i][1])
				break
			elif sum_ + (m - a[i][1]) > h:
				s = s + a[i][0] * (m - a[i][1] - (sum_ + (m - a[i][1]) - h))
				break
			else:
				sum_ = sum_ + (m - a[i][1])
				s = s + a[i][0] * (m - a[i][1])
				a[i][1] = a[i][1] + (m - a[i][1])
	print(s)


(n, r, avg) = [int(X) for X in input().split()]
pairs = [[int(X) for X in input().split()] for i in range(n)]
req = avg * n - sum([x[0] for x in pairs])
pairs = sorted(pairs, key=lambda x: x[1])
n_essay = 0
for x in pairs:
	if req <= 0:
		break
	pts = min(r - x[0], req)
	n_essay += pts * x[1]
	req -= pts
print(n_essay)


l = [int(i) for i in input().split()]
n = l[0]
r = l[1]
a = l[2]
e = [None] * n
i = 0
goal = a * n
s = 0
while i < n:
	e[i] = [int(x) for x in input().split()]
	s += e[i][0]
	i += 1
e.sort(key=lambda y: y[1])
deficit = goal - s
essays = 0
i = 0
while deficit > 0:
	while e[i][0] == r:
		i += 1
	if deficit > r - e[i][0]:
		essays += (r - e[i][0]) * e[i][1]
		deficit -= r - e[i][0]
		e[i][0] = r
	else:
		essays += deficit * e[i][1]
		deficit = 0
		e[i][0] += deficit
print(essays)


def main():
	(n, r, avg) = map(int, input().strip().split())
	cur_sum = 0
	exams = list()
	for i in range(n):
		(a, b) = map(int, input().strip().split())
		cur_sum += a
		if a < r:
			exams.append((a, b))
	if cur_sum / n >= avg:
		print(0)
		return

	def ts(el):
		return el[1]
	exams = sorted(exams, key=ts)
	req_sum = avg * n
	d = req_sum - cur_sum
	added = 0
	pos = 0
	while 1:
		(a, b) = exams[pos]
		z = r - a
		if z >= d:
			added += d * b
			print(added)
			return
		if z < d:
			added += z * b
			pos += 1
			d -= z
main()


(n, r, avg) = list(map(int, input().split()))
pass_point = avg * n
current_point = 0
a = []
for _ in range(n):
	(point, essay) = list(map(int, input().split()))
	a.append([essay, point])
	current_point += point
a.sort()
ans = 0
for i in range(n):
	point = a[i][1]
	essay = a[i][0]
	if current_point + r - point <= pass_point:
		ans += (r - point) * essay
		current_point += r - point
	elif current_point <= pass_point:
		ans += (pass_point - current_point) * essay
		current_point = pass_point
print(ans)


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
from fractions import Fraction
mod = 100000007
(n, r, avg) = vary(3)
grades = []
for i in range(n):
	(u, v) = vary(2)
	grades.append([v, u])
grades.sort()
intial = 0
for i in range(n):
	intial += grades[i][1]
total = n * avg
count = 0
getit = total - intial
if getit <= 0:
	print(0)
	exit()
for i in range(n):
	if intial < total:
		if grades[i][1] < r:
			if getit >= r - grades[i][1]:
				count += grades[i][0] * (r - grades[i][1])
				getit = getit - r + grades[i][1]
				intial += 1
			else:
				count += grades[i][0] * getit
				intial += 1
				break
	else:
		break
print(count)


(n, r, avg) = map(int, input().split())
lst = []
ans = 0
s = n * avg
for i in range(n):
	x = input().split()
	lst.append([int(x[1]), int(x[0])])
	s -= int(x[0])
lst.sort()
for j in lst:
	if s <= 0:
		break
	tem = min(s, r - j[1])
	ans += tem * j[0]
	s -= tem
print(ans)


(n, r, avg) = map(int, input().split())
l = []
grade = 0
for i in range(n):
	(a, b) = map(int, input().split())
	l.append([b, a])
	grade += a
reqd = n * avg - grade
if reqd < 1:
	print(0)
	exit()
l.sort()
i = 0
ans = 0
while reqd > 0:
	if reqd > r - l[i][1]:
		ans += l[i][0] * (r - l[i][1])
		reqd -= r - l[i][1]
		i += 1
	else:
		ans += l[i][0] * reqd
		reqd = 0
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, r, avg) = map(int, input().split())
x = n * avg
l1 = [0 for i in range(0, n)]
sum1 = 0
sum2 = 0
for i in range(0, n):
	(a, b) = map(int, input().split())
	sum1 += a
	l1[i] = [b, a]
if sum1 > x:
	print(0)
else:
	l1.sort()
	for i in l1:
		p = min(r - i[1], x - sum1)
		sum2 += p * i[0]
		sum1 += p
		if x == sum1:
			break
	print(sum2)


(n, r, avg) = list(map(int, input().split()))
a = []
sum = int(round(avg * n))
sum1 = 0
res = 0
for i in range(n):
	(x, y) = list(map(int, input().split()))
	a.append([y, x])
	sum1 += x
a.sort()
i = 0
while sum > sum1:
	if sum - sum1 > r - a[i][1]:
		sum1 += r - a[i][1]
		res += (r - a[i][1]) * a[i][0]
		i += 1
	else:
		res += (sum - sum1) * a[i][0]
		sum1 = sum
print(res)


(n, r, avg) = map(int, input().split())
sum_of_marks = 0
sum_required = n * avg
a = n * [0]
ans = 0
for i in range(n):
	x = list(map(int, input().split()))
	a[i] = x
	sum_of_marks += x[0]
a.sort(key=lambda x: x[1])
if sum_of_marks >= sum_required:
	print(0)
else:
	while sum_of_marks < sum_required:
		for i in range(n):
			if a[i][0] != r:
				if r - a[i][0] + sum_of_marks < sum_required:
					ans += (r - a[i][0]) * a[i][1]
					sum_of_marks += r - a[i][0]
				else:
					ans += (sum_required - sum_of_marks) * a[i][1]
					sum_of_marks = sum_required
			if sum_of_marks >= sum_required:
				break
		break
	print(ans)


(n, r, avg) = map(int, input().split())
l = []
s = 0
for i in range(n):
	k = []
	(a, b) = map(int, input().split())
	s += a
	k.append(b)
	k.append(a)
	l.append(k)
lp = avg * n - s
l.sort()
i = 0
nes = 0
while lp > 0:
	slp = r - l[i][1]
	mi = min(lp, slp)
	nes += mi * l[i][0]
	lp -= mi
	i += 1
print(nes)


(n, r, avg) = map(int, input().split())
arr = []
s = 0
for i in range(n):
	(a, b) = map(int, input().split())
	arr.append((b, r - a))
	s += a
arr.sort()
(i, res) = (0, 0)
while s < n * avg:
	if n * avg - s <= arr[i][1]:
		res += (n * avg - s) * arr[i][0]
		s = n * avg
	else:
		s += arr[i][1]
		res += arr[i][1] * arr[i][0]
	i += 1
print(res)


(n, r, avg) = map(int, input().split())
a = []
cur = 0
for i in range(n):
	a.append(list(map(int, input().split())))
	(a[i][0], a[i][1]) = (a[i][1], a[i][0])
	cur += a[i][1]
a.sort()
ans = 0
for i in range(n):
	if cur < avg * n:
		ans += a[i][0] * min(n * avg - cur, r - a[i][1])
		cur += min(n * avg - cur, r - a[i][1])
	else:
		break
print(ans)


from sys import stdin
input = stdin.readline
(n, r, avg) = map(int, input().split())
prosjek = avg * n
popis = []
sad = 0
for i in range(n):
	(a, b) = map(int, input().split())
	popis.append([b, a])
	sad += a
popis = sorted(popis)
treba = 0
e = 0
while sad < prosjek:
	smanji = prosjek - sad
	if smanji > r - popis[e][1]:
		smanji = r - popis[e][1]
	sad += smanji
	treba += smanji * popis[e][0]
	e += 1
print(treba)


import operator
(n, r, avg) = list(map(int, input().split()))
Goal = n * avg
(Sum, ans) = (0, 0)
Exam = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	Sum += a
	Exam.append([a, b])
Exam.sort(key=operator.itemgetter(1))
i = 0
while Sum < Goal and i < n:
	d = min(Goal - Sum, r - Exam[i][0])
	ans += d * Exam[i][1]
	Sum += d
	i = i + 1
print(ans)


(n, r, avg) = map(int, input().split())
l = []
top = 0
for i in range(n):
	(a, b) = map(int, input().split())
	top += a
	l.append((a, b))
ne = avg * n
l.sort(key=lambda x: x[1])
res = 0
for i in l:
	(a, b) = i
	inc = r - a
	t = inc * b
	if top + inc < ne:
		res += t
		top += inc
	elif top + inc >= ne:
		kk = max(ne - top, 0)
		res += kk * b
		break
print(res)


(n, r, avg) = map(int, input().split())
arr = []
count = 0
for i in range(n):
	(a, b) = map(int, input().split())
	count += a
	arr.append([b, a])
arr.sort()
total = avg * n
e = 0
i = 0
while i < n and total > count:
	e += arr[i][0] * min(total - count, r - arr[i][1])
	count += min(total - count, r - arr[i][1])
	i += 1
print(e)


def main():
	(n, r, avg) = map(int, input().split())
	need = avg * n
	d = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])
	cur = sum((x[0] for x in d))
	ret = 0
	left = need - cur
	if left <= 0:
		return 0
	for x in d:
		can = min(r - x[0], left)
		ret += can * x[1]
		left -= can
		if left == 0:
			return ret
print(main())


(n, r, avg) = map(int, input().split())
rs = avg * n
s = 0
al = []
for _ in range(n):
	(x, y) = map(int, input().split())
	s += x
	if x != r:
		al.append([x, y])
al.sort(key=lambda x: x[1])
re = rs - s
ans = 0
i = 0
while re > 0:
	if r - al[i][0] > re:
		ans += al[i][1] * re
		re = 0
	else:
		ans += al[i][1] * (r - al[i][0])
		re -= r - al[i][0]
	i += 1
print(ans)


def input_split(f):
	return map(f, input().split())

def main():
	(n, r, avg) = input_split(int)
	ex = []
	sum_a = 0
	for i in range(n):
		(ai, bi) = input_split(int)
		sum_a += ai
		ex.append([bi, ai])
	ex.sort()
	le = avg * n - sum_a
	res = 0
	i = 0
	while le > 0:
		(bi, ai) = ex[i]
		if ai < r:
			time = min(r - ai, le)
			res += bi * time
			le -= time
		i += 1
	print(res)
main()


(n, r, avg) = [int(i) for i in input().split()]
x = n * avg
a = []
tot = 0
for i in range(n):
	(k, l) = [int(i) for i in input().split()]
	tot += k
	a.append([l, k])
a = sorted(a)
(ans, i) = (0, 0)
while tot < x:
	d = min(x - tot, r - a[i][1])
	tot += d
	ans += d * a[i][0]
	i += 1
print(ans)


import sys
import math
(n, r, avg) = [int(n) for n in input().split(' ')]
(arr, s, ind, ret) = (n * [n * [0]], 0, 0, 0)
for i in range(n):
	arr[i] = [int(n) for n in input().split(' ')]
	s += arr[i][0]
arr = sorted(arr, key=lambda x: x[1])
while s < avg * n:
	ret += min(avg * n - s, r - min(r, arr[ind][0])) * arr[ind][1]
	s += min(avg * n - s, r - min(r, arr[ind][0]))
	ind += 1
print(ret)


n = list(map(int, input().split()))
r = n[1]
e = 0
l = []
d = n[2] * n[0]
for i in range(n[0]):
	l += [list(map(int, input().split()))]
l.sort(key=lambda x: x[1])
f = [i[0] for i in l]
c = sum(f)
if c < d:
	for i in l:
		if i[0] < r and c + r - i[0] < d:
			e += (r - i[0]) * i[1]
			c += r - i[0]
		elif i[0] < r and c + r - i[0] >= d:
			e += (d - c) * i[1]
			c = d
			break
	print(e)
else:
	print('0')


import sys
import math
import collections
import bisect

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	(n, maxim, avg) = get_ints()
	val = 0
	increase = []
	for i in range(n):
		(a, b) = get_ints()
		val += a
		if a != maxim:
			increase.append([b, maxim - a])
	if val >= avg * n:
		print(0)
		continue
	increase.sort()
	more = avg * n - val
	ans = 0
	pos = 0
	while more > 0:
		cost_for_one = increase[pos][0]
		inc = min(more, increase[pos][1])
		more -= inc
		ans += inc * cost_for_one
		pos += 1
	print(ans)


[n, r, avg] = list(map(int, input().split()))
points = n * avg
mark_sheet = []
for i in range(n):
	mark_sheet.append(list(map(int, input().split())))
mark_sheet.sort(key=lambda x: x[1])
total_points = 0
for i in range(n):
	total_points += mark_sheet[i][0]
ans = 0
current_paper = 0
while points > total_points:
	if total_points + (r - mark_sheet[current_paper][0]) <= points:
		ans += (r - mark_sheet[current_paper][0]) * mark_sheet[current_paper][1]
		total_points += r - mark_sheet[current_paper][0]
	else:
		ans += (points - total_points) * mark_sheet[current_paper][1]
		total_points += points
	current_paper += 1
print(ans)


(n, r, avg) = map(int, input().split())
v_avg = 0
t = [[0 for x in range(2)] for x in range(n)]
for i in range(0, n):
	(t[i][1], t[i][0]) = map(int, input().split())
	v_avg += t[i][1]
s = 0
t.sort()
m = 0
while v_avg < avg * n:
	if v_avg + r - t[m][1] < avg * n:
		s += t[m][0] * (r - t[m][1])
		v_avg += r - t[m][1]
		t[m][1] = r
		m += 1
	else:
		s += t[m][0] * (avg * n - v_avg)
		t[m][1] += avg * n - v_avg
		v_avg = avg * n
print(s)


import sys
(n, m, avg) = list(map(int, sys.stdin.readline().rstrip().lstrip().split()))
arr = []
x = 0
for i in range(n):
	(u, v) = list(map(int, sys.stdin.readline().rstrip().lstrip().split()))
	arr.append([v, u])
	x += u
arr.sort()
req = avg * n
if x >= req:
	sys.stdout.write('0' + '\n')
else:
	req = req - x
	ans = 0
	for i in arr:
		(b, a) = (i[0], i[1])
		rem = m - a
		rem = min(req, rem)
		req -= rem
		ans += rem * b
		if req == 0:
			break
	sys.stdout.write(str(ans) + '\n')


import sys
sys.setrecursionlimit(10 ** 8)
try:
	FILE_POINTER = open('input.inpt')
	input = FILE_POINTER.readline
except:
	FILE_POINTER = None
	input = sys.stdin.readline
(n, r, av) = list(map(int, input().strip().split()))
grades = []
curr = 0
for i in range(n):
	grades.append(list(map(int, input().strip().split())))
	curr += grades[-1][0]
require = av * n
grades.sort(key=lambda x: x[1])
i = 0
ans = 0
while curr < require:
	if grades[i][0] < r:
		increment = min(require - curr, r - grades[i][0])
		ans += grades[i][1] * increment
		curr += increment
	i += 1
print(ans)
if FILE_POINTER:
	FILE_POINTER.close()


(n, r, a) = map(int, input().split())
l = [[*map(int, input().split())] for i in range(n)]
sum = 0
w = 0
z = 0
for i in range(n):
	sum += l[i][0]
	(l[i][0], l[i][1]) = (l[i][1], l[i][0])
l.sort()
if sum >= a * n:
	print(0)
else:
	i = 0
	k = a * n - sum
	while k > 0:
		if l[i][1] < r:
			z = min(k, r - l[i][1])
			w += l[i][0] * z
			k -= z
		i += 1
	print(w)


(n, r, avg) = map(int, input().split())
a = []
b = []
c = []
for i in range(n):
	(num1, num2) = map(int, input().split())
	a.append(num1)
	b.append(num2)
	c.append((num1, num2))
want = avg * n
have = sum(a)
diff = want - have
left = diff
cnt = 0
if diff <= 0:
	print(0)
else:
	c.sort(key=lambda x: x[1])
	for i in c:
		diff = r - i[0]
		if left > diff:
			cnt += diff * i[1]
			left -= diff
		else:
			cnt += left * i[1]
			left = 0
	print(cnt)


(n, r, avg) = map(int, input().split())
s = 0
t = n * avg
l = []
for i in range(n):
	(x, y) = map(int, input().split())
	s += x
	l.append([x, y])
l.sort(key=lambda x: x[1])
ans = 0
i = 0
while t > s:
	p = min(t - s, r - l[i][0])
	ans += p * l[i][1]
	s += p
	i += 1
print(ans)


(n, r, avg) = [int(x) for x in input().split()]
l = []
for i in range(n):
	l.append([int(x) for x in input().split()][::-1])
l.sort()
need = avg * n
have = sum((x[1] for x in l))
ans = 0
for (a, b) in l:
	ans += max(min(need - have, r - b), 0) * a
	have += max(min(need - have, r - b), 0)
print(ans)


array = list(map(int, input().rstrip().split()))
n = array[0]
r = array[1]
avg = array[2]
minmmarks = n * avg
marks = 0
List = []
for i in range(n):
	ab = list(map(int, input().rstrip().split()))
	marks += ab[0]
	ab.reverse()
	List += [ab]
if marks >= minmmarks:
	print(0)
else:
	required = minmmarks - marks
	List.sort()
	essay = 0
	for i in range(n):
		if r - List[i][1] >= required:
			essay += required * List[i][0]
			print(essay)
			break
		else:
			essay += (r - List[i][1]) * List[i][0]
			required -= r - List[i][1]


import operator
inStr = input()
n = int(inStr.split()[0])
r = int(inStr.split()[1])
avg = int(inStr.split()[2])
gePairs = []
curSum = 0
sumRequ = n * avg
for i in range(n):
	inStr = input()
	a = int(inStr.split()[0])
	curSum = curSum + a
	b = int(inStr.split()[1])
	gePairs.append((a, b))
sortedGEPairs = sorted(gePairs, key=operator.itemgetter(1))
nOfEssays = 0
for gePair in sortedGEPairs:
	if curSum >= sumRequ:
		break
	gr = gePair[0]
	eRequ = gePair[1]
	grIncRequ = min(sumRequ - curSum, r - gr)
	nOfEssays = nOfEssays + eRequ * grIncRequ
	curSum = curSum + grIncRequ
print(nOfEssays)


read = lambda : map(int, input().split())
(n, r, avg) = read()
p = [tuple(read()) for i in range(n)]
p.sort(key=lambda x: x[1])
avg *= n
cur = sum((a for (a, b) in p))
ans = 0
for (a, b) in p:
	if cur >= avg:
		break
	if avg - cur < r - a:
		ans += (avg - cur) * b
		cur = avg
	else:
		ans += (r - a) * b
		cur += r - a
print(ans)


s = input()
(n, r, gpa) = s.split()
n = int(n)
r = int(r)
gpa = int(gpa)
z = []
sum0 = 0
avg = 0.0
for x in range(0, n):
	a = list(map(int, input().split()))
	z.append(a)
	sum0 += z[x][0]
r0 = gpa * n
flag = False
if sum0 >= r0:
	print(0)
else:
	ans = 0
	z.sort(key=lambda y: y[1])
	i = 0
	while sum0 < r0:
		tmp = min(r - z[i][0], r0 - sum0)
		sum0 += tmp
		ans += tmp * z[i][1]
		i += 1
	print(ans)


line = input().split(' ')
n = int(line[0])
r = int(line[1])
avg = int(line[2])

class Exam:

	def __init__(self, a, b):
		self.a = a
		self.b = b

	def __repr__(self):
		return repr((self.a, self.b))
i = 0
s = 0
lst = []
while i < n:
	line = input().split(' ')
	a = int(line[0])
	b = int(line[1])
	lst.append(Exam(a, b))
	s += a
	i += 1
lst.sort(key=lambda exam: exam.b)
ans = 0
avg *= n
for exam in lst:
	if s >= avg:
		break
	ans += min(r - exam.a, avg - s) * exam.b
	s += min(r - exam.a, avg - s)
print(ans)


import sys
input = sys.stdin.readline
(n, r, avg) = map(int, input().split())
d = []
s = 0
f = avg * n
for i in range(n):
	(a, b) = map(int, input().split())
	d.append([b, a])
	s += a
ans = 0
if s < f:
	d.sort()
	t = f - s
	while t:
		for i in d:
			k = min(r - i[1], t)
			ans += k * i[0]
			s += k
			t = f - s
print(ans)


inp = [int(x) for x in input().split()]
n = inp[0]
r = inp[1]
avg = inp[2]
exams = [[int(x) for x in input().split()] for x in range(n)]
exams.sort(key=lambda x: x[1])
examsSum = 0
for x in exams:
	examsSum += x[0]
missingPoints = avg * n - examsSum
assigments = 0
i = 0
while missingPoints > 0:
	if r == exams[i][0]:
		i += 1
		continue
	availablePoints = r - exams[i][0]
	points = availablePoints if availablePoints <= missingPoints else missingPoints
	assigments += points * exams[i][1]
	missingPoints -= points
	i += 1
print(assigments)


(n, r, avg) = map(int, input().split())
arr = [tuple(map(int, input().split())) for _ in range(n)]
arr.sort(key=lambda x: x[1])
diff = n * avg - sum([x[0] for x in arr])
c = 0
if diff > 0:
	for i in range(n):
		x = min(diff, r - arr[i][0])
		c += x * arr[i][1]
		diff -= x
		if diff == 0:
			break
print(c)


(n, r, avg) = map(int, input().split())
t = n * avg
e = []
for i in range(n):
	(a, b) = map(int, input().split())
	t -= a
	if a != r:
		e.append((a, b))
e.sort(key=lambda x: x[1])
s = 0
for (a, b) in e:
	if t <= 0:
		break
	c = min(t, r - a)
	t -= c
	s += c * b
print(s)


(n, r, avg) = map(int, input().split())
A = []
curr_sum = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	A.append((a, b))
	curr_sum += a
needed_points = avg * n - curr_sum
if needed_points <= 0:
	print(0)
else:
	A.sort(key=lambda t: t[1])
	ans = 0
	for i in range(n):
		(a, b) = A[i]
		d = r - a
		if d > 0:
			if needed_points >= d:
				needed_points -= d
				ans += d * b
			else:
				ans += needed_points * b
				needed_points = 0
			if needed_points == 0:
				break
	print(ans)


ab = []
total_a = 0
points = 0
(n, r, avg) = [int(_) for _ in input().split()]
for _ in range(n):
	(a, b) = [int(_) for _ in input().split()]
	ab.append((a, b))
	total_a = total_a + a
avg_a = total_a // n
if avg <= avg_a:
	print(0)
	exit(0)
else:
	points = avg * n - total_a
ab = sorted(ab, key=lambda x: x[1])
ans = 0
for (index, elem) in enumerate(ab):
	to_r = r - elem[0]
	ans = ans + min(points, to_r) * elem[1]
	points -= to_r
	if points <= 0:
		break
print(ans)


(n, r, avg) = map(int, input().split())
arr = []
for i in range(n):
	(x, y) = map(int, input().split())
	arr.append([y, x])
s = 0
for i in range(n):
	s += arr[i][1]
if s >= avg * n:
	print(0)
else:
	arr.sort()
	ans = 0
	i = 0
	while s < avg * n:
		t = min(avg * n - s, r - arr[i][1])
		ans += t * arr[i][0]
		s += t
		i += 1
	print(ans)


inp = input().split()
n = int(inp[0])
r = int(inp[1])
avg = int(inp[2])
arr = []
for i in range(0, n):
	inp = input().split()
	ai = int(inp[0])
	bi = int(inp[1])
	arr.append((bi, ai))
arr = sorted(arr)
total = 0
for i in range(0, n):
	total += arr[i][1]
curavg = total / n
if curavg >= avg:
	print(0)
else:
	req = avg * n
	cnt = 0
	i = 0
	while True:
		if total >= req or i >= n:
			break
		if arr[i][1] < r:
			if r - arr[i][1] + total <= req:
				cnt += (r - arr[i][1]) * arr[i][0]
				total += r - arr[i][1]
			else:
				cnt += (req - total) * arr[i][0]
				total += req - total
		i += 1
	print(cnt)


(n, r, avg) = map(int, input().split())
arr = []
ss = 0
temp = []
for i in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])
	ss += a
	if a < r:
		temp.append([a, b])
aa = avg * n - ss
temp = sorted(temp, key=lambda item: item[1])
ans = 0
for i in range(len(temp)):
	if aa <= 0:
		break
	tt = min(r - temp[i][0], aa)
	ans += tt * temp[i][1]
	aa -= tt
	if aa <= 0:
		break
print(ans)


from functools import cmp_to_key
(n, r, avg) = map(int, input().split())
arr = []
for _ in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])

def cmp(sublist1, sublist2):
	if sublist1[1] > sublist2[1]:
		return 1
	elif sublist1[1] < sublist2[1]:
		return -1
	else:
		return 0
arr.sort(key=cmp_to_key(cmp))
current_sum = 0
for i in range(len(arr)):
	current_sum += arr[i][0]
more_needed = avg * n - current_sum
if current_sum / n >= avg:
	print(0)
else:
	s = 0
	for i in range(len(arr)):
		if arr[i][0] < r:
			possible = r - arr[i][0]
			if possible >= more_needed:
				s += more_needed * arr[i][1]
				more_needed = 0
				break
			else:
				s += possible * arr[i][1]
				more_needed -= possible
	print(s)


import sys
import math
(n, r, avg) = map(int, sys.stdin.readline().strip().split(' '))
arr = []
total = 0
for n0 in range(n):
	(ai, bi) = map(int, sys.stdin.readline().strip().split(' '))
	total += ai
	arr.append((bi, ai))
arr = sorted(arr)
lacking = avg * n - total
idx = 0
ans = 0
while lacking > 0:
	(bi, ai) = arr[idx]
	x = min(lacking, r - ai)
	lacking -= x
	ans += bi * x
	idx += 1
print(ans)


(n, r, avg) = map(int, input().split())
goal = n * avg
essay = 0
V = []
for i in range(n):
	(a, b) = map(int, input().split())
	goal -= a
	V.append([b, a])
V.sort()
goal = [0, goal][goal > 0]
for j in V:
	if not goal:
		break
	else:
		m = min(r - j[1], goal)
		essay += j[0] * m
		goal -= m
print(essay)


import random, math
from copy import deepcopy as dc

def input_test():
	(n, r, avg) = map(int, input().strip().split(' '))
	a = []
	b = []
	for i in range(n):
		(k, l) = map(int, input().strip().split(' '))
		a.append(k)
		b.append([l, k])
	b.sort(key=lambda x: x[0])
	cur_sum = sum(a)
	if cur_sum / n > avg:
		print(0)
		return
	else:
		s = 0
		needed = avg * n - cur_sum
		for i in b:
			if i[1] < r:
				make = r - i[1]
				if make >= needed:
					s += needed * i[0]
					needed = 0
					break
				else:
					s += make * i[0]
					needed -= make
		print(s)
input_test()