#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; vector cnt1(2*n*n+1, 0), cnt2(2*n*n+1, 0); for(int i=1;i<=n;++i) { for(int j=1;j<=n;++j) { ++cnt1[i*i+j*j]; ++cnt2[i*i-j*j+n*n]; } } ll ans = 0LL; for(int i=1;i<=2*n*n&&d-i+n*n>=0;++i) { ans += (cnt1[i] * cnt2[d-i+n*n]) % MOD; ans %= MOD; // cerr << i << ": " << cnt1[i] << " " << d-i << ": " << cnt2[d-i+n*n] << endl; } cout << ans << endl; }