eolymp
bolt
Try our new interface for solving problems
Problems

Sort the hashes 2

Sort the hashes 2

Set of words is given. Sort them in ascending order of hashes. The hash of the string $s$ is the sum of the ASCII codes of the characters in it. For example, hash("Cat") = $67 + 97 + 116 = 280$, hash("dOG") = $100 + 79 + 71 = 250$. Let a string $a$ be less than a string $b$ if hash($a$) < hash($b$). For example, hash("dOG") < hash("Cat") since $250 < 280$. However, there is a special word "\textbf{ADAUniversity}" in the text, that should always be at the start of the sorted list. We assume that hash("ADAUniversity") = $0$. For words that have the same hash, sort the words in their lexicographical order. \InputFile The text contains a set of words. Each word consists of letters of Latin alphabet (lower and upper case). Only spaces can be present between the words. The number of words in the text does not exceed $1000$. The length of each word does not exceed $100$ characters. \OutputFile Print all words sorted according to the given condition. Each word should be printed on a separate line.
Time limit 1 second
Memory limit 128 MiB
Input example #1
Cat ADAUniversity
bBC dOG      ADAUniversity   CbB
    BbC     Cat   bCB   BCb
Output example #1
ADAUniversity
ADAUniversity
BCb
BbC
CbB
bBC
bCB
dOG
Cat
Cat