Harryxun/stf_run huggingface dataset:
#inputは文字列として取得
input1=input()
input2=input()
#splitする必要がある
input2=input2.split(" ")

N=int(input1)
D=[int(s) for s in input2]

dp=[[0] * max(D) for i in range(max(D))]

def pow(a,b):
    
    if dp[a-1][b-1]!=0:
        return dp[a-1][b-1]

    else:
        if b==1:
            return a
        else:
            ans=pow(a,b-1)*a
            ans=ans%998244353
            dp[a-1][b-1]=ans
            return ans

ans=None

if D.count(0)==1 and D[0]==0:

    mul=1
    n=1

    for i in range(1,max(D)+1):
        m=D.count(i)
        mul*=pow(n,m)
        n=m
    
    ans=mul%998244353

else:
    ans=0

print(int(ans))

### FIXED CODE ###

#inputは文字列として取得
input1=input()
input2=input()
#splitする必要がある
input2=input2.split(" ")

N=int(input1)
D=[int(s) for s in input2]

ans=None


if D.count(0)==1 and D[0]==0:

    L=[0]*(max(D)+1)

    for i in range(len(D)):
        L[D[i]]+=1

    mul=1

    for i in range(len(L)-1):
        mul*=L[i]**L[i+1]%998244353
    
    ans=mul%998244353

else:
    ans=0

print(int(ans))
S = input()
N = len(S)
K = int(input())

MOD = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

# 必要なだけforを回す
for i in range(2, 6):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# nCr n個から重複を許さずr個の組み合わせを選ぶ
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD

def rec(i, k, isSmaller):
    if i == N:
        if k == 0:
            return 1
        else:
            return 0
    
    if k == 0:
        return 1
    
    if isSmaller:
        return cmb(N-i, k) * pow(9, k)
    else:
        if S[i] == '0':
            return rec(i+1, k, False)
        else:
            zero = rec(i+1, k, True)
            between = rec(i+1, k-1, True) * (int(S[i]) - 1)
            same = rec(i+1, k-1, False)
            return zero + between + same

print(rec(0, K, False))


### FIXED CODE ###

S = input()
N = len(S)
K = int(input())

MOD = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

# 必要なだけforを回す
for i in range(2, 10 ** 6):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# nCr n個から重複を許さずr個の組み合わせを選ぶ
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD

def rec(i, k, isSmaller):
    if i == N:
        if k == 0:
            return 1
        else:
            return 0
    
    if k == 0:
        return 1
    
    if isSmaller:
        return cmb(N-i, k) * pow(9, k)
    else:
        if S[i] == '0':
            return rec(i+1, k, False)
        else:
            zero = rec(i+1, k, True)
            between = rec(i+1, k-1, True) * (int(S[i]) - 1)
            same = rec(i+1, k-1, False)
            return zero + between + same

print(rec(0, K, False))
s=int(input())
ans=0
for i in range(4):
  if s[i]=="+":
    ans+=1
  else:
    ans-=1
print(ans)

### FIXED CODE ###

s=input()
ans=0
for i in range(4):
  if s[i]=="+":
    ans+=1
  else:
    ans-=1
print(ans)
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
delta = 10*10**9

hl_s = sorted(hl, reverse=True)

if n > 1000:
    if hl_s[n//2] > (hl_s[0] + hl_s[n])//2: #中央値＞平均値
        hl_s = hl_s[:n//2]
    else:
        hl_s = hl_s[n//2:]

for i in range(len(hl_s)-k+1):
    h_max = max(hl_s[i:i+k])
    h_min = min(hl_s[i:i+k])
    if delta > (h_max - h_min):
        delta = h_max - h_min
    if delta == 0:
        break

print(delta)

### FIXED CODE ###

n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
hl.sort()

h_min = min(hl[i+k-1] - hl[i] for i in range(n-k+1))
print(h_min)
N, M = map(int, input().split())
a_n = list(map(int, input().split()))
a_n = [int(a_n[i]*1/2) for i in range(len(a_n))]
 
def lcm(lis):
    from fractions import gcd
    x = lis[0]
    for i in range(1, len(lis)):
        x = (x * lis[i]) // gcd(x, lis[i])
    return x
res = lcm(a_n)

count = 0
for i in range(len(M)):
  count += 1
  if res * (2 * i + 1) > M:
    break

print(count)

### FIXED CODE ###

N,M = map(int, input().split())
a_n = list(map(int, input().split()))
g = a_n.copy()
 
while not any(x%2 for x in g): g = [x//2 for x in g]
if not all(x%2 for x in g): print(0); exit(0)
def gcd(a,b):
  while b: a,b = b,a%b
  return a
lcm = lambda a,b: a*b//gcd(a,b)
tot = 1
for x in a_n: tot = lcm(tot,x//2)
print((M//tot+1)//2)
def gcd(a, b):
    while a > 0:
        a, b = b, a%b
    return b

n, x = map(int, input().split())
town = list(map(int, input().split()))

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

### FIXED CODE ###

from fractions import gcd
from functools import reduce

n, x = map(int, input().split())
town = map(int, input().split())

dist = map(lambda y: abs(x - y), town)
res = reduce(gcd, dist)
print(res)
n = int(input())
count = 0
card = {"S": card_(), "H": card_(), "C": card_(), "D": card_()}
while count < n:
	i = list(input().split(" "))
	card[i[0]] -= {int(i[1])}
	count += 1

mark = ["S", "H", "C", "D"]
for m in mark:
	for c in sorted(card[m]):
		print("%s %d" % (m, c))

### FIXED CODE ###

card_ = lambda:set([i for i in range(1, 14)])
n = int(input())
count = 0
card = {"S": card_(), "H": card_(), "C": card_(), "D": card_()}
while count < n:
    i = list(input().split(" "))
    card[i[0]] -= {int(i[1])}
    count += 1
 
mark = ["S", "H", "C", "D"]
for m in mark:
    for c in sorted(card[m]):
        print("%s %d" % (m, c))
N,K=map(int,input().split())
H=[int(i) for i in input().split()]
H.append(0)
H.sort()
for _ in range(K):
  H.pop()
print(sum(H))

### FIXED CODE ###

#ABC153-C
N,K=map(int,input().split())
H=[int(i) for i in input().split()]
H.sort(reverse=True)
print(sum(H[K:]))
[a,b]=list(map(int,(input().split())))
if a*b=15:
  print("*")
else:
  if a+b=15:
    print("+")
    else:
      print("x")

### FIXED CODE ###

[a,b]=map(int,input().split())
if a*b==15:
  print("*")
else:
  if a+b==15:
    print("+")
  else:
    print("x")
import sys

input = sys.stdin.readline


class Node:
    def __init__(self, id):
        self.id = id
        self.next = []
        self.val = 0

    def set_node(self, node):
        self.next.append(node)


def add_val(node, val):
    global tree
    node.val += val
    if not node.next:
        return
    for i in node.next:
        add_val(tree[i], val)


n, q = map(int, input().split())
tree = [Node(id) for id in range(n + 1)]
query = [0 for _ in range(n + 1)]

for i in range(n - 1):
    a, b = map(int, input().split())
    tree[a].set_node(b)

for i in range(q):
    p, x = map(int, input().split())
    query[p] += x

for i in range(n):
    val = query[i]
    if val != 0:
        add_val(tree[i], val)

print(*[tree[i].val for i in range(1, n + 1)])


### FIXED CODE ###

import sys

input = sys.stdin.readline


class Node:
    def __init__(self, parent_id=None):
        self.val = 0
        self.parent_id = parent_id


n, q = map(int, input().split())
tree = [Node() for _ in range(n)]

for _ in range(1, n):
    a, b = map(int, input().split())
    tree[b - 1].parent_id = a - 1

for _ in range(q):
    p, x = map(int, input().split())
    tree[p - 1].val += x

for i in range(1, n):
    tree[i].val += tree[tree[i].parent_id].val

print(*[node.val for node in tree])
s1,s2,s3=map(str,input().split(","))
print(S1,S2,S3)


### FIXED CODE ###

s1,s2,s3=map(str,input().split(","))
print(s1,s2,s3)
N = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)

HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))
    

### FIXED CODE ###


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

minX = min(X)
maxX = max(X)
if minX==maxX:
    print(0)
    quit()

HP = []
for p in range(minX, maxX):
    hp = 0
    for x in X:
        hp += (x-p)**2
    HP.append(hp)

print(min(HP))
s = input()
t = input()

for i in np.flip(np.arange(len(t))):
    if t[:i] in s:
        print(len(t)-i)
        break
    else:
        print(len(t))

### FIXED CODE ###

import numpy as np
s = input()
t = input()
strs = []
t_size = len(t)
for i in np.arange(len(s)-len(t)+1):
    strs.append(s[i:i+t_size])
n = 0
max_n = 0
for ss in strs:
    for i in np.arange(len(t)):
        if t[i]==ss[i]:
            n += 1
        if max_n < n:
            max_n = n
    n = 0
print(len(t)-max_n)
S=input()
for i in range(len(S)):
  S[i]=x
print(S)
  

### FIXED CODE ###

S=input()
print("x"*len(S))
n, k = map(int, input().split())

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

a.sort(reverse=True)

print(sum(a[:k])

### FIXED CODE ###

n, k = map(int, input().split())

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

a.sort(reverse=True)

print(sum(a[:k]))
word = input()

flag = True
if len(word)%2 == 1:
    flag = False

wordset = set(word)
leng = len(wordset)
i = 0
while flag and (i<leng):
    if word.count(wordset[i])%2 == 1:
        flag = False
        break
    i += 1
if flag:print("Yes")
else: print("No")


### FIXED CODE ###

word = input()

flag = True
if len(word)%2 == 1:
    flag = False

wordset = set(word)
leng = len(wordset)
for s in wordset:
    if word.count(s)%2 == 1:
        flag = False
        break
if flag:print("Yes")
else: print("No")
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        nc = (500 * i + 100 * j) // 50
        if nc < 0 || c < nc:
            continue
        ans += 1

print(ans)


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        nc = (x - 500*i - 100*j) // 50
        if nc < 0 or c < nc:
            continue
        ans += 1

print(ans)
from sympy import divisor_count
n = int(input)
count = 0
for c in range(1, n):
    count += divisor_count(c)
print(count)


### FIXED CODE ###

n = int(input()) - 1
lst = [n // k for k in range(1, int(n**0.5+1))]
print(2 * sum(lst) - int(n**0.5)**2)
a[0] = input()
a[1] = input()
print (a[1] + a[0])

### FIXED CODE ###

L,R = input().split()
k = R + L
print (k)
a,b=map(int,input().split())
if a=="H" and b=="H":
    print("H")
elif a=="D" and b=="D":
    print("H")
else:
    print("D")


### FIXED CODE ###

a,b=input().split()
if a=="H" and b=="H":
    print("H")
elif a=="D" and b=="D":
    print("H")
else:
    print("D")
n=int(input())
s=list(str(n))
t=0
for i in range(len(s)):
  t+=s[i]
if n%s==0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=int(input())
s=list(str(n))
t=0
for i in range(len(s)):
  t+=int(s[i])
if n%t==0:
  print('Yes')
else:
  print('No')
N,X = map(int,input().split())
finished_dic ={} 
def f(N):
    if(N == 0):
        return 'P'
    else:
        if(N in finished_dic):
            return finished_dic[N]
        else:
            finished_dic[N] = ('B' + f(N-1) + 'P' + f(N-1) + 'B')
            return finished_dic[N]
burger = f(N)
print(burger[0:X].count('P'))

### FIXED CODE ###

N,X = map(int,input().split())
bg_cnt = [1]
pan_cnt = [1]
for i in range(N):
    bg_cnt.append(bg_cnt[i] * 2 + 3)
    pan_cnt.append(pan_cnt[i] * 2 + 1)

def f(N,X):
    if N == 0:
        return 1
    elif X == 1:
        return 0
    elif X <= 1 + bg_cnt[N-1]:
        return f(N-1,X-1)
    elif X == 2 + bg_cnt[N-1]:
        return 1 + f(N-1,X-1)
    else:
        return pan_cnt[N-1] + 1 + f(N-1,X-2-bg_cnt[N-1])    
print(f(N,X))
n, m = map(int, input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())

up = [0]*(m+1)
if m == 0:
  up[0] = n
else:
  up[0] = a[0]-1
  up[m] = n - a[m-1]-1
  for i in range(m-1):
    up[i+1] = a[i+1]-a[i]-2

ans = 1
if -1 in up:
  ans = 0
else:
  f = [0]*(max(up)+1)
  f[0] = 1
  f[1] = 1
  for i in range(2, max(up)+1):
    f[i] = f[i-1] + f[i-2]
  for i in range(m+1):
    ans *= f[up[i]]

print(ans % 1000000007)

### FIXED CODE ###

n, m = map(int, input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())

up = [0]*(m+1)
if m == 0:
  up[0] = n
else:
  up[0] = a[0]-1
  up[m] = n - a[m-1]-1
  for i in range(m-1):
    up[i+1] = a[i+1]-a[i]-2

ans = 1
if -1 in up:
  ans = 0
else:
  f = [0]*(max(up)+1)
  f[0] = 1
  if max(up) > 0:
    f[1] = 1
    for i in range(2, max(up)+1):
      f[i] = f[i-1] + f[i-2]
  for i in range(m+1):
    ans *= f[up[i]]

print(ans % 1000000007)
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n) :
    for j in range(i+1, n) :
        for k in range(n) :
            if i == k or j == k:
                continue
            
            d = A[i][k] + A[k][j]
            if d == A[i][j] :
                ans += d
            elif d < A[i][j] :
                print(-1)
                exit()

print(ans)

### FIXED CODE ###

a,b,c,d,e,f = map(int, input().split())

w = [i+j for i in range(0,f+1,100*a) for j in range(0,f+1,100*b) if i+j <= f]
s = [i+j for i in range(0,f+1,c) for j in range(0,f+1,d) if i+j <= f]

W = w[-1]
S = 0
for ww in w :
    for ss in s :
        if ww+ss > f or ww == 0:
            continue
        elif ss/(ss+ww) > S/(W+S) and e >= 100*ss/ww:
            W = ww
            S = ss

print(W+S, S)
from collections import defaultdict
MAX_N = 10 ** 3 + 10
MAX_M = 2 * (10 ** 3) + 1
INF = -(10 ** 100)

def bfs(graph, N, M):
    que = []
    que.append([0, 0])
    visited = defaultdict(list)
    result = INF
    while (len(que) > 0):
        now = que[0]
        que.pop(0)

        pos = now[0]
        cost = now[1]

        if (pos == N - 1):
            result = max(result, cost)

        if (pos in visited):
            visited_cost = visited[pos][0]
            visited_cnt = visited[pos][1]
            if (visited_cost >= cost):
                continue
            if (visited_cnt >= 2 * MAX_M):
                return (0, False)
            visited[pos] = [cost, visited_cnt + 1]
        else:
            visited[pos] = [cost, 0]


        for val in graph[pos]:
            nxt = val[0]
            nxt_cost = val[1]
            if (nxt not in visited):
                que.append([nxt, nxt_cost + cost])
            elif(nxt_cost + cost > visited[nxt][0]):
                que.append([nxt, nxt_cost + cost])
    return (result, True)


if __name__ == "__main__":
    N, M = map(int, input().split())
    graph = defaultdict(list)
    for x in range(M):
        a,b,c = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append([b, c])
    res,ok = bfs(graph, N, M)
    if (not ok):
        print ('inf')
    else:


### FIXED CODE ###


MAX_N = 10 ** 3 + 10
MAX_M = 2 * (10 ** 3) + 1
INF = 10 ** 13

def bfs(graph, N, M):
    que = []
    que.append([0, 0])
    visited = [-INF for x in range(MAX_N)]
    update_cnt = [0 for x in range(MAX_N)]
    result = -INF
    while (len(que) > 0):
        now = que[0]
        que.pop(0)

        pos = now[0]
        cost = now[1]
        if (visited[pos] > cost):
            continue
        for val in graph[pos]:
            nxt = val[0]
            nxt_cost = val[1]

            if (cost + nxt_cost > visited[nxt] and update_cnt[nxt] < MAX_M):
                visited[nxt] = cost + nxt_cost
                update_cnt[nxt] += 1
                que.append([nxt, nxt_cost + cost])

    if (update_cnt[N - 1] >= MAX_N):
        return (0, False)
    return (visited[N - 1], True)


if __name__ == "__main__":
    N, M = map(int, input().split())
    graph = [[] for x in range(MAX_N)]
    for x in range(M):
        a,b,c = map(int, input().split())
        a -= 1
        b -= 1
        graph[a].append([b, c])
    res,ok = bfs(graph, N, M)
    if (not ok):
        print ('inf')
    else:
        print (res)
n = int(input())
for i in range(int(n**0.5),0,-1):
    if n%i == 0:
        a = max(i,n//i)
        print(int(math.log10(a))+1)
        break

### FIXED CODE ###

import math
n = int(input())
for i in range(int(n**0.5),0,-1):
    if n%i == 0:
        a = max(i,n//i)
        print(int(math.log10(a))+1)
        break
num = int(input())
base_str = input()
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
            'U', 'V', 'W', 'X', 'Y', 'Z']
def replacer(letter, num):
    letter_index = alphabets.index(letter)
    return(alphabets[(letter_index+num)%27])
answer = []
for i in range(len(base_str)):
    answer.append(replacer(base_str[i], num))
answer = ''.join(answer)
print(answer)

### FIXED CODE ###

num = int(input())
base_str = input()
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
            'U', 'V', 'W', 'X', 'Y', 'Z']
def replacer(letter, num):
    letter_index = alphabets.index(letter)
    return(alphabets[(letter_index+num)%26])
answer = []
for i in range(len(base_str)):
    answer.append(replacer(base_str[i], num))
answer = ''.join(answer)
print(answer)
c = input()
    print(chr(ord(c)+1))

### FIXED CODE ###

c = input()

print(chr(ord(c)+1))
n = input()
print n if len(n)==2 else n[::-1]

### FIXED CODE ###

n = raw_input()
print n if len(n)==2 else n[::-1]
x=int(input())
cost=100
while(cost<x):
    cost*=101
    cost//=100
    ans+=1
print(ans)

### FIXED CODE ###

x=int(input())
ans=0
cost=100
while(cost<x):
    cost=cost*101//100
    ans+=1
print(ans)
n = int(input())
a = list(map(int, input().split()))
ra = []
for i in xrange(n):
    ra.append((i+1)*30000)
rb = []
for i in xrange(n):
    rb.append((n-i)*30000+a[i])

for i in ra:
    print(i,end=" ")
print("")
for i in rb:
    print(i,end=" ")


### FIXED CODE ###

N = input()
l = input().split()

N=int(N)
a=range(1,N+1)
b=range(1,N+1)
a=[i*N for i in a]
b=[i*N for i in b]
b.reverse()

c=0
for i in l:
    i=int(i)
    b[i-1]+=c
    c+=1

for i in a:
    print(i,end=" ")
print("")
for i in b:
    print(i,end=" ")
a,b,c=map(int,nput().split())
print(min(a+b,a+c,b+c))

### FIXED CODE ###

a,b,c=map(int,input().split())
print(min(a+b,a+c,b+c))
n = int(input())
s = input()
a = len(s)
if s <= n:
  print(s)
else:
  print(s[0:n-1] + '...')


### FIXED CODE ###

n = int(input())
s = input()
a = len(s)
if a <= n:
  print(s)
else:
  print(s[0:n] + '...')
k,n=map(int,input().split())
arr=list(map(int,input().split()))

for i in range(n-1):
	arr.append(arr[i]+k)

min_=99999999999

for i in range(n):
	if arr[i+n-1]-arr[i]<min_:
		min_=arr[i+n-1]-arr[i]


print(min_)

### FIXED CODE ###

s=input()

if s[2]==s[3] and s[4]==s[5]:
  print("Yes")
else:
  print("No")
n = int(input())
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

mod = 10**9+7

def dfs(i=0, r=-1):
    b = w = 1
    for j in e[i]:
        if j == r:
            continue
        bb, ww = dfs(j, i)
        b = b * ww % mod
        w = w * (bb + ww) % mod
    return b, w

print(sum(dfs()))


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()
n = int(input())
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

mod = 10**9+7

def dfs(i=0, r=-1):
    b = w = 1
    for j in e[i]:
        if j == r:
            continue
        bb, ww = dfs(j, i)
        b = b * ww % mod
        w = w * (bb + ww) % mod
    return b, w

print(sum(dfs())%mod)
n=int(input())
v_list = list(map(int,input().split()))
odd_list = []
even_list = []

for i in range(n):
    if i % 2 == 0:
        odd_list.append(v_list[i]) 
    else:
        even_list.append(v_list[i])

import collections

odd_list_c = collections.Counter(odd_list)
even_list_c = collections.Counter(even_list)

if odd_list_c.most_common()[0][0] != even_list_c.most_common()[0][0]:
    ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[0][1]
else:
    if len(even_list_c) == 1 && len(odd_list_c) == 1:
        ans = n // 2
    else: 
        if odd_list_c.most_common()[0][1] >= even_list_c.most_common()[0][1]:
            ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[1][1]
        elif odd_list_c.most_common()[0][1] < even_list_c.most_common()[0][1]:
            ans = n - odd_list_c.most_common()[1][1] - even_list_c.most_common()[0][1]

print(ans)

### FIXED CODE ###

n=int(input())
v_list = list(map(int,input().split()))
odd_list = []
even_list = []

for i in range(n):
    if i % 2 == 0:
        odd_list.append(v_list[i]) 
    else:
        even_list.append(v_list[i])

import collections

odd_list_c = collections.Counter(odd_list)
even_list_c = collections.Counter(even_list)

if odd_list_c.most_common()[0][0] != even_list_c.most_common()[0][0]:
    ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[0][1]
else:
    if len(even_list_c) == 1 and len(odd_list_c) == 1:
        ans = n // 2
    else: 
        ans1 = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[1][1]
        ans2 = n - odd_list_c.most_common()[1][1] - even_list_c.most_common()[0][1]
        ans = min(ans1, ans2)

print(ans)
import math
import sys

r = int(raw_input())
print str(float(r)**2 * math.pi) + " " + str(float(r) * 2 * math.pi)
sys.exit()

### FIXED CODE ###

import math
import sys

r = float(raw_input())
print str('%.5f' % (r**2 * math.pi)) + " " + str('%.5f' % (r * 2 * math.pi))
sys.exit()
if A/10 >1 and B/10 > 1:
  print(A*B)
else:
  print(-1)

### FIXED CODE ###

A,B=map(int,input().split())
if A/10 <1 and B/10 < 1:
  print(A*B)
else:
  print(-1)
#coding:utf-8
a, b = map(int, input().split)
print(min(0, a - 2*b))

### FIXED CODE ###

#coding:utf-8
a, b = map(int, input().split())
print(max(0, a - 2*b))
lis=list(input())

for i,x in enumerate(lis):
  if x == 0:
    a = i
print a
  
  


### FIXED CODE ###

lis=list(map(int,input().split()))
for i, x in enumerate(lis):
  if x == 0:
    a = i+1
print (a)
a = (int(item) for item in input().split())
seki = a[0] * a[1]
if seki % 2 == 0:
    print('Even')
else:
    print('Odd')

### FIXED CODE ###

a = [int(item) for item in input().split()]
seki = a[0] * a[1]
if seki % 2 == 0:
    print('Even')
else:
    print('Odd')
a,b,c = map(lambda x: int(x), input().split())
k = int(input())

for _ in range(k):
    if b < a:
        b = 2 * b
        continue
    if c < b:
        c = 2 * c
        continue
    print('Yes')
    sys.exit()
print('No')

### FIXED CODE ###

import sys
 
def main():
  a,b,c = map(lambda x: int(x), input().split())
  k = int(input())
 
  for _ in range(k):
      if b <= a:
          b = 2 * b
          continue
      if c <= b:
          c = 2 * c
          continue
      print('Yes')
      return
 
  if (a < b) & (b < c):
      print('Yes')
      return
  print('No')
 
if __name__ == '__main__':
    main()
string = input()
mid = len(s)//2

gnirts = reversed(string)
print(gnirts)
if(string != gnirts or string[:mid-1] != gnirts[mid+1:] or string[mid+1:] != gnirts[:mid-1]):
  print("No")
  exit()
print("Yes")

### FIXED CODE ###

string = input()
mid = len(string)//2

gnirts = string[::-1]
if(string != gnirts or string[:mid] != gnirts[mid+1:] or string[mid+1:] != gnirts[:mid]):
  print("No")
  exit()
print("Yes")
import math
N,K = map(int,input().split())
r = 0
for i in range(1,N+1):
        l = math.ceil(math.log2(K / i))
        r += ((1 / 2) ** l)/N
print(r)



### FIXED CODE ###

import math
N,K = map(int,input().split())
r = 0
for i in range(1,N+1):
    if i >= K:
        r += 1/N
    else:
        l = math.ceil(math.log2(K / i))
        r += ((1 / 2) ** l)/N
print(r)
X, Y = map(int, input().split())
import math
if (2 * Y - X ) % 3 == 0 and (2 * X -  Y) % 3 == 0:
  k = (2 * Y - X) // 3
  l = (2 * X - Y) // 3
  ue = math.factorial(k+l)
  sita_1 = math.factorial(k)
  sita_2 = math.factorial(l)
  total = ue //(sita_1 * sita_2)
  print(total % (7 + 10 ** 9))
else:
  print(0)


### FIXED CODE ###

X, Y = map(int, input().split())
import math
mod = pow(10,9) + 7
a = 2*Y -X
b = 2*X -Y
if a % 3 == 0 and b % 3 == 0 and a >= 0 and b >= 0:
  k = a // 3
  l = b // 3
  c = max(k, l)
  d = min(k, l)
  bunshi = 1
  bunbo = 1
  for i in range(c+1,c+d+1):
    bunshi = bunshi * i % mod
  for i in range(1,d+1):
    bunbo = bunbo * i % mod
  ans = bunshi * pow(bunbo, mod-2, mod) % mod
  print(ans)
else:
  print(0)