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: Runtime Error

Solution code:
import numpy as np
n = int(input())

v = list(map(int,input().split()))
v1 = []
v2 = []
len_v = len(v)

for i in range(len_v):
        if i % 2:
            v1.append(v[i])
        else:
            v2.append(v[i])

v1_unique = np.array(list(set(v1)))
v2_unique = np.array(list(set(v2)))

v1_cnt = []
v2_cnt = []

for i in range(len(v1_unique)):
    cnt = 0
    for j in range(int(len_v / 2)):
        if v1[j] == v1_unique[i]:
            cnt += 1
    v1_cnt.append(cnt)

for i in range(len(v2_unique)):
    cnt = 0
    for j in range(int(len_v / 2)):
        if v2[j] == v2_unique[i]:
            cnt += 1
    v2_cnt.append(cnt)

v1_unique[np.argsort(v1_cnt)]
v2_unique[np.argsort(v2_cnt)]
np.sort(v1_cnt)
np.sort(v2_cnt)

if v1_unique[-1] != v2_unique[-1]:
    print(n - v1_cnt[-1] - v2_cnt[-1])
else:
    if len(v1_unique) == 1 and len(v2_unique) == 1:
        print(int(len_v / 2))
    else:
        print(max(n - v1_cnt[-1] - v2_[-2], n - v1_cnt[-2] -v2_cnt[-1]))

Submission status: Runtime Error

Solution code:
from collections import Counter

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

# 最終的な2値をx, yとしたとき書き換える要素が最小の場合は、
# xは、書き換えが最も少ない数。つまり、もともと最も多い数
# yも同様。
# ただ、xとyがかぶる場合があるので、それに対処。
if len(Counter(v)) > 1:
    v1 = v[0:n+1:2]
    # print(v)
    # print(v1)
    v2 = v[1:n+2:2]
    # print(v2)
    v1_count = Counter(v1)
    v2_count = Counter(v2)

    v1_1st_common = v1_count.most_common(1)
    v2_1st_common = v2_count.most_common(1)
    sols = []
    # print(v1_1st_common[0][1], v2_1st_common[0][1])
    # v1を基準として多い方を考える場合。
    n1 = v1_1st_common[0][1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0][0] == v2_1st_common[0][0]:
        if len(v2_count >= 2):
            v2_2nd_common = v2_count.most_common(2)
            n2 = v2_2nd_common[0][1]
        else:
            print(n//2)
    else:
        n2 = v2_1st_common[0][1]
    sols.append(n-n1-n2)

    # v2を基準として多い方を考える場合。
    n2 = v2_1st_common[0][1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0][0] == v2_1st_common[0][0]:
         if len(v1_count >= 2):
            v1_2nd_common = v1_count.most_common(2)
            n1 = v1_2nd_common[0][1]
         else:
            print(n//2)
    else:
        n1 = v1_1st_common[0][1]
    sols.append(n-n1-n2)
    print(min(sols))
else:
    print(n//2)

Submission status: Runtime Error

Solution code:

























-UUU:----F1  *scratch*      All L1     (Fundamental Fill) ----------------------------------------------
ad-handle-definition: ‘pdb’ got redefined
30.py                                  col_m.txt
31.png                                 del_list.txt
31.py                                  enwiki-20150112-400-r10-105752.txt.bz2
32.png                                 features.txt
32.py                                  hightemp.txt
33.png                                 jawiki-country.json.gz
33.py                                  json_write.py
34.png                                 jsonkun.txt
34.py                                  l005.py
35.png                                 lambda.py
35.py                                  nako.txt.tmp
36.png                                 neko.txt
36.py                                  neko.txt.cabocha
36a.py                                 neko.txt.cabocha.tmp
37.png                                 neko.txt.mecab
37.py                                  neko.txt.tmp
38.png                                 nlp.txt
38.py                                  nlp.txt.xml
39.png                                 parse.out
39.py                                  predicate.txt
4.png                                  predicate_Particle.txt
40.png                                 result.png
40.py                                  result.txt
41.png                                 result49.txt
41.py                                  rt-polarity.neg
42.png                                 rt-polarity.pos
42.py                                  rt-polaritydata
43.png                                 rt-polaritydata.tar.gz
43.py                                  sentiment.txt
44.png                                 stanford-corenlp-full-2018-02-27
44.py                                  stanford-corenlp-full-2018-02-27.zip
45.png                                 start_server.sh
45.py                                  test.sh
46.png                                 test.sh~
46.py                                  test47.sh
47.png                                 test47.sh~
47.py                                  test_db
48.png                                 する.txt
48.py                                  見る.txt
49.png                                 与える.txt
49.py                                  すべて.txt
5.png
➜  lang_process_100 git:(master) ✗ git add 90.py
➜  lang_process_100 git:(master) ✗ git commit -m "20180930 wrote need check"
[master 8821b56] 20180930 wrote need check
 1 file changed, 13 insertions(+), 4 deletions(-)
➜  lang_process_100 git:(master) ✗ git push -u origin master
Enter passphrase for key '/Users/junya/.ssh/github_id_rsa':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 709 bytes | 709.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:higher68/lang_process.git
   5a0fa42..8821b56  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
➜  lang_process_100 git:(master) ✗ e question-words.txt
➜  lang_process_100 git:(master) ✗ e question-words.txt
➜  lang_process_100 git:(master) ✗ git add 91.py
➜  lang_process_100 git:(master) ✗ git commit -m "20180930 wrote need check"
[master bdc97a1] 20180930 wrote need check
 1 file changed, 21 insertions(+)
 create mode 100644 91.py
➜  lang_process_100 git:(master) ✗ git push -u origin master
Enter passphrase for key '/Users/junya/.ssh/github_id_rsa':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 617 bytes | 617.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:higher68/lang_process.git
   8821b56..bdc97a1  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
➜  lang_process_100 git:(master) ✗ git add 92.py
➜  lang_process_100 git:(master) ✗ git commit -m "20180930 wrote need check"
[master 8d2cb0c] 20180930 wrote need check
 1 file changed, 62 insertions(+)
 create mode 100644 92.py
➜  lang_process_100 git:(master) ✗ git push -u origin master
Enter passphrase for key '/Users/junya/.ssh/github_id_rsa':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.06 KiB | 542.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:higher68/lang_process.git
   bdc97a1..8d2cb0c  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
➜  lang_process_100 git:(master) ✗ git add 92.py
➜  lang_process_100 git:(master) ✗ git commit -m "20181001 wrote need check"
[master e8eed9e] 20181001 wrote need check
 1 file changed, 1 deletion(-)
➜  lang_process_100 git:(master) ✗ git push -u origin master
Enter passphrase for key '/Users/junya/.ssh/github_id_rsa':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 294 bytes | 147.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:higher68/lang_process.git
   8d2cb0c..e8eed9e  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
➜  lang_process_100 git:(master) ✗ git add 93.py
➜  lang_process_100 git:(master) ✗ git commit -m "20181001 wrote need check"
[master 37076e6] 20181001 wrote need check
 1 file changed, 18 insertions(+)
 create mode 100644 93.py
➜  lang_process_100 git:(master) ✗ git push -u origin master
Enter passphrase for key '/Users/junya/.ssh/github_id_rsa':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 642 bytes | 642.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:higher68/lang_process.git
   e8eed9e..37076e6  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
➜  lang_process_100 git:(master) ✗ ls
#64.py#                                51.py
000.py                                 51_ans.py
001.py                                 52.py
002.py                                 53.py
003.py                                 54.py
003_B.py                               55.py
004.py                                 56.py
006.py                                 56_test.py
007.py                                 57.py
008.py                                 58.py
009.py                                 59.py
00e0.py                                6.png
010.py                                 60.py
011.py                                 61.py
012.py                                 62.py
013.py                                 63.py
014.py                                 64.py
015.py                                 65.py
016.py                                 67.py
017.py                                 68.py
018.py                                 69.py
019.py                                 7.png
020.py                                 70.py
021.py                                 71.py
022.py                                 72.py
023.py                                 73.py
024.py                                 74.py
025.py                                 75.py
026.py                                 76.py
026_a.py                               77.py
027.py                                 78.py
028.py                                 79.py
029.py                                 8.png
1.png                                  80.py
10.png                                 81.py
11.png                                 82.py
12.png                                 83.py
13.png                                 84.py
14.png                                 85.py
15.png                                 86.py
16.png                                 87.py
17.png                                 88.py
18.png                                 89.py
19.png                                 9.png
2.png                                  90.py
20.png                                 91.py
21.png                                 92.py
22.png                                 93.py
23.png                                 94.py
24.png                                 Country_list.csv
25.png                                 Country_list.numbers
26.png                                 README.md
27.png                                 __pycache__
28.png                                 artist.json.gz
29.png                                 cgi-bin
3.png                                  col1.txt
30.png                                 col2.txt
30.py                                  col_m.txt
31.png                                 del_list.txt
31.py                                  enwiki-20150112-400-r10-105752.txt.bz2
32.png                                 features.txt
32.py                                  hightemp.txt
33.png                                 jawiki-country.json.gz
33.py                                  json_write.py
34.png                                 jsonkun.txt
34.py                                  l005.py
35.png                                 lambda.py
35.py                                  nako.txt.tmp
36.png                                 neko.txt
36.py                                  neko.txt.cabocha
36a.py                                 neko.txt.cabocha.tmp
37.png                                 neko.txt.mecab
37.py                                  neko.txt.tmp
38.png                                 nlp.txt
38.py                                  nlp.txt.xml
39.png                                 parse.out
39.py                                  predicate.txt
4.png                                  predicate_Particle.txt
40.png                                 question-words.txt
40.py                                  result.png
41.png                                 result.txt
41.py                                  result49.txt
42.png                                 rt-polarity.neg
42.py                                  rt-polarity.pos
43.png                                 rt-polaritydata
43.py                                  rt-polaritydata.tar.gz
44.png                                 sentiment.txt
44.py                                  stanford-corenlp-full-2018-02-27
45.png                                 stanford-corenlp-full-2018-02-27.zip
45.py                                  start_server.sh
46.png                                 test.sh
46.py                                  test.sh~
47.png                                 test47.sh
47.py                                  test47.sh~
48.png                                 test_db
48.py                                  wordsim353
49.png                                 wordsim353.zip
49.py                                  する.txt
5.png                                  見る.txt
50.png                                 与える.txt
50.py                                  すべて.txt
50_sub.py
➜  lang_process_100 git:(master) ✗ git add 94.py
➜  lang_process_100 git:(master) ✗ git commit -m "20181001 writing"
[master 256b14d] 20181001 writing
 1 file changed, 20 insertions(+)
 create mode 100644 94.py
➜  lang_process_100 git:(master) ✗ git push -u origin master
Enter passphrase for key '/Users/junya/.ssh/github_id_rsa':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 652 bytes | 652.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:higher68/lang_process.git
   37076e6..256b14d  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
➜  lang_process_100 git:(master) ✗ cd
➜  ~
➜  ~ cd git/atcoder/Beginner111
➜  Beginner111 git:(master) ✗ ls
a.py        b2.py       c.py        c3.py       d.py
b.py        b_review.py c2.py       cpy
➜  Beginner111 git:(master) ✗ p b_review.py
111
111
222
333
444
555
666
777
888
999
➜  Beginner111 git:(master) ✗
➜  Beginner111 git:(master) ✗
➜  Beginner111 git:(master) ✗ p b_review.py
111
111
➜  Beginner111 git:(master) ✗ p b_review.py
112
222
➜  Beginner111 git:(master) ✗ p b_review.py
750
777
➜  Beginner111 git:(master) ✗ git add 94.py
fatal: pathspec '94.py' did not match any files
➜  Beginner111 git:(master) ✗ cd
➜  ~ cd git/lang_process_100
➜  lang_process_100 git:(master) ✗ git add 94.py
➜  lang_process_100 git:(master) ✗ git commit -m "20181001 writing"
[master 6080a32] 20181001 writing
 1 file changed, 13 insertions(+), 1 deletion(-)
➜  lang_process_100 git:(master) ✗ git push -u origin master
ssh: Could not resolve hostname github.com: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

File Edit Options Buffers Tools Help

























































-UUU:----F1  *scratch*      All L1     (Fundamental Fill) ----------------------------------------------
ad-handle-definition: ‘pdb’ got redefined
Please make sure you have the correct access rights
and the repository exists.
➜  lang_process_100 git:(master) ✗ git push -u origin master
Enter passphrase for key '/Users/junya/.ssh/github_id_rsa':
File Edit Options Buffers Tools Help

























































-UUU:----F1  *scratch*      All L1     (Fundamental Fill) ----------------------------------------------
ad-handle-definition: ‘pdb’ got redefined
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 477 bytes | 477.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:higher68/lang_process.git
   256b14d..6080a32  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
    v2_count = Counter(v2)

    v1_1st_common = v1_count.most_common(1)
    v1_2nd_common = v1_count.most_common(2)
    print("v1", v1_1st_common, v1_2nd_common)
    v2_1st_common = v2_count.most_common(1)
    v2_2nd_common = v2_count.most_common(2)
    print("v2", v2_1st_common, v2_2nd_common)
    sols = []

    # v1を基準として多い方を考える場合。
    n1 = v1_1st_common[1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0] == v2_1st_common[0]:
        n2 = v2_2nd_common[1]
    else:
        n2 = v2_1st_common[1]
    sols.append(n-n1-n2)

    # v2を基準として多い方を考える場合。
    n2 = v2_1st_common[1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0] == v2_1st_common[0]:
        n1 = v1_2nd_common[1]
    else:
        n1 = v1_1st_common[1]
    sols.append(n-n1-n2)
    print(min(sols))
else:
    print(n//2)
















-UUU(LF)----F1  c_review.py    All L43    (Python AC ElDoc) --------------------------------------------
Wrote /Users/junya/git/atcoder/Beginner111/c_review.py
from collections import Counter

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

# 最終的な2値をx, yとしたとき書き換える要素が最小\\
の場合は、
# xは、書き換えが最も少ない数。つまり、もともと最\\
も多い数
# yも同様。
# ただ、xとyがかぶる場合があるので、それに対処。
if len(Counter(v)) > 1:
    v1 = v[0:n-2:2]
    v2 = v[1:n-1:2]
    v1_count = Counter(v1)
    v2_count = Counter(v2)

    v1_1st_common = v1_count.most_common(1)
    v1_2nd_common = v1_count.most_common(2)
    print("v1", v1_1st_common, v1_2nd_common)
    v2_1st_common = v2_count.most_common(1)
    v2_2nd_common = v2_count.most_common(2)
    print("v2", v2_1st_common, v2_2nd_common)
    sols = []

    # v1を基準として多い方を考える場合。
    n1 = v1_1st_common[1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0] == v2_1st_common[0]:
        n2 = v2_2nd_common[1]
    else:
        n2 = v2_1st_common[1]
    sols.append(n-n1-n2)

    # v2を基準として多い方を考える場合。
    n2 = v2_1st_common[1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0] == v2_1st_common[0]:
        n1 = v1_2nd_common[1]
    else:
        n1 = v1_1st_common[1]
    sols.append(n-n1-n2)
    print(min(sols))
else:
    print(n//2)











File Edit Options Buffers Tools Help

























































-UUU:----F1  *scratch*      All L1     (Fundamental Fill) ----------------------------------------------
ad-handle-definition: ‘pdb’ got redefined

File Edit Options Buffers Tools Help

























































-UUU:----F1  *scratch*      All L1     (Fundamental Fill) ----------------------------------------------
ad-handle-definition: ‘pdb’ got redefined

File Edit Options Buffers Tools Help

























































-UUU:----F1  *scratch*      All L1     (Fundamental Fill) ----------------------------------------------
ad-handle-definition: ‘pdb’ got redefined
-UUU(LF)----F1  c_review.py    All L43    (Python A
Wrote /Users/junya/git/atcoder/Beginner111/c_revie\
➜  lang_process_100 git:(master) ✗ cd
➜  ~ cd git/atcoder/Beginner111
➜  Beginner111 git:(master) ✗ p c.py
4
3 1 3 2
1
File Edit Options Buffers Tools Help

























































-UUU:----F1  *scratch*      All L1     (Fundamental Fill) ----------------------------------------------
ad-handle-definition: ‘pdb’ got redefined
➜  Beginner111 git:(master) ✗

➜  Beginner111 git:(master) ✗
➜  Beginner111 git:(master) ✗ p c.py
6
105 119 105 119 105 119
0
➜  Beginner111 git:(master) ✗
File Edit Options Buffers Tools Help






















































-UUU:----F1  *scratch*      All L1     (Fundamental
ad-handle-definition: ‘pdb’ got redefined
from collections import Counter

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

# 最終的な2値をx, yとしたとき書き換える要素が最小\\
の場合は、
# xは、書き換えが最も少ない数。つまり、もともと最\\
も多い数
# yも同様。
# ただ、xとyがかぶる場合があるので、それに対処。
if len(Counter(v)) > 1:
    v1 = v[0:n+1:2]
    # print(v)
    # print(v1)
    v2 = v[1:n+2:2]
    # print(v2)
    v1_count = Counter(v1)
    v2_count = Counter(v2)

    v1_1st_common = v1_count.most_common(1)
    v2_1st_common = v2_count.most_common(1)
    sols = []
    # print(v1_1st_common[0][1], v2_1st_common[0][\
1])
    # v1を基準として多い方を考える場合。
    n1 = v1_1st_common[0][1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0][0] == v2_1st_common[0][0]:
        if len(v2_count >= 2):
            v2_2nd_common = v2_count.most_common(2\
)
            n2 = v2_2nd_common[0][1]
        else:
            print(n//2)
    else:
        n2 = v2_1st_common[0][1]
    sols.append(n-n1-n2)

    # v2を基準として多い方を考える場合。
    n2 = v2_1st_common[0][1]
    # v1の1位とv2の1位がかぶる場合
    if v1_1st_common[0][0] == v2_1st_common[0][0]:
         if len(v1_count >= 2):
            v1_2nd_common = v1_count.most_common(2\
)
            n1 = v1_2nd_common[0][1]
         else:
            print(n//2)
    else:
        n1 = v1_1st_common[0][1]
    sols.append(n-n1-n2)
    print(min(sols))
else:
    print(n//2)

-UUU(LF)----F1  c_review.py    All L22    (Python A
Wrote /Users/junya/git/atcoder/Beginner111/c_revie\
w.py

Submission status: Runtime Error

Solution code:
from collections import Counter

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

# 最終的な2値をx, yとしたとき書き換える要素が最小の場合は、
# xは、書き換えが最も少ない数。つまり、もともと最も多い数
# yも同様。
# ただ、xとyがかぶる場合があるので、それに対処。
v1 = v[0:n-2:2]
v2 = v[1:n-1:2]
v1_count = Counter(v1)
v2_count = Counter(v2)

v1_1st_common = v1_count.most_common(1)
v1_2nd_common = v1_count.most_common(2)

v2_1st_common = v2_count.most_common(1)
v2_2nd_common = v2_count.most_common(2)
sols = []

# v1を基準として多い方を考える場合。
n1 = v1_1st_common[1]
# v1の1位とv2の1位がかぶる場合
if v1_1st_common[0] == v2_1st_common[0]:
    n2 = v2_2nd_common[1]
else:
    n2 = v2_1st_common[1]
sols.append(n-n1-n2)

# v2を基準として多い方を考える場合。
n2 = v2_1st_common[1]
# v1の1位とv2の1位がかぶる場合
if v1_1st_common[0] == v2_1st_common[0]:
    n1 = v1_2nd_common[1]
else:
    n1 = v1_1st_common[1]
sols.append(n-n1-n2)
print(min(sols))

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
​
cnt = [Counter(), Counter()]
cmn = [0, 0]
for parity in range(2):
    for i in (range(parity, n, 2)):
        cnt[parity][v[i]] += 1
    cmn[parity] = cnt[parity].most_common(1)[0]
​
if cmn[0][0] != cmn[1][0]:
    ret = n - cmn[0][1] - cmn[1][1]
else:
    subcmn_mult = [0, 0]
    for parity in range(2):
        try:
            subcmn_mult[parity] = cnt[parity].most_common(2)[1][1]
        except IndexError:
            subcmn_mult[parity] = 0
    ret = n - cmn[0][1] - max(subcmn_mult[0], subcmn_mult[1])
print(ret)

Submission status: Runtime Error

Solution code:
import collections

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

list_e = [list[i] for i in range(0,n-1,2)]
list_o = [list[i] for i in range(1,n,2)]
e = collections.Counter(list_e)
o = collections.Counter(list_o)
mode_e=e.most_common(2)
mode_o=o.most_common(2)
if mode_e[0][0]==mode_o[0][0]:
    if mode_e[0][1]>mode_o[0][1]:
        mode_e_value=mode_e[0][1]
        mode_o_value=mode_o[1][1]
    else:
        mode_e_value=mode_e[1][1]
        mode_o_value=mode_o[0][1]
else:
    mode_e_value = mode_e[0][1]
    mode_o_value = mode_o[0][1]
print(n-mode_e_value-mode_o_value)

Submission status: Runtime Error

Solution code:
N = int(input())
NA = int(input())
NX = NA.split(" ")
NW = []
for i in range (1,N+1):
    Ni = int(NX.count(i))
    NW.append(Ni)
NN = NW.sort()
print(NW)
S = 0
for x in range (0,N-2):
    S = S + NW[x]
print(S)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

import collections

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

if len(set(v_l)) == 1:
    print(n // 2)
    exit()

v_l_odd = []
v_l_even = []

for i in range(n):
    if i % 2 == 0:
        v_l_odd.append(v_l[i])
    else:
        v_l_even.append(v_l[i])

max_odd = collections.Counter(v_l_odd)
mon = max_odd.most_common(1)[0][0]
max_even = collections.Counter(v_l_even)
men = max_even.most_common(1)[0][0]

if mon == men:
    if max(max_odd.most_common(2)[1][1], max_even.most_common(2)[1][1]) 
== max_odd.most_common(2)[1][1]:
        mon = max_odd.most_common(2)[1][1]
    else:
        men = max_even.most_common(2)[1][1]

v_l_odd_l = []
v_l_even_l = []

for i in range(n):
    if i % 2 == 0:
        if v_l[i] != mon:
            v_l_odd_l.append(v_l[i])
    else:
        if v_l[i] != men:
            v_l_even_l.append(v_l[i])

print(len(v_l_odd_l) + len(v_l_even_l))

Submission status: Runtime Error

Solution code:
n=int(input())
ans=0
mae=[0 for i in range(100000)]
usi=[0 for i in range(100000)]
li=list(map(int,input().split()))
for i in range(n//2):
    mae[li[2*i]]+=1
    usi[li[2*i+1]]+=1
maema, usima = 0, 0
maei, usii = 0, 0
for i in range(100000):
    ans+=mae[i]+usi[i]
    maema, usima=max(maema,mae[i]), max(usima,usi[i])
    maei=i if (maema==mae[i]) else maei
    usii=i if (usima==usi[i]) else usii
if maei==usii:
    ans-=max(maema, usima)
else:
    ans-=(maema+usima)
print(ans)

Submission status: Runtime Error

Solution code:
N = 2
a = [input() for i in range(N)]

N = list(a[1].replace(' ', ''))

odd = []
even = []
for idx, _ in enumerate(N, start=1):
    if idx % 2 == 0:
        even.append(i)
    else:
        odd.append(i)

c = 1
for i in odd:
    if c <= odd.count(i):
        c = odd.count(i)
d = 1
for i in even:
    if d <= even.count(i):
        d = even.count(i)
        
print(len(odd) - c + len(even) - d)

Submission status: Runtime Error

Solution code:
n = int(input().rstrip())
v_list = input().rstrip().split(' ')

result = 0
finish_num = n // 2

top_num = v_list[0]
count_top = v_list.count(top_num)
if count_top == len(v_list):
  print(finish_num)
  skip_flag = True

for i in range(finish_num):
  if v_list[i] != v_list[i+2]:
    result += 1

if not skip_flag:
	print(result)

Submission status: Runtime Error

Solution code:
N = list(input().replace(' ', ''))

odd = []
even = []
for idx, _ in enumerate(N, start=1):
    if idx % 2 == 0:
        even.append(i)
    else:
        odd.append(i)

c = 1
for i in odd:
    if c <= odd.count(i):
        c = odd.count(i)
d = 1
for i in even:
    if d <= even.count(i):
        d = even.count(i)
        
print(len(odd) - c + len(even) - d)

Submission status: Runtime Error

Solution code:
#encoding utf-8
def main(n,v):
    # n = int(input())
    # v = list(int(i) for i in input().split())
    even_v = []
    odd_v = []

    for i in range(n):
        if i%2 == 0:
            odd_v.append(v[i])
        else:
            even_v.append(v[i])

    odd_dic = {}
    even_dic = {}
    for i in range(len(odd_v)):
        if odd_v[i] in odd_dic.keys():
            odd_dic[odd_v[i]] += 1
        else:
            odd_dic[odd_v[i]] = 1

    for i in range(len(even_v)):
        if even_v[i] in even_dic.keys():
            even_dic[even_v[i]] += 1
        else:
            even_dic[even_v[i]] = 1

    tem_dic = {}
    for k, v in sorted(even_dic.items(), key=lambda x: -x[1]):
        tem_dic[k] = v
    even_dic = tem_dic
    tem_dic = {}
    for k, v in sorted(odd_dic.items(), key=lambda x: -x[1]):
        tem_dic[k] = v
    odd_dic = tem_dic

    # odd_dic = sorted(odd_dic.items(),key=lambda x:x[1])
    # even_dic = sorted(even_dic.items(),key=lambda x:x[1])

    odd_keys = list(odd_dic.keys())
    even_keys = list(even_dic.keys())

    for i in range(len(odd_keys)-1):
        if odd_dic[odd_keys[i]] == odd_dic[odd_keys[i+1]]:
            if odd_keys[i] > odd_keys[i+1]:
                tem = odd_keys[i]
                odd_keys[i] = odd_keys[i+1]
                odd_keys[i+1] = tem

    for i in range(len(even_keys)-1):
        if even_dic[even_keys[i]] == even_dic[even_keys[i+1]]:
            if even_keys[i] > even_keys[i+1]:
                tem = even_keys[i]
                even_keys[i] = even_keys[i+1]
                even_keys[i+1] = tem


    # print(even_dic,odd_dic)
    # print(even_keys,odd_keys)
    if (len(odd_keys) == 1 and len(even_keys) == 1) and odd_keys[0] == even_keys[0]:
        answer = n/2
    elif odd_dic[odd_keys[0]] == even_dic[even_keys[0]]:
        ans1 = n-int(odd_dic[odd_keys[0]])-int(even_dic[even_keys[1]])
        ans2 = n-int(odd_dic[odd_keys[1]])-int(even_dic[even_keys[0]])
        answer = min(ans1, ans2)
    else:
        answer = n-int(odd_dic[odd_keys[0]])-int(even_dic[even_keys[0]])

    print(int(answer))
    # return(int(answer))

if __name__ == "__main__":
    n = int(input())
    v = list(int(i) for i in input().split())
    main(n,v)