Buggy python submission (verdict: Time Limit Exceeded):
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
import heapq


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


def main():
    qnum = intin()
    qlist = [input() for _ in range(qnum)]

    alist = []
    acount = 0
    lsum = 0
    rsum = 0
    bsum = 0

    for q in qlist:

        if q[0] == '1':
            q = q.split(' ')
            a = int(q[1])
            b = int(q[2])

            bsum += b

            med = None
            odd_slice = None
            even_slice = None

            if alist:
                med = alist[acount//2 if acount&1 else acount//2-1]
                if acount & 1:
                    if a <= med:
                        odd_slice = True
                    else:
                        odd_slice = False
                else:
                    if a < med:
                        even_slice = False
                    else:
                        even_slice = True

            heapq.heappush(alist, a)
            alist.sort()
            acount += 1

            if med is not None:
                prev_med = med
                med = alist[acount//2 if acount&1 else acount//2-1]
                if odd_slice is not None:
                    if odd_slice:
                        lsum -= (abs(prev_med - med) * ((acount - 1) // 2))
                        lsum += abs(med - a)
                        rsum += (abs(prev_med - med) * (acount // 2))
                    else:
                        rsum += abs(med - a)
                if even_slice is not None:
                    if even_slice:
                        lsum += (abs(med - prev_med) * (acount // 2))
                        rsum -= (abs(med - prev_med) * (acount // 2))
                        rsum += abs(a - med)
                    else:
                        lsum += abs(med - a)

        if q[0] == '2':
            print('%d %d' % 
                  (alist[acount//2 if acount&1 else acount//2-1],
                   lsum + rsum + bsum))


if __name__ == '__main__':
    main()


Fixed submission:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
import heapq


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


def main():
    qnum = intin()
    qlist = [input() for _ in range(qnum)]

    lalist = []
    ralist = []
    acount = 0
    lsum = 0
    rsum = 0
    bsum = 0

    for q in qlist:

        if q[0] == '1':
            q = q.split(' ')
            a = int(q[1])
            b = int(q[2])

            bsum += b

            if acount:
                _, prev_med = lalist[0]
                if acount & 1:
                    acount += 1
                    if a <= prev_med:
                        heapq.heappop(lalist)
                        heapq.heappush(lalist, (-a, a))
                        heapq.heappush(ralist, (prev_med, prev_med))
                        _, med = lalist[0]
                        lsum -= (abs(prev_med - med) * ((acount - 1) // 2))
                        lsum += abs(med - a)
                        rsum += (abs(prev_med - med) * (acount // 2))
                    else:
                        heapq.heappush(ralist, (a, a))
                        _, med = lalist[0]
                        rsum += abs(med - a)
                else:
                    acount += 1
                    if a < prev_med:
                        heapq.heappush(lalist, (-a, a))
                        _, med = lalist[0]
                        lsum += abs(med - a)
                    else:
                        _, tmp = heapq.heappop(ralist)
                        l = min(a, tmp)
                        r = max(a, tmp)
                        heapq.heappush(ralist, (r, r))
                        heapq.heappush(lalist, (-l, l))
                        _, med = lalist[0]
                        lsum += (abs(med - prev_med) * (acount // 2))
                        rsum -= (abs(med - prev_med) * (acount // 2))
                        rsum += abs(a - med)

            else:
                lalist.append((-a, a))
                acount += 1

        if q[0] == '2':
            _, med = lalist[0]
            print('%d %d' % (med, lsum + rsum + bsum))


if __name__ == '__main__':
    main()