constexprint N = 50005; int mu[N], pri[N], f[N], cnt; bool st[N];
voidinit(){ mu[1] = 1; F(i, 2, N) { if(!st[i]) pri[++ cnt] = i, mu[i] = -1; for(int j = 1; j <= cnt && i * pri[j] < N; ++j) { st[i * pri[j]] = 1; if(i % pri[j] == 0) { mu[i * pri[j]] = 0; break; } mu[i * pri[j]] = -mu[i]; } } F(i, 1, N) mu[i] += mu[i - 1]; F(i, 1, N) { for(int l = 1, r; l <= i; l = r + 1) { r = i / (i / l); f[i] += 1ll * (r - l + 1) * (i / l); } } }
voidsolve(){ int n, m; cin >> n >> m; if(n > m) swap(n, m); ll ans = 0; for(int l = 1, r; l <= n; l = r + 1){ r = min(n / (n / l), m /(m / l)); ans += 1ll * (mu[r] - mu[l - 1]) * f[n / l] * f[m / l]; } cout << ans <<endl; }