#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c> n >> d; map pl; map mi; for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;j++){ ll x = i*i+j*j; auto itr = pl.find(x); if(itr==pl.end()) pl.emplace(x, 1); else (*itr).second++; ll y = i*i-j*j+d; itr = mi.find(y); if(itr==mi.end()) mi.emplace(y, 1); else (*itr).second++; } } ll ans = 0; for(auto p:pl){ auto itr = mi.find(p.first); if(itr==mi.end()) continue; ans += p.second * (*itr).second; } std::cout << ans << '\n'; }