#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; vll pl(10000000, 0); vll mi(10000000, 0); for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;j++){ ll x = i*i+j*j; pl[x]++; ll y = i*i-j*j+d; mi[y]++; } } ll ans = 0; for(int i=0;i<10000000;i++) ans += pl[i] * mi[i]; std::cout << ans << '\n'; }