import heapq class MedianCalculator: def __init__(self): self.heaps = [], [] def add_num(self, num): small, large = self.heaps heapq.heappush(small, -heapq.heappushpop(large, num)) if len(large) < len(small): heapq.heappush(large, -heapq.heappop(small)) def find_median(self): small, large = self.heaps if len(large) > len(small): return float(large[0]) return (large[0] - small[0]) / 2.0 if __name__ == "__main__": median_calculator = MedianCalculator() try: while True: num = int(input()) median_calculator.add_num(num) print('Current median: ', median_calculator.find_median()) except EOFError: print('End of stream.')