#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N; Eratosthenes(); ll limit = min(N+1, (ll)sqrt(500000)+100); ll count = 0; FOR(r, 2, limit){ if(!is_prime[r]) continue; FOR(p, 2, N+1){ if(!is_prime[p]) continue; ll q = r*r - p; if(q<=1) continue; if(q>N) continue; if(is_prime[q]){ // cout << "pqr " << p << ' ' << q << ' ' << r << endl; count++; } } } p(count); return 0; }