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
#include <cstdio>

#define REP(a, n) for (int a = 0; a<(n); ++a)
#define FOR(a, b, c) for (int a = (b); a<=(c); ++a)

typedef long long LL;

using namespace std;

//////////////

int N;

int t1[5000*5000], t2[5000*5000];

int main() {
    scanf("%d", &N);
    FOR(a, 1, 5000)
        FOR(b, a, 5000) {
            int z = a*a+b*b;
            if (z>=5000*5000)
                break;
            ++t1[z];
        }
    FOR(p, 1, N)
        FOR(c, 1, p)
            ++t2[p*p-c*c];
    LL w = 0;
    REP(a, 5000*5000)
        w += t1[a]*(LL)t2[a];
    printf("%lld\n", w);
}