CF616F Expensive Strings
Description
You are given $ n $ strings $ t_{i} $ . Each string has cost $ c_{i} $ .
Let's define the function of string , where $ p_{s,i} $ is the number of occurrences of $ s $ in $ t_{i} $ , $ |s| $ is the length of the string $ s $ . Find the maximal value of function $ f(s) $ over all strings.
Note that the string $ s $ is not necessarily some string from $ t $ .
Input Format
The first line contains the only integer $ n $ ( $ 1
Output Format
Print the only integer $ a $ — the maximal value of the function $ f(s) $ over all strings $ s $ . Note one more time that the string $ s $ is not necessarily from $ t $ .