Language: C++

/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  "An ideal problem has no test data."
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

#ifdef ARYANC403
#define dbg(...) { cerr<<"[ "; __aryanc403__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.X<<","<<x.Y<<")";
}

template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}

template <typename Arg1>
void __aryanc403__(const string name, Arg1&& arg1){
	cerr << name << " : " << arg1 << " ] " << endl;
}

template <typename Arg1, typename... Args>
void __aryanc403__(const string names, Arg1&& arg1, Args&&... args){
	const string name = names.substr(0,names.find(','));
	cerr<<name<<" : "<<arg1<<" | ";
	__aryanc403__(names.substr(1+(int)name.size()), args...);
}

#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || a.X==b.X && a.Y <= b.Y);   }};

// void add( map<lli,lli> &m, lli x,lli cnt=1)
// {
//     auto jt=m.find(x);
//     if(jt==m.end())         m.insert({x,cnt});
//     else                    jt->Y+=cnt;
// }

// void del( map<lli,lli> &m, lli x,lli cnt=1)
// {
//     auto jt=m.find(x);
//     if(jt->Y<=cnt)            m.erase(jt);
//     else                      jt->Y-=cnt;
// }

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
const lli maxN = 2*mod+3;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    map<int,lli> sum,freq;
    lli fullSum;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

void add(map<lli,lli> &a,lli x,lli v)
{
    while(x<=maxN)
    {
        a[x]+=v;
        x+=x&(-x);
    }
}

lli query(map<lli,lli> &a,lli x)
{
    lli cnt=0;
    while(x>0)
    {
        auto it=a.find(x);
        if(it!=a.end())
            cnt+=it->Y;
        x-=x&(-x);
    }
    return cnt;
}

lli bs(lli v)
{
    lli l=-1,r=maxN+1,m;
    while(r-l>1)
    {
        m=(l+r)/2;
        if(query(freq,m)>=v)
            r=m;
        else
            l=m;
    }
    return r;
}

lli eval(lli x,lli n)
{
    lli p=query(freq,x);
    lli ans=0;
    ans+=fullSum;
    ans-=2*query(sum,x);
    ans+=(2*p-n)*x;
    return ans;
}

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    lli cns=0,a,b,p;
    i=0;
    while(n--)
    {
        cin>>T;
        dbg(T);
        if(T==1)
        {
            i++;
            cin>>a>>b;
            cns+=b;
            a+=mod;
            fullSum+=a;
            add(freq,a,1);
            add(sum,a,a);
        }
        else
        {
            p=(i+1)/2;
            a=bs(p);
            b=eval(a,i)+cns;
            cout<<a-mod<<" "<<b<<endl;
        }
        dbg(T);
    }

}   aryanc403();

    return 0;
}

Compiler output:
a.cc: In function 'lli bs(lli)':
a.cc:146:18: error: invalid initialization of reference of type 'std::map<long long int, long long int>&' from expression of type 'std::map<int, long long int>'
  146 |         if(query(freq,m)>=v)
      |                  ^~~~
a.cc:127:25: note: in passing argument 1 of 'lli query(std::map<long long int, long long int>&, lli)'
  127 | lli query(map<lli,lli> &a,lli x)
      |           ~~~~~~~~~~~~~~^
a.cc: In function 'lli eval(lli, lli)':
a.cc:156:17: error: invalid initialization of reference of type 'std::map<long long int, long long int>&' from expression of type 'std::map<int, long long int>'
  156 |     lli p=query(freq,x);
      |                 ^~~~
a.cc:127:25: note: in passing argument 1 of 'lli query(std::map<long long int, long long int>&, lli)'
  127 | lli query(map<lli,lli> &a,lli x)
      |           ~~~~~~~~~~~~~~^
a.cc:159:18: error: invalid initialization of reference of type 'std::map<long long int, long long int>&' from expression of type 'std::map<int, long long int>'
  159 |     ans-=2*query(sum,x);
      |                  ^~~
a.cc:127:25: note: in passing argument 1 of 'lli query(std::map<long long int, long long int>&, lli)'
  127 | lli query(map<lli,lli> &a,lli x)
      |           ~~~~~~~~~~~~~~^
a.cc: In function 'int main()':
a.cc:186:17: error: invalid initialization of reference of type 'std::map<long long int, long long int>&' from expression of type 'std::map<int, long long int>'
  186 |             add(freq,a,1);
      |                 ^~~~
a.cc:118:24: note: in passing argument 1 of 'void add(std::map<long long int, long long int>&, lli, lli)'
  118 | void add(map<lli,lli> &a,lli x,lli v)
      |          ~~~~~~~~~~~~~~^
a.cc:187:17: error: invalid initialization of reference of type 'std::map<long long int, long long int>&' from expression of type 'std::map<int, long long int>'
  187 |             add(sum,a,a);
      |                 ^~~
a.cc:118:24: note: in passing argument 1 of 'void add(std::map<long long int, long long int>&, lli, lli)'
  118 | void add(map<lli,lli> &a,lli x,lli v)
      |          ~~~~~~~~~~~~~~^