Median of stream of integers

I have asked the doubt before also but its not been cleared.What correction do I need to make in my code?

Its giving correct answer for the test data but its not correct for the other test datas

Modified Code

code and logic is correct but the problem is with statement
if (first.size() - second.size() > 1)
{
instead of this if you use if (first.size()>second.size()+1)
{

it will pass all testcase