#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>s; int n=s.size(); string t(s); reverse(t.begin(),t.end()); if(s==t){ cout<>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; } if(l==min(i,n-(i+1))){ chmax(ans,l*2+1); continue; } int pl=l,pr=r; { l=pl;r=pr; int p=l; r=min(i,n-(i+2))+1; while(l+1>1; auto x=rhs.find(i+2+p,i+2+m); auto y=rht.find(n-i+p,n-i+m); if(x==y) l=m; else r=m; } chmax(ans,l*2+1); } { l=pl;r=pr; int p=l; r=min(i-1,n-(i+1))+1; while(l+1>1; auto x=rhs.find(i+1+p,i+1+m); auto y=rht.find(n-i+p+1,n-i+m+1); if(x==y) l=m; else r=m; } chmax(ans,l*2+1); } } // even for(int i=0;i+1>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; } if(l==min(i,n-(i+2))){ chmax(ans,l*2+2); continue; } int pl=l,pr=r; { l=pl;r=pr; int p=l; r=min(i,n-(i+3))+1; while(l+1>1; auto x=rhs.find(i+3+p,i+3+m); auto y=rht.find(n-i+p,n-i+m); if(x==y) l=m; else r=m; } chmax(ans,l*2+2); } { l=pl;r=pr; int p=l; r=min(i-1,n-(i+2))+1; while(l+1>1; auto x=rhs.find(i+2+p,i+2+m); auto y=rht.find(n-i+p+1,n-i+m+1); if(x==y) l=m; else r=m; } chmax(ans,l*2+2); } } cout<