Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.
You are a worker at Alphaland Gym Houston. The member attendance data is stored as a string. Rearrange its characters so that letters with higher frequency appear first. If two characters have the same frequency, sort alphabetically. Sample Input: 10 kanghaerin Sample Output: aanneghikr Question Input: 30 steaenltrseateoaristtehnasdeih