Finished optimized code that will calculate the median of a set of integers, and will automatically update that median value after removing and adding values.