【題目敘述】https://zerojudge.tw/ShowProblem?problemid=e973
Python code (credit: Amy Chou)
N = list(input())
dic = {}
for c in N:
dic[c] = dic.get(c, 0) + 1
for k, v in sorted(dic.items(), key=lambda x:(-x[1], x[0])):
# 滿意度出現次數(dic.values())由高至低
# 次數一樣則輸出滿意度值(dic.keys())小者
print(f"{k} ", end="")
print()