Language: C++

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int q;
int k[200100];
ll a[200100], b[100100];

void solve() {
    multiset<ll> l, r;
    ll base = 0;
    ll ml = (ll)-1e18;
    ll mr = (ll)1e18;
    int cnt = 0;
    for (int i = 0; i < q; i++) {
        if (k[i] == 1) {
            if (cnt % 2) {
                if (a[i] <= ml) {
                    base += b[i] + ml-a[i];                    
                    l.insert(-a[i]);
                    ml = -(*l.begin());
                } else {
                    base += b[i] + a[i]-mr;
                    r.insert(a[i]);
                    mr = r.begin();
                }
            } else {
                if (ml <= a[i] && a[i] <= mr) {
                    l.insert(-ml);
                    r.insert(mr);
                    ml = mr = a[i];
                    base += b[i];
                } else if (a[i] < ml) {
                    base += b[i] + ml-a[i];
                    r.insert(mr);
                    l.insert(-a[i]);
                    mr = ml;
                } else {
                    base += b[i] + a[i]-mr;                    
                    l.insert(ml);
                    r.insert(a[i]);
                    ml = mr;
                }                
            }
            cnt++;
        } else {
            cout << ml << " " << base << endl;
        }
    }
}

void input() {
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> k[i];
        if (k[i] == 1) cin >> a[i] >> b[i];
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:67:33: error: cannot convert 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} to 'll' {aka 'long long int'} in assignment
   67 |                     mr = r.begin();
      |                          ~~~~~~~^~
      |                                 |
      |                                 std::multiset<long long int>::iterator {aka std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator}