1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <bits/stdc++.h>
using namespace std;
int main()
{
	vector<long long int>t(50000007);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
		for(int j=i; j<=n; j++)
			t[i*i+j*j]++;
	long long int res=0;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=n; j++)
			if(i*i-j*j>=0)
				res+=t[i*i-j*j];
	cout<<res<<"\n";
}