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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#define _CRT_SECURE_NO_WARNINGS                                                 
#include <iostream>                                                             
#include <algorithm>                                                            
#include <vector>                                                               
#include <cmath>                                                                
#include <map>                                                                  
#include <queue>                                                                
#include <set>                                                                  
#include <numeric>                                                              
#include <stack>                                                                
#include <iomanip>   
#include <unordered_map>
using namespace std;
using ll = long long int;
#define debug(x) cout << #x << " = " << x << endl;        

int kwadraty[5005];
void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        kwadraty[i] = i * i;
    }
    unordered_map<int, int>m;
    for (int a = 1; a <= n; a++)
    {
        for (int b = a; b <= n; b++)
        {
            if (kwadraty[a] + kwadraty[b] <= kwadraty[n])
                m[kwadraty[a] + kwadraty[b]]++;//mozliwe kwadraty podstaw
            else break;
        }
    }
    int odp = 0;
    for (int d = 1; d <= n; d++)
    {
        for (int h = 1; h <= d; h++)
        {

            odp += m[kwadraty[d] - kwadraty[h]];
        }
    }
    cout << odp << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    //int t;                                                                    
    //cin >> t;                                                                 
    //while (t--)                                                               
    //{                                                                         
    solve();
    //}                                                                         
    return 0;
}