#include <iostream>
#include <algorithm>
#include <string.h>
#define IOS std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double lb;
const int E = 1e5+5;
ll c[E],p[E],S,n;
int main() {
IOS;
int T = 1;
//std::cin >> T;
while (T--) {
std::cin >> n >> S;
ll cnt = 0,mip = 0x3f3f3f3f;
for(int i = 1;i <= n;i++){
std::cin >> c[i] >> p[i];
cnt += c[i];
mip = std::min(mip,p[i]);
}
if(cnt <= S){
ll ans = 0;
for(int i = 1;i <= n;i++){
ans += c[i] * p[i];
}
std::cout << ans;
}
else {
ll ans = 0;
ans += S * mip;
for(int i = 1;i <= n;i++){
ans += (p[i] - mip) * c[i];
}
std::cout << ans;
}
}
return 0;
}
0 tps 求助