You are given a string of lowercase Latin letters. Let us define a substring's "occurrence value" as the number of the substring occurrences in the string multiplied by the length of the substring. For a given string find the largest occurrence value of palindromic substrings.
Notes
is the length of string .
A substring of string is any non-empty string , where . Any string is also its own substring.
A string is called palindromic, if it reads the same in either direction: from left to right and from right to left.
Input Specification
The only line of input contains a non-empty string of lowercase Latin letters (a
-z
).
Output Specification
Output one integer – the largest occurrence value of palindromic substrings.
Sample Input 1
abacaba
Sample Output 1
7
Explanation for Sample Output 1
There are seven palindromic substrings a
, b
, c
, aba
, aca
, bacab
, abacaba
.
a
has 4 occurrences in the given string, its occurrence value isb
has 2 occurrences in the given string, its occurrence value isc
has 1 occurrence in the given string, its occurrence value isaba
has 2 occurrences in the given string, its occurrence value isaca
has 1 occurrence in the given string, its occurrence value isbacab
has 1 occurrence in the given string, its occurrence value isabacaba
has 1 occurrence in the given string, its occurrence value is
So, the largest occurrence value of palindromic substrings is 7.
Sample Input 2
www
Sample Output 2
4
Scoring
Subtask 1 (points: 8)
Subtask 2 (points: 15)
Subtask 3 (points: 24)
Subtask 4 (points: 26)
Subtask 5 (points: 27)
Comments