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:
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
v3 = Counter(v1)
v4 = Counter(v2)
a = v3.most_common()[0][0]
b = v4.most_common()[0][0]
c = v3.most_common()[0][1]
d = v4.most_common()[0][1]
if a != b:
 print(len(v1)-c+len(v2)-d)
else:
 if len(list(set(v1))) == 1 and len(list(set(v2))) == 1:
  print(min(len(v1),len(v2)))

 else:
  if c <= d:
   print(len(v1)+len(v2)-d-v3.most_common()[1][1])
  else:
   print(len(v1)+len(v2)-c-v4.most_common()[1][1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
v3 = Counter(v1)
v4 = Counter(v2)
a = v3.most_common()[0][0]
b = v4.most_common()[0][0]
c = v3.most_common()[0][1]
d = v4.most_common()[0][1]
if a != b:
 print(len(v1)-c+len(v2)-d)
else:
 if len(list(set(v1))) == 1 and len(list(set(v2))) == 1:
  print(min(len(v1),len(v2)))
 elif len(list(set(v1))) == 1:
  print(len(v2)-v4.most_common()[1][1])
 elif len(list(set(v2))) == 1:
  print(len(v1)-v3.most_common()[1][1])
 else:
  if c <= d:
   print(len(v1)+len(v2)-d-v3.most_common()[1][1])
  else:
   print(len(v1)+len(v2)-c-v4.most_common()[1][1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
v3 = Counter(v1)
v4 = Counter(v2)
a = v3.most_common()[0][0]
b = v4.most_common()[0][0]
c = v3.most_common()[0][1]
d = v4.most_common()[0][1]
if a != b:
 print(len(v1)-c+len(v2)-d)
else:
 if len(list(set(v1))) == 1 and len(list(set(v2))) == 1:
  print(min(len(v1),len(v2)))
 elif len(list(set(v1))) == 1:
  print(len(v2)-v4.most_common()[1][1])
 elif len(list(set(v2))) == 1:
  print(len(v1)-v3.most_common()[1][1])
 else:
  print(len(v1)+len(v2)-c-v4.most_common()[1][1]) if c >= d else print(len(v1)+len(v2)-d-v3.most_common()[1][1])

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(input().split())
 
v_odd = []
v_even = []
 
for i in range(int(n)):
  if i % 2 == 1:
  	v_odd.append(v[i])
  else:
    v_even.append(v[i])
  
  
v_odd_counter = collections.Counter(v_odd)
a = v_odd_counter.most_common()[0][1]
 
v_even_counter = collections.Counter(v_even)
b = v_even_counter.most_common()[0][1]
 
if v_odd_counter.most_common()[0][0] == v_even_counter.most_common()[0][0] :
  print(n - a)
else:
  print(n - a - b)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
v3 = Counter(v1)
v4 = Counter(v2)
a = v3.most_common()[0][0]
b = v4.most_common()[0][0]
c = v3.most_common()[0][1]
d = v4.most_common()[0][1]
if a != b:
 print(len(v1)-c+len(v2)-d)
else:
 if len(list(set(v1))) == 1 and len(list(set(v2))) == 1:
  print(min(len(v1),len(v2)))
 elif len(list(set(v1))) == 1:
  print(len(v2)-v4.most_common()[1][1])
 elif len(list(set(v2))) == 1:
  print(len(v1)-v3.most_common()[1][1])
 else:
  e = v3.most_common()[1][1]
  f = v4.most_common()[1][1]
  print(len(v1)+len(v2)-c-f) if c >= d else print(len(v1)+len(v2)-d-e)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(input().split())
 
v_odd = []
v_even = []
 
for i in range(int(n)):
  if i % 2 == 1:
  	v_odd.append(v[i])
  else:
    v_even.append(v[i])
  
  
v_odd_counter = collections.Counter(v_odd)
a = v_odd_counter.most_common()[0][1]
 
v_even_counter = collections.Counter(v_even)
b = v_even_counter.most_common()[0][1]
 
print(n - a - b)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
v = list(input().split())
 
v_odd = []
v_even = []
 
for i in range(int(n)):
  if i % 2 == 1:
  	v_odd.append(i)
  
for i in range(int(n)):
  if i % 2 == 0:
  	v_even.append(i)
  
v_odd_counter = collections.Counter(v_odd)
a = v_odd_counter.most_common()[0][1]
 
v_even_counter = collections.Counter(v_even)
b = v_even_counter.most_common()[0][1]
 
print(n - a - b)

Submission status: Wrong Answer

Solution code:
N=int(input())
n=list(map(int,input().split()))
#Divide it into even and odd
n1=[]
n2=[]
for i in range(N//2):
    n1.append(n[i*2])
    n2.append(n[i*2-1])
#end
#make lile {key,value}
cn1=[]
s=0
while n1!=[]:
    cn1.append([n1.count(n1[0]),n1[0]])
    for j in range(cn1[s][0]):
            n1.remove(cn1[s][1])
    s+=1

cn2=[]
s=0
while n2!=[]:
    cn2.append([n2.count(n2[0]),n2[0]])
    for j in range(cn2[s][0]):
            n2.remove(cn2[s][1])
    s+=1
#end

#sort
cn1.sort(key=lambda x:x[0])
cn1.sort(key=lambda x:x[1])
cn2.sort(key=lambda x:x[0])
cn2.sort(key=lambda x:x[1])
#end

#for example(4,1 1 1 1)
cn1.append([0,0])
cn2.append([0,0])

#answer
ans=0
if cn1[0][1]!=cn2[0][1]:
    for i in range(1,len(cn1)):
        ans+=cn1[i][0]
    for j in range(1,len(cn2)):
        ans+=cn2[i][0]
elif cn1[0][0]-cn1[1][0] > cn2[0][0]-cn2[1][0]:#prefer large disadvantage  
    ans+=cn1[0][0]
    ans+=cn2[1][0]
    for i in range(2,len(cn1)):
        ans+=cn1[i][0]
    for j in range(2,len(cn2)):
        ans+=cn2[i][0]
else:
    ans+=cn1[1][0]
    ans+=cn2[0][0]
    for i in range(2,len(cn1)):
        ans+=cn1[i][0]
    for j in range(2,len(cn2)):
        ans+=cn2[i][0]
print(ans)
#end

Submission status: Wrong Answer

Solution code:
import numpy as np

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

m = int(n / 2)
p = max(v)

evens = np.array([0] * p)
odds = np.array([0] * p)

for i in range(0, m):
    evens[v[2 * i] - 1] += 1
    odds[v[2 * i + 1] - 1] += 1

if len(evens) == 1 and len(odds) == 1:
    if evens.argsort()[-1] == odds.argsort()[-1]:
        print(m)
    else:
        print(0)
elif len(evens) ==1:
    mode_e1 = evens.argsort()[-1]
    mode_o2, mode_o1 = odds.argsort()[-2:]
    if mode_e1 == mode_o1:
        print(m - odds[mode_o2])
    else:
        print(m - odds[mode_o1])
elif len(odds) == 1:
    mode_e2, mode_e1 = evens.argsort()[-2:]
    mode_o1 = odds.argsort()[-1]
    if mode_e1 == mode_o1:
        print(m - evens[mode_e2])
    else:
        print(m - evens[mode_e1])
else:
    mode_e2, mode_e1 = evens.argsort()[-2:]
    mode_o2, mode_o1 = odds.argsort()[-2:]

    if mode_e1 == mode_o1:
        if evens[mode_e1] > odds[mode_o1]:
            print(n - evens[mode_e1] - odds[mode_o2])
        else:
            print(n - evens[mode_e2] - odds[mode_o1])
    else:
        print(n - evens[mode_e1] - odds[mode_o1])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

m = int(n / 2)
p = max(v)

evens = np.array([0] * p)
odds = np.array([0] * p)

for i in range(0, m):
    evens[v[2 * i] - 1] += 1
    odds[v[2 * i + 1] - 1] += 1

if len(evens) == 1 and len(odds) == 1:
    if evens[0] == odds[0]:
        print(m)
    else:
        print(0)
elif len(evens) ==1:
    mode_e1 = evens.argsort()[-1]
    mode_o2, mode_o1 = odds.argsort()[-2:]
    if mode_e1 == mode_o1:
        print(n - evens[mode_e1] - odds[mode_o2])
    else:
        print(n - evens[mode_e1] - odds[mode_o1])
elif len(odds) == 1:
    mode_e2, mode_e1 = evens.argsort()[-2:]
    mode_o1 = odds.argsort()[-1]
    if mode_e1 == mode_o1:
        print(n - evens[mode_e2] - odds[mode_o1])
    else:
        print(n - evens[mode_e1] - odds[mode_o1])
else:
    mode_e2, mode_e1 = evens.argsort()[-2:]
    mode_o2, mode_o1 = odds.argsort()[-2:]

    if mode_e1 == mode_o1:
        if evens[mode_e1] > odds[mode_o1]:
            print(n - evens[mode_e1] - odds[mode_o2])
        else:
            print(n - evens[mode_e2] - odds[mode_o1])
    else:
        print(n - evens[mode_e1] - odds[mode_o1])

Submission status: Wrong Answer

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

m = int(n / 2)
p = max(v)

evens = [0] * p
odds = [0] * p

for i in range(0, m):
    evens[v[2 * i] - 1] += 1
    odds[v[2 * i + 1] - 1] += 1

if v[0] == v[1] and max(evens) == m and max(odds) == m:
    print(m)
else:
    print(n - max(evens) - max(odds))

Submission status: Wrong Answer

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

m = int(n / 2)
p = max(v)

evens = [0] * p
odds = [0] * p

for i in range(0, m):
    evens[v[2 * i] - 1] += 1
    odds[v[2 * i + 1] - 1] += 1

if v[0] == v[1] and max(evens) == m and max(odds) == m:
    print(p + 1)
else:
    print(n - max(evens) - max(odds))

Submission status: Wrong Answer

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

count = 0
even = Counter(V[0::2])
odd = Counter(V[1::2])
even_common0 = even.most_common()[0][0]
odd_common0 = odd.most_common()[0][0]

try:
  even_common1 = even.most_common()[1][0]
  odd_common1 = odd.most_common()[1][0]
except IndexError:
  pass

if even_common0 != odd_common0:
  for i in even:
    if i != even_common0:
      count += 1
  for i in odd:
    if i != odd_common0:
      count += 1
elif even_common0 == odd_common0:
  count += even[even_common0]
elif even[even_common1] >= odd[odd_common1]:
  for i in even:
    if i != even_common0:
      count += 1
  for i in odd:
    if i != odd_common1:
      count += 1
else:
  for i in even:
    if i != even_common1:
      count += 1
  for i in odd:
    if i != odd_common0:
      count += 1

print(count)

Submission status: Wrong Answer

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

count = 0
even = V[0::2]
odd = V[1::2]

for i in range(len(even)//2):
  if even[i] != even[i+1]:
    count += 1
  if odd[i] != odd[i+1]:
    count += 1

if sum(V) == len(V)*V[0]:
  count += len(V)//2


print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2]).most_common(1)[0]
b = Counter(v[1::2]).most_common(1)[0]
print(len(v) - a[1] - b[1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import collections

n = int(input().strip())
vs = [int(s) for s in input().strip().split()]

e = [vs[i*2] for i in range(n//2)]
o = [vs[i*2+1] for i in range(n//2)]

e_counter = collections.Counter(e).most_common()
o_counter = collections.Counter(o).most_common()

e1, e1_count = e_counter[0]
try:
    e2, e2_count = e_counter[1]
except IndexError:
    e2_count = 0

o1, o1_count = o_counter[0]
try:
    o2, o2_count = o_counter[1]
except IndexError:
    o2_count = 0

if e1 != o1:
    keep_num_count = e1_count + o1_count
else:
    if e1_count > o1_count:
        keep_num_count = e1_count + o2_count
    else:
        keep_num_count = e2_count + o1_count

print(n - keep_num_count)

Submission status: Wrong Answer

Solution code:
_ = input()
seq = list(map(int,input().split()))

seq1 = seq[::2]
seq2 = seq[1::2]
 
if len(set(seq)) == 1:
    print(len(seq2))
    exit()
    
def count_dictonary(seq):
    ret_dict={}
    for item in seq:
        if item not in ret_dict:
            ret_dict[item] = 1
        else:
            ret_dict[item]+=1
    return ret_dict

def modes(counting_dict):
    #(11,2),(2,1),(3,3)
    ret={}
    for item in counting_dict.items():
        no, count = item
        if counting_dict[no] in ret:
            ret[count].append(no)
        else:
            ret[count]=[no]
            
    return ret


counting1 = count_dictonary(seq1)
counting2 = count_dictonary(seq2)

modes1 = sorted(modes(counting1).items(),reverse=True)
modes2 = sorted(modes(counting2).items(),reverse=True)

min_change=len(seq)
if modes1[0][1] != modes2[0][1]:
    min_change = (len(seq1) - modes1[0][0]) + (len(seq2) - modes2[0][0])
else:
    m01=len(seq)
    m10=len(seq)
    if len(modes2) !=1:
        m01 =  (len(seq1) - modes1[0][0]) + (len(seq2) - modes2[1][0])
    if len(modes1) !=1:
        m10 =  (len(seq1) - modes1[1][0]) + (len(seq2) - modes2[0][0])
    min_change = min(m01,m10)
    
print(min_change)

Submission status: Wrong Answer

Solution code:
_ = input()
seq = list(map(int,input().split()))
 
seq1 = seq[::2]
seq2 = seq[1::2]
 
if len(set(seq)) == 1:
    print(min(len(seq1),len(seq2)))
    exit()
    
def count_dictonary(seq):
    ret_dict={}
    for item in seq:
        if item not in ret_dict:
            ret_dict[item] = 1
        else:
            ret_dict[item]+=1
    return ret_dict
 
def max2seq(seq):
    ret=[]
    max=seq[0][1]
    while True:
        if(len(seq)==0):
        	break
        tmp = seq.pop(0)
        if(tmp[1] == max):
            ret.append(tmp)
        else:
            if len(ret) == 1:
                ret.append(tmp)
            break
    return ret

seq_dict1 = max2seq(sorted(count_dictonary(seq1).items(),key=lambda x:x[1],reverse=True))
seq_dict2 = max2seq(sorted(count_dictonary(seq2).items(),key=lambda x:x[1],reverse=True))



min_change=len(seq)
for i1, count1 in seq_dict1:
    for i2, count2 in seq_dict2:
      ch1 = len(seq1) - count1
      ch2 = len(seq2) - count2
      #print(i1,i2,ch1,ch2,ch1+ch2)
      change_ = ch1+ch2
      if(min_change > ch1+ch2):
        min_change = ch1+ch2
            
print(min_change)

Submission status: Wrong Answer

Solution code:
_ = input()
seq = list(map(int,input().split()))
 
seq1 = seq[::2]
seq2 = seq[1::2]
 
if len(set(seq)) == 1:
    print(min(len(seq1),len(seq2)))
    exit()
    
def count_dictonary(seq):
    ret_dict={}
    for item in seq:
        if item not in ret_dict:
            ret_dict[item] = 1
        else:
            ret_dict[item]+=1
    return ret_dict
 
seq_dict1 = sorted(count_dictonary(seq1).items(),key=lambda x:x[1],reverse=True)
seq_dict2 = sorted(count_dictonary(seq2).items(),key=lambda x:x[1],reverse=True)
 
min_change=len(seq)
for i1, count1 in seq_dict1[:2]:
    for i2, count2 in seq_dict2[:2]:
      ch1 = len(seq1) - count1
      ch2 = len(seq2) - count2
      #print(i1,i2,ch1,ch2,ch1+ch2)
      change_ = ch1+ch2
      if(min_change > ch1+ch2):
        min_change = ch1+ch2
            
print(min_change)

Submission status: Wrong Answer

Solution code:
_ = input()
seq = list(map(int,input().split()))
 
seq1 = seq[::2]
seq2 = seq[1::2]
 
if len(set(seq)) == 1:
    print(min(len(seq1),len(seq2)))
    exit()
    
def count_dictonary(seq):
    ret_dict={}
    for item in seq:
        if item not in ret_dict:
            ret_dict[item] = 1
        else:
            ret_dict[item]+=1
    return ret_dict
 
seq_dict1 = sorted(count_dictonary(seq1).items(),key=lambda x:[1],reverse=True)
seq_dict2 = sorted(count_dictonary(seq2).items(),key=lambda x:[1],reverse=True)
 
min_change=len(seq)
for i1, count1 in seq_dict1[:2]:
    for i2, count2 in seq_dict2[:2]:
      ch1 = len(seq1) - count1
      ch2 = len(seq2) - count2
      #print(i1,i2,ch1,ch2,ch1+ch2)
      change_ = ch1+ch2
      if(min_change > ch1+ch2):
        min_change = ch1+ch2
            
print(min_change)

Submission status: Wrong Answer

Solution code:
_ = input()
seq = list(map(int,input().split()))
 
seq1 = seq[::2]
seq2 = seq[1::2]
 
if len(set(seq)) == 1:
    print(min(len(seq1),len(seq2)))
    exit()
    
def count_dictonary(seq):
    ret_dict={}
    for item in seq:
        if item not in ret_dict:
            ret_dict[item] = 1
        else:
            ret_dict[item]+=1
    return ret_dict
 
seq_dict1 = count_dictonary(seq1)
seq_dict2 = count_dictonary(seq2)

print(0)

Submission status: Wrong Answer

Solution code:
_ = input()
seq = list(map(int,input().split()))
 
seq1 = seq[::2]
seq2 = seq[1::2]
 
if len(set(seq)) == 1:
    print(min(len(seq1),len(seq2)))
    exit()
    
def count_dictonary(seq):
    ret_dict={}
    for item in seq:
        if item not in ret_dict:
            ret_dict[item] = 1
        else:
            ret_dict[item]+=1
    return ret_dict
print(1)

Submission status: Wrong Answer

Solution code:
import collections

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

V_e = V[1::2]
V_o = V[::2]

dic_e = collections.Counter(V_e)
dic_o = collections.Counter(V_o)

e12 = []
for k,v in dic_e.items():
    e12.append((k,v))
o12 = []
for k,v in dic_o.items():
    o12.append((k,v))


if len(e12) == 1 and len(o12) == 1 and e12 != o12:
    ans = 0
elif len(e12) == 1 and len(o12) == 1 and e12 == o12:
    ans = n//2
elif len(e12) == 1:
    if e12[0][0] != o12[0][0]:
        ans = (n//2 - o12[0][1])
    else:
        ans = (n//2 - o12[1][1])
elif len(o12) == 1:
    if o12[0][0] != e12[0][0]:
        ans = (n//2 - e12[0][1])
    else:
        ans = (n//2 - e12[1][1])
elif e12[0][0] != o12[0][0]:
    ans = (n//2 - e12[0][1]) + (n//2 - o12[0][1])
else:
    if e12[0][1] > o12[0][1]:
        ans = (n//2) - e12[0][1]
        if e12[0][0] == o12[0][0]:
            ans += (n//2) - o12[1][1]
        else:
            ans += (n//2) - o12[0][1]
    elif e12[0][1] < o12[0][1]:
        ans = (n//2) - o12[0][1]
        if e12[0][0] == o12[0][0]:
            ans += (n//2) - e12[1][1]
        else:
            ans += (n//2) - e12[0][1]
    else:
        if e12[1][1] >= o12[1][1]:
            ans = (n//2 - e12[1][1]) + (n//2 - o12[0][1])
        elif e12[1][1] < o12[1][1]:
            ans = (n//2 - e12[0][1]) + (n//2 - o12[1][1])

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

V_e = V[1::2]
V_o = V[::2]

dic_e = collections.Counter(V_e)
dic_o = collections.Counter(V_o)

e12 = []
for k,v in dic_e.items():
    e12.append((k,v))
o12 = []
for k,v in dic_o.items():
    o12.append((k,v))

if e12 == o12:
    ans = n//2
elif e12[0][0] != o12[0][0]:
    ans = (n//2 - e12[0][1]) + (n//2 - o12[0][1])
else:
    if e12[0][1] > o12[0][1]:
        ans = (n//2) - e12[0][1]
        if e12[0][0] == o12[0][0]:
            ans += (n//2) - o12[1][1]
        else:
            ans += (n//2) - o12[0][1]
    elif e12[0][1] < o12[0][1]:
        ans = (n//2) - o12[0][1]
        if e12[0][0] == o12[0][0]:
            ans += (n//2) - e12[1][1]
        else:
            ans += (n//2) - e12[0][1]
    else:
        if e12[1][1] >= o12[1][1]:
            ans = (n//2 - e12[1][1]) + (n//2 - o12[0][1])
        elif e12[1][1] < o12[1][1]:
            ans = (n//2 - e12[0][1]) + (n//2 - o12[1][1])

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

V_e = V[1::2]
V_o = V[::2]

dic_e = collections.Counter(V_e)
dic_o = collections.Counter(V_o)

e12 = []
for k,v in dic_e.items():
    e12.append((k,v))
o12 = []
for k,v in dic_o.items():
    o12.append((k,v))

if len(e12) == 1 and len(o12):
    if e12[0][0] != o12[0][0]:
        ans = 0
    else:
        ans = n//2
else:
    if e12[0][1] >= o12[0][1]:
        ans = (n//2) - e12[0][1]
        if e12[0][0] == o12[0][0]:
            ans += (n//2) - o12[1][1]
        else:
            ans += (n//2) - o12[0][1]
    else:
        ans = (n//2) - o12[0][1]
        if e12[0][0] == o12[0][0]:
            ans += (n//2) - e12[1][1]
        else:
            ans += (n//2) - e12[0][1]

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
import sys
_=input()
l=list(map(int,input().split()))
a=l[::2]
b=l[1::2]
c1 = collections.Counter(a)
c2 = collections.Counter(b)
if list(c1.keys())[0] == list(c2.keys())[0]:
    print(int(len(l)/2))
    sys.exit()
print(sum(list(c1.values())[1:])+sum(list(c2.values())[1:]))

Submission status: Wrong Answer

Solution code:
import collections
_=input()
l=list(map(int,input().split()))
a=l[::2]
b=l[1::2]
c1 = collections.Counter(a)
c2 = collections.Counter(b)
print(sum(list(c1.values())[1:])+sum(list(c2.values())[1:]))

Submission status: Wrong Answer

Solution code:
import collections
_=input()
l=list(map(int,input().split()))
c = collections.Counter(l)
print(sum(list(c.values())[3:]))

Submission status: Wrong Answer

Solution code:
_=input()
l=list(map(int,input().split()))
a=set(l[::2])
b=set(l[1::2])
print(len(a)+len(b)-2)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import collections


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

    va = []
    vb = []
    for i in range(0, n, 2):
        va.append(v[i])
        vb.append(v[i + 1])

    if va == vb:
        print(len(va))
        return

    c1mc = collections.Counter(va).most_common()
    c2mc = collections.Counter(vb).most_common()

    count1 = 0
    count2 = 0
    if c1mc[0][0] != c2mc[0][0]:
        print(n - c1mc[0][1] - c2mc[0][1])
        return

    else:
        a = n - c1mc[1][1] - c2mc[0][1]
        b = n - c1mc[0][1] - c2mc[1][1]

        if a < b:
            print(a)
        else:
            print(b)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import collections


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

    va = []
    vb = []
    for i in range(0, n, 2):
        va.append(v[i])
        vb.append(v[i + 1])

    if va == vb:
        print(len(va))
        return

    c1mc = collections.Counter(va).most_common()
    c2mc = collections.Counter(vb).most_common()

    count1 = 0
    count2 = 0
    if c1mc[0][0] != c2mc[0][0]:
        # 最頻値が同じではないとき
        for i in range(1, len(c1mc)):
            count1 += c1mc[i][1]
        for i in range(1, len(c2mc)):
            count2 += c2mc[i][1]

        print(count1 + count2)
        return

    else:
        count1 = 0
        count2 = 0
        for i in range(len(c1mc)):
            if i == 1:
                continue
            count1 += c1mc[i][1]
        for i in range(1, len(c2mc)):
            count2 += c2mc[i][1]
        tmp1 = count1 + count2

        count1 = 0
        count2 = 0
        for i in range(1, len(c1mc)):
            count1 += c1mc[i][1]
        for i in range(len(c2mc)):
            if i == 1:
                continue
            count2 += c2mc[i][1]
        tmp2 = count1 + count2

        if tmp1 < tmp2:
            print(tmp1)
        else:
            print(tmp2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import collections


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

    va = []
    vb = []
    for i in range(0, n, 2):
        va.append(v[i])
        vb.append(v[i + 1])

    if va == vb:
        print(len(va))
        return

    c1mc = collections.Counter(va).most_common()
    c2mc = collections.Counter(vb).most_common()

    count1 = 0
    count2 = 0
    if c1mc[0][0] != c2mc[0][0]:
        for i in range(1, len(c1mc)):
            count1 += c1mc[i][1]
        for i in range(1, len(c2mc)):
            count2 += c2mc[i][1]
    else:
        if c1mc[0][1] == c2mc[0][1]:
            if c1mc[1][1] > c2mc[1][1]:
                for i in range(len(c1mc)):
                    if i == 1:
                        continue
                    count1 += c1mc[i][1]
                for i in range(1, len(c2mc)):
                    count2 += c2mc[i][1]
            else:
                for i in range(1, len(c1mc)):
                    count1 += c1mc[i][1]
                for i in range(len(c2mc)):
                    if i == 1:
                        continue
                    count2 += c2mc[i][1]

        elif c1mc[0][1] > c2mc[0][1]:
            for i in range(1, len(c1mc)):
                count1 += c1mc[i][1]

            for i in range(len(c2mc)):
                if i == 1:
                    continue
                count2 += c2mc[i][1]
        else:
            for i in range(len(c1mc)):
                if i == 1:
                    continue
                count1 += c1mc[i][1]

            for i in range(1, len(c2mc)):
                count2 += c2mc[i][1]

    print(count1 + count2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import collections


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

    va = []
    vb = []
    for i in range(0, n, 2):
        va.append(v[i])
        vb.append(v[i + 1])

    if va == vb:
        print(len(va))
        return

    c1mc = collections.Counter(va).most_common()
    c2mc = collections.Counter(vb).most_common()

    count1 = 0
    count2 = 0
    if c1mc[0][0] != c2mc[0][0]:
        for i in range(1, len(c1mc)):
            count1 += c1mc[i][1]
        for i in range(1, len(c2mc)):
            count2 += c2mc[i][1]
    else:
        if c1mc[0][1] == c2mc[0][1]:
            if c1mc[1][1] < c2mc[1][1]:
                for i in range(len(c1mc)):
                    if i == 1:
                        continue
                    count1 += c1mc[i][1]
                for i in range(1, len(c2mc)):
                    count2 += c2mc[i][1]
            else:
                for i in range(1, len(c1mc)):
                    count1 += c1mc[i][1]
                for i in range(len(c2mc)):
                    if i == 1:
                        continue
                    count2 += c2mc[i][1]

        elif c1mc[0][1] > c2mc[0][1]:
            for i in range(1, len(c1mc)):
                count1 += c1mc[i][1]

            for i in range(len(c2mc)):
                if i == 1:
                    continue
                count2 += c2mc[i][1]
        else:
            for i in range(len(c1mc)):
                if i == 1:
                    continue
                count1 += c1mc[i][1]

            for i in range(1, len(c2mc)):
                count2 += c2mc[i][1]

    print(count1 + count2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import collections


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

    va = []
    vb = []
    for i in range(0, n, 2):
        va.append(v[i])
        vb.append(v[i + 1])

    if va == vb:
        print(len(va))
        return

    c1mc = collections.Counter(va).most_common()
    c2mc = collections.Counter(vb).most_common()

    count1 = 0
    count2 = 0
    if c1mc[0][0] != c2mc[0][0]:
        for i in range(1, len(c1mc)):
            count1 += c1mc[i][1]

        for i in range(1, len(c2mc)):
            count2 += c2mc[i][1]
    else:
        if c1mc[0][1] > c2mc[0][1]:
            for i in range(1, len(c1mc)):
                count1 += c1mc[i][1]

            for i in range(len(c2mc)):
                if i == 1:
                    continue
                count2 += c2mc[i][1]
        else:
            for i in range(len(c1mc)):
                if i == 1:
                    continue
                count1 += c1mc[i][1]

            for i in range(1, len(c2mc)):
                count2 += c2mc[i][1]

    print(count1 + count2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

# 始点から5(6-1)番目の要素を2個ごとに取り出す
# a[:6:2] #[0, 2, 4]
# 7番目から終点までの要素を2個ごとに取り出す
# a[7::2] #[7, 9]
odd=vlis[0::2]
even=vlis[1::2]



import collections
odd_max=collections.Counter(odd).most_common(2)
even_max=collections.Counter(even).most_common(2)
print(odd_max)
print(even_max)

# 一番多い数の数字が偶奇で同じ場合
if odd_max[0][0]==even_max[0][0]:
    # 全てが同じ数字の場合
    if len(odd_max)==1 and len(even_max)==1:
        print(int(len(vlis)/2))
    # 偶数列が全部同じ値だった時は奇数列は２番目多い数の数字に合わせる
    elif len(even_max)==1:
        print(len(vlis)-even_max[0][1]-odd_max[1][1])
    # 奇数列が全部同じ値だった時は偶数列は２番目多い数の数字に合わせる
    elif len(odd_max)==1:
        print(len(vlis)-odd_max[0][1]-even_max[1][1])
    else:
        
        if odd_max[0][1]+even_max[1][1]>=odd_max[1][1]+even_max[0][1]:
            print(len(vlis)-odd_max[0][1]-even_max[1][1])
        else:
            print(len(vlis)-odd_max[1][1]-even_max[0][1])
else:
    print(len(vlis)-odd_max[0][1]-even_max[0][1])

Submission status: Wrong Answer

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

first = data[::2]
second = data[1::2]


dic1 = {}
dic2 = {}

dic1[0] = 0
dic2[0] = 0
for i in range(n//2):
    if not first[i] in dic1:
        dic1[first[i]] = 1
    else:
        dic1[first[i]] += 1
    if not second[i] in dic2:
        dic2[second[i]] = 1
    else:
        dic2[second[i]] += 1

max1 = 0
second1 = 0
for kouho in dic1.items():
    if kouho[1] > max1:
        second1 = max1
        max1 = kouho[0]

max2 = 0
second2= 0
for kouho in dic2.items():
    if kouho[1] > max2:
        second2 = max2
        max2 = kouho[0]

if not max1 == max2:
    print(n-dic1[max1]-dic2[max2])
else:
    if dic1[max1] > dic2[max2]:
        print(n-dic1[max1]-dic2[second2])
    else:
        print(n-dic1[second2]-dic2[max2])

Submission status: Wrong Answer

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

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

ever = []
odds = []
for i in range(0,len(v1)):
    ever.append(v1.count(v1[i]))

for i in range(0,len(v2)):
    odds.append(v2.count(v2[i]))


everCountMax = 0
oddsCountMax = 0

for i in range(len(v1)):
    if(ever[i] >= everCountMax):
        everMax = ever[i]

for i in range(len(v2)):
    if(odds[i] >= oddsCountMax):
        oddsMax = odds[i]


if(everCountMax == n//2 and oddsCountMax == n//2 and v1[0] == v2[0]):
    print(len(v) // 2)
elif (everCountMax == n//2 and oddsCountMax == n//2 ):
    print(0)
else:
    print((n//2-everMax)+(n//2-oddsMax))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

import numpy as np

n = int(input())

v = np.array([int(c) for c in input().split()])

v1 = v[0::2]
v2 = v[1::2]

v1_n = np.unique(v1)
v2_n = np.unique(v2)
v1_cnt = np.array([len(v1[v1==n]) for n in v1_n])
v2_cnt = np.array([len(v2[v2==n]) for n in v2_n])

v1_n = v1_n[np.argsort(v1_cnt)]
v2_n = v2_n[np.argsort(v2_cnt)]
v1_cnt.sort()
v2_cnt.sort()
v1_cnt = np.append(v1_cnt, 0)
v2_cnt = np.append(v2_cnt, 0)


if v1_n[0] != v2_n[0]:
    print(n - v1_cnt[0] - v2_cnt[0])
else:
    n1 = n - v1_cnt[0] - v2_cnt[1]
    n2 = n - v1_cnt[1] - v2_cnt[0]
    print(min(n1, n2))

Submission status: Wrong Answer

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

count = 0
even = V[0::2]
odd = V[1::2]

for i in range(len(even)//2):
  if even[i] != even[i+1]:
    count += 1
  if odd[i] != odd[i+1]:
    count += 1

if sum(V) == len(V)*V[0]:
  count += len(V)//2


print(count)

Submission status: Wrong Answer

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

count = 0
for i in range(len(V)):
  if V[i] != V[i+2]:
    count += 1
  elif V[i] == V[i+1]:
    if V[i-1] == V[i-2]:
      count += 1
  if i+2 == len(V)-1:
    break


print(count)