1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
#define e using u=ostream;template<class a,class b>u&operator<<(u&o,pair<a,b>&x)
using namespace std;e;u&operator<<(u&o,string&s){return o<<s.c_str();}template<
class t>auto operator<<(u&o,t&x)->decltype(x.end(),o){o<<'{';int i=2;for(auto y:
x)o<<", "+i<<y,i=0;return o<<'}';}e{return o<<'('<<x.first<<", "<<x.second<<')';}
#ifdef DEBUG
#define LOG(x...)cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...)<<'\n';}(x)
#else
#define LOG(...)
#endif
#define ff first
#define ss second
#define ll long long

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	set <ll> squares;
	vector <int> suma(50000001);
	for (ll i = 1; i <= 5000; i++) {
		for (ll j = i; j <= 5000; j++) {
			suma[i*i+j*j]++;
		}
	}
	ll n;
	ll res = 0;
	cin >> n;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= 5000; j++) {
			if (i*i-j*j >= 0 && suma[i*i-j*j] != 0) {
//				cout << i << " " << j << " " << i*i-j*j << "\n";
				res += suma[i*i-j*j];
			}
		}
	}
	cout << res << "\n";
}