Harryxun/stf_run huggingface dataset:
import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = map(int, input().split())
 
result = 0
for i in range(n):
  for j in range(1,n):
    diff = map(lambda x: x*x, x[i]-x[j])
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)


### FIXED CODE ###

import math
n, d = map(int, input().split())
x = [[0 for i in range(d)] for j in range(n)]
for i in range(n):
  x[i] = list(map(int, input().split()))
result = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    diff = list(map(lambda x,y: pow(x-y,2), x[i], x[j]))
    calc = math.sqrt(sum(diff))
    if calc.is_integer():
      result +=1
print(result)
ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
        

print(ans)


### FIXED CODE ###

def N(x,y,n): # no of x...y < n
    if n<100:
        r=0
        for i in range(1,n+1):
            if str(i)[0]==str(x) and str(i)[-1]==str(y):
                r+=1
        return r
    
    r=N(x,y,99)
    d=len(str(n))
    for i in range(1,d-2):
        r+=10**i
    top=int(str(n)[0])
    if top<x:
        r+=0
    elif top==x:
        r+=int(str(n)[1:-1])
        if str(n)[-1]>=str(y):
            r+=1
    else:
        r+=10**(d-2)

        
    return r


ans=0
n=int(input())
for x in range(1,10):
    for y in range(1,10):
        ans+=N(x,y,n)*N(y,x,n)
print(ans)
a, b, h = map(int, input().split())
S = (a+b)* h / 2
print(S)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
from math import ceil
(lambda H,A : print( ceil(H/A) ))(map(int,input().split()))

### FIXED CODE ###

from math import ceil
(lambda H,A : print( ceil(H/A) ))(*map(int,input().split()))
n = int(input())

arr = input().split()
count = 1
if "0" in arr:
  count = 0
else: for i in arr:
        count *= int(i)
      if count > 1000000000000000000: count = -1
  
print(count)


### FIXED CODE ###

n = int(input())
arr = input().split()


def mult():
    if "0" in arr:
        return 0
    else:
        a = 1
        for i in arr:
            a = a * int(i)
            if a > 1000000000000000000:
                return -1
        return a

print(mult())
s = input()
p = input()
if p == s + -:
    print("Yes")
else: print("No")

### FIXED CODE ###

s = input()
t = input()
if len(s)+1 ==len(t) and all(s[i]==t[i] for i in range(len(s))):
    print("Yes")
else: print("No")
inputs = map(int, list(input()))
A, B, T = inputs

print(T // A * B)

### FIXED CODE ###

inputs = list(map(int, input().split()))
A, B, T = inputs

print(T // A * B)
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    # 最短経路問題で使われるアルゴリズムの１つ。
    # グラフ上の全ての頂点間の最短経路を探す
    # 負の閉路（辺の重みの和が負になるような閉路）がない限り、負の辺があっても使える。

    # 負の閉路を持つ場合は'NEGATIVE CYCLE'を、そうでない場合には(i,j)成分に
    # 頂点iから頂点jへの最短経路の距離を格納するdist_listをprintする関数
    def warshall_floyd(v_num, dist_lst):
        # 負の閉路を持つか
        negative_cycle_flag = False

        # 頂点iから頂点jへの経路と、頂点kを経由した場合の経路とを比較して
        # よりコストの合計が小さい方を配列に入れる動的計画法
        for k in range(v_num):
            for i in range(v_num):
                for j in range(v_num):
                    # i→k→jがつながっててしかもi→jルートよりもイケてるなら更新
                    if dist_lst[i][k] != INF and dist_lst[k][j] != INF:
                        if dist_lst[i][j] > dist_lst[i][k] + dist_lst[k][j]:
                            dist_lst[i][j] = dist_lst[i][k] + dist_lst[k][j]

        for v in range(v_num):
            # dist_lstに負の数が格納されているとは、
            # グラフが負の閉路を持つことを意味する
            if dist_lst[v][v] < 0:
                negative_cycle_flag = True

        if negative_cycle_flag:
            print("NEGATIVE CYCLE")
        else:
            return dist_lst

    H, W = map(int, input().split())
    # 頂点の数と辺の数
    v_num, e_num = 10, 100

    # 配列dist_lst[a][b]には頂点a,b間の辺のコストを入れておき、
    # a=bの時は0を、a,b間の辺が存在しないときはINFを入れておく。
    INF = 10 ** 20
    dist_lst = [[INF] * v_num for _ in range(v_num)]

    costs = [[i for i in list(map(int, input().split()))] for _ in range(10)]
    for s in range(10):
        for t in range(10):
            dist_lst[s][t] = costs[s][t]

    dist_lst = warshall_floyd(v_num, dist_lst)
    wall = [[i for i in list(map(int, input().split()))] for _ in range(10)]
    cnt = 0
    for h in range(H):
        for w in range(W):
            val = wall[h][w]
            if val != -1:
                cnt += dist_lst[val][1]
    print(cnt)


resolve()

### FIXED CODE ###

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    H, W = map(int, input().split())

    graph = [[i for i in list(map(int, input().split()))] for _ in range(10)]
    graph = csr_matrix(graph)

    dist_matrix = floyd_warshall(csgraph=graph, directed=True, return_predecessors=False)
    dist_matrix = list(dist_matrix)

    wall = [[i for i in list(map(int, input().split()))] for _ in range(H)]

    cnt = 0
    for h in range(H):
        for w in range(W):
            val = wall[h][w]
            if val != -1 and val != 1:
                cnt += dist_matrix[val][1]
    print(int(cnt))


resolve()
import itertools 
x = int(input())
list_ = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "y", "w", "z" ]
len(list_)
kara = []
if x >= 1 and x <= 26 :
    ans = 0
    for i in itertools.product(list_, repeat = 1):
        ans += 1
        if ans == n:
            print(*i, sep = '')
elif 27<=x and x<= 702:
    ans = 26
    for i in itertools.product(list_, repeat = 2):
        ans += 1
        if ans == n:
            print(*i, sep = '')
elif 703<=x and x<=18278:
    ans = 702
    for i in itertools.product(list_, repeat = 3):
        ans += 1
        if ans == n:
            print(*i, sep='')
elif x <= 475254:
    ans = 18278
    for i in itertools.product(list_, repeat = 4):
        ans += 1
        if ans == n:
            print(*i, sep='')
elif x <= 12356630:
    ans =475254
    for i in itertools.product(list_, repeat = 5):
        ans += 1
        if ans == n:
            print(*i, sep='')
elif x <= 321272406:
    ans = 12356630
    for i in itertools.product(list_, repeat = 6):
        ans += 1
        if ans == n:
            print(*i, sep='')
elif x <= 8353082582:
    ans = 321272406
    for i in itertools.product(list_, repeat = 7):
        ans += 1
        if ans == n:
            print(*i, sep='')
elif x <= 217180147158:
    ans = 8353082582
    for i in itertools.product(list_, repeat = 8):
        ans += 1
        if ans == n:
            print(*i, sep='')
elif x <= 5646683826134:
    ans = 217180147158
    for i in itertools.product(list_, repeat = 9):
        ans += 1
        if ans == n:
            print(*i, sep='')
elif x <= 146813779479510:
    ans = 5646683826134
    for i in itertools.product(list_, repeat = 10):
        ans += 1
        if ans == n:
            print(*i, sep='')
elif x <= 3817158266467286:
    ans = 5646683826134
    for i in itertools.product(list_, repeat = 11):
        ans += 1
        if ans == n:
            print(*i, sep='')

### FIXED CODE ###

n = int(input())
n -= 1
for i in range(1, 15):
    if n >= 26**i :
        n -= 26**i
        continue 
    ans = ""
    for j in range(i):
        d = n % 26
        ans += chr(ord("a")+d)
        n //= 26
    ans = ans[::-1]
    break
print(ans)
#!/usr/bin/env python
# coding: utf-8

# In[14]:


import math


# In[21]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[22]:


ans = pow(2, n, mod)-1
ans -= nCk(n, a, mod) + nCk(n, b, mod)
print(ans%mod)


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[1]:


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


# In[2]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[3]:


mod = 10**9+7
ans = pow(2, n, mod)-1
ans -= nCk(n, a, mod) + nCk(n, b, mod)
print(ans%mod)


# In[ ]:
#!/usr/bin/env python3

N = int(input())
# S = input()
# N, K = map(int, input().split())
P = list(map(int, input().split()))

def main():
    pre = 0
    ans = 0
    for i, p in enumerate(P, 1):
        if i == p:
            ans += 1
            P[i] = p
    print(ans)
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

N = int(input())
# S = input()
# N, K = map(int, input().split())
P = list(map(int, input().split()))

def main():
    ans = 0
    for i, p in enumerate(P, 1):
        if i == p:
            ans += 1
            if i != N:
                P[i] = p
    print(ans)

if __name__ == "__main__":
    main()
#!/usr/bin/env python3
from typing import *

# def solve(X: int, Y: int, Z: int) -> Any:
def solve(x, y, z):
    x, y = y, x
    x, z = z, x
    return x, y, z

# generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
def main():
    X, Y, Z = map(int, input().split())
    ans = solve(X, Y, Z)
    print(*ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# from typing import *

# def solve(X: int, Y: int, Z: int) -> Any:
def solve(x, y, z):
    x, y = y, x
    x, z = z, x
    return x, y, z

# generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
def main():
    X, Y, Z = map(int, input().split())
    ans = solve(X, Y, Z)
    print(*ans)

if __name__ == '__main__':
    main()
#wlist = list(map(int,input().split()))
nlist = list(input().split())
if nlist.couunt("5") ==2 and nlist.count("7")==1:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

#wlist = list(map(int,input().split()))
nlist = list(input().split())
if nlist.count("5") ==2 and nlist.count("7")==1:
    print("YES")
else:
    print("NO")
n=int(input())

zahyo=[]

for _ in range(n):
    zahyo.append(list(map(int,input().split())))

for x in range(101):
    for y in range(101):

        flag=0
        saisho=10**9+1
        H=0
        for item in zahyo:
            if item[2]==0:
                saisho=min(saisho,abs(x-item[0])+abs(y-item[1]))
            else:
                if H==0:
                    H=item[2]+abs(item[0]-x)+abs(item[1]-y)
                else:
                    H_temp=item[2]+abs(item[0]-x)+abs(item[1]-y)
                    if H_temp!=H:
                        flag=1
                        break
        if flag==0 and H<=saisho:
            print(x,y,H)


            




### FIXED CODE ###

n=int(input())
if n==1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)
while True:
    h, w = map(int, input().split())
    if h == 0: break

    for i in range(h)
        for j in range(w)
            if (i+j) % 2 == 0 : print("#")
            else : print(".")
        print() 
    print()



### FIXED CODE ###


while True:
    h, w = map(int, input().split())
    if h == 0: break

    for i in range(h):
        for j in range(w):
            if (i+j) % 2 == 0 : print("#",end="")
            else : print(".",end="")
        print() 
    print()
import sys
import math

a,b,h,m = (int(x) for x in input().split())

zi = 0.5 * 60 * h + 0.5 * m
hun = 6 * h * 60 + 6 * m

if hun >= 360:
    for i in range(12):

        if hun >= 360:
            hun = hun - 360 
        elif hun < 360:
            break

if hun > zi:
    if hun - zi > 180:
        degree = 360 - hun + zi
    elif hun - zi < 180:
        degree = hun - zi
    elif hun - zi == 180:
        print(a + b)
        sys.exit()
elif hun == zi:
    print(b - a)
    sys.exit()
else:
    if zi - hun > 180:
        degree = 360 - zi + hun
    elif zi - hun < 180:
        degree = zi - hun
    elif hun - zi == 180:
        print(a + b)
        sys.exit()

cosain = math.cos(math.radians(degree))

print(math.sqrt(a ** 2 + b**2 -2 * a * b *cosain))


    

### FIXED CODE ###

import sys
import math

a,b,h,m = (float(x) for x in input().split())

zi = 0.5 * 60 * h + 0.5 * m
hun = 6 * h * 60 + 6 * m

if hun >= 360:
    for i in range(11):

        if hun >= 360:
            hun = hun - 360 
        elif hun < 360:
            break



if hun > zi:
    if hun - zi > 180:
        degree = 360 - hun + zi
    elif hun - zi < 180:
        degree = hun - zi
    elif hun - zi == 180:
        print(a + b)
        sys.exit(0)

elif zi > hun: 
    if zi - hun > 180:
        degree = 360 - zi + hun
    elif zi - hun < 180:
        degree = zi - hun
    elif zi - hun == 180:
        print(a + b)
        sys.exit(0)
elif hun == zi:
    if b >= a:
        print(b - a)
        sys.exit(0)
    else:
        print(a-b)
        sys.exit(0)

cosain = math.cos(math.radians(degree))

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cosain))
from sys import stdin
readline = stdin.readline
H,W = map(int,input().split())
A = ['' for i in range(H)]
colors = [[-2 for j in range(W)] for i in range(H)]
q = []
for i in range(H):
    A[i] = list(readline())
    for j,color in enumerate(A[i]):
        colors[i][j] = 0 if color == '#' else -1
        if '#' == color:
            q.append([i,j,0])
            colors[i][j] = 0
# for i in colors:
#     print(i)
mx = 0
direction = [[1,0],[0,1],[-1,0],[0,-1]]

while len(q) > 0:
    # print(q)
    tmp = [y,x,op] = q.pop(0)
    mx = max(mx,op)
    if colors[y][x] >= 0 and mx > 0: continue
    for [dx,dy] in direction:
        ny,nx = y + dy , x + dx
        if  0 <= ny and ny < H and 0 <= nx and nx < W:
            if A[ny][nx] == '#' or colors[ny][nx] >= 0:
                continue
            q.append([ny,nx,op+1])
            colors[y][x] = op+1
print(mx)

### FIXED CODE ###

from sys import stdin
from collections import deque
def main():
    readline = stdin.readline
    H,W = map(int,readline()[:-1].split())
    A = ['' for i in range(H)]
    visited = [[False] * W for i in range(H)]
    q = deque()
    for i in range(H):
        A[i] = readline()[:-1]
        # print(A[i])
        for j,color in enumerate(A[i]):
            if '#' == color:
                q.append([i,j,0])
                visited[i][j] = True
            # for i in visited:
            #     print(i)
    mx = 0
    direction = [[1,0],[0,1],[-1,0],[0,-1]]
    op = -1
    while len(q) > 0:
        # print(q)
        tmp = [y,x,op] = q.popleft()
        # print(tmp)
        mx = mx if mx > op else op
        for [dx,dy] in direction:
            ny,nx = y + dy , x + dx
            if  0 <= ny and ny < H and 0 <= nx and nx < W:
                if A[ny][nx] == '#' or visited[ny][nx] == True:
                    continue
                q.append([ny,nx,op+1])
                visited[ny][nx] = True
    print(op)

main()
def c_coloring_colorfully(S):
    s1 = '10' * (len(S) // 2) + ('1' if len(S) % 2 == 1 else '')
    s2 = '01' * (len(S) // 2) + ('0' if len(S) % 2 == 1 else '')
    ans1, ans2 = 0, 0
    for k, s in enumerate(S):
        if s != s1[k]:
            ans1 += 1
        if s != s2[k]:
            ans2 += 1
    return min(ans1, ans2)

S = input()
print(c_doloring_colorfully(S))

### FIXED CODE ###

def c_coloring_colorfully(S):
    s1 = '10' * (len(S) // 2) + ('1' if len(S) % 2 == 1 else '')
    s2 = '01' * (len(S) // 2) + ('0' if len(S) % 2 == 1 else '')
    ans1, ans2 = 0, 0
    for k, s in enumerate(S):
        if s != s1[k]:
            ans1 += 1
        if s != s2[k]:
            ans2 += 1
    return min(ans1, ans2)

S = input()
print(c_coloring_colorfully(S))
import heapq
from collections import deque

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

work = [list(map(int,input().split())) for _ in range(N)]

wq = deque(sorted(work))

paytree = []

ans = 0

for day in range(M + 1):
    while len(wq) > 0 and wq[0][0] <= day:
        heapq.heappop(paytree, wq.popleft()[1] * (-1))
    if len(paytree) > 0:
        ans -= heapq.heappop(paytree)

print(ans)

### FIXED CODE ###

import heapq
from collections import deque

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

work = [list(map(int,input().split())) for _ in range(N)]

wq = deque(sorted(work))

paytree = []

ans = 0

for day in range(M + 1):
    while len(wq) > 0 and wq[0][0] <= day:
        heapq.heappush(paytree, wq.popleft()[1] * (-1))
    if len(paytree) > 0:
        ans -= heapq.heappop(paytree)

print(ans)
k = int(input())
a = '7' * (k - 1)
if int(a) % k == 0:
    for i in range(1, 100):
        a = '7' * i
        if int(a) % k == 0:
            print(i)
            exit()
    print(k-1)
print(-1)


### FIXED CODE ###

k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
i = 0
ai = 0
while True:
    ai = (ai * 10 + 7) % k
    i += 1
    if ai == 0:
        break
print(i)
N = int(input())
list = []
for i in range(N):
  list.attend(N)
  N -= 1
print(sum(list))

### FIXED CODE ###

N = int(input())
print(N*(N+1)//2)
from functools import lru_cache
import sys
sys.setrecursionlimit(2000)

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

@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    return min(abs(h[n]-h[n-1]) + rec(n-1), abs(h[n]-h[n-2]) + rec(n-2))

print(rec(n-1))


### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
res = [0] * n

res[1] = abs(h[1] - h[0])
for i in range(2, n):
    res[i] = min(res[i-2] + abs(h[i] - h[i-2]),
                 res[i-1] + abs(h[i] - h[i-1]))

print(res[-1])
H,W=list(map(int,input().split()))
A=[]
for i in range(H):
    A.append(list(map(int,input().split())))
sum_=0
ans=[]
for i,aline in enumerate(A):
    for j in range(W-1):
        if aline[j]%2==1:
            aline[j+1]+=1
            sum+=1
            ans.append('{0} {1} {2} {3}'.format(i+1,j+1,i+1,j+2))
for i,aline in enumerate(A[:-1]):
    if aline[W-1]%2==1:
        A[i+1][W-1]+=1
        sum_+=1
        ans.append(('{0} {1} {2} {3}'.format(i+1,j+1,i+2,j+1)))
print(sum_)
for x in ans:
    print(x)

### FIXED CODE ###

H,W=list(map(int,input().split()))
A=[]
for i in range(H):
    A.append(list(map(int,input().split())))
sum_=0
ans=[]
for i,aline in enumerate(A):
    for j in range(W-1):
        if aline[j]%2==1:
            aline[j+1]+=1
            sum_+=1
            ans.append('{0} {1} {2} {3}'.format(i+1,j+1,i+1,j+2))
for i,aline in enumerate(A[:-1]):
    if aline[W-1]%2==1:
        A[i+1][W-1]+=1
        sum_+=1
        ans.append(('{0} {1} {2} {3}'.format(i+1,W,i+2,W)))
print(sum_)
for x in ans:
    print(x)
def solve( ):
    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval('S[0] + a + S[1] +b + S[2] + c + S[3]) == 7:
                    return 'S[0] + a + S[1] +b + S[2] + c + S[3]=7'
                    break

S = input()
print(solve(S))


### FIXED CODE ###

S = input()


for i in range(8):
    f = ""
    B = ["-"]*3

    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    
        
    if eval(f) == 7:
        print(f+"=7")
        break
import math

def main():
  R = input()
  answer = R * 2 / 3.14
  print(answer)
  
if __name__ == '__main__':
  main()

### FIXED CODE ###

import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()
print(int(input())*6.3)


### FIXED CODE ###

import math

R = int(input())

print(R * 2 * math.pi)
from scipy.special import comb
N,A,B = map(int,input().split())
v = list(map(int,input().split()))
v.sort(reverse=True)

ans = 0
if v[A-1] == v[0]:
    mean = v[0]
    count = 0
    for i in range(N):
        if v[i] == v[0]:
            count += 1
    for i in range(A,min(B,count)+1):
        ans += comb(count,i,exact=True)
else:
    mean = sum(v[:A])/A
    count = 0
    j = N
    for i in range(N):
        if v[i] == v[A-1]:
            j = min(i,j)
            count += 1
    ans = comb(count,A-j,exact=True)
print(mean)
print(ans)

### FIXED CODE ###

def fact(n):
    if n == 0:
        return 1
    else:
        return n*fact(n-1)
def conb(n,r):
    return fact(n)//(fact(r)*fact(n-r))

N,A,B = map(int,input().split())
v = list(map(int,input().split()))
v.sort()
v.reverse()
d_all = {}
for i in range(N):
    if v[i] not in d_all:
        d_all[v[i]] = 0
    d_all[v[i]] += 1
import numpy as np
avg = np.cumsum(np.array(v))
avg = [0]*N
avg[0]=v[0]
for i in range(N-1):
    avg[i+1]=avg[i]+v[i+1]
for i in range(N):
    avg[i]=avg[i]/(i+1)
    
avg = avg[A-1:B]
ans = max(avg)
print(ans)
avg=np.array(avg)
indices = np.where(avg==ans)[0]
ans = 0
for index in indices:
    d_use = {}
    use = A + index
    v_use = v[:use]
    choose=1
    for item in v_use:
        if item not in d_use:
            d_use[item] = 0
        d_use[item] += 1
    for item in d_use:
        choose *= conb(d_all[item],d_use[item])
    ans += choose

print(ans)
#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(filter(lambda e: e != e2, E))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(filter(lambda o: o != o2, O))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)

    num = 0
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return

def len2(l):
    n = 0
    for i in l:
        n += 1
    return n

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()