[P1117] [NOI2016] 优秀的拆分
Problem Statement (NOI2016 Day 1 Task 1 / Luogu P1117)
If a string can be split into the concatenation of four non-empty strings AABB (where A and B are non-empty strings, possibly A = B), then this splitting is called an excellent splitting. Given T strings S of lowercase English letters, for each string find the total number of excellent splittings across all substrings of S (identical substrings at different positions or different splittings of the same substring are counted separately).
Input: First line: integer T (1 <= T <= 10). Next T lines: each contains a lowercase string S (|S| <= 30000).
Output: T lines, each an integer representing the total number of excellent splittings.
Sample Input 1: 4 aabbbb cccccc aabaabaabaa bbaabaababaaba
Sample Output 1: 3 5 4 7