#abc141e. [abc141_e]Who Says a Pun?
[abc141_e]Who Says a Pun?
Problem Statement
Given is a string of length .
Find the maximum length of a non-empty string that occurs twice or more in as contiguous substrings without overlapping.
More formally, find the maximum positive integer such that there exist integers and ( ) that satisfy the following:
-
-
S\[l_1+i\] = S\[l_2+i\] (i = 0, 1, ..., len - 1)
If there is no such integer , print .
Constraints
- consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum length of a non-empty string that occurs twice or more in as contiguous substrings without overlapping. If there is no such non-empty string, print instead.
Sample Input 1
5
ababa
Sample Output 1
2
The strings satisfying the conditions are: a
, b
, ab
, and ba
. The maximum length among them is , which is the answer. Note that aba
occurs twice in as contiguous substrings, but there is no pair of integers and mentioned in the statement such that .
Sample Input 2
2
xy
Sample Output 2
0
No non-empty string satisfies the conditions.
Sample Input 3
13
strangeorange
Sample Output 3
5