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
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//Aleksander Łukasiewicz
#include<bits/stdc++.h>
using namespace std;

#define fru(j,n) for(int j=0; j<(n); ++j)
#define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ALL(G) (G).begin(),(G).end()

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;
const int MAXN = 1000*1000;

int X, Y, K;
vector<PII> triplets;
// vector<PII> S;
// 
// // int cnt[7000][7000];

bool cmp(PII A, PII B){
    return A.x*B.y < A.y*B.x;
}

vector<PII> GetTriplets(){
    vector<PII> ret;
    ret.pb(mp(0, 1));
    for(int i=2; i*i <= K; i++){
        for(int j=1; j<i && i*i + j*j <= K; j++){
            if((i+j)%2 == 1 && __gcd(i, j) == 1){
                int A = i*i - j*j;
                int B = 2*i*j;
                
                ret.pb(mp(A, B));
                ret.pb(mp(B, A));
            }
        }
    }
    
    sort(ret.begin(), ret.end(), cmp);
    
    vector<PII> last = ret;
    
    for(int i=0; i<3; i++){
        for(auto &v : last){
            v = mp(v.y, -v.x);
            ret.pb(v);
        }
    }
    
//     printf("size: %d\n", ret.size());
//     for(auto v : ret){
//         printf("%d %d\n", v.x, v.y);
//     }
    return ret;
}


int main(){
    scanf("%d %d %d", &X, &Y, &K);
    X--;
    Y--;
    triplets = GetTriplets();
/*    
    S.pb(mp(0,0));
    cnt[0][0] = 1;
    for(auto T : triplets){
        printf("%d %d\n", T.x, T.y);
        vector<PII> V;
        for(auto s : S){
            PII v = mp(s.x + T.x, s.y + T.y);
            if(cnt[v.x][v.y] == 0)
                V.pb(v);
            cnt[v.x][v.y]++;
        }
        for(auto v : V){
            S.pb(v);
        }
        //printf("%d\n", S.size());
    }
    
    int M = 0;
    int c = 0;
    for(int i=0; i<X; i++)
        for(int j=0; j<Y; j++){
            M = max(M, cnt[i][j]);
            c += cnt[i][j] >= 1;
        }
    printf("%d %d\n", M, c);*/

    unsigned int ans = 0;
    int n = (int)triplets.size();
    for(int mask = 0; mask < (1<<n); mask++){
        if(__builtin_popcount(mask) < 3) continue;
        int minX = 0, maxX = 0, minY = 0, maxY = 0;
        PII curr = mp(0, 0);
        for(int i=0; i<n; i++){
            if(((1<<i) & mask)){
                curr = mp(curr.x + triplets[i].x, curr.y + triplets[i].y);
                if(curr.x > X || curr.y > Y) break;
                minX = min(minX, curr.x);
                maxX = max(maxX, curr.x);
                minY = min(minY, curr.y);
                maxY = max(maxY, curr.y);
            }
        }
        
        if(curr.x == 0 && curr.y == 0){
            int A = maxX - minX;
            int B = maxY - minY;
            
            if(A <= X && B <= Y){
//                 puts("rozw");
//                 for(int i=0; i<n; i++){
//                     if(((1<<i) & mask)){
//                         printf("%d %d\n", triplets[i].x, triplets[i].y); 
//                     }
//                 }
//                 printf("%u\n", (unsigned int)(X-A+1)*(unsigned int)(Y-B+1));
                
                ans += (unsigned int)(X-A+1)*(unsigned int)(Y-B+1);
            }
        }
    }
    
    printf("%u\n", ans);
    
return 0;
}