Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H,W;
  cin>>H>>W;
  vector<string> A(H);
  cin>>A;
  vector<vector<int>> dp(H,vector<int>(W,1));
  for(int i=1;i<H;i++){
    for(int j=0;j+1<W;j++){
      bool k1=A[i-1][j]==A[i-1][j+1];
      bool k2=A[i][j]==A[i][j+1];
      if(k1==k2){dp[i][j]=dp[i-1][j]+1;}
      else{dp[i][j]=1;}
    }
  }
  ll ans=H;
  for(int i=0;i<H;i++){
    stack<pll> S;
    S.push({-1,0});
    for(int j=0;j+1<W;j++){
      while(S.top().S>=dp[i][j]){
        pll tp=S.top(); S.pop();
        ans=max(ans,(j-tp.F)*tp.S);
      }
      S.push({j,dp[j]});
    }
    while(!S.empty()){
      pll tp=S.top(); S.pop();
      ans=max(ans,(H-tp.F)*tp.S);
    }
  }
  cout<<ans<<endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:13: error: no matching function for call to 'std::stack<std::pair<long long int, long long int> >::push(<brace-enclosed initializer list>)'
   45 |       S.push({j,dp[j]});
      |             ^
In file included from /usr/include/c++/14/stack:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:160,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_stack.h:258:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; value_type = std::pair<long long int, long long int>]'
  258 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:258:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::stack<std::pair<long long int, long long int> >::value_type&' {aka 'const std::pair<long long int, long long int>&'}
  258 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_stack.h:263:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; value_type = std::pair<long long int, long long int>]'
  263 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_stack.h:263:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::stack<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  263 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~