Language: C++


using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

ll w, h, ans = mod, s[3];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> w >> h;
	if (!(w % 3) || !(h % 3))
		ans = 0;
	fori (i, 1, w)
	{
		s[0] = i * h;
		s[1] = ((w - i) * (h / 2));
		s[2] = ((w - i) * ((h + 1) / 2));
		ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
	}
	fori (i, 1, h)
	{
		s[0] = i * w;
		s[1] = ((h - i) * (w / 2));
		s[2] = ((h - i) * ((w + 1) / 2));
		ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
	}

	cout << ans << endl;
}

Compiler output:
a.cc:22:9: error: 'pair' does not name a type
   22 | typedef pair<int, int> pii;
      |         ^~~~
a.cc:23:9: error: 'pair' does not name a type
   23 | typedef pair<int, ll> pil;
      |         ^~~~
a.cc:24:9: error: 'pair' does not name a type
   24 | typedef pair<ll, int> pli;
      |         ^~~~
a.cc:25:9: error: 'pair' does not name a type
   25 | typedef pair<ll, ll> pll;
      |         ^~~~
a.cc:26:9: error: 'pair' does not name a type
   26 | typedef pair<int, pll> pip;
      |         ^~~~
a.cc:27:9: error: 'pair' does not name a type
   27 | typedef pair<ll, pll> plp;
      |         ^~~~
a.cc:28:9: error: 'pair' does not name a type
   28 | typedef pair<pll, int> ppi;
      |         ^~~~
a.cc:29:9: error: 'pair' does not name a type
   29 | typedef pair<pll, ll> ppl;
      |         ^~~~
a.cc:30:9: error: 'pair' does not name a type
   30 | typedef pair<pll, pll> ppp;
      |         ^~~~
a.cc:31:9: error: 'vector' does not name a type
   31 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:32:9: error: 'vector' does not name a type
   32 | typedef vector<ll> vll;
      |         ^~~~~~
a.cc: In function 'int main()':
a.cc:41:9: error: 'ios_base' has not been declared
   41 |         ios_base::sync_with_stdio(false);
      |         ^~~~~~~~
a.cc:42:9: error: 'cin' was not declared in this scope
   42 |         cin.tie(0);
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:52:33: error: 'max_element' was not declared in this scope
   52 |                 ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
      |                                 ^~~~~~~~~~~
a.cc:52:58: error: 'min_element' was not declared in this scope
   52 |                 ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
      |                                                          ^~~~~~~~~~~
a.cc:52:23: error: 'min' was not declared in this scope; did you mean 'main'?
   52 |                 ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
      |                       ^~~
      |                       main
a.cc:59:33: error: 'max_element' was not declared in this scope
   59 |                 ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
      |                                 ^~~~~~~~~~~
a.cc:59:58: error: 'min_element' was not declared in this scope
   59 |                 ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
      |                                                          ^~~~~~~~~~~
a.cc:59:23: error: 'min' was not declared in this scope; did you mean 'main'?
   59 |                 ans = min(ans, *max_element(s, s + 3) - *min_element(s, s + 3));
      |                       ^~~
      |                       main
a.cc:62:9: error: 'cout' was not declared in this scope
   62 |         cout << ans << endl;
      |         ^~~~
a.cc:62:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:62:24: error: 'endl' was not declared in this scope
   62 |         cout << ans << endl;
      |                        ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 |