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

constexpr double EPS = 1e-6;

int n;
int output;
std::map<int, int> tanks;

int main() {
    std::cin >> n;

    for (int a = 1; a <= n; ++a) {
        for (int b = a; b <= n; ++b) {
            ++tanks[a * a + b * b];
        }
    }

    for (int h = 1; h <= n; ++h) {
        for (int d = h + 1; d <= n; ++d) {
            int x = d * d - h * h;
            if (tanks.find(x) != tanks.end()) {
                output += tanks[x];
            }
        }
    }

    std::cout << output;
}