Problem:


Score : 300 points

Problem Statement

A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:

For each i = 1,2,..., n-2, a_i = a_{i+2}.

Exactly two different numbers appear in the sequence.

You are given a sequence v_1,v_2,...,v_n whose length is even.
We would like to make this sequence /\/\/\/ by replacing some of its elements.
Find the minimum number of elements that needs to be replaced.

Constraints

2 \leq n \leq 10^5

n is even.

1 \leq v_i \leq 10^5

v_i is an integer.

Input

Input is given from Standard Input in the following format:

n
v_1 v_2 ... v_n

Output

Print the minimum number of elements that needs to be replaced.

Sample Input 1

4
3 1 3 2

Sample Output 1

1

The sequence 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.

Sample Input 2

6
105 119 105 119 105 119

Sample Output 2

0

The sequence 105,119,105,119,105,119 is /\/\/\/.

Sample Input 3

4
1 1 1 1

Sample Output 3

2

The elements of the sequence 1,1,1,1 are all the same, so it is not /\/\/\/.



Sample input:
4
3 1 3 2


Sample output:
1

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if list((set(max_c_odd_keys) & set(max_c_even_keys))) != set():
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
        else:
            if list((set(max_c_odd_keys) & set(max_c_even_keys)))[0] in dict_c_odd:
                del dict_c_odd[list((set(max_c_odd_keys) & set(max_c_even_keys)))[0]]              
            max_count_c_odd = max(dict_c_odd.values())
    elif max_count_c_odd < max_count_c_even:
        if list((set(max_c_odd_keys) & set(max_c_even_keys))) != set():
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
        else:
            if list((set(max_c_odd_keys) & set(max_c_even_keys)))[0] in dict_c_even:
                del dict_c_even[list((set(max_c_odd_keys) & set(max_c_even_keys)))[0]]              
            max_count_c_even = max(dict_c_even.values())
    else:
        if len(max_c_odd_keys) > len(max_c_even_keys):
            if list((set(max_c_odd_keys) & set(max_c_even_keys))) != set():
                if max_c_even_keys[0] in dict_c_odd:
                    del dict_c_odd[max_c_even_keys[0]]
                max_count_c_odd = max(dict_c_odd.values())
            else:
                if list((set(max_c_odd_keys) & set(max_c_even_keys)))[0] in dict_c_odd:
                    del dict_c_odd[list((set(max_c_odd_keys) & set(max_c_even_keys)))[0]]              
                max_count_c_odd = max(dict_c_odd.values())
        elif len(max_c_odd_keys) < len(max_c_even_keys):
            if list((set(max_c_odd_keys) & set(max_c_even_keys))) != set():
                if max_c_odd_keys[0] in dict_c_even:
                    del dict_c_even[max_c_odd_keys[0]]
                max_count_c_even = max(dict_c_even.values())
            else:
                if list((set(max_c_odd_keys) & set(max_c_even_keys)))[0] in dict_c_even:
                    del dict_c_even[list((set(max_c_odd_keys) & set(max_c_even_keys)))[0]]              
                max_count_c_even = max(dict_c_even.values())
        else:
            if list((set(max_c_odd_keys) & set(max_c_even_keys))) != set():
                if max_c_even_keys[0] in dict_c_odd:
                    del dict_c_odd[max_c_even_keys[0]]
                max_count_c_odd = max(dict_c_odd.values())
            else:
                if list((set(max_c_odd_keys) & set(max_c_even_keys)))[0] in dict_c_odd:
                    del dict_c_odd[list((set(max_c_odd_keys) & set(max_c_even_keys)))[0]]              
                max_count_c_odd = max(dict_c_odd.values())
    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    elif max_count_c_odd < max_count_c_even:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
    else:
        if len(max_c_odd_keys) > len(max_c_even_keys):
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
        elif len(max_c_odd_keys) < len(max_c_even_keys):
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
        else:
            if list((set(max_c_odd_keys) & set(max_c_even_keys))) != set():
                if max_c_even_keys[0] in dict_c_odd:
                    del dict_c_odd[max_c_even_keys[0]]
            else:
                if list((set(max_c_odd_keys) & set(max_c_even_keys)))[0] in dict_c_odd:
                    del dict_c_odd[list((set(max_c_odd_keys) & set(max_c_even_keys)))[0]]              
            max_count_c_odd = max(dict_c_odd.values())
    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    elif max_count_c_odd < max_count_c_even:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
    else:
        if len(max_c_odd_keys) > len(max_c_even_keys):
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
        elif len(max_c_odd_keys) < len(max_c_even_keys):
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
        else:
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    elif max_count_c_odd < max_count_c_even:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
    else:
        if len(max_c_odd_keys) > len(max_c_even_keys):
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
        elif len(max_c_odd_keys) < len(max_c_even_keys):
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
        else:
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    elif max_count_c_odd < max_count_c_even:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
    else:
        if len(max_c_odd_keys) > len(max_c_even_keys):
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
        elif len(max_c_odd_keys) > len(max_c_even_keys):
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
        else:
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    elif max_count_c_odd < max_count_c_even:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
    else:
        if len(max_c_odd_keys) >= len(max_c_even_keys):
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
        else:
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())           
    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    elif max_count_c_odd < max_count_c_even:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
    else:
        if len(max_c_odd_keys) > len(max_c_even_keys):
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
        else:
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())           
    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    else:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())

    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
        replace_total += (n - max_count_c_odd - max_count_c_even)
        print(int(replace_total))
    elif max_count_c_odd < max_count_c_even:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
        replace_total += (n - max_count_c_odd - max_count_c_even)
        print(int(replace_total))
    else:
        pass

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    elif max_count_c_odd < max_count_c_even:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())

    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd >= max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
    else:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())

    replace_total += (n - max_count_c_odd - max_count_c_even)
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd == max_count_c_even:
        if len(max_c_odd_keys) >= len(max_c_even_keys):
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
            replace_total += (n - max_count_c_odd - max_count_c_even)
            print(int(replace_total))
        else:
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
            replace_total += (n - max_count_c_odd - max_count_c_even)
            print(int(replace_total))
    elif max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
        replace_total += (n - max_count_c_odd - max_count_c_even)
        print(int(replace_total))
    else:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
        replace_total += (n - max_count_c_odd - max_count_c_even)
        print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
dict_c_odd = dict(c_odd)
dict_c_even = dict(c_even)

if len(set(v)) == 1:
    print(int(even_odd_length))
else:
    max_count_c_odd = max(dict_c_odd.values())
    max_count_c_even = max(dict_c_even.values())
    max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
    max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]
    
    if max_count_c_odd == max_count_c_even:
        if len(max_c_odd_keys) >= len(max_c_even_keys):
            if max_c_even_keys[0] in dict_c_odd:
                del dict_c_odd[max_c_even_keys[0]]
            max_count_c_odd = max(dict_c_odd.values())
            replace_total += (even_odd_length - max_count_c_even)
            replace_total += (even_odd_length - max_count_c_odd)
            print(int(replace_total))
        else:
            if max_c_odd_keys[0] in dict_c_even:
                del dict_c_even[max_c_odd_keys[0]]
            max_count_c_even = max(dict_c_even.values())
            replace_total += (even_odd_length - max_count_c_odd)
            replace_total += (even_odd_length - max_count_c_even)
            print(int(replace_total))

    elif max_count_c_odd > max_count_c_even:
        if max_c_odd_keys[0] in dict_c_even:
            del dict_c_even[max_c_odd_keys[0]]
        max_count_c_even = max(dict_c_even.values())
        replace_total += (even_odd_length - max_count_c_odd)
        replace_total += (even_odd_length - max_count_c_even)
        print(int(replace_total))
    else:
        if max_c_even_keys[0] in dict_c_odd:
            del dict_c_odd[max_c_even_keys[0]]
        max_count_c_odd = max(dict_c_odd.values())
        replace_total += (even_odd_length - max_count_c_even)
        replace_total += (even_odd_length - max_count_c_odd)
        print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = len(v) / 2
replace_total = 0

if len(set(v)) == 1:
    print(2)
else:
    c_even = collections.Counter(v[0::2])
    c_odd = collections.Counter(v[1::2])
    replace_total += even_odd_length - list(c_even.values())[0]
    replace_total += even_odd_length - list(c_odd.values())[0]
    print(int(replace_total))

Submission status: Wrong Answer

Solution code:
import collections

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

even_odd_length = len(v) / 2
replace_total = 0

if len(set(v)) == 1:
    print(2)
else:
    c_even = collections.Counter(v[0::2])
    c_odd = collections.Counter(v[1::2])
    replace_total += even_odd_length - list(c_even.values())[0]
    replace_total += even_odd_length - list(c_odd.values())[0]
    print(replace_total)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 17 20:29:30 2020

@author: liang
"""

n = int(input())
E = list()
O = list()
i = 0
for v in input().split():
    if i%2 == 0:
        E.append(int(v))
    else:
        O.append(int(v))
    i += 1
#print(E)
#print(O)
edic = {-1:0}
odic = {-1:0}
for e in E:
    if e not in edic.keys():
        edic[e] = 1
    else:
        edic[e] += 1

for o in O:
    if o not in odic.keys():
        odic[o] = 1
    else:
        odic[o] += 1

while True:
    e = -1
    etmp = 0
    for key in edic.keys():
        if edic[key] > etmp:
            etmp = edic[key]
            e = key
    
    o = -1
    otmp = 0
    for key in odic.keys():
        if odic[key] > otmp:
            otmp = odic[key]
            o = key
    if e != o:
        break
    else:
        if otmp > etmp:
            del edic[e]
        else:
            del odic[o]


#print(edic)

ans = n - etmp - otmp
    
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    # n, k = map(int, input().split())
    v = list(map(int, input().split()))
    # s = input()

    num_count1 = {}
    num_count2 = {}

    for i in range(n):
        if i % 2 == 0:
            if v[i] in num_count1:
                num_count1[v[i]] += 1
            else:
                num_count1[v[i]] = 1
        else:
            if v[i] in num_count2:
                num_count2[v[i]] += 1
            else:
                num_count2[v[i]] = 1

    first_count1 = max(num_count1)
    first_count2 = max(num_count2)
    temp1 = num_count1[first_count1]
    temp2 = num_count2[first_count2]
    num_count1[first_count1] = 0
    num_count2[first_count2] = 0
    second_count1 = max(num_count1)
    second_count2 = max(num_count2)

    ans = 0
    if first_count2 != first_count1:
        ans = n - temp1 - temp2
    else:
        if num_count1[second_count1] < num_count2[second_count2]:
            ans = n - temp1 - num_count2[second_count2]
        else:
            ans = n - num_count1[second_count1] - temp2
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if a.count(a[0])==n:
    print(n//2)
    exit()


x=a[::2]
y=a[1::2]

xx=Counter(x)
yy=Counter(y)

xxx=xx.most_common()
yyy=yy.most_common()



print(n-xxx[0][1]-yyy[0][1])

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
even=[]
odd=[]
for i in range(n):
  if i%2==0:
    even.append(v[i])
  else:
    odd.append(v[i])
from collections import Counter
even=Counter(even)
odd=Counter(odd)

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

a=even[0]
if a[1]==n//2:
  b=0
else:
  b=even[1][1]
  
c=odd[0]
if c[1]==n//2:
  d=0
else:
  d=odd[1][1]
  
if a[0]==c[0]:
  print(max(n-a[1]-d,n-b-c[1]))
else:
  print(n-a[1]-c[1])

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
from collections import Counter
v=Counter(v)
dic=sorted(v.items(),key=lambda x:x[1],reverse=True)

if dic[0][1]==n:
  print(n//2)
elif dic[0][1]+dic[1][1]==n:
  print(n//2-dic[1][1])
else:
  s=len(dic)
  others=0
  for i in range(2,s):
    others+=dic[i][1]
  first=dic[0][1]
  second=dic[1][1]
  if n//2-first-others>=0:
    print(n//2-first+(n-first-second-otheres))
  else:
    print(n-first-second)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
from collections import Counter
v=Counter(v)
dic=sorted(v.items(),key=lambda x:x[1],reverse=True)

tup=dic[0]
if tup[1]==n:
  print(n//2)
elif tup[1]>=n//2:
  print(n//2-dic[1][1])
else:
  print(n-dic[0][1]-dic[1][1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if len(set(v)) <= 1:
    print(int(n/2))
    exit()

odd = [v[i] for i in range(0, n, 2)]
odd_val, odd_cnt = zip(*Counter(odd).most_common())

even = [v[i] for i in range(1, n, 2)]
even_val, even_cnt = zip(*Counter(even).most_common())

if even_val[0] != odd_val[0]:
    ans = n-even_cnt[0]-odd_cnt[0]
else:
    if even_cnt[0] >= odd_cnt[0]:
        ans = n-even_cnt[0]-odd_cnt[1]
    else:
        ans = n-even_cnt[1]-odd_cnt[0]
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

if len(set(v)) <= 1:
    print(int(n/2))
    exit()

odd = [v[i] for i in range(0, n, 2)]
odd_val, odd_cnt = zip(*Counter(odd).most_common())

even = [v[i] for i in range(1, n, 2)]
even_val, even_cnt = zip(*Counter(even).most_common())

ans = n-even_cnt[0]-odd_cnt[0]
print(ans)

Submission status: Wrong Answer

Solution code:
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(1)[0][1]
    b = Counter(B).most_common(1)[0][1]
    print(n - a - b)

Submission status: Wrong Answer

Solution code:
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 = map(lambda x: x[1], V.most_common(2))
    if a < b:
        a, b = b, a
    a = min(n // 2 + n % 2, a)
    b = min(n // 2, b)
    print(n - a - b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

list_odd=v[1::2]
list_even=v[0::2]

cnt_odd=Counter(list_odd)
cnt_even=Counter(list_even)

cnt_odd_sorted=sorted(cnt_odd.items(),reverse=True,key=lambda x:x[1])
cnt_even_sorted=sorted(cnt_even.items(),reverse=True,key=lambda x:x[1])

if cnt_odd_sorted[0][0]!=cnt_even_sorted[0][0]:
    ans=len(list_odd)-cnt_odd_sorted[0][1]
    ans+=len(list_even)-cnt_even_sorted[0][1]

else:
    if len(cnt_odd)==1 and len(cnt_even)==1:
        ans=len(list_even)
    elif len(cnt_odd)==1:
        ans=len(list_even)-cnt_even_sorted[1][1]
    elif len(cnt_even)==1:
        ans=len(list_odd)-cnt_odd_sorted[1][1]
    else:
        ans1=len(list_even)-cnt_even_sorted[1][1]
        ans2=len(list_odd)-cnt_odd_sorted[1][1]
        ans=min(ans1,ans2)

print(ans)