eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Another word sorting

Another word sorting

Лимит времени 1 секунда
Лимит использования памяти 64 MiB

A new scoring system for a word is invented and described as follows. Each letter has a value according to its alphabetic position e.g. a=1, b=2, c=3, ..., z=26. The score of a word is the sum of values of its letters plus the bonus. When a word has double letters (2 consecutive same letters), it will obtain the bonus of 2 times the letter value. Take a look at these examples:

apple = (1+16+16+12+5) + bonus 2x16 = 82

banana = (2+1+14+1+14+1) = 33 (no bonus)

orange = 15+18+1+14+7+5 = 60 (no bonus)

acted = (1+3+20+5+4) = 33 (no bonus)

commit = 3+15+13+13+9+20 + bonus 13x2 = 99

A letter can be used to calculate the bonus only once.

Given a list of words, your task is to rearrange them in descending order of their scores. In case of equal score, sort the words lexicographically.

Входные данные

The input contains a sequence of words each in a separate line. Each word contains only lower case letters (a...z) and has no more than 20 letters. The input can contain up to one 1000 lines.

Выходные данные

The output includes a sequence of the input words rearranged by this method. Each line contains only one word. If there are duplicate words, conserve all of them. There are neither blanks nor blank lines in the output.

Пример

Входные данные #1
apple
banana
commit
orange
acted
apple
ieee
Выходные данные #1
commit
apple
apple
orange
ieee
acted
banana