Harryxun/stf_run huggingface dataset:
from math import floor, ceil
N, M = [int(elem) for elem in input().split(' ')]

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

M_fct = factorize(M)
M_divisors = divisorize(M_fct)
max_divisor = 0
for M_divisor in M_divisors:
    cand = num(M_divisor)
    if cand >= N:
        max_divisor = max(M // cand, max_divisor)
print(max_divisor)


### FIXED CODE ###

from math import floor, ceil, sqrt
N, M = [int(elem) for elem in input().split(' ')]

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    try:
        b, e = fct.pop()  # base, exponent
    except:
        return []
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

M_divisors = divisorize(factorize(M))
threshold = M // N
max_possible_divisor = 1
for M_divisor in M_divisors:
    divisor = num(M_divisor)
    if divisor <= threshold:
        max_possible_divisor = max(max_possible_divisor, divisor)
print(max_possible_divisor)
N = int(input())
Problems = list(map(int,input().split()))
results = []
M = int(input())
for i in range(M):
  	temPro = Problems
    p,t = map(int,input().split())
    temPro[p-1] = t

    print(sum(temPro))


### FIXED CODE ###

N = int(input())
Problems = list(map(int,input().split()))
M = int(input())
for i in range(M):
    p,t = map(int,input().split())
    k = Problems[p-1]
    Problems[p-1] = t
    print(sum(Problems))
    Problems[p-1] = k
s = input()
kk = len(s)
k = k//2
ans = 0
for i in range(k):
  if s[i] != s[kk - i - 1]:
    ans += 1
print(ans)

### FIXED CODE ###

s = input()
kk = len(s)
k = kk//2
ans = 0
for i in range(k):
  if s[i] != s[kk - i - 1]:
    ans += 1
print(ans)
s=str(input())[-1]
 
if s in ["2", "4", "5", "7", "9"]:
  print("hon")
else if s == 3:
  print("bon")
else:
  print("pon")

### FIXED CODE ###

S = str(input())[-1]
tmp = ['0', '1', '6', '8']
if S == '3':
    print('bon')
elif S in tmp:
    print('pon')
else:
    print('hon')
import sys
input=sys.stdin.readline

D=int(input().rstrip('\n'))
cs=[int(x) for x in input().rstrip('\n').split()]
S={}
cd=[0]*26
for i in range(D):
  S[i] = [int(x) for x in input().rstrip('\n').split()]
for i in range(D):
  s1 = S[i]
  s1_s=sorted(s1,reverse=True)
  if i!=D-1:
    s2=S[i+1]
    s1_a=[x-y for x,y in zip(s1,cd)]
    s2_i=[x-y for x,y in zip(s2,cd)]
    s1_b=sorted(s1_a,reverse=True)
    if s2_i.index(max(s2_i))==s1_a.index(s1_b[0]):
      x = s1.index(s1_b[1])+1
      cd = [y+z for y,z in zip(cd,cs)]
      cd[x-1]=0
      print(x)
    else:
      print(s1.index(s1_b[0])+1)
print(S[D-1].index(max(S[D-1]))+1)

### FIXED CODE ###

import sys
input=sys.stdin.readline

D=int(input().rstrip('\n'))
cs=[int(x) for x in input().rstrip('\n').split()]
for i in range(D):
  Ss = [int(x) for x in input().rstrip('\n').split()]
  print(Ss.index(max(Ss))+1)
x,n = map(int,input().split())
p = list(map(int,input().split()))

val = []
ans = []
if p:
    for i in range(1,101):
        if i not in p:
            val.append(abs(x-i))
    if x - min(val) not in p:
        ans.append(x - min(val))
    if x + min(val) not in p:
        ans.append(x + min(val))
    print(min(ans))

else:
    print(x)

### FIXED CODE ###

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

for i in range(200):
    ans1 = x - i
    ans2 = x + i
    if ans1 not in p:
        print(ans1)
        break
    if ans2 not in p:
        print(ans2)
        break
import numpy as np

def main():
    #n = int(input())
    x,n = map( int, input().split())
    if n == 0:
        print(x)
    else:
        p = list(map( int, input().split()))

        l = []
        for i in range(1,101):
            if i not in p:
                l.append(i)
        
        l2 = []
        for j in range(1,101):
            nump = x+j
            numm = x-j
            if nump in l:
                l2.append(nump)
            if numm in l:
                l2.append(numm)
            if len(l2)>0:
                break
        print(np.min(l2))

        
    
if __name__ == '__main__':
    main()
   


### FIXED CODE ###

import numpy as np

def main():
    #n = int(input())
    x,n = map( int, input().split())
    if n == 0:
        print(x)
    else:
        p = list(map( int, input().split()))

        l = []
        for i in range(-100,120):
            if i not in p:
                l.append(i)
        
        l2 = []
        if x not in p:
            print(x)
        else:
            for j in range(1,101):
                nump = x+j
                numm = x-j
                if numm in l:
                    l2.append(numm)
                if nump in l:
                    l2.append(nump)
                if len(l2)>0:
                    break
            print(l2[0])

        
    
if __name__ == '__main__':
    main()
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 g=A.index(max(A[i],A[i,2*i][2*i<H],A[i,2*i+1][2*i+1<H]))
 if g>i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


### FIXED CODE ###

H=int(input())+1
A=[0]+list(map(int,input().split()))
def s(x,y):A[x],A[y]=A[y],A[x];h(y)
def h(i):
 l=2*i;r=l+1
 if r<H:
  if A[i]<A[l]:
   if A[l]<A[r]:s(i,r)
   else:s(i,l)
  elif A[i]<A[r]:s(i,r)
 elif l<H and A[i]<A[l]:s(i,l)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))
L,R = map(int, input().split())
if L * R < 2019:
        print(L * R)
        exit()

if R - L >= 2019:
        print(0)
        exit()

li=range(L, R)
tmp = []
for i in range(min(2019 * 2, R - L)):
        if li[i] % 2019 == 0:
                print(0)
                exit()
        tmp.append(li[i] % 2019)
tmp.sort()

print(tmp[0]* tmp[1])



### FIXED CODE ###

import itertools
L,R = map(int, input().split())
if (R - L) + 1 >= 2019:
        print(0)
        exit()
elif (R - L) + 1 >= 673:
        print(0)
        exit()

if (R - 1) * R < 2019:
        print(L * R)
        exit()


if L % 2019 == 0:
        print(0)
        exit()
elif L % 673 < R % 673:
        li = range(L, R + 1)
        cmb = list(itertools.combinations(li,2))
        ans = (R-1) * R
        for i,j in cmb:
                ans = min(ans, (i*j) % 2019)
        print(ans)

else:
        print(0)
        exit()
# coding: utf-8
# Your code here!

s=input()
t=input()
if len(s)-len(t)<0:
    flg=False
else:
    for i in range(len(s)-len(t)):
        ans=s
        for j in range(len(t)):
            flg=True
            if t[-1-j]==s[-1-j-i] or s[-1-j-i]=='?':
                #print(ans)
                ans=ans[:-1-j-i]+t[-1-j]+('' if -1-i-j+1==0 else ans[-1-i-j+1:])
            else:
                flg=False
                break
        if flg==True:
            break
ans=ans.replace('?','a')
print(ans if flg else 'UNRESTORABLE')

### FIXED CODE ###

# coding: utf-8
# Your code here!

s=input()
t=input()
b=[]

if len(s)-len(t)<0:
    flg=False
else:
    for i in range(len(s)-len(t)+1):
        ans=s
        for j in range(len(t)):
            flg=True
            if s[i+j]=='?' or s[i+j]==t[j]:
                #print(ans)
                ans=ans[:i+j]+t[j]+('' if i+j+1>len(s) else ans[i+j+1:])
            else:
                flg=False
                break
        if flg==True:
            b.append(ans.replace('?','a'))
#print(b)
b.sort()

print(b[0] if len(b)>0 else 'UNRESTORABLE')
N,M = list(map(int,input().split()))
S = input()
T = input()
sl = list(S)
tl = list(T)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

lcm = lcm(N,M)
Sd = lcm//N
St = lcm//M
kaisu = min((N-1)//St,(M-1)//Sd)
flag = 0
for i in range(kaisu+1):
    if sl[St*i] != tl[Sd*i]:
        flag = 1
if flag == 0:
    print(lcm)
else:
    print(-1)


### FIXED CODE ###

N,M = list(map(int,input().split()))
S = input()
T = input()
sl = list(S)
tl = list(T)
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(x, y):
    return int((x * y) / gcd(x, y))

lcm = lcm(N,M)
Sd = int(lcm/N)
St = int(lcm/M)
kaisu = min(int((N-1)/St),int((M-1)/Sd))
flag = 0
for i in range(kaisu+1):
    if sl[St*i] != tl[Sd*i]:
        flag = 1
if flag == 0:
    print(lcm)
else:
    print(-1)
import itertools

n = 10
data = [_ for _ in range(1,n+1)]
print(data)

dt = [2,4635,534,534,5,2345,13,41,51,23]

for i in itertools.combinations(data, 1):
    print(i)





for i in fakePeople:
            if turndata[i] != []:
                for j in turndata[i]:
                    if j[1] == 0:
                        j[1] = 1
                    else:
                        j[1] = 0

import itertools
import copy

n = int(input())
indexes = [_ for _ in range(1, n+1)]

def ifCorrect(data, fakes):
    answer_sheet = [-1 for i in range(n+1)]
    for i in fakes:
        answer_sheet[i] = 0

    #このあたりで、fakeでない人の情報とも比較して、正直者の証言がそれらのリストと合致しているかを確認すれば良い
    for i in range(len(data)):
        for j in data[i]:
            if not i in fakes:
                if answer_sheet[j[0]] == -1:
                    if j[1] == 0 and not j[0] in fakes:
                        return False
                    else:
                        answer_sheet[j[0]] = j[1]
                elif not answer_sheet[j[0]] == j[1]:
                    return False
                    
    return True

data = [[] for _ in range(n+1)]
for i in range(n):
    id = int(input())
    for _ in range(id):
        x, y = map(int, input().split(" "))
        data[i+1].append([x,y])

fakePersonCount = 0
flag = True
while fakePersonCount <= n and flag:
    comb = itertools.combinations(indexes, fakePersonCount)
    for fakePeople in comb:
        if ifCorrect(data, fakePeople):
            print(n - fakePersonCount)
            flag = False
            break
    fakePersonCount += 1

if flag:
    print(0)

#[[], [[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]

### FIXED CODE ###

import itertools
import copy

n = int(input())
indexes = [_ for _ in range(1, n+1)]

def ifCorrect(data, fakes):
    answer_sheet = [1 for i in range(n+1)]
    answer_sheet[0] = -1
    for i in fakes:
        answer_sheet[i] = 0

    #このあたりで、fakeでない人の情報とも比較して、正直者の証言がそれらのリストと合致しているかを確認すれば良い
    for i in range(len(data)):
        for j in data[i]:
            if not i in fakes and not answer_sheet[j[0]] == j[1]:
                return False
                    
    return True

data = [[] for _ in range(n+1)]
for i in range(n):
    id = int(input())
    for _ in range(id):
        x, y = map(int, input().split(" "))
        data[i+1].append([x,y])

fakePersonCount = 0
flag = True
while fakePersonCount <= n and flag:
    comb = itertools.combinations(indexes, fakePersonCount)
    for fakePeople in comb:
        if ifCorrect(data, fakePeople):
            print(n - fakePersonCount)
            flag = False
            break
    fakePersonCount += 1

if flag:
    print(0)

#[[], [[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]
def a(R)
    b = 6.28 * {}.format(R)
    return b
 
print(b)

### FIXED CODE ###

print(int(input())*6.3)
N, Q = map(int, input().split())


class Tree(object):
    def __init__(self, num):
        self.num = num
        self.childs = []
        self.count = 0


def dfs(p, x):
    """
    add x to all elements which have p as parent
    :param p: root of subtree, Tree class
    :param x: numbers to add, int
    """
    # add x to p.count
    p.count += x

    # recurrsive call for direct children of p
    for child in p.childs:
        dfs(child, x)


trees = [Tree(num) for num in range(N)]
print(trees)

for _ in range(N-1):
    a, b = map(int, input().split())
    a = a - 1
    b = b - 1
    trees[a].childs.append(trees[b])


for _ in range(Q):
    p, x = map(int, input().split())
    p = p - 1
    dfs(trees[p], x)


for tree in trees:
    print(tree.count)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

 
N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in PX:
    value[p] += x
 
def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])
 
dfs(1,0,0)
 
answer = ' '.join(map(str,value[1:]))
print(answer)
h, w = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
ans = [[0]*w for _ in range(h)]
idx_ls = [(0, 0)]

i = j = 0
flip = 0
flag = 1
for _ in range(h*w-1):
    if (j == w-1 or j == 0)and not flag:
        i += 1
        flip ^= 1
        flag = 1
        idx_ls.append((i, j))
        continue
    flag = 0
    j = j+[1, -1][flip]
    idx_ls.append((i, j))


for color, a in enumerate(A):
    color += 1
    for _ in range(a):
        i, j = idx_ls.pop()
        ans[i][j] = color

for x in ans:
    print(*x)


### FIXED CODE ###

h, w = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
ans = [[0]*w for _ in range(h)]

idx_ls = []

flip = 0
for i in range(h):
    if not flip:
        for j in range(w):
            idx_ls.append((i, j))
    else:
        for j in range(w-1, -1, -1):
            idx_ls.append((i, j))
    flip ^= 1


for color, a in enumerate(A):
    color += 1
    for _ in range(a):
        i, j = idx_ls.pop()
        ans[i][j] = color

for x in ans:
    print(*x)
a, b =map(int,input().split())

if a<b-1:
print(a)

else:
print(a-1)

### FIXED CODE ###

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

if a<b+1:
     print (a)
else:
     print (a-1)
import math

N = int(input())
s = [""] * N
for i in range(N):
	s[i] = list(input())
	s[i].sort()
s.sort()

st, count = 1, 0
for i in range(1, N):
	if s[i - 1] == s[i]:
		st += 1
	elif st > 2:
		count += math.factorial(st) / (2 * (st - 2))
		st = 1
	elif st == 2:
		count += 1
		st = 1
if st > 2:
	count += math.factorial(st) / (2 * (st - 2))
elif st == 2:
	count += 1

print(int(count))

### FIXED CODE ###

import math

N = int(input())
s = [""] * N
for i in range(N):
	s[i] = list(input())
	s[i].sort()
s.sort()

st, count = 1, 0
for i in range(1, N):
	if s[i - 1] == s[i]:
		st += 1
	elif st > 1:
		count += math.factorial(st) // (2 * math.factorial(st - 2))
		st = 1
if st > 1:
	count += math.factorial(st) // (2 * math.factorial(st - 2))

print(count)
a, b = map(int, input().split())
s = a-2b if a-2b >= 0 else 0
print(s)

### FIXED CODE ###

a, b = map(int, input().split())
s = a-2*b if a-2*b >= 0 else 0
print(s)
# -*- coding: utf-8 -*-
"""
Created on Thu Apr  4 14:43:20 2019

@author: fumito
"""

def create_sub(lr,S):
    sub = S[int(lr[0])-1:int(lr[1])]
    list = [i for i in sub]
    return list

def A_index(sub):
    A_index = [i for i,x in enumerate(sub) if x == 'A']
    return A_index

def count(sub,index):
    count = 0
    for i in index:
        if i == len(sub):
            pass
        elif sub[i+1] == 'C':
            count += 1
        else:
            pass
    return count

if __name__ == "__main__":
    N,Q = map(int,input().split())
    S = str(input())
    lr = [input().split() for i in range(Q)]
    
    ans = []
    for i in range(Q):
        Sub = create_sub(lr[i],S)
        Index = A_index(Sub)
        Count = count(Sub,Index)
        ans.append(Count)
    for j in ans:
        print(j)

### FIXED CODE ###

N,Q = map(int,input().split())
S = str(input())
l,r = [0]*Q,[0]*Q
for i in range(Q):
    l[i],r[i] = map(int,input().split())
    
count_list = []
count = 0
count_list.append(0)
for i in range(1,N):
    if S[i-1] == "A" and S[i] == "C":
        count += 1
        count_list.append(count)
    else:
        count_list.append(count)
    
for j in range(Q):
    print(count_list[r[j]-1]-count_list[l[j]-1])
A, B, K = map(int, input().split())
A, B, K = map(int, input().split())
N = min(A, B)
list_gcd = [] 

for i in range(1, N):
  print(A)
  if A % i == 0 and B % i == 0:
    list_gcd.append(i)
    
if N == 1:
  Y = max(A,B)
  if Y == 1:
    list_gcd.append(1)
  else:
    for i in range(1, Y):
      if Y % i == 0:
        list_gcd.append(i)
    
print(list_gcd[K-1])

### FIXED CODE ###

A, B, K = map(int, input().split())
N = min(A, B)
list_gcd = [] 

for i in range(1, N+1):
  if A % i == 0 and B % i == 0:
    list_gcd.append(i)
    
if N == 1:
  Y = max(A,B)
  if Y == 1:
    list_gcd.append(1)
  else:
    for i in range(1, Y):
      if Y % i == 0:
        list_gcd.append(i)

print(list_gcd[-K])
if age > 13;
	print(fee)
else;
	print(fee / 2)

### FIXED CODE ###

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

if A >= 13:
	print(B)
    
elif 6 <= A <= 12:
	print(B // 2)

else:
	print(0)
import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
fft = np.fft.rfft
ifft = np.fft.irfft
mod = 998244353

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

dp = np.zeros(U+10, dtype=np.int64)
dp[0] = 1
for a in A:
    newDP = dp.copy() * 2
    newDP[a:] += dp[:-a]
    newDP %= mod
    dp = newDP

print(dp[S])

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
fft = np.fft.rfft
ifft = np.fft.irfft
mod = 998244353

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

dp = np.zeros(U+10, dtype=np.int64)
dp[0] = 1
for a in A:
    newDP = dp.copy() * 2
    newDP[a:] += dp[:-a]
    newDP %= mod
    dp = newDP

print(dp[S])
# D - Xor Sum 2

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

l,r = 0,1 # l<rの場合を考える
tmp_xor = A[l] ^ A[r]
tmp_sum = A[l] + A[r]
ans = N

while 1:
    if tmp_xor == tmp_sum:
        ans += r-l # 先頭l以上、末尾rの部分数列の個数
        r += 1
        if r == N:
            break
        tmp_xor = tmp_xor ^ A[r]
        tmp_sum += A[r]
    elif l+1 < r:
        tmp_sum -= A[l]
        l += 1
        tmp_xor = A[l]
        for idx in range(l+1,r+1):
            tmp_xor = tmp_xor ^ A[idx]
    else:
        l = r
        r += 1
        if r == N:
            break
        tmp_xor = A[l] ^ A[r]
        tmp_sum = A[l] + A[r]

print(ans)

### FIXED CODE ###

# D - Xor Sum 2

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

if N == 1:
    print(1)
    exit()

l,r = 0,1 # l<rの場合を考える
tmp_xor = A[l] ^ A[r]
tmp_sum = A[l] + A[r]
ans = N

while 1:
    if tmp_xor == tmp_sum:
        ans += r-l # 先頭l以上、末尾rの部分数列の個数
        r += 1
        if r == N:
            break
        tmp_xor = tmp_xor ^ A[r]
        tmp_sum += A[r]
    elif l+1 < r:
        tmp_sum -= A[l]
        tmp_xor = tmp_xor ^ A[l]
        l += 1
    else:
        l = r
        r += 1
        if r == N:
            break
        tmp_xor = A[l] ^ A[r]
        tmp_sum = A[l] + A[r]

print(ans)
import sys
readline = sys.stdin.buffer.readline
t = readline()
print(t.replace('?','D')

### FIXED CODE ###

t = input()
print(t.replace('?', 'D'))
a,b,c = map(int, input().split())
print(str(a+b+c))

### FIXED CODE ###

s = input()
factor = [int(x) for x in s]
print(sum(factor))
def tri_len(x,y):
  if x== y:
    return x
  elif x < y:
    return tri_len(y-x,x)+2*x
  else:
    return tri_len(x-y,y)+2*y
import sys
sys.setrecursionlimit(10000)

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

print( n+tri_len(x,n-x))

### FIXED CODE ###

a = input()
lst = list(map(int,input().split(" ")))
lst.sort()
ans=0
for i in range(int(len(lst)/2)):
  ans += lst[len(lst)-2*i-2]
 
print(ans)
N = int(input()), K = int(input())
h = list(map(int, input().split()))
 
num =0
for i in range(N):
    if h[i]>K or h[i] == K:
        num =num+ 1
print(num)

### FIXED CODE ###

N,K = map(int, input().split())
h = list(map(int, input().split()))
 
num =0
for i in range(N):
    if h[i]>K or h[i] == K:
        num =num+ 1
print(num)
S = input()

jogai = "ZXVBNMLKJHFDSQWERYUIOP"
cnt = []
for i in range(0,len(S)):
    for j in range(1,len(S)+1):
        tmp = S[i:j]
        flg = 1
        for a in jogai:
            if a in tmp:
                flg = 0
        if flg:
            cnt.append(len(tmp))
print(max(cnt))

### FIXED CODE ###

S = input()
N = len(S)
ans =0
for i in range(0, N):
    for j in range(i, N+1):
        tmp = S[i:j]
        if len(tmp)==tmp.count('A')+tmp.count('G')+tmp.count('C')+tmp.count('T'):
            ans = max(ans,len(tmp))
print(ans)
a = int(input())

b = list(map(int,input().split()))
d = max(b)
c = [0 for i in range(pow(10,5)+100)]
cc = [0 for i in range(pow(10,5)+100)]
for i in range(len(b)):
    if i % 2 == 0:
        cc[b[i]-1] += 1
    else:
        c[b[i]-1] += 1

one = 0
onee = 0
two = 0
twoo = 0
k = 0
kk = 0
for i in range(len(c)+10):
    if one <= c[i]:
        onee = one
        one = c[i]
        k = i
    if two <= cc[i]:
        twoo = two
        two = cc[i]
        kk = i

t = max(one+twoo,onee+two)

if k != kk:
    print(a-one-two)
else:
    print(a-t)


### FIXED CODE ###

from collections import Counter

a = int(input())

b = list(map(int,input().split()))
d = max(b)
c = [0 for i in range(pow(10,5)+1)]
cc = [0 for i in range(pow(10,5)+1)]
for i in range(len(b)):
    if i % 2 == 0:
        c[b[i]] += 1
    else:
        cc[b[i]] += 1
first = Counter(b[::2]).most_common(2) + [(0, 0)]
latter = Counter(b[1::2]).most_common(2) + [(0, 0)]
one = 0
onee = 0
two = 0
twoo = 0
k = 0
kk = 0
for i in range(d+1):
    if one <= c[i]:
        onee = one
        one = c[i]
        k = i
    elif onee <= c[i]:
        onee = c[i]
    if two <= cc[i]:
        twoo = two
        two = cc[i]
        kk = i
    elif twoo <= cc[i]:
        twoo = cc[i]
t = max(one+twoo,onee+two)

if k != kk:
    print(a-one-two)
else:
    print(a-t)
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
 
ans = 0
for i in range(N):
    for j in range(i+1, N+1):
        if sum(A[i:j]) >= K:
            ans += N - j + 1
            break
 
print(ans)

### FIXED CODE ###

X, A = map(int, input().split())
if X < A:
    print(0)
else:
    print(10)
val = input()
if val <= 999:
  str_val = str(val)
  val_one = str_val[-1]
  if val_one in {'2','4','5','9','7'}:
    print('hon')
  elif val_one in {'0','1','6','8'}:
    print('pon')
  elif val_one == '3':
    print('bon')

### FIXED CODE ###

val = input()
if int(val) <= 999:
  str_val = str(val)
  val_one = str_val[-1]
  if val_one in {'2','4','5','9','7'}:
    print('hon')
  elif val_one in {'0','1','6','8'}:
    print('pon')
  elif val_one == '3':
    print('bon')