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 <cstdint>
#include <iostream>
#include <set>
#include <math.h>
#include <stdint.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    int ret = 0;
    int upper_bound;
    for (int i = 1; i <= n; i++) {
        for (int h = 1; h <= i; h++) {
            upper_bound = sqrt((i*i - h*h + 1)/2);
            for (int a = 1; a <= upper_bound; a++) {
                int b_square = i*i - a*a - h*h;
                float b = sqrt(b_square);
                if (b > 0 and b == floor(b)) {
                    ret += 1;
                }
            }
        }
    }
    cout << ret << endl;
    return 0;
}