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

eve = {}
odd = {}

for i in range(len(vs)):
    if i % 2 == 0:
        if vs[i] in eve:
            eve[vs[i]] += 1
        else:
            eve[vs[i]] = 1
    else:
        if vs[i] in odd:
            odd[vs[i]] += 1
        else:
            odd[vs[i]] = 1

es = sorted(eve.items(), key=lambda x: -x[1])
os = sorted(odd.items(), key=lambda x: -x[1])

trans = 0

if es[0][0] == os[0][0]:
    if es[0][1] > os[0][1]:
        del es[0]
        if(len(os) > 1):
            del os[1]
    else:
        del os[0]
        if(len(es) > 1):
            del es[1]
else:
    del os[0]
    del es[0]

for i in range(1, len(es)):
    trans += es[0][1]
for i in range(1, len(os)):
    trans += os[0][1]

print(trans)

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

eve = {}
odd = {}

for i in range(len(vs)):
    if i % 2 == 0:
        if vs[i] in eve:
            eve[vs[i]] += 1
        else:
            eve[vs[i]] = 1
    else:
        if vs[i] in eve:
            eve[vs[i]] += 1
        else:
            eve[vs[i]] = 1

es = sorted(eve.items(), key=lambda x: -x[1])
os = sorted(eve.items(), key=lambda x: -x[1])

trans = 0

if es[0][0] == os[0][0]:

    if es[0][1] > os[0][1]:
        del es[0]
        if(len(os) > 1):
            del os[1]
    else:
        del os[0]
        if(len(es) > 1):
            del es[1]
else:
    for i in range(1, len(es)):
        trans += es[0][1]
    for i in range(1, len(os)):
        trans += os[0][1]

print(trans)



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

eve = {}
odd = {}

for i in range(len(vs)):
    if i % 2 == 0:
        if vs[i] in eve:
            eve[vs[i]] += 1
        else:
            eve[vs[i]] = 1
    else:
        if vs[i] in odd:
            odd[vs[i]] += 1
        else:
            odd[vs[i]] = 1

es = sorted(eve.items(), key=lambda x: -x[1])
os = sorted(odd.items(), key=lambda x: -x[1])

if es[0][0] == os[0][0]:
    if es[0][1] > os[0][1]:
        del es[0]
        if len(os) > 1 :
            del os[1]
    elif es[0][1] < os[0][1]:
        del os[0]
        if len(es) > 1 :
            del es[1]
    else:
        if len(es) == 1 and len(os) == 1:
            del os[0]
        elif len(es) == 1 and len(os) != 1:
            del es[0]
            del os[1]
        elif len(es) != 1 and len(os) == 1:
            del es[1]
            del os[0]
        else:
            if es[1][1] < os[1][1]:
                del es[0]
                del os[1]
            else:
                del es[1]
                del os[0]
else:
    del os[0]
    del es[0]

trans = 0

for i in range(len(es)):
    trans += es[i][1]
for i in range(len(os)):
    trans += os[i][1]

print(trans)

Verdicts: Wrong Answer

Wrong Answer

Accepted