#include <iostream> #include <vector> #include <algorithm> using namespace std; bool compare(const vector<int> a, const vector<int> b) { return a[1] < b[1]; } int main() { long long n, r, avg; while(cin >> n && cin >> r && cin >> avg) { vector<vector<int>> ab(n,vector<int>(2)); //cout << "n= " << n << " r= " << r << " avg= " << avg << endl; long long sum = 0; for(int i = 0; i < n; i++) { cin >> ab[i][0] >> ab[i][1]; sum += ab[i][0]; } long long target = avg * n; if(target <= sum || avg > r) { cout << 0 << endl; continue; } target -= sum; sort(ab.begin(),ab.end(),compare); long long time = 0, curr = 0; while(target > 0) { int max_n = min(target,r-ab[curr][0]); time += max_n * ab[curr][1]; curr ++; if(curr >= n) break; target -= max_n; } cout <<time<<endl; } return 0; }