Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    float a,b,d;
    int ans=INT_MAX;
    float r,c;
    cin>>r>>c;
    int total  = r*c;
    if(total%3==0){
        cout<<0<<endl;
        return 0 ;
    }
    else{
         for(int i =1;i <r;i++){
            a = c*i;
            float left_rows = r-i;
            b = floor(left_rows/2)*c;
            d = ceil(left_rows/2)*c;
            ans = min(ans,max({a,b,d})-min({a,b,d}));

            a = c*i;
            b = floor(c/2)*(r-i);
            d=ceil(c/2)*(r-i);
            ans = min(ans,max({a,b,d})-min({a,b,d}));

         }
         for(int i =1;i <c;i++){
             a = r*i;
            float left_rows = c-i;
            b = floor(left_rows/2)*r;
            d = ceil(left_rows/2)*r;
            ans = min(ans,max({a,b,d})-min({a,b,d}));

            a = r*i;
            b = floor(r/2)*(c-i);
            d=ceil(r/2)*(c-i);;
           ans = min(ans,max({a,b,d})-min({a,b,d}));

         }
    }
    cout<<ans<<endl;


















}




















Compiler output:
a.cc: In function 'int32_t main()':
a.cc:34:22: error: no matching function for call to 'min(long long int&, float)'
   34 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:34:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'float')
   34 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:34:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:39:22: error: no matching function for call to 'min(long long int&, float)'
   39 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:39:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'float')
   39 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:39:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   39 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:47:22: error: no matching function for call to 'min(long long int&, float)'
   47 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:47:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'float')
   47 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:47:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |             ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:52:21: error: no matching function for call to 'min(long long int&, float)'
   52 |            ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:52:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'float')
   52 |            ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:52:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |            ans = min(ans,max({a,b,d})-min({a,b,d}));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~