#include using namespace std; #define rep(i,n) for (int i = 0; i < (int)(n); ++i) #define rrep(i,n) for (int i = (int)(n-1); i >= 0; --i) #define Rep(i,a,b) for (int i = a; i < b; ++i) #define rRep(i,a,b) for (int i = a; i > b; --i) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define Bit(x,i) (((x)>>(i))&1) using ll = long long; using vi = vector; using vll = vector; using vvi = vector; using vvll = vector; using vb = vector; using vs = vector; using pii = pair; using pll = pair; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N >> D; Rep(i, 1, N+1) { Rep(j, 1, N+1) { A.push_back(i*i + j*j); B.push_back(i*i - j*j); } } sort(all(B)); ll ans = 0; fore(a, A) { // a + b = D auto itr1 = lower_bound(all(B), D-a); auto itr2 = lower_bound(all(B), D-a+1); ans += (itr2 - itr1); } cout << ans << endl; }