Language: C++

/* AOJ 0525
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0525
 *
 */


//include
#include<bits/stdc++.h>

//using
using namespace std;

//define static const typedef
#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n"
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n"
#define F first
#define S second


typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

static const int INF = 1 << 25;

//global
static set<vector<vector<char> > > a;
static vector<vector<char> > d;
static int h, w;
static int ans;
//function
static void solve(VVI ar){
  if(a.count(ar)){
    return;
  }
  a.insert(ar);
  static int cnt;
  cnt = 0;
  REP(i, h){
    REP(j, w){
      cnt += ar[i][j];
    }
  }
  ans = max(cnt, ans);
  REP(i, h){
    REP(j, w){
      ar[i][j] = !ar[i][j];
    }
    solve(ar);
    REP(j, w){
      ar[i][j] = !ar[i][j];
    }
  }
  REP(i, w){
    REP(j, h){
      ar[j][i] = !ar[j][i];
    }
    solve(ar);
    REP(j, h){
      ar[j][i] = !ar[j][i];
    }
  }
}
int main(){
  while(scanf("%d %d", &h, &w)){
    if(!h && !w){
      break;
    }
    ans = 0;
    d.resize(h, VI(w));
    REP(i, h){
      REP(j, w){
	scanf("%d", &d[i][j]);
      }
    }
    solve(d);
    printf("%d\n", ans);
    d.resize(0, vector<char>(0));
    a = set<vector<vector<char> > >();
  }
  return 0;
}

Compiler output:
a.cc: In function 'void solve(VVI)':
a.cc:48:13: error: no matching function for call to 'std::set<std::vector<std::vector<char> > >::count(VVI&)'
   48 |   if(a.count(ar)){
      |      ~~~~~~~^~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_set.h:756:9: note: candidate: 'template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::vector<std::vector<char> >; _Compare = std::less<std::vector<std::vector<char> > >; _Alloc = std::allocator<std::vector<std::vector<char> > >]'
  756 |         count(const _Kt& __x) const
      |         ^~~~~
/usr/include/c++/14/bits/stl_set.h:756:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype (((const std::set<std::vector<std::vector<char> > >*)this)->std::set<std::vector<std::vector<char> > >::_M_t.std::_Rb_tree<std::vector<std::vector<char> >, std::vector<std::vector<char> >, std::_Identity<std::vector<std::vector<char> > >, std::less<std::vector<std::vector<char> > >, std::allocator<std::vector<std::vector<char> > > >::_M_count_tr<_Kt, _Req>(__x)) std::set<std::vector<std::vector<char> > >::count(const _Kt&) const [with _Kt = std::vector<std::vector<int> >]':
a.cc:48:13:   required from here
   48 |   if(a.count(ar)){
      |      ~~~~~~~^~~~
/usr/include/c++/14/bits/stl_set.h:757:37: error: no matching function for call to 'std::_Rb_tree<std::vector<std::vector<char> >, std::vector<std::vector<char> >, std::_Identity<std::vector<std::vector<char> > >, std::less<std::vector<std::vector<char> > >, std::allocator<std::vector<std::vector<char> > > >::_M_count_tr(const std::vector<std::vector<int> >&) const'
  757 |         -> decltype(_M_t._M_count_tr(__x))
      |                     ~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:1311:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Req = _Kt; _Key = std::vector<std::vector<char> >; _Val = std::vector<std::vector<char> >; _KeyOfValue = std::_Identity<std::vector<std::vector<char> > >; _Compare = std::less<std::vector<std::vector<char> > >; _Alloc = std::allocator<std::vector<std::vector<char> > >]'
 1311 |         _M_count_tr(const _Kt& __k) const
      |         ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1311:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::vector<std::vector<char> > >; _SfinaeType = std::vector<std::vector<int> >]':
/usr/include/c++/14/bits/stl_tree.h:1309:9:   required by substitution of 'template<class _Kt> decltype (((const std::set<std::vector<std::vector<char> > >*)this)->std::set<std::vector<std::vector<char> > >::_M_t.std::_Rb_tree<std::vector<std::vector<char> >, std::vector<std::vector<char> >, std::_Identity<std::vector<std::vector<char> > >, std::less<std::vector<std::vector<char> > >, std::allocator<std::vector<std::vector<char> > > >::_M_count_tr<_Kt, _Req>(__x)) std::set<std::vector<std::vector<char> > >::count(const _Kt&) const [with _Kt = std::vector<std::vector<int> >]'
 1309 |                typename _Req = __has_is_transparent_t<_Compare, _Kt>>
      |                ^~~~~~~~
a.cc:48:13:   required from here
   48 |   if(a.count(ar)){
      |      ~~~~~~~^~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::vector<std::vector<char> > >, std::vector<std::vector<int> >, void>'
 1427 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:750:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::vector<std::vector<char> >; _Compare = std::less<std::vector<std::vector<char> > >; _Alloc = std::allocator<std::vector<std::vector<char> > >; size_type = long unsigned int; key_type = std::vector<std::vector<char> >]'
  750 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:750:29: note:   no known conversion for argument 1 from 'VVI' {aka 'std::vector<std::vector<int> >'} to 'const std::set<std::vector<std::vector<char> > >::key_type&' {aka 'const std::vector<std::vector<char> >&'}
  750 |       count(const key_type& __x) const
      |             ~~~~~~~~~~~~~~~~^~~
a.cc:51:11: error: no matching function for call to 'std::set<std::vector<std::vector<char> > >::insert(VVI&)'
   51 |   a.insert(ar);
      |   ~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = std::vector<std::vector<char> >; _Compare = std::less<std::vector<std::vector<char> > >; _Alloc = std::allocator<std::vector<std::vector<char> > >]'
  568 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:511:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::vector<std::vector<char> >; _Compare = std::less<std::vector<std::vector<char> > >; _Alloc = std::allocator<std::vector<std::vector<char> > >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::vector<std::vector<char> >, std::vector<std::vector<char> >, std::_Identity<std::vector<std::vector<char> > >, std::less<std::vector<std::vector<char> > >, std::allocator<std::vector<std::vector<char> > > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::vector<std::vector<char> > >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::vector<std::vector<char> > >, std::vector<std::vector<char> > >::rebind<std::vector<std::vector<char> > >; typename _Alloc::value_type = std::vector<std::vector<char> >; value_type = std::vector<std::vector<char> >]'
  511 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:511:32: note:   no known conversion for argument 1 from 'VVI' {aka 'std::vector<std::vector<int> >'} to 'const std::set<std::vector<std::vector<char> > >::value_type&' {aka 'const std::vector<std::vector<char> >&'}
  511 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:520:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = std::vector<std::vector<char> >; _Compare = std::less<std::vector<std::vector<char> > >; _Alloc = std::allocator<std::vector<std::vector<char> > >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::vector<std::vector<char> >, std::vector<std::vector<char> >, std::_Identity<std::vector<std::vector<char> > >, std::less<std::vector<std::vector<char> > >, std::allocator<std::vector<std::vector<char> > > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::vector<std::vector<char> > >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::vector<std::vector<char> > >, std::vector<std::vector<char> > >::rebind<std::vector<std::vector<char> > >; typename _Alloc::value_type = std::vector<std::vector<char> >; value_type = std::vector<std::vector<char> >]'
  520 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:520:27: note:   no known conversion for argument 1 from 'VVI' {aka 'std::vector<std::vector<int> >'} to 'std::set<std::vector<std::vector<char> > >::value_type&&' {aka 'std::vector<std::vector<char> >&&'}
  520 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:548:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, const value_type&) [with _Key = std::vector<std::vector<char> >; _Compare = std::less<std::vector<std::vector<char> > >; _Alloc = std::allocator<std::vector<std::vector<char> > >; iterator = std::_Rb_tree<std::vector<std::vector<char> >, std::vector<std::vector<char> >, std::_Identity<std::vector<std::vector<char> > >, std::less<std::vector<std::vector<char> > >, std::allocator<std::vector<std::vector<char> > > >::const_iterator; const_iterator = std::_Rb_tree<std::vector<std::vector<char> >, std::vector<std::vector<char> >, std::_Identity<std::vector<std::vector<char> > >, std::less<std::vector<std::vector<char> > >, std::allocator<std::vector<std::vector<char> > > >::const_iterator; value_type = std::vector<std::vector<char> >]'
  548 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/i