output_description: Print the maximum possible area of Snuke's rectangle.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      H W
      S_1
      S_2
      :
      S_H
attempt: #include<iostream>
  #include<vector>
  #include<algorithm>
  #include<queue>
  #include<stack>
  #include<cstring>
  #include<utility>
  #include<cmath>
  #include<assert.h>
  #include<set>
  #include<map>
  #include<unordered_set>
  #include<unordered_map>
  #include<complex>
  #include<bitset>
  #include<numeric>
  
  #define int long long
  using namespace std;
  #define rep(i, n) for(int i=0;i<(n);++i)
  typedef pair<int, int> pii;
  const int INF = 1l << 60;
  #define u_b upper_bound
  #define l_b lower_bound
  
  const int MAX_H = 2000, MAX_W = 2000;
  int H, W;
  string S[MAX_H];
  int bad[MAX_H - 1][MAX_W - 1];
  
  signed main() {
      cin >> H >> W;
      rep(i, H) {
          cin >> S[i];
      }
      rep(h, H - 1) {
          rep(w, W - 1) {
              rep(i, 2) {
                  rep(j, 2) {
                      bad[h][w] += (S[h + i][w + j] == '#');
                  }
              }
              bad[h][w] %= 2;
          }
      }
      rep(w, W - 1)bad[0][w] = 2 - bad[0][w];
      rep(h, H - 2) {
          rep(w, W - 1) {
              if (bad[h + 1][w] == 1)bad[h + 1][w] = 1;
              else bad[h + 1][w] = bad[h][w] + 1;
          }
      }
      int ans = max(H, W);
      rep(h, H - 1) {
          stack<pii> st;
          rep(w, W - 1) {
              int tmp = w;
              while (!st.empty() && st.top().second > bad[h][w]) {
                  pii p = st.top();
                  st.pop();
                  ans = max(ans, p.second * (w - p.first + 1));
                  tmp = p.first;
              }
              st.push(pii(tmp, bad[h][w]));
          }
          while (!st.empty()) {
              pii p = st.top();
              st.pop();
              ans = max(ans, p.second * (W - p.first));
          }
      }
      cout << ans << endl;
      return 0;
  }
  
problem_description: Statement
  
  We have a board with an H \times W grid. Each square in the grid is painted in
  black or white. The square at the i-th row from the top and j-th column from
  the left is black if the j-th character in S_i is `#`, and white if that
  character is `.`.
  
  Snuke can perform the following operation on the grid any number of times:
  
    * Select a row or column in the grid, and invert the color of all the squares in that row or column (that is, black squares become white and vice versa).
  
  Then, Snuke draws a rectangle along grid lines. Here, all the squares
  contained in the rectangle must be painted in black.
  
  Find the maximum possible area of Snuke's rectangle when the operation is
  performed optimally.
samples: [{"input": "3 3\n    ..#\n    ##.\n    .#.", "output": "6\n    \n\nIf the first row from the top and the third column from the left are inverted,\na 2 \\times 3 rectangle can be drawn, as shown below:\n\n![](https://atcoder.jp/img/arc081/2995c3921ed4dffc8ee528b63b9c6118.png)\n\n* * *"}, {"input": "4 4\n    ....\n    ....\n    ....\n    ....", "output": "16\n    \n\n* * *"}, {"input": "10 8\n    ##...#.#\n    ##...#.#\n    ..###.#.\n    #.##.#.#\n    .#..#.#.\n    ..##.#.#\n    ##.#.#..\n    ...#.#..\n    ###.#.##\n    ###..###", "output": "27"}]