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:
import itertools

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []
A, B = [[-1, 0]], [[-1, 0]]

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

L = itertools.groupby(L)
for key, group in L:
    A.append([key, len(list(group))])

A.sort(key=lambda x:(x[1], x[0]))

R = itertools.groupby(R)
for key, group in R:
    B.append([key, len(list(group))])

B.sort(key=lambda x:(x[1], x[1]), reverse=True)

if A[-1][0] != B[0][0]:
    print(n - A[-1][1] - B[0][1])
else:
    print(min(n - A[-2][1] - B[0][1], n - A[-1][1] - B[1][1]))

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []
A, B = [[-1, 0]], [[-1, 0]]

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

L = itertools.groupby(L)
for key, group in L:
    A.append([key, len(list(group))])

A.sort(key=lambda x:(x[1], x[0]), reverse=True)

R = itertools.groupby(R)
for key, group in R:
    B.append([key, len(list(group))])

B.sort(key=lambda x:x[1], reverse=True)

if A[0][0] != B[0][0]:
    print(n - A[0][1] - B[0][1])
else:
    print(min(n - A[1][1] - B[0][1], n - A[0][1] - B[1][1]))

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []
A, B = [[-1, 0]], [[-1, 0]]

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

L = itertools.groupby(L)
for key, group in L:
    A.append([key, len(list(group))])

A.sort(key=lambda x:x[1], reverse=True)

R = itertools.groupby(R)
for key, group in R:
    B.append([key, len(list(group))])

B.sort(key=lambda x:x[1], reverse=True)

if A[0][0] != B[0][0]:
    print(n - A[0][1] - B[0][1])
else:
    print(min(n - A[1][1] - B[0][1], n - A[0][1] - B[1][1]))

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []
A, B = [[0, 0]], [[0, 0]]
for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

L = itertools.groupby(L)
for key, group in L:
    A.append([key, len(list(group))])

A.sort(key=lambda x:x[1], reverse=True)

R = itertools.groupby(R)
for key, group in R:
    B.append([key, len(list(group))])

B.sort(key=lambda x:x[1], reverse=True)

if A[0][0] != B[0][0]:
    print(n - A[0][1] - B[0][1])
else:
    print(min(n - A[1][1] - B[0][1], n - A[0][1] - B[1][1]))

Submission status: Wrong Answer

Solution code:
# 時間切れは無くなるがWA 16
import collections

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

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

def check_ununiq(list_num, uniq_num):
    tmp_ans = 0
    #print(list_num)

    # ユニークにした時の数字が1より大きいか
    if len(set(list_num)) > 1:
        # 置き換える回数が少ない方の数字を抽出
        tmp = collections.Counter(list_num)
        tmp2 = tmp.most_common()
        uniq_num, dummy = tmp2.pop(0)
        for tmp3 in tmp2:
            #print("BBB", tmp3[1])
            tmp_ans += tmp3[1]
        #print("A", tmp_ans, uniq_num)
    # 既に使われている数字かチェック
    # 使われていればそれを置き換える必要があるのでカウント
    elif uniq_num in list_num:
        tmp_ans = list_num.count(uniq_num)
        #print("B", tmp_ans, uniq_num)
    # 置き換えが必要ない場合。ユニークとした数字のみを出力
    else:
        uniq_num = list_num[0]
        #print("C", tmp_ans, uniq_num)

    return(tmp_ans, uniq_num)

# 
ans1 = 0
uniq_num = 0
tmp_ans, uniq_num = check_ununiq(v_odd, uniq_num)
ans1 += tmp_ans
tmp_ans, uniq_num = check_ununiq(v_even, uniq_num)
ans1 += tmp_ans

# 逆順
ans2 = 0
uniq_num = 0
tmp_ans, uniq_num = check_ununiq(sorted(v_even, reverse=True), uniq_num)
ans2 += tmp_ans
tmp_ans, uniq_num = check_ununiq(sorted(v_odd, reverse=True), uniq_num)
ans2 += tmp_ans

#print(ans1, ans2)
if ans1 < ans2:
    ans = ans1
else:
    ans = ans2

print(ans)

Submission status: Wrong Answer

Solution code:

from collections import Counter


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

    O = Counter(A[::2])
    E = Counter(A[1::2])

    most_O = O.most_common(2)
    most_E = E.most_common(2)
    # 番兵
    most_O.append((0, 0))
    most_E.append((0, 0))

    cnt = 0
    # key comp
    if most_O[0][0] == most_E[0][0]:
        # value
        res1 = most_O[0][1] + most_E[1][1]
        res2 = most_O[1][1] + most_E[0][1]
        cnt = min(res1, res2)
    else:
        cnt = most_O[0][1] + most_E[0][1]

    # 数字が少ないものを書き換える為、Nで引く
    print(N - cnt)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = [int(x) for x in input().split()]
even = []
uneven = []
for i in range(n):
  if i%2 == 0:
    uneven.append(a[i])
    continue
  even.append(a[i])

uneven_counter = collections.Counter(uneven)
sortede_uneven_counter = sorted(uneven_counter.items(),reverse=False)
even_counter = collections.Counter(even)
sortede_even_counter = sorted(even_counter.items(),reverse=False)
  
ans = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[0][1])

if sortede_uneven_counter[0][0] == sortede_even_counter[0][0]:
  if len(set(a)) == 1:
    ans = n/2
  elif sortede_uneven_counter[0][0] ==sortede_even_counter[0][0]:
    ans = (n/2 - sortede_uneven_counter[1][1]) + (n/2 - sortede_even_counter[0][1])
    ans2 = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[1][1])
    if ans2<ans:
      ans = ans2

print(int(ans))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = [int(x) for x in input().split()]
even = []
uneven = []
for i in range(n):
  if i%2 == 0:
    uneven.append(a[i])
    continue
  even.append(a[i])

uneven_counter = collections.Counter(uneven)
sortede_uneven_counter = sorted(uneven_counter.items(),reverse=True)
even_counter = collections.Counter(even)
sortede_even_counter = sorted(even_counter.items(),reverse=True)
  
ans = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[0][1])

if sortede_uneven_counter[0][0] == sortede_even_counter[0][0]:
  if len(set(a)) == 1:
    ans = n/2
  elif sortede_uneven_counter[0][0] ==sortede_even_counter[0][0]:
    ans = (n/2 - sortede_uneven_counter[1][1]) + (n/2 - sortede_even_counter[0][1])
    ans2 = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[1][1])
    if ans2<ans:
      ans = ans2

print(int(ans))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = [int(x) for x in input().split()]
even = []
uneven = []
for i in range(n):
  if i%2 == 0:
    uneven.append(a[i])
    continue
  even.append(a[i])

uneven_counter = collections.Counter(uneven)
sortede_uneven_counter = sorted(uneven_counter.items(),reverse=True)
even_counter = collections.Counter(even)
sortede_even_counter = sorted(even_counter.items(),reverse=True)
  
ans = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[0][1])

if sortede_uneven_counter[0][0] == sortede_even_counter[0][0]:
  if len(set(a)) == 1:
    ans = n/2  
  else:
    ans = (n/2 - sortede_uneven_counter[1][1]) + (n/2 - sortede_even_counter[0][1])
    ans2 = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[1][1])
    if ans2<ans:
      ans = ans2
    
print(int(ans))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = [int(x) for x in input().split()]
even = []
uneven = []
for i in range(n):
  if i%2 == 0:
    uneven.append(a[i])
    continue
  even.append(a[i])

uneven_counter = collections.Counter(uneven)
sortede_uneven_counter = sorted(uneven_counter.items(),reverse=True)
even_counter = collections.Counter(even)
sortede_even_counter = sorted(even_counter.items(),reverse=True)
  
ans = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[0][1])

if sortede_uneven_counter[0][0] == sortede_even_counter[0][0]:
  if len(set(a)) == 1:
    ans = n/2  
  elif sortede_uneven_counter[0][1] < sortede_even_counter[0][1]:
    ans = (n/2 - sortede_uneven_counter[1][1]) + (n/2 - sortede_even_counter[0][1])
  else:
    ans = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[1][1])

print(int(ans))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
vv = list(map(int, input().split()))
ans = 0
aa = [vv[i] for i in range(n) if i % 2 == 0]
bb = [vv[i] for i in range(n) if i % 2 == 1]
ca = collections.Counter(aa) 
la = [(x[0], x[1]) for x in ca.items()]
sa = sorted(la, key=lambda x:x[1])
cb = collections.Counter(bb)
lb = [(x[0], x[1]) for x in cb.items()]
sb = sorted(lb, key= lambda x:x[1])

if sa[0][0] != sb[0][0]:
  if len(sa) == 1:
    ans += 0
  elif len(sa) > 1:
    ans += n - sa[0][1]

  if len(sb) == 1:
    ans += 0
  elif len(sb) > 1:
    ans += len(sb) -sb[0][1]
else:
  ans += min(sa[0][1], sb[0][1])

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int , input().split()))
ev=[]
ov=[]
for i in range(n):
    if i%2==0:
        ev.append(v[i])
    else:
        ov.append(v[i])
ev2=set(ev)
ov2=set(ov)
mins=n/2
for i in ev2:
    for j in ov2:
        if i!=j:
            if n/2-ev.count(i)+n/2-ov.count(j)<mins:
                mins=n/2-ev.count(i)+n/2-ov.count(j)
print(int(mins))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
a = v[0]
b = v[1]
cnt = 0
for i in range(1,n): 
    
    if i%2 == 0:
        if a != v[i]:
            v[i] = a
            cnt = cnt+1
    if i%2 == 1:
        if b != v[i]:
            v[i] = b
            cnt = cnt+1       
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c = Counter(a1)
c1 = []
for i in c:
    c1.append([c[i],i])
c1.sort(reverse = True)

c = Counter(a2)
c2 = []
for i in c:
    c2.append([c[i],i])
c2.sort(reverse = True)

ans = len(a1)+len(a2)
if c1[0][1] != c2[0][1]:
    ans -= c1[0][0]
    ans -= c2[0][0]
else:
    if c1[0][0] > c2[0][0]:
        ans -= c1[0][0]
        if len(c2) > 1: ans -= c2[1][0]
    else:
        ans -= c2[0][0]
        if len(c1) > 1: ans -= c1[1][0]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c = Counter(a1)
c1 = []
for i in c:
    c1.append([c[i],i])
c1.sort(reverse = True)

c = Counter(a2)
c2 = []
for i in c:
    c2.append([c[i],i])
c2.sort(reverse = True)

ans = 0
if c1[0][1] != c2[0][1]:
    ans += len(a1) - c1[0][0]
    ans += len(a2) - c2[0][0]
else:
    if c1[0][0] > c2[0][0]:
        ans += len(a1) - c1[0][0]
        if len(c2) > 1: ans += len(a2) - c2[1][0]
        else: ans += len(a2)
    else:
        ans += len(a2) - c2[0][0]
        if len(c1) > 1: ans += len(a1) - c1[1][0]
        else: ans += len(a1)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c = Counter(a1)
c1 = []
for i in c:
    c1.append([c[i],i])
c1.sort()

c = Counter(a2)
c2 = []
for i in c:
    c2.append([c[i],i])
c2.sort()

ans = 0
if c1[0][1] != c2[0][1]:
    ans += len(a1) - c1[0][0]
    ans += len(a2) - c2[0][0]
else:
    if c1[0][0] > c2[0][0]:
        ans += len(a1) - c1[0][0]
        if len(c2) > 1: ans += len(a2) - c2[1][0]
        else: ans += len(a2)
    else:
        ans += len(a2) - c2[0][0]
        if len(c1) > 1: ans += len(a1) - c1[1][0]
        else: ans += len(a1)
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
v_list=[int(i) for i in input().split()]

odd_list=v_list[::2]
even_list=v_list[1::2]

odd_dic={}
for i in odd_list:
    if i in odd_dic:
        odd_dic[i]+=1
    else:
        odd_dic[i]=1

even_dic={}
for i in even_list:
    if i in even_dic:
        even_dic[i]+=1
    else:
        even_dic[i]=1
        
odd_dic2=sorted(odd_dic.items(), reverse=True)
even_dic2=sorted(even_dic.items(), reverse=True)

if odd_list==even_list:
    ans=n//2

elif odd_dic2[0][0]==even_dic2[0][0]:
    ans_1=n//2-odd_dic2[0][1]+n//2-even_dic2[1][1]
    ans_2=n//2-odd_dic2[1][1]+n//2-even_dic2[0][1]
    ans=min(ans_1, ans_2)

else:
    ans=n//2-odd_dic2[0][1]+n//2-even_dic2[0][1]
    
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	sample
# CreatedDate:  2020-09-27 14:00:12 +0900
# LastModified: 2020-09-27 14:18:18 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter


def main():
    n = int(input())
    v = list(map(int, input().split()))
    v_even = [v[i] for i in range(0, len(v), 2)]
    v_odd = [v[i] for i in range(1, len(v), 2)]
    even_cnt = sorted(map(list, Counter(v_even).items()), key=lambda x: x[1], reverse=True)
    odd_cnt = sorted(map(list, Counter(v_odd).items()), key=lambda x: x[1], reverse=True)
    ans = len(v_even) - even_cnt[0][1] + len(v_odd) - odd_cnt[0][1]
#    if even_cnt[0][0] == odd_cnt[0][0]:

    print(ans)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import collections
url = "https://atcoder.jp//contests/abc111/tasks/arc103_a"

def main():
    input()
    t = list(map(int, input().split()))
    even_lis = t[::2]
    odd_lis = t[1::2]
    e = collections.Counter(even_lis).most_common()
    odd = collections.Counter(odd_lis).most_common()
    if e[0][0] == odd[0][0] and e[0][1] + odd[0][1] == len(t):
        print(e[0][1])
        exit()
    ans = (len(even_lis) - e[0][1]) + (len(odd_lis) - odd[0][1])
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
url = "https://atcoder.jp//contests/abc111/tasks/arc103_a"

def main():
    input()
    t = list(map(int, input().split()))
    even_lis = t[::2]
    odd_lis = t[1::2]
    e = collections.Counter(even_lis).most_common()
    odd = collections.Counter(odd_lis).most_common()
    ans = (len(even_lis) - e[0][1]) + (len(odd_lis) - odd[0][1])
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
V = list(map(int, input().split()))
from collections import Counter
even = Counter(V[0::2])
even["0"]=0
odd = Counter(V[1::2])
odd["-1"]=0
i=0
even_top2, odd_top2 = [], []
for (e, o) in zip(even.items(), odd.items()):
  i+=1
  even_top2.append(e)
  odd_top2.append(o)
  if i==2:
    break
if even_top2[0][0] != odd_top2[0][0]:
  notchange = even_top2[0][1] + odd_top2[0][1]
else:
  notchange = max(even_top2[0][1]+odd_top2[1][1], even_top2[1][1]+odd_top2[0][1])
print(n-notchange)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
n_half = n//2
v = list(map(int, input().split()))
v_gusu = v[0::2]
v_odd = v[1::2]
ans = 0
c1 = collections.Counter(v)
c2 = collections.Counter(v_gusu)
c3 = collections.Counter(v_odd)

if c1.most_common()[0][1] == n:
    print(n_half)
    exit()

ans += (n_half - c2.most_common()[0][1])
ans += (n_half - c3.most_common()[0][1])
print(ans)

Submission status: Wrong Answer

Solution code:
# 時間切れは無くなるがWA 16
import collections

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

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

def check_ununiq(list_num, uniq_num):
    tmp_ans = 0
    #print(list_num)
    # 既に使われている数字かチェック
    # 使われていればそれを置き換える必要があるのでカウント
    if uniq_num in list_num:
        tmp_ans = list_num.count(uniq_num)
        #print("A", tmp_ans, uniq_num)
    # ユニークにした時の数字が1より大きいか
    elif len(set(list_num)) > 1:
        # 置き換える回数が少ない方の数字を抽出
        tmp = collections.Counter(list_num)
        dummy, tmp_ans = tmp.most_common()[-1]
        uniq_num, dummy = tmp.most_common()[0]
        #print("B", tmp_ans, uniq_num)
    # 置き換えが必要ない場合。ユニークとした数字のみを出力
    else:
        uniq_num = list_num[0]
        #print("C", tmp_ans, uniq_num)

    return(tmp_ans, uniq_num)

# 
ans1 = 0
uniq_num = 0
tmp_ans, uniq_num = check_ununiq(v_odd, uniq_num)
ans1 += tmp_ans
tmp_ans, uniq_num = check_ununiq(v_even, uniq_num)
ans1 += tmp_ans

# 逆順
ans2 = 0
uniq_num = 0
tmp_ans, uniq_num = check_ununiq(sorted(v_even, reverse=True), uniq_num)
ans2 += tmp_ans
tmp_ans, uniq_num = check_ununiq(sorted(v_odd, reverse=True), uniq_num)
ans2 += tmp_ans


if ans1 < ans2:
    ans = ans1
else:
    ans = ans2

print(ans)

Submission status: Wrong Answer

Solution code:
# 時間切れは無くなるがWA 16
import collections

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

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

def check_ununiq(list_num, uniq_num):
    tmp_ans = 0
    #print(list_num)
    # 既に使われている数字かチェック
    # 使われていればそれを置き換える必要があるのでカウント
    if uniq_num in list_num:
        tmp_ans = list_num.count(uniq_num)
        #print("A", tmp_ans, uniq_num)
    # ユニークにした時の数字が1より大きいか
    elif len(set(list_num)) > 1:
        # 置き換える回数が少ない方の数字を抽出
        tmp = collections.Counter(list_num)
        dummy, tmp_ans = tmp.most_common()[-1]
        uniq_num, dummy = tmp.most_common()[0]
        #print("B", tmp_ans, uniq_num)
    # 置き換えが必要ない場合。ユニークとした数字のみを出力
    else:
        uniq_num = list_num[0]
        #print("C", tmp_ans, uniq_num)

    return(tmp_ans, uniq_num)

# 
ans1 = 0
uniq_num = 0
tmp_ans, uniq_num = check_ununiq(v_odd, uniq_num)
ans1 += tmp_ans
tmp_ans, uniq_num = check_ununiq(v_even, uniq_num)
ans1 += tmp_ans

# 逆順
ans2 = 0
uniq_num = 0
tmp_ans, uniq_num = check_ununiq(sorted(v_even, reverse=True), uniq_num)
ans2 += tmp_ans
tmp_ans, uniq_num = check_ununiq(sorted(v_odd, reverse=True), uniq_num)
ans2 += tmp_ans



print(ans1, ans2)
if ans1 < ans2:
    ans = ans1
else:
    ans = ans2

print(ans)

Submission status: Wrong Answer

Solution code:
# 時間切れは無くなるがWA 16
import collections

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

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

ans = 0
uniq_num = 0
def check_ununiq(list_num, uniq_num):
    tmp_ans = 0
    # 既に使われている数字かチェック
    # 使われていればそれを置き換える必要があるのでカウント
    if uniq_num in list_num:
        tmp_ans = list_num.count(uniq_num)
        #print ("A", uniq_num, tmp_ans)
    # ユニークにした時の数字が1より大きいか
    elif len(set(list_num)) > 1:
        # 置き換える回数が少ない方の数字を抽出
        tmp = collections.Counter(list_num)
        dummy, tmp_ans = tmp.most_common()[-1]
        uniq_num, dummy = tmp.most_common()[0]
        #print ("B", uniq_num, tmp_ans)
    # 置き換えが必要ない場合。ユニークとした数字のみを出力
    else:
        uniq_num = list_num[0]
        #print("C", uniq_num, tmp_ans)

    return(tmp_ans, uniq_num)

tmp_ans, uniq_num = check_ununiq(v_odd, uniq_num)
ans += tmp_ans
tmp_ans, uniq_num = check_ununiq(v_even, uniq_num)
ans += tmp_ans

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

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

ans = 0
uniq_num = 0
def check_ununiq(list_num, uniq_num):
    tmp_ans = 0
    # 既に使われている数字かチェック
    # 使われていればそれを置き換える必要があるのでカウント
    if uniq_num in list_num:
        tmp_ans = list_num.count(uniq_num) #
    # ユニークにした時の数字が1より大きいか
    elif len(set(list_num)) > 1:
        # 置き換える回数が少ない方の数字を抽出
        tmp = collections.Counter(list_num)
        uniq_num, tmp_ans = tmp.most_common()[-1]
    # 置き換えが必要ない場合。ユニークとした数字のみを出力
    else:
        uniq_num = list_num[0]
    return(tmp_ans, uniq_num)

tmp_ans, uniq_num = check_ununiq(v_odd, uniq_num)
ans += tmp_ans
tmp_ans, uniq_num = check_ununiq(v_even, uniq_num)
ans += tmp_ans

print(ans)

Submission status: Wrong Answer

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

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

ans = 0
uniq_num = 0
def check_ununiq(list_num, uniq_num):
    tmp_ans = 0
    if uniq_num in set(list_num):
        tmp_ans = list_num.count(uniq_num)
    elif len(set(list_num)) > 1:
        min_ununiq = 10 ** 5
        for i in set(list_num):
            if list_num.count(i) < min_ununiq:
                min_ununiq = list_num.count(i)
                uniq_num = i
        tmp_ans += min_ununiq
    else:
        uniq_num = list_num[0]
    return(tmp_ans, uniq_num)

tmp_ans, uniq_num = check_ununiq(v_odd, uniq_num)
ans += tmp_ans
tmp_ans, uniq_num = check_ununiq(v_even, uniq_num)
ans += tmp_ans

print(ans)

Submission status: Wrong Answer

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

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

ans = 0
uniq_num = 0
def check_ununiq(list_num, uniq_num):
    tmp_ans = 0
    if uniq_num in list_num:
        tmp_ans = list_num.count(uniq_num)
    elif len(set(list_num)) > 1:
        min_ununiq = 10 ** 5
        for i in set(list_num):
            if list_num.count(i) < min_ununiq:
                min_ununiq = list_num.count(i)
                uniq_num = i
        tmp_ans += min_ununiq
    else:
        uniq_num = list_num[0]
    return(tmp_ans, uniq_num)

tmp_ans, uniq_num = check_ununiq(v_odd, uniq_num)
ans += tmp_ans
tmp_ans, uniq_num = check_ununiq(v_even, uniq_num)
ans += tmp_ans

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

#import
#import math
#import numpy as np
n = int(input())
V = list(map(int, input().split()))

even = {}
odd = {}

for i in range(n):
    v = V[i]
    if i % 2 == 0:
        if v in even:
            even[v] += 1
        else:
            even[v] = 1
    else:
        if v in odd:
            odd[v] += 1
        else:
            odd[v] = 1

oi = 0
oi2 = 0
ei = 0
ei2 = 0
for e in even:
    if even[e] > ei:
        ei2 = ei
        ei = e
    elif even[e] > ei2:
        ei2 = e

for o in odd:
    if odd[o] > oi:
        oi2 = oi
        oi = o
    elif odd[o] > oi:
        oi2 = o

ans = n - even[ei] - odd[oi]

if oi == ei:
    t1 = odd[oi]
    if oi2 != 0:
        t1 -= odd[oi2]
    t2 = even[ei]
    if ei2 != 0:
        t2 -= even[ei2]

    ans += min(t1, t2)

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

#import
#import math
#import numpy as np
n = int(input())
V = list(map(int, input().split()))

even = {}
odd = {}

for i in range(n):
    v = V[i]
    if i % 2 == 0:
        if v in even:
            even[v] += 1
        else:
            even[v] = 1
    else:
        if v in odd:
            odd[v] += 1
        else:
            odd[v] = 1

oi = 0
oi2 = 0
ei = 0
ei2 = 0
for e in even:
    if even[e] > ei:
        ei2 = ei
        ei = e

for o in odd:
    if odd[o] > oi:
        oi2 = oi
        oi = o

ans = n - even[ei] - odd[oi]

if oi == ei:
    t1 = odd[oi]
    if oi2 != 0:
        t1 -= odd[oi2]
    t2 = even[ei]
    if ei2 != 0:
        t2 -= even[ei2]

    ans += min(t1, t2)

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

#import
#import math
#import numpy as np
n = int(input())
V = list(map(int, input().split()))

even = {}
odd = {}

for i in range(n):
    v = V[i]
    if i % 2 == 0:
        if v in even:
            even[v] += 1
        else:
            even[v] = 1
    else:
        if v in odd:
            odd[v] += 1
        else:
            odd[v] = 1

oi = 0
oi2 = 0
ei = 0
ei2 = 0
for e in even:
    if even[e] > ei:
        ei2 = ei
        ei = e

for o in odd:
    if odd[o] > oi:
        oi2 = oi
        oi = o

ans = 0
for e in even:
    if e == ei:
        continue
    ans += even[e]

for o in odd:
    if o == oi:
        continue
    ans += odd[o]

if oi == ei:
    t1 = odd[oi]
    if oi2 != 0:
        t1 -= odd[oi2]
    t2 = even[ei]
    if ei2 != 0:
        t2 -= even[ei2]

    ans += min(t1, t2)

print(ans)

Submission status: Wrong Answer

Solution code:
#100 C - /\/\/\/
import collections
n = int(input())
A = list(map(int,input().split()))

A1 = A[::2]
A2 = A[1::2]
cnt1 = collections.Counter(A1)
cnt2 = collections.Counter(A2)

items1 = list(cnt1.items())
items2 = list(cnt2.items())

if items1[0][0] != items2[0][0]:
    ans = (len(A1) - items1[0][1]) + (len(A2) - items2[0][1])
else:
    if len(items1) == len(items2) == 1:
        ans = min(len(A1),len(A2))
    else:
        ans1 = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
        ans2 = (len(A1) - items1[1][1]) + (len(A2) - items2[0][1])
        ans = min(ans1,ans2)
print(ans)

Submission status: Wrong Answer

Solution code:
#100 C - /\/\/\/
import collections
n = int(input())
A = list(map(int,input().split()))

A1 = A[::2]
A2 = A[1::2]
cnt1 = collections.Counter(A1)
cnt2 = collections.Counter(A2)

items1 = list(cnt1.items())
items2 = list(cnt2.items())

if items1[0][0] != items2[0][0]:
    ans = (len(A1) - items1[0][1]) + (len(A2) - items2[0][1])
else:
    if len(items1) == len(items2) == 1:
        ans = min(len(A1),len(A2))
    elif len(items1) == 1:
        ans = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
    elif len(items2) == 1:
        ans = (len(A1) - items1[1][1]) + (len(A2) - items2[0][1])
    else:
        ans1 = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
        ans2 = (len(A1) - items1[1][1]) + (len(A2) - items2[0][1])
        ans = min(ans1,ans2)
print(ans)

Submission status: Wrong Answer

Solution code:
#100 C - /\/\/\/
import collections
n = int(input())
A = list(map(int,input().split()))

A1 = A[::2]
A2 = A[1::2]
cnt1 = collections.Counter(A1)
cnt2 = collections.Counter(A2)

items1 = list(cnt1.items())
items2 = list(cnt2.items())
items1.append((0,0))
items2.append((0.0))

O1 = items1[0][0]
O2 = items1[0][1]
E1 = items2[0][0]
E2 = items2[0][1]

if O1 != E1:
    ans = (len(A1) - cnt1[O1]) + (len(A2) - cnt2[E1])
else:
    ans1 = (len(A1) -  cnt1[O1]) + (len(A2) - cnt2[E2])
    ans2 = (len(A1) - cnt1[E2]) + (len(A2) - cnt2[E1])
    ans = min(ans1,ans2)
print(ans)

Submission status: Wrong Answer

Solution code:
#100 C - /\/\/\/
import collections
n = int(input())
A = list(map(int,input().split()))

A1 = A[::2]
A2 = A[1::2]
cnt1 = collections.Counter(A1)
cnt2 = collections.Counter(A2)

items1 = list(cnt1.items())
items2 = list(cnt2.items())

if items1[0][0] != items2[0][0]:
    ans = (len(A1) - items1[0][1]) + (len(A2) - items2[0][1])
else:
    if len(items1) == len(items2) == 1:
        ans = min(len(A1),len(A2))
    elif len(items1) == 1:
        ans = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
    elif len(items2) == 1:
        ans = (len(A1) - items1[1][1]) + (len(A2) - items2[2][1])
    else:
        ans1 = (len(A1) - items1[0][1]) + (len(A2) - items2[1][1])
        ans2 = (len(A1) - items1[1][1]) + (len(A2) - items2[0][1])
        ans = min(ans1,ans2)
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = [int(x) for x in input().split()]
v_odd, v_evn = [], []
for i in range(n):
  if i%2==0:
    v_odd.append(v[i])
  else:
    v_evn.append(v[i])
v_odd_cnt = collections.Counter(v_odd)
v_evn_cnt = collections.Counter(v_evn)
if len(v_odd_cnt) == len(v_evn_cnt) == 1:
  print(n//2)
  exit()
#print(v_odd_cnt, v_even_cnt)
max_kv_odd = max(v_odd_cnt.items(), key=lambda x: x[1])
max_kv_evn = max(v_evn_cnt.items(), key=lambda x: x[1])
if max_kv_odd[0] == max_kv_evn[0]:
  if len(v_odd_cnt) == 1:
    v_evn_cnt.pop(max_kv_evn[0])
    max_kv_evn_tmp = max(v_evn_cnt.items(), key=lambda x: x[1])
    print(n-max_kv_odd[1]-max_kv_evn_tmp[1])
    exit()
  if len(v_evn_cnt) == 1:
    v_odd_cnt.pop(max_kv_odd[0])
    max_kv_odd_tmp = max(v_odd_cnt.items(), key=lambda x: x[1])
    print(n-max_kv_odd_tmp[1]-max_kv_evn[1])
    exit()
  v_odd_cnt_tmp = v_odd_cnt
  v_evn_cnt_tmp = v_evn_cnt
  v_odd_cnt_tmp.pop(max_kv_odd[0])
  v_evn_cnt_tmp.pop(max_kv_evn[0])
  max_kv_odd_tmp = max(v_odd_cnt_tmp.items(), key=lambda x: x[1])
  max_kv_evn_tmp = max(v_evn_cnt_tmp.items(), key=lambda x: x[1])
  a = max_kv_odd[1] + max_kv_evn_tmp[1]
  b = max_kv_evn[1] + max_kv_odd_tmp[1]
  print(n-max(a, b))
  exit()
print(n-max_kv_odd[1]-max_kv_evn[1])
'''
v_odd = [0] * 10**5
veven = [0] * 10**5
for i in range(0, n//2+1, 2):
  v_odd[v[i]] += 1
  veven[v[i+1]] += 1
for i, x in enumerate(v_odd):

v_odd = {}
veven = {}
for i in range(0, n//2+1, 2):
  v_odd[v[i]] = v_odd.get(v[i], 0) + 1
  veven[v[i+1]] = veven.get(v[i+1], 0) + 1
'''

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

kisu = Counter(v[::2]).most_common(2)
gusu = Counter(v[1::2]).most_common(2)

if kisu[0][0] == gusu[0][0]:
    keep = max(kisu[1][1] + gusu[0][1],
               kisu[0][0] + gusu[1][1])
else:
    keep = kisu[0][1] + gusu[0][1]

print(n - keep)

Submission status: Wrong Answer

Solution code:
n = int(input())
alist  = list(map(int,input().split()))
list1 = alist[1::2]
list2 = alist[0::2]
from collections import Counter
dic1 = Counter(list1)
dic2 = Counter(list2)
vlist1 = sorted(list(dic1.values()))
vlist2 = sorted(list(dic2.values()))
print(n - vlist1[-1] - vlist2[-1])