Rolling median function (Daily Coding Problem 377)
This compiles cleanly and produces reasonable integer output (though not in the format required by the problem statement).

Note that you are required to include &lt;cstdlib&gt; before using EXIT_SUCCESS; failing to do so may be a portability bug.

All that copying and sorting gets expensive as the input and k both get larger.  We should probably create a stateful class that we can update with the new right-most value and the left-most to be removed.  I'd probably implement that with two sets - one holding values lower than the median and one holding higher values.  When we shift the window by one position, then we update the two sets and move an element if necessary to balance them (remember that because a set is sorted, it's easy to find the lowest and highest values using front() and back()).