Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll n;
string s;
bool hogege=true;
bool check(ll mid){
  map<string,pair<ll,ll>>MP;
  for(int i=0;i<=s.size()-mid;i++){
    string ss=SUBS(s,i+1,i+1+mid);
    ll num=MP[ss].F,num2=MP[ss].S;
    if(num == 0){
      MP[ss] = mp(i+1,i+1);
    }else{
      MP[ss] = mp(min(i+1,num),max(i+1,num2));
    }
  }
  for(auto a:MP){
    ll po=a.S.F,po2=a.S.S;
    if(po+mid<=po2){
      return true;
    }
  }
  return false;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>s;
  ll le=0,ri=222222;
  map<char,ll>MP;
  for(int i=0;i<n;i++)MP[s[i]]++;
  if(MP.size()==2)hogege=false;
  while(ri-le>1){
    ll mid=(le+ri)/2;
    if(check(mid)){
      le=mid;
    }else ri=mid;
  }
  cout<<le<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'bool check(long long int)':
a.cc:31:22: error: no matching function for call to 'min(int, long long int&)'
   31 |       MP[ss] = mp(min(i+1,num),max(i+1,num2));
      |                   ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/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:   template argument deduction/substitution failed:
a.cc:31:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |       MP[ss] = mp(min(i+1,num),max(i+1,num2));
      |                   ~~~^~~~~~~~~
/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, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:31:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |       MP[ss] = mp(min(i+1,num),max(i+1,num2));
      |                   ~~~^~~~~~~~~
a.cc:31:35: error: no matching function for call to 'max(int, long long int&)'
   31 |       MP[ss] = mp(min(i+1,num),max(i+1,num2));
      |                                ~~~^~~~~~~~~~
/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:   template argument deduction/substitution failed:
a.cc:31:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |       MP[ss] = mp(min(i+1,num),max(i+1,num2));
      |                                ~~~^~~~~~~~~~
/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, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:31:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |       MP[ss] = mp(min(i+1,num),max(i+1,num2));
      |                                ~~~^~~~~~~~~~