• + 0 comments
    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    from collections import Counter
    
    if __name__ == '__main__':
        s = input()  # Get the input string
        
        # Count the frequency of each character
        counter = Counter(s)
        
        # Sort by frequency in descending order and by character in ascending order
        most_common = sorted(counter.items(), key=lambda x: (-x[1], x[0]))
        
        # Print the top 3 most common characters
        for i in range(3):
            char, count = most_common[i]
            print(char, count)