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

import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        n = IO_for_Contest.read_int()
        t = []
        a = []
        for i in range(n):
            buf = IO_for_Contest.read_n_int(2)
            t.append(buf[0])
            a.append(buf[1])
        return t, a

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def solve():
    buf = IO_for_Contest.read_from_input()
    t = buf[0]
    a = buf[1]
    min_number_of_vote = get_min_number_of_vote(t, a)
    print(sum(min_number_of_vote))


def get_min_number_of_vote(t, a):
    vote_t = 1
    vote_a = 1
    for i in range(len(t)):
        buf = get_estimate_of_next_vote(vote_t, vote_a, t[i], a[i])
        # print(buf)
        vote_t = buf[0]
        vote_a = buf[1]
    return vote_t, vote_a


def get_estimate_of_next_vote(vote_t, vote_a, ratio_t, ratio_a):
    # simple case
    if vote_t % ratio_t == 0 and vote_a % ratio_a == 0:
        if vote_t // ratio_t == vote_a // ratio_a:
            return vote_t, vote_a
    offset = 0
    while True:
        new_vote_t = vote_t + offset
        if new_vote_t % ratio_t == 0:
            if (new_vote_t // ratio_t) * ratio_a >= vote_a:
                return new_vote_t, (new_vote_t // ratio_t) * ratio_a
            else:
                offset += ratio_t
        else:
            offset += 1

if __name__ == '__main__':
    # doctest.testmod()
    solve()


### FIXED CODE ###

def solve():
    list_t_and_a = read()
    result = think(list_t_and_a)
    write(result)


def read():
    n = read_int(1)[0]
    list_t_and_a = []
    for _ in range(n):
        list_t_and_a.append(read_int(2))
    return list_t_and_a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(list_t_and_a):
    n = len(list_t_and_a)
    vote_t, vote_a = list_t_and_a[0][0], list_t_and_a[0][1]
    for i in range(1, n):
        ti, ai = list_t_and_a[i][0], list_t_and_a[i][1]
        ratio_t = vote_t // ti
        if vote_t % ti != 0:
            ratio_t += 1
        ratio_a = vote_a // ai
        if vote_a % ai != 0:
            ratio_a += 1
        ratio = max(ratio_t, ratio_a)
        vote_t = ratio * ti
        vote_a = ratio * ai
    return vote_t + vote_a


def expected_lower_value_than_actual(actual, expected):
    return actual > expected


def write(result):
    print(result)


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]

islands = [set() for _ in range(n + 1)]

for _ in range(m):
    ab = [int(x) for x in input().split()]
    islands[min(ab)].add(max(ab))

ans = 0

for i in range(1, n):
    if i + 1 in islands[i]:
        ans += 1
    else:
        for j in islands[i]:
            islands[i + 1].add(j)

ans += len(islands[n])

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]

islands = [set() for _ in range(n + 1)]

for _ in range(m):
    ab = [int(x) for x in input().split()]
    islands[min(ab)].add(max(ab))

ans = 0

for i in range(1, n):
    if i + 1 in islands[i]:
        ans += 1
    elif len(islands[i]) > 0:
        islands[i + 1].add(min(islands[i]))

ans += len(islands[n])

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

n,m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
bc = [[int(i) for i in input().split()] for i in range(m)]

for b,c in bc:
    a.extend([c]*b)

print(sum(sorted(a,reverse=True)[:n]))

### FIXED CODE ###

# 高速版input
import sys
input = sys.stdin.readline

n,m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
bc = [[int(i) for i in input().split()] for i in range(m)]

x = []
for b,c in sorted(bc, key=lambda x: x[1], reverse=True):
    x.extend([c]*b)
    if len(x) > n:
        break
        
a.extend(x)
print(sum(sorted(a,reverse=True)[:n]))
### BUGGY CODE ###


N = int(input())
A = list(map(int,input().split()))
lcm = A[0]
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

for i in range(1,N):
    lcm = (lcm*A[i])//gcd(lcm,A[i])
MOD = 10**9+7
ans = 0
for a in A:
    b = lcm//a
    ans += b
    ans %= MOD
print(ans)

### FIXED CODE ###

from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
lcm = a[0]
for i in range(1,n):
  lcm = lcm*a[i] // gcd(lcm,a[i])
mod=pow(10,9)+7
lcm%=mod
ans=0
for x in a:
  ans+=pow(x,mod-2,mod)
  ans%=mod
print(ans*lcm%mod)
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
lis=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  print((len(s[lis[i][0]-1:lis[i][1]])-len(s[lis[i][0]-1:lis[i][1]].replace('AC','')))//2)

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
lis=[list(map(int,input().split())) for i in range(q)]
g=[0]*n
cnt=0
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    cnt+=1
    g[i+1]=cnt
  else:
    g[i+1]=cnt

for i in range(q):
  print(g[lis[i][1]-1]-g[lis[i][0]-1])
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
H = [int(h) for h in input().split()]
H = np.array(H)

dp = np.array([0]*(N+1))

for n in range(1,N):
    k = np.array([i for i in range(1, K+1)])
    dp[n] = np.amin(dp[np.maximum(n-k, 0)] + np.abs(H[n]-H[np.maximum(n-k, 0)]))

a = 0
print(dp[N-1])

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
# H = np.array([int(h) for h in input().split()])
H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)
k = np.array([i for i in range(1, K+1)])

for n in range(1, N):
    start = max(n-K, 0)
    #if n < K:
    #   dp[n] = np.amin(dp[start] + np.abs(H[n]-H[start]))
    #else:
    #   dp[n] = np.min(dp[n - k] + np.abs(H[n] - H[n - k]))
    dp[n] = np.min(dp[start:n] + np.abs(H[n]-H[start:n]))

print(dp[N-1])
### BUGGY CODE ###

N = int(input())
ans = 0

for i in range(1,N):
    for j in range(1,N):
        if i*j<N:
            ans+=1

print(ans)

### FIXED CODE ###

N = int(input())
ans = 0

for i in range(1,N):
    for j in range(1,N):
        if i*j<N:
            ans+=1
        else:
            break

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

# TODO:累積和を使った手法

int_n = int(input())
str_s = input()

changes = 999999

for i in range(int_n):
    member_left = str_s[:i]
    member_right = str_s[i + 1:]
    # print(i)
    # print("left:" + member_left, "right:" + member_right)

    this_change = (member_left.count("W") + member_right.count("E"))

    changes = this_change if (changes >= this_change) else changes

print(changes)





### FIXED CODE ###

int_n = int(input())
str_s = input()

li_west = [0] * int_n
for i in range(int_n - 1):
    if str_s[i] == 'W':
        li_west[i + 1] = li_west[i] + 1
    else:
        li_west[i + 1] = li_west[i]
li_east = [0] * int_n

for i in range(int_n - 1, 0, -1):
    if str_s[i] == 'E':
        li_east[i - 1] = li_east[i] + 1
    else:
        li_east[i - 1] = li_east[i]

minimum = 999999
for i in range(int_n):
    int_w = li_west[i] + li_east[i]
    minimum = min(minimum, int_w)

print(minimum)
### BUGGY CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, q = na()
s = input()
index = []
for i in range(len(s)):
    if s[i:i+2] == "AC":
        index.append(i)
for i in range(q):
    l, r = na()
    print(len([i for i in index if l-1<= i <= r-1 and l-1<= i+1 <=r-1]))

### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, q = na()
s = input()
ct = [0] * n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        ct[i+1] = 1
for i in range(n-1):
    ct[i+1] += ct[i]
for i in range(q):
    l, r = na()
    l -= 1
    r -= 1
    print(ct[r] - ct[l])
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
fs=0
a=sorted(a)
from itertools import combinations
#listからkコ選ぶ組み合わせ
for i in combinations(a,k):
    fs+=(i[-1]-i[0])%(10**9+7)
    if fs>=10**9+7:
        fs=fs%(10**9+7)
print(fs)   

### FIXED CODE ###

def pre_c(n, mod):
    f = [0] * (n + 1)
    g = [0] * (n + 1)
    for i in range(n + 1):
        if i == 0:
            f[i] = 1
            g[i] = 1
        else:
            f[i] = (f[i - 1] * i) % mod
            g[i] = pow(f[i], mod - 2, mod)

    return f, g

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mod = 10 ** 9 + 7
f, g = pre_c(n, mod)

ans = 0
for i in range(n - k + 1):
    min_temp = a[i] * f[n - i - 1] * g[k - 1] * g[n - i - 1 - k + 1] % mod
    max_temp = a[n - i - 1] * f[n - i - 1] * g[k - 1] * g[n - i - 1 - k + 1] % mod

    ans = (ans + (max_temp - min_temp) % mod ) %mod
print(ans)
### BUGGY CODE ###

N = int(input())
A = [] 
numbers = []
for _ in range(N):
    A.append(int(input()))

for i in range(N):
    if A[i] in numbers:
        numbers.remove(A[i])
    else:
        numbers.append(A[i])

print(len(numbers))

### FIXED CODE ###

import collections
N = int(input())
A = [] 
for _ in range(N):
    A.append(int(input()))
answer = 0
numbers = collections.Counter(A)

for i in numbers.values():
    answer += i % 2

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

import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    input = readline
    mod = 10 ** 9 + 7
    H, W, M = map(int, input().split())
    Hlist = [0] * H
    Wlist = [0] * W
    hw = []

    for _ in range(M):
        h, w = map(int, input().split())
        Hlist[h-1] += 1
        Wlist[w-1] += 1
        hw.append([h, w])


    hmax = [i for i, x in enumerate(Hlist) if x == max(Hlist)]
    wmax = [i for i, x in enumerate(Wlist) if x == max(Wlist)]
    hmaxset = set(hmax)
    wmaxset = set(wmax)

    flag = False
    count = 0
    for hh in hw:
        h = hh[0] - 1
        w = hh[1] - 1
        if h in hmaxset and w in wmaxset:
            count += 1
    if count != len(hmax) * len(wmax):
        flag = True

    if flag:
        print(Hlist[hmax[0]] + Wlist[wmax[0]])
    else:
        print(Hlist[hmax[0]] + Wlist[wmax[0]] - 1)





if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    input = readline
    mod = 10 ** 9 + 7
    H, W, M = map(int, input().split())
    Hlist = collections.defaultdict(int)
    Wlist = collections.defaultdict(int)
    hw = []

    for _ in range(M):
        h, w = map(int, input().split())
        Hlist[h-1] += 1
        Wlist[w-1] += 1
        hw.append([h, w])

    #hmax = [i for i, x in enumerate(Hlist) if x == max(Hlist)]
    #wmax = [i for i, x in enumerate(Wlist) if x == max(Wlist)]

    Hlist = sorted(Hlist.items(), key=lambda x: x[1], reverse=True)
    Wlist = sorted(Wlist.items(), key=lambda x: x[1], reverse=True)

    hmaxset = set()
    wmaxset = set()

    maxH = Hlist[0][1]
    for k, v in Hlist:
        if v != maxH:
            break
        else:
            hmaxset.add(k)

    maxW = Wlist[0][1]
    for k, v in Wlist:
        if v != maxW:
            break
        else:
            wmaxset.add(k)


    flag = False
    count = 0
    for hh in hw:
        h = hh[0] - 1
        w = hh[1] - 1
        if h in hmaxset and w in wmaxset:
            count += 1

    lenhmax = len(hmaxset)
    lenwmax = len(wmaxset)

    if count != lenhmax * lenwmax:
        flag = True

    if flag:
        print(maxH + maxW)
    else:
        print(maxH + maxW - 1)





if __name__ == '__main__':
    solve()
### BUGGY CODE ###

import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[::-1][i])*10**i)%2019)
u2 = collections.Counter(u)
print(sum([int(i*(i-1)/2) for i in u2.values()]))

### FIXED CODE ###

import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

for i in range(N): A[i] = format(A[i], "#062b")

#print(*A,sep="\n")
nijou = 1 #二乗計算を高速化するため
xorsum = 0
for i in range(60):
    count0 = 0
    count1 = 0
    for j in range(N):
        if A[j][-(i+1)] == "0":
            count0 += 1
        else:
            count1 += 1
    xorsum += ((count0*count1)%mod)*nijou%mod
    nijou *= 2

print(xorsum%mod)



### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
xorsum = 0
for i in range(60):
  c1 = sum([1 for a in A if (a >> i) & 1]) #
  xorsum += (c1*(N-c1)*(1<<i))
  xorsum = xorsum%mod
print(xorsum%mod)
### BUGGY CODE ###

import random

D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

T = []
t = 0
for d in range(D):
    t = int(random.uniform(1,27))
    T.append(t)

# print(*T,sep='\n')

score = 0
t = 0
for d in range(D):
    t = T[d] - 1
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[i]*((d+1) - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
# print(score)

for _ in range(10000):

    TT = []
    for d in range(D):
        t = int(random.uniform(1,27))
        TT.append(t)

    now = 0
    t = 0
    for d in range(D):
        t = TT[d] - 1
        O[d][t] = 1
        dw = 0
        for i in range(26):
            dw += C[i]*((d+1) - last(d,i))
        A[d][t] = S[d][t] - dw
        now += A[d][t]
    if score < now:
        score = now
        T = TT

# print(score)

print(*T,sep='\n')


### FIXED CODE ###

D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]

# print(D)
# print(C)
# print(*S,sep='\n')

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

score = 0
t = 0
for d in range(D):
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[t]*(d - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
    print(t+1)
    t = (t+1) % 26
# print(score)

# t = 0
# for d in range(D):
#     O[d][t] = 1
#     dw = 0
#     for i in range(26):
#         dw += C[t]*(d - last(d,i))
#     A[d][t] = S[d][t] - dw
#     print(t)
#     t = (t+1) % 26

# for d in range(D):
#     s = 0
#     for t in range(26):
#         s += C[t]*(d - last(d,t))
#     print(s)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    k = int(input())
    n = len(S)

    SS = set()
    for i in range(n):
        ss = S[i]
        SS.add(ss)
        for j in range(i + 1, n):
            ss += S[j]
            SS.add(ss)
    SS = sorted(list(SS))
    print(SS[k - 1])


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys
from heapq import heapify, heappop

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    k = int(input())
    n = len(S)

    SS = set()
    for i in range(n):
        ss = S[i]
        SS.add(ss)
        for j in range(i + 1, min(n, i + k)):
            ss += S[j]
            SS.add(ss)

    SS = list(SS)
    heapify(SS)
    for _ in range(k):
        res = heappop(SS)
    print(res)


if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N=int(input())
a = []
for _ in range(N):
    a.append(int(input()))
found = [0]*N

steps = 0
i = 0
found[i] = 1
while True:
    j = a[i] - 1
    if found[j] == 1:
        print(-1)
        exit()
    steps += 1
    i = j
    if i == 1:
        print(steps)
        exit()


### FIXED CODE ###

import sys
input = sys.stdin.readline

N=int(input())
a = []
for _ in range(N):
    a.append(int(input()))
found = [0]*N

steps = 0
i = 0
found[i] = 1
while True:
    j = a[i] - 1
    if found[j] == 1:
        print(-1)
        exit()
    steps += 1
    i = j
    found[i] = 1
    if i == 1:
        print(steps)
        exit()
### BUGGY CODE ###

n,x,y = map(int,input().split())
dist = []

for i in range(1,n):
    for j in range(i+1,n+1):
        dist.append(min(j - i,abs(i-x) + 1 + abs(y-j),abs(y-i)+ 1 + abs(j-x)))

for i in range(1,n):
    print(dist.count(i))

### FIXED CODE ###

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

for i in range(1,n):
    for j in range(i+1,n+1):
        dist[min(j - i,abs(i-x) + 1 + abs(y-j),abs(y-i)+ 1 + abs(j-x))][0] += 1

for i in range(1,n):
    print(dist[i][0])
### BUGGY CODE ###


N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    ans.pop(0)
    ans.append(V[n])
    max_v = max(max_v, sum(ans))
print(max_v)

### FIXED CODE ###

N, K=map(int, input().split())
Pn=list(map(int, input().split()))
V = [0] * N
ans = [0] * K
max_v = 0
sum_v = 0
for n in range(N):
    V[n] = (0.5*Pn[n]*(Pn[n]+1))/Pn[n]
    if n < K:
        sum_v += V[n]
        max_v = sum_v
    else:
        sum_v = sum_v - V[n-K] + V[n]
        max_v = max(max_v, sum_v)
print(max_v)
### BUGGY CODE ###

N, K = [int(nk) for nk in input().split()]

ans = 0
# a+b=pK b+c=qK c+a=rK
for p in range(1, ((2*N)//K)+1):#1<=p<=(2*N)//K
  for q in range(1, ((2*N)//K)+1):
    for r in range(1, ((2*N)//K)+1):
      a = (( p-q+r)*K)/2
      b = (( p+q-r)*K)/2
      c = ((-p+q+r)*K)/2
      if b < 1:
        break
      elif a > N or c > N:
        break
      elif b > N:
        continue
      elif a < 1 or c < 1:
        continue
      elif a == int(a) and b == int(b) and c == int(c):
        ans += 1
        
print(ans)

### FIXED CODE ###

N, K = [int(nk) for nk in input().split()]

if K % 2 == 1:
  print((N//K)**3)
else:
  ans1 = (N//K)**3
  ans2 = ((N-(K//2))//K + 1)**3
  print(ans1 + ans2)
### BUGGY CODE ###

n,m=map(int, input().split())
a=[int(x) for x in input().split()]

i=0
while m>0:
    a.sort(reverse=True)
    a[0]=a[0]/2
    m-=1
a=[int(x) for x in a]
print(sum(a))

### FIXED CODE ###

n,m=map(int, input().split())
a=[int(x) for x in input().split()]
a=[-1*x for x in a]

import heapq

heapq.heapify(a)

for i in range(m):
    max_value = heapq.heappop(a) #最大値の取得
    heapq.heappush(a, (max_value/2)) #半額にして-1倍してからキューに戻す

a=[-1*x for x in a]
a=[int(x) for x in a]
print(sum(a))
### BUGGY CODE ###

h, w = list(map(int, input().split()))
 
s = []
for i in range(h):
    line = input()
    s.append(line)
 
ans = []
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        d = [[1<<10 for x in range(w)] for y in range(h)]
 
        stack = []
        stack.append((i, j))
        d[i][j] = 0
        while stack:
            y, x = stack.pop()
            if y > 0 and s[y-1][x] == '.' and d[y-1][x] > d[y][x]+1:
                d[y-1][x] = d[y][x] + 1
                stack.append((y-1, x))
            if x < w-1 and s[y][x+1] == '.' and d[y][x+1] > d[y][x]+1:
                d[y][x+1] = d[y][x] + 1
                stack.append((y, x+1))
            if y < h-1 and s[y+1][x] == '.' and d[y+1][x] > d[y][x]+1:
                d[y+1][x] = d[y][x] + 1
                stack.append((y+1, x))
            if x > 0 and s[y][x-1] == '.' and d[y][x-1] > d[y][x]+1:
                d[y][x-1] = d[y][x] + 1
                stack.append((y, x-1))
        ma = 0
        for y in range(h):
            for x in range(w):
                if d[y][x] != 1024 and d[y][x] > ma:
                    ma = d[y][x]

        ans.append(ma)
ans.sort()
print(ans[-1])


### FIXED CODE ###

import collections
h, w = list(map(int, input().split()))

s = []
for i in range(h):
    line = input()
    s.append(line)

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        d = [[False for x in range(w)] for y in range(h)]

        stack = collections.deque()
        stack.append((i, j, 0))
        d[i][j] = True
        while stack:
            y, x, score = stack.popleft()
            if y > 0 and s[y-1][x] == '.' and not d[y-1][x]:
                stack.append((y-1, x, score+1))
                d[y-1][x] = True
            if x < w-1 and s[y][x+1] == '.' and not d[y][x+1]:
                stack.append((y, x+1, score+1))
                d[y][x+1] = True
            if y < h-1 and s[y+1][x] == '.' and not d[y+1][x]:
                stack.append((y+1, x, score+1))
                d[y+1][x] = True
            if x > 0 and s[y][x-1] == '.' and not d[y][x-1]:
                stack.append((y, x-1, score+1))
                d[y][x-1] = True
            if score > ans:
                ans = score
print(ans)
### BUGGY CODE ###

n = int(input())
x = [int(input()) for i in range(n)]
y = list(set(x))
cnt = 0
for i in range(len(y)):
    if x.count(y[i]) % 2 == 1:
        cnt += 1
print(cnt)

### FIXED CODE ###

import collections
n = int(input())
x = [int(input()) for i in range(n)]
c = collections.Counter(x)
cc = list(c.values())
cnt = 0
for i in range(len(cc)):
    if cc[i] % 2 == 1:
        cnt += 1
print(cnt)