Refrain
Hard
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Consider a sequence of n integers ranging from 1 to m. A subsequence of consecutive numbers is termed a refrain if the product of its length and the number of times it appears in the sequence is maximized.
Your task is to identify the refrain in the given sequence.
Input
The first line contains two integers n and m (1 ≤ n ≤ 150000, 1 ≤ m ≤ 10). The second line provides n integers, each between 1 and m.
Output
The first line should display the product of the refrain's length and its frequency. The second line should show the length of the refrain. The third line should present the sequence that constitutes the refrain.
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 4%