test case is decrementing for two times???

this is a problem in which I have to calculate the median in a sorted array after insertion and deletion each time but the test case is decrementing for 2 times i each iteration ?? I am unable to find it :frowning:

My code is :-----
#include
#include
#include<stdio.h>
using namespace std;
multiset myset;
int main()
{

int test;
cin>>test;
int e=test;
while(test)
{
    test=test-1;
    //test++;
    char input;
    int value;
    //scanf("%c",&input);
    cin>>input;

    //scanf("%d",&value);
    cin>>value;
    if(input=='a')
    {
        //cout<<"byeeeeeeeee\n"<<test<<"lsfhvfduhvl";
        myset.insert(value);
        int a=myset.size();
        if(a%2!=0)  //odd case
        {
            multiset<int> :: const_iterator it=myset.begin();
            for(int i=0;i<(a/2);i++)
            {
                it++;
            }
            printf("%d\n",*it);
            //cout<<(*it)<<"\n";
        }
        else
        {
            int b,c;
            multiset<int> :: const_iterator it=myset.begin();
            for(int i=0;i<(a/2);i++)
            {
                it++;
            }
            b=(*it);
            it--;
            c=(*it);
            double x= 1.0*(b+c)/2;
            printf("%.10g\n",x);
            //cout<<setprecision(9)<<x<<"\n";

        }
    }
    else if(input=='r')
    {
        //cout<<"hiiiiiiiiiiiii\n"<<test<<"lufhvfdhsv";

        if(myset.find(value)!=myset.end())
        {
            cout<<"hiiiiiiiiiiiii";
            myset.erase(myset.find(value));

            if(!myset.empty())
            {
                int a=myset.size();


        if(a%2!=0)  //odd case
        {
            multiset< int > :: const_iterator it=myset.begin();
            for(int i=0;i<(a/2);i++)
            {
                it++;
            }
            printf("%d\n",*it);
            //cout<<(*it)<<"\n";
        }
        else
        {
            int b,c;
            multiset< int > :: const_iterator it=myset.begin();
            for(int i=0;i<(a/2);i++)
            {
                it++;
            }
            b=(*it);
            it--;
            c=(*it);
            //cout<<1.*(b+c)/2<<"\n";
            double x= 1.0*(b+c)/2;
            printf("%.10g\n",x);
            //cout<<setprecision(9)<<x<<"\n";

        }
        }
        else
        cout<<"Wrong!\n";


        }
        else
        {
            cout<<"Wrong!\n";
        }

    }


}
return 0;

}

it is a problem of interview street
https://www.interviewstreet.com/challenges/dashboard/#problem/4fcf919f11817
why the test case is giving me the problem ie, it is decrementing by 2 instead of 1 in each iteration ??

no,its not working

if i change cin with scanf then still it is decremeting by two .
i am getting the problem in it

First of all you should use scanf instead of printf… By all means avoid using cin and cout… scanf and printf are STRONGLY recommended… And can you give me the problem statement? I think that way it will be easier to help you… If I can of course.

see this… its working fine here…