#P6456. Longest Repeated Substring

    ID: 19670 Type: Default 1000ms 256MiB

Longest Repeated Substring

Longest Repeated Substring

Given a string of length \(L\), find the longest substring that appears at least twice (in different positions) within the string. Output the length of such a substring.

Note: The substring occurrences must not overlap in their positions.

inputFormat

The input consists of a single line containing a non-empty string.

The length of the string is denoted by \(L\).

outputFormat

Output a single integer: the length of the longest substring appearing at least twice in the given string.

sample

banana
3