Example

Input

2 2 2 1
0 0 0


Output

24
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

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

int X[1010], Y[1010], Z[1010], P[1010];
int main() {
    long long int A, B, C, N; scanf("%lld%lld%lld%lld", &A, &B, &C, &N);

    long long int ans = 2 * (A*B + B*C + C*A);
    map< vector<int>, int > mp;
    for(int i=0; i<N; i++) {
        vector<int> v(3);
        scanf("%d%d%d", &v[0], &v[1], &v[2]);
        mp[v]++;
        for(int k=0; k<6; k++) {
            int nx = v[0] + dx[k], ny = v[1] + dy[k], nz = v[2] + dz[k];
            vector<int> nxt{nx, ny, nz};
            if(nx < 0 || nx >= A || ny < 0 || ny >= B || nz < 0 || nz >= C || mp.count(nxt)) {
                ans--;
            }
            else {
                ans++;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}
