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):
from collections import Counter
N=int(input())
V=list(map(int,input().split()))
V0=Counter(V[::2]).most_common()
V1=Counter(V[1::2]).most_common()
ans=0
for i in range(1,len(V0)-1):
  ans+=V0[i][1]
for i in range(1,len(V1)-1):
  ans+=V1[i][1]
print(ans)

V=list(map(int,input().split()))
V0=Counter(V[::2]).most_common()
V1=Counter(V[1::2]).most_common()
ans=0
if V0[0][0]==V1[0][0]:
  if len(V0)==1 and len(V1)==1:
    print(N//2)
    exit()
  elif len(V0)!=1 and len(V1)!=1:
    if V0[1][0]>=V1[1][0]:
      V0[0],V0[1]=V0[1],V0[0]
    else:
      V1[0],V1[1]=V1[1],V1[0]
  elif len(V0)>len(V1):
     V0[0],V0[1]=V0[1],V0[0]
  else:
    V1[0],V1[1]=V1[1],V1[0]
for i in range(1,len(V0)):
  ans+=V0[i][1]
for i in range(1,len(V1)):
  ans+=V1[i][1]
print(ans)

from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
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])))

Verdicts: Wrong Answer

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 = input().split()

vv = list(set(v))

if len(vv) >= 2:
    vvv = vv.copy()

    min = 10**6
    for i in vv:
        vvv.remove(i)
        for j in vvv:
            if 10-(v.count(i)+v.count(j)) > min:
                pass
            else:
                ct = 0
                a = [i if k % 2 == 0 else j for k in range(n)]
                print(' '.join(a))
                for k in range(n):
                    if a[k] != v[k]:
                        ct += 1
                if ct < min:
                    min = ct
        vvv.append(i)
    print(min)
else:
    print(int(n/2))


import collections

n = int(input())
v = input().split()

e = [v[i] for i in range(n) if i % 2 == 0]
o = [v[i] for i in range(n) if i % 2 == 1]

c_e = collections.Counter(e).most_common()
c_o = collections.Counter(o).most_common()

e_0 = c_e[0]
o_0 = c_o[0]

if e_0 != o_0:
    print(len(e) - e_0[1] + len(o) - o_0[1])
else:
    if len(c_e) == 1:
        e_1 = [0, 0]
    else:
        e_1 = c_e[1]
    if len(c_o) == 1:
        o_1 = [0, 0]
    else:
        o_1 = c_o[1]
    print(min(len(e)-e_0[1]+len(o)-o_1[1], len(e)-e_1[1]+len(o)-o_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):
6
105 119 105 119 105 119

n = int(input())

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

odd = [data[i] for i in range(0,n,2)]
even = [data[i] for i in range(1,n,2)]

odd_dict = dict({})
even_dict = dict({})

for i in range(n//2):
    if odd_dict.__contains__(odd[i]):
        odd_dict[odd[i]]+=1
    else:
        odd_dict[odd[i]] = 1
    if even_dict.__contains__(even[i]):
        even_dict[even[i]]+=1
    else:
        even_dict[even[i]] = 1

odd = sorted(odd_dict.items(), key=lambda d:d[1],reverse=True)
even = sorted(even_dict.items(), key=lambda d:d[1],reverse=True)

odd.append((0,0))
even.append((0,0))
if odd[0][0] == even[0][0]:
    print(min(n-odd[0][1]-even[1][1],n-odd[1][1]-even[0][1]))
else:
    print(n-odd[0][1]-even[0][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 = [int(i) for i in input().split()]
e = []
o = []
for i, a in enumerate(v):
    if i % 2:
        o.append(a)
    else:
        e.append(a)
oc = Counter(o)
ec = Counter(e)
h = n//2
ans = h

a = []
for i, (k, v) in enumerate(oc.most_common()):
    if not v in a:
        a.append(v)
    if len(a) >= 3:
        break
a = []
for j, (k, v) in enumerate(ec.most_common()):
    if not v in a:
        a.append(v)
    if len(a) >= 3:
        break
for k, v in oc.most_common(i):
    for k2, v2 in ec.most_common(j):
        if k == k2:
            continue
        ans = min(ans, h - v + h - v2)
print(ans)


from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
e = []
o = []
for i, a in enumerate(v):
    if i % 2:
        o.append(a)
    else:
        e.append(a)
oc = Counter(o)
ec = Counter(e)
h = n//2
if oc.most_common(1)[0][0] != ec.most_common(1)[0][0]:
    a = h - oc.most_common(1)[0][1]
    b = h - ec.most_common(1)[0][1]
    print(a+b)
else:
    if len(oc) == 1:
        print(h)
        exit()
    E1 = E2 = 0
    for i, (k, v) in enumerate(ec.most_common(2)):
        if i == 0:
            E2 = E1 = k
        else:
            E2 = k
    O1 = O2 = 0
    for i, (k, v) in enumerate(oc.most_common(2)):
        if i == 0:
            O2 = O1 = k
        else:
            O2 = k
    print(min(h-ec[E1] + h - oc[O2], h - ec[E2] + h - oc[O1]))


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 = [i for i in map(int, input().split())]
cnt = Counter(v)
if len(cnt) == 1:
    print(n//2)
    exit()
val = list(cnt.values())
val.sort()
val = val[::-1]
if len(val) == 2:
    print(abs(n//2 - val[0]))
    exit()
else:
    print(val)
    print(max(val[0] - n//2, 0) + sum(val[2:]))
    exit()

from collections import Counter
n = int(input())
v = [i for i in map(int, input().split())]
v_e, v_o = v[0::2], v[1::2]
cnt_e, cnt_o = Counter(v_e), Counter(v_o)
val_e, val_o = list(cnt_e.values()), list(cnt_o.values())
val_e.sort()
val_o.sort()
val_e, val_o = val_e[::-1], val_o[::-1]
cnt_e = sorted(cnt_e.items(), key=lambda x:x[1])[::-1]
cnt_o = sorted(cnt_o.items(), key=lambda x:x[1])[::-1]
key_e, key_o = cnt_e[0][0], cnt_o[0][0]
if key_e == key_o:
    if len(val_e) == len(val_o) == 1:
        print(n // 2)
    elif len(val_e) == 1:
        print(n // 2 - val_o[1])
    elif len(val_o) == 1:
        print(n // 2 - val_e[1])
    else:
        print(min(n - val_e[0] - val_o[1], n - val_e[1] - val_o[0]))
else:
    if len(val_e) == len(val_o) == 1:
        print(0)
    elif len(val_e) == 1:
        print(n // 2 - val_o[0])
    elif len(val_o) == 1:
        print(n // 2 - val_e[0])
    else:
        print(n - val_o[0] - val_e[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):
import sys

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

a1 = {}
a2 = {}
for i in range(n) :
  a = v[i]
  if i%2 == 0 :
    if a in a1 :
      a1[a] += 1
    else :
      a1[a] = 1
  else :
    if a in a2 :
      a2[a] += 1
    else :
      a2[a] = 1

a1_s = sorted(a1.items(), key = lambda x : x[1], reverse = True)
a2_s = sorted(a2.items(), key = lambda x : x[1], reverse = True)

ans = n
for i in range(2) :
  for j in range(2) :
    if a1_s[i][0] == a2_s[j][0] :
      continue
    ans = min(ans,n-a1_s[i][1]-a2_s[j][1])
    
print(ans)

import sys

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

a1 = {}
a2 = {}
for i in range(n) :
  a = v[i]
  if i%2 == 0 :
    if a in a1 :
      a1[a] += 1
    else :
      a1[a] = 1
  else :
    if a in a2 :
      a2[a] += 1
    else :
      a2[a] = 1

a1_s = sorted(a1.items(), key = lambda x : x[1], reverse = True)
a2_s = sorted(a2.items(), key = lambda x : x[1], reverse = True)

ans = n
for i in range(min(2,len(a1_s))) :
  for j in range(min(2,len(a2_s))) :
    if a1_s[i][0] == a2_s[j][0] :
      continue
    ans = min(ans,n-a1_s[i][1]-a2_s[j][1])

if len(a1_s) == 1 and len(a2_s) == 1 and ans == n :
  ans = n//2

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

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).most_common(2)
count2 = collections.Counter(v2).most_common(2)

if count1[0][0] != count2[0][0]:
    res = len(v1) - max(count1.values()) + len(v2) - max(count2.values())
    print(res)
else:
    if len(count1) == 1:
        print(len(v1))
    else:
        res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]
        res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]
        print(min(res1,res2))


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).most_common(2)
count2 = collections.Counter(v2).most_common(2)

if max(count1.values()) != max(count2.values()):
    res = len(v1) - max(count1.values()) + len(v2) - max(count2.values())
    print(res)
else:
    if len(count1) == 1:
        print(len(v1))
    else:
        res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]
        res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]
        print(min(res1,res2))


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).most_common(2)
count2 = collections.Counter(v2).most_common(2)

if count1[0][0] != count2[0][0]:
    res = len(v1) - count1[0][0] + len(v2) - count2[0][0]
    print(res)
else:
    if len(count1) == 1:
        print(len(v1))
    else:
        res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]
        res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]
        print(min(res1,res2))


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).most_common(2)
count2 = collections.Counter(v2).most_common(2)

if count1[0][0] != count2[0][0]:
    res = len(v1) - count1[0][1] + len(v2) - count2[0][1]
    print(res)
else:
    if len(count1) == 1:
        print(len(v1))
    else:
        res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]
        res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]
        print(min(res1,res2))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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()))
freq_odd = [0] * (10 ** 5 + 1)
freq_even = [0] * (10 ** 5 + 1)
for i in range(n // 2):
    freq_odd[v[2 * i]] += 1
    freq_even[v[2 * i + 1]] += 1
# print(freq_odd[:10], freq_even[:10])
freq_even, id_even = zip(*sorted(zip(freq_even, range(10 ** 5 + 1))))
freq_odd, id_odd = zip(*sorted(zip(freq_odd, range(10 ** 5 + 1))))
# print(freq_odd[-2:], freq_even[-2:])
print(id_even[-1], id_odd[-1])
if id_even[-1] != id_odd[-1]:
    print(n - freq_even[-1] - freq_odd[-1])
else:
    print(min(n - freq_even[-2] - freq_odd[-1], n - freq_even[-1] - freq_odd[-2]))


n = int(input())
v = list(map(int, input().split()))
freq_odd = [0] * (10 ** 5 + 1)
freq_even = [0] * (10 ** 5 + 1)
for i in range(n // 2):
    freq_odd[v[2 * i]] += 1
    freq_even[v[2 * i + 1]] += 1
# print(freq_odd[:10], freq_even[:10])
freq_even, id_even = zip(*sorted(zip(freq_even, range(10 ** 5 + 1))))
freq_odd, id_odd = zip(*sorted(zip(freq_odd, range(10 ** 5 + 1))))
# print(freq_odd[-2:], freq_even[-2:])
# print(id_even[-1], id_odd[-1])
if id_even[-1] != id_odd[-1]:
    print(n - freq_even[-1] - freq_odd[-1])
else:
    print(min(n - freq_even[-2] - freq_odd[-1], n - freq_even[-1] - freq_odd[-2]))


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 as col
N= int(input())
A = [int(x) for x in input().split()]
a = A[::2]
print(a)
a = col.Counter(a)
b = A[1::2]
print(b)
b = col.Counter(b)
ans = 0
i = 0
j = 0
if len(a.most_common())==1 and len(b.most_common())==1 and a.most_common()[i][0]==b.most_common()[j][0]:
  print(N//2)
  exit()
while a.most_common()[i][0]==b.most_common()[j][0]:
  m=a.most_common()[i][1]
  n=b.most_common()[j][1]
  if m>n:
    j +=1
  elif m==n:
      if a.most_common()[i+1][1]>b.most_common()[j+1][1]:
        i+=1
      else:
        j +=1
  else:
    i +=1
#print(i,j,a,b)
ans += sum(a.values())+sum(b.values())-a.most_common()[i][1]-b.most_common()[j][1]
print(ans)

import collections as col
N= int(input())
A = [int(x) for x in input().split()]
a = A[::2]
a = col.Counter(a)
b = A[1::2]
b = col.Counter(b)
ans = 0
i = 0
j = 0
#while a.most_common()[i][0]!=b.most_common()[j][0]:
if a.most_common(1)[0][0]!=b.most_common(1)[0][0]:
  ans += sum(a.values())+sum(b.values)-a.most_common(1)[0][1]-b.most_common(1)[0][1]
print(ans)

import collections as col
N= int(input())
A = [int(x) for x in input().split()]
a = A[::2]

a = col.Counter(a)
b = A[1::2]

b = col.Counter(b)
ans = 0
i = 0
j = 0
if len(a.most_common())==1 and len(b.most_common())==1 and a.most_common()[i][0]==b.most_common()[j][0]:
  print(N//2)
  exit()
while a.most_common()[i][0]==b.most_common()[j][0]:
  m=a.most_common()[i][1]
  n=b.most_common()[j][1]
  if m>n:
    j +=1
  elif m==n:
      if a.most_common()[i+1][1]>b.most_common()[j+1][1]:
        i+=1
      else:
        j +=1
  else:
    i +=1
#print(i,j,a,b)
ans += sum(a.values())+sum(b.values())-a.most_common()[i][1]-b.most_common()[j][1]
print(ans)

Verdicts: Wrong Answer

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

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
print(a)
print(b)
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
  print(n-(a[0][1]+b[0][1])
else:
  print(min(n-(a[0][1]+b[1][1]),n-(a[1][1]+b[0][1])))


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

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
print(a)
print(b)
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
  print(n-(a[0][1]+b[0][1]))
else:
  print(min(n-(a[0][1]+b[1][1]),n-(a[1][1]+b[0][1])))

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

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
print(a)
print(b)
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
  print(n-(a[0][0]+b[0][0])
else:
  print(min(n-(a[0][0]+b[1][0]),n-(a[1][0]+b[0][0])))

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

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
  print(n-(a[0][1]+b[0][1]))
else:
  print(min(n-(a[0][1]+b[1][1]),n-(a[1][1]+b[0][1])))

Verdicts: Runtime Error

Wrong Answer

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 main():
    n = int(input())
    v_n = input().split(' ')
    
    gu = Counter(v_n[::2])
    ki = Counter(v_n[1::2])

    guusuu = gu.most_common()
    kisuu = ki.most_common()

    print(guusuu)
    print(kisuu)
    print('len: ', len(guusuu), ', ', len(kisuu))
    if guusuu[0][0]==kisuu[0][0]:
        if len(guusuu)==1 and len(kisuu)==1:
            print(len(gu))
        else:
            print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))
    else:
        print(n - guusuu[0][1] - kisuu[0][1])

main()


from collections import Counter


def main():
    n = int(input())
    v_n = input().split(' ')

    
    
    a_n = Counter(v_n[::2])
    a_n2 = Counter(v_n[1::2])


    # print(a_n)
    # print(a_n2)

    a_n = a_n.most_common()
    a_n2 = a_n2.most_common()



    # print(a_n)
    # print(a_n2)

    max_an = a_n[0][1]
    max_an2 = a_n2[0][1]

    # print(max_an)
    # print(max_an2)

    if len(set(a_n)) == 1:
      print(n/2 - 1)
    elif len(set(a_n2)) == 1:
      print(n/2 - 1)




main()

from collections import Counter


def main():
    n = int(input())
    v_n = input().split(' ')
    
    gu = Counter(v_n[::2])
    ki = Counter(v_n[1::2])

    guusuu = gu.most_common()
    kisuu = ki.most_common()

    print(guusuu, len(guusuu))
    print(kisuu, len(kisuu))
    
    if guusuu[0][0]==kisuu[0][0]:
        if len(guusuu)==1 and len(kisuu)==1:
            # n=4, `4 4 4 4`
            # print('----------')
            print(guusuu[0][1])
        else:
            print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))
    else:
        print(n - guusuu[0][1] - kisuu[0][1])

main()

from collections import Counter


def main():
    n = int(input())
    v_n = input().split(' ')
    
    gu = Counter(v_n[::2])
    ki = Counter(v_n[1::2])

    guusuu = gu.most_common()
    kisuu = ki.most_common()

    
    
    
    if guusuu[0][0]==kisuu[0][0]:
        if len(guusuu)==1 and len(kisuu)==1:
            # n=4, `4 4 4 4`
            # print('----------')
            print(guusuu[0][1])
        else:
            print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))
    else:
        print(n - guusuu[0][1] - kisuu[0][1])

main()

Verdicts: Wrong Answer

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())
v=list(input().split(" "))
count = 0
print(v)

for i in range(0,n-2):
    if v[i]!=v[i+2]:
        v[i+2]=v[i]
        count+=1
        
    if v[i]==v[i+1]:
        count+=1
        
print(count)       

import collections
n = int(input())
v = [int(i) for i in input().split()]
kisu = []
gusu = []

kisu = v[::2]
gusu = v[1::2]

kisu_cnt = collections.Counter(kisu)
gusu_cnt = collections.Counter(gusu)

kisu_cnt = kisu_cnt.most_common(2)
gusu_cnt = gusu_cnt.most_common(2)
kisu_most  = 0
gusu_most = 0
if kisu_cnt[0][0]!=gusu_cnt[0][0]:
    print(n-kisu_cnt[0][1]-gusu_cnt[0][1])
    exit()
else:
    if len(kisu_cnt)==1 or len(gusu_cnt)==1:
        print(n//2)
        exit()
    else:
        print(n-max(kisu_cnt[0][1]+gusu_cnt[1][1],kisu_cnt[1][1]+gusu_cnt[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()))
    odd = V[1::2]
    even = V[0::2]
    mode_o = Counter(odd).most_common()
    mode_o.append([0,0])
    mode_e = Counter(even).most_common()
    mode_e.append([0,0])
    ans = 0
    if mode_o[0][0] != mode_e[0][0]:
        ans = N-mode_o[0][1]-mode_e[0][1]
    else:
        if mode_e[0][1] < mode_o[0][1]:
            ans = N - mode_e[0][1] - mode_o[1][1]
        else:
            ans = N - mode_e[1][1] - mode_o[0][1]
    
    print(ans)

from collections import Counter

def main():
    
    N = int(input())
    V = list(map(int,input().split()))
    odd = V[1::2]
    even = V[0::2]
    mode_o = Counter(odd).most_common()
    mode_o.append([0,0])
    mode_e = Counter(even).most_common()
    mode_e.append([0,0])
    ans = 0
    if mode_o[0][0] != mode_e[0][0]:
        ans = N-mode_o[0][1]-mode_e[0][1]
    else:
        ans = N - max(mode_e[0][1]+mode_o[1][1],mode_e[1][1]+mode_o[0][1])
    print(ans)

if __name__ == "__main__":
    main()

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

x = Counter(v[::2])
y = Counter(v[1::2])

ans = n
if len(x) > 1:
  ans -= x.most_common(1)[0][1]
if len(y) > 1:
  ans -= y.most_common(1)[0][1]
print(ans)

from collections import Counter

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

x = Counter(v[::2]).most_common(2)
y = Counter(v[1::2]).most_common(2)
ans = n
if x[0][0] == y[0][0]:
  if len(x) == len(y) == 1:
    ans = n//2
  else:
    s = max([a[1] for a in x]) + min([b[1] for b in y])
    t = min([a[1] for a in x]) + max([b[1] for b in y])
    ans -= max(s, t)
else:
  ans -= x[0][1] + y[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())
l = list(map(int,input().split()))

from collections import Counter
l1 = Counter(l[0::2])
mostl1 = l1.most_common()[0]
semimostl1 = l1.most_common()[1]

l2 = Counter(l[1::2])
mostl2 = l2.most_common()[0]
semimostl2 = l2.most_common()[1]

if mostl1[0] != mostl2[0]:
    print(n-mostl1[1]-mostl2[1])
#elif print(min(n-mostl1[1]-mostl2[1],n-mostl1[1]-mostl2[1]))

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

from collections import Counter
l1 = Counter(l[0::2])
mostl1 = l1.most_common()[0]


l2 = Counter(l[1::2])
mostl2 = l2.most_common()[0]


if mostl1[0] != mostl2[0]:
    print(n-mostl1[1]-mostl2[1])
elif len(l1.keys()) == 1 and len(l2.keys()) == 1:
    print(int(n/2))

else:
    semimostl1 = l1.most_common()[1]
    semimostl2 = l2.most_common()[1]
    print(min(n - mostl1[1] - semimostl2[1], n - semimostl1[1] - mostl2[1]))


#elif print(min(n-mostl1[1]-mostl2[1],n-mostl1[1]-mostl2[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 defaultdict
dic1=defaultdict(int)
dic2=defaultdict(int)
n=int(input())
l=list(map(int,input().split()))
if n%2==0:
  for i in range(0,n-1,2):
    dic1[l[i]]+=1
  for i in range(1,n,2):
    dic2[l[i]]+=1
  max11=0
  i1=0
  max12=0
  i2=0
  max21=0
  i3=0
  max22=0
  i4=0
  for i in dic1:
    if dic1[i]>max11:
      max12=max11
      max11=dic1[i]
      i2=i1
      i1=i
    elif dic1[i]>max12:
      max12=dic1[i]
      i2=i
  for i in dic1:
    if dic1[i]>max11:
      max12=max11
      max11=dic1[i]
      i4=i3
      i3=i
    elif dic1[i]>max12:
      max12=dic1[i]
      i4=i
  if i1!=i3:
    print(n-max11-max21)
  elif l1==l3:
    print(min(n-max11-max22,n-max21-max12))

    
    
  

from collections import defaultdict
dic1=defaultdict(int)
dic2=defaultdict(int)
n=int(input())
l=list(map(int,input().split()))
for i in range(0,n-1,2):
  dic1[l[i]]+=1
for i in range(1,n,2):
  dic2[l[i]]+=1
max11=0
i1=0
max12=0
i2=0
max21=0
i3=0
max22=0
i4=0
for i in dic1:
  if dic1[i]>=max11:
    max12=max11
    max11=dic1[i]
    i2=i1
    i1=i
  elif dic1[i]>max12:
    max12=dic1[i]
    i2=i
for i in dic2:
  if dic2[i]>=max21:
    max22=max21
    max21=dic2[i]
    i4=i3
    i3=i
  elif dic2[i]>max22:
    max22=dic2[i]
    i4=i
if i1!=i3:
  print(n-max11-max21)
elif i1==i3:
  print(min(n-max11-max22,n-max21-max12))

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 = 12
v = list(map(int, '1 1 1 1 2 2 2 2 2 2 3 3'.split()))

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
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])))

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

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
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])))

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()))
a=[]
b=[]
for i in range(0,n,1):
  a.append(v[i])
  b.append(v[i+1])
c=collections.Counter(a)
d=collections.Counter(b)
C=sorted(c.items(), key=lambda x:-x[1])
D=sorted(d.items(), key=lambda x:-x[1])
A=int(C[0][0])
B=int(D[0][0])
cnt=0
for i in range(n):
  if a[i]!=A:
    cnt+=1
for j in range(n):
  if b[j]!=B:
    cnt+=1
print(cnt)

    





import collections
n=int(input())
v=list(map(int,input().split()))
a=[]
b=[]
for i in range(0,n,1):
  a.append(v[i-1])
  b.append(v[i])
c=collections.Counter(a)
d=collections.Counter(b)
C=sorted(c.items(), key=lambda x:-x[1])
D=sorted(d.items(), key=lambda x:-x[1])
A=int(C[0][0])
B=int(D[0][0])
cnt=0
for i in range(n//2):
  if a[i]!=A:
    cnt+=1
for j in range(n//2):
  if b[j]!=B:
    cnt+=1
print(cnt)

    





import collections,sys
n=int(input())
v=list(map(int,input().split()))
a=[]
b=[]
for i in range(0,n,2):
  a.append(v[i-1])
  b.append(v[i])
c=collections.Counter(a)
d=collections.Counter(b)
C=sorted(c.items(), key=lambda x:-x[1])
D=sorted(d.items(), key=lambda x:-x[1])
A=int(C[0][0])
B=int(D[0][0])
cnt=0
if len(set(v))==1:
  print(n//2)
  sys.exit()
if A!=B:
  for i in range(n//2):
    if a[i]!=A:
      cnt+=1
  for j in range(n//2):
    if b[j]!=B:
      cnt+=1
  print(cnt)
  sys.exit()
if A==B:
  totla=0
  A_=int(C[1][0]) if len(set(a))!=1 else A
  for i in range(n//2):
    if a[i]!=A_:
      totla+=1
  for j in range(n//2):
    if b[j]!=B:
      totla+=1
  totlb=0
  B_=int(D[1][0]) if len(set(b))!=1 else B
  for i in range(n//2):
    if a[i]!=A:
      totlb+=1
  for j in range(n//2):
    if b[j]!=B_:
      totlb+=1
  print(min(totla,totlb))
  sys.exit()
  
  
  
  
    
    
    

    





Verdicts: Runtime Error

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

l0 = l[::2]
l1 = l[1::2]

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

memo0.append([0, -1])
memo1.append([0, -1])

print(memo0)
print(memo1)

if memo0[0][1]!=memo1[0][1]:
    print(n-memo0[0][0]-memo1[0][0])
else:
    ans1 = n- memo0[0][0]-memo1[1][0]
    ans2 = n- memo0[1][0]-memo1[0][0]
    print(min(ans1, ans2))

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

l0 = l[::2]
l1 = l[1::2]

l0.sort()
l1.sort()

# print(l0)
# print(l1)

memo0 = [[1, l0[0]]]
memo1 = [[1, l1[0]]]
for i in range(1, n//2):
    if memo0[-1][1] == l0[i]:
        memo0[-1][0] += 1
    else:
        memo0.append([1, l0[i]])

    if memo1[-1][1] == l1[i]:
        memo1[-1][0] += 1
    else:
        memo1.append([1, l1[i]])

memo0.sort(reverse=True)
memo1.sort(reverse=True)

memo0.append([0, -1])
memo1.append([0, -1])

# print(memo0)
# print(memo1)

if memo0[0][1]!=memo1[0][1]:
    print(n-memo0[0][0]-memo1[0][0])
else:
    ans1 = n- memo0[0][0]-memo1[1][0]
    ans2 = n- memo0[1][0]-memo1[0][0]
    print(min(ans1, ans2))

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()))
x = len(set(V))
if x == 1:
    print(n // 2)
else:
    V = Counter(V)
    a, b = V.most_common(2)
    a = a[1]
    b = b[1]
    if x == 2:
        y = abs(a - b)
        if y <= 1:
            print(0)
        else:
            print(y)
    else:
        print(n - a - b + max(a, b) - min(a, b) + 1)

from collections import Counter
n = int(input())
V = list(map(int, input().split()))
x = len(set(V))
if x == 1:
    print(n // 2)
else:
    A = list()
    B = list()
    for i, v in enumerate(V):
        if i & 1:
            A.append(v)
        else:
            B.append(v)
    A = Counter(A).most_common()
    B = Counter(B).most_common()
    a = A[0]
    b = B[0]
    if a[0] == b[0]:
        if len(A) == 1:
            b = B[1]
        elif len(B) == 1:
            a = A[1]
        else:
            if A[1][1] >= B[1][1]:
                a = A[1]
            else:
                b = B[1]
    print(n - a[1] - b[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):
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
a = ai()
if all(i == a[0] for i in a):
    print(n//2)
    exit()

a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c1 = Counter(a1)
c2 = Counter(a2)
m1 = c1.most_common(2)
m2 = c2.most_common(2)
if m1[0][0] == m2[0][0]:
    if len(c1) == 1:
        print(n-m1[0][1]-m2[1][1])
    elif len(c2) == 1:
        print(n - m1[0][1] - m2[1][1])
    else:
        print(min(n-m1[0][1]-m2[1][1], n-m1[1][1]-m2[0][1]))
else:
    print(n-m1[0

ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
a = ai()
if all(i == a[0] for i in a):
    print(n//2)
    exit()

a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c1 = Counter(a1)
c2 = Counter(a2)
m1 = c1.most_common(2)
m2 = c2.most_common(2)
if m1[0][0] == m2[0][0]:
    if len(c1) == 1:
        print(n-m1[0][1]-m2[1][1])
    elif len(c2) == 1:
        print(n - m1[0][1] - m2[1][1])
    else:
        print(min(n-m1[0][1]-m2[1][1], n-m1[1][1]-m2[0][1]))
else:
    print(n-m1[0][1] - m2[0][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):
a = int(input())
b = list(map(int, input().split()))
c = []
for i in range(a):
    d = False
    for j in range(0, len(c)):
        if c[j][0] == b[i]:
            c[j][1] += 1
            d = True
            break
    if not d:
        c.append([b[i], 1])
c = sorted(c, key=lambda x: x[0], reverse=True)
print("test")
exit()
if len(c) <= 1:
    print(a // 2)
else:
    e = [c[0][0], c[1][0]] + b
    f = [c[1][0], c[0][0]] + b
    ec = 0
    fc = 0
    for i in range(2, len(e)):
        if e[i] != e[i-2]:
            e[i] = e[i-2]
            ec += 1
        if f[i] != f[i-2]:
            f[i] = f[i-2]
            fc += 1
    print(min(ec, fc))


a = int(input())
b = list(map(int, input().split()))
c = {}
for i in range(a):
    if str(b[i]) in c:
        c[str(b[i])] += 1
    else:
        c[str(b[i])] = 1
c = sorted(c.items(), key=lambda x: x[1], reverse=True)
if len(c) <= 1:
    print(a // 2)
elif len(c) == 2:
    e = [int(c[0][0]), int(c[1][0])] + b
    f = [int(c[1][0]), int(c[0][0])] + b
    ec = 0
    fc = 0
    for i in range(2, len(e)):
        if e[i] != e[i-2]:
            e[i] = e[i-2]
            ec += 1
        if f[i] != f[i-2]:
            f[i] = f[i-2]
            fc += 1
    print(min(ec, fc))
elif len(c) >= 3:
    e = [int(c[0][0]), int(c[1][0])] + b
    f = [int(c[1][0]), int(c[0][0])] + b
    g = [int(c[0][0]), int(c[2][0])] + b
    h = [int(c[1][0]), int(c[2][0])] + b
    j = [int(c[2][0]), int(c[0][0])] + b
    k = [int(c[2][0]), int(c[1][0])] + b

    ec = 0
    fc = 0
    gc = 0
    hc = 0
    jc = 0
    kc = 0
    for i in range(2, len(e)):
        if e[i] != e[i-2]:
            e[i] = e[i-2]
            ec += 1
        if f[i] != f[i-2]:
            f[i] = f[i-2]
            fc += 1
        if g[i] != g[i-2]:
            g[i] = g[i-2]
            gc += 1
        if h[i] != h[i-2]:
            h[i] = h[i-2]
            hc += 1
        if j[i] != j[i-2]:
            j[i] = j[i-2]
            jc += 1
        if k[i] != k[i-2]:
            k[i] = k[i-2]
            kc += 1
    print(min(ec, fc, gc, hc, jc, kc))


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())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
  if i%2==0:
    o.append(a[i])
  else:
    e.append(a[i])
from collections import Counter as co
o=co(o)
e=co(e)
o['x']=0
e['x']=0
ov=o.values()+[0]
ev=e.values()+[0]
mo=max(ov)
me=max(ev)
if n==2:
  if a[0]==a[1]:
    print(1)
  else:
    print(0)
else:
  if max(o,key=o.get)==max(e,key=e.get):
    if mo>me:
      me=sorted(ev)[-2]
    else:
      mo=sorted(ov)[-2]
  print(n-mo-me)

n=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
  if i%2==0:
    o.append(a[i])
  else:
    e.append(a[i])
from collections import Counter as co
o=co(o)
e=co(e)
ov=o.values()+[0]
ev=e.values()+[0]
mo=max(ov)
me=max(ev)
if n==2:
  if a[0]==a[1]:
    print(1)
  else:
    print(0)
else:
  if max(o,key=o.get)==max(e,key=e.get):
    if mo>me:
      me=sorted(ev)[-2]
    else:
      mo=sorted(ov)[-2]
  print(n-mo-me)

n=int(input())
a=list(map(int,input().split()))
o=[]
e=[]
for i in range(n):
  if i%2==0:
    o.append(a[i])
  else:
    e.append(a[i])
from collections import Counter as co
o=co(o)
e=co(e)
o['x']=0
e['x']=0
ov=o.values()
ev=e.values()
mo=max(ov)
me=max(ev)
if n==2:
  if a[0]==a[1]:
    print(1)
  else:
    print(0)
else:
  if max(o,key=o.get)==max(e,key=e.get):
    if mo>me:
      me=sorted(ev)[-2]
    elif mo<me:
      mo=sorted(ov)[-2]
    else:
      mo=max(sorted(ev)[-2],sorted(ov)[-2])
  print(n-mo-me)

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):
import numpy as np
n = int(input())
As = input().split()
As = [int(A) for A in As]
# n=4
# As = [3,1,3,2,4,3,1,1]
# As = [1,1,1,2,1,1,1,1]

# print(As)
A_odd = As[::2]         
A_even = As[1:][::2]    

print(A_odd,A_even)

def num_pair(l):
    counts_pair = []
    for i in set(l):
        counts_pair.append([i,l.count(i)])
    odd = np.array(counts_pair)
    return odd[odd[:,1].argsort()[::-1],:]

odd_pair = num_pair(A_odd)
even_pair = num_pair(A_even)


if odd_pair[0][0] != even_pair[0][0]:
    print(n-odd_pair[0][1]-even_pair[0][1])
else:
    if len(odd_pair) == 1 and len(even_pair) == 1:
        print(n/2)
    elif len(odd_pair) == 1:
        print(n-even_pair[1][1])
    elif len(even_pair) == 1:
        print(n-odd_pair[1][1]) 
    elif odd_pair[1][1] > even_pair[1][1]:
        print(n-even_pair[0][1]-odd_pair[1][1])
    else:
        print(n-odd_pair[0][1]-odd_pair[1][1])


import numpy as np
from collections import Counter
n = int(input())
As = input().split()
As = [int(A) for A in As]

A_odd = As[::2]         
A_even = As[1:][::2]    


odd_pair = Counter(A_odd).most_common(2)
even_pair = Counter(A_even).most_common(2)

if odd_pair[0][0] != even_pair[0][0]:               
    N = n-odd_pair[0][1]-even_pair[0][1]
else:                                               
    if len(odd_pair) == 1 and len(even_pair) == 1:  
        N = n/2
    elif len(odd_pair) == 1:                        
        N = n-even_pair[1][1]
    elif len(even_pair) == 1:                       
        N = n-odd_pair[1][1] 
    elif odd_pair[1][1] > even_pair[1][1]:          
        N = n-even_pair[0][1]-odd_pair[1][1]
    else:
        N = n-odd_pair[0][1]-even_pair[1][1]        
print(int(N))

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 Counter
n=int(input())
v=list(map(int,input().split()))
s1,s2=[],[]
for i in range(n):
  if i%2==0:
    s1.append(v[i])
  else:
    s2.append(v[i])
c1=Counter(s1)
c2=Counter(s2)
d1=c1.most_common()
d2=c2.most_common()
if d1[0][0]!=d2[0][0]:
  print(n-d1[0][1]-d2[0][1])
else:
  print(min(n-d1[0][1]-d2[1][1],n-d1[1][1]-d2[0][1]))

from collections import Counter
n=int(input())
v=list(map(int,input().split()))
s1,s2=[],[]
for i in range(n):
  if i%2==0:
    s1.append(v[i])
  else:
    s2.append(v[i])
c1=Counter(s1)
c2=Counter(s2)
d1=c1.most_common()
d2=c2.most_common()
if d1[0][0]!=d2[0][0]:
  print(n-d1[0][1]-d2[0][1])
else:
  if len(d1)>1 and len(d2)>1:
    print(min(n-d1[0][1]-d2[1][1],n-d1[1][1]-d2[0][1]))
  elif len(d1)==1 and len(d2)==1:
    print(n//2)
  elif len(d1)==1:
    print(n//2-d2[0][1])
  else:
    print(n//2-d1[0][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):
N = int(input())
v = list(map(int,input().split()))
v_even = [0 for i in range(max(v)+1)]
v_odd = [0 for i in range(max(v))+1]
sum_even = 0
sum_odd = 0
for i in range(N):
    if i%2 :
        v_odd[v[i]] += 1
        sum_odd += 1
    else:
        v_even[v[i]] += 1
        sum_even += 1
max_odd = 0
odd = 0
max_even = 0
even = 0
for i in range(len(v_odd)):
    if v_odd[i] > max_odd:
        max_odd = v_odd[i]
        odd = i

for i in range(len(v_even)):
    if v_even[i] > max_even:
        max_even = v_even[i]
        even = i

if odd != even:
    ans = sum_even - max_even + sum_odd - max_odd
else:
    v_odd[odd] = 0
    v_even[even] = 0
    ans = min((sum_even - max_even + sum_odd - max(v_odd)), sum_even - max(v_even) + sum_odd - max_odd)

print(ans)

N = int(input())
v = list(map(int,input().split()))
v_even = [0 for i in range(max(v)+1)]
v_odd = [0 for i in range(max(v)+1)]
sum_even = 0
sum_odd = 0
for i in range(N):
    if i%2 :
        v_odd[v[i]] += 1
        sum_odd += 1
    else:
        v_even[v[i]] += 1
        sum_even += 1
max_odd = 0
odd = 0
max_even = 0
even = 0
for i in range(len(v_odd)):
    if v_odd[i] > max_odd:
        max_odd = v_odd[i]
        odd = i

for i in range(len(v_even)):
    if v_even[i] > max_even:
        max_even = v_even[i]
        even = i

if odd != even:
    ans = sum_even - max_even + sum_odd - max_odd
else:
    v_odd[odd] = 0
    v_even[even] = 0
    ans = min((sum_even - max_even + sum_odd - max(v_odd)), sum_even - max(v_even) + sum_odd - max_odd)

print(ans)


Verdicts: Runtime Error

Accepted