Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()
i = 0
n=input()
S=map(int, raw_input().split())
q=input()
T=map(int, raw_input().split())
#?????????????????????????????????
s=sorted(set(S), key=S.index)
t=sorted(set(T), key=T.index)
ST=s+t
t=set()
m=[x for x in ST if x in t or t.add(x)]
#print ' '.join(map(str, m))
print len(m)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()
i = 0
n=input()
S=map(int, raw_input().split())
q=input()
T=map(int, raw_input().split())
#s=sorted(set(S), key=S.index)
print len(set(S)&set(T))
### BUGGY CODE ###

num = int(input())
p = map(int, input().split())
pList = list(p)

aList = []
ret = "YES"
for i in range(num):
    if pList[i] in aList:
        ret = "NO"
        break
    aList.append(pList[i])

print("{}".format(ret))

### FIXED CODE ###

# C - Distinct or Not
# https://atcoder.jp/contests/abc154/tasks/abc154_c

num = int(input())
p = list(map(int, input().split()))
list.sort(p)

ret = "YES"
for i in range(num-1):
    if p[i] == p[i+1]:
        ret = "NO"
        break

print("{}".format(ret))
### BUGGY CODE ###

count = int(input())
zenbu = []

for x in range(count):
    keihin = input()

    if not keihin in zenbu:
        zenbu.append(keihin)
print(len(zenbu))

### FIXED CODE ###

count = int(input())
zenbu = set()
 
for x in range(count):
    keihin = input()
    zenbu.add(keihin)
print(len(zenbu))
### BUGGY CODE ###

from collections import Counter
H, W, M = map(int, input().split())
h_list = []
w_list = []
bomber = []
for _ in range(M):
    h, w = map(int, input().split())
    h_list.append(h)
    w_list.append(w)
    bomber.append([h, w])
h_cnt = Counter(h_list)
w_cnt = Counter(w_list)
ans = 0
for h_key, h_value in h_cnt.items():
    for w_key, w_value in w_cnt.items():
        tmp = 0
        if [h_key, w_key] in bomber:
            tmp -= 1
        ans = max(ans, h_value + w_value + tmp)
print(ans)

### FIXED CODE ###

H, W, M = map(int, input().split())
h_list = [0 for _ in range(H + 1)]
w_list = [0 for _ in range(W + 1)]
bomb = set([])
for _ in range(M):
    h, w = map(int, input().split())
    h_list[h] += 1
    w_list[w] += 1
    bomb.add((h, w))
h_max = max(h_list)
w_max = max(w_list)
h_index = []
w_index = []
for i in range(H + 1):
    if h_list[i] == h_max:
        h_index.append(i)
for i in range(W + 1):
    if w_list[i] == w_max:
        w_index.append(i)
tmp = -1        
for h in h_index:
    for w in w_index:
        if (h, w) not in bomb:
            tmp = 0
            break
print(h_max + w_max + tmp)
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

n,x,y = map(int,input().split())
graph = [[0 for i in range(n)]for j in range(n)]

for i in range(n-1):
    graph[i][i+1] = 1
    graph[i+1][i] = 1
    
graph[x-1][y-1] = 1
graph[y-1][x-1] = 1

ans = shortest_path(np.array(graph))
u= np.unique(ans)

for i in range(1,n):
    print(int(np.count_nonzero(ans == i)/2))

### FIXED CODE ###

n,x,y = map(int,input().split())
ans = [0]*n
for i in range(1,n+1):
    for j in range(i+1,n+1):
        ans[min(abs(i-j) , abs(i-x)+1+abs(j-y), abs(i-y)+1+abs(j-x)) ]+=1
        
for i in range(1,n):
    print(ans[i])
### BUGGY CODE ###

n = int(input())
s = input()
a = 0
for i in range(n):
    if s[i] == '1':
        a += int(pow(2, n - i - 1))
v = bin(a).count('1')
for i in range(n):
    add = int(pow(2, n - i - 1))
    if s[i] == '1':
        add *= -1
    copy = a + add
    x = v
    if s[i] == '1':
        x -= 1
    else:
        x += 1
    cnt = 1
    if copy == 0:
        cnt = 0
    while x > 0 and copy % x != 0:
        copy %= x
        x = bin(copy).count('1')
        cnt += 1
    print(cnt)
    
        


### FIXED CODE ###

n = int(input())
s = input()
pw, pw1, pw2 = [0] * n, [0] * n, [0] * n
pw[0], pw1[0], pw2[0] = 1, 1, 1
v, mod1, mod2 = 0, 0, 0
for i in range(n):
    if s[i] == '1':
        v += 1
for i in range(1, n):
    pw1[i] = int(pw1[i - 1] * 2) % (v + 1)
    if v >= 2:
        pw2[i] = int(pw2[i - 1] * 2) % (v - 1)
for i in range(n):
    if s[i] == '1':
        mod1 = (mod1 + pw1[n - i - 1]) % (v + 1)
        if v >= 2:
            mod2 = (mod2 + pw2[n - i - 1]) % (v - 1)    
for i in range(n):
    copy, x, cnt = 0, v, 1
    
    if s[i] == '0':
        x += 1
        copy = (mod1 + pw1[n - i - 1]) % x
    else:
        x -= 1
        if x >= 1:
            copy = (mod2 - pw2[n - i - 1]) % x
        else:
            copy = -1
    if copy == -1:
        print(0)
    else:
        x = bin(copy).count('1')
        while copy > 0:
            copy %= x
            x = bin(copy).count('1')
            cnt += 1
        print(cnt)
### BUGGY CODE ###

N=int(input())
*A,=map(int, input().split())

MOD = 10**9+7
class Mint:
    def __init__(self, value=0):
        self.value = value % MOD
        if self.value < 0: self.value += MOD

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, MOD
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        if u < 0: u += MOD
        return u

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.value
    def __neg__(self): return Mint(-self.value)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value += Mint.get_value(other)
        if self.value >= MOD: self.value -= MOD
        return self
    def __add__(self, other):
        new_obj = Mint(self.value)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value -= Mint.get_value(other)
        if self.value < 0: self.value += MOD
        return self
    def __sub__(self, other):
        new_obj = Mint(self.value)
        new_obj -= other
        return new_obj
    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % MOD
        return self
    def __mul__(self, other):
        new_obj = Mint(self.value)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other)
        self *= other.inverse()
        return self
    def __floordiv__(self, other):
        new_obj = Mint(self.value)
        new_obj //= other
        return new_obj
    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other))
        new_obj //= self
        return new_obj

M = 10**3
primes = []
is_prime = [True] * (M+1)
for n in range(2,M+1):
    if not is_prime[n]: continue
    primes.append(n)
    for m in range(2*n,M+1,n): is_prime[m] + False

from collections import defaultdict
D = [defaultdict(int) for _ in range(N)]
cmnd = defaultdict(int)

for i,a in enumerate(A):
    for n in primes:
        while a % n == 0:
            D[i][n] += 1
            a //= n
    if a > 1: D[i][a] += 1
    for k,v in D[i].items():
        cmnd[k] = max(cmnd[k], v)

ans = Mint()
for i in range(N):
    tmp = Mint(1)
    for k,v in cmnd.items():
        tmp *= k**(v-D[i][k])
    ans += tmp

print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))

MOD=10**9+7
def gcd(a,b):
    while b: a,b=b,a%b
    return a
def lcm(a,b): return a*b//gcd(a,b)

LCM=A[:]
num=N
while num>1:
    for i in range(1,num,2):
        LCM[i//2]=lcm(LCM[i-1],LCM[i])
    if num&1:
        LCM[num//2]=LCM[num-1]
    num=(num+1)//2

ans=0
l=LCM[0]%MOD
for a in A:
    ans+=l*pow(a,MOD-2,MOD)
    ans%=MOD

print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
B = sorted(set(A))
ans = 0

for i in range(len(B)):
    m = A.count(B[i])
    if m > 1:
        ans += m*(m-1)//2
        
for i in range(n):
    m = A.count(A[i])
    print(ans + 1 - m)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1

import collections
c = collections.Counter(a)

for i in c.values():
    ans += i*(i-1)//2
    
for i in a:
    print(ans - c[i])
### BUGGY CODE ###


A, B = map(int, input().split())
x = A
for i in range(A + 1, B + 1):
    x = x ^ i

print(x)

### FIXED CODE ###

from operator import xor

A, B = map(int, input().split())


def f(n):
    if n % 2 == 0:
        if n % 4 == 0:
            return n
        else:
            return xor(n, 1)
    else:
        return xor(n, f(n - 1))


print(xor(f(A - 1), f(B)))

# 0,   1,   2,   3,   4,   5,   6,   7
# 000, 001, 010, 011, 100, 101, 110, 111
# 000, 001, 011, 000, 100, 001, 000, 111
# f(A, B) = f(0, A - 1) ^ f(0, B)
# f(0, X) = X ^ (X - 1)
### BUGGY CODE ###

n = int(input())
nums = [input() for i in range(n)]
m = max(nums)

ans=[m if nums.count(m) >=2 or nums[i] != m else sorted(nums)[-2] for i in range(n)]

for i in range(n):
  print(ans[i])

### FIXED CODE ###

n = int(input())
nums = [int(input()) for i in range(n)]
m = max(nums)
m2 = sorted(nums)[-2]
[print(m) if nums[i] != m else print(m2) for i in range(n)]
### BUGGY CODE ###

import collections
N = int(input())
a = list(map(int, input().split()))
cand = collections.Counter(a)
cand_list = cand.most_common(len(set(a)))
ans = 0
for i in range(len(set(a))):
  num = cand_list[i][0]
  count = cand[num]
  if num + 1 in a:
    count += cand[num + 1]
  if num - 1 in a:
    count += cand[num - 1]
  ans = max(ans,count)

print(ans)

### FIXED CODE ###

import collections
N = int(input())
a = list(map(int, input().split()))
cand = collections.Counter(a)
cand_list = cand.most_common(len(set(a)))
ans = 0
for i in range(len(set(a))):
  num = cand_list[i][0]
  count = cand[num] + cand[num + 1] + cand[num - 1]
  ans = max(ans,count)

print(ans)
### BUGGY CODE ###

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))
A.sort()
S=set(A)
B=[]
for i in S:
  a=A[0]
  b=len(A)
  for k in range(b):
    if A[k]!=a:
      j=k
      break
  else:
    j=b
  B.append(j)
  A=A[j:]
B.sort()
# print(B)
C=B[:len(S)-K]
print(sum(C))


### FIXED CODE ###

from collections import Counter

N,K=list(map(int, input().split()))
A=list(map(int, input().split()))

dic = dict(Counter(A))
ls = list(dic.items())
ls.sort(key=lambda x: x[1])

i=0
ans=0
res=len(ls)
while 1:
  if res <= K or i >= N:
    break
  ans += ls[i][1]
  i+=1
  res-=1
print(ans)
### BUGGY CODE ###

n = int(input())
s = input()

r_list = []
g_list = []
b_list = []
for _ in range(n):
    if s[_] == "R":
        r_list.append(_ )
    elif s[_] == "G":
        g_list.append(_ )
    else:
        b_list.append(_ )

count = 0
for r in r_list:
    for g in g_list:
        for b in b_list:
            List = sorted([r, g, b])
            if List[0] + List[2] != List[1] * 2:
                count += 1

print(count)

### FIXED CODE ###

n = int(input())
s = input()

r_list = []
g_list = []
for _ in range(n):
    if s[_] == "R":
        r_list.append(_)
    elif s[_] == "G":
        g_list.append(_)

count = 0
for r in r_list:
    for g in g_list:
        if min(r, g) - abs(r - g) > 0:
            if s[min(r, g) - abs(r - g)] == "B":
                count += 1
        if max(r, g) + abs(r - g) < n:
            if s[max(r, g) + abs(r - g)] == "B":
                count += 1
        if (r + g) % 2 == 0:
            if s[(r + g) // 2] == "B":
                count += 1


print(len(r_list) * len(g_list) * (n - len(r_list) - len(g_list)) - count)
### BUGGY CODE ###

N = int(input())
XY = [list(map(int, input().split())) + [i + 1] for i in range(N)]

dist = []

XY.sort()
for i in range(N - 1):
  dist.append((abs(XY[i][0] - XY[i + 1][0]), (XY[i][2], XY[i + 1][2])))
XY.sort(key = lambda x: x[1])
for i in range(N - 1):
  dist.append((abs(XY[i][1] - XY[i + 1][1]), (XY[i][2], XY[i + 1][2])))
dist.sort()

root = [i for i in range(N + 1)]
comp_size = [1] * (N+1)
 
def root_find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = root_find(y)
    root[x] = z
    return z

def merge(x, y):
  rx = root_find(x)
  ry = root_find(y)
  sx = comp_size[rx]
  sy = comp_size[ry]
  if rx != ry:
    if sx >= sy:
      root[ry] = rx
      comp_size[rx] = sx + sy
    else:
      root[rx] = ry
      comp_size[ry] = sx + sy
      
answer = 0
for d, (a, b) in dist:
  if root_find(a) != root_find(b):
    merge(a, b)
    answer += d

print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

N = int(input())
XY = [list(map(int, input().split())) + [i + 1] for i in range(N)]

dist = []

XY.sort()
for i in range(N - 1):
  dist.append((abs(XY[i][0] - XY[i + 1][0]), (XY[i][2], XY[i + 1][2])))
XY.sort(key = lambda x: x[1])
for i in range(N - 1):
  dist.append((abs(XY[i][1] - XY[i + 1][1]), (XY[i][2], XY[i + 1][2])))
dist.sort()

root = [i for i in range(N + 1)]
comp_size = [1] * (N+1)
 
def root_find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = root_find(y)
    root[x] = z
    return z

def merge(x, y):
  rx = root_find(x)
  ry = root_find(y)
  sx = comp_size[rx]
  sy = comp_size[ry]
  if rx != ry:
    if sx >= sy:
      root[ry] = rx
      comp_size[rx] = sx + sy
    else:
      root[rx] = ry
      comp_size[ry] = sx + sy
      
answer = 0
for d, (a, b) in dist:
  if root_find(a) != root_find(b):
    merge(a, b)
    answer += d

print(answer)
### BUGGY CODE ###

from collections import deque

N,K = map(int,input().split())
a = list(map(int,input().split()))
b = set(a)
c = [a.count(i) for i in b]
d = len(b)
c.sort()
e = deque(c)
ans = 0
for i in e:
    if K >= d:
        break
    ans += i
    d -= 1
print(ans)


### FIXED CODE ###

import sys
import collections
input = sys.stdin.readline

N,K = map(int,input().split())
a = list(map(int,input().split()))
c = collections.Counter(a)
d = len(c)
ans = 0
c_sorted = sorted(c.items(),key = lambda x:x[1])
for i in c_sorted:
    if K >= d:
        break
    ans += i[1]
    d -= 1
print(ans)
### BUGGY CODE ###

S=input()
m=list(map(len,S.split("0")))
while 0 in m:
    m.remove(0)
n=list(map(len,S.split("1")))
while 0 in n:
    n.remove(0)
print(max(sum(m),sum(n)))

### FIXED CODE ###

S=input()
N=K=len(S)
for i in range(1,N):
    if S[i-1]!=S[i]:
        K=min(K,max(i,N-i))
print(K)
### BUGGY CODE ###

from collections import defaultdict

M = 998244353
B = pow(10, 18, M)
N = int(input())

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in e[i]})
    if m:
      g[i] = m
      x = pow(B, i, M)
      sum_g[m] += x
      sum_g[0] -= x
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(set)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].add(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret = ret + sx*sy*sz
  return ret%M


edge = [read_edge() for i in range(3)]

print(solve(N, edge))

### FIXED CODE ###

from collections import defaultdict

M = 998244353
B = 10**18 % M

def mex(s):
  for i in range(max(s)+2):
    if i not in s:
      return i

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  for i in sorted(e.keys(), reverse=True):
    m = mex({g.get(j,0) for j in e[i]})
    if m:
      g[i] = m
      x = pow(B, i, M)
      sum_g[m] += x
      sum_g[0] -= x
  return sum_g

def get_edge():
  M = int(input())
  e = defaultdict(set)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].add(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, x in sum_g[0].items():
    for gy, y in sum_g[1].items():
      gz = gx^gy
      z = sum_g[2][gz]
      ret = (ret + x*y*z)%M
  return ret

N = int(input())
edge = [get_edge() for i in range(3)]

print(solve(N, edge))
### BUGGY CODE ###

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(self.n+1) # 1-indexed

    def init(self, init_val):
        for i, v in enumerate(init_val):
            self.add(i, v)

    def add(self, i, x):
        # i: 0-indexed
        i += 1 # to 1-indexed
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)

    def sum(self, i, j):
        # return sum of [i, j)
        # i, j: 0-indexed
        return self._sum(j) - self._sum(i)

    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & (-i)
        return res

class RangeAddBIT:
    def __init__(self, n):
        self.n = n
        self.bit1 = BIT(n)
        self.bit2 = BIT(n)

    def init(self, init_val):
        self.bit2.init(init_val)

    def add(self, l, r, x):
        # add x to [l, r)
        # l, r: 0-indexed
        self.bit1.add(l, x)
        self.bit1.add(r, -x)
        self.bit2.add(l, -x*l)
        self.bit2.add(r, x*r)

    def sum(self, l, r):
        # return sum of [l, r)
        # l, r: 0-indexed
        return self._sum(r) - self._sum(l)

    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        return self.bit1._sum(i)*i + self.bit2._sum(i)

import sys
import io, os
#input = sys.stdin.buffer.readline
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

def main():
    n, d, a = map(int, input().split())
    XH = []
    for i in range(n):
        x, h = map(int, input().split())
        XH.append((x-d, h))
    XH.sort()
    X = []
    H = []
    for x, h in XH:
        X.append(x)
        H.append(h)

    bit = RangeAddBIT(n+1)
    bit.init(H)
    import bisect
    ans = 0
    for i in range(n):
        h = bit.sum(i, i+1)
        if h > 0:
            q = (h+a-1)//a
            ans += q
            j = bisect.bisect_right(X, X[i]+2*d)
            bit.add(i, j, -q*a)
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

n, d, a = map(int, input().split())
l = [[0, 0] for _ in range(n)]
for i in range(n):
  x, h = map(int, input().split())
  l[i][0] = x
  l[i][1] = h
  
l.sort()
from collections import deque
d = 2*d
q = deque([])
total = 0

ans = 0
for i in range(n):
  x = l[i][0]
  h = l[i][1]
  if q:
    while q[0][0] < x:
      total -= q[0][1]
      q.popleft()
      if not q:
        break
  h -= total
  if h > 0:
    num = (h+a-1)//a
    ans += num
    damage = num*a
    total += damage
    q.append([x+d, damage])

print(ans)
### BUGGY CODE ###

n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
if(len(a)!=n):
  	exit()
for calc in a:
    if(0 in a==True):
        print(0)
        exit()
    ans=ans*a[i]
    i+=1
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n=int(input())
a=input().split()
a=list(map(int,a))
ans=1
if(0 in a):
    print(0)
    exit()

for calc in a:
    ans*=calc
    if(ans>10**18):
        print(-1)
        exit()
if(ans>10**18):
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

for i in range(n):
  ans = 0
  t = 0
  for j in range(n):
    if i == j: continue
    ans += abs(t - a[j])
    t = a[j]
  ans += abs(t)
  print(ans)

### FIXED CODE ###

n = int(input())
a = [0] + list(map(int, input().split())) + [0]

nums = [0]*(n+1)
for i in range(1, n+2): nums[i-1] = abs(a[i] - a[i-1])

ans = sum(nums)
for i in range(1,n+1):
  print(ans - nums[i-1]-nums[i]+abs(a[i+1]-a[i-1]))
### BUGGY CODE ###

h,w = map(int,input().split())
grid = [[c=="."for c in input()]for _ in range(h)]
L,R,U,D = eval("[[0]*(w+2) for _ in range(h+2)],"*4)
for y in range(h):
	for x in range(w):
		if grid[y][x]:
			L[y+1][x+1] = L[y+1][x]+1
		if grid[y][w-x-1]:
			R[y+1][w-x] = R[y+1][w-x+1]+1
for x in range(w):
	for y in range(h):
		if grid[y][x]:
			U[y+1][x+1] = U[y][x+1]+1
		if grid[h-y-1][x]:
			D[h-y][x+1] = D[h-y+1][x+1]+1
a = 0
for y in range(1,h+1):
	for x in range(1,w+1):
		a = max(a, L[y][x] + R[y][x] + U[y][x] + D[y][x] -3)
print(a)

### FIXED CODE ###

t,*grid = open(0)
h,w = map(int,t.split())
L,R,U,D = eval("[[0]*(w+2) for _ in range(h+2)],"*4)
for y in range(h):
	for x in range(w):
		if grid[y][x]==".":
			L[y+1][x+1] = L[y+1][x]+1
		if grid[y][w-x-1]==".":
			R[y+1][w-x] = R[y+1][w-x+1]+1
for x in range(w):
	for y in range(h):
		if grid[y][x]==".":
			U[y+1][x+1] = U[y][x+1]+1
		if grid[h-y-1][x]==".":
			D[h-y][x+1] = D[h-y+1][x+1]+1
a = 0
for y in range(1,h+1):
	for x in range(1,w+1):
		a = max(a, L[y][x] + R[y][x] + U[y][x] + D[y][x] -3)
print(a)
### BUGGY CODE ###

def minus(n):
    return n - 1


n, k, q = map(int, input().split())
points = []
for i in range(n):
    points.append(k)
for i in range(q):
    a = input()
    a = int(a)
    points = list(map(minus, points))
    points[a - 1] += 1
for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

import numpy as np
n, k, q = map(int, input().split())
points = np.full(n, k)
z = np.full(n, 0)
points = points - q
for i in range(q):
    a = int(input())
    z[a - 1] += 1
points = points + z
for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

from heapq import heapify, heappush, heappop
N = int(input())
s = list(map(int,input().split()))
a, b = s[1], s[2]
L = []
R = []
heappush(L,-a)
heappush(R,a)

bsum = b
t = 0
for k in range(N-1):
    s = input()
    if s[0] == "1":
        s = list(map(int,s.split()))
        a = s[1]
        b = s[2]
        bsum += b
        if -L[0] <= a <= R[0]:
            pass
        else:
            t += min(abs(a+L[0]),abs(a-R[0]))
        heappush(L,-a)
        heappush(R,a)
        if -L[0] > R[0]:
            c = heappop(L)
            d = heappop(R)
            heappush(R,-c)
            heappush(L,-d)
    else:
        print(-L[0], t+bsum)

### FIXED CODE ###

from heapq import heappush, heappop
N = int(input())
s = list(map(int,input().split()))
a, b = s[1], s[2]
L = []
R = []
heappush(L,-a)
heappush(R,a)

bsum = b
t = 0
for k in range(N-1):
    s = input()
    if s[0] == "1":
        s = list(map(int,s.split()))
        a = s[1]
        b = s[2]
        bsum += b
        if -L[0] <= a <= R[0]:
            pass
        else:
            t += min(abs(a+L[0]),abs(a-R[0]))
        heappush(L,-a)
        heappush(R,a)
        if -L[0] > R[0]:
            c = heappop(L)
            d = heappop(R)
            heappush(R,-c)
            heappush(L,-d)
    else:
        print(-L[0], t+bsum)