manacher模板题
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iomanip>
#include<cctype>
#include<queue>
using namespace std;
const int N=2e6+5;
char t[N],s[N];
int T,n,m,po,mx,r,R[N];
void manacher()
{
po=mx=r=0;
for(int i=1;i<=n;i++)
{
if(mx>i)r=min(mx-i,R[2*po-i]);
else r=1;
while(s[i-r]==s[i+r])r++;
if(i+r>mx)mx=i+r,po=i;
R[i]=r;
}
}
int main()
{
//freopen("lx.in","r",stdin);
while(scanf("%s",t+1)&&t[1]!='E')
{
s[n=0]='!';
m=strlen(t+1);
for(int i=1;i<=m;i++)
s[++n]='#',s[++n]=t[i];
s[++n]='#',s[++n]='?';
manacher();
int ans=0;
for(int i=1;i<=n;i++)
ans=max(ans,R[i]);
cout<<"Case "<<++T<<": "<<ans-1<<'\n';
}
return 0;
}