P4248 [AHOI2013] Difference

Description

Given a string $S$ of length $n$, let $T_i$ denote the suffix starting from its $i$-th character. Compute $$\displaystyle \sum_{1\leqslant i

Input Format

One line, a string $S$.

Output Format

One line, an integer representing the required value.

Explanation/Hint

#### Constraints - For $100\%$ of the testdata, it is guaranteed that $2\le n\le 500000$, and all characters in $S$ are lowercase letters. Translated by ChatGPT 5