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

from itertools import permutations

N, M, R = map(int, input().split())

visit = list(map(int, input().split()))
g = [[float('inf')] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g[a][b] = c
    g[b][a] = c

for i in range(N):
    for j in range(N):
        for k in range(N):
            g[i][j] = min(g[i][j], g[i][k] + g[k][j])

cost = float('inf')
visit = permutations(visit)
for town in visit:
    c = 0
    for i in range(len(town)-1):
        if g[town[i] - 1][town[i + 1] - 1] == float('inf'):
            break
        else:
            c += g[town[i] - 1][town[i + 1] - 1]
    else:
        cost = min(cost, c)
print(cost)


### FIXED CODE ###

from itertools import permutations

N, M, R = map(int, input().split())

visit = list(map(int, input().split()))
g = [[float('inf')] * N for _ in range(N)]
for i in range(N):
    g[i][i] = 0

for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g[a][b] = c
    g[b][a] = c


def dijkstra(start):
    c_l = [float('inf')] * N
    c_l[start] = 0
    visited = [False] * N
    while True:
        min_v = float('inf')
        next = -1
        visited[start] = True
        for i in range(N):
            if visited[i]:
                continue
            if g[start][i]:
                d = c_l[start] + g[start][i]
                if d < c_l[i]:
                    c_l[i] = d
                if min_v > c_l[i]:
                    min_v = c_l[i]
                    next = i
        start = next
        if next == -1:
            break
    return c_l


cost_list = []
for i in range(N):
    cost_list.append(dijkstra(i))

cost = float('inf')
for town in permutations(visit):
    c = 0
    for i in range(R - 1):
        c += cost_list[town[i] - 1][town[i + 1] - 1]
    cost = min(cost, c)
print(cost)
### BUGGY CODE ###

s = list(input())
l_index = 0
cnt = 0

if len(s) == 1:
  print(cnt)
else:
  while True:
    for k, v in enumerate(s):
      l_index = k
      if k == 0:
        next
      elif v == s[k - 1]:
        cnt += 1
        s[k] = str((int(v) + 1) % 2)
        break

    if l_index == len(s) - 1:
      break

  print(cnt)


### FIXED CODE ###

s = list(input())
r = ''
if s[0] == '0':
  r = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
elif s[0] == '1':
  r = ['1' if i % 2 == 0 else '0' for i in range(len(s))]

mul = [str(int(s[i]) + int(r[i])) for i in range(len(s))]

print(mul.count('1'))
### BUGGY CODE ###

N=int(input());AB=[list(map(int,input().split())) for _ in range(1,N)]
nd=[0 for _ in range(N)]
table = [[] for _ in range(N)]
for a,b in AB:
  table[a-1].append(b)
  nd[a-1]+=1
  nd[b-1]+=1

K=max(nd)
co=[0 for _ in range(N)]
ans=dict()
for x,li in enumerate(table):
  c=[i for i in range(1,K+1) if i != co[x]]
  for b,y in zip(li,c):
    co[b-1]=y
    ans[(x+1,b)]=y

print(K)
for a,b in AB:
  print(ans[(a,b)])


### FIXED CODE ###

import sys

input = sys.stdin.readline
N=int(input());AB=[tuple(map(int,input().split())) for _ in range(1,N)]

co=[0 for _ in range(N)]
prev=0
color=1
for a,b in sorted(AB):
  if prev!=a:
    color=1
  if co[a-1]==color:
    color+=1
  co[b-1]=color
  prev=a
  color+=1

print(max(co))
for _,b in AB:
  print(co[b-1])
### BUGGY CODE ###

#import random
#import time
from collections import defaultdict, Counter

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #N = 20
    #A = [random.randint(1, int(1e6)) for _ in range(int(N))]
    N = int(input())
    A = [int(c) for c in input().split(' ')]
    #t1 = time.time()
    dup_cnt = Counter(A)
    dup = set(x for x in dup_cnt if dup_cnt[x] > 1)
    A_set = set(A)
    if 1 in A_set:
        if 1 in dup:
            print('0')
        else:
            print('1')
        exit()
    A = list(A_set)
    for t in (2,3,5,7):
        if t in A_set:
            A = [x for x in A if x%t != 0 or x==t]
    N = len(A)
    A.sort()
#    B = [factorization(x) for x in A]
#    B.sort()

    d = defaultdict(list)
    B = []
    for x in A:
        x_div = make_divisors(x)
        B.append(x_div)
        for y in x_div:
            d[y].append(x)
    assert len(A)==len(B)
    #print(A)
    #print(B)
    #print(d)
    not_divided = set()
    for i in range(N):
        bi = A[i]
        bi_fac = B[i]
        can_divide = False
        for y in bi_fac:
            for a in d[y]:
                if bi % a == 0 and bi != a:
                    #print(a,bi)
                    can_divide = True
                    break
                elif a > bi:
                    break
            if can_divide:
                break
        if can_divide or bi in dup:
            continue
        else:
            not_divided.add(bi)
    #print(A)
    #print(dup)
    #print(not_divided)
    print(len(not_divided))
    #print(time.time() - t1)


if __name__ == "__main__":
    main()

### FIXED CODE ###

#import random
#import time
from collections import defaultdict, Counter

def main():
    #N = 20
    #A = [random.randint(1, int(1e6)) for _ in range(int(N))]
    N = int(input())
    A = [int(c) for c in input().split(' ')]
    #t1 = time.time()
    dup_cnt = Counter(A)
    dup = set(x for x in dup_cnt if dup_cnt[x] > 1)
    A_set = set(A)
    A = list(A_set)
    A.sort()
    N = len(A)
    max_A = A[-1]
    prime = [True]*(max_A+1)
    ans = 0
    for x in A:
        if not prime[x]:
            continue
        else:
            for y in range(2*x, max_A+1, x):
                prime[y] = False
            if not x in dup:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###


S = input()

MOD = 10 ** 9 + 7
count = 0
S_len = len(S)

dp = [[0 for i in range(13)] for j in range(100006)]
c = -1
if S[0] != '?':
    c = int(S[0])
for j in range(10):
    if c == -1:
        dp[1][j] = 1
    else:
        dp[1][c] = 1

for i in range(2, S_len + 1):
    c = -1
    if S[i - 1] != '?':
        c = ord(S[i - 1]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i][(k * 10 + j) % 13] += dp[i - 1][k]

    for j in range(10):
        dp[i][j] %= MOD

print(dp[S_len][5])




### FIXED CODE ###


S = input()

MOD = 10 ** 9 + 7
count = 0
S_len = len(S)

dp = [[0 for i in range(13)] for j in range(100006)]
c = -1
if S[0] != '?':
    c = int(S[0])
for j in range(10):
    if c == -1:
        dp[1][j] = 1
    else:
        dp[1][c] = 1

for i in range(2, S_len + 1):
    c = -1
    if S[i - 1] != '?':
        c = ord(S[i - 1]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i][(k * 10 + j) % 13] += dp[i - 1][k] % MOD


print(dp[S_len][5] % MOD)
### BUGGY CODE ###

ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n,m,q = ma()
L_rs=[[] for i in range(n)]
for i in range(m):
    l,r=ma()
    L_rs[l-1].append(r-1)
for i in range(n):
    L_rs[i].sort()
# print(L_rs)
def isok(num,val):##適宜変更
    return num<=val
def bisect(ls,val): ##valの関数isok(x,val)がTrueとなる一番右のindex を返す 全部Falseなら-1,Trueならlen(ls)-1
    ok = -1
    ng = len(ls)
    x = (ok+ng)//2
    while ng-ok>1:
        num = ls[x]
        if isok(num,val):
            ok = x
        else:
            ng = x
        x = (ok+ng)//2
    return ok ##一番右のTrueのindex  Trueの個数はok+1こ

def solve(L,R):##0idx
    ret=0
    for l in range(L,R+1):
        ret+=bisect(L_rs[l],R)+1
    return ret
ans = [[0]*n for i in range(n)]
for l in range(n):
    for r in range(n):
        ans[l][r]=solve(l,r)

for i in range(q):
    l,r=ma()
    print(ans[l-1][r-1])


### FIXED CODE ###

ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n,m,q = ma()
L_rs=[[] for i in range(n)]
for i in range(m):
    l,r=ma()
    L_rs[l-1].append(r-1)
for i in range(n):
    L_rs[i].sort()
# print(L_rs)
def isok(num,val):##適宜変更
    return num<=val
def bisect(ls,val): ##valの関数isok(x,val)がTrueとなる一番右のindex を返す 全部Falseなら-1,Trueならlen(ls)-1
    ok = -1
    ng = len(ls)
    x = (ok+ng)//2
    while ng-ok>1:
        num = ls[x]
        if isok(num,val):
            ok = x
        else:
            ng = x
        x = (ok+ng)//2
    return ok ##一番右のTrueのindex  Trueの個数はok+1こ

ans = [[0]*(n+1) for i in range(n+1)]
for r in range(n):
    for l in range(r,-1,-1):
        ans[l][r]=ans[l+1][r] + bisect(L_rs[l],r)+1

for i in range(q):
    l,r=ma()
    print(ans[l-1][r-1])
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
xy = [LIST() for _ in range(N)]
X = sorted([x[0] for x in xy])
Y = sorted([x[1] for x in xy])

ans = INF
for p in combinations(X, 2):
	x_min = p[0]
	x_max = p[1]
	for q in combinations(Y, 2):
		y_min = q[0]
		y_max = q[1]
		
		cnt = 0
		for x, y in xy:
			if x_min <= x <= x_max and y_min <= y <= y_max:
				cnt += 1
		if cnt >= K:
			ans = min(ans, (x_max-x_min)*(y_max-y_min))
print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
xy = [LIST() for _ in range(N)]
X = sorted([x[0] for x in xy])
Y = sorted([x[1] for x in xy])

ans = INF
for p in combinations(X, 2):
	x_min = p[0]
	x_max = p[1]
	for q in combinations(Y, 2):
		y_min = q[0]
		y_max = q[1]
		
		cnt = 0
		for x, y in xy:
			if x_min <= x <= x_max and y_min <= y <= y_max:
				cnt += 1
		if cnt >= K:
			ans = min(ans, (x_max-x_min)*(y_max-y_min))
print(ans)
### BUGGY CODE ###

n=int(input())
def out(i):
  print(i,flush=True)
  s=input()
  if s=="Male":return 0
  elif s=="Female":return 1
  else:exit()
ng=-1
ok=n
while ng+1!=ok:
  mid=(ng+ok)//2
  m=out(mid)
  if mid%2==m%2:ng=mid
  else:ok=mid

### FIXED CODE ###

n=int(input())
def out(i):
  print(i,flush=True)
  s=input()
  if s=="Male":return 0
  elif s=="Female":return 1
  else:exit()
f=out(0)
ng=0
ok=n
while ng+1!=ok:
  mid=(ng+ok)//2
  if (mid+f)%2==out(mid)%2:ng=mid
  else:ok=mid
### BUGGY CODE ###

n = int(input())

array = []
vArray = [-1] * n

for _ in range(n):
    array.append([-1] * n)

for _ in range(n - 1):
    u, v, w = map(int, input().split())
    array[u - 1][v - 1] = w
    array[v - 1][u - 1] = w

def check(checkV, color):
    if vArray[checkV] >= 0:
        return
    vArray[checkV] = color
    for i in range(n):
        if array[checkV][i] >= 0:
            if array[checkV][i] % 2 == 0:
                check(i, color)
            else:
                check(i, not color)


check(0, True)

for i in range(n):
    print(0 if vArray[i] == True else 1)

### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000000)

n = int(input())

ulist = []

for _ in range(n):
    ulist.append([])

vlist = [True] * n

for _ in range(n - 1):
    u, v, w = map(int, input().split())
    ulist[u - 1].append([v - 1, w])
    ulist[v - 1].append([u - 1, w])


def check(checkV, fromV):
    for data in ulist[checkV]:
        if data[0] != fromV:
            vlist[data[0]] = vlist[checkV] if data[1] % 2 == 0 else not vlist[checkV]
            check(data[0], checkV)

check(0, -1)

for i in range(n):
    print(1 if vlist[i] else 0)
### BUGGY CODE ###

n, m = map(int, input().split())
ans = 0
jobs = []
for i in range(n):
    array = list(map(int, input().split()))
    jobs.append(array)

for i in range(1, m+1):
    x = [k for k in jobs if k[0] <= i]
    x.sort(key=lambda t:t[1], reverse=True)
    if len(x) > 0:
        job = x.pop(0)
        jobs.remove(job)
        ans += job[1]

print(ans)



### FIXED CODE ###

import heapq
from collections import defaultdict

n, m = map(int, input().split())
ans = 0
jobs = defaultdict(list)
to_do = []
heapq.heapify(to_do)
for i in range(n):
    array = list(map(int, input().split()))
    array[1] *= -1
    jobs[array[0]].append(array[1])

for i in range(1, m+1):
    if len(jobs[i]) > 0:
        for j in jobs[i]:
            heapq.heappush(to_do, j)
    if len(to_do) > 0:
        ans += -1 * heapq.heappop(to_do)

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

N,Q = map(int,input().split())
S = input()
questions = [[i for i in map(int,input().split())] for j in range(Q)]
import re
for question in questions:
  Sp = S[question[0]-1:question[1]]
  print(len(re.findall('AC', Sp)))

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
questions = [[i for i in map(int,input().split())] for j in range(Q)]
t = [0]*(N+1)
for i in range(N):
  t[i+1] = t[i] + (1 if S[i:i+2]=='AC' else 0)  

for q in questions:
  print(t[q[1]-1] - t[q[0]-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
N = int(input())
#開業されたN個要素を受け付ける
#input_list = [int(input()) for i in range(N)]
input_list = list(map(int, input().split()))
ans = 1
for input in input_list:
    ans = ans*input

if ans > 1000000000000000000:
    ans = -1

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
N = int(input())
#開業されたN個要素を受け付ける
#input_list = [int(input()) for i in range(N)]
input_org = input()
keta = input_org.replace(' ', '')
input_list = list(map(int, input_org.split()))
ans = 1
#print(input_list)
#print( 0 in input_list)
if (0 in input_list):
    ans = 0
elif len(keta) - N > 20:
    ans = -1
else:
    for input in input_list:
        ans = ans*input
        if ans > 1000000000000000000:
            ans = -1

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

n,k =map(int,input().split())
l = sorted(list(map(int,input().split())))[::-1]
for i in range(min(n,k)):
  l.pop(0)
print(sum(l))

### FIXED CODE ###

n,k =map(int,input().split())
l = sorted(list(map(int,input().split())))[::-1]
print(sum(l[min(k,n):]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
S = set()
s = list(input().rstrip())
K = int(input())
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if "".join(s[i:j]) not in S:
            S.add("".join(s[i:j]))
S = list(S)
S.sort()
print("".join(S[K-1]))


### FIXED CODE ###

import sys
input = sys.stdin.readline
S = set()
s = list(input().rstrip())
K = int(input())
for i in range(len(s)):
    for j in range(i+1, i+K+1):
        if "".join(s[i:j]) not in S:
            S.add("".join(s[i:j]))
S = list(S)
S.sort()
print("".join(S[K-1]))
### BUGGY CODE ###

N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

L = len(make_divisors(N))

ans = 0
for i in range(1,L):
    t = N
    while t%(make_divisors(N)[i]) == 0:
        t = t//make_divisors(N)[i]
    if t%make_divisors(N)[i] == 1:
        ans = ans + 1
        
print(ans + len(make_divisors(N-1)) -1)

### FIXED CODE ###

N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

L = len(make_divisors(N))

A = make_divisors(N)

ans = 0
for i in range(1,L):
    t = N
    while t%(A[i]) == 0:
        t = t//A[i]
    if t%A[i] == 1:
        ans = ans + 1
        
print(ans + len(make_divisors(N-1)) -1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(20000000)

s = input()
K = int(input())


def calculate(str, k):
    s = sorted(list(set(str)))
    criteron = s[:k]
    objs = {}
    for index, s in enumerate(str):
        if s in criteron:
            for i in range(index+1,len(str)+1):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)


### FIXED CODE ###

import sys
sys.setrecursionlimit(20000000)

s = input()
K = int(input())


def calculate(str, k):
    s = sorted(list(set(str)))
    criteron = s[:k]
    objs = {}
    for index, s in enumerate(str):
        if s in criteron:
            if len(str)+1 > index + 1 + k:
                made = index + 1 + k
            else:
                made = len(str)+1
            for i in range(index+1,made):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)
### BUGGY CODE ###

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

from fractions import gcd
from functools import reduce
import functools

def gcd(a,b):
    if a==0:
        return b 
    else:
        return gcd(b%a,a)
  
max_gcd = 0

for i in range(N):
  if i < N:
    values = A[i+1:] + A[:i] 
  else:
    values = A[:-1]
  
  g = lambda a,b:a if b==0 else g(b,a%b)
  gcd = functools.reduce(lambda x,y:g(x,y),values)
  max_gcd = max(max_gcd,gcd)

  
print(max_gcd)

### FIXED CODE ###

def gcd(x,y):
    if x<y:
        x,y=y,x
    #x>y
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
 
N=int(input())
A=[int(i) for i in input().split()]
X=[0 for i in range(N)]
Y=[0 for i in range(N)]
for i in range(1,N):
    X[i]=gcd(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i]=gcd(Y[i+1],A[i+1])
Z=[gcd(X[i],Y[i]) for i in range(N)]
print(max(Z))
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
import fractions
from functools import reduce

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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

v=lcm(*c)
ans=0

for i in range(n):
    ans+=v//c[i]

print(ans%mod)


### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
import fractions
from functools import reduce

n=int(input())
c = list(map(int, input().split()))
mod=pow(10,9)+7

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

v=lcm(*c)%mod
ans=0

for i in range(n):
    ans += v * pow(c[i],mod-2,mod)
    ans%=mod

print(ans%mod)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

H, N = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

# AB = sorted(AB, key=lambda x: (-x[2], x[0]))
# print('AB', AB)

cost = [-1 for i in range(H + 1)]
# for damage, mp_cost in AB:
#     cost[damage] = mp_cost
# print('cost', cost)

# c = []
# for damage, mp_cost in AB:


def f(H):
    c = []
    for damage, mp_cost in AB:
        tmp = H - damage
        if tmp <= 0:
            c.append(mp_cost)
            continue
        if cost[tmp] != -1:
            c.append(cost[tmp] + mp_cost)
        else:
            cost[tmp] = f(tmp)
            c.append(cost[tmp] + mp_cost)
    return min(c)


# print('H', H)
# print('f(H)', f(H))
print(f(H))
# print('after cost', cost)


### FIXED CODE ###

H, N = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

INF = 10**20
dp = [0]
for i in range(1, H + 1):
    min_mp_cost = INF
    for damage, mp_cost in AB:
        parent = max(0, i - damage)
        new_cost = dp[parent] + mp_cost
        if new_cost < min_mp_cost:
            min_mp_cost = new_cost
    dp.append(min_mp_cost)
print(dp[-1])
### BUGGY CODE ###

def resolve():
    N = int(input())
    S = []
    for _ in range(N):
        s = input()
        S.append(s)
    SS = list(set(S))
    ans = []
    for i in SS:
        ans.append(S.count(i))
    ooki = max(ans)
    aans = []
    for j in range(len(SS)):
        if ans[j] == ooki:
            aans.append(SS[j])
    aaans = sorted(aans)
    for __ in aaans:
        print(__)
resolve()

### FIXED CODE ###

count = {}
for i in range(int(input())):
    S = input()
    if S in count:
        count[S] += 1
    else:
        count[S] = 1
ans = max(count.values())
print(*sorted([A[0] for A in count.items() if A[1] == ans]))
### BUGGY CODE ###

import fractions

N = int(input())
nums = list(map(int, input().split()))
nums.sort()

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

num = nums[0]
for i in range(N - 1):
    num = lcm(num, nums[i + 1])
# print(num)
print(sum([num // i for i in nums]) % (10 ** 9 + 7))



### FIXED CODE ###

import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

num = nums[0]
for i in range(N - 1):
    num = lcm(num, nums[i + 1])
print(sum([num // i for i in nums]) % (10 ** 9 + 7))
### BUGGY CODE ###

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

li2 = li[::2]
li3 = li[1::2]
max2,max22,max3,max33 = [0,0,0,0]

for i in li2:
    a = li2.count(i)
    if a > max2:
        max22 = max2
        max2 = a
        b = i
    elif a > max22 and i != b:
        max22 = a

for i in li3:
    a = li3.count(i)
    if a > max3:
        max33 = max3
        max3 = a
        c = i
    elif a > max33 and i != c:
        max33 = a

if b == c:
    print(max(n-max22-max3,n-max2-max33))
else:
    print(n-max2-max3)


### FIXED CODE ###

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

cnt1 = {}
cnt2 = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] in cnt1:
            cnt1[v[i]] += 1
        else:
            cnt1[v[i]] = 1
    else:
        if v[i] in cnt2:
            cnt2[v[i]] += 1
        else:
            cnt2[v[i]] = 1

sorted_cnt1 = sorted(cnt1.items(), key = lambda x: x[1], reverse = True)
sorted_cnt2 = sorted(cnt2.items(), key = lambda x: x[1], reverse = True)

sorted_cnt1.append((-1,0))
sorted_cnt2.append((-1,0))

if sorted_cnt1[0][0] != sorted_cnt2[0][0]:
    print(n - sorted_cnt1[0][1] - sorted_cnt2[0][1])
else:
    print(n - max(sorted_cnt1[0][1] + sorted_cnt2[1][1], sorted_cnt1[1][1]+sorted_cnt2[0][1]))