Language: C++

using namespace std;

long Diff(int H, int W)
{
	long Smax, Smin, Diff =0;
	int c = 0;
	for (int i = 1; i < W - 2; i++){
		for (int j = i + 1; j < W - 1; j++){
			Smax = H*max(i, max(j - i, W - j));
			Smin = H*min(i, min(j - i, W - j));
			if (c==0)Diff =    Smax - Smin;
			else (Diff ? Diff : Smax - Smin) ;
			c++;
		}
	}
	for (int i = 1; i < H - 1; i++){
		for (int j = i + 1; j < W - 1; j++){
			Smax = max(i*j, max((H - i)*j, H*(W - j)));
			Smin = min(i*j, min((H - i)*j, H*(W - j)));
			Diff = (Diff < Smax - Smin ? Diff : Smax - Smin);

			Smax = max(H*j, max(i*(W - j), (H - i)*(W - j)));
			Smin = min(H*j, min(i*(W - j), (H - i)*(W - j)));
			Diff = (Diff < Smax - Smin ? Diff : Smax - Smin);

		}
	}
	return Diff;

}
int main()
{
	int H, W;
	cin >> H >> W;
	cout << min(Diff(H, W), Diff(W, H));
	cin >> H;
	return 0;
}

Compiler output:
a.cc: In function 'long int Diff(int, int)':
a.cc:9:41: error: 'max' was not declared in this scope; did you mean 'Smax'?
    9 |                         Smax = H*max(i, max(j - i, W - j));
      |                                         ^~~
      |                                         Smax
a.cc:9:34: error: 'max' was not declared in this scope; did you mean 'Smax'?
    9 |                         Smax = H*max(i, max(j - i, W - j));
      |                                  ^~~
      |                                  Smax
a.cc:10:41: error: 'min' was not declared in this scope; did you mean 'Smin'?
   10 |                         Smin = H*min(i, min(j - i, W - j));
      |                                         ^~~
      |                                         Smin
a.cc:10:34: error: 'min' was not declared in this scope; did you mean 'Smin'?
   10 |                         Smin = H*min(i, min(j - i, W - j));
      |                                  ^~~
      |                                  Smin
a.cc:18:41: error: 'max' was not declared in this scope; did you mean 'Smax'?
   18 |                         Smax = max(i*j, max((H - i)*j, H*(W - j)));
      |                                         ^~~
      |                                         Smax
a.cc:18:32: error: 'max' was not declared in this scope; did you mean 'Smax'?
   18 |                         Smax = max(i*j, max((H - i)*j, H*(W - j)));
      |                                ^~~
      |                                Smax
a.cc:19:41: error: 'min' was not declared in this scope; did you mean 'Smin'?
   19 |                         Smin = min(i*j, min((H - i)*j, H*(W - j)));
      |                                         ^~~
      |                                         Smin
a.cc:19:32: error: 'min' was not declared in this scope; did you mean 'Smin'?
   19 |                         Smin = min(i*j, min((H - i)*j, H*(W - j)));
      |                                ^~~
      |                                Smin
a.cc: In function 'int main()':
a.cc:34:9: error: 'cin' was not declared in this scope
   34 |         cin >> H >> W;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:35:9: error: 'cout' was not declared in this scope
   35 |         cout << min(Diff(H, W), Diff(W, H));
      |         ^~~~
a.cc:35:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:35:17: error: 'min' was not declared in this scope; did you mean 'main'?
   35 |         cout << min(Diff(H, W), Diff(W, H));
      |                 ^~~
      |                 main