Palindromic quadruple - ReimuOJ: Reimu Online Judge

Palindromic quadruple

Time limit: 1000 ms
Memory limit: 512 MB
Let S be a string consisting only of letters. Count the number of tuples (i,j,k,t) such that 1≤i≤j<k≤t≤|S| and S[i..j]+S[k...t] is a palindrome. ### Input - Only line contains a string S. ### Output - Print the number of quadruples that satisfy the conditions. ### Constraints |S|≤5000 ### Example Input: aaca Output: 14