Language: C++

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define MOD 1000000007

using lli = long long int;
using ulli = unsigned long long int;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

ulli S, ans = 99999999999, h;
lli H, W;

int main(){
	cin >>H >>W;
	if(H%3 == 0 || W%3 == 0){
		ans = 0;
	}else{
		for(int l = 1; l < H-1; l++){
			S = abs(l*W - ((H-l)/2)*W;
			if(ans > S) ans = S;
			S = abs(l*W - ((H-l)/2+1)*W;
			if(ans > S) ans = S;
			S = abs(l*W - (H-l)*(W/2);
			if(ans > S) ans = S;
		}
		for(int l = 1; l < W-1; l++){
			S = abs(l*H - ((W-l)/2)*H;
			if(ans > S) ans = S;
			S = abs(l*H - ((W-l)/2+1)*H;
			if(ans > S) ans = S;
			S = abs(l*H - (W-l)*(H/2);
			if(ans > S) ans = S;
		}
		/*
		ans = min(H, W);
		if(H%2 == 0){
			if(W%2 == 0){
				S[0] = H*(W/2) - (H/2)*(W/2);
				S[1] = W*(H/2) - (H/2)*(W/2);
				if(ans > S[0]) ans = S[0];
				dbug(S[0]);
				if(ans > S[1]) ans = S[1];
				dbug(S[1]);
			}else{
				S[0] = H*(W/2) - (H/2)*(W/2+1);
				S[1] = H*(W/2+1) - (H/2)*(W/2);
				S[2] = W*(H/2) - (H/2)*(W/2);
				if(ans > S[0]) ans = S[0];
				dbug(S[0]);
				if(ans > S[1]) ans = S[1];
				dbug(S[1]);
				if(ans > S[2]) ans = S[2];
				dbug(S[2]);
			}
		}else if(H%2 == 1){
			if(W%2 == 0){
				S[0] = H*(W/2) - (H/2)*(W/2);
				S[1] = W*(H/2+1) - (H/2)*(W/2);
				S[2] = W*(H/2) - (H/2+1)*(W/2);
				if(ans > S[0]) ans = S[0];
				dbug(S[0]);
				if(ans > S[1]) ans = S[1];
				dbug(S[1]);
				if(ans > S[2]) ans = S[2];
				dbug(S[2]);
			}else{
				S[0] = H*(W/2) - (H/2)*(W/2+1);
				S[1] = H*(W/2+1) - (H/2)*(W/2);
				S[2] = W*(H/2+1) - (H/2)*(W/2);
				S[3] = W*(H/2) - (H/2+1)*(W/2);
				if(ans > S[0]) ans = S[0];
				dbug(S[0]);
				if(ans > S[1]) ans = S[1];
				dbug(S[1]);
				if(ans > S[2]) ans = S[2];
				dbug(S[2]);
				if(ans > S[3]) ans = S[3];
				dbug(S[3]);
			}
		}
		dbugln;
		S[0] = H;
		S[1] = W;
		if(ans > S[0]) ans = S[0];
		dbug(S[0]);
		if(ans > S[1]) ans = S[1];
		dbug(S[1]);
		*/
	}
	
	cout << ans;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:50: error: expected ')' before ';' token
   33 |                         S = abs(l*W - ((H-l)/2)*W;
      |                                ~                 ^
      |                                                  )
a.cc:35:52: error: expected ')' before ';' token
   35 |                         S = abs(l*W - ((H-l)/2+1)*W;
      |                                ~                   ^
      |                                                    )
a.cc:37:50: error: expected ')' before ';' token
   37 |                         S = abs(l*W - (H-l)*(W/2);
      |                                ~                 ^
      |                                                  )
a.cc:41:50: error: expected ')' before ';' token
   41 |                         S = abs(l*H - ((W-l)/2)*H;
      |                                ~                 ^
      |                                                  )
a.cc:43:52: error: expected ')' before ';' token
   43 |                         S = abs(l*H - ((W-l)/2+1)*H;
      |                                ~                   ^
      |                                                    )
a.cc:45:50: error: expected ')' before ';' token
   45 |                         S = abs(l*H - (W-l)*(H/2);
      |                                ~                 ^
      |                                                  )