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
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define BOOST ios_base::sync_with_stdio(0), cin.tie(0)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int N = 5e3, M = 5e7 + 5;

int ks[M];

int main(){
	BOOST;
	for(int i=1; i<=N; i++){
		for(int j=i; j<=N; j++){
			ks[i*i + j*j]++;
		}
	}
	ll ans = 0;
	int n; cin >> n;
	for(int i=1; i<=n; i++){ // przekątna
		for(int j=1; j<i; j++){ // wysokość
			ans += ks[i*i - j*j];
		}
	}
	cout << ans << "\n";
}