# -*- coding: utf-8 -*- """ Created on Wed Nov 14 13:54:28 2012 @author: milos """ def increment(ch, di): if ch in di: di[ch] += 1 else: di[ch] = 1 import sys counts = {} for line in sys.stdin: line = line.split("\t")[0] line = line.decode("utf-8") line = line.lower() increment (line[-1], counts) if len(line) > 1: increment (line[-2:], counts) if len(line) > 2: increment (line[-3:], counts) for char in counts: print char, counts[char]