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):
import collections

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

b = a[::2]
c = a[1::2]

b_ =collections.Counter(b)
c_ =collections.Counter(c)

baa = b_.most_common(b_)
caa = c_.most_common(c_)

baa.append([0,0])
caa.append([0,0])

if baa[0][0] != caa[0][0]:
    print(N - baa[0][1] - caa[0][1])
else:
    print(max(N - baa[0][1] - caa[1][1],N - caa[0][1] - baa[1][1]))

import collections
N = int(input())
a = []
b = []
for i in range(int(N/2)):
    a.append(input())
    b.append(input())

ac = collections.Counter(a)
bc = collections.Counter(b)

a_1 = ac.most_common()[0]
b_1 = ac.most_common()[0]

a1_ans = N/2 - a_1[1]
b1_ans = N/2 - b_1[1]
if len(ac.most_common()) == 1:
    a2_ans = N/2
else:
    a2_ans = N/2 - ac.most_common()[1][1]
if len(bc.most_common()) == 1:
    b2_ans = N/2
else:
    b2_ans = N/2 - bc.most_common()[1][1]

if a_1[0] != b_1[0]:
    print(int(a1_ans + b1_ans))
else:
    print(int(max(a1_ans+b2_ans,b1_ans+a2_ans)))

import collections

N = int(input())
a = list(map(int,input()))

b = a[::2]
c = a[1::2]

b_ =collections.Counter(b)
c_ =collections.Counter(c)

baa = b_.most_common(b_)
caa = c_.most_common(c_)

baa.append([0,0])
caa.append([0,0])

if baa[0][0] != caa[0][0]:
    print(N - baa[0][1] - caa[0][1])
else:
    print(max(N - baa[0][1] - caa[1][1],N - caa[0][1] - baa[1][1]))


import collections
N = int(input())
a = []
b = []
for i in range(int(N/2 + 0.1)):
    a.append(input().split())
    b.append(input().split())

ac = collections.Counter(a)
bc = collections.Counter(b)

a_1 = ac.most_common()[0]
b_1 = ac.most_common()[0]

a1_ans = N/2 - a_1[1]
b1_ans = N/2 - b_1[1]
if len(ac.most_common()) == 1:
    a2_ans = N/2
else:
    a2_ans = N/2 - ac.most_common()[1][1]
if len(bc.most_common()) == 1:
    b2_ans = N/2
else:
    b2_ans = N/2 - bc.most_common()[1][1]

if a_1[0] != b_1[0]:
    print(int(a1_ans + b1_ans))
else:
    print(int(max(a1_ans+b2_ans,b1_ans+a2_ans)))

import collections

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

b = a[::2]
c = a[1::2]

b_ =collections.Counter(b)
c_ =collections.Counter(c)

baa = b_.most_common(b_)
caa = c_.most_common(c_)

baa.append([0,0])
caa.append([0,0])

if baa[0][0] != caa[0][0]:
    print(N - baa[0][1] - caa[0][1])
else:
    print(max(N - baa[0][1] - caa[1][1],N - caa[0][1] - baa[1][1]))

import collections
N = int(input())
a = []
b = []
for i in range(int(N/2)):
    a.append(input().split())
    b.append(input().split())

ac = collections.Counter(a)
bc = collections.Counter(b)

a_1 = ac.most_common()[0]
b_1 = ac.most_common()[0]

a1_ans = N/2 - a_1[1]
b1_ans = N/2 - b_1[1]
if len(ac.most_common()) == 1:
    a2_ans = N/2
else:
    a2_ans = N/2 - ac.most_common()[1][1]
if len(bc.most_common()) == 1:
    b2_ans = N/2
else:
    b2_ans = N/2 - bc.most_common()[1][1]

if a_1[0] != b_1[0]:
    print(int(a1_ans + b1_ans))
else:
    print(int(max(a1_ans+b2_ans,b1_ans+a2_ans)))

import collections

N = int(input())
a = list(int(i) for i in input().split())

b = a[::2]
c = a[1::2]

b_ =collections.Counter(b)
c_ =collections.Counter(c)

baa = b_.most_common()
caa = c_.most_common()

baa.append([0,0])
caa.append([0,0])

if baa[0][0] != caa[0][0]:
    print(N - baa[0][1] - caa[0][1])
else:
    print(min(N - baa[0][1] - caa[1][1],N - caa[0][1] - baa[1][1]))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted