left, mid, and right to represent the smallest k, middle m - 2k, and largest k elements, respectively.sum to keep the sum of elements in mid.addElement operation:
a. Add the new element to the appropriate set based on its value.
b. Rebalance the sets if the sizes of left or right are not equal to k.
c. Update the sum if elements are moved to or from the mid set.calculateMKAverage operation:
a. If the total number of elements is less than m, return -1.
b. Otherwise, return the floor value of sum divided by the size of mid.