Example

Input

2 2 2 1
0 0 0


Output

24
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
struct cube{
    int x,y,z;
    bool operator<(const cube& right)const{
        if(x!=right.x) return x<right.x;
        if(y!=right.y) return y<right.y;
        return z<right.z;
    }
};
ll A,B,C;
int N;
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(){
    cin >> A >> B >> C >> N;
    vector<cube> v(N);
    int x,y,z;
    ll ans = 2*(A*B+B*C+C*A);
    set<cube> s;
    for(int i=0;i<N;i++){
        cin >> x >> y >> z;
        for(int k=0;k<6;k++){
            int nx = x+dx[k],ny = y+dy[k],nz = z+dz[k];
            if(nx==-1 || nx==A) ans -= 2;
            if(ny==-1 || ny==B) ans -= 2;
            if(nz==-1 || nz==C) ans -= 2; 
        }
        v[i] = {x,y,z};
        s.insert(v[i]);
    }
    for(int i=0;i<N;i++){
        for(int k=0;k<6;k++){
            int nx = v[i].x+dx[k],ny = v[i].y+dy[k],nz = v[i].z+dz[k];
            cube c = {nx,ny,nz};
            if(s.count(c)==0) ans++;
        }
    }
    cout << ans << endl;
}
