TnT/Multi_CodeNet4Repair huggingface dataset:
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 sys
input=sys.stdin.readline

input = open(sys.argv[1], "r").readline

def main():
    N = int(input())
    V1 = {}
    V2 = {}
    V = list(map(int, input().split()))
    for i,v in enumerate(V):
        if i%2 == 0:
            V1[v] = V1[v] + 1 if v in V1 else 1
        else:
            V2[v] = V2[v] + 1 if v in V2 else 1

    V1 = sorted(V1.items(), key=lambda x:x[1], reverse=True)
    V2 = sorted(V2.items(), key=lambda x:x[1], reverse=True)

    if V1[0] != V2[0]:
        ans = 0
        for v in V1[1:]:
            ans += v[1]
        for v in V2[1:]:
            ans += v[1]
        print(ans)
    else:
        a1 = 0
        for v in V1[1:]:
            a1 += v[1]
        a1 += V2[0][1]
        for v in V2[2:]:
            a1 += v[1]
        a2 = 0
        a2 += V1[0][1]
        for v in V1[2:]:
            a2 += v[1]
        for v in V2[1:]:
            a1 += v[1]
        print(min(a1,a2))

if __name__ == '__main__':
    main()


import sys
input=sys.stdin.readline

def main():
    N = int(input())
    V1 = {}
    V2 = {}
    V = list(map(int, input().split()))
    for i,v in enumerate(V):
        if i%2 == 0:
            V1[v] = V1[v] + 1 if v in V1 else 1
        else:
            V2[v] = V2[v] + 1 if v in V2 else 1

    V1 = sorted(V1.items(), key=lambda x:x[1], reverse=True)
    V2 = sorted(V2.items(), key=lambda x:x[1], reverse=True)

    if V1[0] != V2[0]:
        ans = 0
        for v in V1[1:]:
            ans += v[1]
        for v in V2[1:]:
            ans += v[1]
        print(ans)
    else:
        a1 = 0
        for v in V1[1:]:
            a1 += v[1]
        a1 += V2[0][1]
        for v in V2[2:]:
            a1 += v[1]
        a2 = 0
        a2 += V1[0][1]
        for v in V1[2:]:
            a2 += v[1]
        for v in V2[1:]:
            a2 += v[1]
        print(min(a1,a2))

if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Accepted
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):

# coding: utf-8

# In[129]:


from collections import Counter


# In[130]:


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


# In[134]:


v_even = Counter(v[::2]).most_common()
v_odd = Counter(v[1::2]).most_common()


# In[136]:


if len(v_even) == 1:
    v_even.append([0,0])
if len(v_odd) == 1:
    v_odd.append([0,0])


# In[ ]:


if v_even[0][0] == v_odd[0][0]:
    if v_even[1][1] > v_odd[1][1]:
        ret




# coding: utf-8

# In[129]:


from collections import Counter


# In[141]:


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


# In[142]:


v_even = Counter(v[::2]).most_common()
v_odd = Counter(v[1::2]).most_common()


# In[146]:


if len(v_even) == 1:
    v_even.append([0,0])
if len(v_odd) == 1:
    v_odd.append([0,0])
if v_even[0][0] == v_odd[0][0]:
    if v_even[1][1] > v_odd[1][1]:
        ret = n - v_even[1][1] - v_odd[0][1]
    else:
        ret = n - v_even[0][1] - v_odd[1][1]
else:
    ret = n - v_even[0][1] - v_odd[0][1]


# In[147]:


print(ret)



Verdicts: Runtime Error

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

n = int(input())
vn = list(map(int,input().split()))
vn_odd = [vn[i] for i in range(n) if i%2==1]
vn_even = [vn[i] for i in range(n) if i%2==0]
odd_freq = Counter(vn_odd).most_common(2)
even_freq = Counter(vn_even).most_common(2)

ans = 0

if odd_freq[0][0] != even_freq[0][0]:
    ans += n - odd_freq[0][1] - even_freq[0][1]
else:
    ans += n - max(odd_freq[0][1]+even_freq[1][1], odd_freq[1][1]+even_freq[0][1])
            
print(ans)


import collections
 
def counter_top(c, exclude):
  for a in c.most_common():
    if a[0] != exclude:
      return a
  return (object(), 0)
 
def conv_seq(seq, exclude=None):
  c = collections.Counter(seq)
  mc = counter_top(c, exclude)
  return sum(c.values()) - mc[1], mc[0]
 
input()
vals = list(map(int, input().split()))
s1, a = conv_seq(vals[::2])
s2, b = conv_seq(vals[1::2])
if a != b:
  print(s1 + s2)
else:
  s1_new, _ = conv_seq(vals[::2], exclude=b)
  s2_new, _ = conv_seq(vals[1::2], exclude=a)
  print(min(s1_new + s2, s1 + s2_new))

Verdicts: Runtime Error

Accepted
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())

a = [int(l) for l in input().split()]

ac = collections.Counter(a[::2]).most_common()
bc = collections.Counter(a[1::2]).most_common()


min_trans = n//2
for x in ac:
    for y in bc:
        if x[0] == y[0]:
            continue
        else:
            print(x, y)
            min_trans = min(n-x[1]-y[1], min_trans)

print(min_trans)
    







import collections

n = int(input())

al = [int(l) for l in input().split()]

a = []
b = []
for i, x in enumerate(al):
    if i%2 == 0:
        a.append(x)
    else:
        b.append(x)

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

if ac[0][0] != bc[0][0]:
    print(n-ac[0][1]-bc[0][1])
else:
    if len(ac) == 1 and len(bc) == 1:
        print(n-max(ac[0][1], bc[0][1]))
    elif len(ac) == 1:
        print(n-max(ac[0][1], ac[1][1]+bc[0][1]))
    elif len(ac) == 1:
        print(n-max(bc[0][1], ac[0][1]+bc[1][1]))
    else:
        print(n-max(ac[1][1]+bc[0][1], ac[0][1]+bc[1][1]))
    


Verdicts: Wrong Answer

Accepted
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=int(input())
v=list(map(int,input().split()))
even=v[0::2]
odd=v[1::2]
import collections
c=collections.Counter(even)
d=collections.Counter(odd)
e=c.most_common()[0][0]
o=d.most_common()[0][0]
e2=c.most_common()[0][1]
o2=d.most_common()[0][1]
if e==o:
  	if even.count(e)==odd.count(o)==len(even):
        print(n/2)
    elif even.count(e)>odd.count(o):
        o=o2
    else:
        e=e2
count=len(v)-(even.count(e)+odd.count(o))
print(count)
    


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)
elif:
    print(s+t)
    
        


n = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
import operator
def f():
    a = Counter(A[::2]).most_common(2)
    b = Counter(A[1::2]).most_common(2)
    ac, bc = a[0][1], b[0][1]
    ret = n - (ac + bc)
    if a[0][0] == b[0][0]:
        bc_2 = b[1][1] if len(b) != 1 else 0
        ac_2 = a[1][1] if len(a) != 1 else 0
        ret = n - max(ac + bc_2, ac_2 + bc)
    return ret
print(f())

Verdicts: Runtime Error

Runtime Error

Accepted
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):
from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))
 
c1 = Counter(a[::2])
c2 = Counter(a[1::2])
c1f1 = max(c1, key = lambda k:c1[k])
c2f1 = max(c2, key = lambda k:c2[k])
 
if c1f1 != c2f1:
  return n - c1[c1f1] - c2[c2f1]
else:
  if c1[c1f1] > c2[c2f1]:
    del c2[c2f1]
    if not c2: return n-c1[c1f1]
    c2f1 = max(c2, key = lambda k:c2[k])
    return n-c1[c1f1] - c2[c2f1]
  else:
    del c1[c1f1]
    if not c1: return n-c2[c2f1]
    c1f1 = max(c1, key = lambda k:c1[k])
    return n-c1[c1f1] - c2[c2f1]

from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))
cnt1 = Counter(a[::2]).most_common(2)
c11, c12 = (cnt1 if len(cnt1) == 2 else cnt1+[('', 0)])
cnt2 = Counter(a[1::2]).most_common(2)
c21, c22 = (cnt2 if len(cnt2) == 2 else cnt2+[('', 0)])

if c11[0] != c21[0]:
    print(n - c11[1] - c21[1])
else:
    print(n - max(c11[1]+c22[1], c12[1]+c21[1]))

Verdicts: Runtime Error

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

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

 else:
  if c <= d:
   print(len(even1)*2-d-even2.most_common()[1][1])
  else:
   print(len(even1)*2-c-odd2.most_common()[1][1])


from collections import Counter

n = int(input())
v = list(map(int,input().split()))
even1 = v[0::2]
odd1 = v[1::2]
even2 = Counter(even1)
odd2 = Counter(odd1)
a = even2.most_common()[0][0]
b = odd2.most_common()[0][0]
c = even2.most_common()[0][1]
d = odd2.most_common()[0][1]
if a != b:
 print(len(even1)-c+len(odd1)-d)
else:
 if len(list(set(even1))) == 1 and len(list(set(odd1))) == 1:
  print(len(even1))
 elif len(list(set(even1))) == 1:
  print(len(odd1)-odd2.most_common()[1][1])
 elif len(list(set(odd1))) == 1:
  print(len(even1)-even2.most_common()[1][1])
 else:
  e = even2.most_common()[1][1]
  f = odd2.most_common()[1][1]
  if c-e >= d-f:
   print(len(even1)*2-c-f)
  else:
   print(len(even1)*2-d-e)

Verdicts: Runtime Error

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

def calculate_mode(data):
    c = Counter(data)
    
    freq_scores = c.most_common()
    
    max_count = freq_scores[0][1]

    modes = []
    
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)



n = int(input())
v = list(map(int, input().split()))
a = v[0::2]
b = v[1::2]
c = v[0::2]
d = v[1::2]
ans = 0

f = max(calculate_mode(a))
g = max(calculate_mode(b))
print(f,g)
if f == g :
    for i in range(len(a)):
        if f == a[i]:
            a.remove(f)
        if g == b[i]:
            b.remove(g)
    f = calculate_mode(a)
    g = calculate_mode(b)


for i in range(len(a)):
    if f != c[i]:
        ans += 1
    if g != d[i]:
        ans += 1

print(ans)


from collections import Counter

n = int(input())
v = list(map(int, input().split()))
e = v[1::2] 
o = v[0::2] 
ans = 0

a = Counter(e) 
b = Counter(o)

c = a.most_common(2) 
d = b.most_common(2)

if c[0][0] != d[0][0]: 
    ans = n -c[0][1] -d[0][1]
else:                  
    if len(c) == 1:
        if len(d) == 1:
            ans = n//2
        else:
            ans = n -d[0][1]
    elif len(d) == 1 and len(c) != 1:
        ans = n -c[0][1]
    elif c[0][1] > d[0][1]:
        ans = n -c[0][1] -d[1][1]
    else:
        if c[0][1]==d[0][1]:
            ans = min(n-c[0][1]-d[1][1],n-c[1][1]-d[0][1])
        else:
            ans = n -c[1][1] -d[0][1]
    
print(ans)

Verdicts: Runtime Error

Accepted
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):
# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit

# from fractions import gcd

# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# import networkx as nx
# G = Graph()


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

kv1 = Counter(lisA[0:N:2]).most_common()
kv2 = Counter(lisA[1:N:2]).most_common()

if len(kv1)==len(kv2)==1 and kv1[0]==kv2[0]:
    print(N//2)
    exit()

print(kv1,kv2)
ans1 = N
ans2 = N
for i in range(0,N//2-1):
    try:
        if kv1[0][0]!=kv2[i][0]:
            ans1 = min(ans1,N-(kv1[0][1]+kv2[i][1]))
        if kv1[i][0]!=kv2[0][0]:
            ans2 = min(ans1,N-(kv1[i][1]+kv2[0][1]))
    except:
        pass

print(min(ans1,ans2))
# for row in board:

# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit

# from fractions import gcd

# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

# import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# import networkx as nx
# G = Graph()


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

kv1 = Counter(lisA[0:N:2]).most_common()
kv2 = Counter(lisA[1:N:2]).most_common()

if len(kv1)==len(kv2)==1 and kv1[0]==kv2[0]:
    print(N//2)
    exit()

ans1 = N
ans2 = N
for i in range(0,N//2-1):
    try:
        if kv1[0][0]!=kv2[i][0]:
            ans1 = min(ans1,N-(kv1[0][1]+kv2[i][1]))
        if kv1[i][0]!=kv2[0][0]:
            ans2 = min(ans2,N-(kv1[i][1]+kv2[0][1]))
    except:
        pass

print(min(ans1,ans2))
# for row in board:

# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Verdicts: Wrong Answer

Accepted
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 = int(input())
v = list(input().split())

for i in range(len(v)-2):
    v[i+2] = v[i]
    
for i in v:
    print(i,end=" ")

from collections import Counter
n = int(input())
v = list(map(int,input().split()))
 
c1 = Counter(v[::2])
c2 = Counter(v[1::2])
m1 = c1.most_common()
m2 = c2.most_common()
t2 = n//2
t1 = n - t2
 
if len(m1) == len(m2) == 1:
    print(n//2 if m1[0][0] == m2[0][0] else 0)
elif len(m1) == 1:
    if m1[0][0] != m2[0][0]:
        print(t1 - m2[0][1])
    else:
        print(t1 - m2[1][1])
elif len(m2) == 1:
    if m1[0][0] != m2[0][0]:
        print(t2 - m1[0][1])
    else:
        print(t2 - m1[1][1])
else:
    if m1[0][0] != m2[0][0]:
        print(n - m1[0][1] - m2[0][1])
    else:
        ans = n - m1[1][1] - m2[1][1]
        if m1[0][0] != m2[1][0]:
            ans = min(ans, n - m1[0][1] - m2[1][1])
        if m1[1][0] != m2[0][0]:
            ans = min(ans, n - m1[1][1] - m2[0][1])
        print(ans)

Verdicts: Wrong Answer

Accepted
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 = int(input())

v = list(map(int,input().split()))
v_odd = []
v_eve = []
v_odd_set = []
v_eve_set = []
v_odd_count = []
v_eve_count = []
v_o_max = 0
v_e_max = 0


for i in range(N):
    if i % 2 == 0:
        v_odd.append(v[i])
    else:
        v_eve.append(v[i])

v_odd_set = list(set(v_odd))
v_eve_set = list(set(v_eve))

for c in v_odd_set:
    a = v_odd.count(c)
    v_odd_count.append(a)
    if a == max(v_odd_count):
        v_o_max = c
    else:
        continue

for c in v_eve_set:
    a = v_eve.count(c)
    v_eve_count.append(a)
    if a == max(v_eve_count):
        v_e_max = c
    else:
        continue

v_odd_count.sort()
v_eve_count.sort()


if len(v_odd_count) != 1 and len(v_eve_count) != 1:
    if v_o_max == v_e_max:
        if v_odd_count[-1] >= v_eve_count[-2]:
            print(N - v_eve_count[-1] - v_eve_count[-2])
        else:
            print(N - v_odd_count[-1] - v_eve_count[-2])
    else:
        print(N - v_eve_count[-1] - v_odd_count[-1])
else:
    if v_o_max == v_e_max:
        print(int(N/2))
    else:
        print(0)

import collections
c = collections.Counter

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

v_odd = v[::2]
v_eve = v[1::2]

c1 = c(v_odd).most_common(2)
c2 = c(v_eve).most_common(2)

if len(c1) == 1 and len(c2) == 1:
    if c1[0][0] != c2[0][0]:
        ans = 0
    else:
        ans = int(N/2)
else:
    if c1[0] != c2[0]:
        ans = N - c1[0][1] - c2[0][1]
    else:
        if c1[1][1] >= c2[1][1]:
            ans = N - c1[1][1] - c2[0][1]
        else:
            ans = N - c1[0][1] - c2[1][1]

print(ans)

Verdicts: Wrong Answer

Accepted
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())
v = list(map(int, input().split()))
if len(set(v)) == 1:
	print (n//2)
	exit()
a = v[1::2]
b = v[0::2]
if len(set(a)) == 1 and len(set(b)) == 1:
	print (0)
	exit()

aa = collections.Counter(a)
bb = collections.Counter(b)

yousoa = aa.most_common()[0][0]
maa = aa.most_common()[0][1]
yousob = bb.most_common()[0][0]
mbb = bb.most_common()[0][1]
if yousoa == yousob
	if len(a) == 1:
		ans = (len(a) - maa) + (len(b) - bb.most_common()[1][1])
	elif len(b) == 1:
		ans = (len(a) - aa.most_common()[1][1]) + (len(b)-mbb)
	else:
		ans = (len(a) - maa) + (len(b) - bb.most_common()[1][1])
else:
	ans = len(a)-maa + len(b)-mbb
print (ans)

import collections
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
	print (n//2)
	exit()
a = v[1::2]
b = v[0::2]
if len(set(a)) == 1 and len(set(b)) == 1:
	print (0)
	exit()
ans = 0

aa = collections.Counter(a)
bb = collections.Counter(b)

yousoa = aa.most_common()[0][0]
maa = aa.most_common()[0][1]
yousob = bb.most_common()[0][0]
mbb = bb.most_common()[0][1]
if len(set(a)) == 1:
	ans += len(b) - mbb
	print (ans)
	exit()
if len(set(b)) == 1:
	ans += len(a) - maa
	print (ans)
	exit()
maa2 = aa.most_common()[1][1]
mbb2 = bb.most_common()[1][1]
if yousoa == yousob:
	ans = min(n//2-maa + n//2-mbb2,n//2-maa2 + n//2-mbb)
	print (ans)
else:
	print (n-maa-mbb)

Verdicts: Runtime Error

Accepted
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 = int(input())
V = list(map(int, input().split()))

E = V[::2]
O = V[1::2]

from collections import Counter
Ed = Counter(E)
Od = Counter(O)
Edn = Ed.most_common(2)
Odn = Od.most_common(2)
print(Edn,Odn)
if Edn[0][0] != Odn[0][0]:
    print(n- Edn[0][1] - Odn[0][1])
else:
    if len(Edn) == 1:
        if len(Odn) == 1:
            print(n//2)
        else:
            print(n//2-Odn[1][1])
    if len(Odn) == 1:
        print(n//2-Edn[1][1])
    else:
        print(min(n-Edn[0][1]-Odn[1][1],m-Edn[1][1]-Odn[0][1]))

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

Dic = [[i,0] for i in range(1,(10**5)+1)]
Dic2 = [[i,0] for i in range(1,(10**5)+1)]
for i in range(n):
    if i%2 == 0:
        Dic[V[i]-1][1] += 1
    else:
        Dic2[V[i]-1][1] += 1
Dic.sort(key = lambda x:x[1],reverse = True)
Dic2.sort(key = lambda x:x[1], reverse = True)
#print(Dic,Dic2)
cn = 0
if Dic[0][0] != Dic2[0][0]:
    cn += n - Dic[0][1] - Dic2[0][1]
else:
    cn += n - max((Dic[0][1]+Dic2[1][1]), (Dic[1][1]+Dic2[0][1]))
print(cn)

Verdicts: Runtime Error

Accepted
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 = int(input())
Ai = list(map(int, input().split()))

def calc(start): 
    di = dict()
    for i in range(start, N, 2):
        if Ai[i] in di:
            n = di[Ai[i]]
            di[Ai[i]] = n + 1
        else:
            di[Ai[i]] = 1
    return di

d1 = calc(0)
d2 = calc(1)

min_v = 10000000000
for k1 in d1.keys():
    for k2 in d2.keys():
        if k1 == k2:
            continue
        v = N - d1[k1] - d2[k2]
        if v < min_v:
            v = min_v
if min_v == 10000000000:
    print(N // 2)
else:
    print(min_v)


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

def calc(start): 
    di = dict()
    for i in range(start, N, 2):
        if Ai[i] in di:
            n = di[Ai[i]]
            di[Ai[i]] = n + 1
        else:
            di[Ai[i]] = 1
    l = []
    for k in di.keys():
        l.append([k, di[k]])
    l.sort(key=lambda x: x[1], reverse=True)
    return l

l1 = calc(0)
l2 = calc(1)

if l1[0][0] != l2[0][0]:
    print(N - l1[0][1] - l2[0][1])
elif len(l1) == 1 and len(l2) == 1:
    print(N // 2)
else:
    v1 = 100000000000000
    v2 = 100000000000000

    if len(l1) > 1:
        v1 = N - l1[1][1] - l2[0][1]
    if len(l2) > 1:
        v2 = N - l1[0][1] - l2[1][1]
    print(min(v1, v2))

Verdicts: Wrong Answer

Accepted
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())
v = list(map(int,input().split()))
ve = [v[2*i] for i in range(n//2)]
vo = [v[2*i + 1] for i in range(n//2)]
Cve = collections.Counter(ve)
Cvo = collections.Counter(vo)
Cve1 = Cve.most_common()[0]
Cvo1 = Cvo.most_common()[0]


if len(Cve) == 1 and len(Cvo) == 1:
    if Cve1[0] == Cvo1[0]:
        ans = n//2 - Cvo1[1]
    else:
        ans = 0
elif len(Cve) == 1 and len(Cvo) != 1:
    Cvo2 = Cvo.most_common()[1]
    if Cve1[0] == Cvo1[0]:
        ans = n//2 - Cvo2[1]
    else:
        ans = n//2 - Cvo1[1]

elif len(Cve) != 1 and len(Cvo) == 1:
    Cve2 = Cve.most_common()[1]
    if Cve1[0] == Cvo1[0]:
        ans = n//2 - Cve2[1]
    else:
        ans = n//2 - Cve1[2]
else:
    Cve2 = Cve.most_common()[1]
    Cvo2 = Cvo.most_common()[1]

    if Cve1[0] != Cvo1[0]:
        ans = n - Cve1[1] - Cvo1[1] 
    if Cve1[0] == Cvo1[0]:
        if Cve1[1] > Cvo1[1]:
            ans = n - Cve1[1] - Cvo2[1]
        else:
            an

import collections
n = int(input())
v = list(map(int,input().split()))
ve = [v[2*i] for i in range(n//2)]
vo = [v[2*i + 1] for i in range(n//2)]
Cve = collections.Counter(ve)
Cvo = collections.Counter(vo)
Cve1 = Cve.most_common()[0]
Cvo1 = Cvo.most_common()[0]
if len(Cve) == 1 and len(Cvo) == 1: 
    if Cve1[0] == Cvo1[0]: ans = n//2 
    else: ans = 0 
elif len(Cve) == 1 and len(Cvo) > 1: 
    Cvo2 = Cvo.most_common()[1]
    if Cve1[0] == Cvo1[0]: ans = n//2 - Cvo2[1] 
    else: ans = n//2 - Cvo1[1] 
elif len(Cve) > 1 and len(Cvo) == 1: 
    Cve2 = Cve.most_common()[1]
    if Cve1[0] == Cvo1[0]: ans = n//2 - Cve2[1] 
    else: ans = n//2 - Cve1[1] 
else:
    Cve2 = Cve.most_common()[1]
    Cvo2 = Cvo.most_common()[1]
    if Cve1[0] != Cvo1[0]: ans = n - Cve1[1] - Cvo1[1] 
    if Cve1[0] == Cvo1[0]:
        if Cve1[1] < Cvo1[1]: ans = n - Cve2[1] - Cvo1[1]
        elif Cve2[1] > Cvo2[1] : ans = n - Cve2[1] - Cvo1[1]
        else: ans = n - Cve1[1] - Cvo2[1]
print(ans)

Verdicts: Runtime Error

Accepted
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):
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 18:36:13 2020

@author: NEC-PCuser
"""
n = int(input())
l = list(map(int, input().split()))
dic_gusu = {}
dic_kisu = {}

for i in range(0, n):
    if (i % 2 == 0):
        if (l[i] in dic_gusu):
            dic_gusu[l[i]] += 1
        else:
            dic_gusu[l[i]] = 1
    if (i % 2 == 1):
        if (l[i] in dic_kisu):
            dic_kisu[l[i]] += 1
        else:
            dic_kisu[l[i]] = 1
dic_kisu = sorted(dic_kisu.items(), key = lambda x : x[1])
dic_gusu = sorted(dic_gusu.items(), key = lambda x : x[1])


if (len(dic_kisu) == 1 and len(dic_gusu) == 1 and dic_kisu[len(dic_kisu) - 1][0] == dic_gusu[len(dic_gusu) - 1][0]):
    count = n // 2
elif (dic_kisu[len(dic_kisu) - 1][0] != dic_gusu[len(dic_gusu) - 1][0]):
    for i in range(0, len(dic_kisu) - 1):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_gusu) - 1):
        count += dic_kisu[i][1]
else:
    for i in range(0, len(dic_kisu)):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_kisu)):
        count += dic_kisu[i][1]
    count_tmp = count
    count_ans = count_tmp - dic_kisu[len(dic_kisu) - 1][1] - dic_kisu[len(dic_gusu) - 2][1] 
    count_ans2 = count_tmp  - dic_kisu[len(dic_kisu) - 2][1] - dic_kisu[len(dic_gusu) - 1][1]
    count = min([count_ans, count_ans2])     
        
print(count)

# -*- coding: utf-8 -*-
"""
Created on Sun May 31 18:36:13 2020

@author: NEC-PCuser
"""
n = int(input())
l = list(map(int, input().split()))
dic_gusu = {}
dic_kisu = {}

for i in range(0, n):
    if (i % 2 == 0):
        if (l[i] in dic_gusu):
            dic_gusu[l[i]] += 1
        else:
            dic_gusu[l[i]] = 1
    if (i % 2 == 1):
        if (l[i] in dic_kisu):
            dic_kisu[l[i]] += 1
        else:
            dic_kisu[l[i]] = 1
dic_kisu = sorted(dic_kisu.items(), key = lambda x : x[1])
dic_gusu = sorted(dic_gusu.items(), key = lambda x : x[1])

count = 0
if (len(dic_kisu) == 1 and len(dic_gusu) == 1 and dic_kisu[len(dic_kisu) - 1][0] == dic_gusu[len(dic_gusu) - 1][0]):
    count = n // 2
elif (dic_kisu[len(dic_kisu) - 1][0] != dic_gusu[len(dic_gusu) - 1][0]):
    for i in range(0, len(dic_kisu) - 1):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_gusu) - 1):
        count += dic_gusu[i][1]
else:
    for i in range(0, len(dic_kisu)):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_gusu)):
        count += dic_gusu[i][1]
    count_tmp = count
    count_ans = count_tmp - dic_kisu[len(dic_kisu) - 1][1] - dic_gusu[len(dic_gusu) - 2][1] 
    count_ans2 = count_tmp  - dic_kisu[len(dic_kisu) - 2][1] - dic_gusu[len(dic_gusu) - 1][1]
    count = min([count_ans, count_ans2])    
        
print(count)

Verdicts: Runtime Error

Accepted
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=int(input())
V=list(map(int,input().split()))
A=[0]*(10**5+1)
B=[0]*(10**5+1)
for i in range(N):
  if(i%2==0):
    A[V[i]]+=1
  else:
    B[V[i]]+=1
MA=0
NA=A[0]
NA2=A[0]
MB=0
NB=B[0]
NB2=B[0]
for i in range(10**5+1):
  if(A[i]>=NA):
    NA2=NA
    NA=A[i]
    MA=i
  if(B[i]>=NB):
    NB2=NB
    NB=B[i]
    MB=i
if(MA!=MB):
  print(N-NA-NB)
else:
  print(min(N-NA-NB2,N-NA2-NB))
print(MA,MB,NA,NA2,NB,NB2)

N=int(input())
V=list(map(int,input().split()))
A=[0]*(10**5+1)
B=[0]*(10**5+1)
for i in range(N):
  if(i%2==0):
    A[V[i]]+=1
  else:
    B[V[i]]+=1
MA=0
NA=A[0]
MB=0
NB=B[0]
for i in range(10**5+1):
  if(A[i]>=NA):
    NA=A[i]
    MA=i
  if(B[i]>=NB):
    NB=B[i]
    MB=i
A.sort(reverse=True)
B.sort(reverse=True)
if(MA!=MB):
  print(N-NA-NB)
else:
  print(min(N-A[0]-B[1],N-A[1]-B[0]))



Verdicts: Wrong Answer

Accepted
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):
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)

#
#

#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    V = readInts()
    from collections import Counter
    a = Counter(V[0::2]).most_common(1) 
    b = Counter(V[1::2]).most_common(1)
    a.append([0,0])
    b.append([0,0])
    print(a,b)
    if a[0][0] != b[0][0]:
        
        print(n - (a[0][1] + b[0][1]))
    else:
        print(min(n-(a[1][1] - b[0][1]), n-(a[0][1] + b[1][1])))
if __name__ == '__main__':
  main()


n = int(input())
v = list(map(int,input().split()))
from collections import Counter
even = Counter(v[::2]).most_common(2)
odd = Counter(v[1::2]).most_common(2)
even.append((0,0))
odd.append((0,0))
youso = n//2
if even[0][0] == odd[0][0]: 
    print(min(youso - even[1][1] + youso - odd[0][1],youso - odd[1][1] + youso - even[0][1]))
else: 
    print(youso - even[0][1] + youso - odd[0][1])


Verdicts: Wrong Answer

Accepted
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):
from collections import Counter
def main():
    n=int(input())
    v=list(map(int,input().split()))
    v0=sorted(Counter(v[::2]).items(), key=lambda x: x[1])
    v1=sorted(Counter(v[1::2]).items(), key=lambda x: x[1])
    vv = v1[-1][0]
    if v0[-1][0] == v1[-1][0]:
        if len(v0) > 1 and len(v1) > 0:
            vv = min(v0[-2][1], v1[-2][1])
        elif len(v0) > 1:
            vv = v0[-2][1]
        elif len(v1) > 1:
            vv = v1[-2][1]
        else:
            print(n//2)
            return
    print(n-v0[-1][1]-vv)
    
if __name__ == "__main__":
    main()

from collections import Counter
def main():
    n=int(input())
    v=list(map(int,input().split()))
    v0=Counter(v[0::2]).most_common(2)
    v1=Counter(v[1::2]).most_common(2)
    
    print(v0)
    print(v1)
    print(n, v0[0], v1[0])
    if v0[0][0] != v1[0][0]:
        print(n - v0[0][1] - v1[0][1])
    else:
        if len(v0) == 1 and len(v1) == 1:
            print(n//2)
        else:
            print(n-max(v0[0][1]+v1[1][1], v0[1][1]+v1[0][1]))
    
if __name__ == "__main__":
    main()

from collections import Counter
def main():
    n=int(input())
    v=list(map(int,input().split()))
    v0=sorted(Counter(v[::2]).items(), key=lambda x: x[1])
    v1=sorted(Counter(v[1::2]).items(), key=lambda x: x[1])
    
    if v0[-1][0] != v1[-1][0]:
        print(n-v0[-1][1]-v1[-1][1])
    else:
        if len(v0) == 1 and len(v1) == 1:
            print(n//2)
        else:
            a = (v0[-1][1] + v1[-2][1]) if len(v1) > 1 else 0
            b = (v0[-2][1] + v1[-1][1]) if len(v0) > 1 else 0
            print(n - max(a, b))
    
if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
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=int(input())
arr=list(map(int,input().split()))
cnt1=[0]*(10**5+1)
cnt2=[0]*(10**5+1)
for i in range(n):
  if i%2==0:
    cnt1[arr[i]]+=1
  else:
    cnt2[arr[i]]+=1
m1=max(cnt1)
m2=max(cnt2)
p1=cnt1.index(m1)
p2=cnt2.index(m2)
cnt1=sorted(cnt1,reverse=True)
cnt2=sorted(cnt2,reverse=True)
if n==2:
  if arr[0]!=arr[1]:
    print(0)
  else:
    print(1)
else:
  if p1==p2:
    if m1>m2:
      m2=cnt2[1]
    else:
      m1=cnt1[1]
  ans=(n-m1)+(n-m2)
  print(ans)

n=int(input())
arr=list(map(int,input().split()))
cnt1=[0]*(10**5+1)
cnt2=[0]*(10**5+1)
for i in range(n):
  if i%2==0:
    cnt1[arr[i]]+=1
  else:
    cnt2[arr[i]]+=1
m1=max(cnt1)
m2=max(cnt2)
p1=cnt1.index(m1)
p2=cnt2.index(m2)
cnt1=sorted(cnt1,reverse=True)
cnt2=sorted(cnt2,reverse=True)
if n==2:
  if arr[0]!=arr[1]:
    print(0)
  else:
    print(1)
else:
  if p1==p2:
    ans=min(n-m1-cnt2[1],n-cnt1[1]-m2)
  else:
    ans=n-m1-m2
  print(ans)

Verdicts: Wrong Answer

Accepted
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):
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
gu = [::2]
ki = [1::2]
ans = 0
k,g = False,False

if v.count(v[0]) == n:
    ans += n // 2
else:
    kic = Counter(ki)
    guc = Counter(gu)
    k1 = kic.most_common(2)
    g1 = guc.most_common(2)
    if k1[0][0] == g1[0][0]:
        if k1[1][1] < g1[1][1]:
            k = True
        elif k1[1][1] > g1[1][1]:
            g = True

    kic = list(kic.values())
    guc = list(guc.values())
    kic.sort(reverse = True)
    guc.sort(reverse = True)
    if len(kic) != 1:
        if k:
            ans += kic[0]
            ans += sum(kic[2::])
        else:
            ans += sum(kic[1::]) 
    if len(guc) != 1:
        if g:
            ans += guc[0]
            ans += sum(guc[2::])
        else:
            ans += sum(guc[1::])

print(ans)

from collections import Counter
n = int(input())
v = list(map(int, input().split()))
gu = v[::2]
ki = v[1::2]
ans = 0
k,g = False,False



if v.count(v[0]) == n
    ans += n // 2
else:
    kic = Counter(ki)
    guc = Counter(gu)
    k1 = kic.most_common(2)
    g1 = guc.most_common(2)
    if k1[0][0] == g1[0][0]:
        if k1[1][1] < g1[1][1]:
            g = True
        else:
            k = True

    kic = list(kic.values())
    guc = list(guc.values())
    kic.sort(reverse = True)
    guc.sort(reverse = True)
    if len(kic) != 1:
        if k:
            ans += kic[0]
            ans += sum(kic[2::])
        else:
            ans += sum(kic[1::]) 
    if len(guc) != 1:
        if g:
            ans += guc[0]
            ans += sum(guc[2::])
        else:
            ans += sum(guc[1::])

print(ans)

from collections import Counter
n = int(input())
v = list(map(int, input().split()))
gu = v[::2]
ki = v[1::2]
ans = 0
k,g = False,False



if v.count(v[0]) == n:
    ans += n // 2
else:
    kic = Counter(ki)
    guc = Counter(gu)
    k1 = kic.most_common(2)
    g1 = guc.most_common(2)
    if k1[0][0] == g1[0][0]:
        if k1[1][1] < g1[1][1]:
            g = True
        else:
            k = True

    kic = list(kic.values())
    guc = list(guc.values())
    kic.sort(reverse = True)
    guc.sort(reverse = True)
    if len(kic) != 1:
        if k:
            ans += kic[0]
            ans += sum(kic[2::])
        else:
            ans += sum(kic[1::]) 
    if len(guc) != 1:
        if g:
            ans += guc[0]
            ans += sum(guc[2::])
        else:
            ans += sum(guc[1::])

print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
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):
from collections import Counter as c

e,o = 0,0
ans = 0
E,O = [],[]
for v,i in zip(V,range(N)):
    if i%2 == 0:
        E.append(v)
    else:
        O.append(v)
EC = c(E).most_common()
OC = c(O).most_common()
n = N//2

EC01=EC[0][1]

OC01=OC[0][1]

if len(EC) == 1:
    EC11 = 0
else:
    EC11=EC[1][1]
if len(OC) == 1:
    OC11 = 0
else:
    OC11=OC[1][1]
if len(EC) == 1 and len(OC) == 1 and EC[0][0]==OC[0][0]:
    ans = EC01
elif EC01+OC11 > EC11+OC01:
    ans += n - EC01
    ans += n - OC11
elif EC01+OC11 < EC11+OC01:
    ans += n - EC11
    ans += n - OC01
elif EC01 == OC01:
    ans = 0
print(EC01,EC11,OC01,OC11)
print(ans)

from collections import Counter as c

e,o = 0,0
ans = 0
E,O = [],[]
for v,i in zip(V,range(N)):
    if i%2 == 0:
        E.append(v)
    else:
        O.append(v)
EC = c(E).most_common()
OC = c(O).most_common()
n = N//2

EC01=EC[0][1]

OC01=OC[0][1]

if len(EC) == 1:
    EC11 = 0
else:
    EC11=EC[1][1]
if len(OC) == 1:
    OC11 = 0
else:
    OC11=OC[1][1]
if len(EC) == 1 and len(OC) == 1 and EC[0][0]==OC[0][0]:
    ans = EC01
elif EC01+OC11 > EC11+OC01:
    ans += n - EC01
    ans += n - OC11
elif EC01+OC11 < EC11+OC01:
    ans += n - EC11
    ans += n - OC01
elif EC01 == OC01:
    ans = 0
print(ans)

from collections import Counter as c

N = int(input())
V = list(map(int,input().split()))
ev = c(V[::2]).most_common(2)
od = c(V[1::2]).most_common(2)

if ev[0][0] == od[0][0]:
    if len(ev) == 1 and len(od) == 1:
        print(N//2)
    else:
        print(N-max(ev[0][1]+od[1][1],ev[1][1]+od[0][1]))
else:
    print(N-ev[0][1]-od[0][1])

Verdicts: Runtime Error

Runtime Error

Accepted
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 = int(input())
v_list = [int(x) for x in input().split()]
v_odd = [x for x in v_list if v_list.index(x) % 2 == 1]
v_even = [x for x in v_list if v_list.index(x) % 2 == 0]

print(v_odd, v_even)
if len(list(set(v_list))) > 1:

        odd_max1 = list(set(v_odd))[-1]
        
        even_max1 = list(set(v_even))[-1]
        
        
        if odd_max1 == even_max1:
                odd_max2 = list(set(v_odd))[-2]
                even_max2 = list(set(v_even))[-2]

                p = N -v_odd.count(odd_max1) - v_even.count(even_max2)
                q = N -v_odd.count(odd_max2) - v_even.count(even_max1)

                if p > q:
                        n = p
                else:
                        n = q
        else:
                n = N -v_odd.count(odd_max1) - v_even.count(even_max1)

else:
        n = int(N / 2)



print(n)

from collections import defaultdict
import sys
n = int(input())
v = list(map(int, input().split()))

dd_even = defaultdict(int)
dd_odd  = defaultdict(int)


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

l_even = list(dd_even.items())
l_even.sort(key= lambda x:x[1])
top_even = l_even[-1][0]
#print(l_even)


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

l_odd = list(dd_odd.items())
l_odd.sort(key= lambda x:x[1])
#print(l_odd)
top_odd = l_odd[-1][0]

if top_even == top_odd:
    if len(l_odd) == 1: 
        res = int(n / 2)
        print(res)
        sys.exit()
    else:
        
        l_odd_1 = [l for l in l_odd if l[0] != l_odd[-2][0]]
        sum_odd_1 = sum(l[1] for l in l_odd_1)
        l_even_1 = [l for l in l_even if l[0] != top_even]
        sum_even_1 = sum(l[1] for l in l_even_1)
        sum_1 = sum_odd_1 + sum_even_1

        l_odd_2 = [l for l in l_odd if l[0] != top_odd]
        sum_odd_2 = sum(l[1] for l in l_odd_2)
        l_even_2 = [l for l in l_even if l[0] != l_even[-2][0]]
        sum_even_2 = sum(l[1] for l in l_even_2)
        sum_2 = sum_odd_2 + sum_even_2

        if sum_1 < sum_2:
            print(sum_1)
        else:
            print(sum_2)
        sys.exit()
else:
    l_odd = [l for l in l_odd if l[0] != top_odd]

sum_odd = sum(l[1] for l in l_odd)
#print(l_odd, sum_odd)

l_even = [l for l in l_even if l[0] != top_even]
sum_even = sum(l[1] for l in l_even)


res = sum_odd + sum_even
print(res)


Verdicts: Wrong Answer

Accepted
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())
even = [input() for i in range(N) if i%2==0]
odd =[ input() for i in range(N) if i%2!=0]

e = collections.Counter(even)
o = collections.Counter(odd)

ec=e[0][1]
oc=o[0][1]

if e[0][0]==o[0][0]:
  if e[0][1] > o[0][1]:
    oc=o[1][1]
  else:
    ec=e[1][1]
    
ans = N-(ec+oc)
print(ans)

from collections import Counter

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

v1 = []
v2 = []

for i, v in enumerate(V):
    if i % 2 == 0:
       v1.append(v)
    else:
        v2.append(v)

v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()

k1, v1 = v1c[0][0], v1c[0][1]
k2, v2 = v2c[0][0], v2c[0][1]

if k1 == k2:
    ans -= v2
    m = 0
    if len(v1c) >= 2:
        m = max(m, v1c[1][1])
    if len(v2c) >= 2:
        m = max(m, v2c[1][1])
    ans -= m
else:
    ans -= v1 + v2

print(ans)


Verdicts: Runtime Error

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

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

if len(set(v)) == 1:
    count = n//2
else:
    odd = defaultdict(lambda: 0)
    even = defaultdict(lambda: 0)
    for i in v[0::2]:
        odd[i] += 1
    for i in v[1::2]:
        even[i] += 1
    o1, o2, *_ = sorted(odd.items(), key=lambda x: x[1], reverse=True)
    e1, e2, *_ = sorted(even.items(), key=lambda x: x[1], reverse=True)
    if o1[0] != e1[0]:
        count = n - o1[1] - e1[1]
    elif o1[1] >= e1[1]:
        count = n - o1[1] - e2[1]
    elif o1[1] < e1[1]:
        count = n - o2[1] - e1[1]

print(count)

from collections import defaultdict

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

odd = defaultdict(lambda: 0)
even = defaultdict(lambda: 0)
odd[None] = 0
even[None] = 0
for i in v[0::2]:
    odd[i] += 1
for i in v[1::2]:
    even[i] += 1

odd = sorted(odd.items(), key=lambda x: x[1], reverse=True)
even = sorted(even.items(), key=lambda x: x[1], reverse=True)
if odd[0][0] != even[0][0]:
    count = n - odd[0][1] - even[0][1]
else:
    count = n - max(odd[0][1]+even[1][1], odd[1][1]+even[0][1])

print(count)


Verdicts: Runtime Error

Accepted