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 collections

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

v1 = [v[i] for i in range(0,n,2)]
v2 = [v[i] for i in range(1,n,2)]

count1 = collections.Counter(v1)
count2 = collections.Counter(v2)

if len(count1) == 1 and len(count2) == 1:
    if v1 == v2:
        print(len(v1))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
N=list(map(int,input().split()))
even=[]
odd=[]
for i in range(len(N)):
    if i%2==0:
        even.append(N[i])
    if i%2==1:
        odd.append(N[i])
import collections
c = collections.Counter(even)
x=c.most_common()[0][0]
o=even.count(x)
d= collections.Counter(odd)
y=d.most_common()[0][0]
p=odd.count(y)
s=len(even)-even.count(x)
t=len(odd)-odd.count(y)
if x!=y and o==len(even) and p==len(odd):
    print(0)
elif x==y and o==len(even) and p==len(odd):
    print(n/2)
elif x==y and (o!=len(even) or p!=len(odd)):
    if o>p:
        y=d.most_common()[1][0]
        s=len(even)-even.count(x)
        t=len(odd)-odd.count(y)
        print(s+t)
    else:
        x=c.most_common()[1][0]
        s=len(even)-even.count(x)
        t=len(odd)-odd.count(y)
        print(s+t)
else:
    print(s+t)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = input().split()
v_int = [int(i) for i in v]
v_odd = []
v_even = []
for i in range(int(n/2)):
  v_even.append(v_int[i*2])
  v_odd.append(v_int[i*2+1])
print(v_even)
print(v_odd)
c_odd = collections.Counter(v_odd)
c_even = collections.Counter(v_even)
max_odd = 0
second_odd = 0
max_key_odd = 0
for key in c_odd:
  if max_odd < c_odd[key]:
    second_odd = max_odd
    max_odd = c_odd[key]
    max_key_odd = key
  elif second_odd < c_odd[key]:
    second_odd = c_odd[key]
    
max_even = 0
second_even = 0
max_key_even = 0
for key in c_even:
  if max_even < c_even[key]:
    second_even = max_even
    max_even = c_even[key]
    max_key_even = key
  elif second_even < c_even[key]:
    second_even = c_even[key]
    
print(second_odd)
print(second_even)
if max_key_even != max_key_odd:
  print(int(n)- max_even - max_odd)
else:
  if max_even > max_odd:
    if max_even == second_even:
      print(int(n) - max_even - max_odd)
    else:
      print(int(n) - max_even - second_odd)
  else:
    if max_odd == second_odd:
      print(int(n) - max_odd - max_even)
    else:
      print(int(n) - max_odd - second_even)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import collections

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

odd = V[::2]
even = V[1:N:2]

odd_d = collections.Counter(odd)
even_d = collections.Counter(even)

if odd == even and len(odd_d) == 1 and len(even_d) == 1:
    ans = len(odd)

elif len(odd_d) == 1 and len(even_d) == 1:
    ans = 0

else:
    for i,n in enumerate(odd_d.keys()):
        if i == 0:
            odd_ind = n
        elif i == 1:
            odd_ind2 = n
        else:
            break
    for i, n in enumerate(even_d.keys()):
        if i == 0:
            even_ind = n
        elif i == 1:
            even_ind2 = n
        else:
            break

    if odd_ind != even_ind:
        ans = (N//2 - odd_d[odd_ind]) + (N//2 - even_d[even_ind])
    else:
        if odd_d[odd_ind] == odd_d[odd_ind2] or even_d[even_ind] == even_d[even_ind2]:
            ans = (N//2 - odd_d[odd_ind]) + (N//2 - even_d[even_ind])
        elif odd_d[odd_ind] >= even_d[even_ind]:
            ans = (N//2 - odd_d[odd_ind]) + (N//2 - even_d[even_ind2])
        else:
            ans = (N//2 - odd_d[odd_ind2]) + (N//2 - even_d[even_ind])
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

n = input()
line = input().split()
odd = line[::2]
even = line[1::2]
o = collections.Counter(odd)
e = collections.Counter(even)
maxoddcnt = o.most_common()[0][1]
maxevencnt = e.most_common()[0][1]

print(len(odd)-maxoddcnt+len(even)-maxevencnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
from scipy import stats

N = int(raw_input().replace("\n", ""))

a_list = map(int, raw_input().replace("\n", "").split(" "))
a_list = np.asarray(a_list)

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

len_vec = N / 2

#even_c = collections.Counter(even_list)
#odd_c = collections.Counter(odd_list)
#even_first_value, even_first_count = even_c.most_common()[0]
#odd_first_value, odd_first_count  = odd_c.most_common()[0]
even_first_value, even_first_count = [x[0] for x in stats.mode(even_list)]
odd_first_value, odd_first_count = [x[0] for x in stats.mode(odd_list)]

#if even_first_value == odd_first_value and len(even_c) == 1 and len(odd_c) == 1:
if even_first_value == odd_first_value and even_first_count == len_vec and odd_first_count == len_vec:
    cost = len_vec
elif even_first_value != odd_first_value:
    cost =  (even_first_count + odd_first_count)
#elif len(even_c) == 1 and len(odd_c) > 1:
elif even_first_count == len_vec and odd_first_count != len_vec:
    #odd_second_value, odd_second_count = odd_c.most_common(1)
    odd_list = odd_list[odd_list != odd_first_value]
    odd_second_value, odd_second_count = [x[0] for x in stats.mode(odd_list)]
    cost = len_vec + odd_second_count
#elif len(odd_c) == 1 and len(even_c) > 1:
elif even_first_count != len_vec and odd_first_count == len_vec:
    #even_second_value, even_second_count = even_c.most_common(1)
    even_list = even_list[even_list != even_first_value]
    even_second_value, even_second_count = [x[0] for x in stats.mode(even_list)]
    cost = len_vec + even_second_count
else: # ryouhou no first ga onaji de hutatuijou arutoki
    #odd_second_value, odd_second_count = odd_c.most_common(1)
    #even_second_value, even_second_count = even_c.most_common(1)
    odd_list = odd_list[odd_list != odd_first_value]
    odd_second_value, odd_second_count = [x[0] for x in stats.mode(odd_list)]
    even_list = even_list[even_list != even_first_value]
    even_second_value, even_second_count = [x[0] for x in stats.mode(even_list)]
    cost = max(even_first_count+odd_second_count, even_second_count+odd_first_count)

print 2* len_vec - cost

Submission status: Wrong Answer

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

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

v1 = v[::2]
cv1 = collections.Counter(v1)
v2 = v[1::2]
cv2 = collections.Counter(v2)
num1 = cv1.most_common()[0][0]
num2 = cv2.most_common()[0][0]

cnt1 = cv1.most_common()[0][1]
cnt2 = cv2.most_common()[0][1]
if num1==num2:
  temp1 = cv1.most_common()[0][1]
  temp2 = cv2.most_common()[0][1]
  if temp1>temp2:
    cnt1 = cv1.most_common()[0][1]
  else:
    cnt2 = cv2.most_common()[0][1]

print((len(v1)+len(v2))-(cnt1+cnt2))

Submission status: Wrong Answer

Solution code:
import collections
import sys

n = input()
n = int(n)
v = [0]*int(n)
v[:] = map(int, input().split())
#print(n)
#print(v)
v_o = [0]*int((n/2))
v_e = [0]*int((n/2))
for i in range(n):
    if i%2 == 0:
        v_o[i//2] = v[i]
    else:
        v_e[i//2] = v[i]

cnt_o = collections.Counter(v_o).most_common(2)
#print(cnt_o[0][1])
collections.Counter(v_e).most_common(1)
cnt_e = collections.Counter(v_e).most_common(2)
#print(cnt_e[0][1])

if cnt_o[0][0] == cnt_e[0][0]:
    if (cnt_o[0][1] == n//2) and (cnt_e[0][1] == n//2):
        print(n//2)
        sys.exit()
    if cnt_o[0][1] >= cnt_e[0][1]:
        n_min = n -cnt_o[0][1] - cnt_e[1][1]
        print(n_min)
    elif cnt_o[0][1] <= cnt_e[0][1]:
        n_min = n -cnt_o[1][1] - cnt_e[0][1]
        print(n_min)
else:
    n_min = n -cnt_o[0][1] - cnt_e[0][1]
    print(n_min)

Submission status: Wrong Answer

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

head = vlist[::2]
foll = vlist[1::2]

import collections
ch = collections.Counter(head).most_common()
cf = collections.Counter(foll).most_common()

h_ = ch[0]
f_ = cf[0]

if h_[0] == f_[0]:
    if h_[1] > f_[1]:
        if len(cf) != 1:
            f_ = cf[1]
        else:
            f_ = (-1.1, 0)
    else:
        if len(ch) != 1:
            h_ = ch[1]
        else:
            h_ = (-1.1, 0)


count = 0
for i in range(len(vlist)):
    if i % 2 == 0 and vlist[i] != h_[0]:
        count += 1
    if i % 2 == 1 and vlist[i] != f_[0]:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

a_nums = [v[i] for i in range(0, len(v), 2)]
a_count = Counter(a_nums)
b_nums = [v[i] for i in range(1, len(v), 2)]
b_count = Counter(b_nums)

max_hit = 0
a = None
b = None
for a_val, a_hit in a_count.most_common():
    if max_hit > a_hit:
        break
    for b_val, b_hit in b_count.most_common():
        if max_hit > b_hit:
            break
        if a_val == b_val:
            continue
        if a_hit + b_hit > max_hit:
            max_hit = a_hit + b_hit
            a = a_val
            b = b_val

print(len(v) - max_hit)

Submission status: Wrong Answer

Solution code:
n=int(input())
N=list(map(int,input().split()))
even=[]
odd=[]
for i in range(len(N)):
    if i%2==0:
        even.append(N[i])
    if i%2==1:
        odd.append(N[i])
import collections
c = collections.Counter(even)
x=c.most_common()[0][0]
o=even.count(x)
d= collections.Counter(odd)
y=d.most_common()[0][0]
p=odd.count(y)
s=len(even)-even.count(x)
t=len(odd)-odd.count(y)
if x!=y and o==len(even) and p==len(odd):
    print(0)
elif x!=y:
    print(s+t)
elif x==y and o==len(even) and p==len(odd):
    print(n/2)
else:
    if o>p:
        y=d.most_common()[1][0]
        s=len(even)-even.count(x)
        t=len(odd)-odd.count(y)
        print(s+t)
    else:
        x=c.most_common()[1][0]
        s=len(even)-even.count(x)
        t=len(odd)-odd.count(y)
        print(s+t)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
if len(set(a)) == 1:
    print(n//2)
    exit()
for i in range(2,n):
    if a[i] != a[0] and a[i] != a[1] :
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

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

array_0 = collections.Counter(array[::2]).most_common()
array_1 = collections.Counter(array[1::2]).most_common()

array_0_v = array_0[0][0]
array_1_v = array_1[0][0]

if array_0_v == array_1_v:
    if len(array_0) == 1:
        print(n / 2)
        exit()
    elif array_0[0][1] > array_1[0][1]:
        array_1_v = array_1[1][0]
    else:
        array_0_v = array_0[1][0]

count = 0
for i in range(n // 2):
    count += array[i * 2] != array_0_v
    count += array[i * 2 + 1] != array_1_v

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
li = len(set(v))
if li == 1:
    print(2)
elif li == 2:
    print(0)
else:
    print(li-2)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

    ans = 0
    vc = Counter(v)
    vc0 = Counter(v[::2])
    vc1 = Counter(v[1::2])

    if vc.most_common(1)[0][1] > len(v)//2:
        if len(set(v[::2])) > len(set(v[1::2])):
            ans += len((v[::2])) - vc0.most_common(2)[1][1]
            ans += len((v[1::2])) - vc1.most_common(1)[0][1]
        else:
            ans += len((v[::2])) - vc0.most_common(1)[0][1]
            ans += len((v[1::2])) - vc1.most_common(2)[1][1]

    else:
        ans += len((v[::2])) - vc0.most_common(1)[0][1]
        ans += len((v[1::2])) - vc1.most_common(1)[0][1]

    print(ans)

if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:
import collections

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

v1 = [v[i] for i in range(0,n,2)]
v2 = [v[i] for i in range(1,n,2)]

count1 = collections.Counter(v1)
count2 = collections.Counter(v2)

if len(count1) == 1 and len(count2) == 1:
    if v1 == v2:
        print(len(v1))
    else:
        print(0)

else:
    res = 0
    ct1 = list(count1.keys())
    ct2 = list(count2.keys())

    for i in v1:
        if i != ct1[0]:
            res = res + 1
    
    for i in v2:
        if i != ct2[0]:
            res = res + 1
    
    print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
count=0
v=[]
v=[int(i) for i in input().split()]
for i in range(n-2):
    if v[i]==v[i+2]:
        pass
    else:
        count+=1
for i in range(n-1):
    if v[i]==v[i+1]:
        if n%2==0:
            count=int(n/2)
        else:
            count=int((n-1)/2)
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def solve(V):
    odd = Counter()
    even = Counter()
    for i, c in enumerate(V):
        if i % 2 == 0:
            even.update([c])
        else:
            odd.update([c])
    even_maxs = even.most_common(2)
    odd_maxs = odd.most_common(2)
    if len(odd_maxs) > 1:
        odd_max, odd_2nd_max = odd_maxs[0], odd_maxs[1]
    else:
        odd_max, odd_2nd_max = odd_maxs[0], None

    if len(even_maxs) > 1:
        even_max, even_2nd_max = even_maxs[0], even_maxs[1]
    else:
        even_max, even_2nd_max = even_maxs[0], None

    ans = 0
    if odd_max[0] != even_max[0]:
        odd_max = odd_max[0]
        even_max = even_max[0]
    elif odd_2nd_max != None and even_2nd_max == None:
        if even_max[0] != odd_2nd_max[0]:
            even_max = even_max[0]
            odd_max = odd_2nd_max[0]
        else:
            even_max = even_max[0]
            odd_max = odd_2nd_max[0] + odd_2nd_max[0]
    elif odd_2nd_max == None and even_2nd_max != None:

        if odd_max[0] != even_2nd_max[0]:
            odd_max = odd_max[0]
            even_max = even_2nd_max[0]
        else:
            odd_max = odd_max[0]
            even_max = even_2nd_max[0] + even_2nd_max[0]
    elif odd_2nd_max == None and even_2nd_max == None:
        odd_max = odd_max[0]
        even_max = even_max[0] + even_max[0]
    elif odd_2nd_max != None and even_2nd_max != None:
        if odd_2nd_max[0] == even_2nd_max[0]:
            if odd_max[1] >= even_max[1]:
                odd_max = odd_max[0]
                even_max = even_2nd_max[0]
            else:
                odd_max = odd_2nd_max[0]
                even_max = even_max[0]

    for key, count in even.items():
        if key != even_max:
            ans += count
    for key, count in odd.items():
        if key != odd_max:
            ans += count
    return ans


if __name__ == "__main__":
    n = int(input())
    l = input()
    print(solve(l.split(" ")))

Submission status: Wrong Answer

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

a = set()
b = set()

for i in range(n):
    if i % 2 == 1:
        a.add(v[i])
for j in range(n):
    if j % 2 == 0:
        b.add(v[j])

if n == 2:
    print(0)
elif (len(a) == 1) and (len(b) == 1) and (a == b):
    print(n//2)
elif (len(a) == 1) and (len(b) == 1):
    print(0)
else:
    print(len(a) + len(b) -2)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
v = [int(i) for i in input().split()]
odd = collections.Counter(v[1::2])
even = collections.Counter(v[0::2])
# print(odd)

max_odd = max(odd, key=odd.get)
# print(max_odd)
max_even = max(even, key=even.get)
# print(max_even)

if max_odd == max_even:
    max_odd_v = odd[max_odd]
    max_even_v = even[max_even]
    if max_odd_v < max_even_v:
        del(odd[max_odd])
        try:
            max_odd = max(odd, key=odd.get)
            max_odd_v = odd[max_odd]
        except:
            max_odd_v = 0
    else:
        del(even[max_even])
        try:
            max_even = max(even, key=even.get)
            max_even_v = even[max_even]
        except:
            max_even_v = 0
else:
    max_odd_v = odd[max_odd]
    max_even_v = even[max_even]

num_change_odd = int(n / 2) - max_odd_v
num_change_even = int(n / 2) - max_even_v
print(num_change_odd + num_change_even)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
vs = [int(i) for i in input().split()]
evens = []
odds = []
for i,num in enumerate(vs):
    if i % 2 == 0:
        evens.append(num)
    elif i % 2 == 1:
        odds.append(num)

def plana():
    if (len(set(vs)) == 2) and (len(set(evens)) == 1) and (len(set(odds)) == 1):
        return 0
    elif (len(set(vs)) == 1):
        return len(evens)
    ec = collections.Counter(evens)
    oc = collections.Counter(odds)

    count = 0
    count += (len(evens) - ec.most_common()[0][1])
    count += (len(odds) - oc.most_common()[0][1])
    return count

# if len(set(vs)) == 1:
#     print(int(len(vs)/2))
# elif (len(set(evens)) == 1) and (len(set(odds)) == 1):
#     print(0)
# else:
print(int(len(odds)))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

a_nums = [v[i] for i in range(0, len(v), 2)]
a_count = Counter(a_nums)
b_nums = [v[i] for i in range(1, len(v), 2)]
b_count = Counter(b_nums)

max_hit = 0
a = None
b = None
for a_val, a_hit in a_count.most_common():
    if max_hit > a_hit:
        break
    for b_val, b_hit in b_count.most_common():
        if a_val == b_val:
            continue
        if a_hit + b_hit > max_hit:
            max_hit = a_hit + b_hit
            a = a_val
            b = b_val
        else:
            break
print(len(v) - max_hit)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(map(int, input().split()))
vo = [v[i] for i in range(n) if i%2 == 0]
ve = [v[i] for i in range(n) if i%2 == 1]
vo_dict = collections.Counter(vo)
ve_dict = collections.Counter(ve)
if len(vo_dict) == len(ve_dict) and len(vo_dict) == 1:
    ans = n//2
else:
    ans = n - vo_dict.most_common()[0][1] - ve_dict.most_common()[0][1]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = list(map(int,input().split()))
A = []
B = []
Q = [0,0]
R = [0,0]
S = [0,0]
T = [0,0]
J = 1
K = 1
for i in range(n):
  if (i%2 == 0):
    A.append(L[i])
  else:
    B.append(L[i])
A.sort()
B.sort()
A.append(-1)
B.append(-1)
for j in range(1,len(A)):
  if (A[j-1] == A[j]):
    J += 1
  else:
    if (J > Q[0]):
      del Q[0]
      Q.insert(0,J)
      del R[0]
      R.insert(0,A[j-1])
      j += J
      J = 1
    elif (Q[0] >= J >= Q[1]):
      del Q[1]
      Q.append(J)
      del R[1]
      R.append(A[j-1])
      j += J
      J = 1
    else:
      j += J
      J = 1
for k in range(1,len(B)):
  if (B[k-1] == B[k]):
    K += 1
  else:
    if (K > S[0]):
      del S[0]
      S.insert(0,K)
      del T[0]
      T.insert(0,B[k-1])
      k += K
      K = 1
    elif (S[0] >= J >= S[1]):
      del S[1]
      S.append(K)
      del T[1]
      T.append(B[k-1])
      k += K
      K = 1
    else:
      k += K
      K = 1
if (R[0] != T[0]):
  print(n-Q[0]-S[0])
else:
  if (Q[0] >= S[0]):
    print(n-Q[0]-S[1])
  else:
    print(n-S[0]-Q[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = list(map(int, input().split()))
# １文字目 偶数の値が決まる
a = nums[0]
# 奇数格納用
b = 0
# 必要書き換え数
ct = 0
for i in range(0, len(nums)):
    # 奇数の値を取得
    if nums[i] % 2 != 0:
        if a != nums[i]:
            b = nums[i]
            break

for i in range(0, len(nums)):
    if i % 2 == 0:
        if nums[i] != a:
            ct += 1
    elif i != 1:
        if nums[i] != b:
            ct += 1

print(ct)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
l = list(range(n))
odd = [v[i] for i in l if i%2 == 0]
even = [v[i] for i in l if i%2 == 1]

oddm = sorted({i: odd.count(i) for i in set(odd)}.items(),key=lambda x: x[1], reverse=True)
evenm = sorted({i: even.count(i) for i in set(even)}.items(),key=lambda x: x[1], reverse=True)
numodd = oddm[0][1]
numeven = evenm[0][1]
if oddm[0][0] == evenm[0][0]:
    a = len(odd)
else:
    a = (n/2)-numodd+(n/2)-numeven
print(int(a))

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
vs = [int(i) for i in input().split()]
evens = []
odds = []
for i,num in enumerate(vs):
    if i % 2 == 0:
        evens.append(num)
    elif i % 2 == 1:
        odds.append(num)

def plana():
    if (len(set(vs)) == 2) and (len(set(evens)) == 1) and (len(set(odds)) == 1):
        return 0
    elif (len(set(vs)) == 1):
        return len(evens)
    ec = collections.Counter(evens)
    oc = collections.Counter(odds)

    count = 0
    count += (len(evens) - ec.most_common()[0][1])
    count += (len(odds) - oc.most_common()[0][1])
    return count

# if len(set(vs)) == 1:
#     print(int(len(vs)/2))
# elif (len(set(evens)) == 1) and (len(set(odds)) == 1):
#     print(0)
# else:
print(0)

Submission status: Wrong Answer

Solution code:
import collections
#import numpy as np
#print(np.diff(suuretsu))

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

odd = [suuretsu[i] for i in range(n) if i % 2 != 0]
even = [suuretsu[i] for i in range(n) if i % 2 == 0]
ans = 0

#print(odd)
#print(even)

count_dict_odd = collections.Counter(odd)
count_dict_even = collections.Counter(even)

if count_dict_odd.most_common(1)[0][0] == count_dict_even.most_common(1)[0][0]:
  
  if count_dict_odd.most_common(1)[0][1] > count_dict_even.most_common(1)[0][1]:
    ans = n-count_dict_odd.most_common(1)[0][1]-count_dict_even.most_common(2)[0][1]
  elif count_dict_odd.most_common(1)[0][1] == count_dict_even.most_common(1)[0][1]:
    if len(count_dict_odd.most_common(n))== 1 and len(count_dict_even.most_common(n)) == 1:
      ans = int(n/2)
    elif len(count_dict_odd.most_common(n)) > len(count_dict_odd.most_common(n)):
      ans = n-count_dict_odd.most_common(2)[0][1]-count_dict_even.most_common(1)[0][1]
    elif len(count_dict_odd.most_common(n)) > len(count_dict_odd.most_common(n)):
      ans = n-count_dict_odd.most_common(1)[0][1]-count_dict_even.most_common(2)[0][1]
  else:
    ans = n-count_dict_odd.most_common(2)[0][1]-count_dict_even.most_common(1)[0][1]
else:
    ans = n-count_dict_odd.most_common(1)[0][1]-count_dict_even.most_common(1)[0][1]

    
print(ans)
#print(len(count_dict_even.most_common(2)))
#print(len(count_dict_even.most_common(n)))

Submission status: Wrong Answer

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

for i in range(0,len(v)-1):
    par = v[i:len(v)]
    c1 = par[0]
    c2 = par[1]
    if c1 == c2:
        continue
    t_cnt = 0

    for j in range(2,len(par)):
        if j % 2 == 0:
            tar = c1
        else:
            tar = c2

        if tar == par[j]:
            t_cnt += 1
        else:
            break
    if t_cnt > cnt:
        cnt = t_cnt

print(n - (cnt+2))

Submission status: Wrong Answer

Solution code:
import collections
n=input()
N=list(map(int,input().split(" ")))
list_odd=N[::2]
list_even=N[1::2]
c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
most_odd=c_odd.most_common()[0][1]
most_even=c_even.most_common()[0][1]
if(c_odd.most_common()[0][0]==c_even.most_common()[0][0] and len(list_even)==most_even and len(list_odd)==most_odd):
    print(most_odd)
else:
    print(len(list_even)+len(list_odd)-most_even-most_odd)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
if len(set(a)) == 1:
    print(n//2)
    exit()
for i in range(2,n):
    if a[i] != a[0] or a[i] != a[1] :
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
N=list(map(int,input().split()))
even=[]
odd=[]
for i in range(len(N)):
    if i%2==0:
        even.append(N[i])
    if i%2==1:
        odd.append(N[i])
import collections
c = collections.Counter(even)
x=c.most_common()[0][0]
o=even.count(x)
d= collections.Counter(odd)
y=d.most_common()[0][0]
p=odd.count(y)
s=len(even)-even.count(x)
t=len(odd)-odd.count(y)
if x!=y and o==len(even) and p==len(odd):
    print(0)
elif x!=y:
    print(s+t)
elif x==y and o==len(even) and p==len(odd):
    print(n/2)
elif x==y and (o!=len(even) or p!=len(odd)):
    if o>p:
        y=d.most_common()[1][0]
        s=len(even)-even.count(x)
        t=len(odd)-odd.count(y)
        print(s+t)
    else:
        x=c.most_common()[1][0]
        s=len(even)-even.count(x)
        t=len(odd)-odd.count(y)
        print(s+t)

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
li = input().split(" ")
el = []
ol = []
for i in range(n):
    if i % 2 == 0:
        el.append(int(li[i]))
    else:
        ol.append(int(li[i]))
n_el = len(list(set(el)))
n_ol = len(list(set(ol)))
if n_el == 1 and n_ol == 1 and el[0] != ol[0]:
    print(0)
elif n_el == 1 and n_ol == 1 and el[0] == ol[0]:
    print(len(ol))
else:
    els = {}
    ols = {}
    for e in el:
        if(str(e) in els):
            els[str(e)] += 1
        else:
            els[str(e)] = 1
    for o in ol:
        if(str(o) in ols):
            ols[str(o)] += 1
        else:
            ols[str(o)] = 1
    # print(els)
    # print(ols)

    elv = list(els.values())
    olv = list(ols.values())
    elk = sorted(list(els.keys()))
    olk = sorted(list(ols.keys()))
    # print(elv)
    # print(olv)

    is_same_key = 1
    for i in range(len(elk)):
        if elk[i] != olk[i]:
            is_same_key = 0
            break
    ans = 0
    if(not(is_same_key)):
        ans += sum(elv) - max(elv)
        ans += sum(olv) - max(olv)
        print(ans)
    else:
        tempe = []
        tempo = []
        for i in elk:
            tempe.append(n//2 - els[i])
            tempo.append(n//2 - ols[i])
        # print(tempe)
        # print(tempo)
        min_e = min(tempe)
        min_o = min(tempo)
        ind_min_e = tempe.index(min_e)
        ind_min_o = tempo.index(min_o)
        if ind_min_o != ind_min_e:
            print(min_e + min_o)
        else:
            ans_temp = 0
            tempo_temp = copy.deepcopy(tempo)
            tempe_temp = copy.deepcopy(tempe)
            tempo_temp[ind_min_o] = 999999999
            ans_temp = min_e + min(tempo_temp)
            tempe_temp[ind_min_e] = 999999999
            if min_o + min(tempe_temp) < ans_temp:
                ans_temp = min_o + min(tempe_temp)
            print(ans_temp)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
v_odd = list()
v_even = list()
for i in range(int(n/2)):
    v_odd.append(v[2*i])
for i in range(int(n/2)):
    v_even.append(v[2*i+1])
max_odd=dict()
max_even=dict()
x_odd=0
x_even=0
while len(v_odd) > 0:
    a = v_odd.count(v_odd[0])
    if a == n//2:
        x_odd = 1
    max_odd[v_odd[0]] = a
    v_odd=[i for i in v_odd if i != v_odd[0]]
v_odd = sorted(max_odd.items(),key=lambda x:x[1],reverse=True)
while len(v_even) > 0:
    b = v_even.count(v_even[0])
    if b == n//2:
        x_even = 1
    max_even[v_even[0]] = b
    v_even=[i for i in v_even if i != v_even[0]]
v_even = sorted(max_even.items(),key=lambda x:x[1],reverse=True)
ans = 0
if v_odd[0][0]==v_even[0][0]:
    if x_odd == 1:
        if x_even==1:
            ans = n//2
        else:
            ans = n-v_even[1][1]
    else:
        if x_even == 1:
            ans = n-v_odd[1][1]
        else:
            ans =n-max(v_odd[0][1]-v_even[1][1],v_even[0][1]-v_odd[1][1])
else:
    ans = n - v_odd[0][1] - v_even[0][1]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = list(map(int, input().split()))
ma = {}
ma[lst[0]] = 1
mb = {}
mb[lst[1]] = 1
for i in range(2, n, 2):
    lst[i] in ma
    if lst[i] in ma:
        ma[lst[i]] += 1
    else:
        ma[lst[i]] = 1
    lst[i+1] in mb
    if lst[i+1] in mb:
        mb[lst[i+1]] += 1
    else:
        mb[lst[i+1]] = 1
d = sum(ma.values()) - max(ma.values()) + sum(mb.values()) - max(mb.values())
if d == 0 and lst[0] == lst[1]:
    print(sum(ma.values()))
else:
    print(d)

Submission status: Wrong Answer

Solution code:
import collections
 
n = int(input())
vs = [int(i) for i in input().split()]
evens = []
odds = []
for i,num in enumerate(vs):
    if i % 2 == 0:
        evens.append(num)
    elif i % 2 == 1:
        odds.append(num)
 
def plana():
    ec = collections.Counter(evens)
    oc = collections.Counter(odds)
 
    count = 0
    count += (len(evens) - ec.most_common()[0][1])
    count += (len(odds) - oc.most_common()[0][1])
    return count

print(int(plana()))

Submission status: Wrong Answer

Solution code:
import collections as cl

n=int(input())
vlist=list(input().split())

vg=vlist[0::2]
vk=vlist[1::2]

vgcnt=cl.Counter(vg)
vkcnt=cl.Counter(vk)

vgmax=max(vgcnt)
vkmax=max(vkcnt)

if vgmax==vkmax:
    if vgcnt[vgmax]<vkcnt[vkmax]:
        vgcnt.pop(vgmax)
        if len(vgcnt)>0:
            vgmax=max(vgcnt)
        else:
            vgmax='a'
    else:
        vkcnt.pop(vkmax)
        if len(vkcnt)>0:
            vkmax=max(vkcnt)
        else:
            vkmax='a'

ans=0
for i in range(len(vg)):
    if vg[i]!=vgmax:
        ans+=1
for i in range(len(vk)):
    if vk[i]!=vkmax:
        ans+=1

print(ans)

Submission status: Wrong Answer

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

a = [ v[i] for i in range(0,n,2)]
b = [ v[i] for i in range(1,n,2)]

A = [0] * 100010
B = [0] * 100010

for i in range(int(n/2)):
    A[a[i]] += 1
    B[b[i]] += 1

sorted(A)
sorted(B)

if A.index(max(A)) == B.index(max(B)) and max(A) != max(B):
    if max(A) > max (B):
        BB = sorted(B)
        print(len(b) - BB[-2] + len(a) - max(A))
    else:
        AA = sorted(A)
        print(len(a) - AA[-2] + len(b) - max(B))
else:
    print(n - max(A) - max(B))

Submission status: Wrong Answer

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

index = 0
g_inputs = []
k_inputs = []

for i in input().split():
    if index % 2 == 0:
        g_inputs.append(int(i))
        index += 1
    else:
        k_inputs.append(int(i))
        index += 1

g = Counter(g_inputs)
k = Counter(k_inputs)

g_max = max([(v,k) for k,v in g.items()])[1] 
k_max = max([(v,k) for k,v in k.items()])[1]

if g_max == k_max:
    if g[g_max] < k[k_max]:
        del g[g_max]
        g_max = max([(v,k) for k,v in g.items()])[1]
        print(N - g[g_max] - k[k_max])
    if g[g_max] > k[k_max]:
        del k[k_max]
        k_max = max([(v,k) for k,v in k.items()])[1]
        print(N - g[g_max] - k[k_max])
    else:
        print(n)
else:
    print(N - g[g_max] - k[k_max])