-*- import sys from collections import defaultdict from operator import itemgetter wc_dict = defaultdict(int) for line in sys.stdin: word, count = line.strip().split('¥t') wc_dict[word] += int(count) for word, count in sorted(wc_dict.items(), key=itemgetter(1), reverse=True): print('{0}¥t{1}'.format(word, count))