atcoder#ABC299F. [ABC299F] Square Subsequence
[ABC299F] Square Subsequence
Score : points
Problem Statement
You are given a string consisting of lowercase English letters. Print the number of non-empty strings that satisfy the following condition, modulo .
The concatenation of two copies of is a subsequence of (not necessarily contiguous).
Constraints
- is a string consisting of lowercase English letters whose length is between and , inclusive.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
ababbaba
8
The eight strings satisfying the condition are a, aa, ab, aba, b, ba, bab, and bb.
zzz
1
The only string satisfying the condition is z.
Note that this string contributes to the answer just once, although there are three ways to extract the subsequence zz from zzz: zz, zz, and zz.
ppppqqppqqqpqpqppqpqqqqpppqppq
580