<s> from heapq import heappush , heappop <EOL> class MedianFinder : <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . __max_heap = [ ] <EOL> self . __min_heap = [ ] <EOL> def addNum ( self , num ) : <EOL> """<STR_LIT>""" <EOL> if not self . __max_heap or num > - self . __max_heap [ <NUM_LIT:0> ] : <EOL> heappush ( self . __min_heap , num ) <EOL> if len ( self . __min_heap ) > len ( self . __max_heap ) + <NUM_LIT:1> : <EOL> heappush ( self . __max_heap , - heappop ( self . __min_heap ) ) <EOL> else : <EOL> heappush ( self . __max_heap , - num ) <EOL> if len ( self . __max_heap ) > len ( self . __min_heap ) : <EOL> heappush ( self . __min_heap , - heappop ( self . __max_heap ) ) <EOL> def findMedian ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( - self . __max_heap [ <NUM_LIT:0> ] + self . __min_heap [ <NUM_LIT:0> ] ) / <NUM_LIT> if len ( self . __min_heap ) == len ( self . __max_heap ) else self . __min_heap [ <NUM_LIT:0> ] </s>
