macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
pub mod at {
    // use std;
    #[inline]
    fn rmb(k: usize) -> usize {
        (k as isize & -(k as isize)) as usize
    }
    pub trait Monoid {
        type T: Clone + PartialEq;
        fn mempty(&self) -> Self::T;
        fn mappend(&self, x: &Self::T, y: &Self::T) -> Self::T;
    }
    pub struct BinaryIndexedTree<M: Monoid> {
        bit: Vec<M::T>,
        m: M,
    }
    impl<M: Monoid> BinaryIndexedTree<M> {
        pub fn new(n: usize, m: M) -> BinaryIndexedTree<M> {
            let bit = vec![m.mempty(); n + 1];
            BinaryIndexedTree { bit: bit, m: m }
        }
        #[doc = " 1-indexed"]
        pub fn query(&self, k: usize) -> M::T {
            let mut res = self.m.mempty();
            let mut k = k;
            while k > 0 {
                res = self.m.mappend(&res, &self.bit[k]);
                k -= rmb(k);
            }
            res
        }
        #[doc = " 1-indexed"]
        pub fn update(&mut self, k: usize, x: M::T) {
            let mut k = k;
            while k < self.bit.len() {
                self.bit[k] = self.m.mappend(&self.bit[k], &x);
                k += rmb(k);
            }
        }
    }
    pub trait Group: Monoid {
        fn invert(&self, x: &Self::T) -> Self::T;
    }
    impl<G: Group> BinaryIndexedTree<G> {
        #[doc = " 0-indexed [l, r)"]
        pub fn query_section(&self, l: usize, r: usize) -> G::T {
            self.m
                .mappend(&self.m.invert(&self.query(l)), &self.query(r))
        }
        #[doc = " 1-indexed"]
        pub fn get_val(&self, k: usize) -> G::T {
            self.query_section(k - 1, k)
        }
        #[doc = " 1-indexed"]
        pub fn set_val(&mut self, k: usize, x: G::T) {
            let y = self.m.invert(&self.get_val(k));
            let z = self.m.mappend(&y, &x);
            self.update(k, z);
        }
    }
    pub struct AnyMonoid<T: Clone, F: Fn(&T, &T) -> T> {
        id: T,
        op: F,
    }
    impl<T: Clone, F: Fn(&T, &T) -> T> AnyMonoid<T, F> {
        pub fn new(id: T, op: F) -> AnyMonoid<T, F> {
            AnyMonoid { id: id, op: op }
        }
    }
    impl<T: Clone + PartialEq, F: Fn(&T, &T) -> T> Monoid for AnyMonoid<T, F> {
        type T = T;
        fn mempty(&self) -> T {
            self.id.clone()
        }
        fn mappend(&self, x: &T, y: &T) -> T {
            (self.op)(x, y)
        }
    }
    pub struct AnyGroup<T: Clone, F: Fn(&T, &T) -> T, G: Fn(&T) -> T> {
        id: T,
        op: F,
        inv: G,
    }
    impl<T: Clone, F: Fn(&T, &T) -> T, G: Fn(&T) -> T> AnyGroup<T, F, G> {
        pub fn new(id: T, op: F, inv: G) -> AnyGroup<T, F, G> {
            AnyGroup {
                id: id,
                op: op,
                inv: inv,
            }
        }
    }
    impl<T: Clone + PartialEq, F: Fn(&T, &T) -> T, G: Fn(&T) -> T> Monoid for AnyGroup<T, F, G> {
        type T = T;
        fn mempty(&self) -> T {
            self.id.clone()
        }
        fn mappend(&self, x: &T, y: &T) -> T {
            (self.op)(x, y)
        }
    }
    impl<T: Clone + PartialEq, F: Fn(&T, &T) -> T, G: Fn(&T) -> T> Group for AnyGroup<T, F, G> {
        fn invert(&self, x: &T) -> T {
            (self.inv)(x)
        }
    }
    pub trait Bisect: Copy {
        fn halve(self, other: Self) -> Self;
        fn section_end(self, other: Self) -> bool;
    }
    impl Bisect for usize {
        fn halve(self, other: Self) -> Self {
            if self > other {
                other + (self - other) / 2
            } else {
                self + (other - self) / 2
            }
        }
        fn section_end(self, other: Self) -> bool {
            (if self > other {
                self - other
            } else {
                other - self
            }) <= 1
        }
    }
    impl Bisect for i64 {
        fn halve(self, other: Self) -> Self {
            (self + other) / 2
        }
        fn section_end(self, other: Self) -> bool {
            (self - other).abs() <= 1
        }
    }
    impl Bisect for f64 {
        fn halve(self, other: Self) -> Self {
            (self + other) / 2.
        }
        fn section_end(self, other: Self) -> bool {
            (self - other).abs() <= 1e-8
        }
    }
    pub fn binary_search<T: Bisect, F: Fn(T) -> bool>(f: F, ok: T, err: T) -> T {
        let mut ok = ok;
        let mut err = err;
        while !ok.section_end(err) {
            let m = ok.halve(err);
            if f(m) {
                ok = m;
            } else {
                err = m;
            }
        }
        ok
    }
    pub fn lower_bound<T: Bisect + Ord>(v: &[T], x: T) -> usize {
        binary_search(|i| v[i as usize] >= x, v.len() as i64, -1) as usize
    }
    impl<M: Monoid> BinaryIndexedTree<M>
    where
        M::T: Ord,
    {
        #[doc = " 0-indexed"]
        pub fn lower_bound(&self, x: M::T) -> (usize, M::T) {
            let n = self.bit.len() - 1;
            let mut acc = self.m.mempty();
            let mut pos = 0;
            let mut k = 1 << format!("{:b}", n).len();
            while k > 0 {
                if k + pos <= n && self.m.mappend(&acc, &self.bit[k + pos]) < x {
                    pos += k;
                    acc = self.m.mappend(&acc, &self.bit[pos]);
                }
                k >>= 1;
            }
            (pos, acc)
        }
    }
}
use at::*;
use std::collections::BTreeSet;
fn main() {
    input! { iter = iter, q };
    let mut update_query = vec![];
    let mut minimum_query = vec![];
    for _ in 0..q {
        input_inner! { iter, x };
        if x == 1 {
            input_inner! { iter, a: i64, b: i64 };
            update_query.push((a, b));
        } else {
            minimum_query.push(update_query.len() - 1);
        }
    }
    let v = update_query
        .iter()
        .map(|&(a, _)| a)
        .collect::<BTreeSet<_>>()
        .into_iter()
        .collect::<Vec<_>>();
    let mut bitm = BinaryIndexedTree::new(v.len(), AnyGroup::new(0, |&x, &y| x + y, |&x| -x));
    let mut bitc = BinaryIndexedTree::new(v.len(), AnyGroup::new(0, |&x, &y| x + y, |&x| -x));
    let mut acc = 0;
    let mut j = 0;
    for (i, &(a, b)) in update_query.iter().enumerate() {
        let k = lower_bound(&v, a) + 1;
        bitm.update(k, a);
        bitc.update(k, 1);
        acc += b;
        while j < minimum_query.len() && i == minimum_query[j] {
            let (k, _sxx) = bitc.lower_bound(i as i64 / 2 + 1);
            let mut ans = bitm.query_section(k + 1, v.len()) - bitm.query_section(0, k + 1);
            ans += (i as i64 + 1 - 2 * bitc.query_section(k + 1, v.len())) * v[k] + acc;
            println!("{} {}", v[k], ans);
            j += 1;
        }
    }
}


Measured memory_bytes: 18000