#C3417. Count Palindromic Substrings

    ID: 46842 Type: Default 1000ms 256MiB

Count Palindromic Substrings

Count Palindromic Substrings

Given a string text, count the number of palindromic substrings in it. A palindromic substring is one that reads the same backwards as forwards. Note that every single character is considered a palindromic substring.

You are required to use an efficient center-expansion approach. The idea is to expand around each index (and between indices) to count all palindromic substrings. In mathematical terms, if \( n \) is the length of the string, the total count can be expressed as:

\[ \text{Total Count} = \sum_{i=0}^{n-1} \Big(\text{OddPalindromes}_i + \text{EvenPalindromes}_i\Big) \]

Implement your solution so that it reads input from stdin and writes the result to stdout.

inputFormat

The input consists of a single line containing the string text. The string may be empty.

outputFormat

Output a single integer, which is the number of palindromic substrings in the given string.

## sample
abba
6