Problem:


Score : 300 points

Problem Statement

A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:

For each i = 1,2,..., n-2, a_i = a_{i+2}.

Exactly two different numbers appear in the sequence.

You are given a sequence v_1,v_2,...,v_n whose length is even.
We would like to make this sequence /\/\/\/ by replacing some of its elements.
Find the minimum number of elements that needs to be replaced.

Constraints

2 \leq n \leq 10^5

n is even.

1 \leq v_i \leq 10^5

v_i is an integer.

Input

Input is given from Standard Input in the following format:

n
v_1 v_2 ... v_n

Output

Print the minimum number of elements that needs to be replaced.

Sample Input 1

4
3 1 3 2

Sample Output 1

1

The sequence 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.

Sample Input 2

6
105 119 105 119 105 119

Sample Output 2

0

The sequence 105,119,105,119,105,119 is /\/\/\/.

Sample Input 3

4
1 1 1 1

Sample Output 3

2

The elements of the sequence 1,1,1,1 are all the same, so it is not /\/\/\/.



Sample input:
4
3 1 3 2


Sample output:
1

Submission status: Wrong Answer

Solution code:
from itertools import groupby

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

odd=[v[i] for i in range(0,n) if i%2==1]
even=[v[i] for i in range(0,n) if i%2==0]
odd.sort()
even.sort()
odd=groupby(odd)
even=groupby(even)
oddm1=0
oddm2=0
oddmax=0
evenm1=0
evenm2=0
evenmax=0
for key,group in odd:
    g=len(list(group))
    if g>oddm1:
        oddm1=g
        oddmax=key
    elif g>oddm2:
        oddm2=g
for key,group in even:
    g=len(list(group))
    if g>evenm1:
        evenm1=g
        evenmax=key
    elif g>evenm2:
        evenm2=g
if oddmax!=evenmax:
    print(n-oddm1-evenm1)
else:
    print(min(n-oddm2-evenm1,n-oddm1-evenm2))

Submission status: Wrong Answer

Solution code:
from itertools import groupby

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

odd=[v[i] for i in range(0,n) if i%2==1]
even=[v[i] for i in range(0,n) if i%2==0]
odd.sort()
even.sort()
odd=groupby(odd)
even=groupby(even)
oddm1=0
oddm2=0
oddmax=0
evenm1=0
evenm2=0
evenmax=0
for key,group in odd:
    g=len(list(group))
    if g>oddm1:
        oddm1=g
        oddmax=key
    elif g>oddm2:
        oddm2=g
for key,group in even:
    g=len(list(group))
    if g>evenm1:
        evenm1=g
        evenmax=key
    elif g>oddm2:
        evenm2=g
if oddmax!=evenmax:
    print(n-oddm1-evenm1)
else:
    print(min(n-oddm2-evenm1,n-oddm1-evenm2))

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int,input().split()))

O = [0] * 10 ** 6
E = [0] * 10 ** 6

for v in range(len(V)):
  if v % 2 == 0:
    E[V[v]] += 1
  else:
    O[V[v]] += 1
    
o_max = max(O)
e_max = max(E)

o = [i for i,x in enumerate(O) if x == o_max]
e = [i for i,x in enumerate(E) if x == e_max]

ans = 0
if len(o) == 1 and len(e) == 1 and e[0] == o[0]:
  a=max(sorted(O)[-2],sorted(E)[-2])
  if a == 0:
    print(int(N/2))
  else:
    print(int(int(N/2 - o_max) + int(N/2 - e_max)))
else:
  print(int(int(N/2 - o_max) + int(N/2 - e_max)))

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int,input().split()))

O = [0] * 10 ** 6
E = [0] * 10 ** 6

for v in range(len(V)):
  if v % 2 == 0:
    E[V[v]] += 1
  else:
    O[V[v]] += 1
    
o_max = max(O)
e_max = max(E)

o = [i for i,x in enumerate(O) if x == o_max and x % 2 == 1]
e = [i for i,x in enumerate(E) if x == e_max and x % 2 == 0]

ans = 0
if len(o) == 1 and len(e) == 1 and e[0] == o[0]:
  a=max(sorted(O)[-2],sorted(E)[-2])
  if a == 0:
    print(int(N/2))
  else:
    print(int(int(N/2 - o_max) + int(N/2 - e_max)))
print(int(int(N/2 - o_max) + int(N/2 - e_max)))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = [x for x in input().split()]
v1, v2 = collections.Counter(v[0::2]), collections.Counter(v[1::2])
v1 = sorted(v1.items(), key=lambda x:x[1])[::-1]
v2 = sorted(v2.items(), key=lambda x:x[1])[::-1]
if v1[0][0] != v2[0][0]: print(n - v1[0][1] - v2[0][1])
else:
    if v1[0][1] == n // 2 and v2[0][1] == n // 2: print(n // 2)
    elif v1[0][1] == n // 2: print(n // 2 - v2[1][1])
    elif v2[0][1] == n // 2: print(n // 2 - v1[1][1])
    else:
        if v1[0][1] < v2[0][1]: print(n - v1[1][1] - v2[0][1])
        else: print(n - v1[0][1] - v2[1][1])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = [x for x in input().split()]
v1, v2 = collections.Counter(v[0::2]), collections.Counter(v[1::2])
v1 = sorted(v1.items(), key=lambda x:x[1])[::-1]
v2 = sorted(v2.items(), key=lambda x:x[1])[::-1]
if v1[0][0] != v2[0][0]: print(n - v1[0][1] - v2[0][1])
else:
    if v1[0][1] == n // 2 and v2[0][1] == n // 2: print(n // 2)
    elif v1[0][1] == n // 2: print(n // 2 - v2[0][1])
    elif v2[0][1] == n // 2: print(n // 2 - v1[0][1])
    else:
        if v1[0][1] < v2[0][1]: print(n - v1[1][1] - v2[0][1])
        else: print(n - v1[0][1] - v2[1][1])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = [x for x in input().split()]
v1, v2 = collections.Counter(v[0::2]), collections.Counter(v[1::2])
v1 = sorted(v1.items(), key=lambda x:x[1])
v2 = sorted(v2.items(), key=lambda x:x[1])
if v1[0][0] != v2[0][0]: print(n - v1[0][1] - v2[0][1])
else:
    if v1[0][1] == n // 2 and v2[0][1] == n // 2: print(n // 2)
    elif v1[0][1] == n // 2: print(n // 2 - v2[0][1])
    elif v2[0][1] == n // 2: print(n // 2 - v1[0][1])
    else:
        if v1[0][1] < v2[0][1]: print(n - v1[1][1] - v2[0][1])
        else: print(n - v1[0][1] - v2[1][1])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = [x for x in input().split()]
v1, v2 = collections.Counter(v[0::2]), collections.Counter(v[1::2])
v1 = sorted(v1.items(), key=lambda x:x[1])
v2 = sorted(v2.items(), key=lambda x:x[1])
if v1[0][0] != v2[0][0]: print(n - v1[0][1] - v2[0][1])
else:
    if v1[0][1] == n // 2 and v2[0][1] == n // 2: print(n // 2)
    elif v1[0][1] == n // 2: print(n // 2 - v2[1][1])
    elif v2[0][1] == n // 2: print(n // 2 - v1[1][1])
    else:
        if v1[0][1] < v2[0][1]: print(n - v1[1][1] - v2[0][1])
        else: print(n - v1[0][1] - v2[1][1])

Submission status: Wrong Answer

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

v1 = [0] * (10**5)
v2 = [0] * (10**5)

for i in range(0,n,2):
	v1[v[i]-1] += 1

for i in range(1,n,2):
	v2[v[i]-1] += 1

ans = n - ( max(v1) + max(v2) )
if ans == 0:
	if v[0] == v[1]:
		print(n//2)
		exit()

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
kisu = sorted(v[0::2])
gusu = sorted(v[1::2])
ans = 0
if len(set(v)) == 1 :
    ans += len(set(v))//2
else:
    for i in range(0, len(kisu)-1) :
        if kisu[i] != kisu[i+1]:
            ans += 1
    for i in range(0, len(gusu)-1) :
        if gusu[i] != gusu[i+1]:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = [s for s in input().split()]
v_0, v_1 = {}, {}
for i, vi in enumerate(v):
    if i % 2 == 0:
        if vi not in v_0.keys():
            v_0[vi] = 0
        v_0[vi] += 1
    else:
        if vi not in v_1.keys():
            v_1[vi] = 0
        v_1[vi] += 1
v_0 = sorted(v_0.items(), key=lambda x:x[1])[::-1]
v_1 = sorted(v_1.items(), key=lambda x:x[1])[::-1]
if v_0[0][0] == v_1[0][0] and v_0[0][1] == v_1[0][1]: print(n//2)
elif v_0[0][0] == v_1[0][0]:
    if v_0[0][1] <= v_1[0][1]:
        print(int(n - v_1[0][1] - v_0[1][1]))
    else:
        print(int(n - v_1[1][1] - v_0[0][1]))
else: print(int(n - v_0[0][1] - v_1[0][1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = [s for s in input().split()]
v_0, v_1 = {}, {}
for i, vi in enumerate(v):
    if i % 2 == 0:
        if vi not in v_0.keys():
            v_0[vi] = 0
        v_0[vi] += 1
    else:
        if vi not in v_1.keys():
            v_1[vi] = 0
        v_1[vi] += 1
v_0 = sorted(v_0.items(), key=lambda x:x[1])[::-1]
v_1 = sorted(v_1.items(), key=lambda x:x[1])[::-1]
if v_0[0][0] == v_1[0][0]: print(n//2)
else: print(int(n - v_0[0][1] - v_1[0][1]))

Submission status: Wrong Answer

Solution code:
import collections

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

L1 = []
L2 = []

for i in range(N):
  if i % 2 == 0:
    L1.append(V[i])
  else:
    L2.append(V[i])
    
con1 = collections.Counter(L1).most_common()
con2 = collections.Counter(L2).most_common()

nums = 0

for i in range(1,len(con1)):
  nums += con1[i][1]

for i in range(1,len(con2)):
  nums += con2[i][1]
  
if len(set(V)) == 1:
  print(N // 2)
elif len(set(L1)) == 1 and len(set(L2)) == 1:
  print(0)
else:
  print(nums)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
v = list(map(int,input().split()))

countT = np.bincount(v[0::2])
top = countT.argsort()[::-1]
countU = np.bincount(v[1::2])
under = countU.argsort()[::-1]

if countT[0]==countU[0]:
    print(N-max(countT[top[0]]+countU[under[1]], countT[top[1]]+countU[under[0]]))
else:
    print(N-countT[top[0]]-countU[under[0]])

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int,input().split()))

import numpy as np
top = np.argmax(np.bincount(v[0::2]))
under = np.argmax(np.bincount(v[1::2]))

if top==under:
    print(int(N/2))
else:
    print(N-v[0::2].count(top)-v[1::2].count(under))

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int,input().split()))

import numpy as np
top = np.argmax(np.bincount(v[0::2]))
under = np.argmax(np.bincount(v[1::2]))

print(N-v[0::2].count(top)-v[1::2].count(under))

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections

N = int(input())
V = np.array(list(map(int, input().split())))

if N == len(np.where(V == V[0])[0]):
    print(N // 2)
else:
    v0 = [V[i] for i in range(0, N - 1, 2)]
    v1 = [V[i] for i in range(1, N, 2)]
    count = (N // 2) - max(collections.Counter(v0).values())
    count += (N // 2) - max(collections.Counter(v1).values())
    print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
V = np.array(list(map(int, input().split())))
count = 0

if N == len(np.where(V == V[0])[0]):
    print(N // 2)
else:
    for n in range(N - 2):
        if V[n] != V[n + 2]:
            count += 1
            V[n + 2] = V[n]
    print(count)

Submission status: Wrong Answer

Solution code:
import collections

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

c=collections.Counter(l[::2])
c=c.most_common()
d=collections.Counter(l[1::2])
d=d.most_common()

if c[0][0]==d[0][0]:
    if len(c)==1 and len(d)==1:
        print(n//2)
    elif len(c)==1:
        print(n//2-d[1][1])
    elif len(d)==1:
        print(n//2-c[1][1])
    else:
        if c[0][1]<=d[0][1]:
            print(n-c[1][1]-d[0][1])
        else:
            print(n-d[1][1]-c[0][1])
else:
    print(n-c[0][1]-d[0][1])

Submission status: Wrong Answer

Solution code:
import collections

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

c=collections.Counter(l[::2])
c=c.most_common()
d=collections.Counter(l[1::2])
d=d.most_common()

if c[0][0]==d[0][0]:
    if len(c)==1 and len(d)==1:
        print(n//2)
    elif len(c)==1:
        print(n-d[1][1])
    elif len(d)==1:
        print(n-c[1][1])
    else:
        if c[0][1]<=d[0][1]:
            print(n-c[1][1]-d[0][1])
        else:
            print(n-d[1][1]-c[0][1])
else:
    print(n-c[0][1]-d[0][1])

Submission status: Wrong Answer

Solution code:
import collections

n=int(input())
l=list(map(int,input().split()))
m=0
c=collections.Counter(l[::2])
d=collections.Counter(l[1::2])

if c.most_common()[0][0]==d.most_common()[0][0] and d.most_common()[0][1]<=c.most_common()[0][1]:
    m=m+n//2-c.most_common()[0][1]
    try:
        m=m+n//2-d.most_common()[1][1]
    except IndexError:
        m=m+n//2
if c.most_common()[0][0]==d.most_common()[0][0] and d.most_common()[0][1]>c.most_common()[0][1]:
    m=m+n//2-d.most_common()[0][1]
    try:
        m=m+n//2-c.most_common()[1][1]
    except IndexError:
        m=m+n//2

else:
    m=m+n-d.most_common()[0][1]-c.most_common()[0][1]


print(m)

Submission status: Wrong Answer

Solution code:
import collections

n=int(input())
l=list(map(int,input().split()))
m=0
c=collections.Counter(l[::2])
m=m+n//2-c.most_common()[0][1]

d=collections.Counter(l[1::2])

if c.most_common()[0][0]==d.most_common()[0][0]:
    try:
        m=m+n//2-d.most_common()[1][1]
    except IndexError:
        m=m+n//2

else:
    m=m+n//2-d.most_common()[0][1]


print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
V = [int(i) for i in input().split()]
cnt, cnt1 = 0, 0
v0 = V[0]
v1 = V[1]
for i in range(2,n):
  if i%2 == 0 and V[i]!=v0:
    cnt += 1
  elif i%2!=0 and V[i]!=v1:
    cnt1 += 1
ans0 = min(cnt, n//2-cnt)
ans1 = min(cnt1, n//2-cnt1)
if v0 == v1 and cnt==0 and cnt1==0:
  print(len(V)//2)
else:
  print(ans0+ans1)

Submission status: Wrong Answer

Solution code:
print("hello")

Submission status: Wrong Answer

Solution code:
import collections

num_of_nums = int(input())
numbers = list(map(int, input().split(" ")))
numbers_odd = [numbers[i] for i in range(1, num_of_nums, 2)]
numbers_even = [numbers[j] for j in range(0, num_of_nums, 2)]
c_odd = collections.Counter(numbers_odd)
c_even = collections.Counter(numbers_even)

counter_odd = 0
counter_even = 0

if sum(numbers) / int(len(numbers)) != numbers[0]:
    if c_odd.most_common()[0][0] != c_even.most_common()[0][0]:
        counter_odd += int(len(numbers_odd)) - c_odd.most_common()[0][1]
        counter_even += int(len(numbers_even)) - c_even.most_common()[0][1]
        print(counter_even + counter_odd)
    else:
        if c_odd.most_common()[1][0] <= c_even.most_common()[1][0]:
            counter_odd += int(len(numbers_odd)) - c_odd.most_common()[0][1]
            counter_even += int(len(numbers_even)) - c_even.most_common()[1][1]
            print(counter_even + counter_odd)
        else:
            counter_odd += int(len(numbers_odd)) - c_odd.most_common()[1][1]
            counter_even += int(len(numbers_even)) - c_even.most_common()[0][1]
            print(counter_odd + counter_even)
else:
    print(int(int(len(numbers)) / 2))

Submission status: Wrong Answer

Solution code:
num_of_nums = int(input())
numbers = list(map(int, input().split(" ")))
counter_even = 0
counter_odd = 0
counter_total = 0

if sum(numbers) / num_of_nums != numbers[0]:
    for i in range(0, num_of_nums, 2):
        if numbers[0] != numbers[i]:
            counter_even += 1
    
    for j in range(1, num_of_nums, 2):
        if numbers[1] != numbers[j]:
            counter_odd += 1

    if counter_even > num_of_nums // 4:
        counter_total += num_of_nums / 2 - counter_even
    else:
        counter_total += counter_even
    
    if counter_odd > num_of_nums // 4:
        counter_total += num_of_nums / 2 - counter_odd
    else:
        counter_total += counter_odd
else:
    counter_total += num_of_nums / 2
    
print(int(counter_total))

Submission status: Wrong Answer

Solution code:
n=int(input())  
v=list(map(int, input().split()))
odd = []
even = []
for i in range(n):
  if i % 2 ==0:
    odd.append(v[i])
  else:
    even.append(v[i])
#集計
from collections import Counter
oddc=Counter(odd)
evenc=Counter(even)
od = oddc.most_common(2)
ev = evenc.most_common(2)
m =od[0][1] + ev[0][1]
if len(od)>1:
  m = max(m,od[1][1] + ev[0][1])
if len(ev)>1:
  m = max(m,ev[1][1] + od[0][1])
if odd == even and len(od)==1:
  print(n//2)
else:
  print(n-m)

Submission status: Wrong Answer

Solution code:
n=int(input())  
v=list(map(int, input().split()))
odd = []
even = []
for i in range(n):
  if i % 2 ==0:
    odd.append(v[i])
  else:
    even.append(v[i])
#集計
from collections import Counter
oddc=Counter(odd)
evenc=Counter(even)
od = oddc.most_common(2)
ev = evenc.most_common(2)
m =od[0][1] + ev[0][1]
if len(od)>1:
  m = max(m,od[1][1] + ev[0][1])
if len(ev)>1:
  m = max(m,ev[1][1] + od[0][1])
if odd == even:
  print(n//2)
else:
  print(n-m)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n    = int(raw_input())
nums = list(map(int, raw_input().split()))

nums_odd  =   nums[0:n:2]
nums_even =   nums[1:n:2]

N_odd     =   sorted(Counter(nums_odd ).items(), key=lambda x: x[1], reverse=True) + [(-1,0)]
N_even    =   sorted(Counter(nums_even).items(), key=lambda x: x[1], reverse=True) + [(-1,0)]

if N_odd[0][0] == N_even[0][0]:
    if N_odd[0][1] + N_even[1][1] > N_odd[1][1] + N_even[0][1]:
        print n - N_odd[0][1] + N_even[1][1]
    else:
        print n - N_odd[1][1] + N_even[0][1]
else:
    print n - N_odd[0][1] - N_even[0][1]

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(map(int,input().split()))
ans = 0
a = []
b = []
atmp = []
btmp = []
n //= 2

for i in range(n):
    if i%2:
        a.append(v[i])
    else:
        b.append(v[i])

a = collections.Counter(a)
b = collections.Counter(b)
atmp = a.most_common()
btmp = b.most_common()

#print(atmp[1][0],atmp)



if atmp[0][0] != btmp[0][0]:
    ans += (n-atmp[0][1])
    ans += (n-btmp[0][1])
else:
    if len(atmp) == 1 and len(btmp) == 1:
        ans = n

    elif atmp[1][1] + btmp[0][1] > atmp[0][1] + btmp[1][1]:
        ans += (n-atmp[1][1])
        ans += (n-btmp[0][1])
    else:
        ans += (n-atmp[0][1])
        ans += (n-btmp[1][1])
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(map(int,input().split()))
ans = 0
a = []
b = []
atmp = []
btmp = []
n //= 2

for i in range(n):
    if i%2:
        a.append(v[i])
    else:
        b.append(v[i])

a = collections.Counter(a)
b = collections.Counter(b)
atmp = a.most_common()
btmp = b.most_common()

#print(atmp[1][0],atmp)



if atmp[0][0] != btmp[0][0]:
    ans += (n-atmp[0][1])
    ans += (n-btmp[0][1])
else:
    if len(atmp) < 2 and len(btmp) < 2:
        ans = n

    elif len(atmp) < 2:
        ans += (n-atmp[0][1])
        ans += (n-btmp[1][1])

    elif len(btmp) < 2:
        ans += (n-atmp[1][1])
        ans += (n-btmp[0][1])

    elif atmp[1][1] + btmp[0][1] > atmp[0][1] + btmp[1][1]:
        ans += (n-atmp[1][1])
        ans += (n-btmp[0][1])
    else:
        ans += (n-atmp[0][1])
        ans += (n-btmp[1][1])
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
m = n//2
s = []
t = []
S = 0
T = 0
M = 0
N = 0
a = 0
b = 0
for i in range(m):
    s.append(v[2*i])
    t .append(v[2*i+1])
for i in range(m):
    p = s.count(v[2*i])
    if p > S:
        M = S
        S = p
        a = v[2*i]
    q = t.count(v[2*i+1])
    if q > T:
        N = T
        T = q
        b = v[2:i]
ans = n - S - T
if a == b:
    if S == T:
        if M >= N:
            ans = ans + S - M
        else:
            ans = ans + T - N
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
m = n//2
s = []
t = []
S = 0
T = 0
M = 0
N = 0
a = 0
b = 0
for i in range(m):
    s.append(v[2*i])
    t .append(v[2*i+1])
for i in range(m):
    p = s.count(v[2*i])
    if p > S:
        M = S
        S = p
        a = v[2*i]
    q = t.count(v[2*i+1])
    if q > T:
        N = T
        T = q
        b = v[2:i]
ans = n - S - T
if a == b:
    if M >= N:
        ans = ans + S - M
    else:
        ans = ans + T - N
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
m = n//2
s = []
t = []
S = 0
T = 0
M = 0
N = 0
for i in range(m):
    s.append(v[2*i])
    t .append(v[2*i+1])
for i in range(m):
    p = s.count(v[2*i])
    if p > S:
        M = S
        S = p
    q = t.count(v[2*i+1])
    if q > T:
        N = T
        T = q
ans = n - S - T
if T == S:
    if M >= N:
        ans = ans + S - M
    else:
        ans = ans + T - N
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
m = n//2
s = []
t = []
for i in range(m):
    s.append(v[2*i])
for i in range(m):
    t .append(v[2*i+1])
S = 0
T = 0
M = 0
N = 0
for i in range(m):
    p = s.count(v[2*i])
    if p > S:
        M = S
        S = p
for i in range(m):
    q = t.count(v[2*i+1])
    if q > T:
        N = T
        T = q
ans = n - S - T
if T == S:
    if M >= N:
        ans = ans + S - M
    else:
        ans = ans + T - N
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int,input().split()))
vo = dict({})
ve = dict({})
for i,e in zip(v[0::2],v[1::2]):
    if i in ve :
        ve[i] += 1
    else:
        ve[i] = 1
    if e in vo :
        vo[e] += 1
    else:
        vo[e] = 1
if len(vo)==1 and len(ve):
    if v[0]!=v[1]:
        print(0)
    else:
        print(N//2)
else:
    vo = sorted([(i,vo[i]) for i in vo.keys()], key = lambda x:x[1], reverse = True)
    ve = sorted([(i,ve[i]) for i in ve.keys()], key = lambda x:x[1], reverse = True)
    if vo[0][0]!=ve[0][0]:
        print(N-vo[0][1]-ve[0][1])
    else:
        print(N-max(vo[0][1]+ve[1][1],vo[1][1]+ve[0][1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int,input().split()))
vo = dict({})
ve = dict({})
for i,e in zip(v[0::2],v[1::2]):
    if i in ve :
        ve[i] += 1
    else:
        ve[i] = 1
    if e in vo :
        vo[e] += 1
    else:
        vo[e] = 1
if len(vo)==1 and len(ve):
    if v[0]!=v[1]:
        print(0)
    else:
        print(N//2)
else:
    vo = sorted([(i,vo[i]) for i in vo.keys()], key = lambda x:x[1], reverse = True)
    ve = sorted([(i,ve[i]) for i in ve.keys()], key = lambda x:x[1], reverse = True)
    if vo[0][0]!=ve[0][0]:
        print(N-vo[0][1]-ve[0][1])
    else:
        print(N-max(vo[0][1]-ve[1][1],vo[1][1]-ve[0][1]))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
input = sys.stdin.readline

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


def f(odd):
    return Counter([x for i, x in enumerate(v) if i % 2 == odd]).most_common(2)


a = f(0)
b = f(1)

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    if a[0][1] > b[0][1]:
        print(n - a[0][1] - (0 if len(b) < 2 else b[1][1]))
    else:
        print(n - (0 if len(a) < 2 else a[1][1]) - b[0][1])

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
v = list(map(int,input().split()))
vodd = v[0::2]
veven = v[1::2]

set_vodd = list(set(vodd))
set_veven = list(set(veven))
cnt_vodd = collections.Counter(vodd)
cnt_veven = collections.Counter(veven)

if len(set_vodd) == 1 and set_vodd == set_veven:
    print(n//2)
else:
    ans_vodd = (n//2)- cnt_vodd.most_common(1)[0][1]
    ans_veven = (n//2)- cnt_veven.most_common(1)[0][1]
    print(ans_vodd + ans_veven)

Submission status: Wrong Answer

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

v1 = []
v2 = []

if max(v) == min(v):
    print(int(n/2))
else:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    
    j=0

    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values1, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values2, counts2 = zip(*v2n.most_common())
    
    if max(counts1) != 1 and max(counts2) != 1:
        print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))
    else:
        print( int(n/2) + min((len(v1)-max(counts1)),(len(v2)-max(counts2))) - 1)

Submission status: Wrong Answer

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

v1 = []
v2 = []

if max(v) == min(v):
    print(int(n/2))
else:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    
    j=0

    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values1, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values2, counts2 = zip(*v2n.most_common())
    
    if max(counts1) != 1 and max(counts2) != 1:
        print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))
    else:
        print( int(n/2) + min((len(v1)-max(counts1)),(len(v2)-max(counts2))) )

Submission status: Wrong Answer

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

v1 = []
v2 = []



if max(v) == min(v):
    print(int(n/2))
else:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    
    j=0

    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values1, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values2, counts2 = zip(*v2n.most_common())
    
    if values1 != values2 and max(counts1) != 1 and max(counts2) != 1:
        print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))
    else:
        print( int(n/2) + min((len(v1)-max(counts1)),(len(v2)-max(counts2))) )

Submission status: Wrong Answer

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

v1 = []
v2 = []



if max(v) == min(v):
    print(int(n/2))
else:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    
    j=0

    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values1, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values2, counts2 = zip(*v2n.most_common())
    
    if values1 != values2 and v[0] != v[1]:
        print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))
    elif values1 != values2 and v[0] == v[1]:
        print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)) + 1)
    else:
        print( int(n/2) + min((len(v1)-max(counts1)),(len(v2)-max(counts2))) )

Submission status: Wrong Answer

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

v1 = []
v2 = []



if max(v) == min(v):
    print(int(n/2))
else:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    
    j=0

    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values1, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values2, counts2 = zip(*v2n.most_common())
    
    if values1 != values2:
        print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))
    else:
        print( int(n/2) + min((len(v1)-max(counts1)),(len(v2)-max(counts2))) )

Submission status: Wrong Answer

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

v1 = []
v2 = []



if max(v) == min(v):
    print(int(n/2))
elif v[0] == v[1]:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    j=0
    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values, counts2 = zip(*v2n.most_common())

    print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)) + 1)
else:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    
    j=0

    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values, counts2 = zip(*v2n.most_common())

    print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))

Submission status: Wrong Answer

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

v1 = []
v2 = []



if max(v) == min(v):
    print(int(n/2))
elif v[0] == v[1]:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    j=0
    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values, counts2 = zip(*v2n.most_common())

    print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)) + 1)
else:
    j=0
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    
    j=0

    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values, counts2 = zip(*v2n.most_common())

    print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)) + 1)

Submission status: Wrong Answer

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

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

import collections

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

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

print(ans)

Submission status: Wrong Answer

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

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

import collections

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

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

print(ans)

Submission status: Wrong Answer

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

v1 = []
v2 = []

j=0

if max(v) == min(v):
    print(int(n/2))
else:
    for i in range(int(n/2)):
        v1.append(v[j])
        j+=2
    
    j=0

    for i in range(int(n/2)):
        v2.append(v[j+1])
        j+=2

    import collections

    v1n = collections.Counter(v1)
    values, counts1 = zip(*v1n.most_common())

    v2n = collections.Counter(v2)
    values, counts2 = zip(*v2n.most_common())

    print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))

Submission status: Wrong Answer

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

v1 = []
v2 = []

j=0

for i in range(int(n/2)):
    v1.append(v[j])
    j+=2
    
j=0

for i in range(int(n/2)):
    v2.append(v[j+1])
    j+=2

import collections

v1n = collections.Counter(v1)
values, counts1 = zip(*v1n.most_common())

v2n = collections.Counter(v2)
values, counts2 = zip(*v2n.most_common())

print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))