Harryxun/stf_run huggingface dataset:
import functools


def divise(n, divisor):
    if n == divisor:
        return n
    elif n % divisor == 0:
        return 0
    else:
        return n

number = int(input())
origin = [int(input()) for x in range(number)]

divised = origin  # initialize

for i in range(2, max(origin)+1):
    divised = list(map(functools.partial(divise, divisor=i), divised))

for j in range(number):
    if divised[j] == 0:
        origin.pop(j)
    else:
        pass

print(len(origin))

### FIXED CODE ###

def is_prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True

count = 0

number = int(input())
for i in range(number):
    n = int(input())
    if is_prime(n):
        count = count + 1

print(count)
from heapq import heappush, heappop
s=set()
q=[]
x, y, z, k = map(int, input().split())
a=sorted(list(map(int, input().split())), reverse=True)
b=sorted(list(map(int, input().split())), reverse=True)
c=sorted(list(map(int, input().split())), reverse=True)
heapq.heappush(q, (-(a[0]+b[0]+c[0]), 0, 0, 0))
def push(d, e, f):
    if (d, e, f) not in s and 0<=d<x and 0<=e<y and 0<=f<z:
        heapq.heappush(q, (-(a[d]+b[e]+c[f]), d, e, f))
        s.add((d, e, f))
for i in range(k):
    p, d, e, f =heapq.heappop(q)
    print(-p)
    push(d+1, e, f)
    push(d, e+1, f)
    push(d, e, f+1)
        

### FIXED CODE ###

from heapq import heappush, heappop
s=set()
q=[]
x, y, z, k = map(int, input().split())
a=sorted(list(map(int, input().split())), reverse=True)
b=sorted(list(map(int, input().split())), reverse=True)
c=sorted(list(map(int, input().split())), reverse=True)
heappush(q, (-(a[0]+b[0]+c[0]), 0, 0, 0))
def push(d, e, f):
    if (d, e, f) not in s and 0<=d<x and 0<=e<y and 0<=f<z:
        heappush(q, (-(a[d]+b[e]+c[f]), d, e, f))
        s.add((d, e, f))
for i in range(k):
    p, d, e, f =heappop(q)
    print(-p)
    push(d+1, e, f)
    push(d, e+1, f)
    push(d, e, f+1)
N,K=map(int,input().split())
N=list(map(int,input().split()))
a={}
 
b=1
a[1]=1
count=0
while(count<=K+1):
  count+=1
  b=N[b-1]
  #print(b)
  if b in a:
    #print(a)
    #print(b)
    #print(count)
    cycle=count-a[b]
    rest=K-count+1
    ans=rest%cycle
    for i in range(ans-1):
      b=N[b-1]
    print(b)
    break
  a[b]=count
  if count==K+1:
    print(b)
    break

### FIXED CODE ###

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

count=0
k=1
countlist={}
#countlist[1]=A[0]
count=1
while True:    
    k=A[k-1]
    
    if k in countlist:
        cycle=count-countlist[k]
        rest=K-count
        move=rest%cycle
        for i in range(min(rest,move)):
            k=A[k-1]
        print(k)
        break
    
    countlist[k]=count
    
    if count==K:
        print(k)
        break
    
    count+=1
from collections import Counter

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

c = Counter(A)


ans = []
for i, j in c.items():
    if j >= 2:
        ans.append(i)

ans.sort()    

print(ans[-1]*ans[-2])

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
a = collections.Counter(A)
ans = [0, 0]
for i in a.keys():
    if a[i] >= 2:
        ans.append(i)
    if a[i] >= 4:
        ans.append(i)
ans.sort()
print(ans[-1]*ans[-2])
f = True

a, b, c = map(int, input().split())
candy = [a, b, c]
if not max(candy) == sum(candy) - max(candy):
    f = False

if f:
    print("YES")
else:


### FIXED CODE ###

[a,b,c]=list(map(int,input().split()))
if a+b==c or a+c==b or b+c==a :
    print("Yes")
else:
    print("No")
A, B, X = map(int, input().split())

print('NO' if X - A < 0 or X - A > B 'YES')


### FIXED CODE ###

# Aは猫, Bはどっちかわからん
A, B, X = map(int, input().split())

if X - A < 0:
    print('NO')
elif X - A > B:
    print('NO')
else:
    print('YES')
s = str(input())
print(s[0:5]+' '+s[6:13]+' '+s[14:]

### FIXED CODE ###

s = str(input())
ans = ''

for i in range(19):
    
    if i==5 or i==13:
        ans += ' '

    else:
        ans += s[i]

print(ans)
import sys
readline = sys.stdin.buffer.readline
N,W = map(int,readline().split())

#i:N,j:W,value:value
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(1,N+1):
    w,v = map(int,readline().split())
    for j in range(1,W+1):
        if j < w:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v)

print(dp[-1][-1])

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
N,W = map(int,readline().split())
w,v = map(int,readline().split())
tmp = w
lst1 = [1,0,0,0]
v0 = [v]
v1 = []
v2 = []
v3 = []
for i in range(N-1):
    w,v = map(int,readline().split())
    if w == tmp:
        lst1[0] += 1
        v0.append(v)
    elif w == tmp+1:
        lst1[1] += 1
        v1.append(v)
    elif w == tmp+2:
        lst1[2] += 1
        v2.append(v)
    else:
        lst1[3] += 1
        v3.append(v)
v0.sort(reverse=True)
for i in range(1,lst1[0]):
    v0[i] += v0[i-1]
v1.sort(reverse=True)
for i in range(1,lst1[1]):
    v1[i] += v1[i-1]
v2.sort(reverse=True)
for i in range(1,lst1[2]):
    v2[i] += v2[i-1]
v3.sort(reverse=True)
for i in range(1,lst1[3]):
    v3[i] += v3[i-1]

ans = 0
for i in range(lst1[0]+1):
    for j in range(lst1[1]+1):
        for k in range(lst1[2]+1):
            for l in range(lst1[3]+1):
                res = i*tmp+j*(tmp+1)+k*(tmp+2)+l*(tmp+3)
                if W >= res:
                    res2 = 0
                    if i != 0:
                        res2 += v0[i-1]
                    if j != 0:
                        res2 += v1[j-1]
                    if k != 0:
                        res2 += v2[k-1]
                    if l != 0:
                        res2 += v3[l-1]


                    ans = max(ans,res2)

print(ans)
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 12:45:03 2020

@author: shinba
"""
import sys

S = list(input())

if S.count("K") != 1 and S.count("I") != 1 and S.count("H") != 1 and S.count("B") != 1 and S.count("R") != 1:
    print("NO")
    sys.exit()    

k = S.index("K")
i = S.index("I")
h = S.index("H")
b = S.index("B")
r = S.index("R")

if (0 <= k <= 1) and (i - k == 1) and (h - i == 1) and (0 <= b - h <= 1) and (0 <= r - b <= 1):
    if k < i < h < b < r:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


    
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue May 12 12:45:03 2020

@author: shinba
"""
import sys

S = list(input())

if S.count("K") != 1 or S.count("I") != 1 or S.count("H") != 1 or S.count("B") != 1 or S.count("R") != 1:
    print("NO")
    sys.exit()    

l = len(S)

k = S.index("K")
i = S.index("I")
h = S.index("H")
b = S.index("B")
r = S.index("R")

while "A" in S:
    S.remove("A")
    
if len(S) != 5:
    print("NO")
    sys.exit()
    

if (0 <= k <= 1) and (h - k == 2) and (1 <= b - h <= 2) and (1 <= r - b <= 2) and (l-2 <= r <= l-1):
    if k < i < h < b < r:
        print("YES")
    else:
        print("NO")
else:
    print("NO")
n = input()
A = [int(i) for i in input().split(' ')]

def trace(A):
    for index, v in enumerate(A):
        print(v, end='')
        if index != len(A) - 1:
            print(' ', end='')
    print()

def bubble_sort(A, n):
    i = n - 1
    counter = 0
    while i >= 0:
        j = i - 1
        while j >= 0:
            if A[i] < A[j]:
                A[i], A[j] = A[j], A[i]
                counter += 1
            j -= 1
        i -= 1
    trace(A)
    print(counter)

bubble_sort(A, 20)

### FIXED CODE ###

n = int(input())
A = [int(i) for i in input().split(' ')]
# A = '0 33 43 62 29 0 8 52 56 56 19 11 51 43 5 8 93 30 66 69'.split(' ')
# A = [int(i) for i in A]

def trace(A):
    for index, v in enumerate(A):
        print(v, end='')
        if index != len(A) - 1:
            print(' ', end='')
    print()

def bubble_sort(A, n):
    i = 0
    counter = 0
    while i <= n - 1:
        j = n - 1
        while j >= i + 1:
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                counter += 1
            j -= 1
        i += 1
    trace(A)
    print(counter)

bubble_sort(A, n)
import collections
A, B = [int(x) for x in raw_input().split(' ')]
def reduceNum(n):
    res = collections.Counter()
    res[1] = 1
    while n != 1:
        for index in range(2, int(n + 1)):
            while n % index == 0:
                n /= index
                res[index] += 1
    return res
sa = reduceNum(A)
sb = reduceNum(B)
be = sa & sb
print(len(be))

### FIXED CODE ###

from fractions import gcd
d = gcd(*map(int, input().split()))
r = 1
i = 2
while i * i <= d:
    r += d % i == 0
    while d % i == 0:
        d //= i
    i += 1
print(r + (d > 1))
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0

for i in range(N):
  work = C
  for j in range(M):
    work += A[j] * B[j]
  if work >= 0:
    ans += 1
    
print(ans)

### FIXED CODE ###

N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0

for i in range(N):
  A = list(map(int, input().split()))
  work = C
  for j in range(M):
    work += A[j] * B[j]
  if work > 0:
    ans += 1
    
print(ans)
Copy
Copy
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
A = sorted(A, key = lambda x:abs(x), reverse=True)
#print(A)
 
ans = []
negidx = 0
posidx = 0
neg = False
for i in range(K):
  a = A[i]
  ans.append(a)
  if a<0:
    negidx = i
    neg = not neg
  else:
    posidx = i
#print(ans, neg, negidx)
answer = 1
if neg:
  poppos = list(ans)
  pg = poppos.pop(posidx)
  popneg = list(ans)
  ng = popneg.pop(negidx)
  pgratio = None
  ngratio = None
  found = 0
  for i in range(K+1, N):
    if A[i]>=0 and ngratio is None:
      found = 1
      popneg.append(A[i])
      ngratio = -A[i]/ng
    if A[i]<0 and pgratio is None:
      found = 2
      poppos.append(A[i])
      pgratio = -A[i]/pg
    if pgratio is not None and npratio is not None:
      found = 3
      break
  if found == 1:
    for a in popnep:
      answer *= abs(a)%1000000007
    print(answer%1000000007)
  elif found == 2:
    for a in poppos:
      answer *= abs(a)%1000000007
    print(answer%1000000007)
  elif found == 3:
    if pgratio > ngratio:
      for a in poppos:
        answer *= abs(a)%1000000007
      print(answer%1000000007)
    else:
      for a in popneg:
        answer *= abs(a)%1000000007
      print(answer%1000000007)
  else:
    for i in range(K):
      answer *= A[-(i+1)]%1000000007
    print(answer%1000000007)
else:
  for a in ans:
    answer *= abs(a)%1000000007
  print(answer%1000000007)
      

### FIXED CODE ###

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

A_neg = []
A_pos = []

for i in range(N):
  if A[i] <= 0:
    A_neg.append(-A[i])
  else:
    A_pos.append(A[i])

A_neg.sort(reverse=True)
A_pos.sort(reverse=True)

ans = 1

if K == N:
  for i in range(N):
    ans *= (A[i]%1000000007)
    ans %= 1000000007
  print(ans)

elif K%2==1 and len(A_pos)==0:
  for i in range(1, K+1):
    ans *= ((-A_neg[-i])%1000000007)
    ans %= 1000000007
  print(ans)

else:
  if K%2==1:
    ans *= A_pos.pop(0)
    K -= 1
  buf = []
  for i in range(len(A_pos)//2):
    buf.append(A_pos[2*i]*A_pos[2*i+1])
  for i in range(len(A_neg)//2):
    buf.append(A_neg[2*i]*A_neg[2*i+1])
  buf.sort(reverse=True)
  for i in range(K//2):
    ans *= (buf[i]%1000000007)
    ans %= 1000000007
  print(ans)
a = int(input())
prnt(48 - a)

### FIXED CODE ###

t = int(input())
print(48 - t)
a,b,m=map(int,input().split())
A=input().split()
B=input().split()
AA=[]
for i in range(len(A)):
	AA.append(int(A[i]))
BB=[]
for i in range(len(B)):
	BB.append(int(B[i]))
C=[]
for i in range(m):
	x,y,c=map(int,input().split())
	C.append(AA[x]+BB[y]-c)
C.append(min(AA)+min(BB))
print(min(C))

### FIXED CODE ###

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

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[list(map(int,input().split())) for i in range(m)]

lis=[min(A)+min(B)]

for i in range(m):
    lis.append(A[C[i][0]-1]+B[C[i][1]-1]-C[i][2])

print(min(lis))
n, d = map(int, input().split())
i = 0
num = 0
while i < n:
  x, y = map(int, input().split())
  _d = sprt((x*x) + (y*y))
  if _d <= d:
    num += 1
  i += 1

print(num)

  

### FIXED CODE ###

import math
# -*- coding: utf-8 -*-
n, d = map(int, input().split())
i = 0
num = 0
while i < n:
  x, y = map(int, input().split())
  _d = math.sqrt((x*x) + (y*y))
  if _d <= d:
    num += 1
  i += 1
 
print(num)
a,b,c = list(map(input().split()))
print(min(a*b, c))


### FIXED CODE ###

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

print(min(a*b, c))
class UnionFind:
    def __init__(self, num):
        self.p = [x for x in range(num)]
    def root(self, x):
        if self.p[x] == x:
            return x
        self.p[x] = self.root(self.p[x])
        return self.p[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx is ry:
            return
        self.p[rx] = ry
    def same(self, x, y):
        return self.root(x) == self.root(y)

def main():
    N, M = (int(x) for x in input().split())
    u = UnionFind(N)

    for i in range(M):
        x,y,_ = map(int, input().split())
        u.unite(x-1, y-1)

    rlist = set([])
    for i in range(N):
        parent = u.root(i)
        rlist.add(parent)

    print(len(rlist))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

class UnionFind:
    def __init__(self, num):
        self.p = [x for x in range(num)]
    def root(self, x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            self.p[ry] = rx

def main():
    N, M = (int(x) for x in input().split())
    u = UnionFind(N)

    for i in range(M):
        x,y,_ = map(int, input().split())
        u.unite(x-1, y-1)

    rlist = set()
    for i in range(N):
        rlist.add(u.root(i))

    print(len(rlist))

if __name__ == '__main__':
    main()
n = int(input())
uvw = [list(map(int,input().split())) for _ in range(n-1)]

uvw =sorted(uvw,key = lambda x:(x[0],x[1]))
tree={}
tree[uvw[0][0]]=0  

for i in range(n-1):
  # treeと一致しているやつ
  if uvw[i][0] in tree:
    left = uvw[i][1]
    right = uvw[i][0]
  else:
    left = uvw[i][0]
    right = uvw[i][1]    
      
  if uvw[i][2]%2==0:
    tree[left] = tree[right]
  else:
    tree[left] = abs(tree[right]-1) 

if sum(tree.values())==0:
  tree[1]=1

for item in sorted(tree.items()):
  print(item[1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n = int(input())
uvw = [list(map(int,input().split())) for _ in range(n-1)]

e =[[] for _ in range(n)]
color = [-1]*n
dw = {}

for u,v,w in uvw:
  e[u-1].append(v-1)
  e[v-1].append(u-1)
  dw[(u-1,v-1)] = dw[(v-1,u-1)] = w

def dfs(i,c)  :
  color[i] = c
  for ei in e[i]:
    if color[ei] != -1:
      continue
    dfs(ei, c+dw[(i,ei)])

dfs(0,0)   

for c in color:
  print(c%2)
import functools
​
def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1
    
def multiply(x,y):
    ans = x*y
    if ans>=10**9+7:
        ans %= (10**9+7)
    return ans
​
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
​
if (A[-1]<0 and K%2==1) or K==N:
    combi = A[-K:]
    if K >1:
        answer =  functools.reduce(multiply,map(abs,combi[1:]))
        answer *= combi[0]
    else:
        answer = combi[0]
    answer %= 10**9+7
else:
    signs = 1
    i,j = 0,0
    for _ in range(K):
        if abs(A[i]) > abs(A[N-j-1]):
            signs *= sign(A[i])
            i += 1
            
        else:
            signs *= sign(A[N-j-1])
            j += 1
    combi = A[N-j:] + A[:i]
    del A[N-j:]
    del A[:i]
    combi = combi[::-1]     
       
    if signs == -1:
        if A:
            if A[0]>=0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            elif A[-1] <= 0:
                del combi[-1]
                combi.insert(0,A[0]) 
        
    answer =  functools.reduce(multiply,map(abs,combi))
print(answer)

### FIXED CODE ###

import functools

def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1
    
def multiply(x,y):
    ans = x*y
    if ans>=10**9+7 or ans<0:
        ans %= (10**9+7)
    return ans

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

if (A[-1]<0 and K%2==1):
    combi = A[-K:]
    if K >1:
        answer =  functools.reduce(multiply,combi)

elif K == N:
    answer = functools.reduce(multiply,A)
    
else:
    signs = 1
    i,j = 0,0
    for _ in range(K):
        if abs(A[i]) > abs(A[N-j-1]):
            signs *= sign(A[i])
            i += 1
            
        else:
            signs *= sign(A[N-j-1])
            j += 1
    combi = A[N-j:] + A[:i]
    del A[N-j:]
    del A[:i]
    combi = combi[::-1]     
       
    if signs == -1:
        if A:
            if combi[-1]<0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]>=0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            elif A[-1] <= 0:
                del combi[-1]
                combi.insert(0,A[0]) 
                
    answer =  functools.reduce(multiply,combi)
print(answer)
MAX = 10000000
def isP(n):
	for i in prime:
		if i >= n:
			break
		if n%i == 0:
			return False
	return True

r = int((MAX+1)**0.5)
s = int(r**0.5)
p = [1]*r
p[0] = p[1] = 0
for i in range(2,s):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]
prime = []
for i in range(r):
	if p[i]:
		prime.append(i)

while 1:
	n = input()
	if n == 0: break
	i = n-(1-n%2)
	while i > 12:
		p6 = isP(i-6)
		if not isP(i-8) or not isP(i-2):
			if not p6:
				i -= 10
			else:
				i -= 4
			continue
		if isP(i) and p6:
			print i
			break
		i -= 2

### FIXED CODE ###

ref = [[[10,8],[4,4]],[[10,2],[4,2]]]
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0]*len(p[2*i::i])
		
while 1:
	try:
		n = input()
		if n == 0: break
		n -= 1-n%2
		while any(not p[n-i] for i in [0,2,6,8]):
			n -= ref[p[n-2]][p[n-6]][p[n-8]]
		print n
	except:
		pass
k,n = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  if a[i] >= k/2
    a[i] = a[i] -k
print(max(a)-min(a))

### FIXED CODE ###

k,n = map(int,input().split())
a = list(map(int,input().split()))
l = []
l.append(abs(k-abs(a[0]-a[n-1])))
for i in range(n-1):
	l.append(abs(a[i]- a[i+1]))
print(sum(l)-max(l))
#output <= 1000

nums = [int(e) for e in input().split()]
flag = 0
for i in range(1,1001):
  if ((((i * 8) // 100) == nums[0]) & (((i * 10) // 100) == nums[1])):
    flag = 1
    print(i)
    break

if flag = 0:
    print(-1)

### FIXED CODE ###

#output <= 1000

nums = [int(e) for e in input().split()]
flag = 0
for i in range(1,1001):
  if ((((i * 8) // 100) == nums[0]) & (((i * 10) // 100) == nums[1])):
    flag = 1
    print(i)
    break

if flag == 0:
    print(-1)
N = int(input())
L = int(input())

aji = [(i+1)+L-1 for i in range(N)]
abs = list(map(abs, aji))
index = abs.index(min(abs))

print(sum(aji)-aji[index])

### FIXED CODE ###

N,L = input().split()

aji = [(i+1)+int(L)-1 for i in range(int(N))]
abs = list(map(abs, aji))
index = abs.index(min(abs))

print(sum(aji)-aji[index])
import itertools
n = int(input())

a = []
xys = [[] for i in range(n)]

for j in range(n):
    a.append(int(input()))
    for i in range(a[j]):
        xys[j].append(list(map(int,input().split())))


ps = []
p = [0 for i in range(n)]
for i in range(n+1):
    for combi in itertools.combinations(range(n),i):
        p = [0 for i in range(n)]
        combi = list(combi)
        for i in combi:
            p[i] = 1
        ps.append(p)

for l in range(2**n):
    for i in range(n):
        if  (ps[l])[i] == 1:
            for j in range(a[i]):
                if ps[l][xys[i][j][0] - 1] != xys[i][j][1]:
                    ps[l] = [0,0,0]

print(max(sum(ps[l]) for l in range(2**n)))


### FIXED CODE ###

n = int(input())

a = []
xys = [[] for i in range(n)]

for j in range(n):
    a.append(int(input()))
    for i in range(a[j]):
        xys[j].append(list(map(int,input().split())))


ans = 0
for i in range(1,2**n):
    cont = True
    for j in range(n):
        if (i >> j) & 1 == 1:
            for x,y in xys[j]:
                if (i >> (x-1)) & 1 != y:
                    cont = False
                    break
        if not cont:
            break
    if cont:
        ans = max(ans,bin(i)[2:].count('1'))

print(ans)
from collections import Counter

n = int(input())
v = [int(_) for _ in input().split()]

# 最終的な2値をx, yとしたとき書き換える要素が最小の場合は、
# xは、書き換えが最も少ない数。つまり、もともと最も多い数
# yも同様。
# ただ、xとyがかぶる場合があるので、それに対処。
v1 = v[0:n-2:2]
v2 = v[1:n-1:2]
v1_count = Counter(v1)
v2_count = Counter(v2)

v1_1st_common = v1_count.most_common(1)
v1_2nd_common = v1_count.most_common(2)

v2_1st_common = v2_count.most_common(1)
v2_2nd_common = v2_count.most_common(2)
sols = []

# v1を基準として多い方を考える場合。
n1 = v1_1st_common[1]
# v1の1位とv2の1位がかぶる場合
if v1_1st_common[0] == v2_1st_common[0]:
    n2 = v2_2nd_common[1]
else:
    n2 = v2_1st_common[1]
sols.append(n-n1-n2)

# v2を基準として多い方を考える場合。
n2 = v2_1st_common[1]
# v1の1位とv2の1位がかぶる場合
if v1_1st_common[0] == v2_1st_common[0]:
    n1 = v1_2nd_common[1]
else:
    n1 = v1_1st_common[1]
sols.append(n-n1-n2)
print(min(sols))


### FIXED CODE ###

from collections import Counter
n = int(input())
v = [int(_) for _ in input().split()]
v1 = []
v2 = []
for i in range(n):
    if i % 2 == 0:
        v1.append(v[i])
    else:
        v2.append(v[i])
v_count = Counter(v)
v1_count = Counter(v1)
v2_count = Counter(v2)
# print("v1_count", v1_count)
# print("v2_count", v2_count)
v1_comm = v1_count.most_common(1)
v2_comm = v2_count.most_common(1)
sols = []
# print("v1_comm", v1_comm)
# print("v2_comm", v2_comm)
if len(v_count) == 1:
    print(n//2)
else:
    key1 = v1_comm[0][1]
    # print("v1_comm[0][0]", v1_comm[0][0])
    # print("v2_comm[0][0]", v2_comm[0][0])
    if v1_comm[0][0] == v2_comm[0][0]:
        # print("hoge")
        v2_comm = v2_count.most_common(2)
        key2 = v2_comm[1][1]
    else:
        key2 = v2_comm[0][1]
    sols.append(n-key1-key2)
    key1 = v2_comm[0][1]
    if v1_comm[0][0] == v2_comm[0][0]:
        v1_comm = v1_count.most_common(2)
        key2 = v1_comm[1][1]
    else:
        key2 = v1_comm[0][1]
    sols.append(n-key1-key2)
    print(min(sols))
import itertools
n,y = map(int,input().split())
z = y//1000

list = list(range(n+1))
for a,b,c in itertools.product(list,list,list):
    v = 10*a + 5*b + c
    w = a + b + c
    if v == z and w == n:
        break
else:
    a = -1
    b = -1
    c = -1

print(str(a),str(b),str(c))


### FIXED CODE ###

print("2018"+input()[4:])
s = input()
t = input()
ls = len(s)
lt = len(t)

a = []
sum_ = 0
for i in range(ls-lt+1):
    ss = s[i:i+lt]
    sum_ = 0
    for i, alb in enumerate(lt):
        if alb == ss[i]:
            sum_+= 1
    a.append(sum_)

print(lt - max(a))

### FIXED CODE ###

s = input()
t = input()
ls = len(s)
lt = len(t)

a = []
sum_ = 0
for i in range(ls-lt+1):
    ss = s[i:i+lt]
    sum_ = 0
    for i, alb in enumerate(t):
        if alb == ss[i]:
            sum_+= 1
    a.append(sum_)

print(lt - max(a))