#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define debug(x) cerr << #x << ": " << x << endl using namespace std; typedef long long ll; typedef pair Pll; typedef pair Pii; const ll MOD = 1000000007; const long double EPS = 1e-10; const int dyx[4][2] = { { 0, 1}, {-1, 0}, {0,-1}, {1, 0} }; int main() { ll n, d; cin >> n >> d; map cnt1, cnt2; for(int i=1;i<=n;++i) { for(int j=1;j<=n;++j) { ++cnt1[i*i+j*j]; ++cnt2[i*i-j*j]; } } ll ans = 0LL; for(auto itr=cnt1.begin();itr!=cnt1.end();++itr) { ans += ((itr->second) * cnt2[d-(itr->first)]) % MOD; ans %= MOD; // cerr << i << ": " << cnt1[i] << " " << d-i << ": " << cnt2[d-i+n*n] << endl; } cout << ans << endl; }