#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; #ifndef LOCAL #define debug(x) ; #else #define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; template ostream &operator<<(ostream &out, const pair &p) { out << "{" << p.first << ", " << p.second << "}"; return out; } template ostream &operator<<(ostream &out, const vector &v) { out << '{'; for (const T &item : v) out << item << ", "; out << "\b\b}"; return out; } #endif #define mod 1000000007 //1e9+7(prime number) #define INF 1000000000 //1e9 #define LLINF 2000000000000000000LL //2e18 #define SIZE 200010 /* Manacher.cpp (Source: snukeさんブログ) */ // R[i] := 文字 i を中心とする最長の回文の半径( 全長+1 / 2 ) // 偶数長は文字間にダミーを入れる(例: a#b#a#c#b) void Manacher(const char *S, int *R){ int i = 0, j = 0, k, n = strlen(S); while (S[i]) { while (i-j >= 0 && i+j < n && S[i-j] == S[i+j]) j++; R[i] = j; for (k = 1; i-k >= 0 && i+k < n && k+R[i-k] < j; k++) R[i+k] = R[i-k]; i += k; j -= k; } } char s[SIZE], t[SIZE]; vector vec[SIZE]; ll dp[5][SIZE]; int main(){ int n; scanf("%s", s); n = strlen(s); for(int i=0;i