#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a hash,p; RollingHash(){} RollingHash(const string &s,ull B=1000000007LL){ int n=s.size(); hash.assign(n+1,0); p.assign(n+1,1); for(int i=0;i manacher(string s){ int n=s.size(); vector v(n); for(int i=0,j=0;i=0&&i+j=0&&i+k>s; int n=s.size(); string t(s); reverse(t.begin(),t.end()); RollingHash rhs(s),rht(t); int ans=0; { string x; x.push_back('$'); for(char c:s){ x.push_back(c); x.push_back('$'); } int ans1=0,ans2=0; auto v=manacher(x); for(int i=0;i>1; auto x=rhs.find(i+1,i+1+m); auto y=rht.find(n-i,n-i+m); if(x==y) l=m; else r=m; } chmax(ans,l*2); } // erase i, i+1 if(i+2>1; auto x=rhs.find(i+2,i+2+m); auto y=rht.find(n-i,n-i+m); if(x==y) l=m; else r=m; } chmax(ans,l*2+1); } } cout<