Language: C++

#define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

template <typename T>
class Bit {
private:
    V<T> data;
    T identity_ele;

public:
    Bit(ll size, T identity_ele) : identity_ele(identity_ele) {
        ll newsize = 1;
        while(newsize < size) {
            newsize = newsize << 1;
        }
        data = V<T>(newsize + 1, identity_ele);
    }

    /*
     * 0-origin
     * sum of [0, pos)
     */
    T sum(ll pos) {
        T ret = identity_ele;
        while(pos > 0) {
            ret += data[pos];
            pos -= pos & -pos;
        }
        return ret;
    }

    /*
     * 0-origin
     * sum of [l, r)
     */
    T sum(ll l, ll r) {
        return sum(r) - sum(l);
    }

    /*
     * 0-origin
     */
    void add(ll pos, T delta) {
        pos++;
        while(pos <= data.size()) {
            data[pos] = data[pos] + delta;
            pos += pos & -pos;
        }
    }
};

using TLL = tuple<ll, ll, ll>;

int main() {
    ll Q;
    cin >> Q;
    V<TLL> query;
    V<ll> nlis;
    for(ll i = 0; i < Q; i++) {
        ll q;
        cin >> q;
        if(q == 1) {
            ll a, b;
            cin >> a >> b;
            query.emplace_back(q, a, b);
            nlis.push_back(a);
        } else {
            query.emplace_back(q, 0, 0);
        }
    }
    
    {
        sort(ALL(nlis));
        auto ite = unique(ALL(nlis));
        nlis.erase(ite, nlis.end());
    }

    auto get_idx = [&](ll n) {
        return distance(nlis.begin(),
                        lower_bound(ALL(nlis), n));
    };

    Bit<ll> bt(nlis.size() + 10, 0);
    ll asum = 0;
    ll bsum = 0;
    ll cnt = 0;
    
    for(const auto ele : query) {
        ll q, a, b;
        tie(q, a, b) = ele;
        if(q == 1) {
            bt.add(get_idx(a), 1);
            asum += a;
            bsum += b;
            cnt++;
            continue;
        }
        ll ok = nlis.size() - 1, ng = -1;
        ll aim = (cnt + 1) / 2;
        while(ok - ng > 1) {
            ll mid = (ok + ng) / 2;
            if(bt.sum(0, mid + 1) >= aim) ok = mid;
            else ng = mid;
        }
        ll x = nlis[ok];
        cout << x << ' ' << asum - x * aim - x * (cnt - aim) + bsum << endl;
    }
    return 0;
}



Compiler output:
a.cc:36:10: fatal error: ../debug.cpp: No such file or directory
   36 | #include "../debug.cpp"
      |          ^~~~~~~~~~~~~~
compilation terminated.