In a Meta live monitoring pipeline, event counts arrive one integer at a time. Implement a data structure that supports inserting a new integer from the stream and returning the median of all values seen so far at any moment.
Implement a function that processes a list of operations and returns the result for each median query.
operations: a list of operations{"op": "add", "value": x} where x is an integer{"op": "median"}median query contributes the current median.def stream_median(operations):