Example

Input

2 2 2 1
0 0 0


Output

24
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <tuple>

using namespace std;

using lint = long long;
using ldouble = long double;

const int dx[6] = {-1, 1, 0, 0, 0, 0},
          dy[6] = {0, 0, -1, 1, 0, 0},
          dz[6] = {0, 0, 0, 0, -1, 1};

int main() {
    lint A, B, C;
    int N;
    cin >> A >> B >> C >> N;

    lint S = (A * B + B * C + C * A) * 2;

    set<tuple<int, int, int>> emp;
    for (int i = 0; i < N; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        emp.emplace(x, y, z);
    }

    for (auto t : emp) {
        int x, y, z;
        tie(x, y, z) = t;

        S -= (x == 0) + (x == A - 1) +
             (y == 0) + (y == B - 1) +
             (z == 0) + (z == C - 1);

        for (int i = 0; i < 6; ++i) {
            int nx = x + dx[i], ny = y + dy[i], nz = z + dz[i];
            if (nx < 0 || A <= nx || ny < 0 || B <= ny || nz < 0 || C <= nz) continue;

            if (!emp.count(make_tuple(nx, ny, nz))) ++S;
        }
    }

    cout << S << endl;
    return 0;
}

