回文字动机模板
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[300005];
int n, las, fil[300005], nx[300005][35], len[300005], tot, rt, now, cnt[300005];
ll ans;
int newnode(int x) {
len[tot] = x;
return tot++;
}
int getfil(int x, int n) {
while(s[n - 1 - len[x]] != s[n]) x = fil[x];
return x;
}
int main() {
int i;
cin >> (s + 1);
s[0] = -1;
las = 0;
newnode(0);
newnode(-1);
fil[0] = 1;
for(n = 1; s[n]; ++n) {
s[n] -= 'a';
rt = getfil(las, n);
if(!nx[rt][s[n]]) {
now = newnode(len[rt] + 2);
fil[now] = nx[getfil(fil[rt], n)][s[n]];
nx[rt][s[n]] = now;
}
cnt[las = nx[rt][s[n]]]++;
}
for(i = tot - 1; i >= 0; --i) {
cnt[fil[i]] += cnt[i];
ans = max(ans, 1ll * cnt[i] * len[i]);
}
cout << ans;
return 0;
}