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
37
38
39
40
41
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int visited[5003];
int sumy[50000009];
int main()
{
    int z ;
    cin >> z;
    int n = z;
    int suma = 0;
    ll odp=0;
    int gg = 0;
    for(int a = 1 ; a<=n ; ++a)
        for(int b = a ; b<=n ; ++b)
            {//cout << a << " "<<b<<endl;
                ++sumy[(a*a)+(b*b)];}
    /*for( int i = 1 ; i<=100;++i)
        cout<<" i " << i<< " " <<sumy[i]<<"\n";*/
for(int h = 1; h<=z;++h)
    for(int N= h;N<=z;++N)
            {
            odp+=sumy[(N*N)-(h*h)];
            }
    /*for(int n = 3 ; n<=z;++n)
        for(int a = 1 ; a<=z;++a)
            for(int b = a ; b<=z ; ++b)
                {
                    suma = (n*n)-(a*a)-(b*b);
                    if(suma<=0)
                        break;
                    else
                    gg = sqrt(suma);
                    if(suma==gg*gg)
                    {//cout << suma << " ";
                        ++odp;}
                }*/
    cout << odp;
    return 0 ;
}