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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include <bits/stdc++.h>
using namespace std;

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
template<class T, class U>
ostream& operator<<(ostream& os, pair<T, U> p) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template<class C, class = typename C::value_type>
typename enable_if<!is_same<C, string>::value, ostream&>::type
operator<<(ostream& os, C c) {
    for (auto i = c.begin(); i != c.end(); i++) {
        os << " {"[i == c.begin()] << *i << ",}"[next(i) == c.end()];
    }
    return os;
}

#define debug(x) { cerr << #x << " = " << x << endl; }
#else
#define debug(...) {}
#endif


struct pkt {
    int x, y;
    pkt(int x_ = 0, int y_ = 0) : x(x_), y(y_) {}

    bool operator==(pkt p) {
        return x == p.x && y == p.y;
    }
    bool operator!=(pkt p) {
        return !(*this == p);
    }

    pkt operator-(pkt p) {
        return pkt(x - p.x, y - p.y);
    }
};

// ostream& operator<<(ostream& os, pkt p) {
//     return os << "<" << p.x << ", " << p.y  << ">";
// }

int sgn(int x) {
    if (x > 0) { return 1; }
    if (x < 0) { return -1; }
    return 0;
}

int cross(pkt v, pkt u) {
    return sgn(v.x * u.y - v.y * u.x);
}

bool left(pkt a, pkt b, pkt c) {
    pkt v1 = b - a;
    pkt v2 = c - b;
    return v1.x * v2.y - v1.y * v2.x > 0;
}

bool correct_sides(pkt a, pkt b, pkt c, pkt d) {
    pkt v = b - a;
    pkt u = d - c;
    return cross(v, c - a) * cross(v, d - a) > 0
        && cross(u, a - c) * cross(u, b - c) > 0;
}

vector<pkt> genSides() {
    vector<pkt> res = { pkt(0, 1), pkt(0, -1), pkt(1, 0), pkt(-1, 0) };
    
    vector<pkt> cand = { pkt(3, 4), pkt(5, 12) };
    vector<int> mulx = {-1, -1, 1, 1};
    vector<int> muly = {-1, 1, -1, 1};
    
    for (pkt c : cand) {
        for (int i = 0; i < 4; i++) {
                res.emplace_back(mulx[i] * c.x, muly[i] * c.y);
                res.emplace_back(muly[i] * c.y, mulx[i] * c.x);
        }
    }
    
    return res;
}

using uint = uint32_t;

uint X;
uint Y;
uint result = 0;
// int counter = 0;

void gen(vector<pkt> & poly) {
//    debug(poly);

    static vector<pkt> sides = genSides();
    //{ pkt(0, 1), pkt(0, -1), pkt(1, 0), pkt(-1, 0) }; 
        //pkt(3, 4), pkt(4, 3), pkt(5, 12), pkt(12, 5) };
//     static vector<int> mulx = {-1, -1, 1, 1};
//     static vector<int> muly = {-1, 1, -1, 1};
    
    if (poly.size() > 1 && poly.back() == poly[0]) {
        debug(poly);
//         cout << "Found: ";
//         for (pkt p : poly) {
//             cout << p << " ";
//         }
//         cout << "\n";
        int xmin, xmax, ymin, ymax;
        xmin = xmax = poly[0].x;
        ymin = ymax = poly[0].y;
        for (pkt p : poly) {
            xmin = min(xmin, p.x);
            xmax = max(xmax, p.x);
            ymin = min(ymin, p.y);
            ymax = max(ymax, p.y);
        }
        
        uint dx = xmax - xmin;
        uint dy = ymax - ymin;
        
        if (dx <= X - 1 && dy <= Y - 1) {
            result = result + (X - dx) * (Y - dy);
        }
//         counter++;

        return;
    }
    
    pkt last_pkt = poly.back();

    for (pkt side : sides) {
//         for (int mx : mulx) {
//             for (int my : muly) {
//                 int dx = mx * side.x;
//                 int dy = my * side.y;
                //cout << dx << " " << dy << "\n";

                pkt next_pkt(last_pkt.x + side.x, last_pkt.y + side.y);
//                 debug(next_pkt);
                
                if (next_pkt != poly[0]) {
                    bool ok = true;
                    for (pkt p : poly) {
                        if (p == next_pkt) {
//                             debug("repeat");

                            ok = false;
                            break;
                        }
                    }
                    
                    if (!ok) {
                        continue;
                    }

                    for (int i = 0; i < (int)poly.size() - 2; i++) {
                        if (!correct_sides(poly[i], poly[i + 1], last_pkt, next_pkt)) {
//                             debug("incorrect");
//                             debug(i);
                            ok = false;
                            break;
                        }
                    }

                    if (!ok) {
                        continue;
                    }
                }

                if ((next_pkt.x > 0
                     || (next_pkt.x == 0
                         && next_pkt.y >= 0))
                    && (poly.size() <= 1
                        || left(poly[poly.size() - 2], last_pkt, next_pkt))) {
                    
                    poly.push_back(next_pkt);
                    gen(poly);
                    poly.pop_back();
                }
//             }
//         }
    }
}



int main() {
    ios_base::sync_with_stdio(false);
    
    vector<pkt> poly = { pkt(0, 0) };
    int k;
    cin >> X >> Y >> k;
    gen(poly);
    cout << result << endl;
}