Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int Case1(int h, int w) {
    if (h % 3 == 0) {
        return 0;
    } else {
        return w;
    }
}
/*long long min(long long a, long long b) {
    if (a > b) {
        return b;
    } else {
        return a;
    }
}*/
long long Case2(int h, int w) {
    long long block[3];
    long long mindiff = 1e10;
    for (int i = 1; i < h; ++i) {
        block[0] = i * w;
        block[1] = (w / 2 + w % 2) * (h - i); // () is important!
        block[2] = w / 2 * (h - i);
        mindiff = min(mindiff, max(block[0], block[1]) - min(block[0] - block[2]));
    }
    return mindiff;
}
int main() {
    int h, w; cin >> h >> w;
    cout << min({Case1(h, w), Case1(w, h), Case2(h, w), Case2(w, h)}) << endl;
    return 0;
}



Compiler output:
a.cc: In function 'long long int Case2(int, int)':
a.cc:26:61: error: no matching function for call to 'min(long long int)'
   26 |         mindiff = min(mindiff, max(block[0], block[1]) - min(block[0] - block[2]));
      |                                                          ~~~^~~~~~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/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:   template argument deduction/substitution failed:
a.cc:26:61: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |         mindiff = min(mindiff, max(block[0], block[1]) - min(block[0] - block[2]));
      |                                                          ~~~^~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
a.cc: In function 'int main()':
a.cc:32:16: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   32 |     cout << min({Case1(h, w), Case1(w, h), Case2(h, w), Case2(w, h)}) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:32:16: note:   deduced conflicting types for parameter '_Tp' ('int' and 'long long int')
   32 |     cout << min({Case1(h, w), Case1(w, h), Case2(h, w), Case2(w, h)}) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided