Problem: 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.

Submission attempts (in order):
n-v_odd_common[0][1]-v_even_common[1][1]

from collections import Counter
 
n = int(input())
v_array = list(map(int,input().split()))
 
v_odd = v_array[0::2]
v_even = v_array[1::2]
 
v_odd_common = Counter(v_odd).most_common()
v_even_common = Counter(v_even).most_common()

v_odd_common.append((0,0))
v_even_common.append((0,0))

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

from collections import Counter
from sys import exit

n = input()
v_array = list(map(int,input().split()))
 
v_odd = v_array[0::2]
v_even = v_array[1::2]
 
v_odd_common = Counter(v_odd).most_common()
v_even_common = Counter(v_even).most_common()

if len(set(v_array)) == 1:
    print(int(len(v_array)/2))
    exit()

print(v_odd_common, v_even_common)
for i in range(0,min(len(v_odd_common),len(v_even_common))):
    if v_odd_common[i] == v_even_common[i]:
        if v_odd_common[i+1][1] > v_even_common[i+1][1]:
            v_odd_common_candidate = v_odd_common[i][1]
            v_even_common_candidate = v_even_common[i+1][i]
            break
        elif v_odd_common[i+1][1] < v_even_common[i+1][1]:
            v_odd_common_candidate = v_odd_common[i+1][1]
            v_even_common_candidate = v_even_common[i][i]
            break
        else:
            v_odd_common_candidate = v_odd_common[i][1]
            v_even_common_candidate = v_even_common[i][i]
            break
    else:
        v_odd_common_candidate = v_odd_common[0][1]
        v_even_common_candidate = v_even_common[0][1]
    
print(len(v_odd) - v_odd_common_candidate + len(v_even) - v_even_common_candidate)

from collections import Counter
 
n = int(input())
v_array = list(map(int,input().split()))
 
v_odd = v_array[0::2]
v_even = v_array[1::2]
 
v_odd_common = Counter(v_odd).most_common()
v_even_common = Counter(v_even).most_common()

v_odd_common.append((0,0))
v_even_common.append((0,0))

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

n-v_odd_common[0][1]-v_even_common[1][1]

from collections import Counter
 
n = int(input())
v_array = list(map(int,input().split()))
 
v_odd = v_array[0::2]
v_even = v_array[1::2]
 
v_odd_common = Counter(v_odd).most_common()
v_even_common = Counter(v_even).most_common()

v_odd_common.append((0,0))
v_even_common.append((0,0))

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted