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

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;
```

}