#K69527. Taco Score Calculation
Taco Score Calculation
Taco Score Calculation
You are given a string s
that consists of lowercase English letters. Each letter has a base score: \(a=1, b=2, \ldots, z=26\). The score of the string is calculated by grouping consecutive identical letters. For each group of consecutive identical letters, if the letter has a base score \(b\) and appears consecutively \(n\) times, then the group contributes a score of \(b \times n^2\). The total score is the sum of the scores of all groups.
For example:
- For input
a
: there is one group: \(1 \times 1^2 = 1\). - For input
aa
: group \(aa\) gives \(1 \times 2^2 = 4\). - For input
aaa
: group \(aaa\) gives \(1 \times 3^2 = 9\). - For input
xyzxyzxyz
: each letter appears individually, so the score is \((24 + 25 + 26) \times 3 = 225\) assuming x=24, y=25, z=26. - For input
aabbbc
: the groups are "aa" \((1 \times 2^2 = 4)\), "bbb" \((2 \times 3^2 = 18)\), and "c" \((3 \times 1^2 = 3)\) for a total score of \(4+18+3=25\).
Your task is to compute the total score for a given string using the above rules.
inputFormat
The input consists of a single line containing a non-empty string s
of lowercase English letters read from standard input.
outputFormat
Output a single integer representing the total score of the string to standard output.
## samplea
1