eolymp
bolt
Try our new interface for solving problems
Problems

The biggest border of the substring

The biggest border of the substring

The \textit{border (verge, brink) br} of the string \textbf{S} is any proper prefix of this string that is equal to the suffix of \textbf{S}. A string \textbf{S = abaababaabaab} has two borders (not empty) - \textbf{ab} and \textbf{abaab}. A string \textbf{S = abaabaab} has two borders - \textbf{ab} and \textbf{abaab}, but the second one is overlapping. A string of length \textbf{n} formed with a repeating character, like \textbf{aaaaaaaa} (or \textbf{a^8}), has \textbf{n-1} borders. For \textbf{S = a^8} the borders are: \textbf{a}, \textbf{aa}, \textbf{aaa}, \textbf{aaaa}, \textbf{aaaaa}, \textbf{aaaaaa}, \textbf{aaaaaaa}. The concept of "\textit{proper prefix}" eliminates the border equals to the string. \textit{The length} of the border is the number of characters in it. We make a generalization of the problem. Suppose we want to calculate the values of the largest borders for all substrings of \textbf{S\[1..i\]} (\textbf{i = 1..n}) and store them in the array \textbf{br\[1..n\]}. Find the maximum value of the border in array of the largest borders \textbf{br} for all substrings in \textbf{S}. \InputFile Given a string \textbf{S} (|\textbf{S}| ≤ \textbf{10^6}). \OutputFile Print one number - the answer to the problem.
Time limit 1 second
Memory limit 64 MiB
Input example #1
abaabaab
Output example #1
5