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

Q=int(input())

que=list(map(int,input().split()))
b=que[2]
a=[que[1]]
min=0
l,r=0,0
j=1
tmp=que[1]
for i in range(Q-1):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        a.insert(  bisect.bisect_left(a,que[1]), que[1] )
        if j%2==0: r+=1
        else: l+=1
        
        if a[l]!=a[r]: min+=abs(tmp-que[1])
        else: min+=abs(tmp-que[1])-abs(a[l]-tmp)
        tmp=a[l]

    elif que[0]==2:
        print(tmp,min+b)

Fixed submission:
import bisect
import heapq 

Q=int(input())

que=list(map(int,input().split()))
b=que[2]
l,r=[-que[1]],[que[1]]
heapq.heapify(l)
heapq.heapify(r)
a=0
tmp=que[1]
j=1
for i in range(Q-1):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        q1=que[1]
        if j%2==0:
            if q1<-l[0]:
                heapq.heappushpop(l,-q1)
            else:
                heapq.heappushpop(r,q1)

        else:
            if q1<-l[0]:
                heapq.heappush(l,-q1)
                heapq.heappush(r,-l[0])
            else:
                heapq.heappush(r,q1)
                heapq.heappush(l,-r[0])
        

        if -l[0]!=r[0]: a+=abs(tmp-q1)
        else: a+=abs(tmp-q1)-abs(-l[0]-tmp)
        tmp=-l[0]

    elif que[0]==2:
        print(tmp,a+b)

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

Q=int(input())

b=0
a=[]
min=0
tmp=0
j=0
for i in range(Q):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        a.insert(  bisect.bisect_left(a,que[1]), que[1] )

        p= bisect.bisect_left(a,tmp)
        if p>j-p:
            min+=abs(que[1]-tmp)-abs(a[p-1]-tmp) 
            tmp=a[p-1]
        elif p==j-p:
            min+=abs(que[1]-tmp)
            tmp=a[p-1]
        else:
            q= bisect.bisect_right(a,tmp)
            if q<j-q:
                min+=abs(que[1]-tmp)-abs(a[q]-tmp) 
                tmp=a[q]
            else:min+=abs(que[1]-tmp)

    elif que[0]==2:
        print(tmp,min+b)

Fixed submission:
import bisect
import heapq 

Q=int(input())

que=list(map(int,input().split()))
b=que[2]
l,r=[-que[1]],[que[1]]
heapq.heapify(l)
heapq.heapify(r)
a=0
tmp=que[1]
j=1
for i in range(Q-1):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        q1=que[1]
        if j%2==0:
            if q1<-l[0]:
                heapq.heappushpop(l,-q1)
            else:
                heapq.heappushpop(r,q1)

        else:
            if q1<-l[0]:
                heapq.heappush(l,-q1)
                heapq.heappush(r,-l[0])
            else:
                heapq.heappush(r,q1)
                heapq.heappush(l,-r[0])
        

        if -l[0]!=r[0]: a+=abs(tmp-q1)
        else: a+=abs(tmp-q1)-abs(-l[0]-tmp)
        tmp=-l[0]

    elif que[0]==2:
        print(tmp,a+b)

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

Q=int(input())

b=0
a=[]
min=0
tmp=0
j=0
for i in range(Q):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        a.insert(  bisect.bisect_left(a,que[1]), que[1] )

        p= bisect.bisect_left(a,tmp)
        q= bisect.bisect_right(a,tmp)
        if p>j-p:
            min+=abs(que[1]-tmp)-abs(a[p-1]-tmp) 
            tmp=a[p-1]
        elif p==j-p:
            min+=abs(que[1]-tmp)
            tmp=a[p-1]

        else:
            q= bisect.bisect_right(a,tmp)
            if q<j-q:
                min+=abs(que[1]-tmp)-abs(a[q]-tmp) 
                tmp=a[q]
            else:min+=abs(que[1]-tmp)

    elif que[0]==2:
        print(tmp,min+b)

Fixed submission:
import bisect
import heapq 

Q=int(input())

que=list(map(int,input().split()))
b=que[2]
l,r=[-que[1]],[que[1]]
heapq.heapify(l)
heapq.heapify(r)
a=0
tmp=que[1]
j=1
for i in range(Q-1):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        q1=que[1]
        if j%2==0:
            if q1<-l[0]:
                heapq.heappushpop(l,-q1)
            else:
                heapq.heappushpop(r,q1)

        else:
            if q1<-l[0]:
                heapq.heappush(l,-q1)
                heapq.heappush(r,-l[0])
            else:
                heapq.heappush(r,q1)
                heapq.heappush(l,-r[0])
        

        if -l[0]!=r[0]: a+=abs(tmp-q1)
        else: a+=abs(tmp-q1)-abs(-l[0]-tmp)
        tmp=-l[0]

    elif que[0]==2:
        print(tmp,a+b)

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

Q=int(input())

b=0
a=[]
min=0
tmp=0
j=0
for i in range(Q):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        a.insert(  bisect.bisect_left(a,que[1]), que[1] )

        p= bisect.bisect_left(a,tmp)
        q= bisect.bisect_right(a,tmp)
        if p>j-p:
            min+=abs(que[1]-tmp)-abs(a[p-1]-tmp) 
            tmp=a[p-1]
        elif p==j-p:
            min+=abs(que[1]-tmp)
            tmp=a[p-1]
        elif q<j-q:
            min+=abs(que[1]-tmp)-abs(a[q]-tmp) 
            tmp=a[q]
        else:

            min+=abs(que[1]-tmp)

    elif que[0]==2:
        print(tmp,min+b)

Fixed submission:
import bisect
import heapq 

Q=int(input())

que=list(map(int,input().split()))
b=que[2]
l,r=[-que[1]],[que[1]]
heapq.heapify(l)
heapq.heapify(r)
a=0
tmp=que[1]
j=1
for i in range(Q-1):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        q1=que[1]
        if j%2==0:
            if q1<-l[0]:
                heapq.heappushpop(l,-q1)
            else:
                heapq.heappushpop(r,q1)

        else:
            if q1<-l[0]:
                heapq.heappush(l,-q1)
                heapq.heappush(r,-l[0])
            else:
                heapq.heappush(r,q1)
                heapq.heappush(l,-r[0])
        

        if -l[0]!=r[0]: a+=abs(tmp-q1)
        else: a+=abs(tmp-q1)-abs(-l[0]-tmp)
        tmp=-l[0]

    elif que[0]==2:
        print(tmp,a+b)