Harry and magic string

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 5157
64-bit integer IO format: %I64d      Java class name: Main

Description

Harry got a string T, he wanted to know the number of T’s disjoint palindrome substring pairs. A string is considered to be palindrome if and only if it reads the same backward or forward. For two substrings of $T: \, x = T[a_1 \ldots b_1], \, y = T[a_2 \ldots b_2]$(where a1 is the beginning index of $x, b_1$ is the ending index of x. $a_2, b_2$ as the same of y), if both x and y are palindromes and $b_1 < a_2 \text{ or } b_2 < a_1$ then we consider (x, y) to be a disjoint palindrome substring pair of T.

Input

There are several cases.
For each test case, there is a string T in the first line, which is composed by lowercase characters. The length of T is in the range of [1,100000].

Output

For each test case, output one number in a line, indecates the answer.

Sample Input

aca
aaaa

Sample Output

3
15

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .