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()))
#偶数
eve = [0 for i in range(100000+1)]
#奇数
odd = [0 for i in range(100000+1)]

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

eve_1st_ind = eve.index(max(eve))
odd_1st_ind = odd.index(max(odd))
eve_1st_cnt = max(eve)
odd_1st_cnt = max(odd)

#2番目
eve[eve_1st_ind] = 0
odd[odd_1st_ind] = 0
eve_2nd_ind = eve.index(max(eve))
odd_2nd_ind = odd.index(max(odd))
eve_2nd_cnt = max(eve)
odd_2nd_cnt = max(odd)

#同じ場合
out1 = (n//2-eve_1st_cnt)+(n//2-odd_2nd_cnt)
out2 = (n//2-eve_2nd_cnt)+(n//2-odd_1st_cnt)

#最初から/vvvの場合
if out1 == n//2 and out2 == n//2 and not(eve_1st_ind == odd_1st_ind):
    print(0)
else:
    print(min(out1,out2))

Submission status: Wrong Answer

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

l0 = l[::2]
l1 = l[1::2]

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

memo0.append([0, -1])
memo1.append([0, -1])

print(memo0)
print(memo1)

if memo0[0][1]!=memo1[0][1]:
    print(n-memo0[0][0]-memo1[0][0])
else:
    ans1 = n- memo0[0][0]-memo1[1][0]
    ans2 = n- memo0[1][0]-memo1[0][0]
    print(min(ans1, ans2))

Submission status: Wrong Answer

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

l0 = []
l1 = []
for i in range(n):
    if i%2==0:
        l0.append(l[i])
    else:
        l1.append((l[i]))

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

memo0.append([0, -1])
memo1.append([0, -1])

# print(memo0)
# print(memo1)

if memo0[0][1]!=memo1[0][1]:
    print(n-memo0[0][0]-memo1[0][0])
else:
    ans1 = n- memo0[0][0]-memo1[1][0]
    ans2 = n- memo1[1][0]-memo1[0][0]
    print(min(ans1, ans2))

Submission status: Wrong Answer

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

l0 = []
l1 = []
for i in range(n):
    if i%2==0:
        l0.append(l[i])
    else:
        l1.append((l[i]))

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

memo0.append([0, -1])
memo1.append([0, -1])

# print(memo0)
# print(memo1)

if memo0[0][1]!=memo1[0][1]:
    print(n-memo0[0][0]-memo1[0][0])
else:
    ans1 = n- memo0[0][0]+memo1[1][0]
    ans2 = n- memo1[1][0]+memo1[0][0]
    print(min(ans1, ans2))

Submission status: Wrong Answer

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

l0 = []
l1 = []
for i in range(n):
    if i%2==0:
        l0.append(l[i])
    else:
        l1.append((l[i]))

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

memo0.append([0, -1])
memo1.append([0, -1])

# print(memo0)
# print(memo1)

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

Submission status: Wrong Answer

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

l0 = []
l1 = []
for i in range(n):
    if i%2==0:
        l0.append(l[i])
    else:
        l1.append((l[i]))

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

# print(memo0)
# print(memo1)

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

Submission status: Wrong Answer

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

l0 = []
l1 = []
for i in range(n):
    if i%2==0:
        l0.append(l[i])
    else:
        l1.append((l[i]))

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

# print(memo0)
# print(memo1)

if memo0[0][1]!=memo1[0][1]:
    print(n-memo0[0][0]-memo1[0][0])
elif len(memo0)==1 and len(memo1)==1:
    print(n//2)
elif len(memo0)==1:
    print(n-memo0[0][0]-memo1[1][0])
elif len(memo1)==1:
    print(n-memo1[1][0]-memo1[0][0])
#else:
    # print(n-max(memo0[0][0]+memo1[1][0], memo1[1][0]+memo1[0][0]))

Submission status: Wrong Answer

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

l0 = []
l1 = []
for i in range(n):
    if i%2==0:
        l0.append(l[i])
    else:
        l1.append((l[i]))

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

# print(memo0)
# print(memo1)

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

Submission status: Wrong Answer

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

l0 = []
l1 = []
for i in range(n):
    if i%2==0:
        l0.append(l[i])
    else:
        l1.append((l[i]))

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

# print(memo0)
# print(memo1)

if memo0[0][1]!=memo1[0][1]:
    print(n-memo0[0][0]-memo1[0][0])
elif len(memo0)==1 and len(memo1)==1:
    print(n//2)
elif len(memo0)==1:
    print(n-memo0[0][0]-memo1[1][0])
elif len(memo1)==1:
    print(n-memo1[1][0]-memo1[0][0])
else:
    print(n-max(n-memo0[0][0]-memo1[1][0], n-memo1[1][0]-memo1[0][0]))

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	v = list(map(int,input().split()))
	v0 = [v[i*2-1] for i in range(n//2)]
	v1 = [v[i*2] for i in range(n//2)]
	mxv0 = sorted(Counter(v0).items(),key = lambda x:x[1])
	mxv1 = sorted(Counter(v1).items(),key = lambda x:x[1])
	if(mxv1[-1][0] == mxv0[-1][0]):
		if(n == mxv1[-1][1]*2):
			print(n//2)
		elif(mxv1[-2][1] > mxv0[-2][1]):
			print(n-mxv0[-2][-1]-mxv1[-1][-1])
		else:
			print(n-mxv0[-1][-1]-mxv1[-2][-1])
	else:
		print(n-mxv0[-1][-1]-mxv1[-1][-1])

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    V = string_to_int(inputs[0])
    N = len(V)
    counts = {
        0: {},
        1: {}
    }
    for i, v in enumerate(V):
        key = i % 2
        if v in counts[key]:
            counts[key][v] += 1
        else:
            counts[key][v] = 1

    counts_sorted = []
    for i in range(2):
        counts_sorted.append(
            sorted(list(counts[i].items()), key=lambda x: x[1], reverse=True)
        )

    order = [0, 1]
    is_same = False
    if counts_sorted[0][0][0] == counts_sorted[1][0][0]:
        is_same = True
        if counts_sorted[0][0][1] >= counts_sorted[1][0][1]:
            order = [0, 1]
        else:
            order = [1, 0]

    change_count = 0
    for i, o in enumerate(order):
        if i == 1 and is_same:
            if len(counts_sorted[o]) == 1:
                change_count += N//2
            else:
                change_count += N//2 - counts_sorted[o][1][1]
        else:
            change_count += N//2 - counts_sorted[o][0][1]

    return change_count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Submission status: Wrong Answer

Solution code:

from collections import Counter
n = int(input())

lst = [int(i) for i in input().split()]

lst_odd = []
lst_eve = []

for i in range(n):
    if i%2 == 0:
        lst_odd.append(lst[i])
    else:
        lst_eve.append(lst[i])

cnt = Counter(lst_odd)
mod_o = (cnt.most_common(1))[0][0]

cnt = Counter(lst_eve)
mod_e = (cnt.most_common(1))[0][0]

if mod_o == mod_e:
    ans = len(lst_eve)
else:
    ans = len(lst_odd) - lst_odd.count(mod_o) + len(lst_eve) - lst_eve.count(mod_e)

print(ans)

Submission status: Wrong Answer

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

lst = [int(i) for i in input().split()]

lst_odd = []
lst_eve = []

for i in range(n):
    if i%2 == 0:
        lst_odd.append(lst[i])
    else:
        lst_eve.append(lst[i])

cnt = Counter(lst_odd)
mod = (cnt.most_common(1))[0][0]
num_o = len(lst_odd) - lst_odd.count(mod)

cnt = Counter(lst_eve)
mod = (cnt.most_common(1))[0][0]
num_e = len(lst_eve) - lst_eve.count(mod)

print(num_o + num_e)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

v_odd_mc = Counter(v_odd).most_common()
v_even_mc = Counter(v_even).most_common()

v_odd_mc.append((0, 0))
v_even_mc.append((0, 0))

if v_odd_mc[0] != v_even_mc[0]:
    print(n-v_odd_mc[0][1]-v_even_mc[0][1])
else:
    # print(n - max(v_odd_mc[0][1] + v_even_mc[1][1], v_odd_mc[1][0]+v_even_mc[0][1]))
    print(min(n - v_odd_mc[0][1] - v_even_mc[1][1], n - v_odd_mc[1][0] - v_even_mc[0][1]))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

v_odd_mc = Counter(v_odd).most_common()
v_even_mc = Counter(v_even).most_common()

v_odd_mc.append((0, 0))
v_even_mc.append((0, 0))

if v_odd_mc[0] != v_even_mc[0]:
    print(n-v_odd_mc[0][1]-v_even_mc[0][1])
else:
    # print(n - max(v_odd_mc[0][1] + v_even_mc[1][1], v_odd_mc[1][0]+v_even_mc[0][1]))
    print(min(n - v_odd_mc[0][1] - v_even_mc[1][1], n - v_odd_mc[1][0] - v_even_mc[0][1]))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

v_odd_mc = Counter(v_odd).most_common()
v_even_mc = Counter(v_even).most_common()

v_odd_mc.append((0, 0))
v_even_mc.append((0, 0))

if v_odd_mc[0] != v_even_mc[0]:
    print(n-v_odd_mc[0][1]-v_even_mc[0][1])
else:
    print(n - max(v_odd_mc[0][1] + v_even_mc[1][1], v_odd_mc[1][0]+v_even_mc[0][1]))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

odd = defaultdict(int)
even = defaultdict(int)

nodd = 0
neven = 0
for ix in range(1, n+1):
    if ix & 1:
        odd[v[ix-1]] += 1
        nodd += 1
    else:
        even[v[ix-1]] += 1
        neven += 1

odd_sorted = sorted(odd.items(), key=lambda x: x[1], reverse=True)
even_sorted = sorted(even.items(), key=lambda x: x[1], reverse=True)

odd_top = odd_sorted[0]
even_top = even_sorted[0]

# solve

ans = 0

if odd_top[0] == even_top[0]:

    if len(odd) == len(even) == 1:
        ans = nodd

    else:
        if len(odd) == 1:
            ans += nodd - odd_top[1]
            ans += neven - even_sorted[1][1]

        elif len(even) == 1:
            ans += nodd - odd_sorted[1][1]
            ans += neven - even_top[1]

        else:
            odd_sec = odd_sorted[1]
            even_sec = even_sorted[1]

            # use others
            if odd_sec[1] < even_sec[1]:
                # use nodd_sec
                ans += nodd - odd_sec[1]
                ans += neven - even_top[1]
            else:
                ans += nodd - odd_top[1]
                ans += neven - even_sec[1]
else:
    ans += nodd - odd_top[1]
    ans += neven - even_top[1]

print(ans)

Submission status: Wrong Answer

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

num = 100001
#num = 10

even = [[0,i] for i in range(num)]
odd = [[0,i] for i in range(num)]

for i in range(n):
    if i%2 == 0:
        even[v[i]][0] += 1
    else:
        odd[v[i]][0] += 1
        
odd.sort(key=lambda x: -x[0])
even.sort(key=lambda x: -x[0])

if even[0][1] != odd[0][1]:
    print(n-even[0][0]-odd[0][0])
else:
    print(max(n-even[0][0]-odd[1][0], n-even[1][0]-odd[0][0]))

Submission status: Wrong Answer

Solution code:
import collections
def main():


    N = int(input())
    V = list(map(int,input().split()))
    V1 = V[0::2]
    V2 = V[1::2]
    count = 0

    fre1 = collections.Counter(V1).most_common(2)
    fre2 = collections.Counter(V2).most_common(2)
    

    if len(list(set(V)))==1:
        print(int(N/2))
        exit()


    if fre1[0][0] != fre2[0][0]:

        count += len(V1)-fre1[0][1]
        count += len(V2)-fre2[0][1]
        print(count)
    
    else:
        if len(V1)-fre1[0][1] < len(V2)-fre2[0][1]:
            count += len(V1)-fre1[0][1]
            count += len(V2)-fre2[1][1]
            print(count)
        else:
            count += len(V1)-fre1[1][1]
            count += len(V2)-fre2[0][1]
            print(count)

        






if __name__== "__main__":
    main()

Submission status: Wrong Answer

Solution code:

def main():


    N = int(input())
    V = list(map(int,input().split()))
    V1 = [i for i in V[0::2]]
    V2 = [i for i in V[1::2]]
    count1 = 0

    if len(list(set(V)))==1:
        print(int(N/2))
        exit()

    for i,j in enumerate(V1[1::]):
        if V1[i-1] != j:
            count1 +=1

    
    for i,j in enumerate(V2[1::]):
        if V2[i-1] != j:
            count1 +=1

    print(count1)





if __name__== "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc111/tasks/arc103_a
# C - /\/\/\/
import collections

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

odd_list = [v for i, v in enumerate(v_list) if i % 2 == 1]
even_list = [v for i, v in enumerate(v_list) if i % 2 == 0]
# print(even_list)

odd_counter = collections.Counter(odd_list)
# print('odd_counter: {}'.format(dict(odd_counter)))
odd_kouho_list = [odd_counter.most_common()[0]]

if len(odd_counter) >= 2:
    odd_kouho_list.append(odd_counter.most_common()[1])

even_counter = collections.Counter(even_list)
# print('even_counter: {}'.format(dict(even_counter)))
even_kouho_list = [even_counter.most_common()[0]]

if len(even_counter) >= 2:
    even_kouho_list.append(even_counter.most_common()[1])

# print('odd: {}'.format(odd_kouho_list))
# print('even: {}'.format(even_kouho_list))

if len(even_counter) == 1 and len(odd_counter) == 1:
    # 11
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # 全て同じ数字
        # 1111
        # print('case z-1')
        ans = len(v_list) // 2
    else:
        # すでに山になってる
        # ex) 1212
        # print('case z-2')
        ans = 0
elif len(even_counter) == 1 and len(odd_counter) != 1:
    # 12
    # 奇数側が1種類の数字しかない。必然的に偶数側を変える必要がある
    if odd_kouho_list[0][0] == even_kouho_list[0][0]:
        # ex) 1 1 1 1 1 3 1 3 1 2 -> 3
        # print('case a-1')
        target = odd_kouho_list[1][0] # 1番手は使えないので2番手を残す
    else:
        # ex) 1 3 1 3 1 3 1 3 1 2 -> 1
        # print('case a-2')
        target = odd_kouho_list[0][0] # 1番手を残す
    # 残すと決めた数字以外の要素が何個あるか
    ans = len([x for x in odd_list if x != target])
elif len(even_counter) != 1 and len(odd_counter) == 1:
    # 21
    # 偶数側が1種類の数字しかない。必然的に偶数側を変える必要がある
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # ex) 2 1 3 1 3 1 1 1 1 1 1 1 -> 4
        # print('case b-1')
        target = even_kouho_list[1][0]
    else:
        # ex) 2 1 3 1 3 1 3 1 3 1 -> 1
        # print('case b-2')
        target = even_kouho_list[0][0]
    ans = len([x for x in even_list if x != target])
else:
    # 22
    # ex) 1 2 1 2 1 2 3 4 3 4 5 6 -> 6
    # 奇数側も偶数側も2種類以上の数がある
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # 奇数側も偶数側も最大個数の数字が同じ場合
        if even_kouho_list[0][1] >= odd_kouho_list[0][1]:
            # ex) 1 1 1 1 1 1 1 2 3 2 4 4 -> 6
            # 奇数側の方が個数が多い
            # print('case c-11')
            even_target = even_kouho_list[0][0] # 奇数側は1番手を使う
            odd_target = odd_kouho_list[1][0] # 偶数側は2番手を使う
        else:
            # print('case c-12')
            even_target = even_kouho_list[1][0] # 奇数側は2番手を使う
            odd_target = odd_kouho_list[0][0] # 偶数側は1番手を使う
    else:
        # print('case c-2')
        # 数字が被っていないので、奇数側も偶数側も1番手の数字を使う
        even_target = even_kouho_list[0][0]
        odd_target = odd_kouho_list[0][0]

    ans_1 = len([x for x in even_list if x != even_target])
    ans_2 = len([x for x in odd_list if x != odd_target])
    ans = ans_1 + ans_2

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc111/tasks/arc103_a
# C - /\/\/\/
import collections

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

odd_list = [v for i, v in enumerate(v_list) if i % 2 == 1]
even_list = [v for i, v in enumerate(v_list) if i % 2 == 0]
# print(even_list)

odd_counter = collections.Counter(odd_list)
# print('odd_counter: {}'.format(dict(odd_counter)))
odd_kouho_list = [odd_counter.most_common()[0]]

if len(odd_counter) >= 2:
    odd_kouho_list.append(odd_counter.most_common()[1])

even_counter = collections.Counter(even_list)
# print('even_counter: {}'.format(dict(even_counter)))
even_kouho_list = [even_counter.most_common()[0]]

if len(even_counter) >= 2:
    even_kouho_list.append(even_counter.most_common()[1])

# print('odd: {}'.format(odd_kouho_list))
# print('even: {}'.format(even_kouho_list))

if len(even_counter) == 1 and len(odd_counter) == 1:
    # 11
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # 全て同じ数字
        # 1111
        # print('case z-1')
        ans = len(v_list) // 2
    else:
        # すでに山になってる
        # ex) 1212
        # print('case z-2')
        ans = 0
elif len(even_counter) == 1 and len(odd_counter) != 1:
    # 12
    # 奇数側が1種類の数字しかない。必然的に偶数側を変える必要がある
    if odd_kouho_list[0][0] == even_kouho_list[0][0]:
        # ex) 1 1 1 1 1 3 1 3 1 2 -> 3
        # print('case a-1')
        target = odd_kouho_list[1][0] # 1番手は使えないので2番手を残す
    else:
        # ex) 1 3 1 3 1 3 1 3 1 2 -> 1
        # print('case a-2')
        target = odd_kouho_list[0][0] # 1番手を残す
    # 残すと決めた数字以外の要素が何個あるか
    ans = len([x for x in odd_list if x != target])
elif len(even_counter) != 1 and len(odd_counter) == 1:
    # 21
    # 偶数側が1種類の数字しかない。必然的に偶数側を変える必要がある
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # ex) 2 1 3 1 3 1 1 1 1 1 1 1 -> 4
        # print('case b-1')
        target = even_kouho_list[1][0]
    else:
        # ex) 2 1 3 1 3 1 3 1 3 1 -> 1
        # print('case b-2')
        target = even_kouho_list[0][0]
    ans = len([x for x in even_list if x != target])
else:
    # 22
    # ex) 1 2 1 2 1 2 3 4 3 4 5 6 -> 6
    # 奇数側も偶数側も2種類以上の数がある
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # 奇数側も偶数側も最大個数の数字が同じ場合
        if even_kouho_list[0][1] >= odd_kouho_list[0][1]:
            # 奇数側の方が個数が多い
            # print('case c-11')
            even_target = even_kouho_list[0][0] # 奇数側は1番手を使う
            odd_target = odd_kouho_list[0][1] # 偶数側は2番手を使う
        else:
            # print('case c-12')
            even_target = even_kouho_list[0][1] # 奇数側は2番手を使う
            odd_target = odd_kouho_list[0][0] # 偶数側は1番手を使う
    else:
        # print('case c-2')
        # 数字が被っていないので、奇数側も偶数側も1番手の数字を使う
        even_target = even_kouho_list[0][0]
        odd_target = odd_kouho_list[0][0]

    ans_1 = len([x for x in even_list if x != even_target])
    ans_2 = len([x for x in odd_list if x != odd_target])
    ans = ans_1 + ans_2

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc111/tasks/arc103_a
# C - /\/\/\/
import collections

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

odd_list = [v for i, v in enumerate(v_list) if i % 2 == 1]
even_list = [v for i, v in enumerate(v_list) if i % 2 == 0]
# print(even_list)

odd_counter = collections.Counter(odd_list)
# print('odd_counter: {}'.format(dict(odd_counter)))
odd_kouho_list = [odd_counter.most_common()[0]]

if len(odd_counter) >= 2:
    odd_kouho_list.append(odd_counter.most_common()[1])

even_counter = collections.Counter(even_list)
# print('even_counter: {}'.format(dict(even_counter)))
even_kouho_list = [even_counter.most_common()[0]]

if len(even_counter) >= 2:
    even_kouho_list.append(even_counter.most_common()[1])

# print('odd: {}'.format(odd_kouho_list))
# print('even: {}'.format(even_kouho_list))

if len(even_counter) == 1 and len(odd_counter) == 1:
    # 11
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # 全て同じ数字
        # 1111
        # print('case z-1')
        ans = len(v_list) // 2
    else:
        # すでに山になってる
        # ex) 1212
        # print('case z-2')
        ans = 0
elif len(even_counter) == 1 and len(odd_counter) != 1:
    # 12
    # 奇数側が1種類の数字しかない。必然的に偶数側を変える必要がある
    if odd_kouho_list[0][0] == even_kouho_list[0][0]:
        # ex) 1 1 1 1 1 3 1 3 1 2 -> 3
        # print('case a-1')
        target = odd_kouho_list[1][0] # 1番手は使えないので2番手を残す
    else:
        # ex) 1 3 1 3 1 3 1 3 1 2 -> 1
        # print('case a-2')
        target = odd_kouho_list[0][0] # 1番手を残す
    # 残すと決めた数字以外の要素が何個あるか
    ans = len([x for x in odd_list if x != target])
elif len(even_counter) != 1 and len(odd_counter) == 1:
    # 21
    # 偶数側が1種類の数字しかない。必然的に偶数側を変える必要がある
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # ex) 2 1 3 1 3 1 1 1 1 1 1 1 -> 4
        # print('case b-1')
        target = even_kouho_list[1][0]
    else:
        # ex) 2 1 3 1 3 1 3 1 3 1 -> 1
        # print('case b-2')
        target = even_kouho_list[0][0]
    ans = len([x for x in even_list if x != target])
else:
    # 22
    # ex) 1 2 1 2 1 2 3 4 3 4 5 6 -> 6
    # 奇数側も偶数側も2種類以上の数がある
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # 奇数側も偶数側も最大個数の数字が同じ場合
        if even_kouho_list[0][1] >= odd_kouho_list[0][1]:
            # 奇数側の方が個数が多い
            print('case c-11')
            even_target = even_kouho_list[0][0] # 奇数側は1番手を使う
            odd_target = odd_kouho_list[0][1] # 偶数側は2番手を使う
        else:
            print('case c-12')
            even_target = even_kouho_list[0][1] # 奇数側は2番手を使う
            odd_target = odd_kouho_list[0][0] # 偶数側は1番手を使う
    else:
        print('case c-2')
        # 数字が被っていないので、奇数側も偶数側も1番手の数字を使う
        even_target = even_kouho_list[0][0]
        odd_target = odd_kouho_list[0][0]

    ans_1 = len([x for x in even_list if x != even_target])
    ans_2 = len([x for x in odd_list if x != odd_target])
    ans = ans_1 + ans_2

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc111/tasks/arc103_a
# C - /\/\/\/
import collections

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

odd_list = [v for i, v in enumerate(v_list) if i % 2 == 1]
even_list = [v for i, v in enumerate(v_list) if i % 2 == 0]
# print(even_list)

odd_counter = collections.Counter(odd_list)
# print('odd_counter: {}'.format(dict(odd_counter)))
odd_kouho_list = [odd_counter.most_common()[0]]

if len(odd_counter) >= 2:
    odd_kouho_list.append(odd_counter.most_common()[1])

even_counter = collections.Counter(even_list)
# print('even_counter: {}'.format(dict(even_counter)))
even_kouho_list = [even_counter.most_common()[0]]

if len(even_counter) >= 2:
    even_kouho_list.append(even_counter.most_common()[1])

# print('odd: {}'.format(odd_kouho_list))
# print('even: {}'.format(even_kouho_list))

if len(even_counter) == 1 and len(odd_counter) == 1:
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # 全て同じ数字
        # 1111
        ans = len(v_list) // 2
    else:
        # すでに山になってる
        # ex) 1212
        ans = 0
elif len(even_counter) == 1 and len(odd_counter) != 1:
    if odd_kouho_list[0][0] == even_kouho_list[0][0]:
        # ex) 1 1 1 1 1 3 1 3 1 2 -> 3
        target = odd_kouho_list[1][0]
    else:
        # ex) 1 3 1 3 1 3 1 3 1 2 -> 1
        target = odd_kouho_list[0][0]
    ans = len([x for x in odd_list if x != target])
elif len(even_counter) != 1 and len(odd_counter) == 1:
    if even_kouho_list[0][0] == odd_kouho_list[0][0]:
        # ex) 2 1 3 1 3 1 1 1 1 1 -> 2
        target = even_kouho_list[1][0]
    else:
        # ex) 2 1 3 1 3 1 3 1 3 1 -> 1
        target = even_kouho_list[0][0]
    ans = len([x for x in even_list if x != target])
else:
    # if even_kouho_list[0][1] >= odd_kouho_list[0][0]:
    #     target = odd_kouho_list[1][0]
    # else:
    #     target = even_kouho_list[0][0]
    # ex) 1 2 1 2 1 2 3 4 3 4 5 6 -> 6
    ans_1 = len([x for x in even_list if x != even_kouho_list[0][0]])
    ans_2 = len([x for x in odd_list if x != odd_kouho_list[0][0]])
    ans = ans_1 + ans_2

print(ans)

Submission status: Wrong Answer

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

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

odd = {}
even = {}

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

max_odd = max(odd)
max_even = max(even)

odd.pop(max_odd)
even.pop(max_even)

print(sum(list(odd.values())+ list(even.values())))

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
ea = N // 2
e1 = e[0][1]
e2 = e[1][1] if len(e) > 1 else 0
oa = N - ea
o1 = o[0][1]
o2 = o[1][1] if len(o) > 1 else 0
cnt = 0
if e[0][0] != o[0][0]:
    cnt = N - e1 - o1
else:
    if o2 < e1:
        cnt = N - e2 - o1
    else:
        cnt = N - e1 - o2
print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
ea = N // 2
e1 = e[0][1]
e2 = e[1][1] if len(e) > 1 else 0
oa = N - ea
o1 = o[0][1]
o2 = o[1][1] if len(o) > 1 else 0
cnt = 0
if e[0][0] != o[0][0]:
    cnt = N - e1 - o1
else:
    if o2 > e1:
        cnt = N - e2 - o1
    else:
        cnt = N - e1 - o2
print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
v = list(map(int, input().split()))
e = []
o = []
for idx, i in enumerate(v):
    if idx % 2 == 0:
        o.append(i)
    else:
        e.append(i)

e = Counter(e).most_common()
o = Counter(o).most_common()
ea = N // 2
e1 = e[0][1]
e2 = e[1][1] if len(e) > 1 else 0
oa = N - ea
o1 = o[0][1]
o2 = o[1][1] if len(o) > 1 else 0
cnt = 0
if e1 != o1:
    cnt = N - e1 - o1
else:
    if o2 > e1:
        cnt = N - e2 - o1
    else:
        cnt = N - e1 - o2
print(cnt)