Longest Repeating Substring

We define the score of a string $$x$$ as the length of longest substring of $$x$$ which appears more than one times in $$x$$. (The substrings may overlap)

Let $$S$$ be the sum of the scores of all the strings in this file. Find $$S$$