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

nums1 = nums[0::2] #[開始インデックス::インデックスの間隔]
nums2 = nums[1::2]
print(nums1)
print(nums2)

bug1 = [0] * 100001 #要素の数を数えるためにあらかじめ0のリストを用意しておく
bug2 = [0] * 100001

#出てきた要素の数を数える
for num in nums1:
    bug1[num] += 1

for num in nums2:
    bug2[num] += 1

max_v_1 = max(bug1)
max_i_1 = bug1.index(max_v_1) #インデックス値＝要素なのでindexで最大のものを取り出す
max_v_2 = max(bug2)
max_i_2 = bug2.index(max_v_2)

if max_i_1 == max_i_2:
    bug1[max_i_1] = 0 #値が同じなので最大の物を０とするとMAXを取った時に２番目に大きい値が取り出せる
    bug2[max_i_2] = 0
    sec_max_v_1 = max(bug1)
    sec_max_v_2 = max(bug2)
	#一番大きい値の
    print(n - max(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))
else:
    print(n - max_v_1 - max_v_2) #全体から該当要素を引く

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
V = list(map(int,input().split()))
odd = []
even = []
if len(list(set(V))) == 1:
  print(len(V)//2)
  exit()
else:
  for i in range(N):
    if i%2 == 0:
      odd.append(V[i])
    else:
      even.append(V[i])
odd_c = Counter(odd)
odd_v = list(odd_c.values())
odd_k = list(odd_c.keys())
even_c = Counter(even)
even_v = list(even_c.values())
even_k = list(even_c.keys())
ans = 0
if len(odd_v) == 0 and len(even_v) == 0:
  print(0)
else:
  M = max(len(odd_v),len(even_v))
  for i in range(1,M):
    if i < len(odd_v):
      ans += odd_v[i]
    if i < len(even_v):
      ans += even_v[i]
  if odd_k[0] != even_k[0]:
    pass
  else:
    if odd_v[0]+odd_v[1] > even_v[0]+even_v[1]:
      ans += even_v[0]
      ans -= even_v[1]
    else:
      ans += odd_v[0]
      ans -= odd_v[1]
  print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
V = list(map(int,input().split()))
odd = []
even = []
if len(list(set(V))) == 1:
  print(len(V)//2)
  exit()
else:
  for i in range(N):
    if i%2 == 0:
      odd.append(V[i])
    else:
      even.append(V[i])
odd_c = Counter(odd)
odd_v = list(odd_c.values())
even_c = Counter(even)
even_v = list(even_c.values())
ans = 0
if len(odd_v) == 0 and len(even_v) == 0:
  print(0)
else:
  M = max(len(odd_v),len(even_v))
  for i in range(1,M):
    if i < len(odd_v):
      ans += odd_v[i]
    if i < len(even_v):
      ans += even_v[i]
  print(ans)

Submission status: Wrong Answer

Solution code:
import collections

sequence_num=int(input())
count=0
even_sequence_list=[]
odd_sequence_list=[]
sequence_list=list(map(int,input().split()))
for i in range(sequence_num):
	if i%2 == 0:
		even_sequence_list.append(sequence_list[i])
	else:
		odd_sequence_list.append(sequence_list[i])
even_most_num=(collections.Counter(even_sequence_list)).most_common()[0][0]
odd_most_num=(collections.Counter(odd_sequence_list)).most_common()[0][0]
even_num_num=collections.Counter(even_sequence_list).most_common()[0][1]
odd_num_num=collections.Counter(odd_sequence_list).most_common()[0][1]
if even_most_num == odd_most_num:
	if even_num_num > odd_num_num:
		odd_most_num=collections.Counter(odd_sequence_list).most_common()[1][0]
	elif even_num_num < odd_num_num:
		even_most_num=collections.Counter(even_sequence_list).most_common()[1][0]
	else:
		even_most_num=0
""" 
	if collections.Counter(odd_sequence_list).most_common()[0][1] == len(odd_sequence_list):
		odd_most_num=0
	else:
		odd_most_num=collections.Counter(odd_sequence_list).most_common()[1][0] """
for j in even_sequence_list:
	if j != even_most_num:
		count+=1
for k in odd_sequence_list:
	if k != odd_most_num:
		count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import collections

sequence_num=int(input())
count=0
even_sequence_list=[]
odd_sequence_list=[]
sequence_list=list(map(int,input().split()))
for i in range(sequence_num):
	if i%2 == 0:
		even_sequence_list.append(sequence_list[i])
	else:
		odd_sequence_list.append(sequence_list[i])
even_most_num=(collections.Counter(even_sequence_list)).most_common()[0][0]
odd_most_num=(collections.Counter(odd_sequence_list)).most_common()[0][0]
even_num_num=collections.Counter(even_sequence_list).most_common()[0][1]
odd_num_num=collections.Counter(even_sequence_list).most_common()[0][1]
if even_most_num == odd_most_num:
	if even_num_num > odd_num_num:
		odd_most_num=collections.Counter(odd_sequence_list).most_common()[1][0]
	elif even_num_num < odd_num_num:
		even_most_num=collections.Counter(even_sequence_list).most_common()[1][0]
	else:
		even_most_num=0
""" 
	if collections.Counter(odd_sequence_list).most_common()[0][1] == len(odd_sequence_list):
		odd_most_num=0
	else:
		odd_most_num=collections.Counter(odd_sequence_list).most_common()[1][0] """
for j in even_sequence_list:
	if j != even_most_num:
		count+=1
for k in odd_sequence_list:
	if k != odd_most_num:
		count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import collections

sequence_num=int(input())
count=0
even_sequence_list=[]
odd_sequence_list=[]
sequence_list=list(map(int,input().split()))
for i in range(sequence_num):
	if i%2 == 0:
		even_sequence_list.append(sequence_list[i])
	else:
		odd_sequence_list.append(sequence_list[i])
even_most_num=(collections.Counter(even_sequence_list)).most_common()[0][0]
odd_most_num=(collections.Counter(odd_sequence_list)).most_common()[0][0]
if even_most_num == odd_most_num:
	if collections.Counter(odd_sequence_list).most_common()[0][1] == len(odd_sequence_list):
		odd_most_num=0
	else:
		odd_most_num=collections.Counter(odd_sequence_list).most_common()[1][0]
for j in even_sequence_list:
	if j != even_most_num:
		count+=1
for k in odd_sequence_list:
	if k != odd_most_num:
		count+=1
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main():
    n=int(input())
    v=list(map(int,input().split()))
    l1=Counter(v[::2])
    l2=Counter(v[1::2])
    l1[0]=0
    l2[0]=0
    f1,s1=l1.most_common(2)
    f2,s2=l2.most_common(2)
    if f1[0]==f2[0]:
        print(n-f1[1]-f2[1])
    else:
        print(min(n-f1[1]-s2[1],n-f2[1]-s1[1]))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    v=list(map(int,input().split()))
    l1=[0]*(10**5+1)
    l2=[0]*(10**5+1)
    for i,vn in enumerate(v):
        if i%2==0:
            l1[vn]+=1
        else:
            l2[vn]+=1
    f1,f2,s1,s2=0,0,0,0
    for i,ln in enumerate(l1):
        s1=max(s1,min(ln,f1))
        f1=max(f1,ln)
    for i,ln in enumerate(l2):
        s2=max(s2,min(ln,f2))
        f2=max(f2,ln)
    print(min(n-f1-s2,n-f2-s1))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    v=list(map(int,input().split()))
    l1=[0]*(10**5+1)
    l2=[0]*(10**5+1)
    for i,vn in enumerate(v):
        if i%2==0:
            l1[vn]+=1
        else:
            l2[vn]+=1
    f1,f2,s1,s2=0,0,0,0
    for i,ln in enumerate(l1):
        s1=max(s1,min(ln,f1))
        f1=max(f1,ln)
    for i,ln in enumerate(l2):
        s2=max(s2,min(ln,f2))
        f2=max(f2,ln)
    print(max(n-f1-s2,n-f2-s1))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

ls1 = v_list[::2]
ls2 = v_list[1::2]

c1 = Counter(ls1)
c2 = Counter(ls2)

c1_list = c1.most_common()
c2_list = c2.most_common()

c1_val = 0
c2_val = 0

ret = 0

if c1_list[0][1] >= c2_list[0][1]:
    c1_val = c1_list[0][0]
    ret += len(ls1) - c1_list[0][1]
    if c2_list[0][0] == c1_val:
        if len(c2_list) == 1:
            ret += len(ls2)
        else:
            ret += len(ls2) - c2_list[1][1]
    else:
        ret += len(ls2) - c2_list[0][1]
else:
    c2_val = c2_list[0][0]
    ret += len(ls2) - c2_list[0][1]

    if c1_list[0][0] == c2_val:
        if len(c1_list) == 1:
            ret += len(ls1)
        else:
            ret += len(ls1) - c1_list[1][1]
    else:
        ret += len(ls1) - c1_list[0][1]

print(ret)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = list(map(int, input().split()))
s1 = s[::2]
s2 = s[1::2]

ans1 = len(s1) - Counter(s1).most_common(1)[0][1]
ans2 = len(s2) - Counter(s2).most_common(1)[0][1]
if(ans1 == ans2 == 0 and s[0] == s[1]):
    print(n // 2)
else:
    print(ans1 + ans2)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = list(map(int, input().split()))
s1 = s[::2]
s2 = s[1::2]

ans1 = len(s1) - Counter(s1).most_common()[0][1]
ans2 = len(s2) - Counter(s2).most_common()[0][1]
if(ans1 == ans2 == 0 and s[0] == s[1]):
    print(n // 2)
else:
    print(ans1 + ans2)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = list(map(int, input().split()))
s1 = s[::2]
s2 = s[1::2]

ans1 = len(s1) - Counter(s1).most_common()[0][1]
ans2 = len(s2) - Counter(s2).most_common()[0][1]
print(ans1 + ans2)

Submission status: Wrong Answer

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

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

c_v = collections.Counter(v)
c_even = collections.Counter(v_even)
c_odd = collections.Counter(v_odd)

c_even_s = sorted(c_even.items(), key=lambda x:x[1], reverse=True)
c_odd_s = sorted(c_odd.items(), key=lambda x:x[1], reverse=True)

if(len(c_v) != 1):
    if(c_even_s[0][0] != c_odd_s[0][0]):
        print(n//2-c_even_s[0][1]+n//2-c_odd_s[0][1])
    else:
        if(c_even_s[0][1] > c_odd_s[0][1]):
            ans = n//2-c_even_s[0][1]+n//2-c_odd_s[1][1]
        else:
            ans = n//2-c_odd_s[0][1] + n//2-c_even_s[1][1]
        print(ans)
else:
    print(n//2)

Submission status: Wrong Answer

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

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

c_v = collections.Counter(v)
c_even = collections.Counter(v_even)
c_odd = collections.Counter(v_odd)

c_even_s = sorted(c_even.items(), key=lambda x:x[1], reverse=True)
c_odd_s = sorted(c_odd.items(), key=lambda x:x[1], reverse=True)

if(len(c_v) != 1):
    if(c_even_s[0][0] != c_odd_s[0][0]):
        print(abs(c_even_s[0][1]-n//2)+abs(c_odd_s[0][1]-n//2))
    else:
        ans = abs(c_even_s[0][1]-n//2)+c_odd_s[0][1]
        print(ans)
else:
    print(n//2)

Submission status: Wrong Answer

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

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

c_v = collections.Counter(v)
c_even = collections.Counter(v_even)
c_odd = collections.Counter(v_odd)

c_even_s = sorted(c_even.items(), key=lambda x:x[1], reverse=True)
c_odd_s = sorted(c_odd.items(), key=lambda x:x[1], reverse=True)

if(len(c_v) != 1):
    print(abs(c_even_s[0][1]-n//2)+abs(c_odd_s[0][1]-n//2))
else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(map(int, input().split()))
c = collections.Counter(v)
c_s = sorted(c.items(), key=lambda x:x[1], reverse=True)

if(len(c_s) > 1):
    if(n//2 >= c_s[0][1]):
        cnt = abs(n//2-c_s[0][1])+abs(n//2-c_s[1][1])
        print(cnt)
    else:
        cnt = abs(n//2-c_s[1][1])
        print(cnt)
else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A_odd = A[1::2]
    A_even = A[0::2]
    dict_odd = {-1:0}
    dict_even = {-1:0}
    for i in A_odd :
        if i not in dict_odd :
            dict_odd[i] = 1
        else:
            dict_odd[i] += 1
    for i in A_even :
        if i not in dict_even :
            dict_even[i] = 1
        else:
            dict_even[i] += 1
    dict_odd  = sorted(dict_odd.items(), key = lambda x : x[1],reverse=True)
    dict_even = sorted(dict_even.items(), key=lambda x: x[1], reverse=True)

    if dict_even[0][0] != dict_odd[0][0] :
        max_odd = dict_odd[0][1]
        max_even = dict_even[0][1]
        print(N - max_even - max_odd)
    else:
        if dict_odd[0][1] > dict_even[0][1]:
            max_odd = dict_odd[0][1]
            max_even = dict_even[1][1]
            print(N - max_even - max_odd)
        else:
            max_odd = dict_odd[1][1]
            max_even = dict_even[0][1]
            print(N - max_even - max_odd)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A_odd = A[1::2]
    A_even = A[0::2]
    dict_odd = {0:0}
    dict_even = {0:0}
    for i in A_odd :
        if i not in dict_odd :
            dict_odd[i] = 1
        else:
            dict_odd[i] += 1
    for i in A_even :
        if i not in dict_even :
            dict_even[i] = 1
        else:
            dict_even[i] += 1
    dict_odd  = sorted(dict_odd.items(), key = lambda x : x[1],reverse=True)
    dict_even = sorted(dict_even.items(), key=lambda x: x[1], reverse=True)

    if dict_even[0][0] != dict_odd[0][0] :
        max_odd = dict_odd[0][1]
        max_even = dict_even[0][1]
        print(N - max_even - max_odd)
    else:
        if dict_odd[0][1] > dict_even[0][1]:
            max_odd = dict_odd[0][1]
            max_even = dict_even[1][1]
            print(N - max_even - max_odd)
        else:
            max_odd = dict_odd[1][1]
            max_even = dict_even[0][1]
            print(N - max_even - max_odd)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

list_0 = []
list_1 = []
for i in range(n//2):
    list_0.append(v[i*2])
    list_1.append(v[i*2+1])


c_0 = list(collections.Counter(list_0).values())
c_1 = list(collections.Counter(list_1).values())
c_0.sort(reverse=True)
c_1.sort(reverse=True)
#print(c_0)
#print(c_1)


cnum_0 = list(collections.Counter(list_0).keys())
cnum_1 = list(collections.Counter(list_1).keys())
#print(cnum_0[0])
#print(cnum_1[0])

tmp_0 = 0
tmp_1 = 0
#if len(c_0) >= 2:
#    tmp_0 = sum(c_0[1:])
#if len(c_1) >= 2:
#    tmp_1 = sum(c_1[1:])


if len(c_0) >= 2 and len(c_1) >= 2:
    # 奇数番のリストと偶数番の出現数の多い順に並べたリストそれぞれの先頭の数が同じ場合
    if cnum_0[0] == cnum_1[0]:
        # 一番多い数字の数も同じ場合
        if c_0[0] == c_1[0]:
            if c_0[1] <= c_1[1]:
                tmp_0 = sum(c_0[1:])
                if len(c_1) == 2:
                    tmp_1 = c_1[0]
                else:
                    tmp_1 = c_1[0] + sum(c_1[2:])
            else:
                tmp_1 = sum(c_1[1:])
                if len(c_0) == 2:
                    tmp_0 = c_0[0]
                else:
                    tmp_0 = c_0[0] + sum(c_0[2:])

        # 一番多い数字の数が偶数番のリストと奇数番のリストで違うとき
        elif c_0[0] > c_1[0]:
            tmp_0 = sum(c_0[1:])
            tmp_1 = c_1[0]
        elif c_0[0] < c_1[0]:
            tmp_1 = sum(c_1[1:])
            tmp_0 = c_0[0]

    elif cnum_0[0] != cnum_1[0]:
        tmp_0 = sum(c_0[1:])
        tmp_1 = sum(c_1[1:])


elif len(c_0) >= 2 and len(c_1) == 1:
    tmp_1 = 0
    if cnum_0[0] != cnum_1[0]:
        tmp_0 = sum(c_0[1:])
    else:
        if len(c_0) == 2:
            tmp_0 = c_0[0]
        else:
            tmp_0 = c_0[0] + sum(c_0[2:])
        
elif len(c_0) == 1 and len(c_1) >= 2:
    tmp_0 = 0
    if cnum_0[0] != cnum_1[0]:
        tmp_1 = sum(c_1[1:])
    else:
        if len(c_1) == 2:
            tmp_1 = c_1[0]
        else:
            tmp_1 = c_1[0] + sum(c_1[2:])

elif len(c_0) == 1 and len(c_1) == 1:
    if v[0] == v[1]:
        tmp_0 = c_0[0]
        tmp_1 = 0
    elif v[0] != v[1]:
        tmp_0 = 0
        tmp_1 = 0

print(tmp_0+tmp_1)

Submission status: Wrong Answer

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

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

list_0 = []
list_1 = []
for i in range(n//2):
    list_0.append(v[i*2])
    list_1.append(v[i*2+1])


c_0 = list(collections.Counter(list_0).values())
c_1 = list(collections.Counter(list_1).values())
c_0.sort(reverse=True)
c_1.sort(reverse=True)
#print(c_0)
#print(c_1)


cnum_0 = list(collections.Counter(list_0).keys())
cnum_1 = list(collections.Counter(list_1).keys())
#print(cnum_0[0])
#print(cnum_1[0])

tmp_0 = 0
tmp_1 = 0
#if len(c_0) >= 2:
#    tmp_0 = sum(c_0[1:])
#if len(c_1) >= 2:
#    tmp_1 = sum(c_1[1:])


if len(c_0) >= 2 and len(c_1) >= 2:
    # 奇数番のリストと偶数番の出現数の多い順に並べたリストそれぞれの先頭の数が同じ場合
    if (c_0[0] == c_1[0]) and cnum_0[0] == cnum_1[0]:
        if c_0[1] <= c_1[1]:
            tmp_0 = sum(c_0[1:])
            if len(c_1) == 2:
                tmp_1 = c_1[0]
            else:
                tmp_1 = c_1[0] + sum(c_1[2:])
        else:
            tmp_1 = sum(c_1[1:])
            if len(c_0) == 2:
                tmp_0 = c_0[0]
            else:
                tmp_0 = c_0[0] + sum(c_0[2:])
    elif cnum_0[0] != cnum_1[0]:
        tmp_0 = sum(c_0[1:])
        tmp_1 = sum(c_1[1:])


elif len(c_0) >= 2 and len(c_1) == 1:
    tmp_1 = 0
    if cnum_0[0] != cnum_1[0]:
        tmp_0 = sum(c_0[1:])
    else:
        if len(c_0) == 2:
            tmp_0 = c_0[0]
        else:
            tmp_0 = c_0[0] + sum(c_0[2:])
        
elif len(c_0) == 1 and len(c_1) >= 2:
    tmp_0 = 0
    if cnum_0[0] != cnum_1[0]:
        tmp_1 = sum(c_1[1:])
    else:
        if len(c_1) == 2:
            tmp_1 = c_1[0]
        else:
            tmp_1 = c_1[0] + sum(c_1[2:])

elif len(c_0) == 1 and len(c_1) == 1:
    if v[0] == v[1]:
        tmp_0 = c_0[0]
        tmp_1 = 0
    elif v[0] != v[1]:
        tmp_0 = 0
        tmp_1 = 0

print(tmp_0+tmp_1)

Submission status: Wrong Answer

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

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

list_0 = []
list_1 = []
for i in range(n//2):
    list_0.append(v[i*2])
    list_1.append(v[i*2+1])


c_0 = list(collections.Counter(list_0).values())
c_1 = list(collections.Counter(list_1).values())
c_0.sort(reverse=True)
c_1.sort(reverse=True)
#print(c_0)
#print(c_1)


cnum_0 = list(collections.Counter(list_0).keys())
cnum_1 = list(collections.Counter(list_1).keys())
#print(cnum_0[0])
#print(cnum_1[0])

tmp_0 = 0
tmp_1 = 0
#if len(c_0) >= 2:
#    tmp_0 = sum(c_0[1:])
#if len(c_1) >= 2:
#    tmp_1 = sum(c_1[1:])


if len(c_0) >= 2 and len(c_1) >= 2:
    # 奇数番のリストと偶数番のリストそれぞれの先頭の数が同じ場合
    if (c_0[0] == c_1[0]) and cnum_0[0] == cnum_1[0]:
        if c_0[1] <= c_1[1]:
            tmp_0 = sum(c_0[1:])
            if len(c_1) == 2:
                tmp_1 = c_1[0]
            else:
                tmp_1 = c_1[0] + sum(c_1[2:])
        else:
            tmp_1 = sum(c_1[1:])
            if len(c_0) == 2:
                tmp_0 = c_0[0]
            else:
                tmp_0 = c_0[0] + sum(c_0[2:])
    elif cnum_0[0] != cnum_1[0]:
        tmp_0 = sum(c_0[1:])
        tmp_1 = sum(c_1[1:])


elif len(c_0) >= 2 and len(c_1) == 1:
    tmp_1 = 0
    tmp_0 = sum(c_0[1:])
elif len(c_0) == 1 and len(c_1) >= 2:
    tmp_0 = 0
    tmp_1 = sum(c_1[1:])

elif len(c_0) == 1 and len(c_1) == 1:
    if v[0] == v[1]:
        tmp_0 = c_0[0]
        tmp_1 = 0
    elif v[0] != v[1]:
        tmp_0 = 0
        tmp_1 = 0

print(tmp_0+tmp_1)

Submission status: Wrong Answer

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

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

list_0 = []
list_1 = []
for i in range(n//2):
    list_0.append(v[i*2])
    list_1.append(v[i*2+1])


c_0 = list(collections.Counter(list_0).values())
c_1 = list(collections.Counter(list_1).values())
c_0.sort(reverse=True)
c_1.sort(reverse=True)
#print(c_0)
#print(c_1)


#cnum_0 = collections.Counter(list_0)
#cnum_1 = collections.Counter(list_1)
#print(cnum_0)
#print(cnum_1)

tmp_0 = 0
tmp_1 = 0
#if len(c_0) >= 2:
#    tmp_0 = sum(c_0[1:])
#if len(c_1) >= 2:
#    tmp_1 = sum(c_1[1:])


if len(c_0) >= 2 and len(c_1) >= 2:
    # 奇数番のリストと偶数番のリストそれぞれの先頭の数が同じ場合
    if c_0[0] == c_1[0]:
        if c_0[1] <= c_1[1]:
            tmp_0 = sum(c_0[1:])
            if len(c_1) == 2:
                tmp_1 = c_1[0]
            else:
                tmp_1 = c_1[0] + sum(c_1[2:])
        else:
            tmp_1 = sum(c_1[1:])
            if len(c_0) == 2:
                tmp_0 = c_0[0]
            else:
                tmp_0 = c_0[0] + sum(c_0[2:])

elif len(c_0) >= 2 and len(c_1) == 1:
    tmp_1 = 0
    tmp_0 = sum(c_0[1:])
elif len(c_0) == 1 and len(c_1) >= 2:
    tmp_0 = 0
    tmp_1 = sum(c_1[1:])

elif len(c_0) == 1 and len(c_1) == 1:
    if v[0] == v[1]:
        tmp_0 = c_0[0]
        tmp_1 = 0
    elif v[0] != v[1]:
        tmp_0 = 0
        tmp_1 = 0

print(tmp_0+tmp_1)

Submission status: Wrong Answer

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

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

list_0 = []
list_1 = []
for i in range(n//2):
    list_0.append(v[i*2])
    list_1.append(v[i*2+1])


c_0 = list(collections.Counter(list_0).values())
c_1 = list(collections.Counter(list_1).values())
c_0.sort(reverse=True)
c_1.sort(reverse=True)
#print(c_0)
#print(c_1)


#cnum_0 = collections.Counter(list_0)
#cnum_1 = collections.Counter(list_1)
#print(cnum_0)
#print(cnum_1)

tmp_0 = 0
tmp_1 = 0
#if len(c_0) >= 2:
#    tmp_0 = sum(c_0[1:])
#if len(c_1) >= 2:
#    tmp_1 = sum(c_1[1:])


if len(c_0) >= 2 and len(c_1) >= 2:
    # 奇数番のリストと偶数番のリストそれぞれの先頭の数が同じ場合
    if c_0[0] == c_1[0]:
        if c_0[1] <= c_1[1]:
            tmp_0 = sum(c_0[1:])
            if len(c_1) == 2:
                tmp_1 = c_1[0]
            else:
                tmp_1 = c_1[0] + sum(c_1[2:])
        else:
            tmp_1 = sum(c_1[1:])
            if len(c_0) == 2:
                tmp_0 = c_0[0]
            else:
                tmp_0 = c_0[0] + sum(c_0[2:])

elif len(c_0) >= 2 and len(c_1) == 1:
    tmp_1 = 0
    tmp_0 = sum(c_0[1:])
elif len(c_0) == 1 and len(c_1) >= 2:
    tmp_0 = 0
    tmp_1 = sum(c_1[1:])

elif len(c_0) == 1 and len(c_1) == 1:
    tmp_0 = 0
    tmp_1 = 0

print(tmp_0+tmp_1)

Submission status: Wrong Answer

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

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

list_0 = []
list_1 = []
for i in range(n//2):
    list_0.append(v[i*2])
    list_1.append(v[i*2+1])


c_0 = list(collections.Counter(list_0).values())
c_1 = list(collections.Counter(list_1).values())
c_0.sort(reverse=True)
c_1.sort(reverse=True)
#print(c_0)
#print(c_1)


#cnum_0 = collections.Counter(list_0)
#cnum_1 = collections.Counter(list_1)
#print(cnum_0)
#print(cnum_1)

tmp_0 = 0
tmp_1 = 0
if len(c_0) >= 2:
    tmp_0 = sum(c_0[1:])
if len(c_1) >= 2:
    tmp_1 = sum(c_1[1:])

if tmp_0 == tmp_1 == 0 and v[0] == v[1]:
    print(c_0[0]) 
else:
    print(tmp_0+tmp_1)

Submission status: Wrong Answer

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

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

list_0 = []
list_1 = []
for i in range(n//2):
    list_0.append(v[i*2])
    list_1.append(v[i*2+1])


c_0 = list(collections.Counter(list_0).values())
c_1 = list(collections.Counter(list_1).values())

#print(c_0)
#print(c_1)

tmp_0 = 0
tmp_1 = 0
if len(c_0) >= 2:
    tmp_0 = sum(c_0[1:])
if len(c_1) >= 2:
    tmp_1 = sum(c_1[1:])

if tmp_0 == tmp_1 == 0 and v[0] == v[1]:
    print(c_0[0]) 
else:
    print(tmp_0+tmp_1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt1 = Counter(v[::2]).most_common()
cnt2 = Counter(v[1::2]).most_common()
cnt1 += [(-1,0)]
cnt2 += [(-1,0)]
if cnt1[0][0] != cnt2[0][0]:
    print(n - (cnt1[0][1] + cnt2[0][1]))
else:
    print(n - max(cnt1[1][1] + cnt2[0][1], cnt1[1][1] + cnt2[0][1]))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt1 = Counter(v[::2]).most_common()
cnt2 = Counter(v[1::2]).most_common()
cnt1 += [(-1,0)]
cnt2 += [(-1,0)]
print(cnt1, cnt2)
if cnt1[0][0] != cnt2[0][0]:
    print(n - (cnt1[0][1] + cnt2[0][1]))
else:
    print(n - max(cnt1[1][1] + cnt2[0][1], cnt1[1][1] + cnt2[0][1]))

Submission status: Wrong Answer

Solution code:
n=int(input())
v=input().split()
k=0
p=1
for i in range(n):
    if v[0]==v[1]:
        for j in range(0,n,2):
            if v[j]!=v[1]:
                v[0]=v[j]
                k+=1
                break
            else:
                v[0]="h"
                k+=1
                break
    elif i%2==0:
        if v[i]!=v[0] :
            k+=1
    else:
        if v[i]!=v[1] :
            k+=1

print(k)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=input().split()
k=0
p=1
for i in range(n):
    if v[0]==v[1]:
        v[0]="hello"
        k+=1
    elif i%2==0:
        if v[i]!=v[0] :
            k+=1
    else:
        if v[i]!=v[1] :
            k+=1

print(k)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=input().split()
k=0
p=1
for i in range(n):
    if i%2==0:
        if v[i]!=v[0] or v[i]==v[1]:
            k+=1
    else:
        if v[i]!=v[1] :
            k+=1

print(k)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=input().split()
k=0
p=1
if len(set(v))!=2:
    print(len(v)//2)
else:
    print(k)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=input().split()
k=0
p=2
j=0
for i in range(0,n//2,1):
    if v[i]!=v[p]:
        k+=1
    elif v[p]==v[p-1]:
        j+=1
    p+=1
print(k+j)

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solve():
    n = int(input())
    v = list(map(int, input().split()))
    even = v[::2]
    odd = v[1::2]
    e_l = len(even)
    o_l = len(odd)
    e_m = Counter(even).most_common()
    o_m = Counter(odd).most_common()
    ret = 0
    if e_m[0][0] == o_m[0][0]:
        e_next = e_m[1][1] if len(e_m) > 1 else 0
        o_next = o_m[1][1] if len(o_m) > 1 else 0
        
        e_red = e_l-e_m[0][1]+o_l-o_next
        o_red = e_l-e_next+o_l-o_m[0][1]
        ret = e_red if e_red > o_red else o_red
    else:
        ret = e_l - e_m[0][1] + o_l - o_m[0][1]
        
    print(ret)
    
solve()

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
v = list(map(int, input().split()))
v1 = v[0::2]
v2 = v[1::2]
c1 = collections.Counter(v1)
c2 = collections.Counter(v2)
best_v1_val = c1.most_common()[0][0]
best_v2_val = c2.most_common()[0][0]
best_v1_cnt = c1.most_common()[0][1]
best_v2_cnt = c2.most_common()[0][1]

cnt = 0
if best_v1_cnt >= best_v2_cnt:
  cnt += n//2 - best_v1_cnt
  if best_v1_val != best_v2_val:
    cnt += n//2 - best_v2_cnt
  else:
    if len(c2) == 1:
      sec_best_v2_cnt = 0
    else:
      sec_best_v2_cnt = c2.most_common()[1][1]
    cnt += n//2 - sec_best_v2_cnt
else:
  cnt += n//2 - best_v2_cnt
  if best_v1_val != best_v2_val:
    cnt += n//2 - best_v1_cnt
  else:
    if len(c1) == 1:
      sec_best_v1_cnt = 0
    else:
      sec_best_v1_cnt = c1.most_common()[1][1]
    cnt += n//2 - sec_best_v1_cnt
print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter as C
n = int(input())
a = list(map(int,input().split()))
c1 = C(a[::2])
c2 = C(a[1::2])
c1_1 = c1.most_common(1)[0]
c2_1 = c2.most_common(1)[0]
ans = n-c1_1[1] - c2_1[1]
print(ans if c1_1[0] != c2_1[0] else n//2)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
a1,a0 = [] , []

for i in range(n):
    if i%2 == 0:
        a0.append(v[i])
    else:
        a1.append(v[i])
        
b0 = Counter(a0)
b1 = Counter(a1)
b0[0] = 0
b1[0] = 0

if max(b0) != max(b1):
    ans = n - max(b0.values()) - max(b1.values())
else:
    q = max(b0.values())
    r = max(b1.values())
    b0.pop(max(b0))
    b1.pop(max(b1))
    ans = min(n - max(b0.values()) - r , n - q - max(b1.values()))
    
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
c1 = Counter(v[::2]).most_common()
c2 = Counter(v[1::2]).most_common()
if c1[0][0] == c2[0][0]:
    if len(c1) > 1 and len(c2) > 1:
        print(n-max(c1[1][1]+c2[0][1], c1[0][1]+c2[1][1]))
    elif len(c1) > 1:
        print(n-c1[1][1]-c2[0][1])
    elif len(c2) > 1:
        print(n-c1[0][1]-c2[1][1])
    else:
        print(n//2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
c1 = Counter(v[::2]).most_common()[0][1]
c2 = Counter(v[1::2]).most_common()[0][1]
if n-c1-c2 == 0:
    if v[0] == v[1]:
        print(n//2)
    else:
        print(n-c1-c2)
else:
    print(n-c1-c2)

Submission status: Wrong Answer

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

arr = [0] * (max(v) + 1)
for i in range(n):
    arr[v[i]] += 1

arr.sort()
arr.reverse()

mi = 10 ** 12
ia = -1
for i in range(len(arr)):
    diff = abs(arr[i] - n // 2)
    if mi > diff:
        mi = diff
        ia = i


mi = 10 ** 12
ib = -1
for i in range(len(arr)):
    diff = abs(arr[i] - n // 2)
    if mi > diff and i != ia:
        mi = diff
        ib = i

        
count = 0
for i in range(len(arr)):
    if i == ia or i == ib:
        if arr[i] > n // 2:
            count += arr[i] - n // 2
        else:
            pass
    else:
        count += arr[i]
print(count)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(input().split())
v0 = []
v1 = []
for i in range(n):
  if i%2 == 0:
    v0.append(v[i])
  else:
    v1.append(v[i])
V0 = collections.Counter(v0)
V1 = collections.Counter(v1)
print(len(v0)+len(v1)-V0.most_common()[0][1]-V1.most_common()[0][1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
V = list(map(int, input().split()))
X, Y = Counter(), Counter()
for i in range(0, N):
    if i & 1:
        Y[V[i]] += 1
    else:
        X[V[i]] += 1
x = max(X.items(), key=lambda x: x[1])[0]
y = max(Y.items(), key=lambda x: x[1])[0]
if x == y:
    y += 1
ans = 0
for i in range(0, N):
    if i & 1:
        if y != V[i]:
            ans += 1
    else:
        if x != V[i]:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

count_even = [0] * (10 ** 5 + 1)
count_odd = [0] * (10 ** 5 + 1)

i = 0
while i < n:
  count_even[v[i]] += 1
  count_odd[v[i+1]] += 1
  i += 2
  
print(n - max(count_even) - max(count_odd))

Submission status: Wrong Answer

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

count_even = [0] * (10 ** 5 + 1)
count_odd = [0] * (10 ** 5 + 1)

i = 0
while i < n:
  count_even[i] += 1
  count_odd[i+1] += 1
  i += 2
  
print(n - max(count_even) - max(count_odd))