<s> """<STR_LIT>""" <EOL> import sys <EOL> class Word ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , word ) : <EOL> self . word = word <EOL> self . count = <NUM_LIT:0> <EOL> def Print ( self ) : <EOL> print '<STR_LIT>' % ( self . word , self . count ) <EOL> def Increment ( self , count = <NUM_LIT:1> ) : <EOL> self . count += count <EOL> class ShortestToLongestReducer ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . current_word = None <EOL> def PrintCurrentWord ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . current_word : <EOL> self . current_word . Print ( ) <EOL> def ProcessLine ( self , line ) : <EOL> """<STR_LIT>""" <EOL> key = line . split ( '<STR_LIT:\t>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> word = key . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] <EOL> if not self . current_word : <EOL> self . current_word = Word ( word ) <EOL> elif self . current_word . word != word : <EOL> self . current_word . Print ( ) <EOL> self . current_word = Word ( word ) <EOL> self . current_word . Increment ( ) <EOL> def main ( input_lines ) : <EOL> reducer = ShortestToLongestReducer ( ) <EOL> for line in input_lines : <EOL> reducer . ProcessLine ( line ) <EOL> reducer . PrintCurrentWord ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( sys . stdin ) </s>
