P16602 [SYSUCPC 2025] SYSU II
Description
As you all know, you are participating in the SYSUCPC (SYSU Counting Periodic-string Contest) finals.
A string is considered $\bf{good}$ if and only if it can be rearranged into a perfectly periodic string with $\texttt{sysu}$ as its period (which means several $\texttt{sysu}$ repetitions). For example, $\texttt{sysu,yssu,ssyyssuu}$ are all $\bf{good}$, while $\texttt{ussu, sysusys}$ are not. Given a string $S$, determine how many of its substrings are $\bf{good}$.
A string $a$ is a substring of a string $b$ if $a$ can be obtained from $b$ by the deletion of several (possibly zero or all) characters from the beginning and several (possibly zero or all) characters from the end.
Input Format
The only line contains a single string $S(4\le |S|\le 2\times 10^5)$. It is guaranteed that $S$ only contains lowercase English letters.
Output Format
An integer, representing the number of $\bf{good}$ substrings of $S$.
Explanation/Hint
There are $6$ $\bf{good}$ substrings : $\texttt{sysu,ysus,susy,usys,sysu,sysusysu}$.