11241: ABC375 - D - ABA
[Creator : ]
Description
You are given a string $S$ consisting of uppercase English letters.
Find the number of integer triples $(i, j, k)$ satisfying both of the following conditions:
Find the number of integer triples $(i, j, k)$ satisfying both of the following conditions:
- $1 \leq i < j < k \leq |S|$
- The length-$3$ string formed by concatenating $S_i$, $S_j$, and $S_k$ in this order is a palindrome.
Input
The input is given from Standard Input in the following format:
$S$
$S$
Output
Print the answer.
Constraints
- $S$ is a string of length between $1$ and $2 \times 10^5$, inclusive, consisting of uppercase English letters.
Sample 1 Input
ABCACC
Sample 1 Output
5
The triples satisfying the conditions are $(i, j, k) = (1, 2, 4), (1, 3, 4), (3, 4, 5), (3, 4, 6), (3, 5, 6)$.
Sample 2 Input
OOOOOOOO
Sample 2 Output
56
Sample 3 Input
XYYXYYXYXXX
Sample 3 Output
75