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
#include<bits/stdc++.h>

int isGood(int x){
	return int(sqrt(x)) * int(sqrt(x)) == x;
}

const int N = 5000 * 5000 * 10;
int Z[N];

int main(){
	using namespace std;
	ios::sync_with_stdio(false), cin.tie(nullptr);
	
	for(int b = 1;b <= 5000;b++)
		for(int h = b;h <= 5000;h++)
			Z[b * b + h * h] += 1;
	
	int n;
	cin >> n;
	
	long long ans = 0;
	for(int x = 2;x <= n;x++){
		// szukasz (a, b, h): a^2 + b^2 + h^2 = x^2
		// go over a i pózniej zapamiętaj gdzieś indziej (b, h)	
		for(int a = 1;a <= x;a++){
			int z = x * x - a * a;
			// b = a?
			// kombinacji b^2 + h^2 = z
			ans += Z[z];
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}