Language: C++

#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

char data[2048][2048];
int danger[2048][2048];
struct Pt{int w, h;};
//int stk[2048];
int biggest[2048];
Pt stk[2048];
static inline void handle(int& top, int& ans, int a, int b, int h)
{
  while (top > 1 && h < stk[top-1].h)
  {
    int w = a - stk[top-2].w;
    int h = stk[top-1].h;
    int s = w * h;
    if (s > ans) ans = s;
    --top;
  }
  stk[top++] = {b, h};
}
int main()
{
  int h, w; scanf("%d %d", &h, &w);
  while (getchar() != '\n');
  for (int i = 0; i < h; ++i) gets(data[i]);
  for (int i = 1; i < h; ++i)
    for (int j = 1; j < w; ++j)
    {
      int c = 0;
      c ^= data[i-1][j-1] == '#';
      c ^= data[i-1][j] == '#';
      c ^= data[i][j-1] == '#';
      c ^= data[i][j] == '#';
      danger[i][j] = c;
    }
  int ans = max(h, w);
  for (int i = 1; i < h; ++i)
  {
    for (int j = 1; j < w; ++j)
    if (danger[i][j]) biggest[j] = i;
    int top = 0;
    int total = 0;
    stk[top++] = {0, 0};
    for (int j = 0; j < w;)
    {
      if (biggest[j] > 0) handle(top, ans, j, j, i - biggest[j] + 1);
      int k = j;
      while (k + 1 < w && biggest[k+1] == 0) ++k;
      handle(top, ans, j, k + 1, i + 1);
      j = k + 1;
    }
    while (top > 1)
    {
      --top;
      int s = stk[top].h * (w - stk[top-1].w);
      if (s > ans) ans = s;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:36: error: reference to 'data' is ambiguous
   29 |   for (int i = 0; i < h; ++i) gets(data[i]);
      |                                    ^~~~
In file included from /usr/include/c++/14/string:53,
                 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:3:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:6: note:                 'char data [2048][2048]'
    7 | char data[2048][2048];
      |      ^~~~
a.cc:29:31: error: 'gets' was not declared in this scope; did you mean 'getw'?
   29 |   for (int i = 0; i < h; ++i) gets(data[i]);
      |                               ^~~~
      |                               getw
a.cc:34:12: error: reference to 'data' is ambiguous
   34 |       c ^= data[i-1][j-1] == '#';
      |            ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:6: note:                 'char data [2048][2048]'
    7 | char data[2048][2048];
      |      ^~~~
a.cc:35:12: error: reference to 'data' is ambiguous
   35 |       c ^= data[i-1][j] == '#';
      |            ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:6: note:                 'char data [2048][2048]'
    7 | char data[2048][2048];
      |      ^~~~
a.cc:36:12: error: reference to 'data' is ambiguous
   36 |       c ^= data[i][j-1] == '#';
      |            ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:6: note:                 'char data [2048][2048]'
    7 | char data[2048][2048];
      |      ^~~~
a.cc:37:12: error: reference to 'data' is ambiguous
   37 |       c ^= data[i][j] == '#';
      |            ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:6: note:                 'char data [2048][2048]'
    7 | char data[2048][2048];
      |      ^~~~