#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b>n>>d; vector x(10000000,0),y(10000000,0); for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;j++){ x[i*i+j*j]++; if(d+i*i-j*j>=0) y[d+i*i-j*j]++; } } ll ans=0; rep(i,10000000) ans+=x[i]*y[i]; cout<