#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll N = 1000000;
const ll M = N * N;
ll k;
int n;
vector<pll> a;
int main() {
cin >> n >> k;
for (int i = 0; i < n; i++) {
ll x, y;
scanf("%lld%lld", &x, &y);
if (x <= N && x * x <= k) {
a.emplace_back(y, x);
}
}
sort(a.begin(), a.end());
ll old = 0;
ll answer = 0;
set<ll> subs;
vector<ll> temp;
for (pll p : a) {
ll y = p.second;
ll x = y * y;
ll current = old;
if (x <= k) {
temp.push_back(x);
current += k / x;
}
for (ll z : subs) {
if (abs(z * y) <= k && abs(z * x) <= k) {
temp.push_back(-z * x);
current += k / (-z * x);
} else {
break;
}
}
for (ll z : temp) {
subs.insert(z);
}
temp.clear();
ll now = current - old;
answer += now * p.first;
old = current;
}
cout << answer << endl;
}
Copy