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 <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
int n;
long long wyn;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    double chec;
    for(int d=3;d<=n;d++){
    	for(int h=1;h<=sqrt(d*d-2);h++){
    		for(int b=1;b<=sqrt(d*d-h*h-1);b++){
    			chec=sqrt(d*d-h*h-b*b);
    			if(floor(chec)==chec){
    				wyn+=1;
    				//cout<<chec<<" "<<b<<" "<<h<<" "<<d<<'\n';
    				if(chec==b){
    					wyn+=1;
					}
				}
			}
		}
	}
    cout<<wyn/2;
	return 0;
}