TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
a = int(input()))
b = int(a /100)
if a > (100b + 10b +b -1):
    print(100(b+1) + 10(b+1) +b +1)
else:
    print(100b + 10b + b)

a = int(input())
b = int(a /100)
if a > (100*b + 10*b +b -1):
    print(100*(b+1) + 10*(b+1) +b +1)
else:
    print(100*b + 10*b + b)

a = int(input())
b = int(a /100)
if a > (100*b + 10*b +b ):
    print(100*(b+1) + 10*(b+1) +b +1)
else:
    print(100*b + 10*b + b)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n=int(input())
print(1111 if n==999 else 111*(n//111) if n<111*(n//111) else 111*(n//111+1))

n=int(input())
print(111*(n//111) if n<=111*(n//111) else 111*(n//111+1))

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
data = input()

sc = 0
ans = []
if (data[0] == data[1]) & (data[0] == data[2]):
    data = int(data)
    print(*data)
elif int(data[0]) > int(data[1]):
    sc = int(data[0])
    ans = 100 * sc + 10 * sc + sc
    print(ans)
else:
    sc = int(data[0]) + 1
    ans = 100* sc + 10 * sc + sc
    print(ans)


    
    


data = input()

sc = 0
ans = []
if (data[0] == data[1]) & (data[0] == data[2]):
    data = int(data)
    print(data)
elif int(data[0]) > int(data[1]):
    sc = int(data[0])
    ans = 100 * sc + 10 * sc + sc
    print(ans)
elif int(data[0]) == int(data[1]):
    if int(data[1]) > int(data[2]):
        sc = int(data[0])
        ans = sc * 100 + sc * 10 + sc
        print(ans)
    else :
        sc = int(data[0]) + 1
        ans = 100* sc + 10 * sc + sc
        print(ans)


        
else:
    sc = int(data[0]) + 1
    ans = 100* sc + 10 * sc + sc
    print(ans)


    
    


Verdicts: Runtime Error

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
N=int(input())
a = N//100+N//100*10+N//100
b = (N//100+1)*100+(N//100+1)*10+(N//100+1)
print(a*(N<=a)+b*(N>a))

N=int(input())
a = N//100*100+N//100*10+N//100
b = (N//100+1)*100+(N//100+1)*10+(N//100+1)
print(a*(N<=a)+b*(N>a))

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
N = int(input())

if(N%111 == 0):
  N += 1
else:
  print(((N // 111) + 1) * 111)


N = int(input())
if N%111 == 0:
  print(N)
else:
  print(111*(N//111+1))

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
N = int(input())
s = int(N / 111)

x = (s + 1) * 111
print(x)

N = int(input())
s = int((N - 1) / 111)

x = (s + 1) * 111
print(x)

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = int(input())
t = n//100
t*=111
if t>n:
  print(t)
else:
  print(t+111)

n = int(input())
t = n//100
t*=111
if t>=n:
  print(t)
else:
  print(t+111)

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
from math import ceil


n = int(input())
print(111 * ceil(n // 111)
      

n = int(input())
m = n // 100

if m == 1:
  print(222)
elif m == 2:
  print(333)
elif m == 3:
  print(444)
elif m == 4:
  print(555)
elif m == 5:
  print(666)
elif m == 6:
  print(777)
elif m == 7:
  print(888)
elif m == 8:
  print(999)
else:
  print(1111)
 

import math


n = int(input())
print(111 * math.ceil(n / 111)
      

from math import ceil


n = int(input())
print(111 * ceil(n / 111)
      

import math


n = int(input())
print(111 * math.ceil(n / 111))

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
N = int(input())
if N % 111 == 0:
  print(N)
for i in range(10):
  if N // 111 == i:
    print(111 * (i + 1) )

N = int(input())
if N % 111 == 0:
  print(N)
for i in range(10):
  if N // 111 = i:
    print(111 * (i + 1) )

N = int(input())
if N % 111 == 0:
  print(N)
for i in range(10):
  if N % 111 != 0 and N // 111 == i:
    print(111 * (i + 1) )

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n=int(input())
a=[int(str(i)*3)-n for i in range(1,10)]
print(a)
ans=[j for j in a if j>=0]
print(n+min(ans))

n=int(input())
a=[int(str(i)*3)-n for i in range(1,10)]
ans=[j for j in a if j>=0]
print(n+min(ans))

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
N = int(input())
a = int(N/111)
print(111*(a+1))


N = int(input())
a = int((N-1)/111)
print(111*(a+1))

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = int(input())
a =  n // 100
if n%10 > a:
    for _ in range(3):
        print(a,end="")
elif n%10 == a:
    for _ in range(3):
        print(a,end="")
else:
    for _ in range(3):
        print(a+1,end="")

n = int(input())
a =  n // 100
if n%10 > a:
    for _ in range(3):
        print(a+1,end="")
elif n%10 == a:
    for _ in range(3):
        print(a,end="")
else:
    for _ in range(3):
        print(a,end="")

n = int(input())
x = 111
for i in range(2,10):
    if n <= x:
        print(x)
        exit()
    x = 111*i
print(x)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = int(input())
ans = 0
for i in range(9):
  j = i+1
  a = 100*j + 10*j + j
  if n < a:
    ans = a
    break
  if n > a:
    k = j+1
    b = 100*k + 10*k + k
    if n < b:
      ans = b
      break
print(ans)

n = int(input())
ans = 0
for i in range(9):
  j = i+1
  a = 100*j + 10*j + j
  if n <= a:
    ans = a
    break
  if n > a:
    k = j+1
    b = 100*k + 10*k + k
    if n < b:
      ans = b
      break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n=int(input())
while True:
    n+=1
    if len(set(str(n)))==1:
        print(n)
        break
    


n=int(input())
if len(set(str(n)))==1:
    print(n)
else:

    while True:
        n+=1
        if len(set(str(n)))==1:
            print(n)
            break
  


Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = int(input())

t = 0
    
while t*111 < n < (t+1)*111:
    t += 1
    
print(t*111)

n = int(input())

t = 0
    
while t*111 <= n  and n >= (t+1)*111:
    t += 1
    
print((t+1)*111)

n = int(input())

t = 0
    
while t*111 < n  and n > (t+1)*111:
    t += 1
    
print((t+1)*111)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n=int(input())
for count in range(10):
    if 100*count+10*count+count>n-1:
        input(100*count+10*count+count)
        break
    else:
        pass

n=int(input())
for count in range(10):
    if 100*count+10*count+count>n-1:
        print(100*count+10*count+count)
        break
    else:
        pass

Verdicts: Runtime Error

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = int(input())
for i in range(111,999,111):
    if i< n < i+111:
        ans = i + 111
        break
print(int(ans))


n = int(input())
for i in range(111,999,111):
    if i<= n <= i+111:
        ans = i + 111
        break
    else:
      ans = 1111
print(int(ans))

n = int(input())
for i in range(111,999,111):
    if i<= n < i+111:
        ans = i + 111
        break
    else:
      ans = 1111
print(int(ans))

n = int(input())
if (n % 111) == 0:
	ans = (n // 111) * 111
else:
	ans = (n // 111 +1) * 111
print(int(ans))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = int(input())
while n % 111 == 0:
  n += 1
print(n)

n = int(input())
while n % 111 != 0:
  n += 1
print(n)

Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = input()
for i in range(int(n), 1000):
  if i.count(n[0]) == 3:
    print(i)
    exit()

n = input()
for i in range(int(n), 1000):
  if str(i).count(str(i)[0]) == 3:
    print(i)
    exit()

Verdicts: Runtime Error

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = int(input())
while n % 111 != 0:
    x = n+1
    n += 1
print(x)

n = int(input())
if n % 111 == 0:
    x = n
while n % 111 != 0:
    x = n+1
    n += 1

print(x)

Verdicts: Runtime Error

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
n = int(input())
print((n // 111 + 1) * 111)


n = int(input())
if n % 111 == 0:
  print(n)
else:
  print((n // 111 + 1) * 111)


Verdicts: Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
s = input()
if int(s[0])>int(s[1]) & int(s[0])>int(s[2]):
    print(int(s[0])*111)
else:
    print((int(s[0])+1)*111)


x=input()
if int(x[0])>int(x[1]):
  if int(x[0])>int(x[2]):
    print(int(x[0])*111)
  else:
    print((int(x[0])+1)*111)
else:
  print((int(x[0])+1)*111)

s = input()
if int(s[0])>=int(s[1]) and int(s[0])>=int(s[2]):
    print(int(s[0])*111)
else:
    print((int(s[0])+1)*111)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
for i in range(int(input()), 100):
  if(str(i)[0] == str(i)[1] and str(i)[1] == str(i)[2]):
    print(i)
    break

n = int(input())

for i in range(n,1000):
 if i % 111 == 0:
  print(i)

n = int(input())
 
for i in range(n,1000):
 if i % 111 == 0:
  print(i)
  break

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Kurohashi has never participated in AtCoder Beginner Contest (ABC).  The next ABC to be held is ABC N (the N-th ABC ever held). Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.  What is the earliest ABC where Kurohashi can make his debut?

Submission attempts (in order):
print((1+(int(input()-1)//111))*111)

print((1+((int(input())-1))//111)*111)

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())
values = [int(i) for i in input().split()]

odd = []  
even = []  # gusu

for n, i in enumerate(values):
    if (n + 1) % 2 == 0:
        even.append(i)
    else:
        odd.append(i)

odd_counts = collections.Counter(odd)
even_counts = collections.Counter(even)

odd_replace_num = n - odd_counts.most_common()[0][1]
even_replace_num = n - even_counts.most_common()[0][1]

print(odd_replace_num + even_replace_num)


import collections

num = int(input())
values = [int(i) for i in input().split()]

odd = []  
even = []  # gusu

for n, i in enumerate(values):
    if (n + 1) % 2 == 0:
        even.append(i)
    else:
        odd.append(i)

odd_counts = collections.Counter(odd)
even_counts = collections.Counter(even)

# print(odd_counts.most_common())
# print(even_counts.most_common())

odd_most_common = odd_counts.most_common()
even_most_common = even_counts.most_common()

half_num = int(num / 2)

if odd_most_common[0][0] != even_most_common[0][0]:
    odd_replace_num = half_num - odd_most_common[0][1]
    even_replace_num = half_num - even_most_common[0][1]
    print(odd_replace_num + even_replace_num)
else:
    answers = []
    odd_replace_num = half_num - odd_most_common[0][1]
    if len(even_most_common) == 1:
        even_replace_num = half_num
    else:
        even_replace_num = half_num - even_most_common[1][1]
    answers.append(odd_replace_num + even_replace_num)

    if len(odd_most_common) == 1:
        odd_replace_num = half_num
    else:
        odd_replace_num = half_num - odd_most_common[1][1]
    even_replace_num = half_num - even_most_common[0][1]
    answers.append(odd_replace_num + even_replace_num)

    print(min(answers))


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 itertools

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []
A, B = [[-1, 0], [-1, 0]]

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

L = itertools.groupby(L)
for key, group in L:
    A.append([key, len(list(group))])

A.sort(key=lambda x:x[1], reverse=True)

R = itertools.groupby(R)
for key, group in R:
    B.append([key, len(list(group))])

B.sort(key=lambda x:x[1], reverse=True)

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())
list_A = list(map(int, input().split()))
L, R = [], []

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

A = Counter(L)
A = sorted(A.items(), key=lambda x:x[1], reverse=True)
A.append((-1, 0))

B = Counter(R)
B = sorted(B.items(), key=lambda x:x[1], reverse=True)
B.append((-1, 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: 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()))
ans1=[0]*(10**5+1)
ans2=[0]*(10**5+1)
for i in v[0::2]:
  ans1[i]+=1
for i in v[1::2]:
  ans2[i]+=1
m1=max(ans1)
m2=max(ans2)
flag=False
for i in range(10**5+1):
  if ans1[i]==m1 and ans2[i]==m2:
    flag=True
    ans1.sort()
    ans2.sort()
    m12=ans1[-2]
    m22=ans2[-2]
    break
print(m1,m12,m2,m22)
if len(set(v))==1:
  print(n//2)
elif flag==True:
  print(n-max(m12+m2,m1+m22))
else:
  print(n-m1-m2)

n=int(input())
v=list(map(int,input().split()))
ans1=[0]*(10**5+1)
ans2=[0]*(10**5+1)
for i in v[0::2]:
  ans1[i]+=1
for i in v[1::2]:
  ans2[i]+=1
m1=max(ans1)
m2=max(ans2)
flag=False
for i in range(10**5+2):
  if ans1[i]==m1 and ans2[i]==m2:
    falg=True
    ans1.sort()
    ans2.sort()
    m12=ans1[-2]
    m22=ans2[-2]
    break
if len(set(v))==1:
  print(n//2)
elif flag:
  print(n-max(m12+m1,m21+m2))
else:
  print(n-m1-m2)

n=int(input())
v=list(map(int,input().split()))
ans1=[0]*(10**5+1)
ans2=[0]*(10**5+1)
for i in v[0::2]:
  ans1[i]+=1
for i in v[1::2]:
  ans2[i]+=1
m1=max(ans1)
m2=max(ans2)
flag=False
for i in range(10**5+1):
  if ans1[i]==m1 and ans2[i]==m2:
    flag=True
    ans1.sort()
    ans2.sort()
    m12=ans1[-2]
    m22=ans2[-2]
    break
if len(set(v))==1:
  print(n//2)
elif flag==True:
  print(n-max(m12+m2,m1+m22))
else:
  print(n-m1-m2)

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())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(n // 2)
    exit()
kisu = v[::2]
gusu = v[1::2]
kisu_color = list(Counter(kisu).items())[:2]
gusu_color = list(Counter(gusu).items())[:2]
print(kisu_color)
print(gusu_color)
if kisu_color[0][0] != gusu_color[0][0]:
    ans = n - kisu_color[0][1] - gusu_color[0][1]
else:
    ans = min(n - kisu_color[0][1] - gusu_color[1][1], n - kisu_color[1][1] - gusu_color[0][1])
print(ans)

from collections import Counter
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(n // 2)
    exit()
kisu = v[::2]
gusu = v[1::2]
kisu_color = Counter(kisu).most_common()[:2]
gusu_color = Counter(gusu).most_common()[:2]
if kisu_color[0][0] != gusu_color[0][0]:
    ans = n - kisu_color[0][1] - gusu_color[0][1]
else:
    ans = min(n - kisu_color[0][1] - gusu_color[1][1], n - kisu_color[1][1] - gusu_color[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):
from collections import Counter

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

ki = v[::2]
gu = v[1::2]

ki = Counter(ki)
gu = Counter(gu)

ki = ki.most_common()
gu = ki.most_common()

if ki[0][0] == gu[0][0] :
    if(len(ki) == len(gu)) :
        print(n/2)
    else :
        if(ki[1][1] > gu[1][1]) :
            print(n-ki[1][1]-gu[0][1])
        else :
            print(n-ki[0][1]- gu[1][1])

else :
    print(n-ki[0][1]-gu[0][1])

from collections import Counter

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

ki = v[::2]
gu = v[1::2]

ki = Counter(ki)
gu = Counter(gu)

ki = ki.most_common()
gu = gu.most_common()

if ki[0][0] == gu[0][0] :
    if len(ki) == 1 and len(gu) == 1 :
        print(int(n/2))
    else :
        if ki[1][1] > gu[1][1] :
            print(n-ki[1][1]-gu[0][1])
        else :
            print(n-ki[0][1]- gu[1][1])

else :
    print(n-ki[0][1]-gu[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):
import heapq
import collections
n = int(input())
v = list(map(int, input().split()))

cnts = [collections.Counter(v[::2]), collections.Counter(v[1::2])]

hs = [[], []]
for i in range(2):
    for k, c in cnts[i].items():
        heapq.heappush(hs[i], (-c, k))
h0 = heapq.heappop(hs[0])
h1 = heapq.heappop(hs[1])
if h0[1] == h1[1]:
    if not hs[0] and not hs[1]:
        print(n//2)
    elif not hs[0]:
        print(n+h1[0])
    elif not hs[1]:
        print(n+h0[0])
    else:
        n0 = heapq.heappop(hs[0])
        n1 = heapq.heappop(hs[1])
        print(n - max(-h0[0]-n1[0], -n0[0]-h1[0]))
else:
    print(n-(h0[0]+h1[0]))


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

cnts = [collections.Counter(v[::2]), collections.Counter(v[1::2])]

if cnts[0] == cnts[1]:
    print(n//2)
    exit()

hs = [[], []]
for i in range(2):
    for k, c in cnts[i].items():
        heapq.heappush(hs[i], (-c, k))
h0 = heapq.heappop(hs[0])
h1 = heapq.heappop(hs[1])
if h0[1] == h1[1]:
    if cnts[0] == cnts[1]:
        print(n//2)
        exit()
    n0 = heapq.heappop(hs[0])
    n1 = heapq.heappop(hs[1])
    print(n - max(-h0[0]-n1[0], -n0[0]-h1[0]))
else:
    print(n-(h0[0]+h1[0]))


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

cnts = [collections.Counter(v[::2]), collections.Counter(v[1::2])]

hs = [[], []]
for i in range(2):
    for k, c in cnts[i].items():
        heapq.heappush(hs[i], (-c, k))
h0 = heapq.heappop(hs[0])
h1 = heapq.heappop(hs[1])
if h0[1] == h1[1]:
    if not hs[0] and not hs[1]:
        print(n//2)
    elif not hs[0]:
        print(n+h1[0])
    elif not hs[1]:
        print(n+h0[0])
    else:
        n0 = heapq.heappop(hs[0])
        n1 = heapq.heappop(hs[1])
        print(n + min(h0[0]+n1[0], n0[0]+h1[0]))
else:
    print(n+(h0[0]+h1[0]))


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

e = Counter(v[::2])
o = Counter(v[1::2])

e = sorted([(k,v) for k, v in e.items()],key = lambda z:z[1],reverse = True) + [(0,0)]
o = sorted([(k,v) for k, v in o.items()],key = lambda z:z[1],reverse = True) + [(0,0)]

if e[0][0] != o[0][0]:
    print(n - e[0][1] - o[0][1])
else:
    print(n - max(e[0][1] + o[1][1], e[1][1] + o[0][1]))

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

e = Counter(v[::2])
o = Counter(v[1::2])

ev = sorted([(k,i) for k, i in e.items()],key = lambda z:z[1],reverse = True) + [(0,0)]
od = sorted([(k,i) for k, i in o.items()],key = lambda z:z[1],reverse = True) + [(0,0)]

if ev[0][0] != od[0][0]:
    print(n - ev[0][1] - od[0][1])
else:
    print(n - max(ev[0][1] + od[1][1], ev[1][1] + od[0][1]))
print(ev,od)

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

e = Counter(v[::2])
o = Counter(v[1::2])

e = sorted([(k,v) for k, v in e.items()],key = lambda z:z[1],reverse = True) + [(0,0)]
o = sorted([(k,v) for k, v in o.items()],key = lambda z:z[1],reverse = True) + [(0,0)]

if e[0][0] != o[0][0]:
    print(n - e[0][1] - o[0][1])
else:
    print(n - max(e[0][1] + o[1][1], e[1][1] + o[0][1]))

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

e = Counter(v[::2])
o = Counter(v[1::2])

ev = sorted([(k,i) for k, i in e.items()],key = lambda z:z[1],reverse = True) + [(0,0)]
od = sorted([(k,i) for k, i in o.items()],key = lambda z:z[1],reverse = True) + [(0,0)]

if ev[0][0] != od[0][0]:
    print(n - ev[0][1] - od[0][1])
else:
    print(n - max(ev[0][1] + od[1][1], ev[1][1] + od[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

n = int(input())
vs = input().split()
even = []
odd = []
if not even == odd:
  for i, v in enumerate(vs):
  	if i % 2 == 0:
    	even.append(int(v))
    else:
    	odd.append(int(v))
  counter_even = Counter(even)
  counter_odd = Counter(odd)

  res = len(even) - counter_even.most_common()[0][1] + len(odd) - counter_odd.most_common()[0][1] 
else:
  res = len(even)
print(res)

from collections import Counter

n = int(input())
vs = input().split()
even = []
odd = []
if not even == odd:
  for i, v in enumerate(vs):
  	if i % 2 == 0:
    	even.append(int(v))
    else:
    	odd.append(int(v))
  counter_even = Counter(even)
  counter_odd = Counter(odd)

  res = len(even) - counter_even.most_common()[0][1] + len(odd) - counter_odd.most_common()[0][1] 
else:
  res = len(even)
print(res)

from collections import Counter

n = int(input())
vs = input().split()
even = []
odd = []

if len(list(set(vs))) == 1:
  res = int(len(vs) / 2)
else:
  for i, v in enumerate(vs):
    if i % 2 == 0:
      even.append(int(v))
    else:
      odd.append(int(v))
  counter_even = Counter(even)
  counter_odd = Counter(odd)
  if counter_even.most_common()[0][0] != counter_odd.most_common()[0][0]:
    res = len(even) - counter_even.most_common()[0][1]  + len(odd) - counter_odd.most_common()[0][1]
  else:
    res1 = len(even) - counter_even.most_common()[1][1]  + len(odd) - counter_odd.most_common()[0][1]
    res2 = len(even) - counter_even.most_common()[0][1]  + len(odd) - counter_odd.most_common()[1][1]
    res = min(res1, res2)
print(res)

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(map(int, input().split()))
w = [0]*(10**5+1)
for x in v: w[x]+=1
print(n-sum(sorted(w)[:2]))

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

d1 = {0:0}
d2 = {0:0}
for i, v in enumerate(V):
    d = d2 if i&1 else d1
    if v not in d: d[v]=0
    d[v]+=1
    

d1 = sorted(list(d1.items()), key=lambda x:-x[1])
d2 = sorted(list(d2.items()), key=lambda x:-x[1])

if d1[0][0]!=d2[0][0]:
    print(N-d1[0][1]-d2[0][1])
else:
    print(min(N-d1[1][1]-d2[0][1], N-d1[0][1]-d2[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):
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

a = []
b = []
for i in range(n//2):
    a.append(v[2*i])
    b.append(v[2*i+1])

def change(list):
    counter = Counter(list)
    m_ap1, m_ap2 = counter.most_common()[0][0], counter.most_common()[1][0]
    l = len(list)
    cnt = 0
    for i in range(l):
        if list[i] != m_ap1:
            cnt1 += 1
        if list[i] != m_ap2:
            cnt2 += 1
    return cnt1, cnt2, m_ap1, m_ap2
ca1, ca2, ma1, ma2 = change(a)
cb1, cb2, mb1, mb2 = change(b)

if ca1+cb1:
    if ma1 != mb1:
        print(ca1+cb1)
    else:
        print(min(ca1+cb2,cb1+ca2))
else:
    print(n//2)


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

a = []
b = []
for i in range(n//2):
    a.append(v[2*i])
    b.append(v[2*i+1])

def change(list):
    counter = Counter(list)
    m_ap1 = '0'
    m_ap2 = '0'
    if len(counter.most_common()) > 1:
        m_ap1, m_ap2 = counter.most_common()[0][0], counter.most_common()[1][0]
    else:
        m_ap1 = counter.most_common()[0][0]
    l = len(list)
    cnt1 = 0
    cnt2 = 0
    for i in range(l):
        if list[i] != m_ap1:
            cnt1 += 1
        if list[i] != m_ap2:
            cnt2 += 1
    return cnt1, cnt2, m_ap1, m_ap2
ca1, ca2, ma1, ma2 = change(a)
cb1, cb2, mb1, mb2 = change(b)
# print(change(a))
# print(change(b))
if ca1+cb1:
    if ma1 != mb1:
        print(ca1+cb1)
    else:
        print(min(ca1+cb2,cb1+ca2))
else:
    if ma1 != mb1:
        print(ca1+cb1)
    else:
        print(n//2)


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, *v = map(int, open(0).read().split())
if v[::2] == v[1::2]:
        print(n // 2)
    else:
        print(n - Counter(v[::2]).most_common()[0][1] - Counter(v[1::2]).most_common()[0][1])


from collections import Counter

n, *v = map(int, open(0).read().split())
c1 = Counter(v[::2]).most_common()
c2 = Counter(v[1::2]).most_common()

c1.append([0, 0])
c2.append([0, 0])

if c1[0][0] != c2[0][0]:
  print(n - c1[0][1] - c2[0][1])
else:
  print(min(n - c1[0][1] - c2[1][1], n - c1[1][1] - c2[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 = list(map(int, input().strip().split(" ")))
odd = []
even = []
for i in range(len(v)):
    if(i % 2 == 0):
        even.append(v[i])
    else:
        odd.append(v[i])


c_even = Counter(even).most_common(2)
c_odd = Counter(odd).most_common(2)

print(c_even, c_odd)

if(c_even[0][0] != c_odd[0][0]):
    print(n - c_even[0][1] - c_odd[0][1])
elif(len(c_even) != 1 and len(c_odd) != 1):
    second = max[c_even[1][1], c_odd[1][1]]
    print(n - c_even[0][1] - second)
else:
    print(min([c_even[0][1], c_odd[0][1]]))

from collections import Counter
    
n = int(input())
v = list(map(int, input().split()))
odd = v[::2]
even = v[1::2]
    
c_even = Counter(even).most_common(2)
c_odd = Counter(odd).most_common(2)

print(c_even, c_odd)
    
if(c_even[0][0] != c_odd[0][0]):
    print(n - c_even[0][1] - c_odd[0][1])
elif(len(c_even) >= 2 and len(c_odd) >= 2):
    second = max[c_even[1][1], c_odd[1][1]]
    print(n - c_even[0][1] - second)
else:
    print(n//2)

from collections import Counter
    
n = int(input())
v = list(map(int, input().split()))
odd = v[::2]
even = v[1::2]
    
c_even = Counter(even).most_common(2)
c_odd = Counter(odd).most_common(2)

    
if(c_even[0][0] != c_odd[0][0]):
    print(n - c_even[0][1] - c_odd[0][1])
else:
    if(len(c_even) == 1):
        print(n//2)
    else:
        second = max([c_even[1][1], c_odd[1][1]])
        print(n - c_even[0][1] - second)

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

v1 = []
v2 = []
for i in range(0,n,2):
  v1.append(i)
for i in range(1,n,2):
  v2.append(i)
  
v1s = set(v1)
v2s = set(v2)
  
v1c = []
v2c = []
for i in list(v1s):
  v1c.append(v1.count(i))
for i in list(v2s):
  v2c.append(v2.count(i))

v1c.sort(reverse=True)
v2c.sort(reverse=True)

print(sum(v1c[1:])+sum(v2c[1:]))

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

from collections import Counter

v1 = []
v2 = []
for i in range(0,n,2):
  v1.append(i)
for i in range(1,n,2):
  v2.append(i)
  
c1 = Counter(v1)
c2 = Counter(v2)

if list(c1.keys())[0] == list(c2.keys())[0]:
  a1 = sum(list(c1.values())[1:])+list(c2.values())[0]+sum(list(c2.values()[2:]))
  a2 = sum(list(c2.values())[1:])+list(c1.values())[0]+sum(list(c1.values()[2:]))
           
  ans = min(a1,a2)
  
else:
  ans = sum(list(c1.values())[1:])+sum(list(c2.values())[1:])

print(ans)

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

from collections import Counter

v1 = []
v2 = []
for i in range(0,n-1,2):
  v1.append(V[i])
for i in range(1,n,2):
  v2.append(V[i])
  
c1 = Counter(v1).most_common() + [(0,0)]
c2 = Counter(v2).most_common() + [(0,0)]

if c1[0][0] == c2[0][0]:
  a1 = n -c1[1][1]-c2[0][1]
  a2 = n -c1[0][1]-c2[1][1]
  ans = min(a1,a2)
  
else:
  ans = n-c1[0][1]-c2[0][1]

print(ans)

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


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


if len(set(lst_v)) == 1:
    ans = n // 2
else:
    lst_odd = lst_v[::2]
    lst_even = lst_v[1::2]
    cnt_odd = sorted(Counter(lst_odd).items(), key=lambda x: -x[1])
    cnt_even = sorted(Counter(lst_even).items(), key=lambda x :-x[1])
    o1 = cnt_odd[0]
    e1 = cnt_even[0]
    o2 = cnt_odd[1] if cnt_odd[1] else (0, 0)
    e2 = cnt_even[1] if cnt_even[1] else (0, 0)

    if o1[0] == e1[0]:
        rem_number = max(o1[1] + e2[1], o2[1] + e1[1])
    else:
        rem_number = o1[1] + e1[1]
    sum_odd = sum(t[1] for t in cnt_odd)
    sum_even = sum(t[1] for t in cnt_even)
    ans = sum_odd + sum_even - rem_number


print(ans)


from collections import Counter


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


if len(set(lst_v)) == 1:
    ans = n // 2
else:
    lst_odd = [lst_v[i] for i in range(n) if i%2==0]
    lst_even = [lst_v[i] for i in range(n) if i%2!=0]
    print(lst_odd)
    print(lst_even)


    cnt_odd = list(Counter(lst_odd).values())
    cnt_even = list(Counter(lst_even).values())
    print(cnt_odd)
    print(cnt_even)

    ans = sum(cnt_odd) - max(cnt_odd) + sum(cnt_even) - max(cnt_even)


print(ans)


from collections import Counter


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


lst_o = lst_v[::2]
lst_e = lst_v[1::2]
cnt_o = Counter(lst_o).most_common() + [(0, 0)]
cnt_e = Counter(lst_e).most_common() + [(0, 0)]


if cnt_o[0][0] == cnt_e[0][0]:
    rem_number = max(cnt_o[0][1] + cnt_e[1][1], cnt_o[1][1] + cnt_e[0][1])
else:
    rem_number = cnt_o[0][1] + cnt_e[0][1]
ans = n - rem_number


print(ans)


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())
vlis=[int(i) for i in input().split()]


# a[:6:2] #[0, 2, 4]

# a[7::2] #[7, 9]
odd=vlis[0::2]
even=vlis[1::2]



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


if odd_max[0][0]==even_max[0][0]:
    
    if len(odd_max)==1 and len(even_max)==1:
        print(int(len(vlis)/2))
    
    elif len(even_max)==1:
        print(len(vlis)-even_max[0][1]-odd_max[1][1])
    
    elif len(odd_max)==1:
        print(len(vlis)-odd_max[0][1]-even_max[1][1])
    else:
        
        if odd_max[0][1]+even_max[1][1]>=odd_max[1][1]+even_max[0][1]:
            print(len(vlis)-odd_max[0][1]-even_max[1][1])
        else:
            print(len(vlis)-odd_max[1][1]-even_max[0][1])
else:
    print(len(vlis)-odd_max[0][1]-even_max[0][1])

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


# a[:6:2] #[0, 2, 4]

# a[7::2] #[7, 9]
odd=vlis[0::2]
even=vlis[1::2]



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


if odd_max[0][0]==even_max[0][0]:
    
    if len(odd_max)==1 and len(even_max)==1:
        print(int(len(vlis)/2))
    
    elif len(even_max)==1:
        print(len(vlis)-even_max[0][1]-odd_max[1][1])
    
    elif len(odd_max)==1:
        print(len(vlis)-odd_max[0][1]-even_max[1][1])
    else:

        if odd_max[0][1]+even_max[1][1]>=odd_max[1][1]+even_max[0][1]:
            print(len(vlis)-odd_max[0][1]-even_max[1][1])
        else:
            print(len(vlis)-odd_max[1][1]-even_max[0][1])
else:
    print(len(vlis)-odd_max[0][1]-even_max[0][1])

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

e = v[::2]
o = v[1::2]

ev = {}
ov = {}
for t in e :
    if t in ev :
        ev[t] = ev[t] + 1
    else :
        ev[t] = 1

for t in o :
    if t in ov:
        ov[t] = ov[t] + 1
    else :
        ov[t] = 1

print(ev)
print(ov)

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

eidx = 0
oidx = 0
et = list(ev.values())[eidx]
ot = list(ov.values())[oidx]

if et == ot :
    if ev[et] > ov[ot] :
        if len(ot) > 1:
            ot = list(ov.values())[oidx+1]
    else:
        if len(et) > 1:
            et = list(ov.values())[eidx+1]

ans = len(e) - et + len(o) - ot
print(ans)

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

e = v[::2]
o = v[1::2]

ev = {}
ov = {}
for t in e :
    if t in ev :
        ev[t] = ev[t] + 1
    else :
        ev[t] = 1

for t in o :
    if t in ov:
        ov[t] = ov[t] + 1
    else :
        ov[t] = 1

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

#li = []
#for elm in list(ev.keys()) :

#for elm in list(ov.keys()) :
    
#li.sort(key=lambda x : x[1][1],reverse=True)
#print(li)

ee  = ev[0][0]
oo  = ov[0][0]

es0 = ev[0][1]
os0 = ov[0][1]
ans = n - es0 - os0

if ee == oo:
    tmp1 = n - es0
    tmp2 = n - os0

    if len(ev) > 1:
        es1 = ev[1][1]
        tmp1 = n  - es1  - os0

    if len(ov) > 1:
        os1 = ov[1][1]
        tmp2 = n  - es0  - os1

    if tmp1 > tmp2 :
        ans = tmp2 
    else :
        ans = tmp1

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 Counter
n = int(input())
V = list(map(int,input().split()))
V_odd = []
V_even = []
for i in range(n):
    if i % 2 == 0:
        V_odd += [V[i]]
    else:
        V_even += [V[i]]
V_odd = list(Counter(V_odd).most_common()) + [(-1,0)]
V_even = list(Counter(V_even).most_common()) + [(-2,0)]
print(V_odd,V_even)
if V_odd[0][0] != V_even[0][0]:
    print(len(V)-V_odd[0][1]-V_even[0][1],'a')
elif V_odd[1][1] >= V_even[1][1]:
    print(len(V)-V_odd[1][1]-V_even[0][1],'b')
else:
    print(len(V)-V_odd[0][1]-V_even[1][1],'c')

from collections import Counter
n = int(input())
V = list(map(int,input().split()))
V_odd = []
V_even = []
for i in range(n):
    if i % 2 == 0:
        V_odd += [V[i]]
    else:
        V_even += [V[i]]
V_odd = list(Counter(V_odd).most_common()) + [(-1,0)]
V_even = list(Counter(V_even).most_common()) + [(-2,0)]
if V_odd[0][0] != V_even[0][0]:
    print(len(V)-V_odd[0][1]-V_even[0][1])
elif V_odd[1][1] >= V_even[1][1]:
    print(len(V)-V_odd[1][1]-V_even[0][1])
else:
    print(len(V)-V_odd[0][1]-V_even[1][1])

Verdicts: Wrong Answer

Accepted