Language: C++

#include<iostream>
long long diff(long long x, long long y, long long z) {
  return max(x, max(y, z)) - min(x, min(y, z));
}
int main() {
  long long h, w;
  cin >> h >> w;
  long long ans(INT_MAX);
  for (int i = 1; i <= h / 2; ++i) {
    //for (int j = 1; j <= w / 2; ++j) {
      long long j = w / 2;
      long long a = i * j, b = (h - i) * j, d = (h - i) * (w-j), c = i * (w - j);
      long long t1 = min(diff(a + b, c, d), diff(a + c, b, d));
      long long t2 = min(diff(b + d, a, c), diff(c + d, a, b));
      ans = min(ans, min(t1, t2));
    //}
  }
  cout << ans;
  return 0;
};

Compiler output:
a.cc: In function 'long long int diff(long long int, long long int, long long int)':
a.cc:3:17: error: 'max' was not declared in this scope; did you mean 'std::max'?
    3 |   return max(x, max(y, z)) - min(x, min(y, z));
      |                 ^~~
      |                 std::max
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:3:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
    3 |   return max(x, max(y, z)) - min(x, min(y, z));
      |          ^~~
      |          std::max
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:3:37: error: 'min' was not declared in this scope; did you mean 'std::min'?
    3 |   return max(x, max(y, z)) - min(x, min(y, z));
      |                                     ^~~
      |                                     std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:3:30: error: 'min' was not declared in this scope; did you mean 'std::min'?
    3 |   return max(x, max(y, z)) - min(x, min(y, z));
      |                              ^~~
      |                              std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> h >> w;
      |   ^~~
      |   std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:17: error: 'INT_MAX' was not declared in this scope
    8 |   long long ans(INT_MAX);
      |                 ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | long long diff(long long x, long long y, long long z) {
a.cc:13:22: error: 'min' was not declared in this scope; did you mean 'std::min'?
   13 |       long long t1 = min(diff(a + b, c, d), diff(a + c, b, d));
      |                      ^~~
      |                      std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:18:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |   cout << ans;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~