#C5816. Frequency Sorting of Characters

    ID: 49507 Type: Default 1000ms 256MiB

Frequency Sorting of Characters

Frequency Sorting of Characters

Given a string s consisting of lowercase alphabets, rearrange the characters such that they are sorted by their frequency in descending order. In other words, for two characters c1 and c2, if \( f(c_1) > f(c_2) \) then c1 should appear before c2. If the frequencies are equal, then sort the characters in ascending lexicographical order.

Note: Here, \( f(c) \) denotes the number of occurrences of character c in the string s.

inputFormat

The input consists of a single line containing a non-negative string of lowercase English letters.

outputFormat

Output a single line, which is the input string rearranged such that characters are sorted by their frequency in descending order. For characters with the same frequency, they should appear in alphabetical order.

## sample
tree
eert