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:
N = int(input())
V = list(map(int, input().split()))

even = [v for i, v in enumerate(V) if i % 2 == 0]
odd = [v for i, v in enumerate(V) if i % 2 == 1]

even_d = {v: 0 for v in set(even)}
odd_d = {v: 0 for v in set(odd)}

for v in even:
    even_d[v] += 1
for v in odd:
    odd_d[v] += 1

even = [(k, v) for k, v in even_d.items()]
odd = [(k, v) for k, v in odd_d.items()]

even.sort(key=lambda tpl: tpl[1], reverse=True)
odd.sort(key=lambda tpl: tpl[1], reverse=True)

if len(even) == 1 and len(odd) == 1:
    if even[0][0] == odd[0][0]:
        print(N // 2)
    else:
        print(0)
    exit()

if len(even) == 1:
    if even[0][0] == odd[0][0]:
        del odd[1]
    else:
        del odd[0]
    print(sum([v for _, v in odd]))
    exit()

if len(odd) == 1:
    if even[0][0] == odd[0][0]:
        del even[1]
    else:
        del even[0]
    print(sum([v for _, v in even]))
    exit()

if even[0][0] == odd[0][0]:
    if even[0][1] > odd[0][1]:
        del even[0]
        del odd[1]
    else:
        del even[1]
        del odd[0]
else:
    del even[0]
    del odd[0]
print(sum([v for _, v in even]) + sum([v for _, v in odd]))

Submission status: Wrong Answer

Solution code:
import collections

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

if len(set(v)) == 1:
    print(n//2)

else:
    v_odd = collections.Counter(v[0::2])
    v_even = collections.Counter(v[1::2])

    v_odd_top = list(sorted(v_odd.items(),key = lambda x:-x[1]))[0]
    v_even_top = list(sorted(v_even.items(),key = lambda x:-x[1]))[0]
 
    if v_odd_top == v_even_top:
        if list(sorted(v_odd.items(),key = lambda x:-x[1]))[1] > list(sorted(v_even.items(),key = lambda x:-x[1]))[1]:
            v_odd_top = list(sorted(v_odd.items(),key = lambda x:-x[1]))[1] 
        else:
            v_even_top = list(sorted(v_even.items(),key = lambda x:-x[1]))[1] 

    # リスト作成
    v_list = [0] * n
    v_list[0::2] = [v_odd_top[0]] * (n // 2)
    v_list[1::2] = [v_even_top[0]] * (n // 2)

    # リストを比較
    for i in range(n):
        if v[i] != v_list[i]:
            ans += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

if len(set(v)) == 1:
    print(n//2)

else:
    v_odd = collections.Counter(v[0::2])
    v_even = collections.Counter(v[1::2])

    v_odd_top = list(sorted(v_odd.items())[0])
    v_even_top = list(sorted(v_even.items())[0])

    if v_odd_top == v_even_top:
        if list(sorted(v_even.items())[0]) > list(sorted(v_odd.items())[1]):
            v_even_top = list(sorted(v_even.items())[1])
        else:
            v_odd_top = list(sorted(v_odd.items())[1])


    # リスト作成
    v_list = [0] * n
    v_list[0::2] = [v_odd_top[0]] * (n // 2)
    v_list[1::2] = [v_even_top[0]] * (n // 2)

    # リストを比較
    for i in range(n):
        if v[i] != v_list[i]:
            ans += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

if len(set(v)) == 1:
    print(n//2)

else:
    v_odd = collections.Counter(v[0::2])
    v_even = collections.Counter(v[1::2])

    v_odd_top = list(sorted(v_odd.items())[0])
    v_even_top = list(sorted(v_even.items())[0])

    if v_odd_top == v_even_top:
        v_even_top =  list(sorted(v_odd.items())[1])

    # リスト作成
    v_list = [0] * n
    v_list[0::2] = [v_odd_top[0]] * (n // 2)
    v_list[1::2] = [v_even_top[0]] * (n // 2)

    # リストを比較
    for i in range(n):
        if v[i] != v_list[i]:
            ans += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

if len(set(v)) == 1:
    print(n//2)

else:
    v_odd = collections.Counter(v[0::2])
    v_even = collections.Counter(v[1::2])

    v_odd_top = list(sorted(v_odd.items())[0])
    v_even_top = list(sorted(v_even.items())[0])

    # リスト作成
    v_list = [0] * n
    v_list[0::2] = [v_odd_top[0]] * (n // 2)
    v_list[1::2] = [v_even_top[0]] * (n // 2)

    # リストを比較
    for i in range(n):
        if v[i] != v_list[i]:
            ans += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
import collections


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

if len(set(l)) == 1:
    print(n//2)
    exit()

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]
ce = collections.Counter(leven)
co = collections.Counter(lodd)

ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][0] != co[-1][0]:
	print(n - ce[-1][1] - co[-1][1])
elif ce[-2][1] > co[-2][1]:
    print(n - ce[-2][1] - ce[-1][1])
else:
    print(n - ce[-1][1] - ce[-2][1])

Submission status: Wrong Answer

Solution code:
import collections


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

if len(set(l)) == 1:
    print(n//2)
    exit()

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]
ce = collections.Counter(leven)
co = collections.Counter(lodd)

ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

print(n - ce[-1][1] - co[-1][1])

Submission status: Wrong Answer

Solution code:
import collections


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

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]
ce = collections.Counter(leven)
co = collections.Counter(lodd)

ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][1] + co[-1][1] == n and ce[-1][0] == co[-1][0]:
    print(n//2)
elif ce[-1][0] != co[-1][0]:
    print(n - ce[-1][1] - co[-1][1])
elif ce[-2][0] >= co[-2][0]:
    print(n - ce[-2][1] - co[-1][1])
else:
    print(n - ce[-1][1] - co[-2][1])

Submission status: Wrong Answer

Solution code:
import collections


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

leven = [x for x in l[::2]]
lodd  = [x for x in l[1::2]]
ce = collections.Counter(leven)
co = collections.Counter(lodd)

ce = sorted(ce.items(), key=lambda x:x[1])
co = sorted(co.items(), key=lambda x:x[1])

if ce[-1][1] + co[-1][1] == n:
    print(n//2)
elif ce[-1][0] != co[-1][0]:
    print(n - ce[-1][1] - co[-1][1])
elif ce[-2][0] >= co[-2][0]:
    print(n - ce[-2][1] - co[-1][1])
else:
    print(n - ce[-1][1] - co[-2][1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

even = a[1::2]
odd = a[::2]

c_even = Counter(even)
c_odd = Counter(odd)

arr_even = c_even.most_common()
arr_odd = c_odd.most_common()

sum_even = sum(x[1] for x in arr_even)
sum_odd = sum(x[1] for x in arr_odd)

min_sum = float("inf")

for i, x in arr_even:
    for j, y in arr_odd:
        if i != j:
            cnt = sum_even - x + sum_odd - y
            min_sum = min(min_sum, cnt)
            break
        else:
            cnt = n // 2
            min_sum = min(min_sum, cnt)

print(min_sum)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

even = a[1::2]
odd = a[::2]

c_even = Counter(even)
c_odd = Counter(odd)

arr_even = c_even.most_common()
arr_odd = c_odd.most_common()

sum_even = sum(x[1] for x in arr_even)
sum_odd = sum(x[1] for x in arr_odd)

min_sum = float("inf")

for i, x in arr_even:
    for j, y in arr_odd:
        if i != j:
            cnt = sum_even - x + sum_odd - y
            min_sum = min(min_sum, cnt)
            break
        else:
            cnt = n - 2
            min_sum = min(min_sum, cnt)

print(min_sum)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

even = a[1::2]
odd = a[::2]

c_even = Counter(even)
c_odd = Counter(odd)

arr_even = c_even.most_common()
arr_odd = c_odd.most_common()

sum_even = sum(x[1] for x in arr_even)
sum_odd = sum(x[1] for x in arr_odd)

min_sum = float("inf")

for i, x in arr_even:
    for j, y in arr_odd:
        if i != j:
            cnt = sum_even - x + sum_odd - y
            min_sum = min(min_sum, cnt)
        else:
            cnt = n - 2
            min_sum = min(min_sum, cnt)

print(min_sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = input().split(" ")

import collections

even = collections.Counter(L[::2]).most_common(2)
odd = collections.Counter(L[1::2]).most_common(2)

if even[0][1] != odd[0][1]:
    print(N - even[0][1] - odd[0][1])
else:
    # even[0][1] == odd[0][1]
    if len(even) == 1 or len(odd) == 1:
        print(N // 2)
    else:
        print(N - max(even[0][1] + odd[1][1], even[1][1] + odd[0][1]))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())

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

even = collections.Counter(v[0::2])
odd  = collections.Counter(v[1::2])

if odd.most_common()[0][0] != even.most_common()[0][0]:
    print(n-odd.most_common()[0][1] - even.most_common()[0][1])
elif len(even)>= 2 and odd.most_common()[0][1] >= even.most_common()[0][1]:
    print(n-odd.most_common()[0][1] - even.most_common()[1][1])
elif len(odd) >= 2: 
    print(n-odd.most_common()[1][1] - even.most_common()[0][1])
else:
    print(n//2)

Submission status: Wrong Answer

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

even_dict = {}
odd_dict = {}
for i, value in enumerate(v):
    if i % 2:
        even_dict[value] = 1 if value not in even_dict else even_dict[value] + 1
    else:
        odd_dict[value] = 1 if value not in odd_dict else odd_dict[value] + 1

counter = 0
even = sorted(even_dict.items(), key=lambda x: x[1], reverse=True)
odd = sorted(odd_dict.items(), key=lambda x: x[1], reverse=True)

if even[0][0] == odd[0][0]:
    even_second = 0 if len(even) < 2 else even[1][1]
    odd_second = 0 if len(odd) < 2 else odd[1][1]
    if even[0][1] - odd_second > odd[0][1] - odd_second:
        counter += sum([x[1] for x in even[1:]])
        counter += sum([x[1] for x in odd[2:] + [odd[0]]])
    else:
        counter += sum([x[1] for x in odd[1:]])
        counter += sum([x[1] for x in even[2:] + [even[0]]])
else:
    counter += sum([x[1] for x in even[1:]])
    counter += sum([x[1] for x in odd[1:]])

print(counter)

Submission status: Wrong Answer

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

even_dict = {}
odd_dict = {}
for i, value in enumerate(v):
    if i % 2:
        even_dict[value] = 1 if value not in even_dict else even_dict[value] + 1
    else:
        odd_dict[value] = 1 if value not in odd_dict else odd_dict[value] + 1

counter = 0
even = sorted(even_dict.items(), key=lambda x: x[1], reverse=True)
odd = sorted(odd_dict.items(), key=lambda x: x[1], reverse=True)

if even[0][0] == odd[0][0]:
    if even[0][1] > odd[0][1]:
        counter += sum([x[1] for x in even[1:]])
        counter += sum([x[1] for x in odd[2:] + [odd[0]]])
    else:
        counter += sum([x[1] for x in odd[1:]])
        counter += sum([x[1] for x in even[2:] + [even[0]]])
else:
    counter += sum([x[1] for x in even[1:]])
    counter += sum([x[1] for x in odd[1:]])

print(counter)

Submission status: Wrong Answer

Solution code:
N = int(input())
V = [int(v) for v in input().split()]

V_element = list(set(V))
mx_cnt_V_135 = 0
mx_cnt_V_246 = 0

for i in range(len(V_element)):
  cnt_V_135 = V[0:N:2].count(V_element[i])
  cnt_V_246 = V[1:N:2].count(V_element[i])
  if cnt_V_135 > cnt_V_246:
    if cnt_V_135 > mx_cnt_V_135:
      mx_cnt_V_135 = cnt_V_135
  else:
    if cnt_V_246 > mx_cnt_V_246:
      mx_cnt_V_246 = cnt_V_246

how_many_replace = len(V) - mx_cnt_V_135 - mx_cnt_V_246
print(how_many_replace)

Submission status: Wrong Answer

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

even_dict = {}
odd_dict = {}
for i, value in enumerate(v):
    if i % 2:
        even_dict[value] = 1 if value not in even_dict else even_dict[value] + 1
    else:
        odd_dict[value] = 1 if value not in odd_dict else odd_dict[value] + 1

counter = 0
for key, value in sorted(even_dict.items(), key=lambda x: x[1], reverse=True)[1:]:
    counter += value

for key, value in sorted(odd_dict.items(), key=lambda x: x[1], reverse=True)[1:]:
    counter += value

if len(even_dict) == 1 and len(odd_dict) == 1 and v[0] == v[1]:
    print(len(v) // 2)
else:
    print(counter)

Submission status: Wrong Answer

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

even_dict = {}
odd_dict = {}
for i, value in enumerate(v):
    if i % 2:
        even_dict[value] = 1 if value not in even_dict else even_dict[value] + 1
    else:
        odd_dict[value] = 1 if value not in odd_dict else odd_dict[value] + 1

counter = 0
for key, value in sorted(even_dict.items(), key=lambda x: x[1])[1:]:
    counter += value

for key, value in sorted(odd_dict.items(), key=lambda x: x[1])[1:]:
    counter += value

if len(even_dict) == 1 and len(odd_dict) == 1 and v[0] == v[1]:
    print(len(v) // 2)
else:
    print(counter)

Submission status: Wrong Answer

Solution code:
# ABC111C - /\/\/\/
from collections import Counter

n = int(input())
lst = list(map(int, input().rstrip().split()))
even = Counter(lst[::2]).most_common(2)
odd = Counter(lst[1::2]).most_common(2)
ans = 0
if even[0][0] != odd[0][0]:
    print(n - even[0][1] - odd[0][0])
else:
    if len(even) == 1 or len(odd) == 1:
        print(n // 2)
    else:
        print(n - max(even[0][1] + odd[1][1], even[1][1] + odd[0][1]))

Submission status: Wrong Answer

Solution code:
# ABC111C - /\/\/\/
n = int(input())
lst = list(map(int, input().rstrip().split()))
a = lst[0]
b = lst[1]
ans = 0
for i, j in enumerate(lst):
    if i % 2 == 0:
        if j != a:
            ans += 1
    else:
        if j != b:
            ans += 1
if ans == 0 and a == b:
    print(n // 2)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    v = f()

    a = [ v[i] for i in range(n) if i%2 == 0]
    b = [ v[i] for i in range(n) if i%2 == 1]

    cnt_a = {}
    cnt_b = {}
    for i in a:
        if i in cnt_a:
            cnt_a[i] += 1
        else:
            cnt_a[i] = 1
    
    for i in b:
        if i in cnt_b:
            cnt_b[i] += 1
        else:
            cnt_b[i] = 1

    ncnt_a = sorted(cnt_a.items(), key = lambda x:x[1])
    ncnt_b = sorted(cnt_b.items(), key = lambda x:x[1])

    

    if ncnt_a[0][0]!=ncnt_b[0][0]:
        print(n -ncnt_a[0][1]- ncnt_b[0][1])
    else:
        ans1 = n - ncnt_b[0][1] - (ncnt_a[1][1] if len(ncnt_a)>1 else 0)
        ans2 = n -ncnt_a[0][1]- (ncnt_b[1][1] if len(ncnt_b)>1 else 0)
        print(min(ans1, ans2))



solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
v = input().split()
vg = [v[i] for i in range(0, len(v), 2)]
vk = [v[i] for i in range(1, len(v), 2)]
# print(vg, vk)
cgk = list(Counter(vg).keys())
ckk = list(Counter(vk).keys())
cgv = list(Counter(vg).values())
ckv = list(Counter(vk).values())
# print(cgk, cgv, ckk, ckv)
if cgk[0] != ckk[0]:
    print(n - cgv[0] - ckv[0])
elif len(cgk) != 1 and len(ckk) != 1:
    if (cgv[0] - cgv[1]) > (ckv[0] - ckv[1]):
        print(n - cgv[0] - ckv[1])
    else:
        print(n - cgv[1] - ckv[0])
elif len(cgk) != 1 or len(ckk) != 1:
    if cgv[0] > ckv[0]:
        print(n - cgv[0] - ckv[1])
    else:
        print(n - cgv[1] - ckv[0])

else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
v = input().split()
vg = [v[i] for i in range(0, len(v), 2)]
vk = [v[i] for i in range(1, len(v), 2)]
# print(vg, vk)
cgk = list(Counter(vg).keys())
ckk = list(Counter(vk).keys())
cgv = list(Counter(vg).values())
ckv = list(Counter(vk).values())
# print(cgk, cgv, ckk, ckv)
if cgk[0] != ckk[0]:
    print(n - cgv[0] - ckv[0])
elif len(cgk) != 1 or len(ckk) != 1:
    if cgv[0] > ckv[0]:
        print(n - cgv[0] - ckv[1])
    else:
        print(n - cgv[1] - ckv[0])
else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
v = input().split()
vg = [v[i] for i in range(0, len(v), 2)]
vk = [v[i] for i in range(1, len(v), 2)]
# print(vg, vk)
cgk = list(Counter(vg).keys())
ckk = list(Counter(vk).keys())
cgv = list(Counter(vg).values())
ckv = list(Counter(vk).values())
print(cgk, cgv, ckk, ckv)
if cgk[0] != ckk[0]:
    print(n - cgv[0] - ckv[0])
elif len(cgk) != 1 or len(ckk) != 1:
    if cgv[0] > ckv[0]:
        print(n - cgv[0] - ckv[1])
    else:
        print(n - cgv[1] - ckv[0])
else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
v = input().split()
vg = [v[i] for i in range(0, len(v), 2)]
vk = [v[i] for i in range(1, len(v), 2)]
# print(vg, vk)
cgk = list(Counter(vg).keys())
ckk = list(Counter(vk).keys())
cgv = list(Counter(vg).values())
ckv = list(Counter(vk).values())
# print(cgk)
if cgk[0] != ckk[0]:
    print(n - cgv[0] - ckv[0])
elif len(cgk) != 1 or len(ckk) != 1:
    if cgk[0] > ckk[0]:
        print(n - cgv[0] - ckv[1])
    else:
        print(n - cgv[1] - ckv[0])
else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
v = input().split()
vg = [v[i] for i in range(0, len(v), 2)]
vk = [v[i] for i in range(1, len(v), 2)]
print(vg, vk)
cgk = list(Counter(vg).keys())
ckk = list(Counter(vk).keys())
cgv = list(Counter(vg).values())
ckv = list(Counter(vk).values())
print(cgk)
if cgk[0] != ckk[0]:
    print(n - cgv[0] - ckv[0])
elif len(cgk) != 1 or len(ckk) != 1:
    if cgk[0] > ckk[0]:
        print(n - cgv[0] - ckv[1])
    else:
        print(n - cgv[1] - ckv[0])
else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
import statistics
import collections
n = int(input())
l = list(int(x) for x in input().split())
el= []
ol = []
for i in range(n):
  if i % 2 == 0:
    el.append(l[i])
  else:
    ol.append(l[i])
e1 = collections.Counter(el).most_common()[0][0]
e2 = collections.Counter(el).most_common()[0][1]
o1 = collections.Counter(ol).most_common()[0][0]
o2 = collections.Counter(ol).most_common()[0][1]
cnt1 = 0
cnt2 = 0
if e1 != o1:
  for i in range(n//2):
    if el[i] != e1:
      cnt1 += 1
    if ol[i] != o1:
      cnt1 += 1
  print(cnt1)
else:
  for i in range(n//2):
    if el[i] != e1:
      cnt1 += 1
    if ol[i] != o2:
      cnt1 += 1
    if el[i] != e2:
      cnt2 += 1
    if ol[i] != o1:
      cnt2 += 1
  print(min(cnt1,cnt2))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
e =[]
o = []
#e12list = []
#o12list = []
e1 = 0
e2 = 0
o1 = 0
o2 = 0
e_true = 10**5
o_true = 10**5
max_countE = 0
max_countO = 0
sec_countE = 0
sec_countO =0

for i in range(0,n,2):
    e.append(v[i])
for j in range(1,n,2):
    o.append(v[j])

for k in range(0,9):
    if max_countE < e.count(k):
        e2 = e1
        e1 = k
        max_countE = e.count(k)
    if max_countE > e.count(k) and sec_countE < e.count(k):
        e2 = k
        sec_countE = e.count(k)

    """
    e12list.append(e.count(k))
    e12list.sort(reverse=True)
    e1 = e12list[0]
    e2 = e12list[1]
    
    """

for h in range(0, 9):
    if max_countO < o.count(h):
        o2 = o1
        o1 = h
        max_countO = o.count(h)
    if max_countO > o.count(h) and sec_countO < o.count(h):
        o2 = h
        sec_countO = o.count(h)
    """
        o12list.append(o.count(h))
        o12list.sort(reverse=True)
        o1 = o12list[0]
        o2 = o12list[1]
    """

e_true = e.count(e1) + o.count(o2)
o_true = e.count(e2) + o.count(o1)

"""
print(e1)
print(e2)
print(o1)
print(o2)
print(e_true)
print(o_true)
"""


print(min(e_true, o_true))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
e =[]
o = []
#e12list = []
#o12list = []
e1 = 0
e2 = 0
o1 = 0
o2 = 0
e_true = 10**5
o_true = 10**5
max_countE = 0
max_countO = 0
sec_countE = 0
sec_countO =0

for i in range(0,n,2):
    e.append(v[i])
for j in range(1,n,2):
    o.append(v[j])

for k in range(0,9):
    if max_countE < e.count(k):
        e2 = e1
        e1 = k
        max_countE = e.count(k)
    if max_countE > e.count(k) and sec_countE < e.count(k):
        e2 = k
        sec_countE = e.count(k)

    """
    e12list.append(e.count(k))
    e12list.sort(reverse=True)
    e1 = e12list[0]
    e2 = e12list[1]
    
    """

for h in range(0, 9):
    if max_countO < o.count(h):
        o2 = o1
        o1 = h
        max_countO = o.count(h)
    if max_countO > o.count(h) and sec_countO < o.count(h):
        o2 = h
        sec_countO = o.count(h)
    """
        o12list.append(o.count(h))
        o12list.sort(reverse=True)
        o1 = o12list[0]
        o2 = o12list[1]
    """

e_true = e.count(e1) + o.count(o2)
o_true = e.count(e2) + o.count(o1)

print(e1)
print(e2)
print(o1)
print(o2)
#print(e_true)
#print(o_true)



print(min(e_true, o_true))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
e =[]
o = []
e1 = 0
e2 = 0
o1 = 0
o2 = 0
e_true = 10**5
o_true = 10**5

for i in range(0,n,2):
    e.append(v[i])
for j in range(1,n,2):
    o.append(v[j])

for k in range(0,9):
    if e1 < e.count(k):
        e2 = e1
        e1 = k

for h in range(0, 9):
    if o1 < o.count(h):
        o2 = o1
        o1 = h

e_true = e.count(e1) + o.count(o2)
o_true = e.count(e2) + o.count(o1)




print(min(e_true, o_true))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())

e = []
o = []
for i, v in enumerate(input().split(' ')):
    if i % 2 == 0:
        e.append(int(v))
    else:
        o.append(int(v))

if len(set(e + o)) == 1:
    print(int(len(e + o) / 2))
    exit()

print(len(o) - Counter(o).most_common()[0][1] + len(e) - Counter(e).most_common()[0][1])

Submission status: Wrong Answer

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

n = int(input())
v = list(map(int, input().split()))
w = [0]*(n//2)
x_c = Counter(v)

if x_c.most_common()[0][1] == n:
    ans = n//2
else:
    for i in range(n//2):
        w[i] = v.pop(2*i - i)
    v_0 = Counter(v).most_common()[0][1]
    w_0 = Counter(w).most_common()[0][1]
    if x_c.most_common()[0][1]*2 > n:
        if len(Counter(v)) == 1:
            ans = n//2 - Counter(w).most_common()[1][1]
        elif len(Counter(w)) == 1:
            ans = n//2 - Counter(v).most_common()[1][1]
        else:
            if v_0 > w_0:
                ans = n - (Counter(w).most_common()[1][1] + v_0)
            else:
                ans = n - (Counter(v).most_common()[1][1] + w_0)
    else:
        ans = n - (w_0 + v_0)
print(ans)

Submission status: Wrong Answer

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

n = int(input())
v = list(map(int, input().split()))
w = [0]*(n//2)
x_c = Counter(v)

if x_c.most_common()[0][1] == n:
    ans = n//2
else:
    for i in range(n//2):
        w[i] = v.pop(2*i - i)
    v_c = Counter(v)
    w_c = Counter(w)
    if x_c.most_common()[0][1]*2 > n:
        if len(v_c) == 1:
            ans = n//2 - w_c.most_common()[1][1]
        else:
            ans = n//2 - v_c.most_common()[1][1]
    else:
        ans = n - (v_c.most_common()[0][1]+w_c.most_common()[0][1])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())

e = []
o = []
for i, v in enumerate(input().split(' ')):
    if i % 2 == 0:
        e.append(int(v))
    else:
        o.append(int(v))

if len(set(e + o)) == 1:
    print(int(len(e + o) / 2))
    exit()

if Counter(e).most_common()[0][1] > Counter(o).most_common()[0][1]:
    print(len(o) - Counter(o).most_common()[0][1])
else:
    print(len(e) - Counter(e).most_common()[0][1])

Submission status: Wrong Answer

Solution code:
from sys import stdin
import collections
n = int(stdin.readline().rstrip())
V = [int(x) for x in stdin.readline().rstrip().split()]
V_odd = [V[2 * k] for k in range(int(n / 2))]
V_even = [V[2 * k + 1] for k in range(int(n / 2))]
co = collections.Counter(V_odd)
ce = collections.Counter(V_even)
if len(co.most_common()) == 1 and len(ce.most_common()) == 1:
    print(co.most_common()[0][1])
elif co.most_common()[0][0] != ce.most_common()[0][0]:
    print(n - co.most_common()[0][1] - ce.most_common()[0][1])
else:
    print(n - (max(co.most_common()[1][1] + ce.most_common()[0][1], co.most_common()[0][1] + ce.most_common()[1][1])))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n, *v = map(int, open(0).read().split())
c1 = Counter(v[::2]).most_common()
c2 = Counter(v[1::2]).most_common()

c1.append([0, 0])
c2.append([0, 0])

if c1[0][0] != c2[0][0]:
  print(n - c1[0][1] - c2[0][1])
else:
  print(n - min(c1[0][1] + c2[1][1], c1[1][1] + c2[0][1]))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n, *v = map(int, open(0).read().split())
c1 = Counter(v[::2])
c2 = Counter(v[1::2])

odd_1 = c1.most_common()[0]
evn_1 = c2.most_common()[0]

if odd_1[0] != evn_1[0]:
  print(n - odd_1[1] - evn_1[1])
elif len(c1) == 1 and len(c2) == 1:
  print(n // 2)
elif len(c1) == 1 and len(c2) != 1:
  print(n // 2 - c2.most_common()[1][1])
elif len(c1) != 1 and len(c2) == 1:
  print(n // 2 - c1.most_common()[1][1])
else:
  odd_2 = c1.most_common()[1][1]
  evn_2 = c2.most_common()[1][1]
  print(n // 2 + min(odd_2 - evn_2, evn_2 - odd_2))

Submission status: Wrong Answer

Solution code:
from collections import Counter

n, *v = map(int, open(0).read().split())
if v[::2] == v[1::2]:
  print(n // 2)
else:
  odd = n // 2 - Counter(v[::2]).most_common()[0][1]
  even = n // 2 - Counter(v[1::2]).most_common()[0][1]
  print(odd + even)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n, *v = map(int, open(0).read().split())
c1 = Counter(v[::2])
c2 = Counter(v[1::2])

odd = n // 2 - c1.most_common()[0][1]
even = n // 2 - c2.most_common()[0][1]
print(odd + even)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
V = list(map(int, input().split()))

even = [0] * (n//2)
odd = [0] * (n//2)
for nn in range(n):
    if nn % 2 == 0:
        even.append(V[nn])
    else:
        odd.append(V[nn])

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

if e[0][0] != o[0][0]:
    print(n - e[0][1] - o[0][1])
else:
    if len(e) == 1 and len(o) == 1:
        print(n // 2)
    elif len(e) == 1 and len(o) >= 2:
        print(n - o[0][1])
    elif len(e) >= 2 and len(o) == 1:
        print(n - e[0][1])
    else:
        print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
V = list(map(int, input().split()))

even = [0] * 100001
odd = [0] * 100001
for nn in range(n):
    if nn % 2 == 0:
        even.append(V[nn])
    else:
        odd.append(V[nn])

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

if e[0][0] != o[0][0]:
    print(n - e[0][1] - o[0][1])
else:
    if len(e) == 1 and len(o) == 1:
        print(n // 2)
    elif len(e) == 1 and len(o) >= 2:
        print(n - o[0][1])
    elif len(e) >= 2 and len(o) == 1:
        print(n - e[0][1])
    else:
        print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))

Submission status: Wrong Answer

Solution code:
"""
偶数番目、機数番目をそれぞれリストに格納
偶数番目の中で、（全て）ー（もっとも要素数が多い数の数）
機数番目の中で、（全て）ー（もっとも要素数が多い数の数）
この和を求めれば良い

"""
import collections


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

even = []
odd = []
for nn in range(n):
    if nn % 2 == 0:
        even.append(V[nn])
    else:
        odd.append(V[nn])

e = collections.Counter(even)
o = collections.Counter(odd)

print(n - e.most_common()[0][1] - o.most_common()[0][1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
odd = []
even = []

for i in range(n):
  if i % 2 == 0:
    even.append(v[i])
  else:
    odd.append(v[i])

o_count = Counter(odd)
e_count = Counter(even)
o_count[-1] = 0
e_count[-2] = 0

if o_count.most_common(1)[0] != e_count.most_common(1)[0]:
  print(n - o_count.most_common(1)[0][1] - e_count.most_common(1)[0][1])
else:
  o1e2 = n - o_count.most_common(2)[0][1] + e_count.most_common(2)[1][1]
  o2e1 = n - o_count.most_common(2)[1][1] + e_count.most_common(2)[0][1]
  ans = min(o1e2,o2e1)
  print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = map(int, input().split())
from collections import defaultdict
ans = defaultdict(int)
result = n
for i in s:
  ans[i] += 1

ln = len(ans)
if ln == 1:
  print(result // 2)
elif ln == 2:
  ind = 0
  a = 0
  z = sorted(ans.items(), key=lambda x: x[1], reverse=True)
  print(z[0][1] - z[1][1])
else:
  z = sorted(ans.items(), key=lambda x: x[1], reverse=True)
  print(n - z[0][1] - z[1][1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

v_even = v[0::2]
v_odd = v[1::2]

c = Counter(v_even)
mode1 = c.most_common()
cnt1 = mode1[0][1]

cnt2 = 0
d = Counter(v_odd)
mode2 = d.most_common()
for i in range(len(mode2)):
    if  mode1[0][0]!=mode2[i][0]:
        cnt2 = mode2[i][1]
        
print(n-cnt1-cnt2)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import collections


def solve(n: int, V: "List[int]"):

    ev = V[0::2]
    ov = V[1::2]

    ec = collections.Counter(ev)
    oc = collections.Counter(ov)

    em = ec.most_common()
    om = oc.most_common()

    if em[0][0] != om[0][0]:
        print( n-em[0][1]-om[0][1])
    else:
        if len(em) == 1 and len(om) == 1:
            print(n-em[0][1])
        elif  len(em) == 1:
            print( n-em[0][1]-om[1][1])
        elif  len(om) == 1:
            print( n-em[1][1]-om[0][1])
        else:
            print(max(n-em[0][1]-om[1][1], n-em[1][1]-om[0][1]))

            



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()