<s> f = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> times = dict ( ) <EOL> end = <NUM_LIT:0> <EOL> start = <NUM_LIT:0> <EOL> for line in f . readlines ( ) : <EOL> split = line . split ( ) <EOL> if split [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == '<STR_LIT:.>' : <EOL> times [ split [ <NUM_LIT:0> ] ] = int ( float ( split [ <NUM_LIT:1> ] ) ) <EOL> elif split [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> end = int ( float ( split [ <NUM_LIT:1> ] ) ) <EOL> elif split [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> start = int ( float ( split [ <NUM_LIT:1> ] ) ) <EOL> if end != <NUM_LIT:0> and start != <NUM_LIT:0> : <EOL> key = split [ <NUM_LIT:2> ] [ split [ <NUM_LIT:2> ] . rfind ( '<STR_LIT:.>' ) : ] <EOL> if key in times : <EOL> times [ key ] += end - start <EOL> else : <EOL> times [ key ] = end - start <EOL> end = <NUM_LIT:0> <EOL> start = <NUM_LIT:0> <EOL> f . close ( ) <EOL> f = open ( "<STR_LIT>" , "<STR_LIT:w>" ) <EOL> for key in times : <EOL> f . write ( '<STR_LIT>' % ( key , int ( float ( times [ key ] ) ) ) ) </s>
