<s> """<STR_LIT>""" <EOL> import heapq <EOL> from collections import defaultdict <EOL> def mode ( lst ) : <EOL> "<STR_LIT>" <EOL> counts = defaultdict ( int ) <EOL> for x in lst : <EOL> counts [ x ] += <NUM_LIT:1> <EOL> max = <NUM_LIT:0> <EOL> item = None <EOL> for val , count in counts . items ( ) : <EOL> if count > max : <EOL> max = count <EOL> item = val <EOL> return item <EOL> def median ( lst ) : <EOL> "<STR_LIT>" <EOL> lst . sort ( ) <EOL> middle = len ( lst ) // <NUM_LIT:2> <EOL> return lst [ middle ] <EOL> def max_count ( count ) : <EOL> "<STR_LIT>" <EOL> vals = [ ] <EOL> orig_names = { } <EOL> for n , c in count . items ( ) : <EOL> orig_names [ str ( n ) ] = n <EOL> vals . append ( ( - c , str ( n ) ) ) <EOL> heapq . heapify ( vals ) <EOL> while len ( vals ) : <EOL> c , n = heapq . heappop ( vals ) <EOL> yield ( - c , orig_names [ n ] ) <EOL> def harmonic_mean ( lst ) : <EOL> "<STR_LIT>" <EOL> n = len ( lst ) <EOL> inv_sum = sum ( ( <NUM_LIT:1.0> / x ) for x in lst ) <EOL> return ( <NUM_LIT:1.0> / ( ( <NUM_LIT:1.0> / n ) * inv_sum ) ) </s>
