func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, m, l, r, p, span, t, lwr, upr;   long pr[200000];   vector<long> vec[200000];   long calc[200000];   long long res, nmoves[200000];   long long check[200000];   long long temp;   long long answ;   long long gcd(long long a, long long b) {     while (a && b) a > b ? a %= b : b %= a;     return a + b;   }   long long solve1(long long x, long long lim) {     long long res = 0;     for (int mask = 0; mask < (1 << (vec[x].size())); mask++) {       temp = 1;       for (int j = 0; j < vec[x].size(); j++)         if (mask & (1 << j)) temp *= vec[x][j];       if (calc[mask] % 2)         res -= lim / temp;       else         res += lim / temp;     }     return res;   }   long long solve(long long x, long long lim) {     long long res = 0;     long long ts = 0;     long long q, qsum;     for (int mask = 0; mask < (1 << (vec[x].size())); mask++) {       temp = 1;       for (int j = 0; j < vec[x].size(); j++)         if (mask & (1 << j)) temp *= vec[x][j];       q = lim / temp;       qsum = q * (q + 1) / 2;       qsum *= temp;       if (calc[mask] % 2)         res -= qsum;       else         res += qsum;     }     return res;   }   long long gett(long long g, long long x, long long lim) {     if (lim <= 0) return 0;     long long tsum = (g + 1) * solve1(x, lim);     tsum -= solve(x, lim);     return tsum;   }   int main() {     ios_base::sync_with_stdio(0);     pr[1] = 1;     for (int i = 2; i <= 100000; i++)       if (pr[i] == 0)         for (int j = i * 2; j <= 100000; j += i) {           pr[j] = 1;           vec[j].push_back(i);         }     for (int i = 2; i <= 100000; i++)       if (pr[i] == 0) vec[i].push_back(i);     calc[0] = 0;     for (int i = 1; i <= (1 << 15); i++) {       t = i;       for (int j = 0; j < 15; j++)         if (t & (1 << j)) ++calc[i];     }     long long a, b;     cin >> n >> m;     cin >> l >> r >> p;     l *= l;     r *= r;     for (long long span = 2; span <= 100000 && span <= n; span++) {       if (span * span > r) continue;       t = l - span * span;       if (t <= 0)         lwr = 0;       else         lwr = sqrt(t - 0.5) + 1;       t = r - span * span;       upr = sqrt(t + 0.5);       if (upr >= span) upr = span - 1;       if (upr > m) upr = m;       if (upr < lwr) continue;       res = (gett(m, span, upr) - gett(m, span, lwr - 1)) * (n - span + 1) * 2;       answ = answ + res;       answ %= p;     }     swap(n, m);     for (long long span = 2; span <= 100000 && span <= n; span++) {       if (span * span > r) continue;       t = l - span * span;       if (t <= 0)         lwr = 0;       else         lwr = sqrt(t - 0.5) + 1;       t = r - span * span;       upr = sqrt(t + 0.5);       if (upr >= span) upr = span - 1;       if (upr > m) upr = m;       if (upr < lwr) continue;       res = (gett(m, span, upr) - gett(m, span, lwr - 1)) * (n - span + 1) * 2;       answ = answ + res;       answ %= p;     }     if (1 >= l && 1 <= r) answ += n * (m + 1), answ += m * (n + 1);     if (2 >= l && 2 <= r) answ += 2 * n * m;     cout << answ % p << endl;     cin.get();     cin.get();     return 0;   }   