Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define ms(a, b)  memset((a), (b), sizeof(a))
#define eps 0.0000001
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x3f3f3f3f;
const LL INF = 0x7fffffff;
const int maxn = 1e6+10;
const int mod = 1e9+7;

void init() {

}
void solve() {
    int H, W;
    cin >> H >> W;
    if(H%3==0|| W%3==0) {
        cout << "0" << endl;
        return;
    } else {
        if(W>H)
            swap(H, W);
        LL ans = INF;
        LL s1, s2, s3, s4, s5, s6;
        for(int i = 1; i<=H; i++) {
            s1 = i*W;
            if(W%2==0) {
                s4 = s3 = (H-i)*(W/2);
            } else {
                s3 = (H-i)*(W/2);
                s4 = (H-i)*((W+1)/2);
            }
//            s3 = (H-i)*(W/2);
//            s4 = s2 - s3;

            LL Min = min(min(s1, s3), s4);
            LL Max = max(max(s1, s3), s4);
            ans = min(ans, Max-Min);

            if((H-i)%2==0) {
                s5 = s6 = ((H-i)/2) * W;
            } else {
                s5 = ((H-i)/2)*W;
                s6 = ((H-i+1)/2)*W;
            }
//            s5 = ((H-i)/2) * W;
//            s6 = s2 - s5;
            Min = min(min(s1, s5), s6);
            Max = max(max(s1, s5), s6);
            ans = min(ans, Max-Min);
        }
        for(int i = 1; i<=W; i++) {
           s1 = i*H;
            if(H%2==0) {
                s4 = s3 = (W-i)*(H/2);
            } else {
                s3 = (W-i)*(H/2);
                s4 = (W-i)*((H+1)/2);
            }
//            s3 = (H-i)*(W/2);
//            s4 = s2 - s3;

            int Min = min(min(s1, s3), s4);
            int Max = max(max(s1, s3), s4);
            ans = min(ans, Max-Min);

            if((W-i)%2==0) {
                s5 = s6 = ((W-i)/2) * H;
            } else {
                s5 = ((W-i)/2)*H;
                s6 = ((W-i+1)/2)*H;
            }
//            s5 = ((H-i)/2) * W;
//            s6 = s2 - s5;
            Min = min(min(s1, s5), s6);
            Max = max(max(s1, s5), s6);
            ans = min(ans, Max-Min);
        }
        cout << ans << endl;
    }

}
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//      freopen("output.txt", "w", stdout);
#endif // LOCAL
    init();
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:80:22: error: no matching function for call to 'min(LL&, int)'
   80 |             ans = min(ans, Max-Min);
      |                   ~~~^~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:80:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   80 |             ans = min(ans, Max-Min);
      |                   ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:13:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:80:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   80 |             ans = min(ans, Max-Min);
      |                   ~~~^~~~~~~~~~~~~~
a.cc:92:22: error: no matching function for call to 'min(LL&, int)'
   92 |             ans = min(ans, Max-Min);
      |                   ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:92:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   92 |             ans = min(ans, Max-Min);
      |                   ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:92:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   92 |             ans = min(ans, Max-Min);
      |                   ~~~^~~~~~~~~~~~~~