Buggy python submission (verdict: Time Limit Exceeded):
import statistics
import sys
input = sys.stdin.readline

Q = int(input())

a = []
a_new = []
b_sum = 0
minima = 0
argmin = 10**10
shift = 0
for i in range(Q):
    ipt = list(map(int, input().split()))
    if len(ipt) == 3:
        a.append(ipt[1])
        argmin_new = statistics.median_low(a)
        if argmin == 10**10:
            argmin = argmin_new
        minima += abs(ipt[1] - argmin_new) + (abs(argmin - argmin_new)) * ((len(a) + 1) % 2)
        b_sum += ipt[2]
        argmin = argmin_new
    else:
        print(argmin, minima + b_sum)

Fixed submission:
def main():
    import sys
    from heapq import heappop, heappush, heappushpop
    input = sys.stdin.readline

    Q = int(input())
    R = [10**9+1]
    L = [10**9+1]
    Rsum = 0
    Lsum = 0
    NL = 0
    NR = 0
    B = 0
    for _ in range(Q):
        query = input().rstrip('\n')
        if query == '2':
            Lmax = -L[0]
            print(Lmax, Lmax * NL - Lsum + Rsum - Lmax * NR + B)
        else:
            _, a, b = query.split()
            a = int(a)
            b = int(b)
            B += b
            if NL != NR:
                Lmax = -L[0]
                Rmin = R[0]
                if a >= Lmax:
                    heappush(R, a)
                    Rsum += a
                    NR += 1
                else:
                    newR = -heappushpop(L, -a)
                    heappush(R, newR)
                    Rsum += newR
                    Lsum += a - newR
                    NR += 1
                    Lmax = -L[0]
            else:
                Rmin = R[0]
                if a <= Rmin:
                    heappush(L, -a)
                    Lsum += a
                    NL += 1
                else:
                    newL = heappushpop(R, a)
                    heappush(L, -newL)
                    Lsum += newL
                    Rsum += a - newL
                    NL += 1


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input = sys.stdin.readline

Q = int(input())

a = []
a_new = []
b_sum = 0
minima = 0
argmin = 10**10
shift = 0
for i in range(Q):
    ipt = list(map(int, input().split()))
    if len(ipt) == 3:
        if len(a) == 0:
            a.append(ipt[1])
        else:
            a.insert(bisect.bisect_left(a, ipt[1]), ipt[1])
        argmin_new = a[(len(a) - 1) // 2]
        if argmin == 10**10:
            argmin = argmin_new
        minima += abs(ipt[1] - argmin_new) + (abs(argmin - argmin_new)) * ((len(a) + 1) % 2)
        b_sum += ipt[2]
        argmin = argmin_new
    else:
        print(argmin, minima + b_sum)

Fixed submission:
def main():
    import sys
    from heapq import heappop, heappush, heappushpop
    input = sys.stdin.readline

    Q = int(input())
    R = [10**9+1]
    L = [10**9+1]
    Rsum = 0
    Lsum = 0
    NL = 0
    NR = 0
    B = 0
    for _ in range(Q):
        query = input().rstrip('\n')
        if query == '2':
            Lmax = -L[0]
            print(Lmax, Lmax * NL - Lsum + Rsum - Lmax * NR + B)
        else:
            _, a, b = query.split()
            a = int(a)
            b = int(b)
            B += b
            if NL != NR:
                Lmax = -L[0]
                Rmin = R[0]
                if a >= Lmax:
                    heappush(R, a)
                    Rsum += a
                    NR += 1
                else:
                    newR = -heappushpop(L, -a)
                    heappush(R, newR)
                    Rsum += newR
                    Lsum += a - newR
                    NR += 1
                    Lmax = -L[0]
            else:
                Rmin = R[0]
                if a <= Rmin:
                    heappush(L, -a)
                    Lsum += a
                    NL += 1
                else:
                    newL = heappushpop(R, a)
                    heappush(L, -newL)
                    Lsum += newL
                    Rsum += a - newL
                    NL += 1


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

Q = int(input())

a = []
a_new = []
b_sum = 0
minima = 0
argmin = 10**10
shift = 0
for i in range(Q):
    ipt = list(map(int, input().split()))
    if len(ipt) == 3:
        if len(a) == 0:
            a.append(ipt[1])
        else:
            a.insert(bisect.bisect_left(a, ipt[1]), ipt[1])
        argmin_new = a[(len(a) - 1) // 2]
        if argmin == 10**10:
            argmin = argmin_new
        minima += abs(ipt[1] - argmin_new) + (abs(argmin - argmin_new)) * ((len(a) + 1) % 2)
        b_sum += ipt[2]
        argmin = argmin_new
    else:
        print(argmin, minima + b_sum)

Fixed submission:
def main():
    import sys
    from heapq import heappop, heappush, heappushpop
    input = sys.stdin.readline

    Q = int(input())
    R = [10**9+1]
    L = [10**9+1]
    Rsum = 0
    Lsum = 0
    NL = 0
    NR = 0
    B = 0
    for _ in range(Q):
        query = input().rstrip('\n')
        if query == '2':
            Lmax = -L[0]
            print(Lmax, Lmax * NL - Lsum + Rsum - Lmax * NR + B)
        else:
            _, a, b = query.split()
            a = int(a)
            b = int(b)
            B += b
            if NL != NR:
                Lmax = -L[0]
                Rmin = R[0]
                if a >= Lmax:
                    heappush(R, a)
                    Rsum += a
                    NR += 1
                else:
                    newR = -heappushpop(L, -a)
                    heappush(R, newR)
                    Rsum += newR
                    Lsum += a - newR
                    NR += 1
                    Lmax = -L[0]
            else:
                Rmin = R[0]
                if a <= Rmin:
                    heappush(L, -a)
                    Lsum += a
                    NL += 1
                else:
                    newL = heappushpop(R, a)
                    heappush(L, -newL)
                    Lsum += newL
                    Rsum += a - newL
                    NL += 1


if __name__ == '__main__':
    main()