#include #define int long long using namespace std; int p, q; map dp; int calc(int n){ if(dp.count(n)) return dp[n]; int q = p / n; int x = p / (q + 1) + 1; return dp[n] = (p % n + p % x) * (n - x + 1) / 2 + calc(x - 1); } signed main(){ cin >> p >> q; dp[0] = 0; for(int i = 0; i < q; i++){ int l, r; cin >> l >> r; cout << calc(r) - calc(l - 1) << endl; } }