Language: C++

#include<iostream>
using namespace std;


int main(){
 
  long int H,W;
  cin>>H>>W;
  long int minn=1000000000;
  long int s1,s2,s3;
  if(H%3==0||W%3==0) {cout<<0<<endl; return 0;}
  
 for(int i = 1; i < W; ++i)
	{
		 s1 = i * H;
		 s2 = max(((W - i) / 2) * H, (W - i) * (H/ 2));
		 s3 = (W - i) * H - s2;
 
		minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
	}
 
	swap(H, W);
 
	 for(int i = 1; i < W; ++i)
	{
		 s1 = i * H;
		 s2 = max(((W - i) / 2) * H, (W - i) * (H/ 2));
		 s3 = (W - i) * H - s2;
 
		minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
	}
 
  cout<<minn<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:39: error: 'a1' was not declared in this scope; did you mean 's1'?
   19 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                       ^~
      |                                       s1
a.cc:19:43: error: 'a2' was not declared in this scope; did you mean 's2'?
   19 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                           ^~
      |                                           s2
a.cc:19:47: error: 'a3' was not declared in this scope; did you mean 's3'?
   19 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                               ^~
      |                                               s3
a.cc:19:37: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   19 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                  ~~~^~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
a.cc:19:57: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   19 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                                      ~~~^~~~~~~~~~~~~~
/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
a.cc:30:39: error: 'a1' was not declared in this scope; did you mean 's1'?
   30 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                       ^~
      |                                       s1
a.cc:30:43: error: 'a2' was not declared in this scope; did you mean 's2'?
   30 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                           ^~
      |                                           s2
a.cc:30:47: error: 'a3' was not declared in this scope; did you mean 's3'?
   30 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                               ^~
      |                                               s3
a.cc:30:37: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   30 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                  ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
a.cc:30:57: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   30 |                 minn = min(minn, max({a1, a2, a3}) - min({a1, a2, a3}));
      |                                                      ~~~^~~~~~~~~~~~~~
/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