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

#define int long long

main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    int res = 0;
    vector<int> sqares(n*n+1);
    for(int i=1; i<=n; i++){
        sqares[i*i] =1;
    }
    for(int h=1; h<n; h++){
        for(int a = 1; a<n; a++){
            for(int b = a; b<n; b++){
                if(h*h + a*a + b*b <= n*n && sqares[h*h + a*a + b*b] ){ 
                    res++;
                }
            }
        }
    }
    cout<<res;
}