problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 262k
1.05M
| problem_description
stringlengths 48
1.55k
| codes
stringlengths 35
98.9k
| status
stringlengths 28
1.7k
| submission_ids
stringlengths 28
1.41k
| memories
stringlengths 13
808
| cpu_times
stringlengths 11
610
| code_sizes
stringlengths 7
505
|
---|---|---|---|---|---|---|---|---|---|---|
p03244 | u811436126 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n print(n // 2)\nelse:\n v1 = [v[i] for i in range(0, n, 2)]\n v2 = [v[i + 1] for i in range(0, n, 2)]\n\n kw1 = Counter(v1)\n kw2 = Counter(v2)\n\n print(kw1)\n print(kw2)\n\n x1 = kw1.most_common()[0][0]\n x2 = kw2.most_common()[0][0]\n\n if x1 == x2:\n if kw1.most_common()[1][1] > kw2.most_common()[1][1]:\n x1 = kw1.most_common()[1][0]\n else:\n x2 = kw2.most_common()[1][0]\n\n ans = 0\n\n for i in v1:\n if i != x1:\n ans += 1\n\n for i in v2:\n if i != x2:\n ans += 1\n\n print(ans)\n', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n print(n // 2)\nelse:\n v1 = [v[i] for i in range(0, n, 2)]\n v2 = [v[i + 1] for i in range(0, n, 2)]\n\n kw1 = Counter(v1)\n kw2 = Counter(v2)\n\n x1 = kw1.most_common()[0][0]\n x2 = kw2.most_common()[0][0]\n\n if x1 != x2:\n ans = 0\n for i in v1:\n if i != x1:\n ans += 1\n for i in v2:\n if i != x2:\n ans += 1\n else:\n y1 = kw1.most_common()[1][0]\n y2 = kw2.most_common()[1][0]\n\n ans1 = 0\n ans2 = 0\n\n for i in v1:\n if i != y1:\n ans1 += 1\n for i in v2:\n if i != x2:\n ans1 += 1\n\n for i in v1:\n if i != x1:\n ans2 += 1\n for i in v2:\n if i != y2:\n ans2 += 1\n\n ans = min(ans1, ans2)\n\n print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s994628837', 's561435031'] | [24132.0, 20572.0] | [190.0, 137.0] | [682, 954] |
p03244 | u812576525 | 2,000 | 1,048,576 | 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. | ['N = int(input())\nV = list(map(int, input().split()))\n\neven = []\nodd = []\nfor i in range(len(V)):\n if V[i] % 2 ==0:\n even.append(V[i])\n else:\n odd.append(V[i])\n\neven =Counter(even)\neven = list(even.items())\neven = sorted(even,key=itemgetter(1),reverse = True)\n\nodd =Counter(odd)\nodd = list(odd.items())\nodd = sorted(odd,key=itemgetter(1),reverse = True)\n\ncnt = 0\nif len(odd) == 0 :\n if len(even) == 1:\n cnt = N // 2\n else:\n cnt = 0\nelif len(even) == 0 :\n if len(odd) == 1:\n cnt = N // 2\n else:\n cnt = 0\n\nelif even[0][1] != odd[0][1]:\n cnt = N - (even[0][1] + odd[0][1])\nelif odd[0][1] == even[0][1]:\n if even[1][1] > odd[1][1]:\n cnt = N- (odd[0][1] + even[1][1])\n elif odd[1][1] > even[1][1]:\n cnt = N- (even[0][1] + odd[1][1])\n\nprint(cnt)', 'from collections import Counter\n\nn = int(input())\nv = list(map(int,input().split()))\n\nac=Counter(v[::2]).most_common(2)\nbc=Counter(v[1::2]).most_common(2)\n\nprint(ac,bc)\nif ac[0][0] != bc[0][0]:\n ans = n -(ac[0][1] + bc[0][1])\nelif ac[0][1] == bc[0][1]:\n ans = n//2\nelse:\n ans = n-max(ac[1][1] + bc[0][1],bc[1][1] + ac[0][1])\n \n \nprint(ans)', 'from collections import Counter\nfrom operator import itemgetter\n\nN = int(input())\nV = Counter(map(int, input().split()))\n\nC = list(V.items())\nC = sorted(C,key=itemgetter(1),reverse = True)\n#print(C)\n\neven = []\nodd = []\nfor i in range(min(len(C),100)):\n if C[i][0] % 2 ==0:\n even.append(C[i])\n else:\n odd.append(C[i])\ncnt = 0\nif even[0][1] != odd[0][1]:\n for i in range(1,len(odd)):\n cnt += even[i][1]\n for i in range(1,len(even)):\n cnt += odd[i][1]\nprint(cnt)', 'from collections import Counter\nfrom operator import itemgetter\n\nN = int(input())\nV = Counter(map(int, input().split()))\n\n\nC = list(V.items())\nC = sorted(C,key=itemgetter(1),reverse = True)\n#print(C)\n\n\neven = []\nodd = []\nfor i in range(min(len(C),100)):\n if C[i][0] % 2 ==0:\n even.append(C[i])\n else:\n odd.append(C[i])\n#print(even,odd)\n\ncnt = 0\nif len(odd) == 0 :\n if len(even) == 1:\n cnt = N // 2\n else:\n cnt = 0\nelif len(even) == 0 :\n if len(odd) == 1:\n cnt = N // 2\n else:\n cnt = 0\nelif even[0][1] > odd[0][1]:\n cnt = even[0][1] - even[1][1]\nelif odd[0][1] > even[0][1]:\n cnt = odd[0][1] - odd[1][1]\nelif odd[0][1] == even[0][1]:\n if even[1][1] > odd[1][1]:\n cnt = even[0][1] - even[1][1]\n elif odd[1][1] > even[1][1]:\n cnt = odd[0][1] - odd[1][1]', 'from collections import Counter\n\nn = int(input())\nv = list(map(int,input().split()))\nac = Counter(v[::2]).most_common(2)\nbc = Counter(v[1::2]).most_common(2)\n\n\n\nif ac[0][0] != bc[0][0]: \n ans = n - ac[0][1] - bc[0][1] \nelse: \n if len(bc) == 1 or len(ac) == 1:\n ans = n // 2\n else: \n ans = n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s060939087', 's069408925', 's362736149', 's526946559', 's322464473'] | [13992.0, 15588.0, 22636.0, 22636.0, 15588.0] | [67.0, 78.0, 80.0, 93.0, 78.0] | [910, 354, 499, 901, 827] |
p03244 | u814781830 | 2,000 | 1,048,576 | 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. | ['N = int(input())\nV = list(map(int, input().split()))\no = {}\ne = {}\nfor i, v in enumerate(V):\n if i % 2 == 1:\n if not v in e.keys():\n e[v] = 0\n e[v] += 1\n else:\n if not v in o.keys():\n o[v] = 0\n o[v] += 1\n\no = sorted(o.values(), reverse=True)\ne = sorted(e.values(), reverse=True)\n\ne1 = sum(e[1:])\ne2 = sum(e[0] + e[2:])\no1 = sum(o[1:])\no2 = sum(o[2:])\nret = min(e1+o2, e2+o1)\nprint(ret)\n', 'from collections import Counter\nN = int(input())\nv = list(map(int, input().split()))\ne = []\no = []\nfor idx, i in enumerate(v):\n if idx % 2 == 0:\n o.append(i)\n else:\n e.append(i)\n\ne = Counter(e).most_common()\no = Counter(o).most_common()\nea = N // 2\ne1 = e[0][1]\ne2 = e[1][1]\noa = N - ea\no1 = o[0][1]\no2 = o[1][1]\ncnt = 0\nif e1 != o1:\n cnt = N - e1 - o1\nelse:\n if o2 > e1:\n cnt = N - e2 - o1\n else:\n cnt = N - e1 - o2\nprint(cnt)', 'from collections import Counter\nN = int(input())\nv = list(map(int, input().split()))\ne = []\no = []\nfor idx, i in enumerate(v):\n if idx % 2 == 0:\n o.append(i)\n else:\n e.append(i)\n\ne = Counter(e).most_common()\no = Counter(o).most_common()\ne1 = e[0][1]\ne2 = e[1][1] if len(e) > 1 else 0\no1 = o[0][1]\no2 = o[1][1] if len(o) > 1 else 0\ncnt = 0\nif e[0][0] != o[0][0]:\n cnt = N - e1 - o1\nelse:\n o = N - e1 - o2\n e = N - e2 - o1\n cnt = min(o, e)\nprint(cnt)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s817894624', 's858304245', 's692832541'] | [17656.0, 20828.0, 20844.0] | [95.0, 116.0, 107.0] | [442, 470, 481] |
p03244 | u814986259 | 2,000 | 1,048,576 | 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. | ['import collections\nn = int(input())\nv = list(map(int, input().split()))\n\nodd = [v[i] for i in range(n) if i % 2 == 0]\neven = [v[i] for i in range(n) if i % 2 == 1]\n\nt = collections.Counter(odd).most_common()\nt2 = collections.Counter(even).most_common()\n\nt = list(t.items())\nt.sort(reverse=True)\n\nt2 = list(t2.items())\nt2.sort(reverse=True)\n\n\nt.append([0, 0])\nt2.append([0, 0])\nans = t[0][1] + t2[0][1]\nif t[0][0] == t2[0][0]:\n ans = max(t[0][1] + t2[1][1], t[1][1]+t2[0][1])\nprint(n - ans)\n', 'import collections\nn = int(input())\nv = list(map(int, input().split()))\n\nodd = [v[i] for i in range(n) if i % 2 == 0]\neven = [v[i] for i in range(n) if i % 2 == 1]\n\nt = collections.defaultdict(int)\nt2 = collections.defaultdict(int)\nfor x in odd:\n t[x] += 1\nfor x in even:\n t2[x] += 1\n\nt = list(t.items())\nt.sort(key = lambda x:x[1], reverse=True)\n\nt2 = list(t2.items())\nt2.sort(key = lambda x:x[1],reverse=True)\n\n\nt.append([0, 0])\nt2.append([0, 0])\nans = t[0][1] + t2[0][1]\nif t[0][0] == t2[0][0]:\n ans = max(t[0][1] + t2[1][1], t[1][1]+t2[0][1])\nprint(n - ans)\n'] | ['Runtime Error', 'Accepted'] | ['s436986491', 's534080226'] | [21084.0, 19040.0] | [105.0, 137.0] | [493, 571] |
p03244 | u826263061 | 2,000 | 1,048,576 | 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. | ['import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\nv0 = [v[i] for i in range(0,n,2)]\nv1 = [v[i] for i in range(1,n,2)]\n\nv0cnt = collections.Counter(v0)\nv1cnt = collections.Counter(v1)\n\nv0most = v0cnt.most_common()[0]\nv1most = v1cnt.most_common()[0]\nv0next = v0cnt.most_common()[1]\nv1next = v1cnt.most_common()[1]\nif v0most[0] != v1most[0]:\n ans = n - v0most[1] -v1most[1]\nelse:\n if v0most[1] == v1most[1]:\n if v0most[1] == n//2:\n ans = n//2\n else:\n if v0next[1] > v1next[1]:\n ans = n - v1most[1] - v0next[1]\n else:\n ans = n - v0most[1] - v1next[1] \n elif v0most[1] > v1most[1]:\n ans = n - v0most[1] - v1next[1]\n else:\n ans = n - v1most[1] - v0next[1]\n\nprint(ans)', '# -*- coding: utf-8 -*-\n"""\nCreated on Sat Sep 29 16:33:51 2018\nABC111C\n@author: maezawa\n"""\n\nimport collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\nv0 = [v[i] for i in range(0,n,2)]\nv1 = [v[i] for i in range(1,n,2)]\n\nv0cnt = collections.Counter(v0)\nv1cnt = collections.Counter(v1)\n\nv0most = v0cnt.most_common()[0]\nv1most = v1cnt.most_common()[0]\nif len(v0cnt) > 1:\n v0next = v0cnt.most_common()[1]\nif len(v1cnt) > 1:\n v1next = v1cnt.most_common()[1]\nif v0most[0] != v1most[0]:\n ans = n - v0most[1] -v1most[1]\nelse:\n if v0most[1] == v1most[1]:\n if v0most[1] == n//2:\n ans = n//2\n else:\n if v0next[1] > v1next[1]:\n ans = n - v1most[1] - v0next[1]\n else:\n ans = n - v0most[1] - v1next[1] \n elif v0most[1] > v1most[1]:\n ans = n - v0most[1] - v1next[1]\n else:\n ans = n - v1most[1] - v0next[1]\n\nprint(ans)\n '] | ['Runtime Error', 'Accepted'] | ['s731901666', 's948401965'] | [19032.0, 19040.0] | [110.0, 111.0] | [799, 944] |
p03244 | u827241372 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\n\ndef main() -> None:\n n = int(input())\n p = [int(i) for i in input().split()]\n\n \n l1 = [int(p[i]) for i in range(0, n, 2)]\n \n l2 = [int(p[i]) for i in range(1, n, 2)]\n\n if len(set(p)) == 1:\n \n print(n // 2)\n else:\n lc1 = Counter(l1).most_common(2)\n lc2 = Counter(l2).most_common(2)\n\n if lc1[0][0] == lc2[0][0]:\n \n print(n - max(lc1[0][1] + lc2[1][1], lc1[1][1] + lc2[0][1]))\n else:\n \n print(n - lc1[0][1] - lc2[0][1])\n', "from collections import Counter\n\n\ndef main() -> None:\n n = int(input())\n p = [int(i) for i in input().split()]\n\n \n l1 = [int(p[i]) for i in range(0, n, 2)]\n \n l2 = [int(p[i]) for i in range(1, n, 2)]\n\n if len(set(p)) == 1:\n \n print(n // 2)\n else:\n lc1 = Counter(l1).most_common(2)\n lc2 = Counter(l2).most_common(2)\n\n if lc1[0][0] == lc2[0][0]:\n \n print(n - max(lc1[0][1] + lc2[1][1], lc1[1][1] + lc2[0][1]))\n else:\n \n print(n - lc1[0][1] - lc2[0][1])\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s120552485', 's836033620'] | [3316.0, 16604.0] | [27.0, 94.0] | [718, 758] |
p03244 | u830054172 | 2,000 | 1,048,576 | 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. | ['\nうまい寿司が食いたい。\nうまい寿司が遠慮なく食べれるようになるまで,進捗とか垂れ流すブログ\n201809-30\nABC111で学んだこと。\nABC 競技プログラミング\n昨日(2018/9/29)行われた,ABC111に参加した。\nただ,集中力が散漫でレートが落ちてしまったので,きっちり復習したいと思います。\n\nAtCoder Beginner Contest 111 - AtCoder\n\n以下,学んだことをまとめます。\n\nA問題\n猫のすぬけは文字を書く練習をしています。 すぬけは今日、数字の 1 と 9 を書く練習をしていたのですが、 間違えて 1 と 9 をあべこべに書いてしまいました。\nすぬけが書いた 3桁の整数nが与えられます。 \nnに含まれる 1 という桁をそれぞれ 9 に、 9 という桁をそれぞれ 1 に置き換えて得られる整数を出力してください。\n\nhttps://beta.atcoder.jp/contests/abc111/tasks/abc111_a\n\n要するに,三桁の整数の9と1を入れ替えてくださいという問題\n\n僕の回答はかなり間に合わせ的な回答で,\n\nN = str(input())\nprint(N.replace(\'1\',\'4\').replace(\'9\',\'1\').replace(\'4\',\'9\'))\npythonの組み込み関数であるreplaceでとりあず,1を適当な数字(ここでは4)に入れ替えて,9を1に入れ替えました。\nそして,最後に適当な数字を9に入れ替えるという方法を取りました。\n\nACになったコードを提出順にしてみて見てみます。\n\nd={\'1\':\'9\', \'9\':\'1\'}\nprint(\'\'.join(d[c] for c in input()))\nkyunaさんの回答\n\n1を9,9を1にする辞書を作っておいて,inputをkeyとして読み取る方法でした。\njoin関数の使い方をよく把握してなかったので,これは勉強になりました。\n\nl=list(input())\nfor i in range(len(l)):\n if(l[i]==\'9\'):\n print(1,end="")\n else:\n print(9,end="")\nankush_sharma_GL さんの回答\n\nfor文とif文を組み合わせれば良いというのと,最後の改行をなくすために,end=""を入れればよいということがわかりました。\n\nfor文とif文を組み合わせるのと,join関数を使う方法として,\n\na = list(input())\nfor i in range(3):\n if a[i] == "1":\n a[i] = "9"\n else:\n a[i] = "1"\nprint("".join(a))\nRyoTeiさんの回答\nというものもありました。そのままだと,listオブジェクトになるので,joinが必要なんですね。よくわかりました。\n\n賢いな,と思った回答としては,\n\nn=int(input())\nprint(1110-n)\naytkdkさんの回答\nがありました。これは本当に賢いと思います。\n\nB問題\n黒橋君は,AtCoder Beginner Contest (ABC) にまだ参加したことがありません.\n次に行われる ABC は第 N 回です. 黒橋君は,初めて参加する ABC を第 x 回としたときに,x の十進法表記でのすべての桁の数字が同じであるようにしたいです.\n黒橋君が初めて参加する ABC としてふさわしいもののうち,最も早いものは第何回でしょうか?\n\nゾロ目の大会に参加したい,という要請になります。 僕の回答は,if文の仕様がなぜかごっちゃになって冗長なコードになっていました。 いまから思えば,もっと簡単にかける気がしています。\n\nn = input()\n\nif int(n[0]) <= int(n[1]):\n if int(n[0]) == int(n[1]) and int(n[0]) >= int(n[2]):\n temp=int(n[0])\n print(temp*100+temp*10+temp)\n else:\n temp=int(n[0])+1\n print(temp*100+temp*10+temp)\nelse:\n temp=int(n[0])\n print(temp*100+temp*10+temp)\n僕の回答 だいぶ反省をしています。\n\nn = int(input())\n\na = -(-n//111)\n\nprint(a*111)\ntokuさんの回答\n多分これが正解なんじゃないでしょうか?\n111で割って切り上げて,その値を111倍する。シンプルかつわかりやすいです。\n\n切り捨てを使う方法として\n\nn = int(input())\nprint(111 * (int((n-1)/111)+1))\nminefyさんの回答\nがありました。\n\nこの辺りを参考に,切り捨て・切り上げのことは頭に置いておきます。\n\nC問題\n数列 a1, a2,..,an が以下の条件を満たすとき、 /\\/\\/\\/ と呼ぶことにします。\n- 各 i=1,2, ...,n−2 について、ai=ai+2\n- 数列に現れる数はちょうど 2 種類\n偶数長の数列 v1,v2,...,vn が与えられます。 要素をいくつか書き換えることでこの数列を /\\/\\/\\/ にしたいです。 \n書き換える要素の数は最小でいくつになるか求めてください。\n\n回答できませんでした。\n\nimport collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n print(int(n/2))\n\nelse:\n odd = v[0::2]\n even = v[1::2]\n if len(set(odd)) > 1:\n odd_c = collections.Counter(odd).most_common()[1:]\n values, odd_counts = zip(*odd_c)\n odd_num=sum(odd_counts)\n else:\n odd_num=0\n \n if len(set(even)) > 1:\n even_c = collections.Counter(even).most_common()[1:]\n values, even_counts = zip(*even_c)\n even_num=sum(even_counts)\n else:\n even_num=0\n \n print(odd_num+even_num)\n僕の回答\n\nこれでWAでした。\n理由は簡単で,最も多く出てくる数が同じ場合を考えてなかったためです。\n例\n1 2 1 2 1 1 2 1 3 1\nこのときに両者ともにすべての数字を1に変えるような操作の数を出力するようにしています。\nコードも冗長であまりよろしくなさそうです。\n\nさて,正解のコードを見る前に実装しながら学んだことを書いておきます。 まず\n\nimport collections\nこれを学びました。参考:ABCを解きながらググったサイト, 便利と書いていたQiitaの記事\n具体的な中身は参考のサイトを見ればよいのですが,このcollections.Counter()関数を使うことで,リスト内に出てくる数のカウントをしてくれます。\nただ,このままですと出てきた順にしか出力されないので,.most_common()をつけてあげることで,頻度順に並びます。大変便利ですね。\n\n次に,\n\n odd = v[0::2]\n even = v[1::2]\nこのリストの書き方です。\n1つ目の引数から,2つ目の引数だけスキップして読み取ることができます。\nこれのお陰で,偶数リスト,奇数リストの作成が簡単にできました。\n\nここまでで,\n\n偶数,奇数番目だけのリストを作成することができる。\nリスト内の要素を頻度順に出すことができる。\nようになりました。\n\nこれらを使ってどのように正解を導いているのか正答を見ていきます。\n\nfrom collections import Counter\n\n\ndef solve(V):\n n = len(V)\n ac = Counter(V[::2]).most_common(2)\n bc = Counter(V[1::2]).most_common(2)\n\n if ac[0][0] != bc[0][0]:\n return n - ac[0][1] - bc[0][1]\n else:\n if len(bc) == 1 or len(ac) == 1:\n return n // 2\n else:\n return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])\n\n\nif __name__ == "__main__":\n n = int(input())\n l = input()\n print(solve(l.split(" ")))\nmitsuo0114さんの回答\nソートして,現時点で一番速いものを選びました。\n\nmost_common(n)でn番目までの要素を出してくれます。\n今回の問題では「奇数番目の最頻値=偶数番目の最頻値」のときに二番目に出てくる要素の数を知る必要があるので,most_common(2)まで書けばよかったんですね。\n\n次に,if文は三通りに分かれています\n\n if ac[0][0] != bc[0][0]:\n return n - ac[0][1] - bc[0][1]\nhoge.most_common()[0][0]は,「最頻値が何か」\nhoge.most_common()[0][1]は,「最頻値が何回出てきたか」\nを出してくれます。\n\nつまり上のコードでは,最頻値が同じでない場合に,全体から偶数のリストと奇数のリストの最頻値の数を引いています。\nこれで,入れ替えるべき数がわかるんですね。\n\n else:\n if len(bc) == 1 or len(ac) == 1:\n return n // 2\n最頻値の数が同じとき,偶数リストと奇数リストの数字が完全に同じときに,こちらの数を返すようにしています。\n\n else:\n return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])\n ```\n最後のelse文です。ここの解読に一番時間がかかりました。<br>\n - 偶数リストの最頻値と奇数リストの二番目の頻度で出てくる値の和\n - 偶数リストの二番目の頻度で出てくる値と奇数リストの最頻値の和\nを取っています。<br>\n\nこの和の大きいほうが,入れ替えなくても良い数を最大化するものですので,`max()`関数を使うことで回答になります。<br>\n\n読むと納得できますね。\n\n\n\nたどり着かなかったので,今回はありません。\nLeo0523 292日前\n\nAdd Star\n \n関連記事\n StanとRでベイズ統計モデリング,\u30004章の計算をしてみた\n2019-01-13\nStanとRでベイズ統計モデリング, 4章の計算をしてみた\n概要 StanとRでベイズ統計モデリングの4章のベイズ信頼区間と予…\n FORM -first order reliability method- 近似的に公差解析を行う方法\u3000① 導入\u3000FORMって何?\n2018-06-29\nFORM -first order reliability method- 近似的に公差解析を行う方…\n公差解析の方法の一つFORM (First Order Reliability Method)に…\n« CUDAのインストール〜Jupyter Notebookへ…\nニンジンのポタージュ »\nプロフィール\n id:Leo0523\nid:Leo0523\n読者になる 1\n検索\n記事を検索\nリンク\nはてなブログ\nブログをはじめる\n週刊はてなブログ\nはてなブログPro\n最新記事\nベイズ線形回帰\nStanとRでベイズ統計モデリング,\u30004章の計算をしてみた\nreについて\nAutler-Townes効果について\nDask メモリにのらない大規模なcsvデータの取扱について\n月別アーカイブ\n▶ 2019 (2)\n▼ 2018 (12)\n2018 / 12 (2)\n2018 / 11 (2)\n2018 / 10 (2)\n2018 / 9 (1)\n2018 / 8 (3)\n2018 / 7 (1)\n2018 / 6 (1)\nはてなブログをはじめよう!\nLeo0523さんは、はてなブログを使っています。あなたもはてなブログをはじめてみませんか?\n\nはてなブログをはじめる(無料)\nはてなブログとは\n うまい寿司が食いたい。 うまい寿司が食いたい。\nPowered by Hatena Blog | ブログを報告する\n\n', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\nodd = v[::2]\neven = v[1::2]\n\nac = Counter(odd).most_common(2)\nbc = Counter(even).most_common(2)\n\nif ac[0][0] != bc[0][0]:\n print(n-ac[0][1]-bc[0][1])\nelse:\n if len(ac) == 1 and len(bc) == 1:\n print(n//2)\n else:\n print(n-max(ac[0][1]+bc[1][1], ac[1][1]+bc[0][1]))'] | ['Runtime Error', 'Accepted'] | ['s129737280', 's677398297'] | [2940.0, 15972.0] | [18.0, 76.0] | [10615, 372] |
p03244 | u842170774 | 2,000 | 1,048,576 | 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. | ['import collections\nn=int(input())\nm=n//2\nv1=list(map(int,input().split()))\nv2=[]\nfor j in range(m):\n v2.append(v1.pop(j))\na1=sorted((collections.Counter(v1)).items(),key=lambda x:x[1],reverse=True)\na2=sorted((collections.Counter(v2)).items(),key=lambda x:x[1],reverse=True)\nif a1[0][1]<a2[0][1]:a1,a2=a2[:],a1[:]\nprint(a2)\nif a1[0][0]!=a2[0][0]:\n print(n-a1[0][1]-a2[0][1])\nelif len(a2)==1:\n print(m)\nelse:\n print(n-a1[0][1]-a2[1][1])', 'import collections\nn=int(input())\nm=n//2\nv1=list(map(int,input().split()))\nv2=[]\nfor j in range(m):\n v2.append(v1.pop(j))\na1=sorted((collections.Counter(v1)).items(),key=lambda x:x[1],reverse=True)\na2=sorted((collections.Counter(v2)).items(),key=lambda x:x[1],reverse=True)\nif a1[0][1]<a2[0][1]:a1,a2=a2[:],a1[:]\nif a1[0][0]!=a2[0][0]:\n print(n-a1[0][1]-a2[0][1])\nelif len(a2)==1:\n print(m)\nelif a1[1][1]<a2[1][1]:\n print(n-a1[0][1]-a2[1][1])\nelse:\n print(n-a1[0][1]-a1[1][1])'] | ['Wrong Answer', 'Accepted'] | ['s351096662', 's142324993'] | [20912.0, 20392.0] | [853.0, 829.0] | [446, 491] |
p03244 | u842964692 | 2,000 | 1,048,576 | 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. | ['#111\nfrom collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\nL=list(Counter(v[0::2]).items())\nR=list(Counter(v[1::2]).items())\n\n\nif L[0][0]!=R[0][0]:\n ans=n-L[0][1]-R[0][1]\nelif len(R)!=1 and len(L)!=1:\n ans=n-max(L[0][1]+R[1][1],L[1][1]+R[0][1])\nelif len(R)!=1 and len(L)==1:\n ans=n-R[1][1]-L[0][1]\nelif len(R)==1 and len(L)!=1:\n ans=n-R[0][1]-L[1][1]\nelif : len(R)==1 and len(L)==1:\n ans=n//2\nprint(ans) \n', '#112\nfrom itertools import product\n\nN=int(input())\npx=[]\npy=[]\nph=[]\n\nfor _ in range(N):\n x,y,h=map(int,input().split())\n if h!=0:\n px.append(x)\n py.append(y)\n ph.append(h)\n\n\n \ndef Calc_H(Cxi,Cyj,pxi,pyj,hi):\n return hi+abs(Cxi-pxi)+abs(Cyj-pyj)\n\n \n \nfor Cxi,Cyj in product(range(101),range(101)):\n preH=Calc_H(Cxi,Cyj,px[0],py[0],ph[0])\n for i in range(1,N):\n nowH=Calc_H(Cxi,Cyj,px[i],py[i],ph[i])\n if preH!=nowH:\n break\n preH=nowH\n else:\n print(Cxi,Cyj,nowH)', '#111\nfrom collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\nL=Counter(v[0::2]).most_common()\nR=Counter(v[1::2]).most_common()\n\n\nif L[0][0]!=R[0][0]:\n ans=n-L[0][1]-R[0][1]\nelif len(R)!=1 and len(L)!=1:\n ans=n-max(L[0][1]+R[1][1],L[1][1]+R[0][1])\nelif len(R)!=1 and len(L)==1:\n ans=n-R[1][1]-L[0][1]\nelif len(R)==1 and len(L)!=1:\n ans=n-R[0][1]-L[1][1]\nelif len(R)==1 and len(L)==1:\n ans=n//2\nprint(ans) \n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s830491604', 's959099196', 's164829581'] | [3064.0, 10932.0, 20700.0] | [17.0, 25.0, 84.0] | [500, 552, 498] |
p03244 | u844005364 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\n\neven = a[1::2]\nodd = a[::2]\n\nc_even = Counter(even)\nc_odd = Counter(odd)\n\narr_even = c_even.most_common()\narr_odd = c_odd.most_common()\n\nsum_even = sum(x[1] for x in arr_even)\nsum_odd = sum(x[1] for x in arr_odd)\n\nmin_sum = sum_even - arr_even[0] + n // 2\n\nfor i, x in arr_even:\n for j, y in arr_odd:\n if i != j:\n cnt = sum_even - x + sum_odd - y\n min_sum = min(min_sum, cnt)\n break\n else:\n continue\n\nprint(min_sum)', 'from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\n\neven = a[1::2]\nodd = a[::2]\n\nc_even = Counter(even)\nc_odd = Counter(odd)\n\narr_even = c_even.most_common()\narr_odd = c_odd.most_common()\n\nsum_even = sum(x[1] for x in arr_even)\nsum_odd = sum(x[1] for x in arr_odd)\n\nmin_sum = sum_even - arr_even[0][1] + n // 2\n\nfor i, x in arr_even:\n for j, y in arr_odd:\n if i != j:\n cnt = sum_even - x + sum_odd - y\n min_sum = min(min_sum, cnt)\n break\n else:\n continue\n\nprint(min_sum)'] | ['Runtime Error', 'Accepted'] | ['s783464815', 's252797728'] | [21952.0, 21952.0] | [99.0, 125.0] | [563, 566] |
p03244 | u844646164 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\nfor_set_v = v \nset_v = set(v)\neven = []\nodd = []\ncount = 0 \ncount_list = []\nfor num in range(n):\n if num % 2 == 0:\n even.append(v[num])\n else:\n odd.append(v[num])\n\neven_most = Counter(even).most_common()\nodd_most = Counter(odd).most_common()\nprint(even_most)\nprint(odd_most)\nif len(set(v)) >= 2:\n if even_most[0][0] != odd_most[0][0]:\n if len(set(even)) != 1:\n count += (n/2) - int(even_most[0][1])\n if len(set(odd)) != 1:\n count += (n/2) - int(odd_most[0][1])\n else:\n try:\n count_list.append(n-int(even_most[0][1])-int(odd_most[1][1]))\n count_list.append(n-int(even_most[1][1])-int(odd_most[0][1]))\n count += int(max(count_list))\n except:\n if len(even_most) == 1:\n count += (n/2)-int(odd_most[1][1])\n elif len(odd_most) == 1:\n count += (n/2)-int(even_most[1][1])\nelse:\n count += (n/2)\nprint(int(count))\n', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\nfor_set_v = v \nset_v = set(v)\neven = []\nodd = []\ncount = 0 \ncount_list = []\nfor num in range(n):\n if num % 2 == 0:\n even.append(v[num])\n else:\n odd.append(v[num])\n\neven_most = Counter(even).most_common()\nodd_most = Counter(odd).most_common()\n#print(even_most)\n#print(odd_most)\nif len(set(v)) >= 2:\n if even_most[0][0] != odd_most[0][0]:\n if len(set(even)) != 1:\n count += (n/2) - int(even_most[0][1])\n if len(set(odd)) != 1:\n count += (n/2) - int(odd_most[0][1])\n else:\n try:\n count_list.append(n-int(even_most[0][1])-int(odd_most[1][1]))\n count_list.append(n-int(even_most[1][1])-int(odd_most[0][1]))\n #print(count_list)\n count += int(min(count_list))\n except:\n if len(even_most) == 1:\n count += (n/2)-int(odd_most[1][1])\n elif len(odd_most) == 1:\n count += (n/2)-int(even_most[1][1])\nelse:\n count += (n/2)\nprint(int(count))\n'] | ['Wrong Answer', 'Accepted'] | ['s285992218', 's574535151'] | [30428.0, 29276.0] | [159.0, 128.0] | [1085, 1118] |
p03244 | u845620905 | 2,000 | 1,048,576 | 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. | ['n1 = [[j, 0] for j in range(100005)]\nn2 = [[j, 0] for j in range(100005)]\nn = int(input())\nv = list(map(int, input().split()))\nfor i in range(n):\n if(i % 2 == 0):\n n1[v[i]][1] += 1\n else:\n n2[v[i]][1] += 1\nn1 = sorted(n1, key=lambda x:x[1], reverse=True)\nn2 = sorted(n2, key=lambda x:x[1], reverse=True)\n\nif(n1[0][0] == n2[0][0]):\n ans1 = n//2 - n1[0][1] + n//2 - n1[1][1]\n ans2 = n//2 - n1[1][1] + n//2 - n1[0][1]\n ans = min(ans1, ans2)\n print(ans)\nelse:\n ans = n//2 - n1[0][1] + n//2 - n1[0][1]\n print(ans)\n\n', 'n1 = [[j, 0] for j in range(100005)]\nn2 = [[j, 0] for j in range(100005)]\nn = int(input())\nv = list(map(int, input().split()))\nfor i in range(n):\n if(i % 2 == 0):\n n1[v[i]][1] += 1\n else:\n n2[v[i]][1] += 1\nn1 = sorted(n1, key=lambda x:x[1], reverse=True)\nn2 = sorted(n2, key=lambda x:x[1], reverse=True)\n\nif(n1[0][0] == n2[0][0]):\n ans1 = n//2 - n1[0][1] + n//2 - n2[1][1]\n ans2 = n//2 - n1[1][1] + n//2 - n2[0][1]\n ans = min(ans1, ans2)\n print(ans)\nelse:\n ans = n//2 - n1[0][1] + n//2 - n2[0][1]\n print(ans)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s260442800', 's585416720'] | [41204.0, 41204.0] | [198.0, 203.0] | [548, 548] |
p03244 | u846041485 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\n\u200b\ncnt = [Counter(), Counter()]\ncmn = [0, 0]\nfor parity in range(2):\n for i in (range(parity, n, 2)):\n cnt[parity][v[i]] += 1\n cmn[parity] = cnt[parity].most_common(1)[0]\n\u200b\nif cmn[0][0] != cmn[1][0]:\n ret = n - cmn[0][1] - cmn[1][1]\nelse:\n subcmn_mult = [0, 0]\n for parity in range(2):\n try:\n subcmn_mult[parity] = cnt[parity].most_common(2)[1][1]\n except IndexError:\n subcmn_mult[parity] = 0\n ret = n - cmn[0][1] - max(subcmn_mult[0], subcmn_mult[1])\nprint(ret)', "from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\n\nk = n // 2\nhalf = [Counter(), Counter()]\nfor i in range(k):\n for par in range(2):\n half[par][v[2*i+par]] += 1\n\ncmn = [0, 0]\nfor par in range(2):\n cmn[par] = half[par].most_common(2)\n if len(cmn[par]) == 1:\n cmn[par].append(('ghost', 0))\nif cmn[0][0][0] != cmn[1][0][0]:\n ret = n - cmn[0][0][1] - cmn[1][0][1]\nelse:\n ret = n - max(cmn[0][0][1] + cmn[1][1][1], cmn[0][1][1] + cmn[1][0][1])\nprint(ret)"] | ['Runtime Error', 'Accepted'] | ['s961377272', 's199929346'] | [2940.0, 17312.0] | [17.0, 170.0] | [611, 513] |
p03244 | u852386636 | 2,000 | 1,048,576 | 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. | ['import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\neven_odd_length = n / 2\nreplace_total = 0\n\nlist_odd = v[0::2]\nlist_even = v[1::2]\n\ndict_c_odd = dict(collections.Counter(list_odd))\ndict_c_even = dict(collections.Counter(list_even))\n\nif len(set(v)) == 1:\n print(int(even_odd_length))\nelse:\n max_count_c_odd = max(dict_c_odd.values())\n max_count_c_even = max(dict_c_even.values())\n max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]\n max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]\n \n if max_count_c_odd > max_count_c_even:\n if max_c_odd_keys[0] in dict_c_even:\n del dict_c_even[max_c_odd_keys[0]]\n max_count_c_even = max(dict_c_even.values())\n elif max_count_c_odd < max_count_c_even:\n if max_c_even_keys[0] in dict_c_odd:\n del dict_c_odd[max_c_even_keys[0]]\n max_count_c_odd = max(dict_c_odd.values())\n else:\n if len(max_c_odd_keys) > len(max_c_even_keys):\n if max_c_even_keys[0] in dict_c_odd:\n del dict_c_odd[max_c_even_keys[0]]\n max_count_c_odd = max(dict_c_odd.values())\n elif: len(max_c_odd_keys) > len(max_c_even_keys):\n if max_c_odd_keys[0] in dict_c_even:\n del dict_c_even[max_c_odd_keys[0]]\n max_count_c_even = max(dict_c_even.values())\n else:\n if max_c_odd_keys[0] in dict_c_even:\n del dict_c_even[max_c_odd_keys[0]]\n max_count_c_even = max(dict_c_even.values())\n replace_total += (n - max_count_c_odd - max_count_c_even)\n print(int(replace_total))', 'import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\neven_odd_length = len(v) / 2\nreplace_total = 0\n\nif len(set(v)) == 1:\n print(2)\nelse:\n c_even = collections.Counter(v[0::2])\n c_odd = collections.Counter(v[1::2])\n replace_total += even_odd_length - list(c_even.values())[0]\n replace_total += even_odd_length - list(c_odd.values())[0]\n print(replace_total)', 'import collections\n\nn = int(input())\nv = list(map(int, input().split()))\neven_odd_length = n / 2\nreplace_total = 0\n\nlist_odd = v[0::2]\nlist_even = v[1::2]\n\ndict_c_odd = dict(collections.Counter(list_odd))\ndict_c_even = dict(collections.Counter(list_even))\ndict_c_even_bk = dict_c_even.copy()\n\nreplace_total_tmp = 0\nreplace_total_tmp2 = 0\n\nmax_count_c_odd = max(dict_c_odd.values())\nmax_count_c_even = max(dict_c_even.values())\nmax_count_c_even_bk = max_count_c_even\n\nmax_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]\nmax_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]\n\nif len(set(v)) == 1:\n print(int(even_odd_length))\nelse: \n if max_c_odd_keys[0] in dict_c_even:\n del dict_c_even[max_c_odd_keys[0]]\n max_count_c_even = max(dict_c_even.values())\n replace_total_tmp = (n - max_count_c_odd - max_count_c_even)\n \n dict_c_even = dict_c_even_bk\n max_count_c_even = max_count_c_even_bk\n \n if max_c_even_keys[0] in dict_c_odd:\n del dict_c_odd[max_c_even_keys[0]]\n max_count_c_odd = max(dict_c_odd.values())\n replace_total_tmp2 = (n - max_count_c_odd - max_count_c_even)\n \n if replace_total_tmp >= replace_total_tmp2:\n replace_total = replace_total_tmp2\n else:\n replace_total = replace_total_tmp\n\n print(replace_total)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s101185227', 's213115640', 's933567780'] | [9072.0, 22916.0, 31960.0] | [28.0, 67.0, 81.0] | [1654, 396, 1342] |
p03244 | u853952087 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\na=int(input())\nA=list(map(int,input().split()))\nb=[A[i] for i in range(a) if i%2==0].sort()\nc=[A[i] for i in range(a) if i%2==1].sort()\nif b==c:\n print(a//2)\nelse:\n bc=Counter(b).most_common()\n cc=Counter(c).most_common()\n if bc[0][0]==cc[0][0]:\n print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))\n else: print(a-bc[0][1]-cc[0][1]) ', 'from collections import Counter\na=int(input())\nA=list(map(int,input().split()))\nbx=[A[i] for i in range(a) if i%2==0]\ncx=[A[i] for i in range(a) if i%2==1]\nb=sorted(bx)\nc=sorted(cx)\nprint(b,c)\nif b==c and len(set(b))==1 and len(set(c))==1:\n print(a//2)\nelse:\n bc=Counter(b).most_common()\n cc=Counter(c).most_common()\n print(bc,cc)\n if bc[0][0]==cc[0][0]:\n print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))\n else: print(a-bc[0][1]-cc[0][1]) ', 'from collections import Counter\n\na=int(input())\nA=list(map(int,input().split()))\nbx=[A[i] for i in range(a) if i%2==0]\ncx=[A[i] for i in range(a) if i%2==1]\n\nif b==c and len(set(b))==1 and len(set(c))==1:\n print(a//2)\nelse:\n bc=Counter(b).most_common()\n cc=Counter(c).most_common()\n if bc[0][0]==cc[0][0]:\n print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))\n else: print(a-bc[0][1]-cc[0][1]) ', 'from collections import Counter\n\na=int(input())\nA=list(map(int,input().split()))\nb=[A[i] for i in range(a) if i%2==0]\nc=[A[i] for i in range(a) if i%2==1]\n\nif b==c and len(set(b))==1 and len(set(c))==1:\n print(a//2)\nelse:\n bc=Counter(b).most_common()\n cc=Counter(c).most_common()\n if bc[0][0]==cc[0][0]:\n print(a-max(bc[1][1]+cc[0][1],bc[0][1]+cc[1][1]))\n else: print(a-bc[0][1]-cc[0][1]) '] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s059995603', 's255880353', 's483003035', 's876335171'] | [14892.0, 23644.0, 14892.0, 21084.0] | [94.0, 204.0, 65.0, 111.0] | [388, 468, 552, 550] |
p03244 | u856169020 | 2,000 | 1,048,576 | 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. | ['\nimport collections\n\nn = int(input())\nV = list(map(int, input().split()))\n\nevel = collections.Counter()\nodd = collections.Counter()\nfor index, v in enumerate(V):\n if index % 2 == 0:\n evel[v] += 1\n else:\n odd[v] += 1\nprint(evel, odd)\nif evel == odd:\n print(int(n / 2))\nelse:\n el = evel.most_common()\n ol = odd.most_common()\n max_val = 0\n for index_e, num_e in el:\n for index_o, num_o in ol:\n if index_e != index_o:\n max_val = max(max_val, num_e + num_o)\n ans = n - max_val\n print(ans)\n', 'import collections\n\nn = int(input())\nV = list(map(int, input().split()))\n\nevel = collections.Counter()\nodd = collections.Counter()\nfor index, v in enumerate(V):\n if index % 2 == 0:\n evel[v] += 1\n else:\n odd[v] += 1\n\nprint(evel.most_common(), odd.most_common())\nif evel == odd:\n print(int(n / 2))\nelse:\n if evel.most_common()[0][0] == odd.most_common()[0][0]:\n \n # ans = int(n / 2) - evel.most_common()[0][1] + int(n / 2) - odd.most_common()[1][1]\n # else:\n # ans = int(n / 2) - evel.most_common()[1][1] + int(n / 2) - odd.most_common()[0][1]\n el = evel.most_common(10)\n ol = odd.most_common(10)\n max_val = 0\n for index_e, num_e in el:\n for index_o, num_o in ol:\n if index_e != index_o:\n max_val = max(max_val, num_e + num_o)\n ans = n - max_val\n else:\n ans = int(n / 2) - evel.most_common()[0][1] + int(n / 2) - odd.most_common()[0][1]\n print(ans)\n', '\nimport collections\n\nn = int(input())\nV = list(map(int, input().split()))\n\n\ndef map_all(li):\n return all([e == li[0] for e in li[1:]]) if li else False\n\n\nevel = collections.Counter()\nevel2 = []\nodd = collections.Counter()\nodd2 = []\nfor index, v in enumerate(V):\n if index % 2 == 0:\n evel[v] += 1\n evel2.append(v)\n else:\n odd[v] += 1\n odd2.append(v)\n\nif map_all(evel2) and map_all(odd2):\n \n if evel2[0] == odd2[0]:\n \n print(int(n / 2))\n else:\n print(0)\nelse:\n el = evel.most_common(100)\n ol = odd.most_common(100)\n max_val = 0\n for index_e, num_e in el:\n for index_o, num_o in ol:\n if index_e != index_o:\n max_val = max(max_val, num_e + num_o)\n ans = n - max_val\n print(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s414259320', 's786443868', 's051089256'] | [22628.0, 23700.0, 17612.0] | [2105.0, 213.0, 167.0] | [558, 1059, 849] |
p03244 | u857759499 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nn,*v = map(int,open(0).read().split())\nv1 = Counter(v[::2])\nv2 = Counter(v[1::2])\nv1 = sorted([(i,v1[i]) for i in v1.keys()],key =lambda x:x[1],reverse=True)\nv2 = sorted([(i,v2[i]) for i in v2.keys()],key =lambda x:x[1],reverse=True)\nprint(v1,v2)\nif len(v1) == 1:\n if len(v2) == 1:\n if v1[0][0] != v2[0][0]:\n print(0)\n else:\n print(n//2)\n else:\n if v1[0][0] != v2[0][0]:\n print(n//2-v2[0][1])\n else:\n print(n//2-v2[1][1])\nelse:\n if len(v2) == 1:\n if v1[0][0] != v2[0][0]:\n print(n//2-v1[0][1])\n else:\n print(n//2-v1[1][1])\n else:\n if v1[0][0] != v2[0][0]:\n print(n-v1[0][1]-v2[0][1])\n else:\n print(min(n-v1[0][1]-v2[1][1],n-v1[1][1]-v2[0][1]))', 'from collections import Counter\nn,*v = map(int,open(0).read().split())\nv1 = Counter(v[::2])\nv2 = Counter(v[1::2])\nv1 = sorted([(i,v1[i]) for i in v1.keys()],key =lambda x:x[1],reverse=True)\nv2 = sorted([(i,v2[i]) for i in v2.keys()],key =lambda x:x[1],reverse=True)\nif v1[0][0] != v2[0][0]:\n print(n-v1[0][1]-v2[0][1])\nelse:\n e1 = n-v2[0][1] if len(v1) == 1 else n-v1[1][1]-v2[0][1]\n e2 = n-v1[0][1] if len(v2) == 1 else n-v1[0][1]-v2[1][1]\n print(min(e1,e2))'] | ['Wrong Answer', 'Accepted'] | ['s819407058', 's048734883'] | [23588.0, 23580.0] | [109.0, 91.0] | [743, 463] |
p03244 | u858742833 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\ndef main():\n N = int(input())\n V = list(map(int, input().split()))\n c0 = Counter(V[::2])\n c1 = Counter(V[1::2])\n cc0 = sorted([(0, 0)] + [(v, k) for k, v in c0.items()], reverse=True)\n cc1 = sorted([(0, 0)] + [(v, k) for k, v in c1.items()], reverse=True)\n m0, v0 = cc0[0]\n m1, v1 = cc0[1]\n if v0 != v1:\n return N - m0 - m1\n if m0 > m1:\n return N - m0 - cc1[1][0]\n return N - m1 - cc0[1][0]\nprint(main())\n', 'from collections import Counter\ndef main():\n N = int(input())\n V = list(map(int, input().split()))\n c0 = Counter(V[::2])\n c1 = Counter(V[1::2])\n cc0 = sorted([(0, 0)] + [(v, k) for k, v in c0.items()], reverse=True)\n cc1 = sorted([(0, 0)] + [(v, k) for k, v in c1.items()], reverse=True)\n m0, v0 = cc0[0]\n m1, v1 = cc1[0]\n if v0 != v1:\n return N - m0 - m1\n return min(N - m0 - cc1[1][0], N - m1 - cc0[1][0])\nprint(main())\n'] | ['Wrong Answer', 'Accepted'] | ['s015944150', 's174975660'] | [27528.0, 27652.0] | [144.0, 144.0] | [484, 459] |
p03244 | u859897687 | 2,000 | 1,048,576 | 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. | ['n=int(input())\ns=list(map(int,input().split()))\nd1=dict()\nd2=dict()\nfor i in range(0,n,2):\n if i not in d1:\n d1[i]=1\n else:\n d1[i]+=1\nfor i in range(1,n,2):\n if i not in d2:\n d2[i]=1\n else:\n d2[i]+=1\ndmk,dm,dmmk,dmm=[],0,[],0\nfor i in d1.keys():\n if dm<d1[i]:\n dmm=dm\n dmmk=dmk\n dm=d1[i]\n dmk=[i]\n elif d1==d1[i]:\n dmk+=[i]\n elif dmm<d1[i]:\n dmm=d1[i]\n dmmk=[i]\n elif dmm=d1[i]:\n dmmk+=[i]\nd1=[len(dmk),len(dmmk)]\ndmk,dm,dmmk,dmm=[],0,[],0\nfor i in d2.keys():\n if dm<d2[i]:\n dmm=dm\n dmmk=dmk\n dm=d2[i]\n dmk=[i]\n elif d2==d2[i]:\n dmk+=[i]\n elif dmm<d2[i]:\n dmm=d2[i]\n dmmk=[i]\n elif dmm=d2[i]:\n dmmk+=[i]\nd2=[len(dmk),len(dmmk)]\nif d1[0]>1 or d2[0]>1:\n print(n-d1[0]-d2[0])\nelse:\n print(n-max(d1[0]+d2[1],d1[1]+d2[0]))\n', 'n=int(input())\ns=list(map(int,input().split()))\nd1=dict()\nd2=dict()\nfor i in range(0,n,2):\n if i not in d1:\n d1[i]=1\n else:\n d1[i]+=1\nfor i in range(1,n,2):\n if i not in d2:\n d2[i]=1\n else:\n d2[i]+=1\ndmk,dm,dmmk,dmm=[],0,[],0\nfor i in d1.keys():\n if dm<d1[i]:\n dmm=dm\n dmmk=dmk\n dm=d1[i]\n dmk=[i]\n elif d1==d1[i]:\n dmk+=[i]\n elif dmm<d1[i]:\n dmm=d1[i]\n dmmk=[i]\n elif dmm==d1[i]:\n dmmk+=[i]\nd1=[dm,dmk,dmm,dmmk]\ndmk,dm,dmmk,dmm=[],0,[],0\nfor i in d2.keys():\n if dm<d2[i]:\n dmm=dm\n dmmk=dmk\n dm=d2[i]\n dmk=[i]\n elif d2==d2[i]:\n dmk+=[i]\n elif dmm<d2[i]:\n dmm=d2[i]\n dmmk=[i]\n elif dmm==d2[i]:\n dmmk+=[i]\nd2=[dm,dmk,dmm,dmmk]\nif len(d1[1])>1 or len(d2[1])>1:\n print(n-d1[0]-d2[0])\nelse:\n print(n-max(d1[0]+d2[2],d1[2]+d2[0]))\n', 'n=int(input())\ns=list(map(int,input().split()))\nd1=dict()\nd2=dict()\nfor i in range(0,n,2):\n if i not in d1:\n d1[i]=1\n else:\n d1[i]+=1\nfor i in range(1,n,2):\n if i not in d2:\n d2[i]=1\n else:\n d2[i]+=1\ndmk,dm,dmmk,dmm=[],0,[],0\nfor i in d1.keys():\n if dm<d1[i]:\n dmm=dm\n dmmk=dmk\n dm=d1[i]\n dmk=[i]\n elif d1==d1[i]:\n dmk+=[i]\n elif dmm<d1[i]:\n dmm=d1[i]\n dmmk=[i]\n elif dmm==d1[i]:\n dmmk+=[i]\nd1=[len(dmk),len(dmmk)]\ndmk,dm,dmmk,dmm=[],0,[],0\nfor i in d2.keys():\n if dm<d2[i]:\n dmm=dm\n dmmk=dmk\n dm=d2[i]\n dmk=[i]\n elif d2==d2[i]:\n dmk+=[i]\n elif dmm<d2[i]:\n dmm=d2[i]\n dmmk=[i]\n elif dmm==d2[i]:\n dmmk+=[i]\nd2=[len(dmk),len(dmmk)]\nif d1[0]>1 or d2[0]>1:\n print(n-d1[0]-d2[0])\nelse:\n print(n-max(d1[0]+d2[1],d1[1]+d2[0]))\n', 'n=int(input())\ns=list(map(int,input().split()))\nd1=dict()\nd2=dict()\nfor i in range(0,n,2):\n if s[i] not in d1:\n d1[s[i]]=1\n else:\n d1[s[i]]+=1\nfor i in range(1,n,2):\n if s[i] not in d2:\n d2[s[i]]=1\n else:\n d2[s[i]]+=1\ndmk,dm,dmmk,dmm=[],0,[],0\nfor i in d1.keys():\n if dm<d1[i]:\n dmm=dm\n dmmk=dmk\n dm=d1[i]\n dmk=[i]\n elif d1==d1[i]:\n dmk+=[i]\n elif dmm<d1[i]:\n dmm=d1[i]\n dmmk=[i]\n elif dmm==d1[i]:\n dmmk+=[i]\nd1=[dm,dmk,dmm,dmmk]\ndmk,dm,dmmk,dmm=[],0,[],0\nfor i in d2.keys():\n if dm<d2[i]:\n dmm=dm\n dmmk=dmk\n dm=d2[i]\n dmk=[i]\n elif d2==d2[i]:\n dmk+=[i]\n elif dmm<d2[i]:\n dmm=d2[i]\n dmmk=[i]\n elif dmm==d2[i]:\n dmmk+=[i]\nd2=[dm,dmk,dmm,dmmk]\nif len(d1[1])>1 or len(d2[1])>1 or d1[1]!=d2[1]:\n print(n-d1[0]-d2[0])\nelse:\n print(n-max(d1[0]+d2[2],d1[2]+d2[0]))\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s295445567', 's592225327', 's873349700', 's371190330'] | [3064.0, 19552.0, 19552.0, 18016.0] | [17.0, 119.0, 118.0, 124.0] | [792, 798, 794, 832] |
p03244 | u861141787 | 2,000 | 1,048,576 | 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. | ['import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\nl1 = []\nl2 = []\nfor i in range(n):\n if i % 2 == 0:\n l1.append(v[i])\n else:\n l2.append(v[i])\n\ncounter1 = collections.Counter(l1)\ncounter2 = collections.Counter(l2)\n\nmode_v1 = counter1.most_common()\nmode_v2 = counter2.most_common()\nprint(mode_v1, mode_v2)\n\nif mode_v1[0][0] != mode_v2[0][0]:\n print(n - mode_v1[0][1] - mode_v2[0][1])\nelse:\n print(n // 2 )', 'import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\nl1 = []\nl2 = []\nfor i in range(n):\n if i % 2 == 0:\n l1.append(v[i])\n else:\n l2.append(v[i])\n\ncounter1 = collections.Counter(l1)\ncounter2 = collections.Counter(l2)\n\nmode_v1 = counter1.most_common()\nmode_v2 = counter2.most_common()\n# print(mode_v1, mode_v2)\n\nif mode_v1[0][0] != mode_v2[0][0]:\n print(n - mode_v1[0][1] - mode_v2[0][1])\nelse:\n if len(set(v)) == 1:\n print(n // 2)\n elif len(set(l1)) == 1:\n print(mode_v2[0][1])\n elif len(set(l2)) == 1:\n print(mode_v1[0][1])\n else:\n print(min(n - mode_v1[0][1] - mode_v2[1][1], n - mode_v1[1][1] - mode_v2[0][1]))'] | ['Wrong Answer', 'Accepted'] | ['s026373414', 's282832324'] | [24928.0, 24016.0] | [154.0, 125.0] | [453, 696] |
p03244 | u861466636 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nvl = [int(i) for i in input().split()]\noc = Counter(a for i, a in enumerate(vl) if i % 2 == 0)\nec = Counter(a for i, a in enumerate(vl) if i % 2 == 1)\nol = sorted(((v, k) for k, v in oc.items()), reverse=True)\nel = sorted(((v, k) for k, v in ec.items()), reverse=True)\n\nif ol[0][1] != el[0][1]:\n print(n - ol[0][0] - el[0][0])\nelse:\n if ol[0][0] >= el[0][0]:\n if len(el) >= 2:\n print(n - ol[0][0] - el[1][0])\n else:\n print(n - ol[0][0])\n else:\n if len(ol) >= 2:\n print(n - ol[1][0] - el[0][0])\n else:\n print(n - el[0][0])', 'from collections import Counter\nn = int(input())\nvl = [int(i) for i in input().split()]\noc = Counter(a for i, a in enumerate(vl) if i % 2 == 0)\nec = Counter(a for i, a in enumerate(vl) if i % 2 == 1)\nol = sorted(((v, k) for k, v in oc.items()), reverse=True)\nel = sorted(((v, k) for k, v in ec.items()), reverse=True)\n\nif ol[0][1] != el[0][1]:\n print(n - ol[0][0] - el[0][0])\nelse:\n res = 1 << 30\n if len(ol) == len(el) == 1:\n res = n // 2\n if len(ol) > 1:\n res = min(res, n - ol[1][0] - el[0][0])\n if len(el) > 1:\n res = min(res, n - ol[0][0] - el[1][0])\n print(res)'] | ['Runtime Error', 'Accepted'] | ['s951050122', 's957085772'] | [14232.0, 23008.0] | [46.0, 128.0] | [619, 606] |
p03244 | u867826040 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nn = int(input())\nv = list(map(int,input().split()))\n\nif len(set(v)) == 1:\n print(n//2)\nelse:\n\n c1 = Counter(v[::2])\n c2 = Counter(v[1::2])\n o = c1.most_common(2)\n e = c2.most_common(2)\n o.append((0,0))\n e.append((0,0))\n if o[0][0] == e[0][0]:\n print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))\n else:\n print(n-o(2)[0][1]-e(2)[0][1])', 'from collections import Counter\nn = int(input())\nv = list(map(int,input().split()))\n\nif len(set(v)) == 1:\n print(n//2)\nelse:\n\n c1 = Counter(v[::2])\n c2 = Counter(v[1::2])\n o = c1.most_common(2)\n e = c2.most_common(2)\n o.append((0,0))\n e.append((0,0))\n if o[0][0] == e[0][0]:\n print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))\n else:\n print(n-o[0][1]-e[0][1])'] | ['Runtime Error', 'Accepted'] | ['s236362755', 's170494111'] | [22960.0, 23124.0] | [71.0, 70.0] | [403, 397] |
p03244 | u871303155 | 2,000 | 1,048,576 | 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. | ['import collections\n\nN = int(input())\nitems = list(map(int, input().split()))\n\n\neven_num = items[::2]\nodd_num = items[1::2]\n\n\ndev = Counter(even_num).most_common(2)\ndod = Counter(odd_num).most_common(2)\n\nif dev[0][0] == dod[0][0] :\n if len(dev) == len(dod) == 1 :\n print(N//2)\n elif len(dev) < len(dod) :\n print(N//2 - dod[1][1])\n elif len(dev) > len(dod) :\n print(N//2 - dev[1][1])\n else :\n print(N - max(dod[1][1] + dev[0][1], dod[0][1] + dev[1][1]))\nelse :\n print(N - dod[0][1]- dev[0][1])\n\n', 'from collections import Counter\n\nN = int(input())\nitems = list(map(int, input().split()))\n\n\neven_num = items[::2]\nodd_num = items[1::2]\n\n\ndev = Counter(even_num).most_common(2)\ndod = Counter(odd_num).most_common(2)\n\nif dev[0][0] == dod[0][0] :\n if len(dev) == len(dod) == 1 :\n print(N//2)\n elif len(dev) < len(dod) :\n print(N//2 - dod[1][1])\n elif len(dev) > len(dod) :\n print(N//2 - dev[1][1])\n else :\n print(N - max(dod[1][1] + dev[0][1], dod[0][1] + dev[1][1]))\nelse :\n print(N - dod[0][1]- dev[0][1])\n\n'] | ['Runtime Error', 'Accepted'] | ['s861790046', 's795377399'] | [14780.0, 16092.0] | [48.0, 83.0] | [651, 664] |
p03244 | u871374729 | 2,000 | 1,048,576 | 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. | ['import collections\n\nn = input()\nnums = list(map(int, input().split()))\nodd = nums[0::2]\neven = nums[1::2]\nodd_c = collections.Counter(odd)\neven_c = collections.Counter(even)\n\n\nif odd_c.most_common(1)[0][0] == even_c.most_common(1)[0][0]:\n if len(odd_c) >= 3 and len(even_c) >= 3:\n odd_first_count = len(odd) - odd_c.most_common(1)[0][1]\n even_first_count = len(even) - even_c.most_common(1)[0][1]\n odd_second_count = len(odd) - odd_c.most_common(2)[1][1]\n even_second_count = len(even) - even_c.most_common(2)[1][1]\n if odd_first_count + even_second_count > odd_second_count + even_first_count:\n print(odd_first_count + even_second_count)\n exit()\n else:\n print(odd_second_count + even_first_count)\n exit()\n odd_next_most = 0\n even_next_most = 0\n if len(odd_c) >= 2:\n odd_next_most = odd_c.most_common(2)[1][1]\n if len(even_c) >= 2:\n even_next_most = even_c.most_common(2)[1][1]\n if odd_next_most > even_next_most:\n print(len(odd) - odd_next_most + len(even) - even_c.most_common(1)[0][1])\n else:\n print(len(odd) - odd_c.most_common(1)[0][1] + len(even) - even_next_most)\nelse:\n print("else")\n odd_change = len(odd) - odd_c.most_common(1)[0][1]\n even_change = len(even) - even_c.most_common(1)[0][1]\n print(odd_change + even_change)\n', 'import collections\n\nn = input()\nnums = list(map(int, input().split()))\nodd = nums[0::2]\neven = nums[1::2]\nodd_c = collections.Counter(odd)\neven_c = collections.Counter(even)\nprint(odd_c)\nprint(even_c)\nif odd_c.most_common(1)[0][0] == even_c.most_common(1)[0][0]:\n odd_next_most = 0\n even_next_most = 0\n if len(odd_c) >= 2:\n odd_next_most = odd_c.most_common(2)[1][1]\n if len(even_c) >= 2:\n even_next_most = even_c.most_common(2)[1][1]\n if odd_next_most > even_next_most:\n print(len(odd) - odd_next_most)\n else:\n print(len(even) - even_next_most)\nelse:\n odd_change = len(odd) - odd_c.most_common(1)[0][1]\n even_change = len(even) - even_c.most_common(1)[0][1]\n if odd_change + even_change == 0:\n if odd_c.most_common(1)[0][0] == even_c.most_common(1)[0][0]:\n print(len(even))\n exit()\n print(odd_change + even_change)\n', 'import collections\n\nn = input()\nnums = list(map(int, input().split()))\nodd = nums[0::2]\neven = nums[1::2]\nodd_c = collections.Counter(odd)\neven_c = collections.Counter(even)\n\n\nif odd_c.most_common(1)[0][0] == even_c.most_common(1)[0][0]:\n if len(odd_c) >= 3 and len(even_c) >= 3:\n odd_first_count = len(odd) - odd_c.most_common(1)[0][1]\n even_first_count = len(even) - even_c.most_common(1)[0][1]\n odd_second_count = len(odd) - odd_c.most_common(2)[1][1]\n even_second_count = len(even) - even_c.most_common(2)[1][1]\n if odd_first_count + even_second_count < odd_second_count + even_first_count:\n print(odd_first_count + even_second_count)\n exit()\n else:\n print(odd_second_count + even_first_count)\n exit()\n odd_next_most = 0\n even_next_most = 0\n if len(odd_c) >= 2:\n odd_next_most = odd_c.most_common(2)[1][1]\n if len(even_c) >= 2:\n even_next_most = even_c.most_common(2)[1][1]\n if odd_next_most > even_next_most:\n print(len(odd) - odd_next_most + len(even) - even_c.most_common(1)[0][1])\n else:\n print(len(odd) - odd_c.most_common(1)[0][1] + len(even) - even_next_most)\nelse:\n print("else")\n odd_change = len(odd) - odd_c.most_common(1)[0][1]\n even_change = len(even) - even_c.most_common(1)[0][1]\n print(odd_change + even_change)\n', 'import collections\n\nn = input()\nnums = list(map(int, input().split()))\nodd = nums[0::2]\neven = nums[1::2]\nodd_c = collections.Counter(odd)\neven_c = collections.Counter(even)\n\n\nif odd_c.most_common(1)[0][0] == even_c.most_common(1)[0][0]:\n if len(odd_c) >= 3 and len(even_c) >= 3:\n odd_first_count = len(odd) - odd_c.most_common(1)[0][1]\n even_first_count = len(even) - even_c.most_common(1)[0][1]\n odd_second_count = len(odd) - odd_c.most_common(2)[1][1]\n even_second_count = len(even) - even_c.most_common(2)[1][1]\n if odd_first_count + even_second_count < odd_second_count + even_first_count:\n print(odd_first_count + even_second_count)\n exit()\n else:\n print(odd_second_count + even_first_count)\n exit()\n odd_next_most = 0\n even_next_most = 0\n if len(odd_c) >= 2:\n odd_next_most = odd_c.most_common(2)[1][1]\n if len(even_c) >= 2:\n even_next_most = even_c.most_common(2)[1][1]\n if odd_next_most > even_next_most:\n print(len(odd) - odd_next_most + len(even) - even_c.most_common(1)[0][1])\n else:\n print(len(odd) - odd_c.most_common(1)[0][1] + len(even) - even_next_most)\nelse:\n odd_change = len(odd) - odd_c.most_common(1)[0][1]\n even_change = len(even) - even_c.most_common(1)[0][1]\n print(odd_change + even_change)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s274086378', 's472155403', 's500373451', 's875743037'] | [19040.0, 22564.0, 19040.0, 19040.0] | [106.0, 148.0, 104.0, 104.0] | [1379, 903, 1379, 1361] |
p03244 | u871841829 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\nv_odd[1::2]\nv_even[0::2]\n\nv_odd_mc = Counter(v_odd).most_common()\nv_even_mc = Counter(v_even).most_common()\n\nv_odd_mc.append((0, 0))\nv_even_mc.append((0, 0))\n\nif v_odd_mc[0] != v_even_mc[0]:\n print(n-v_odd_mc[0][1]-v_even_mc[0][1])\nelse:\n print(n - max(v_odd_mc[0][1] + v_even_mc[1][1], v_odd_mc[1][0]+v_even_mc[0][1]))', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\nv_odd = v[1::2]\nv_even = v[0::2]\n\nv_odd_mc = Counter(v_odd).most_common()\nv_even_mc = Counter(v_even).most_common()\n\nv_odd_mc.append((0, 0))\nv_even_mc.append((0, 0))\n\nif v_odd_mc[0] != v_even_mc[0]:\n print(n-v_odd_mc[0][1]-v_even_mc[0][1])\nelse:\n print(n - max(v_odd_mc[0][1] + v_even_mc[1][1], v_odd_mc[1][1]+v_even_mc[0][1]))\n # print(min(n - v_odd_mc[0][1] - v_even_mc[1][1], n - v_odd_mc[1][1] - v_even_mc[0][1]))'] | ['Runtime Error', 'Accepted'] | ['s382461123', 's440883070'] | [14892.0, 21084.0] | [45.0, 87.0] | [412, 513] |
p03244 | u872887731 | 2,000 | 1,048,576 | 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. | ['import collections\n\nN = int(input().split())\na = list(map(int,input().split()))\n\nb = a[::2]\nc = a[1::2]\n\nb_ =collections.Counter(b)\nc_ =collections.Counter(c)\n\nbaa = b_.most_common(b_)\ncaa = c_.most_common(c_)\n\nbaa.append([0,0])\ncaa.append([0,0])\n\nif baa[0][0] != caa[0][0]:\n print(N - baa[0][1] - caa[0][1])\nelse:\n print(max(N - baa[0][1] - caa[1][1],N - caa[0][1] - baa[1][1]))', 'import collections\nN = int(input())\na = []\nb = []\nfor i in range(int(N/2)):\n a.append(input())\n b.append(input())\n\nac = collections.Counter(a)\nbc = collections.Counter(b)\n\na_1 = ac.most_common()[0]\nb_1 = ac.most_common()[0]\n\na1_ans = N/2 - a_1[1]\nb1_ans = N/2 - b_1[1]\nif len(ac.most_common()) == 1:\n a2_ans = N/2\nelse:\n a2_ans = N/2 - ac.most_common()[1][1]\nif len(bc.most_common()) == 1:\n b2_ans = N/2\nelse:\n b2_ans = N/2 - bc.most_common()[1][1]\n\nif a_1[0] != b_1[0]:\n print(int(a1_ans + b1_ans))\nelse:\n print(int(max(a1_ans+b2_ans,b1_ans+a2_ans)))', 'import collections\n\nN = int(input())\na = list(map(int,input()))\n\nb = a[::2]\nc = a[1::2]\n\nb_ =collections.Counter(b)\nc_ =collections.Counter(c)\n\nbaa = b_.most_common(b_)\ncaa = c_.most_common(c_)\n\nbaa.append([0,0])\ncaa.append([0,0])\n\nif baa[0][0] != caa[0][0]:\n print(N - baa[0][1] - caa[0][1])\nelse:\n print(max(N - baa[0][1] - caa[1][1],N - caa[0][1] - baa[1][1]))\n', 'import collections\nN = int(input())\na = []\nb = []\nfor i in range(int(N/2 + 0.1)):\n a.append(input().split())\n b.append(input().split())\n\nac = collections.Counter(a)\nbc = collections.Counter(b)\n\na_1 = ac.most_common()[0]\nb_1 = ac.most_common()[0]\n\na1_ans = N/2 - a_1[1]\nb1_ans = N/2 - b_1[1]\nif len(ac.most_common()) == 1:\n a2_ans = N/2\nelse:\n a2_ans = N/2 - ac.most_common()[1][1]\nif len(bc.most_common()) == 1:\n b2_ans = N/2\nelse:\n b2_ans = N/2 - bc.most_common()[1][1]\n\nif a_1[0] != b_1[0]:\n print(int(a1_ans + b1_ans))\nelse:\n print(int(max(a1_ans+b2_ans,b1_ans+a2_ans)))', 'import collections\n\nN = int(input())\na = list(map(int,input().split()))\n\nb = a[::2]\nc = a[1::2]\n\nb_ =collections.Counter(b)\nc_ =collections.Counter(c)\n\nbaa = b_.most_common(b_)\ncaa = c_.most_common(c_)\n\nbaa.append([0,0])\ncaa.append([0,0])\n\nif baa[0][0] != caa[0][0]:\n print(N - baa[0][1] - caa[0][1])\nelse:\n print(max(N - baa[0][1] - caa[1][1],N - caa[0][1] - baa[1][1]))', 'import collections\nN = int(input())\na = []\nb = []\nfor i in range(int(N/2)):\n a.append(input().split())\n b.append(input().split())\n\nac = collections.Counter(a)\nbc = collections.Counter(b)\n\na_1 = ac.most_common()[0]\nb_1 = ac.most_common()[0]\n\na1_ans = N/2 - a_1[1]\nb1_ans = N/2 - b_1[1]\nif len(ac.most_common()) == 1:\n a2_ans = N/2\nelse:\n a2_ans = N/2 - ac.most_common()[1][1]\nif len(bc.most_common()) == 1:\n b2_ans = N/2\nelse:\n b2_ans = N/2 - bc.most_common()[1][1]\n\nif a_1[0] != b_1[0]:\n print(int(a1_ans + b1_ans))\nelse:\n print(int(max(a1_ans+b2_ans,b1_ans+a2_ans)))', 'import collections\n\nN = int(input())\na = list(int(i) for i in input().split())\n\nb = a[::2]\nc = a[1::2]\n\nb_ =collections.Counter(b)\nc_ =collections.Counter(c)\n\nbaa = b_.most_common()\ncaa = c_.most_common()\n\nbaa.append([0,0])\ncaa.append([0,0])\n\nif baa[0][0] != caa[0][0]:\n print(N - baa[0][1] - caa[0][1])\nelse:\n print(min(N - baa[0][1] - caa[1][1],N - caa[0][1] - baa[1][1]))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s229127825', 's324832761', 's623756362', 's634146214', 's786796568', 's851836992', 's796113129'] | [3316.0, 4980.0, 4980.0, 10976.0, 19040.0, 10972.0, 21952.0] | [21.0, 22.0, 21.0, 29.0, 60.0, 29.0, 99.0] | [385, 575, 370, 597, 377, 591, 380] |
p03244 | u873269440 | 2,000 | 1,048,576 | 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. | ['\ndef main():\n\n\n N = int(input())\n V = list(map(int,input().split()))\n V1 = [i for i in V[0::2]]\n V2 = [i for i in V[1::2]]\n count1 = 0\n\n if len(list(set(V)))==1:\n print(int(N/2))\n exit()\n\n for i,j in enumerate(V1[1::]):\n if V1[i-1] != j:\n count1 +=1\n\n \n for i,j in enumerate(V2[1::]):\n if V2[i-1] != j:\n count1 +=1\n\n print(count1)\n\n\n\n\n\nif __name__== "__main__":\n main() \n', 'import collections\ndef main():\n\n\n N = int(input())\n V = list(map(int,input().split()))\n V1 = V[0::2]\n V2 = V[1::2]\n count = 0\n\n fre1 = collections.Counter(V1).most_common(2)\n fre2 = collections.Counter(V2).most_common(2)\n \n\n if len(list(set(V)))==1:\n print(int(N/2))\n exit()\n\n\n if fre1[0][0] != fre2[0][0]:\n\n count += len(V1)-fre1[0][1]\n count += len(V2)-fre2[0][1]\n print(count)\n elif len(V1)-fre1[0][1] == len(V2)-fre2[0][1]:\n bigger = max(fre1[1][1],fre2[1][1])\n count += len(V1)-bigger\n count += len(V1)-fre1[0][1]\n print(count)\n else:\n if len(V1)-fre1[0][1] < len(V2)-fre2[0][1]:\n count += len(V1)-fre1[0][1]\n count += len(V2)-fre2[1][1]\n print(count)\n else:\n count += len(V1)-fre1[1][1]\n count += len(V2)-fre2[0][1]\n print(count)\n\n \n\n\n\n\n\n\nif __name__== "__main__":\n main() \n'] | ['Wrong Answer', 'Accepted'] | ['s678679559', 's896640047'] | [16612.0, 16572.0] | [63.0, 79.0] | [454, 969] |
p03244 | u875855656 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nn=int(input())\nl=list(map(int,input().split()))\nf=l[0::2]\ns=l[1::2]\nans=[]\nif len(Counter(l).values()) == 1:\n ans.append(len(f))\nelif len(Counter(f).values()) == len(Counter(s).values()) == 1:\n ans.append(0)\nelse:\n print(Counter(f).items(),Counter(s).items())\n for fk,fv in sorted(Counter(f).items(),key=lambda x:x[0]):\n fdk=fk\n a=sum(Counter(f).values())-fv\n for sk,sv in sorted(Counter(s).items(),key=lambda x:x[0]):\n if fk != sk:\n ans.append(a+sum(Counter(s).values())-sv)\nprint(min(ans))', 'from collections import Counter\nn=int(input())\nl=list(map(int,input().split()))\nf=l[0::2]\ns=l[1::2]\nfn=sorted(Counter(f).items(),key=lambda x:x[1],reverse=True) + [(0, 0)]\nsn=sorted(Counter(s).items(),key=lambda x:x[1],reverse=True) + [(0, 0)]\nif fn[0][0]!=sn[0][0]:\n ans=n-fn[0][1]-sn[0][1]\nelse:\n ans=n-max(fn[1][1]+sn[0][1],fn[0][1]+sn[1][1])\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s338283592', 's990660629'] | [24920.0, 21212.0] | [2105.0, 96.0] | [548, 358] |
p03244 | u879674287 | 2,000 | 1,048,576 | 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. | ['\n\n#include <string>\n#include <cmath>\n#include <algorithm>\n#include <tuple>\nusing namespace std;\ntypedef long long ll;\n\n\n\n\nint main()\n{\n\n int n;\n cin >> n;\n int v[n];\n\n rep(i, n) cin >> v[i];\n\n int seq0[100001] = {}, seq1[100001] = {};\n for (int i = 0; i < n; i += 2)\n ++seq0[v[i]];\n for (int i = 1; i < n; i += 2)\n ++seq1[v[i]];\n\n sort(seq0 + 1, seq0 + 100001, greater<int>());\n sort(seq1 + 1, seq1 + 100001, greater<int>());\n\n if (seq0[0] == seq1[0])\n cout << min(n - seq0[0] - seq1[1], n - seq0[1] - seq1[0]);\n else\n cout << n - seq0[0] - seq1[0];\n}', 'from collections import defaultdict\n\n\ndef main():\n\n n = int(input())\n\n v = list(map(int, input().split(\' \')))\n\n odd = defaultdict(int)\n even = defaultdict(int)\n\n for i, num in enumerate(v):\n # print(i % 2)\n if (i % 2) == 0:\n even[num] += 1\n elif (i % 2) == 1:\n # print(i, ": ", num)\n odd[num] += 1\n\n x = sorted(even.items(), key=lambda x: x[1], reverse=True)\n y = sorted(odd.items, key=lambda x: x[1], reverse=True)\n\n if x[0][0] != y[0][0]:\n ans = n - x[0][1] - y[0][1]\n else:\n ans = n - max(x[0][1] + y[1][1], x[1][1] + y[0][1])\n\n print(ans)\n\n\nmain()\n', "from collections import defaultdict\n\nn = input()\nV = map(int, input().split())\n\nodd = defaultdict(int)\neven = defaultdict(int)\n\nmax_odd = 0\nmax_even = 0\nf_odd = 0\nf_even = 0\ns_odd = 0\ns_even = 0\n\nfor i, v in enumerate(V):\n i += 1\n if i % 2 == 0:\n even[v] += 1\n if even[v] > max_even:\n max_even = even[v]\n if f_even != 0 and v != f_even:\n s_even = f_even\n f_even = v\n elif f_even == 0:\n f_even = v\n\n elif i % 2 == 1:\n odd[v] += 1\n if odd[v] > max_odd:\n max_odd = odd[v]\n if f_odd != 0 and v != f_odd:\n s_odd = f_odd\n f_odd = v\n elif f_odd == 0:\n f_odd = v\n\nprint('test')\n# print(odd, even)\n# print(f'{max_odd}, {max_even}, {f_odd}, {s_odd}, {f_even}, {s_even}')\n", 'from collections import defaultdict\n\nn = int(input())\nV = map(int, input().split())\n\nodd = defaultdict(int)\neven = defaultdict(int)\n\nmax_odd = 0\nmax_even = 0\nf_odd = 0\nf_even = 0\ns_odd = 0\ns_even = 0\n\nfor i, v in enumerate(V):\n i += 1\n if i % 2 == 0:\n even[v] += 1\n if even[v] > max_even:\n max_even = even[v]\n if f_even != 0 and v != f_even:\n s_even = f_even\n f_even = v\n elif f_even == 0:\n f_even = v\n\n elif i % 2 == 1:\n odd[v] += 1\n if odd[v] > max_odd:\n max_odd = odd[v]\n if f_odd != 0 and v != f_odd:\n s_odd = f_odd\n f_odd = v\n elif f_odd == 0:\n f_odd = v\n\nhalf = n / 2\ncnt = 0\n\n\nif f_odd != f_even:\n c1 = (half - max_odd) + (half - max_even)\n c2 = (half - max_even) + (half - max_odd)\n if c1 > c2:\n cnt = c2\n else:\n cnt = c1\n num1 = f_odd\n num2 = f_even\nelif f_odd == f_even:\n c1 = (half - max_odd) + (half - even[s_even])\n c2 = (half - max_even) + (half - odd[s_odd])\n if c1 > c2:\n cnt = c2\n num1 = s_odd\n num2 = f_even\n else:\n cnt = c1\n num1 = f_odd\n num2 = s_even\n\nlast_odd = V[-2]\nlast_even = V[-1]\nif last_odd != num1 and last_odd == num2:\n cnt -= 1\nif last_even != num2 and last_even == num1:\n cnt -= 1\n\nprint(int(cnt))\n', '\n\n#include <string>\n#include <cmath>\n#include <algorithm>\n#include <tuple>\nusing namespace std;\ntypedef long long ll;\n\n\n\n\nint main()\n{\n\n int n;\n cin >> n;\n int v[n];\n\n rep(i, n) cin >> v[i];\n\n int seq0[100001] = {}, seq1[100001] = {};\n for (int i = 0; i < n; i += 2)\n ++seq0[v[i]];\n for (int i = 1; i < n; i += 2)\n ++seq1[v[i]];\n\n sort(seq0 + 1, seq0 + 100001, greater<int>());\n sort(seq1 + 1, seq1 + 100001, greater<int>());\n\n if (seq0[0] == seq1[0])\n cout << min(n - seq0[0][0] - seq1[0][1], n - seq[0][1] - seq1[0][0]);\n else\n cout << n - seq0[0][0] - seq1[0][0];\n}', 'from collections import defaultdict\n\n\ndef main():\n\n n = int(input())\n\n v = list(map(int, input().split(\' \')))\n\n odd = defaultdict(int)\n even = defaultdict(int)\n odd[0] = 0\n even[0] = 0\n\n for i, num in enumerate(v):\n # print(i % 2)\n if (i % 2) == 0:\n even[num] += 1\n elif (i % 2) == 1:\n # print(i, ": ", num)\n odd[num] += 1\n\n even_list = sorted(even.items(), key=lambda x: x[1], reverse=True)\n odd_list = sorted(odd.items(), key=lambda x: x[1], reverse=True)\n\n ans_list = []\n for ev in even_list[:2]:\n for od in odd_list[:2]:\n if ev[0] != od[0]:\n ans = 0\n ans += n - (ev[1] + od[1])\n ans_list.append(ans)\n\n print(min(ans_list))\n\n\nmain()\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s202112962', 's310684079', 's417184884', 's492098689', 's717181989', 's310290272'] | [2940.0, 17564.0, 21224.0, 21216.0, 2940.0, 21140.0] | [17.0, 109.0, 122.0, 126.0, 17.0, 121.0] | [781, 650, 854, 1416, 798, 789] |
p03244 | u882359130 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nV = [int(v) for v in input().split()]\n\nV1 = [V[n] for n in range(0, n, 2)] #v1, v3, v5, ...\nV2 = [V[n] for n in range(1, n, 2)] #v2, v4, v6, ...\n\nV1_set = list(set(V1))\nV1_cnt = []\nfor i in V1_set:\n i_cnt = V1.count(i)\n V1_cnt += [i, i_cnt]\nV1_cnt += [0, 0] \nV1_cnt.sort(key=lambda x: x[1], reverse=True)\n \nV2_set = list(set(V2))\nV2_cnt = []\nfor i in V2_set:\n i_cnt = V2.count(i)\n V2_cnt += [i, i_cnt]\nV2_cnt += [0, 0] \nV2_cnt.sort(key=lambda x: x[1], reverse=True)\n\nmxnum_V1_cnt = V1_cnt[0][0] \nmxnum_V2_cnt = V2_cnt[0][0] \nif mxnum_V1_cnt != mxnum_V2_cnt:\n ans = n - (V1_cnt[0][1] + V2_cnt[0][1])\nelse:\n ans = n - max(V1_cnt[0][1] + V2_cnt[1][1], V1_cnt[1][1] + V2_cnt[0][1])\n\nprint(ans)', 'n = int(input())\nV = [int(v) for v in input().split()]\n\nV1 = [V[n] for n in range(0, n, 2)] #v1, v3, v5, ...\nV2 = [V[n] for n in range(1, n, 2)] #v2, v4, v6, ...\n\nmx_V1 = max(V1)\nV1_cnt = [[0, 0]] \nfor i in range(1, mx_V1+1):\n V1_cnt.append([i, 0])\nfor v in V1:\n V1_cnt[v][1] += 1 \nV1_cnt.sort(key=lambda x: x[1], reverse=True)\n\nmx_V2 = max(V2)\nV2_cnt = [[0, 0]] \nfor j in range(1, mx_V2+1):\n V2_cnt.append([j, 0])\nfor v in V2:\n V2_cnt[v][1] += 1 \nV2_cnt.sort(key=lambda x: x[1], reverse=True)\n\nmxnum_V1_cnt = V1_cnt[0][0] \nmxnum_V2_cnt = V2_cnt[0][0] \nif mxnum_V1_cnt != mxnum_V2_cnt:\n ans = n - (V1_cnt[0][1] + V2_cnt[0][1])\nelse:\n ans = n - max(V1_cnt[0][1] + V2_cnt[1][1], V1_cnt[1][1] + V2_cnt[0][1])\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s249819407', 's795410818'] | [14468.0, 35896.0] | [2104.0, 204.0] | [935, 949] |
p03244 | u882831132 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nv = list(map(int, input().split()))\n\nva, ve = v[0::2], v[1::2]\nda, de = {}, {}\nfor a in va:\n da[a] = da.get(a, 0)+1\nfor e in ve:\n de[e] = de.get(e, 0)+1\nadd = sorted([(k,v) for k,v in da.items()], key=lambda x:-x[1])+[(0,0)]\neven = sorted([(k,v) for k,v in de.items()], key=lambda x:-x[1])+[(0,0)]\nif add[0][0] == even[0][0]:\n if add[1][1] <= even[1][1]:\n even.pop(0)\n else:\n add.pop(0)\nprint(n-add[0][1]-even[0][1])\nprint(add, even)\n', 'n = int(input())\nv = list(map(int, input().split()))\n\nva, ve = v[0::2], v[1::2]\nda, de = {}, {}\nfor a in va:\n da[a] = da.get(a, 0)+1\nfor e in ve:\n de[e] = de.get(e, 0)+1\nadd = sorted([(k,v) for k,v in da.items()], key=lambda x:-x[1])+[(0,0)]\neven = sorted([(k,v) for k,v in de.items()], key=lambda x:-x[1])+[(0,0)]\nif add[0][0] == even[0][0]:\n if add[1][1] <= even[1][1]:\n even.pop(0)\n else:\n add.pop(0)\nprint(n-add[0][1]-even[0][1])'] | ['Wrong Answer', 'Accepted'] | ['s013280094', 's833052922'] | [23932.0, 21880.0] | [140.0, 108.0] | [461, 443] |
p03244 | u886274153 | 2,000 | 1,048,576 | 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. | ['import collections\nn = int(input())\nv = [int(i) for i in input().split()]\n\ndummy = (-1, -1)\n(av1, ak1), (av2, ak2) = (collections.Counter(v[::2]).most_common(2) + dummy)[:2]\n(bv1, bk1), (bv2, bk2) = (collections.Counter(v[1::2]).most_common(2) + dummy)[:2]\n\nif av1 != bv1:\n print(n-ak1-bk1)\nelif ak1 < bk1:\n print(n-ak2-bk1)\nelse:\n print(n-ak1-bk2)', 'import collections\nn = int(input())\nv = [int(i) for i in input().split()]\n\ndummy = [(-1, 0)]\n(av1, ak1), (av2, ak2) = (collections.Counter(v[::2]).most_common(2) + dummy)[:2]\n(bv1, bk1), (bv2, bk2) = (collections.Counter(v[1::2]).most_common(2) + dummy)[:2]\n\nif av1 != bv1:\n print(n-ak1-bk1)\nelif ak1 < bk1:\n print(n-ak2-bk1)\nelif ak1 > bk1:\n print(n-ak1-bk2)\nelif ak1+bk2 > bk1+ak2:\n print(n-ak1-bk2)\nelse:\n print(n-ak2-bk1)'] | ['Runtime Error', 'Accepted'] | ['s014538916', 's405533194'] | [15588.0, 15588.0] | [66.0, 79.0] | [357, 440] |
p03244 | u887207211 | 2,000 | 1,048,576 | 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. | ['N = int(input())\nV = list(map(int,input().split()))\nnums = [v for v in V if V.count(x) != int(N/2)]\nprint(int(len(nums)/2))\n', 'from collections import Counter\n\nN = int(input())\nV = list(map(int,input().split()))\n\neven = Counter(V[1::2]).most_common() + [(0, 0)]\nodd = Counter(V[::2]).most_common() + [(0, 0)]\n\nif even[0][0] != odd[0][0]:\n print(N-even[0][1]-odd[0][1])\nelse:\n print(min(N-even[0][1]-odd[1][1], N-even[1][1]-odd[0][1]))'] | ['Runtime Error', 'Accepted'] | ['s458057606', 's486224455'] | [14404.0, 20572.0] | [41.0, 86.0] | [124, 309] |
p03244 | u896451538 | 2,000 | 1,048,576 | 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. | ['import math\nimport itertools\nimport fractions\nimport heapq\nimport collections\nimport bisect\nimport sys\n\nsys.setrecursionlimit(10**7)\nmod = 10**9+7\ninf = 10**20\n\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\ndef counter_top(c,exclude):\n for a in c.most_common():\n if a[0]!=exclude:\n return a\n return (object(),0)\n\ndef conv_seq(seq,exclude = None):\n c = collections.Counter(seq)\n mc = counter_top(c,exclude)\n return sum(c.values()) - mc[1],mc[0]\n\nN = I()\nV = LI()\n\nl = [V[i] for i in range(0,N,2)]\nr = [V[i] for i in range(1,N,2)]\n\ns1,a = conv_seq(V[::2])\ns2,b = conv_seq(V[1::2])\n\nif s1!=s2:\n print(a+b)\nelse:\n s1_new,_ = conv_seq(V[::2],exclude=b)\n s2_new,_ = conv_seq(V[1::2],exclude=a)\n print(min(s1_new+s2,s1+s2_new))', 'import math\nimport itertools\nimport fractions\nimport heapq\nimport collections\nimport bisect\nimport sys\n\nsys.setrecursionlimit(10**7)\nmod = 10**9+7\ninf = 10**20\n\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\ndef counter_top(c,exclude):\n for a in c.most_common():\n if a[0]!=exclude:\n return a\n return (object(),0)\n\ndef conv_seq(seq,exclude = None):\n c = collections.Counter(seq)\n mc = counter_top(c,exclude)\n return sum(c.values()) - mc[1],mc[0]\n\nN = I()\nV = LI()\n\ns1,a = conv_seq(V[::2])\ns2,b = conv_seq(V[1::2])\n\n\nif s1!=s2:\n print(s1+s2)\nelse:\n s1_new,_ = conv_seq(V[::2],exclude=b)\n s2_new,_ = conv_seq(V[1::2],exclude=a)\n print(min(s1_new+s2,s1+s2_new))\n'] | ['Wrong Answer', 'Accepted'] | ['s982077737', 's642922684'] | [19604.0, 18776.0] | [146.0, 138.0] | [1149, 1085] |
p03244 | u897328029 | 2,000 | 1,048,576 | 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. | ["n = int(input().split()[0])\nv_list = list(map(int, input().split()))\n\n\nodd_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 1]\n\neven_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 0]\n\n\nodd_counter = collections.Counter(odd_list)\nodd_1 = odd_counter.most_common()[0][0]\n\nif len(odd_counter) >= 2:\n odd_2 = odd_counter.most_common()[1][0]\nelse:\n odd_2 = '*' \n\n\neven_counter = collections.Counter(even_list)\neven_1 = even_counter.most_common()[0][0]\n\nif len(even_counter) >= 2:\n even_2 = even_counter.most_common()[1][0]\nelse:\n even_2 = '+' \n\n\n\n\nif even_1 == odd_1:\n \n even_op_count = len([v for v in even_list if v != even_1])\n \n odd_op_count = len([v for v in odd_list if v != odd_2])\n count_1 = even_op_count + odd_op_count\n\n \n even_op_count = len([v for v in even_list if v != even_2])\n \n odd_op_count = len([v for v in odd_list if v != odd_1])\n count_2 = even_op_count + odd_op_count\n\n count = min(count_1, count_2)\nelse:\n \n even_op_count = len([v for v in even_list if v != even_1])\n odd_op_count = len([v for v in odd_list if v != odd_1])\n count = even_op_count + odd_op_count\n\nprint(count)\n", "\n# C - /\\/\\/\\/\nimport collections\n\nn = int(input().split()[0])\nv_list = list(map(int, input().split()))\n\n\nodd_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 1]\n\neven_list = [str(v) for i, v in enumerate(v_list) if i % 2 == 0]\n\n\nodd_counter = collections.Counter(odd_list)\nodd_1 = odd_counter.most_common()[0][0]\n\nif len(odd_counter) >= 2:\n odd_2 = odd_counter.most_common()[1][0]\nelse:\n odd_2 = '*' \n\n\neven_counter = collections.Counter(even_list)\neven_1 = even_counter.most_common()[0][0]\n\nif len(even_counter) >= 2:\n even_2 = even_counter.most_common()[1][0]\nelse:\n even_2 = '+' \n\n\n\n\nif even_1 == odd_1:\n \n even_op_count = len([v for v in even_list if v != even_1])\n \n odd_op_count = len([v for v in odd_list if v != odd_2])\n count_1 = even_op_count + odd_op_count\n\n \n even_op_count = len([v for v in even_list if v != even_2])\n \n odd_op_count = len([v for v in odd_list if v != odd_1])\n count_2 = even_op_count + odd_op_count\n\n count = min(count_1, count_2)\nelse:\n \n even_op_count = len([v for v in even_list if v != even_1])\n odd_op_count = len([v for v in odd_list if v != odd_1])\n count = even_op_count + odd_op_count\n\nprint(count)\n"] | ['Runtime Error', 'Accepted'] | ['s634969414', 's931318906'] | [14008.0, 23864.0] | [83.0, 156.0] | [1643, 1729] |
p03244 | u898917044 | 2,000 | 1,048,576 | 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. | ['# abc111_c_new\n\nfrom collections import Counter\n\n\ndef solve(n, seq):\n odd = seq[::2] # odd numbers of the seq\n even = seq[1::2] # even numbers of the seq\n\n odd = Counter(odd).most_common() # example -> returns [(1, 5), (2, 5)]\n \n # even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)\n even = Counter(even).most_common()\n\n # print(odd)\n # print(even)\n\n sol = 0\n if odd[0][0] == even[0][0]:\n if len(odd) == 1 and len(even) == 1: # seq [1, 1, 1, 1] (special case)\n sol = int(n // 2) # [1, 1, 1, 1] sol = N / 2\n else:\n if odd[0][1] > even[1][1]:\n \n sol = (n / 2 - odd[0][1]) + (n / 2 - even[1][1])\n else:\n \n sol = (n / 2 - odd[1][1]) + (n / 2 - even[0][1])\n else:\n \n sol = (n / 2 - odd[0][1]) + (n / 2 - even[0][1])\n\n return sol\n\n\nif __name__ == "__main__":\n n = int(input())\n seq = list(map(int, input("").split(" ")))\n print(solve(n, seq))\n', '# abc111_c_new\n\nfrom collections import Counter\n\n\ndef solve(n, seq):\n odd = seq[::2] # odd numbers of the seq\n even = seq[1::2] # even numbers of the seq\n\n \n odd = sorted([(k, v) for k, v in Counter(odd).items()], key=lambda x: x[1], reverse=True)\n even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)\n # even = Counter(even).most_common()\n\n # print(odd)\n # print(even)\n\n sol = 0\n if odd[0][0] == even[0][0]:\n if len(odd) == 1 and len(even) == 1: # seq [1, 1, 1, 1] (special case)\n sol = int(n // 2) # [1, 1, 1, 1] sol = N / 2\n else:\n if odd[0][1] > even[1][1]:\n \n sol = (n / 2 - odd[0][1]) + (n / 2 - even[1][1])\n else:\n \n sol = (n / 2 - odd[1][1]) + (n / 2 - even[0][1])\n else:\n \n sol = (n / 2 - odd[0][1]) + (n / 2 - even[0][1])\n\n return sol\n\n\nif __name__ == "__main__":\n n = int(input())\n seq = list(map(int, input("").split(" ")))\n print(solve(n, seq))\n', '# abc111_c_new\n\nfrom collections import Counter\n\n\ndef solve(n, seq):\n odd = seq[::2] # odd numbers of the seq\n even = seq[1::2] # even numbers of the seq\n\n # print(odd)\n # print(even)\n\n \n # even = Counter(even).most_common()\n odd = sorted([(k, v) for k, v in Counter(odd).items()], key=lambda x: x[1], reverse=True)\n even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)\n\n # print(odd)\n # print(even)\n\n sol = 0\n if odd[0][0] == even[0][0]:\n if len(odd) == 1 and len(even) == 1: # seq [1, 1, 1, 1] (special case)\n sol = int(n // 2) # [1, 1, 1, 1] sol = N / 2\n else:\n if len(odd) >= 2 and len(even) >= 2:\n sol = min(n - odd[0][1] - even[1][1], n - odd[1][1] - even[0][1])\n else:\n if odd[0][1] > even[1][1]:\n \n sol = (n // 2 - odd[0][1]) + (n // 2 - even[1][1])\n else:\n \n sol = (n // 2 - odd[1][1]) + (n // 2 - even[0][1])\n else:\n \n sol = (n // 2 - odd[0][1]) + (n // 2 - even[0][1])\n\n return sol\n\n\nif __name__ == "__main__":\n n = int(input())\n seq = list(map(int, input("").split(" ")))\n print(solve(n, seq))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s401450206', 's538957181', 's714974897'] | [20828.0, 20820.0, 20820.0] | [86.0, 95.0, 94.0] | [1243, 1243, 1467] |
p03244 | u903460784 | 2,000 | 1,048,576 | 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. | ["\nn=int(input())\nv=input().split()\nvodd=[]\nveven=[]\nfor i in range(n):\n if i%2:\n veven.append(int(v[i]))\n else:\n vodd.append(int(v[i]))\n\nchangeCnt=0\n\nvoddNum=[vodd[0]]\nvoddCnt=[0]\nj=0\nfor i,odd in enumerate(vodd):\n if voddNum[j]!=odd:\n for k,num in enumerate(voddNum):\n if num==odd:\n j=k\n break\n else:\n j=k+1\n voddNum.append(odd)\n voddCnt.append(0)\n \n voddCnt[j]+=1\n\nvoddSet=list(zip(voddCnt, voddNum))\nprint(voddSet)\nfor i in range(len(voddSet)):\n voddSet[i]=list(voddSet[i])\n\nvoddSet=list(reversed(sorted(voddSet,key=lambda x:x[0])))\n\n\n\nvevenNum=[veven[0]]\nvevenCnt=[0]\nj=0\nfor i,even in enumerate(veven):\n if vevenNum[j]!=even:\n for k,num in enumerate(vevenNum):\n if num==even:\n j=k\n break\n else:\n j=k+1\n vevenNum.append(even)\n vevenCnt.append(0)\n\n vevenCnt[j]+=1\nvevenSet=list(zip(vevenCnt, vevenNum))\nprint(vevenSet)\nfor i in range(len(vevenSet)):\n vevenSet[i]=list(vevenSet[i])\n\nvevenSet=list(reversed(sorted(vevenSet,key=lambda x:x[0])))\n\n'''\nprint()\nprint(veven)\nprint(vevenNum)\nprint(vevenCnt)\nprint(vevenSet)\n'''\n\nchangeCnt+=len(vodd)+len(veven)\nif voddSet[0][1]==vevenSet[0][1]:\n if len(voddSet==1):\n changeCnt+=-len(vodd)\n else:\n if voddSet[1][0]>vevenSet[1][0]:\n changeCnt+=-voddSet[1][0]-vevenSet[0][0]\n else:\n changeCnt+=-voddSet[0][0]-vevenSet[1][0]\nelse:\n changeCnt+=-voddSet[0][0]-vevenSet[0][0]\n \nprint(changeCnt)\n \n", 'n=int(input())\nv=map(int,input().split())\nvodd={-1:0}\nveven={-1:0}\nfor i,vi in enumerate(v):\n if i%2:\n if(vi in veven):\n veven[vi]+=1\n else:\n veven[vi]=1\n else:\n if(vi in vodd):\n vodd[vi]+=1\n else:\n vodd[vi]=1\nveven=list(veven.items())\nveven.sort(key=lambda x:-x[1])\nvodd=list(vodd.items())\nvodd.sort(key=lambda x:-x[1])\nif veven[0][0]==vodd[0][0]:\n a=veven[0][1]+vodd[1][1]\n b=veven[1][1]+vodd[0][1]\n changeCnt=n-a if a>b else n-b\nelse:\n changeCnt=n-veven[0][1]-vodd[0][1]\n\nprint(changeCnt)'] | ['Runtime Error', 'Accepted'] | ['s741816266', 's382843300'] | [15952.0, 20912.0] | [2104.0, 108.0] | [1692, 581] |
p03244 | u903948194 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\nV = [int(n) for n in input().split()]\n\nif len(set(V)) == 1:\n ans = len(V) // 2\nelse:\n vp_ = [v for i, v in enumerate(V) if i%2 == 0] \n vn_ = [v for i, v in enumerate(V) if i%2 != 0] \n\n vp = Counter(vp_).most_common()\n vn = Counter(vn_).most_common()\n\n if vp[0][0] != vn[0][0]:\n gp = vp[0][1]\n gn = vn[0][1]\n else:\n if vp[0][1] > vn[0][1]:\n gp = vp[0][1]\n gn = vn[1][1]\n elif vp[0][1] < vn[0][1]:\n gp = vp[1][1]\n gn = vn[0][1]\n else vp[0][1] == vn[0][1]:\n if vp[1][1] >= vn[1][1]:\n gp = vp[1][1]\n gn = vn[0][1]\n else:\n gp = vp[0][1]\n gn = vn[1][1]\n \n ans = n - gp - gn\nprint(ans)', 'from collections import Counter\n\nn = int(input())\nV = [int(n) for n in input().split()]\n\nif len(set(V)) == 1:\n ans = len(V) // 2\nelse:\n vp_ = [v for i, v in enumerate(V) if i%2 == 0] \n vn_ = [v for i, v in enumerate(V) if i%2 != 0] \n\n vp = Counter(vp_).most_common()\n vn = Counter(vn_).most_common()\n\n if vp[0][0] != vn[0][0]:\n gp = vp[0][1]\n gn = vn[0][1]\n else:\n if vp[0][1] > vn[0][1]:\n gp = vp[0][1]\n gn = vn[1][1]\n elif vp[0][1] < vn[0][1]:\n gp = vp[1][1]\n gn = vn[0][1]\n else vp[0][1] == vn[0][1]:\n if vp[1][1] >= vn[1][1]:\n gp = vp[1][1]\n gn = vp[0][1]\n else:\n gp = vp[0][1]\n gn = vp[1][1]\n \n ans = n - gp - gn\nprint(ans)', 'from collections import Counter\n\nn = int(input())\nV = [int(n) for n in input().split()]\n\nif len(set(V)) == 1:\n ans = len(V) // 2\nelse:\n vp_ = [v for i, v in enumerate(V) if i%2 == 0] \n vn_ = [v for i, v in enumerate(V) if i%2 != 0] \n\n vp = Counter(vp_).most_common()\n vn = Counter(vn_).most_common()\n\n if vp[0][0] != vn[0][0]:\n gp = vp[0][1]\n gn = vn[0][1]\n else:\n if vp[0][1] > vn[0][1]:\n gp = vp[0][1]\n gn = vn[1][1]\n elif vp[0][1] < vn[0][1]:\n gp = vp[1][1]\n gn = vn[0][1]\n else:\n if vp[1][1] >= vn[1][1]:\n gp = vp[1][1]\n gn = vn[0][1]\n else:\n gp = vp[0][1]\n gn = vn[1][1]\n \n ans = n - gp - gn\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s414581363', 's607979644', 's964341817'] | [3064.0, 3064.0, 21076.0] | [24.0, 17.0, 118.0] | [813, 813, 792] |
p03244 | u904943473 | 2,000 | 1,048,576 | 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. | ['# C\nimport collections\nn = int(input())\nlst = list(map(int, input().split()))\nlst1 = lst[::2]\nlst2 = lst[1::2]\ndct1 = sorted(dict(collections.Counter(lst1)).items(), key=lambda x:-x[1])\ndct2 = sorted(dict(collections.Counter(lst2)).items(), key=lambda x:-x[1])\n\n\nans = 0\nprint(len(dct1))\nif (len(dct1) == 1 and len(dct2) == 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tans = dct1[0][1]\n\telse:\n\t\tans = 0\nelif (len(dct1) == 1 and len(dct2) > 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tans = len(dct2) - dct2[1][1]\n\telse:\n\t\tans = len(dct2) - dct2[0][1]\nelif (len(dct2) == 1 and len(dct1) > 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tans = len(dct1) - dct1[1][1]\n\telse:\n\t\tans = len(dct1) - dct1[0][1]\nelif (len(dct1) > 1 and len(dct2) > 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tans = len(lst) - max(dct1[0][1] + dct2[1][1], dct1[1][1] + dct2[0][1])\n\telse:\n\t\tans = len(lst) - dct1[0][1] - dct2[0][1]\nprint(ans)', 'print(0)', '# C\nimport collections\nn = int(input())\nlst = list(map(int, input().split()))\nlst1 = lst[::2]\nlst2 = lst[1::2]\ndct1 = sorted(dict(collections.Counter(lst1)).items(), key=lambda x:-x[1])\ndct2 = sorted(dict(collections.Counter(lst2)).items(), key=lambda x:-x[1])\n\ncnt = len(dict(collections.Counter(lst)))\nif (cnt == 1):\n\tprint(int(len(lst) / 2))\nelif (len(dct1) == 1):\n\tprint(0)\nelif (len(dct1) == 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tprint(len(dct2) - dct2[1][1])\n\telse:\n\t\tprint(len(dct2) - dct2[0][1])\nelif (len(dct2) == 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tprint(len(dct1) - dct1[1][1])\n\telse:\n\t\tprint(len(dct1) - dct1[0][1])\nelse:\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tprint(len(lst) - max(dct1[0][1] + dct2[1][1], dct1[1][1] + dct2[0][1]))\n\telse:\n\t\tprint(len(lst) - dct1[0][1] - dct2[0][1])\n', '# C\nimport collections\nn = int(input())\nlst = list(map(int, input().split()))\nlst1 = lst[::2]\nlst2 = lst[1::2]\ndct1 = sorted(dict(collections.Counter(lst1)).items(), key=lambda x:-x[1])\ndct2 = sorted(dict(collections.Counter(lst2)).items(), key=lambda x:-x[1])\n\ncnt = len(dict(collections.Counter(lst)))\nif (cnt == 1):\n\tprint(int(len(lst) / 2))\nelif (len(dct1) == 1 and len(dct2) == 1):\n\tprint(0)\n', '# C\nimport collections\nn = int(input())\nlst = list(map(int, input().split()))\nlst1 = lst[::2]\nlst2 = lst[1::2]\ndct1 = sorted(dict(collections.Counter(lst1)).items(), key=lambda x:-x[1])\ndct2 = sorted(dict(collections.Counter(lst2)).items(), key=lambda x:-x[1])\n\n\nans = 0\nif (len(dct1) == 1 and len(dct2) == 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tans = dct1[0][1]\n\telse:\n\t\tans = 0\nelif (len(dct1) == 1 and len(dct2) > 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tans = n // 2 - dct2[1][1]\n\telse:\n\t\tans = n // 2 - dct2[0][1]\nelif (len(dct2) == 1 and len(dct1) > 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tans = n // 2 - dct1[1][1]\n\telse:\n\t\tans = n // 2 - dct1[0][1]\nelif (len(dct1) > 1 and len(dct2) > 1):\n\tif (dct1[0][0] == dct2[0][0]):\n\t\tans = n - max(dct1[0][1] + dct2[1][1], dct1[1][1] + dct2[0][1])\n\telse:\n\t\tans = n - dct1[0][1] - dct2[0][1]\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s086373860', 's304319278', 's338708436', 's492709556', 's108109042'] | [24152.0, 2940.0, 27848.0, 27856.0, 24152.0] | [92.0, 17.0, 104.0, 104.0, 89.0] | [885, 8, 793, 397, 842] |
p03244 | u905203728 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nn=int(input())\nV=list(map(int,input().split()))\nV_1=[(0,0)]+sorted(Counter([V[i] for i in range(n) if i%2==0]).items(), key=lambda x:x[1])\nV_2=[(0,0)]+sorted(Counter([V[j] for j in range(n) if j%2==1]).items(), key=lambda x:x[1])\n\na,b=V_1[-1],V_2[-1]\nif a==b:b=V_2[-2]\n\ncnt=0\nfor i in range(n):\n if i%2==0:\n if V[i]!=a:cnt +=1\n else:\n if V[i]!=b:cnt +=1\n\nprint(cnt)', 'from collections import Counter\nn=int(input())\nV=list(map(int,input().split()))\n\neven=[(0,0)]+sorted(Counter(V[::2]).items(), key=lambda x:x[1])\nodd=[(0,0)]+sorted(Counter(V[1::2]).items(), key=lambda x:x[1])\n\nif even[-1][0]==odd[-1][0]:\n if even[-2][1]>odd[-2][1]:even=even[-2][0];odd=odd[-1][0]\n else:even=even[-1][0];odd=odd[-2][0]\nelse:even=even[-1][0];odd=odd[-1][0]\n\ncnt=0\nfor i,j in enumerate(V):\n if i%2==0 and j!=even:cnt +=1\n elif i%2==1 and j!=odd:cnt +=1\n\nprint(cnt)'] | ['Wrong Answer', 'Accepted'] | ['s735509016', 's502474117'] | [20700.0, 20700.0] | [137.0, 117.0] | [417, 490] |
p03244 | u905582793 | 2,000 | 1,048,576 | 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. | ["from collections import Counter\n\nN = int(input())\nl = list(map(int, input().split(' ')))\nl_odd = l[0::2]\nl_even = l[1::2]\ndict_odd = Counter(l_odd)\ndict_even = Counter(l_even)\nmost_odd = dict_odd.most_common()[0][0]\nmost_even = dict_even.most_common()[0][0]\n\nif dict_odd.most_common()[0][1] == dict_even.most_common()[0][1] == N / 2:\n ans = N / 2\n\nelif dict_odd.most_common()[0][1] == N / 2:\n ans = N / 2 - dict_even.most_common()[1][1]\n\nelif dict_even.most_common()[0][1] == N / 2:\n ans = N / 2 - dict_odd.most_common()[1][1]\n\nelif most_odd != most_even:\n ans = N - dict_odd.most_common()[0][1] - dict_even.most_common()[0][1]\n\nelse:\n ans = N - max(most_odd + dict_even.most_common()[1][0], most_even + dict_odd.most_common()[1][0])\n\nprint(ans)", "from collections import Counter\n\nN = int(input())\nl = list(map(int, input().split(' ')))\nl_odd = l[0::2]\nl_even = l[1::2]\ndict_odd = Counter(l_odd)\ndict_even = Counter(l_even)\nmost_odd = dict_odd.most_common()[0][0]\nmost_even = dict_even.most_common()[0][0]\n\nif dict_odd.most_common()[0][1] == dict_even.most_common()[0][1] == N / 2:\n if most_odd == most_even:\n ans = N / 2\n else:\n ans = 0\n\nelif dict_odd.most_common()[0][1] == N / 2:\n ans = N / 2 - dict_even.most_common()[1][1]\n\nelif dict_even.most_common()[0][1] == N / 2:\n ans = N / 2 - dict_odd.most_common()[1][1]\n\nelif most_odd != most_even:\n ans = N - dict_odd.most_common()[0][1] - dict_even.most_common()[0][1]\n\nelse:\n ans = N - max(dict_odd.most_common()[0][1] + dict_even.most_common()[1][1], dict_even.most_common()[0][1] + dict_odd.most_common()[1][1])\n\nprint(dict_odd, dict_even)\nprint(int(ans))", "from collections import Counter\n\nN = int(input())\nl = list(map(int, input().split(' ')))\nl_odd = l[0::2]\nl_even = l[1::2]\ndict_odd = Counter(l_odd)\ndict_even = Counter(l_even)\nmost_odd = dict_odd.most_common()[0][0]\nmost_even = dict_even.most_common()[0][0]\n\nif dict_odd.most_common()[0][1] == dict_even.most_common()[0][1] == N / 2:\n if most_odd == most_even:\n ans = N / 2\n else:\n ans = 0\n\nelif dict_odd.most_common()[0][1] == N / 2:\n ans = N / 2 - dict_even.most_common()[0][1]\n\nelif dict_even.most_common()[0][1] == N / 2:\n ans = N / 2 - dict_odd.most_common()[0][1]\n\nelif most_odd != most_even:\n ans = N - dict_odd.most_common()[0][1] - dict_even.most_common()[0][1]\n\nelse:\n ans = N - max(dict_odd.most_common()[0][1] + dict_even.most_common()[1][1], dict_even.most_common()[0][1] + dict_odd.most_common()[1][1])\n\nprint(int(ans))"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s463647858', 's955036946', 's092070464'] | [19040.0, 22568.0, 19040.0] | [140.0, 199.0, 152.0] | [760, 892, 865] |
p03244 | u917733926 | 2,000 | 1,048,576 | 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. | ['import collections\n\nN = int(input())\nV = list(int(i) for i in input().split())\neven = V[0::2]\nodd = V[1::2]\nhalf_count = len(even)\neven = collections.Counter(even).most_common(1)\neven_elem = even[0][0]\neven_count = even[0][1]\nodd = collections.Counter(odd).most_common(1)\nodd_elem = odd[0][0]\nodd_count = odd[0][1]\n\nif (even_count > odd_count):\n print((half_count - even_count) + (half_count + len(odd.count(even_elem))))\nelif (even_count < odd_count):\n print((half_count - odd_count) + (half_count + len(even.count(odd_elem))))\nelse:\n print(0)', 'import collections\nN = int(input())\nV = list(int(i) for i in input().split())\neven = V[0::2]\nodd = V[1::2]\neven_count = collections.Counter(even).most_common(2)\nodd_count = collections.Counter(odd).most_common(2)\n\nif even_count == N/2:\n print(N / 2 - odd_count)\nelif odd_count == N/2:\n print(N / 2 - even_count)\nelse:\n print(N - odd_count - even_count)', 'import collections\n\nN = int(input())\nV = list(int(i) for i in input().split())\neven = V[0::2]\nodd = V[1::2]\nall_length = len(V)\neven = collections.Counter(even).most_common(2)\nodd = collections.Counter(odd).most_common(2)\nif (even[0][0] != odd[0][0]):\n print(all_length - even[0][1] - odd[0][1])\nelse:\n if(len(even) == 1 and len(odd) == 1):\n print(all_length // 2)\n elif(len(even)==1):\n print(all_length // 2 - odd[1][1])\n elif(len(odd)==1):\n print(all_length // 2 - even[1][1]) \n else:\n print(min(all_length - even[0][1] - odd[1][1], all_length - even[1][1] - odd[0][1]))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s521469166', 's774473908', 's626937275'] | [15972.0, 15972.0, 15972.0] | [73.0, 94.0, 85.0] | [554, 362, 620] |
p03244 | u919633157 | 2,000 | 1,048,576 | 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. | ["# 2019/07/24\n\nfrom collections import Counter\n\nn=int(input())\nv=list(map(int,input().split()))\n\neven=[]\nodd=[]\n\nfor i in range(n):\n if i%2==0:even.append(v[i])\n else:odd.append(v[i])\n\ne=Counter(even).most_common(2)\ne=list([e[0][0]]+[e[1][0]])\no=Counter(odd).most_common(2)\no=list([o[0][0]]+[o[1][0]])\nans=float('inf')\nfor i in e:\n for j in o:\n cnt=0\n if i==j:continue\n for k in range(n):\n if k%2==0 and v[k]!=i:\n cnt+=1\n elif k%2==1 and v[k]!=j:\n cnt+=1\n ans=min(cnt,ans)\n\nprint(ans)", "# 2019/07/24\n\nfrom collections import Counter\n\nn=int(input())\nv=list(map(int,input().split()))\n\neven=[]\nodd=[]\n\nfor i in range(n):\n if i%2==0:even.append(v[i])\n else:odd.append(v[i])\n\ne=Counter(even).most_common(2)\nif len(e)<2:e=[e[0][0]]\nelse:e=list([e[0][0]]+[e[1][0]])\no=Counter(odd).most_common(2)\nif len(o)<2:o=[o[0][0]]\nelse:o=list([o[0][0]]+[o[1][0]])\n\nans=float('inf')\nfor i in e:\n for j in o:\n cnt=0\n if i==j:continue\n for k in range(n):\n if k%2==0 and v[k]!=i:\n cnt+=1\n elif k%2==1 and v[k]!=j:\n cnt+=1\n ans=min(cnt,ans)\n\nif ans==float('inf'):ans=n//2\nprint(ans)"] | ['Runtime Error', 'Accepted'] | ['s296004406', 's415111544'] | [15964.0, 16092.0] | [213.0, 226.0] | [572, 661] |
p03244 | u919689206 | 2,000 | 1,048,576 | 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. | ["import sys\nfrom collections import Counter\n\ndef main():\n input = sys.stdin.readline\n \n n = int(input())\n m = [int(i) for i in input().split()]\n \n even = [m[i] for i, _ in enumerate(m) if i % 2 == 0]\n odd = [m[i] for i, _ in enumerate(m) if i % 2 == 1]\n \n even_c = Counter(even).most_common(1)\n odd_c = Counter(odd).most_common(1)\n \n if even_c[0][0] == odd_c[0][0]:\n print(even_c[0][1])\n else:\n print(len(m) - (even_c + odd_c))\n\nif __name__ == '__main__':\n main()\n", "import sys\nfrom collections import Counter\n\ndef defs(c1, c2):\n if c1[0][0] > c2[0][0]:\n return c1[1], c2[0]\n else:\n return c1[0], c2[1]\n\ndef main():\n input = sys.stdin.readline\n \n n = int(input())\n m = [int(i) for i in input().split()]\n \n even = [m[i] for i, _ in enumerate(m) if i % 2 == 0]\n odd = [m[i] for i, _ in enumerate(m) if i % 2 == 1]\n \n even_c = Counter(even).most_common()\n odd_c = Counter(odd).most_common()\n \n if even_c[0] == odd_c[0]:\n print(len(m) / 2)\n return\n \n# print(even_c)\n# print(odd_c)\n \n even_c, odd_c = defs(even_c, odd_c)\n \n if even_c[1] == odd_c[1]:\n ans = len(odd) - min(even_c[1], odd_c[1])\n \n else:\n ans = len(m) - (even_c[1] + odd_c[1])\n \n print(ans)\n\n\nif __name__ == '__main__':\n main()\n \n", "import sys\nfrom collections import Counter\n \ndef main():\n input = sys.stdin.readline\n \n n = int(input())\n m = [int(i) for i in input().split()]\n \n \n even = [m[i] for i, _ in enumerate(m) if i % 2 == 0]\n odd = [m[i] for i, _ in enumerate(m) if i % 2 == 1]\n \n \n even_c = Counter(even).most_common()\n odd_c = Counter(odd).most_common()\n \n ans = -1\n \n #print(even_c)\n #print(odd_c)\n #print(len(even_c))\n \n \n if even_c[0][0] != odd_c[0][0]:\n ans = len(m) - (even_c[0][1] + odd_c[0][1])\n \n \n elif even_c[0][0] == odd_c[0][0] and len(even_c) > 1:\n ans1 = len(m) - (even_c[0][1] + odd_c[1][1])\n ans2 = len(m) - (even_c[1][1] + odd_c[0][1])\n ans = ans1 if ans1 <= ans2 else ans2\n \n \n else:\n ans = even_c[0][1]\n \n \n print(ans)\n \nif __name__ == '__main__':\n main()\n "] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s298056996', 's791069969', 's430513513'] | [16036.0, 21140.0, 21140.0] | [98.0, 109.0, 117.0] | [519, 849, 1064] |
p03244 | u921811474 | 2,000 | 1,048,576 | 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. | ['def solve(V):\n n = len(V)\n ac = Counter(V[::2]).most_common(2)\n bc = Counter(V[1::2]).most_common(2)\n print(ac,bc)\n if ac[0][0] != bc[0][0]:\n return n - ac[0][1] - bc[0][1]\n else:\n if len(bc) == 1 or len(ac) == 1:\n return n // 2\n else:\n return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])\n\n\nif __name__ == "__main__":\n n = int(input())\n l = input()\n print(l)\n print(solve(l.split(" ")))', 'from collections import Counter\n\n\ndef solve(V):\n n = len(V)\n ac = Counter(V[::2]).most_common(2)\n bc = Counter(V[1::2]).most_common(2)\n print(ac,bc)\n if ac[0][0] != bc[0][0]:\n return n - ac[0][1] - bc[0][1]\n else:\n if len(bc) == 1 or len(ac) == 1:\n return n // 2\n else:\n return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])\n\n\nif __name__ == "__main__":\n n = int(input())\n l = input()\n print(l)\n print(solve(l.split(" ")))', 'from collections import Counter\n\n\ndef solve(V):\n n = len(V)\n ac = Counter(V[::2]).most_common(2)\n bc = Counter(V[1::2]).most_common(2)\n \n if ac[0][0] != bc[0][0]:\n return n - ac[0][1] - bc[0][1]\n else:\n if len(bc) == 1 or len(ac) == 1:\n return n // 2\n else:\n return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])\n\n\nif __name__ == "__main__":\n n = int(input())\n l = input()\n\n print(solve(l.split(" ")))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s465765089', 's549147318', 's523239849'] | [11492.0, 17448.0, 16808.0] | [26.0, 67.0, 69.0] | [464, 498, 473] |
p03244 | u923279197 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\na=Counter(v[::2]).most_common() \nb=Counter(v[1::2]).most_common()\nif len(a)==1:\n a.append([0,0])\nif len(b)==1:\n b.append([0,0])\nif a[0,0]==b[0,0]:\n print(min(n-a[1,1]-b[0,1],n-a[0,1]-b[1,1]))\nelse:\n print(n-a[0,1]-b[0,1])\n', 'from collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\na=Counter(v[::2]).most_common() \nb=Counter(v[1::2]).most_common()\nif len(a)==1:\n a.append([0,0])\nif len(b)==1:\n b.append([0,0])\nif a[0][0]==b[0][0]:\n print(min(n-a[1,1]-b[0,1],n-a[0,1]-b[1,1]))\nelse:\n print(n-a[0,1]-b[0,1])\n', 'from collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\nset_v=set(v)\nif len(set_v)==1:\n print(n//2)\n exit()\na=Counter(v[::2]).most_common() \nb=Counter(v[1::2]).most_common()\nif a[0][0]==b[0][0]:\n print(min(n-b[0][1]-a[1][1],n-a[0][1]-b[1][1]))\nelse:\n print(n-a[0][1]-b[0][1])'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s065293773', 's962187995', 's211979086'] | [20700.0, 20700.0, 24796.0] | [83.0, 84.0, 95.0] | [372, 374, 369] |
p03244 | u923662841 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nv = list(map(int, input().split()))\na = sorted(([i,v[::2].count(i)] for i in set(v[::2])), key=lambda x:x[1])\nb = sorted(([j,v[1::2].count(j)] for j in set(v[1::2])),key=lambda x:x[1])\nif a[-1]!=b[-1]:\n print(n-a[-1][1]-b[-1][1])\nelif len(a) == 1 and len(b) == 1:\n print(min(a[-1][1],b[-1][1]))\nelif len(a) ==1:\n print(n-a[-1][1]-b[-2][1])\nelif len(b) ==1:\n print(n-a[-2][1]-b[-1][1])\nelse:\n print(min(n-a[-2][1]-b[-1][1],n-a[-1][1]-b[-2][1])', 'from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\na = Counter(v[::2]).most_common()\nb = Counter(v[1::2]).most_common()\na.append([0,0])\nb.append([0,0])\n\nif a[0][0]!=b[0][0]:\n print(n-a[0][1]-b[0][1])\nelse:\n print(min(n-a[1][1]-b[0][1],n-a[0][1]-b[1][1]))\n'] | ['Runtime Error', 'Accepted'] | ['s174141173', 's893098602'] | [9060.0, 25252.0] | [24.0, 77.0] | [474, 295] |
p03244 | u927764913 | 2,000 | 1,048,576 | 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. | ['import collections\nn = int(input())\nv = input().split()\nv_int = [int(i) for i in v]\nv_odd = []\nv_even = []\nfor i in range(int(n/2)):\n v_even.append(v_int[i*2])\n v_odd.append(v_int[i*2+1])\nprint(v_even)\nprint(v_odd)\nc_odd = collections.Counter(v_odd)\nc_even = collections.Counter(v_even)\nmax_odd = 0\nsecond_odd = 0\nmax_key_odd = 0\nfor key in c_odd:\n if max_odd < c_odd[key]:\n second_odd = max_odd\n max_odd = c_odd[key]\n max_key_odd = key\n elif second_odd < c_odd[key]:\n second_odd = c_odd[key]\n \nmax_even = 0\nsecond_even = 0\nmax_key_even = 0\nfor key in c_even:\n if max_even < c_even[key]:\n second_even = max_even\n max_even = c_even[key]\n max_key_even = key\n elif second_even < c_even[key]:\n second_even = c_even[key]\n \nprint(second_odd)\nprint(second_even)\nif max_key_even != max_key_odd:\n print(int(n)- max_even - max_odd)\nelse:\n if max_even > max_odd:\n if max_even == second_even:\n print(int(n) - max_even - max_odd)\n else:\n print(int(n) - max_even - second_odd)\n else:\n if max_odd = second_odd:\n print(int(n) - max_odd - max_even)\n else:\n print(int(n) - max_odd - second_even)', 'import collections\nn = int(input())\nv = input().split()\nv_int = [int(i) for i in v]\nv_odd = []\nv_even = []\nfor i in range(int(n/2)):\n v_even.append(v_int[i*2])\n v_odd.append(v_int[i*2+1])\nprint(v_even)\nprint(v_odd)\nc_odd = collections.Counter(v_odd)\nc_even = collections.Counter(v_even)\nmax_odd = 0\nsecond_odd = 0\nmax_key_odd = 0\nfor key in c_odd:\n if max_odd < c_odd[key]:\n second_odd = max_odd\n max_odd = c_odd[key]\n max_key_odd = key\n elif second_odd < c_odd[key]:\n second_odd = c_odd[key]\n \nmax_even = 0\nsecond_even = 0\nmax_key_even = 0\nfor key in c_even:\n if max_even < c_even[key]:\n second_even = max_even\n max_even = c_even[key]\n max_key_even = key\n elif second_even < c_even[key]:\n second_even = c_even[key]\n \nprint(second_odd)\nprint(second_even)\nif max_key_even != max_key_odd:\n print(int(n)- max_even - max_odd)\nelse:\n if max_even > max_odd:\n if max_even == second_even:\n print(int(n) - max_even - max_odd)\n else:\n print(int(n) - max_even - second_odd)\n else:\n if max_odd == second_odd:\n print(int(n) - max_odd - max_even)\n else:\n print(int(n) - max_odd - second_even)', 'import collections\nn = int(input())\nv = input().split()\nv_int = [int(i) for i in v]\nv_odd = []\nv_even = []\nfor i in range(int(n/2)):\n v_even.append(v_int[i*2])\n v_odd.append(v_int[i*2+1])\nprint(v_even)\nprint(v_odd)\nc_odd = collections.Counter(v_odd)\nc_even = collections.Counter(v_even)\nmax_odd = 0\nsecond_odd = 0\nmax_key_odd = 0\nfor key in c_odd:\n if max_odd < c_odd[key]:\n second_odd = max_odd\n max_odd = c_odd[key]\n max_key_odd = key\n elif second_odd < c_odd[key]:\n second_odd = c_odd[key]\n \nmax_even = 0\nsecond_even = 0\nmax_key_even = 0\nfor key in c_even:\n if max_even < c_even[key]:\n second_even = max_even\n max_even = c_even[key]\n max_key_even = key\n elif second_even < c_even[key]:\n second_even = c_even[key]\n \nprint(second_odd)\nprint(second_even)\nif max_key_even != max_key_odd:\n print(int(n)- max_even - max_odd)\nelse:\n if max_even > max_odd:\n print(int(n) - max_even - second_odd)\n else:\n print(int(n) - max_odd - second_even)', 'import collections\nn = int(input())\nv = input().split()\nv_int = [int(i) for i in v]\nv_odd = []\nv_even = []\nfor i in range(int(n/2)):\n v_even.append(v_int[i*2])\n v_odd.append(v_int[i*2+1])\nc_odd = collections.Counter(v_odd)\nc_even = collections.Counter(v_even)\nmax_odd = 0\nsecond_odd = 0\nmax_key_odd = 0\nfor key in c_odd:\n if max_odd < c_odd[key]:\n second_odd = max_odd\n max_odd = c_odd[key]\n max_key_odd = key\n elif second_odd < c_odd[key]:\n second_odd = c_odd[key]\n \nmax_even = 0\nsecond_even = 0\nmax_key_even = 0\nfor key in c_even:\n if max_even < c_even[key]:\n second_even = max_even\n max_even = c_even[key]\n max_key_even = key\n elif second_even < c_even[key]:\n second_even = c_even[key]\n \nif max_key_even != max_key_odd:\n print(int(n)- max_even - max_odd)\nelse:\n if max_even > max_odd:\n if max_even == second_even:\n print(int(n) - max_even - max_odd)\n else:\n print(int(n) - max_even - second_odd)\n elif max_even < max_odd:\n if max_odd == second_odd:\n print(int(n) - max_odd - max_even)\n else:\n print(int(n) - max_odd - second_even)\n else : \n if second_odd > second_even:\n print(int(n) - max_even - second_odd)\n else :\n print(int(n) - max_odd - second_even)'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s044522581', 's263257177', 's740127980', 's267580317'] | [3064.0, 24428.0, 24428.0, 23660.0] | [17.0, 127.0, 130.0, 126.0] | [1148, 1149, 981, 1246] |
p03244 | u934246119 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\nv = [int(_) for _ in input().split()]\n\n\n\n\n\nv1 = v[0:n-2:2]\nv2 = v[1:n-1:2]\nv1_count = Counter(v1)\nv2_count = Counter(v2)\n\nv1_1st_common = v1_count.most_common(1)\nv1_2nd_common = v1_count.most_common(2)\n\nv2_1st_common = v2_count.most_common(1)\nv2_2nd_common = v2_count.most_common(2)\nsols = []\n\n\nn1 = v1_1st_common[1]\n\nif v1_1st_common[0] == v2_1st_common[0]:\n n2 = v2_2nd_common[1]\nelse:\n n2 = v2_1st_common[1]\nsols.append(n-n1-n2)\n\n\nn2 = v2_1st_common[1]\n\nif v1_1st_common[0] == v2_1st_common[0]:\n n1 = v1_2nd_common[1]\nelse:\n n1 = v1_1st_common[1]\nsols.append(n-n1-n2)\nprint(min(sols))\n', 'from collections import Counter\n\nn = int(input())\nv = [int(_) for _ in input().split()]\n\n\n\n\n\nif len(Counter(v)) > 1:\n v1 = v[0:n+1:2]\n # print(v)\n # print(v1)\n v2 = v[1:n+2:2]\n # print(v2)\n v1_count = Counter(v1)\n v2_count = Counter(v2)\n\n v1_1st_common = v1_count.most_common(1)\n v2_1st_common = v2_count.most_common(1)\n sols = []\n # print(v1_1st_common[0][1], v2_1st_common[0][1])\n \n n1 = v1_1st_common[0][1]\n \n if v1_1st_common[0][0] == v2_1st_common[0][0]:\n if len(v2_count) >= 2:\n v2_2nd_common = v2_count.most_common(2)\n n2 = v2_2nd_common[1][1]\n else:\n print(n//2)\n else:\n n2 = v2_1st_common[0][1]\n sols.append(n-n1-n2)\n\n \n n2 = v2_1st_common[0][1]\n \n if v1_1st_common[0][0] == v2_1st_common[0][0]:\n if len(v1_count) >= 2:\n v1_2nd_common = v1_count.most_common(2)\n n1 = v1_2nd_common[1][1]\n else:\n print(n//2)\n else:\n n1 = v1_1st_common[0][1]\n sols.append(n-n1-n2)\n print(min(sols))\nelse:\n print(n//2)'] | ['Runtime Error', 'Accepted'] | ['s643382003', 's278965991'] | [19040.0, 19936.0] | [91.0, 99.0] | [1090, 1532] |
p03244 | u938486382 | 2,000 | 1,048,576 | 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. | ['n = int(input()) // 2\nns = list(map(int, input().split()))\n\nn = 200000\nns = [i for i in range(n)]\n\na = [ns[i] for i in range(len(ns)) if i % 2 == 0]\nb = [ns[i] for i in range(len(ns)) if i % 2 == 1]\nsa = set(a)\nsb = set(b)\n#ca = sorted([(a.count(s), s) for s in sa])[::-1]\n\n\nda = {}\ndb = {}\nfor s in sa:\n da[s] = da.get(s, 0) + 1\nfor s in sb:\n db[s] = db.get(s, 0) + 1\nca = sorted([(v, k) for k, v in da.items()])\ncb = sorted([(v, k) for k, v in db.items()])[::-1]\n\nif ca[0][1] != cb[0][1]:\n print(n-ca[0][0] + n-cb[0][0])\nelse:\n if len(ca) == 1 and len(cb) == 1:\n print(n)\n elif len(ca) == 1:\n print(n-ca[0][0] + n-cb[1][0])\n else:\n print(n-ca[1][0] + n-cb[0][0])', 'n = int(input()) // 2\nns = list(map(int, input().split()))\n\na = [ns[i] for i in range(len(ns)) if i % 2 == 0]\nb = [ns[i] for i in range(len(ns)) if i % 2 == 1]\nsa = set(a)\nsb = set(b)\n#ca = sorted([(a.count(s), s) for s in sa])[::-1]\n\n\nda = {}\ndb = {}\nfor s in sa:\n da[s] = da.get(s, 0) + 1\nfor s in sb:\n db[s] = db.get(s, 0) + 1\nca = sorted([(v, k) for k, v in da.items()])\ncb = sorted([(v, k) for k, v in db.items()])[::-1]\n\nif ca[0][1] != cb[0][1]:\n print(n-ca[0][0] + n-cb[0][0])\nelse:\n if len(ca) == 1 and len(cb) == 1:\n print(n)\n elif len(ca) == 1:\n print(n-ca[0][0] + n-cb[1][0])\n else:\n print(n-ca[1][0] + n-cb[0][0])', 'n = int(input()) // 2\nns = list(map(int, input().split()))\n\na = [ns[i] for i in range(len(ns)) if i % 2 == 0]\nb = [ns[i] for i in range(len(ns)) if i % 2 == 1]\n#ca = sorted([(a.count(s), s) for s in sa])[::-1]\n\n\nda = {}\ndb = {}\nfor s in a:\n da[s] = da.get(s, 0) + 1\nfor s in b:\n db[s] = db.get(s, 0) + 1\nca = sorted([(v, k) for k, v in da.items()])[::-1]\ncb = sorted([(v, k) for k, v in db.items()])[::-1]\n\nif ca[0][1] != cb[0][1]:\n print(n-ca[0][0] + n-cb[0][0])\nelse:\n if len(ca) == 1 and len(cb) == 1:\n print(n)\n elif len(ca) == 1 and len(cb) > 1:\n print(n-ca[0][0] + n-cb[1][0])\n elif len(ca) > 1 and len(cb) == 1:\n print(n-ca[1][0] + n-cb[0][0])\n else:\n print(min(n-ca[1][0] + n-cb[0][0], n-ca[0][0] + n-cb[1][0])) # ?'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s095491173', 's471605572', 's061718073'] | [52060.0, 25664.0, 22168.0] | [222.0, 141.0, 129.0] | [805, 766, 875] |
p03244 | u941753895 | 2,000 | 1,048,576 | 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. | ['n=int(input())\nif n==4:\n exit()\nl=list(map(int,input().split()))\nl1={}\nl2={}\nf=0\nfor i in l:\n if f==0:\n if i not in l1:\n l1[i]=1\n else:\n l1[i]+=1\n f=1\n else:\n if i not in l2:\n l2[i]=1\n else:\n l2[i]+=1\n f=0\nl1=sorted(l1.items(),key=lambda x:x[1],reverse=True)\nl2=sorted(l2.items(),key=lambda x:x[1],reverse=True)\nif l1[0][0]==l2[0][0]:\n if l1[0][1]==l2[0][1] and l1[0][1]==n//2:\n print(n//2)\n elif l1[0][1]>=l2[0][1]:\n print(n-l1[0][1]-l2[1][1])\n else:\n print(n-l1[1][1]-l2[0][1])\nelse:\n print(n-l1[0][1]-l2[0][1])', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef I(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n n=I()\n l=LI()\n\n l1=[]\n l2=[]\n\n f=True\n for x in l:\n if f:\n f=False\n l1.append(x)\n else:\n f=True\n l2.append(x)\n\n l1.sort()\n l2.sort()\n\n l3=[]\n l4=[]\n\n a=l1[0]\n c=1\n for x in l1[1:]:\n if a==x:\n c+=1\n else:\n l3.append([a,c])\n a=x\n c=1\n l3.append([a,c])\n\n a=l2[0]\n c=1\n for x in l2[1:]:\n if a==x:\n c+=1\n else:\n l4.append([a,c])\n a=x\n c=1\n l4.append([a,c])\n\n l3=sorted(l3,key=lambda x:x[1],reverse=True)\n l4=sorted(l4,key=lambda x:x[1],reverse=True)\n\n print(l3)\n print(l4)\n\n if l3[0][0]==l4[0][0]:\n if len(l3)==1:\n return n-l3[0][1]-l4[1][1]\n elif len(l4)==1:\n return n-l3[1][1]-l4[0][1]\n else:\n return min(n-l3[0][1]-l4[1][1],n-l3[1][1]-l4[0][1])\n else:\n return n-l3[0][1]-l4[0][1]\n\nprint(main())\n', "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n n=II()\n l=LI()\n\n if n==4 and ' '.join(str(x) for x in l)=='3 1 3 2':\n exit()\n\n l1=[]\n l2=[]\n\n for i in range(len(l)):\n if i%2==0:\n l1.append(l[i])\n else:\n l2.append(l[i])\n\n l1.sort()\n l2.sort()\n\n a1=[l1[0],1]\n a2=[0,0]\n b1=[l2[0],1]\n b2=[0,0]\n\n _a=l1[0]\n c1=1\n for x in l1[1:]:\n if _a==x:\n c1+=1\n else:\n if c1>a1[1]:\n if a1[0]!=l1[0]:\n a2[0]=a1[0]\n a2[1]=a1[1]\n a1[0]=_a\n a1[1]=c1\n elif c1>a2[1]:\n if a1[0]!=_a:\n a2[0]=_a\n a2[1]=c1\n _a=x\n c1=1\n if c1>a1[1]:\n if a1[0]!=l1[0]:\n a2[0]=a1[0]\n a2[1]=a1[1]\n a1[0]=_a\n a1[1]=c1\n elif c1>a2[1]:\n if a1[0]!=_a:\n a2[0]=_a\n a2[1]=c1\n\n _b=l2[0]\n c2=1\n for x in l2[1:]:\n if _b==x:\n c2+=1\n else:\n if c2>b1[1]:\n if b1[0]!=l2[0]:\n b2[0]=b1[0]\n b2[1]=b1[1]\n b1[0]=_b\n b1[1]=c2\n elif c2>b2[1]:\n if b1[0]!=_b:\n b2[0]=_b\n b2[1]=c2\n _b=x\n c2=1\n if c2>b1[1]:\n if b1[0]!=l2[0]:\n b2[0]=b1[0]\n b2[1]=b1[1]\n b1[0]=_b\n b1[1]=c2\n elif c2>b2[1]:\n if b1[0]!=_b:\n b2[0]=_b\n b2[1]=c2\n\n if a1[0]!=b1[0]:\n return len(l1)-a1[1]+len(l2)-b1[1]\n else:\n return min(len(l1)-a1[1]+len(l2)-b2[1],len(l1)-a2[1]+len(l2)-b1[1])\n\n# main()\nprint(main())\n", 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef I(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n n=I()\n l=LI()\n\n l1=[]\n l2=[]\n\n for i in range(len(l)):\n if i%2==0:\n l1.append(l[i])\n else:\n l2.append(l[i])\n\n l1.sort()\n l2.sort()\n\n a=[]\n b=[]\n\n p=l1[0]\n c=1\n mx=1\n for x in l1[1:]:\n if x==p:\n c+=1\n else:\n a.append([p,c])\n c=1\n p=x\n a.append([p,c])\n\n p=l2[0]\n c=1\n mx=1\n for x in l2[1:]:\n if x==p:\n c+=1\n else:\n b.append([p,c])\n c=1\n p=x\n b.append([p,c])\n\n a=sorted(a,key=lambda x:x[1],reverse=True)\n b=sorted(b,key=lambda x:x[1],reverse=True)\n\n if a[0][0]==b[0][0]:\n if len(a)==1 and len(b)==1:\n return n//2\n return min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1])\n return n-a[0][1]-b[0][1]\n\nprint(main())\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s258621052', 's341626042', 's412850058', 's197256919'] | [19052.0, 24604.0, 17060.0, 21532.0] | [95.0, 205.0, 124.0, 165.0] | [567, 1113, 1653, 993] |
p03244 | u944325914 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\nv1=[]\nv2=[]\nfor i in range(n//2):\n v1.append(v[2*i])\n v2.append(v[2*i+1])\nv1_count=Counter(v1)\nv2_count=Counter(v2)\nif v1==v2:\n print(n//2)\nelif v1_count.most_common()[0][0]!=v2_count.most_common()[0][0]:\n print(n-v1_count.most_common()[0][1]-v2_count.most_common()[0][1])\n print(v1_count.most_common())\n print(v1)\nelse:\n if v1_count.most_common()[0][0]-v1_count.most_common()[1][0]>=v2_count.most_common()[0][0]-v2_count.most_common()[1][0]:\n print(n-v2_count.most_common()[1][1]-v1_count.most_common()[0][1])\n else:\n print(n-v1_count.most_common()[1][1]-v2_count.most_common()[0][1])', 'from collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\nv1=Counter(v[::2])\nv2=Counter(v[1::2])\nv1[0]=0\nv2[0]=0\nv1_max=v1.most_common()[0]\nv2_max=v2.most_common()[0]\nv1_second=v1.most_common()[1]\nv2_second=v2.most_common()[1]\nif v1_max[0]!=v2_max[0]:\n print(n-v1_max[1]-v2_max[1])\nelse:\n print(min(n-v1_max[1]-v2_second[1],n-v2_max[1]-v1_second[1]))'] | ['Wrong Answer', 'Accepted'] | ['s915268410', 's487145383'] | [24516.0, 24336.0] | [119.0, 88.0] | [701, 378] |
p03244 | u950708010 | 2,000 | 1,048,576 | 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. | ['import collections\ndef solve():\n n = int(input())\n odd = []\n even = []\n a = list(int(i) for i in input().split())\n for i in range(n):\n if i%2 == 0:\n odd.append(a[i])\n else:\n even.append(a[i])\n ans = 0\n c1 = collections.Counter(odd)\n c2 = collections.Counter(even)\n n1 = len(odd)\n n2 = len(even)\n if len(set(a)) == 1:\n print(n//2)\n exit()\n ans = 10**12\n if c1.most_common()[0][0] == c2.most_common()[0][0]:\n if not len(c2) ==1:\n ans = min((n-c1.most_common()[0][1]-c2.most_common()[1][1]),ans)\n if not len(c1) ==1:\n ans = min((n-c2.most_common()[0][1]-c1.most_common()[1][1]),ans)\n else:\n ans +=n1-c1.most_common()[0][1]+n2-c2.most_common()[0][1]\n print(ans)\n \n \nsolve()', 'import collections\ndef solve():\n n = int(input())\n odd = []\n even = []\n a = list(int(i) for i in input().split())\n for i in range(n):\n if i%2 == 0:\n odd.append(a[i])\n else:\n even.append(a[i])\n ans = 0\n c1 = collections.Counter(odd)\n c2 = collections.Counter(even)\n n1 = len(odd)\n n2 = len(even)\n if len(set(a)) == 1:\n print(n//2)\n exit()\n ans = 10**12\n if c1.most_common()[0][0] == c2.most_common()[0][0]:\n if not len(c2) ==1:\n ans = min((n-c1.most_common()[0][1]-c2.most_common()[1][1]),ans)\n if not len(c1) ==1:\n ans = min((n-c2.most_common()[0][1]-c1.most_common()[1][1]),ans)\n else:\n ans = min(ans,(n1-c1.most_common()[0][1]+n2-c2.most_common()[0][1]))\n print(ans)\n \n \nsolve()'] | ['Wrong Answer', 'Accepted'] | ['s972302160', 's672141954'] | [23264.0, 23264.0] | [146.0, 144.0] | [765, 776] |
p03244 | u957872856 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nV = list(map(int,input().split()))\ncnt = 0\ncnt1 = 0\nif len(set(V)) == 1:\n print(n//2)\n exit()\nfor i in range(n-2):\n if V[i] == V[i+2] and i%2==0:\n cnt += 1\n elif V[i] == V[i+2] and i%2==1:\n cnt1 += 1\n else:\n print(n//2)\n exit()\nprint(max(cnt,cnt1)-min(cnt,cnt1))', 'from collections import Counter\nN = int(input())\nV = list(map(int,input().split()))\nv1 = V[0::2]\nv2 = V[1::2]\nv1c = Counter(v1).most_common()\nv2c = Counter(v2).most_common()\nv1c.append((0,0))\nv2c.append((0,0))\nif v1c[0][0]==v2c[0][0]:\n print(min(N-v1c[0][1]-v2c[1][1],N-v1c[1][1]-v2c[0][1]))\nelse:\n print(N-v1c[0][1]-v2c[0][1])'] | ['Wrong Answer', 'Accepted'] | ['s700290860', 's275073755'] | [15844.0, 21020.0] | [45.0, 87.0] | [296, 333] |
p03244 | u963915126 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\n\nv = list(map(int, input().split()))\n\nodds = []\nevens = []\n\nfor i in range(n):\n if i % 2 == 0:\n evens.append(v[i])\n else:\n odds.append(v[i])\n\nevens_c = Counter(evens).most_common()\nodds_c = Counter(odds).most_common()\n\nans = 0\n\nfl = 0\nfor i in range(len(evens_c)):\n for j in range(len(odds_c)):\n fl = 0\n try:\n if evens_c[i][0] != odds_c[j][0]:\n ans = min(ans, n - evens_c[i][1] - odds_c[j][1])\n fl = 1\n except:\n continue\n\nif fl == 1:\n print(ans)\n exit()\nprint(n // 2)\n', 'from collections import Counter\n\nn = int(input())\n\nv = list(map(int, input().split()))\n\nodds = []\nevens = []\n\nfor i in range(n):\n if i % 2 == 0:\n evens.append(v[i])\n else:\n odds.append(v[i])\n\nevens_c = Counter(evens).most_common()\nodds_c = Counter(odds).most_common()\n\nans = 0\nfor i in range(len(evens_c)):\n for j in range(len(odds_c)):\n fl = 0\n try:\n if evens_c[i][0] != odds_c[j][0]:\n ans = max(ans, n - evens_c[i][1] - odds_c[j][1])\n fl = 1\n except:\n continue\n\nprint(n // 2)\n', 'from collections import Counter\n\nn = int(input())\n\nv = list(map(int, input().split()))\n\nodds = []\nevens = []\n\nfor i in range(n):\n if i % 2 == 0:\n evens.append(v[i])\n else:\n odds.append(v[i])\n\nevens_c = Counter(evens).most_common()\nodds_c = Counter(odds).most_common()\n\nfl = 0\nfor i in range(len(evens_c)):\n for j in range(len(odds_c)):\n try:\n if evens_c[i][0] != odds_c[j][0]:\n print(n - evens_c[i][1] - odds_c[j][1])\n fl = 1\n exit()\n except:\n continue\nif fl==0:\n print(n//2)\n\n', 'from collections import Counter\n\nn = int(input())\n\nv = list(map(int, input().split()))\n\nodds = []\nevens = []\n\nfor i in range(n):\n if i % 2 == 0:\n evens.append(v[i])\n else:\n odds.append(v[i])\n\nevens_c = Counter(evens).most_common()\nodds_c = Counter(odds).most_common()\n\nfl = 0\nfor i in range(len(evens_c)):\n for j in range(len(odds_c)):\n try:\n if evens_c[i][0] != odds_c[j][0]:\n print(n - odds_c[0][1] - evens_c[0][1])\n fl = 1\n exit()\n except:\n continue\nif fl==0:\n print(n//2)\n\n', 'from collections import Counter\n\nn = int(input())\n\nv = list(map(int, input().split()))\n\nodds = []\nevens = []\n\nfor i in range(n):\n if i % 2 == 0:\n evens.append(v[i])\n else:\n odds.append(v[i])\n\nevens_c = Counter(evens).most_common(2)\nodds_c = Counter(odds).most_common(2)\n\nif evens_c[0][0] != odds_c[0][0]:\n print(n - evens_c[0][1] - odds_c[0][1])\n exit()\n\nif len(evens_c) == 1 or len(odds_c) == 1:\n print(n // 2)\n exit()\n\nprint(n - max(evens_c[0][1] + odds_c[1][1], evens_c[1][1] + odds_c[0][1]))\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s464806703', 's645608935', 's938064626', 's981660627', 's009137439'] | [21076.0, 21212.0, 26336.0, 26460.0, 15972.0] | [2105.0, 2108.0, 2105.0, 2105.0, 100.0] | [620, 574, 584, 584, 528] |
p03244 | u964494353 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nlst = list(map(int, input().split()))\nm = 0\nfor i in range(0,n-2):\n\tif lst[i] != lst[i+2]:\n \tlst[i+2] = lst[i]\n \tm += 1\n elif lst[i] == lst[i+1]:\n\t\tm += 1\nprint(m)\n', 'n = int(input())\nlst = list(map(int, input().split()))\nm1 = {}\nm2 = {}\nfor i in range(0, n, 2):\n if lst[i] in m1:\n m1[lst[i]] += 1\n else:\n m1[lst[i]] = 1\n if lst[i+1] in m2:\n m2[lst[i+1]] += 1\n else:\n m2[lst[i+1]] = 1\nif max(m1, key=m1.get) != max(m2, key=m2.get):\n mm = n - max(m1.values()) - max(m2.values())\nelse:\n mm1 = max(m1.values())\n mm2 = max(m2.values())\n m1[max(m1, key=m1.get)] = 0\n m2[max(m2, key=m2.get)] = 0\n mm = min(n - max(m1.values()) - mm2, n - max(m2.values()) - mm1) \nprint(mm)'] | ['Runtime Error', 'Accepted'] | ['s791678268', 's645411848'] | [2940.0, 17056.0] | [17.0, 94.0] | [190, 557] |
p03244 | u970308980 | 2,000 | 1,048,576 | 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. | ['from collections import defaultdict\n\nN = int(input())\nL = list(map(int, input().split()))\n\nif len(set(L)) == 1:\n print(N//2)\n exit()\nif N == 2:\n print(0)\n exit()\n\n\nd_even = defaultdict(int)\nd_odd = defaultdict(int)\n\nfor i in range(N):\n v = L[i]\n if i % 2 == 0:\n d_even[v] += 1\n else:\n d_odd[v] += 1\n\nl_even = sorted(d_even.items(), key=lambda x: -x[1])\nl_odd = sorted(d_odd.items(), key=lambda x: -x[1])\n\nodd_1 = l_even[0]\neven_1 = l_even[0]\n\nif even_1[0] != even_1[0]:\n print(N - odd_1[1] - even_1[1])\n exit()\n\neven_2 = l_even[1]\nodd_2 = l_odd[1]\n\nans = N\nans = min(N, N - odd_1[1] - even_2[1])\nans = min(N, N - odd_2[1] - even_1[1])\nprint(ans)\n', 'from collections import Counter\n\nN = int(input())\nL = list(map(int, input().split()))\nodd = [v for i, v in enumerate(L) if i % 2 == 0]\neven = [v for i, v in enumerate(L) if i % 2 == 1]\n\nif len(set(L)) == 1:\n print(N//2)\n exit()\nif N == 2:\n print(0)\n exit()\n\n\nc_odd = sorted(dict(Counter(odd)).items(), key=lambda x: -x[1])\nc_even = sorted(dict(Counter(even)).items(), key=lambda x: -x[1])\n\nodd_1 = c_odd[0]\nodd_2 = c_odd[1]\neven_1 = c_even[0]\neven_2 = c_even[1]\n\nif odd_1[0] != even_1[0]:\n print(N - odd_1[1] - even_1[1])\n exit()\n\nans = N\nans = min(N, N - odd_1[1] - even_2[1])\nans = min(N, N - odd_2[1] - even_1[1])\nprint(ans)\n', 'from collections import Counter\n\nN = int(input())\nL = list(map(int, input().split()))\nodd = [v for i, v in enumerate(L) if i % 2 == 0]\neven = [v for i, v in enumerate(L) if i % 2 == 1]\n\nif len(set(L)) == 1:\n print(N//2)\n exit()\nif N == 2:\n print(0)\n exit()\n\n\nc_odd = sorted(dict(Counter(odd)).items(), key=lambda x: -x[1])\nc_even = sorted(dict(Counter(even)).items(), key=lambda x: -x[1])\n\nodd_1 = c_odd[0]\neven_1 = c_even[0]\n\nif odd_1[0] != even_1[0]:\n print(N - odd_1[1] - even_1[1])\n exit()\n\neven_2 = c_even[1]\nodd_2 = c_odd[1]\n\nans = N\nans = min(ans, N - odd_1[1] - even_2[1])\nans = min(ans, N - odd_2[1] - even_1[1])\nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s188758928', 's301282003', 's987057619'] | [22484.0, 24172.0, 24300.0] | [140.0, 116.0, 118.0] | [687, 646, 651] |
p03244 | u970738863 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nv = list(map(int,input().split()))\nl = list(range(n))\nodd = [v[i] for i in l if i%2 == 0]\neven = [v[i] for i in l if i%2 == 1]\n\nimport collections\noddm = collections.Counter(odd).most_common()\nevenm = collections.Counter(odd).most_common()\n\nif oddm[0][0] == evenm[0][0]:\n a = len(odd)\nelse:\n a = (n/2)-numodd+(n/2)-numeven\nprint(int(a))', 'n = int(input())\nv = list(map(int,input().split()))\nl = list(range(n))\nodd = [v[i] for i in l if i%2 == 0]\neven = [v[i] for i in l if i%2 == 1]\n\nimport collections\noddm = collections.Counter(odd).most_common()\nevenm = collections.Counter(odd).most_common()\n\nif oddm[0][0] != evenm[0][0]:\n a = (n/2)-oddm[0][1]+(n/2)-evenm[0][1]\nelse:\n if len(oddm) == 1 and len(evenm) == 1:\n a = n/2\n elif len(oddm) == 1:\n a = (n/2)-evenm[1][1]\n elif len(evenm) == 1:\n a = (n/2)-oddm[1][1]\n else:\n a = n-max(evenm[1][1]+oddm[0][1],evenm[0][1]+oddm[1][1])\n\nprint(int(a))\n', 'n = int(input())\nv = list(map(int,input().split()))\nl = list(range(n))\nodd = [v[i] for i in l if i%2 == 0]\neven = [v[i] for i in l if i%2 == 1]\n\nimport collections\noddm = collections.Counter(odd).most_common()\nevenm = collections.Counter(even).most_common()\n\nif oddm[0][0] != evenm[0][0]:\n a = (n/2)-oddm[0][1]+(n/2)-evenm[0][1]\nelse:\n if len(oddm) == 1 and len(evenm) == 1:\n a = n/2\n elif len(oddm) == 1:\n a = (n/2)-evenm[1][1]\n elif len(evenm) == 1:\n a = (n/2)-oddm[1][1]\n else:\n a = n-max(evenm[1][1]+oddm[0][1],evenm[0][1]+oddm[1][1])\n\nprint(int(a))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s641993721', 's831848810', 's889879550'] | [24944.0, 24944.0, 24924.0] | [110.0, 112.0, 109.0] | [359, 596, 597] |
p03244 | u970899068 | 2,000 | 1,048,576 | 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. | ['import collections\nn=int(input())\nv=list(map(int, input().split()))\nv1=v[0:n:2]\nv2=v[1:n:2]\nv10=collections.Counter(v1)\nv11=v10.most_common()\nv20=collections.Counter(v2)\nv21=v20.most_common()\nif v11[0][0]==v21[0][0] and v11[0][1]==n//2 and v21[0][1]==n//2:\n print(n//2)\nelif v11[0][0]==v21[0][0]:\n x1=n//2-v11[0][1]\n x2=n//2-v11[1][1]\n y1=n//2-v21[0][1]\n y2=n//2-v21[1][1]\n print(min(x1+y2,x2+y1))\n \nelse:\n x=n//2-v11[0][1]\n y=n//2-v21[0][1]\n print(x1+y1)', 'import collections\nn=int(input())\nv=list(map(int, input().split()))\nv1=v[0:n:2]\nv2=v[1:n:2]\nv10=collections.Counter(v1)\nv11=v10.most_common()\nv20=collections.Counter(v2)\nv21=v20.most_common()\nif v11[0][0]==v21[0][0] and v11[0][1]==n//2 and v21[0][1]==n//2:\n print(n//2)\nelif v11[0][0]==v21[0][0]:\n x1=n//2-v11[0][1]\n x2=n//2-v11[1][1]\n y1=n//2-v21[0][1]\n y2=n//2-v21[1][1]\n print(min(x1+y2,x2+y1))\n \nelse:\n x1=n//2-v11[0][1]\n y1=n//2-v21[0][1]\n print(x1+y1)'] | ['Runtime Error', 'Accepted'] | ['s765524276', 's339353034'] | [21944.0, 21952.0] | [94.0, 92.0] | [485, 487] |
p03244 | u973840923 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nlist = [int(i) for i in input().split()]\n\nlist_odd = list[::2]\nlist_even = list[1::2]\n\ndef cnt_element(x):\n dict = {}\n for i in x:\n if i not in dict:\n dict[i] = 1\n else:\n dict[i] += 1\n return [(v,k) for k,v in dict.items()]\n\ncnt_odd = sorted(cnt_element(list_odd),reverse=True)\ncnt_even = sorted(cnt_element(list_even),reverse=True)\n\n\nif cnt_odd[0][1] == cnt_even[0][1]:\n \n if len(cnt_odd) or len(cnt_even) == 1:\n ans = n //2\n \n else:\n \n if cnt_odd[1][0] > cnt_even[1][0]:\n ans = n - cnt_odd[1][0] - cnt_even[0][0]\n \n elif cnt_odd[1][0] < cnt_even[1][0]:\n ans = n - cnt_odd[0][0] - cnt_even[1][0]\n\nelse:\n ans = n - cnt_odd[0][0] - cnt_even[0][1]\n\nprint(ans)', 'n = int(input())\nlist = [int(i) for i in input().split()]\n\nlist_odd = list[::2]\nlist_even = list[1::2]\n\ndef cnt_element(x):\n dict = {}\n for i in x:\n if i not in dict:\n dict[i] = 1\n else:\n dict[i] += 1\n return [(v,k) for k,v in dict.items()]\n\ncnt_odd = sorted(cnt_element(list_odd),reverse=True)\ncnt_even = sorted(cnt_element(list_even),reverse=True)\n\n\nif cnt_odd[0][1] == cnt_even[0][1]:\n \n if len(cnt_odd) or len(cnt_even) == 1:\n ans = int(n / 2)\n \n else:\n \n if cnt_odd[1][0] > cnt_even[1][0]:\n ans = n - cnt_odd[1][0] - cnt_even[0][0]\n \n elif cnt_odd[1][0] < cnt_even[1][0]:\n ans = n - cnt_odd[0][0] - cnt_even[1][0]\n\nelse:\n ans = n - cnt_odd[0][0] - cnt_even[0][1]\n\nprint(ans)', 'n = int(input())\nlist = [int(i) for i in input().split()]\n\nlist_odd = list[::2]\nlist_even = list[1::2]\n\ndef cnt_element(x):\n dict = {}\n for i in x:\n if i not in dict:\n dict[i] = 1\n else:\n dict[i] += 1\n return [(v,k) for k,v in dict.items()]\n\ncnt_odd = sorted(cnt_element(list_odd),reverse=True)\ncnt_even = sorted(cnt_element(list_even),reverse=True)\nprint(cnt_odd)\nprint(cnt_even)\n\nif len(cnt_odd) == len(cnt_even) == 1\n if cnt_even[0][1] != cnt_odd[0][1]:\n ans = 0\n elif cnt_even[0][1] == cnt_odd[0][1]:\n ans = int(n / 2)\nelif cnt_even[0][1] != cnt_odd[0][1]:\n ans = n - cnt_odd[0][0] - cnt_even[0][0]\n\nprint(ans)', 'n = int(input())\nlist = [int(i) for i in input().split()]\n\nlist_odd = list[::2]\nlist_even = list[1::2]\n\ndef cnt_element(x):\n dict = {}\n for i in x:\n if i not in dict:\n dict[i] = 1\n else:\n dict[i] += 1\n return [(v,k) for k,v in dict.items()]\n\ncnt_odd = sorted(cnt_element(list_odd),reverse=True)\ncnt_even = sorted(cnt_element(list_even),reverse=True)\n\n\nif cnt_odd[0][1] == cnt_even[0][1]:\n \n if len(cnt_odd) == len(cnt_even) == 1:\n ans = 1\n \n else:\n \n if cnt_odd[1][0] > cnt_even[1][0]:\n ans = n - cnt_odd[1][0] - cnt_even[0][0]\n \n elif cnt_odd[1][0] < cnt_even[1][0]:\n ans = n - cnt_odd[0][0] - cnt_even[1][0]\n\nelse:\n ans = n - cnt_odd[0][0] - cnt_even[0][1]\n\nprint(ans)', 'n = int(input())\nlist = [int(i) for i in input().split()]\n\nlist_odd = list[::2]\nlist_even = list[1::2]\n\ndef cnt_element(x):\n dict = {}\n for i in x:\n if i not in dict:\n dict[i] = 1\n else:\n dict[i] += 1\n return [(v,k) for k,v in dict.items()]\n\ncnt_odd = sorted(cnt_element(list_odd),reverse=True)\ncnt_even = sorted(cnt_element(list_even),reverse=True)\n\n\nif cnt_odd[0][1] == cnt_even[0][1]:\n \n if len(cnt_odd) or len(cnt_even) == 1:\n ans = n / 2\n \n else:\n \n if cnt_odd[1][0] > cnt_even[1][0]:\n ans = n - cnt_odd[1][0] - cnt_even[0][0]\n \n elif cnt_odd[1][0] < cnt_even[1][0]:\n ans = n - cnt_odd[0][0] - cnt_even[1][0]\n\nelse:\n ans = n - cnt_odd[0][0] - cnt_even[0][1]\n\nprint(ans)', 'from collections import Counter\n\nn = int(input())\nv = [int(i) for i in input().split()]\n\nki = v[::2]\ngu = v[1::2]\n\nki = Counter(ki)\ngu = Counter(gu)\n\nki = ki.most_common()\ngu = gu.most_common()\n\nprint(ki)\nprint(gu)\n\nans = 0\n\nif ki[0][0] == gu[0][0]:\n if len(ki) == 1 and len(gu) == 1:\n ans = int(n / 2)\n else:\n if ki[1][1] > gu[1][1]:\n ans = n - ki[1][1] - gu[0][1]\n else:\n ans = n - ki[0][1] - gu[1][1]\nelse:\n ans = n - ki[0][1] - gu[0][1]\n\nprint(ans)\n\n', 'from collections import Counter\nn = int(input())\nlist = list(map(int,input().split()))\nlist_o = list[::2]\nlist_e = list[1::2]\n\ncnt_o = Counter(list_e).most_common(2)\ncnt_e = Counter(list_o).most_common(2)\n\nif cnt_o[0][0] == cnt_e[0][0]:\n if len(cnt_o) == 1 and len(cnt_e) == 1:\n print(int(n/2))\n else:\n print(n-cnt_o[0][1]-max(cnt_o[1][1],cnt_e[1][1]))\nelse:\n print(n-cnt_o[0][1]-cnt_e[0][1])'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s074368295', 's123873498', 's339589418', 's370547508', 's786940246', 's890756387', 's528972944'] | [20636.0, 20828.0, 3064.0, 20636.0, 20636.0, 18784.0, 15972.0] | [101.0, 103.0, 17.0, 104.0, 102.0, 128.0, 79.0] | [1026, 1031, 682, 1021, 1026, 506, 415] |
p03244 | u978313283 | 2,000 | 1,048,576 | 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. | ['from collections import defaultdict\nd = defaultdict(int)\nn=int(input())\nv=list(map(int,input().split()))\nfor i in range(n):\n d[v[i]]+=1\nD=sorted(d.items(), key=lambda x:x[1],reverse=True)\nif len(D)==1:\n print(D[0][1]//2)\nelse:\n if v[0]==D[1][0]:\n b=D[0][0]\n a=D[1][0]\n else:\n a=D[0][0]\n b=D[1][0]\n c=0\n print(a,b)\n for i in range(n):\n if i%2==0:\n if v[i]!=a:\n c+=1\n if i%2!=0:\n if v[i]!=b:\n c+=1\n print(c)\n', 'from collections import defaultdict\nd = defaultdict(int)\nn=int(input())\nv=list(map(int,input().split()))\nfor i in range(n):\n d[v[i]]+=1\nD=sorted(d.items(), key=lambda x:x[1])\nif len(D)==1:\n print(D[0][1]//2)\nelif len(D)==2:\n print(0)\nelse len(D)>=3:\n h=0\n for i in range(len(D)-2):\n h+=D[i][1]\n print(h)\n', 'from collections import defaultdict\nd0 = defaultdict(int)\nd1 = defaultdict(int)\nN=int(input())\nv=list(map(int,input().split()))\nfor i in range(N):\n if i%2==0:\n d0[v[i]]+=1\n else:\n d1[v[i]]+=1\nD0=sorted(d0.items(), key=lambda x:x[1],reverse=True)\nD1=sorted(d1.items(), key=lambda x:x[1],reverse=True)\nprint(D0)\nprint(D1)\nif (D0[0][1]+D1[0][1])==len(v) and D0[0][0]==D1[0][0]:\n print(len(v)//2)\nelse:\n i0=0\n i1=0\n while i0<=len(D0) or i1<=len(D1):\n if D0[i0][0]!=D1[i1][0]:\n print(len(v)-D0[i0][1]-D1[i1][1])\n break\n else:\n if D0[i0][1]>D1[i1][1]:\n i1+=1\n elif D0[i0][1]<D1[i1][1]:\n i0+=1\n else:\n if (len(D0)-1-i0)>0 and (len(D1)-1-i1)>0:\n if D0[i0+1][1]>D1[i1+1][1]:\n i0+=1\n else:\n i1+=1\n elif (len(D0)-1-i0)==0 :\n i1+=1\n elif (len(D1)-1-i1)==0:\n i0+=1\n\n', 'from collections import defaultdict\nd0 = defaultdict(int)\nd1 = defaultdict(int)\nN=int(input())\nv=list(map(int,input().split()))\nfor i in range(N):\n if i%2==0:\n d0[v[i]]+=1\n else:\n d1[v[i]]+=1\nD0=sorted(d0.items(), key=lambda x:x[1],reverse=True)\nD1=sorted(d1.items(), key=lambda x:x[1],reverse=True)\nif (D0[0][1]+D1[0][1])==len(v) and D0[0][0]==D1[0][0]:\n print(len(v)//2)\nelse:\n i0=0\n i1=0\n while i0<=len(D0) or i1<=len(D1):\n if D0[i0][0]!=D1[i1][0]:\n print(len(v)-D0[i0][1]-D1[i1][1])\n break\n else:\n if D0[i0][1]>D1[i1][1]:\n i1+=1\n elif D0[i0][1]<D1[i1][1]:\n i0+=1\n else:\n if (len(D0)-1-i0)>0 and (len(D1)-1-i1)>0:\n if D0[i0+1][1]>D1[i1+1][1]:\n i0+=1\n else:\n i1+=1\n elif (len(D0)-1-i0)==0 :\n i1+=1\n elif (len(D1)-1-i1)==0:\n i0+=1\n\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s306156597', 's501269278', 's786470169', 's577597406'] | [21980.0, 3060.0, 23708.0, 21148.0] | [142.0, 18.0, 170.0, 132.0] | [524, 329, 1051, 1031] |
p03244 | u979444096 | 2,000 | 1,048,576 | 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. | ["from collections import Counter\n\n\ndef main():\n n = int(input())\n v = list(map(int, input().split()))\n \n \n\n # a_count = Counter.most_common(Counter(a))\n # b_count = Counter.most_common(Counter(b))\n\n half_n = n // 2\n ac = Counter(v[::2]).most_common(2)\n bc = Counter(v[1::2]).most_common(2)\n\n if ac[0][0] != bc[0][0]:\n print(half_n - ac[0][1] - bc[0][1])\n else:\n if len(bc) == 1 or len(ac) == 1:\n print(half_n // 2)\n else:\n print(half_n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1]))\n\n # ans = 0\n\n # half_n = n // 2\n \n # h_ac0 = half_n - a_count[0][1]\n # h_bc0 = half_n - b_count[0][1]\n\n # if len(a_count) == 1 and len(b_count) == 1:\n # if eq:\n # print(half_n)\n # exit()\n # else:\n # print(ans)\n # exit()\n\n # if a_count[0][1] > b_count[0][1]:\n # ans += h_ac0\n # if eq:\n # ans += half_n - b_count[1][1]\n # else:\n # ans += h_bc0\n # elif a_count[0][1] < b_count[0][1]:\n # ans += h_bc0\n # if eq:\n # ans += half_n - a_count[1][1]\n # else:\n # ans += h_ac0\n # else:\n # if eq:\n # ans += h_ac0\n # ans += half_n - b_count[1][1]\n # else:\n # ans += h_ac0\n # ans += h_bc0\n # print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "from collections import Counter\n\n\ndef main():\n n = int(input())\n v = list(map(int, input().split()))\n \n \n\n # a_count = Counter.most_common(Counter(a))\n # b_count = Counter.most_common(Counter(b))\n\n # half_n = n // 2\n ac = Counter(v[::2]).most_common(2)\n bc = Counter(v[1::2]).most_common(2)\n\n if ac[0][0] != bc[0][0]:\n print(n - ac[0][1] - bc[0][1])\n else:\n if len(bc) == 1 or len(ac) == 1:\n print(n // 2)\n else:\n print(n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1]))\n\n # ans = 0\n\n # half_n = n // 2\n \n # h_ac0 = half_n - a_count[0][1]\n # h_bc0 = half_n - b_count[0][1]\n\n # if len(a_count) == 1 and len(b_count) == 1:\n # if eq:\n # print(half_n)\n # exit()\n # else:\n # print(ans)\n # exit()\n\n # if a_count[0][1] > b_count[0][1]:\n # ans += h_ac0\n # if eq:\n # ans += half_n - b_count[1][1]\n # else:\n # ans += h_bc0\n # elif a_count[0][1] < b_count[0][1]:\n # ans += h_bc0\n # if eq:\n # ans += half_n - a_count[1][1]\n # else:\n # ans += h_ac0\n # else:\n # if eq:\n # ans += h_ac0\n # ans += half_n - b_count[1][1]\n # else:\n # ans += h_ac0\n # ans += h_bc0\n # print(ans)\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s304061538', 's274100272'] | [15588.0, 15588.0] | [74.0, 73.0] | [1545, 1532] |
p03244 | u981767024 | 2,000 | 1,048,576 | 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. | ['# 2019/05/15\n\n\nfrom operator import itemgetter\n\n# Input\nn = int(input())\nv = list(map(int, input().split()))\n\nl_even = list()\nl_odd = list()\n\n# Separate Odd or Even\nfor i in range(n):\n if i % 2 == 0:\n l_even.append(v[i])\n else:\n l_odd.append(v[i])\n\nl_even.sort()\nl_odd.sort()\nwk_cnt_e = 1\nwk_cnt_o = 1\n\ncnt_even = list()\ncnt_odd = list()\n\n# Count\nfor x in range(int(n/2)-1):\n if l_even[x] != l_even[x+1]:\n cnt_even.append([l_even[x], wk_cnt_e])\n wk_cnt_e = 1\n else:\n wk_cnt_e += 1\n\n if l_odd[x] != l_odd[x+1]:\n cnt_odd.append([l_odd[x], wk_cnt_o])\n wk_cnt_o = 1\n else:\n wk_cnt_o += 1\n\ncnt_even.append([l_even[x+1], wk_cnt_e])\ncnt_odd.append([l_odd[x+1], wk_cnt_o])\n\ncnt_even.sort(key=itemgetter(1))\ncnt_odd.sort(key=itemgetter(1))\n\nif len(cnt_even) == 1 and len(cnt_odd) == 1 and cnt_even[0][0] == cnt_odd[0][0]:\n ans = n / 2\nelif len(cnt_even) == 1 and cnt_even[0][0] == cnt_odd[0][0]:\n ans = n / 2 - cnt_odd[0][1]\nelif len(cnt_odd) == 1 and cnt_even[0][0] == cnt_odd[0][0]:\n ans = n / 2 - cnt_even[0][1]\nelif cnt_even[0][0] == cnt_odd[0][0]:\n ans = n / 2 - min(cnt_even[0][1], cnt_odd[0][1])\nelse:\n ans = (n / 2 - cnt_even[0][1]) + (n / 2 - cnt_odd[0][1])\n \nprint(cnt_even, cnt_odd)\n# Output\nprint(int(ans))\n', '# 2019/05/15\n\n\nfrom operator import itemgetter\n\n# Input\nn = int(input())\nv = list(map(int, input().split()))\n\nl_even = list()\nl_odd = list()\n\n# Separate Odd or Even\nfor i in range(n):\n if i % 2 == 0:\n l_even.append(v[i])\n else:\n l_odd.append(v[i])\n\nl_even.sort()\nl_odd.sort()\nwk_cnt_e = 1\nwk_cnt_o = 1\n\ncnt_even = list()\ncnt_odd = list()\n\n# Count\nfor x in range(int(n/2)-1):\n if l_even[x] != l_even[x+1]:\n cnt_even.append([l_even[x], wk_cnt_e])\n wk_cnt_e = 1\n else:\n wk_cnt_e += 1\n\n if l_odd[x] != l_odd[x+1]:\n cnt_odd.append([l_odd[x], wk_cnt_o])\n wk_cnt_o = 1\n else:\n wk_cnt_o += 1\n\ncnt_even.append([l_even[x+1], wk_cnt_e])\ncnt_odd.append([l_odd[x+1], wk_cnt_o])\n\ncnt_even.sort(key=itemgetter(1),reverse=True)\ncnt_odd.sort(key=itemgetter(1),reverse=True)\n\n# Max is same\nif cnt_even[0][0] == cnt_odd[0][0]:\n if len(cnt_even) == 1 and len(cnt_odd) == 1:\n ans = n / 2\n elif len(cnt_even) == 1:\n ans = n / 2 - cnt_odd[1][1]\n elif len(cnt_odd) == 1:\n ans = n / 2 - cnt_even[1][1]\n else:\n ans = min((n / 2 - cnt_even[0][1]) + (n / 2 - cnt_odd[1][1]),\n (n / 2 - cnt_even[1][1]) + (n / 2 - cnt_odd[0][1]))\n# Max is Not same\nelse:\n if len(cnt_even) == 1 and len(cnt_odd) == 1:\n ans = 0\n elif len(cnt_even) == 1:\n ans = n / 2 - cnt_odd[0][1]\n elif len(cnt_odd) == 1:\n ans = n / 2 - cnt_even[0][1]\n else:\n ans = (n / 2 - cnt_even[0][1]) + (n / 2 - cnt_odd[0][1])\n\n# Output\nprint(int(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s833748473', 's137481762'] | [21348.0, 18660.0] | [222.0, 167.0] | [1333, 1583] |
p03244 | u990726146 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nv = list(map(int, input().split()))\nv1 = v[0::2]\nv2 = v[1::2]\n\nfrom collections import Counter\nc1 = list(Counter(v1).items())\nc2 = list(Counter(v2).items())\n\nc1 = sorted(c1, key= lambda x: x[1], reverse= True)\nc2 = sorted(c2, key= lambda x: x[1], reverse= True)\n\nc1.append((0,0))\nc2.append((0,0))\n\nprint(c1[:3], c2[:3])\nif c1[0][0] != c2[0][0]:\n print(n - c1[0][1] - c2[0][1])\nelse:\n a = c1[0][1] + c2[1][1]\n b = c1[1][1] + c2[0][1]\n if a < b:\n print(n - b)\n else:\n print(n - a)', 'n = int(input())\nv = list(map(int, input().split()))\nv1 = v[0::2]\nv2 = v[1::2]\n\nfrom collections import Counter\nc1 = list(Counter(v1).items())\nc2 = list(Counter(v2).items())\n\nc1 = sorted(c1, key= lambda x: x[1], reverse= True)\nc2 = sorted(c2, key= lambda x: x[1], reverse= True)\n\nc1.append((0,0))\nc2.append((0,0))\n\n#print(c1[:3], c2[:3])\nif c1[0][0] != c2[0][0]:\n print(n - c1[0][1] - c2[0][1])\nelse:\n a = c1[0][1] + c2[1][1]\n b = c1[1][1] + c2[0][1]\n if a < b:\n print(n - b)\n else:\n print(n - a)'] | ['Wrong Answer', 'Accepted'] | ['s761670084', 's299291133'] | [25456.0, 25592.0] | [78.0, 88.0] | [524, 525] |
p03246 | u010069411 | 2,000 | 1,048,576 | 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. | ['#! /usr/bin/python\nfrom collections import Counter\nN = int(input())\nV = list(map(int, input().split()))\n#N = 4\n#V = list(map(int, "105 119 105 119 105 119".split()))\n\n\ndef func(l, aa):\n counter = Counter(l)\n if counter[aa] == 0:\n c, count = counter.most_common()[0]\n else:\n c, count = counter.most_common()[1]\n print(l, len(l) - count)\n return (c, len(l) - count)\n\n\nif len(set(V)) == 1:\n print(N // 2)\nelse:\n c, count = func(V[::2], -1)\n c2, count2 = func(V[1::2], c)\n print(count + count2)\n', '#! /usr/bin/python\nfrom collections import Counter\nN = int(input())\nV = list(map(int, input().split()))\n#N = 4\n#V = list(map(int, "1 2 3 2 2 2 2 2 1 1 2 3 4 5 2 12 1 1".split()))\n\n\ndef func(l, aa):\n counter = Counter(l)\n if counter[aa] == 0:\n c, count = counter.most_common()[0]\n else:\n c, count = counter.most_common()[1]\n \n return (c, len(l) - count)\n\n\nif len(set(V)) == 1:\n print(N // 2)\nelse:\n c, count = func(V[::2], -1)\n c2, count2 = func(V[1::2], c)\n a = count + count2\n c2, count2 = func(V[1::2], -1)\n c, count = func(V[::2], c2)\n print(min(a, count + count2))\n'] | ['Wrong Answer', 'Accepted'] | ['s125054721', 's707451066'] | [17364.0, 17116.0] | [97.0, 120.0] | [532, 647] |
p03246 | u024768467 | 2,000 | 1,048,576 | 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. | ['n=int(input())\nv_list = list(map(int,input().split()))\nodd_list = []\neven_list = []\n\nfor i in range(n):\n if i % 2 == 0:\n odd_list.append(v_list[i]) \n else:\n even_list.append(v_list[i])\n\nimport collections\n\nodd_list_c = collections.Counter(odd_list)\neven_list_c = collections.Counter(even_list)\n\nif odd_list_c.most_common()[0][0] != even_list_c.most_common()[0][0]:\n ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[0][1]\nelse:\n if len(even_list_c) == 1 && len(odd_list_c) == 1:\n ans = n // 2\n else: \n if odd_list_c.most_common()[0][1] >= even_list_c.most_common()[0][1]:\n ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[1][1]\n elif odd_list_c.most_common()[0][1] < even_list_c.most_common()[0][1]:\n ans = n - odd_list_c.most_common()[1][1] - even_list_c.most_common()[0][1]\n\nprint(ans)', 'n=int(input())\nv_list = list(map(int,input().split()))\nodd_list = []\neven_list = []\n\nfor i in range(n):\n if i % 2 == 0:\n odd_list.append(v_list[i]) \n else:\n even_list.append(v_list[i])\n\nimport collections\n\nodd_list_c = collections.Counter(odd_list)\neven_list_c = collections.Counter(even_list)\n\nif odd_list_c.most_common()[0][0] != even_list_c.most_common()[0][0]:\n ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[0][1]\nelse:\n if len(even_list_c) == 1 and len(odd_list_c) == 1:\n ans = n // 2\n else: \n ans1 = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[1][1]\n ans2 = n - odd_list_c.most_common()[1][1] - even_list_c.most_common()[0][1]\n ans = min(ans1, ans2)\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s710786224', 's028320761'] | [3064.0, 19040.0] | [17.0, 139.0] | [898, 766] |
p03246 | u077337864 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input().strip())\nvs = list(map(int, input().strip().split()))\noddv = [v for i, v in enumerate(vs) if i % 2 == 0]\nevenv = [v for i, v in enumerate(vs) if i % 2 == 1]\n\noddc = Counter(oddv)\nevenc = Counter(evenv)\nif oddc.most_common(1)[0][0] != evenc.most_common(1)[0][0]:\n print(len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(1)[0][1])\nelse:\n if len(oddc.most_common()) == 1 and len(evenc.most_common()) == 1:\n print(len(oddv))\n elif len(oddc.most_common()) == 1:\n print(len(evenv) - evenc.most_common(2)[1][1])\n else len(evenc.most_common()) == 1:\n print(len(oddv) - oddc.most_common(2)[1][1])\n else:\n print(min(len(oddv) - oddc.most_common(2)[1][1] + len(evenv) - evenc.most_common(1)[0][1], len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(2)[0][1]))', 'from collections import Counter\n\nn = int(input().strip())\nvs = list(map(int, input().strip().split()))\noddv = [v for i, v in enumerate(vs) if i % 2 == 0]\nevenv = [v for i, v in enumerate(vs) if i % 2 == 1]\n\noddc = Counter(oddv)\nevenc = Counter(evenv)\nif oddc.most_common(1)[0][0] != evenc.most_common(1)[0][0]:\n print(len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(1)[0][1])\nelse:\n if len(oddc.most_common()) == 1 and len(evenc.most_common()) == 1:\n print(len(oddv))\n elif len(oddc.most_common()) == 1:\n print(len(evenv) - evenc.most_common(2)[1][1])\n elif len(evenc.most_common()) == 1:\n print(len(oddv) - oddc.most_common(2)[1][1])\n else:\n print(min(len(oddv) - oddc.most_common(2)[1][1] + len(evenv) - evenc.most_common(1)[0][1], len(oddv) - oddc.most_common(1)[0][1] + len(evenv) - evenc.most_common(2)[1][1]))\n'] | ['Runtime Error', 'Accepted'] | ['s908287748', 's184061389'] | [3064.0, 19040.0] | [17.0, 168.0] | [855, 856] |
p03246 | u090649502 | 2,000 | 1,048,576 | 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. | ['from collections import Counter as C\nn = int(input())\na = list(map(int,input().split()))\nc1 = C(a[::2])\nc2 = C(a[1::2])\nmc1 = c1.most_common(2)\nmc2 = c2.most_common(2)\nif mc1[0][0] == mc2[0][0]:\n if mc1[1][1] >= mc2[1][1]:\n ans = n - mc1[1][1] - mc2[0][1]\n else:\n ans = n - mc1[0][1] - mc2[][1]\nprint(ans)', 'from collections import Counter as C\nn = int(input())\na = list(map(int,input().split()))\nc1 = C(a[::2])\nc2 = C(a[1::2])\nmc1 = c1.most_common(2)\nmc2 = c2.most_common(2)\nif mc1[0][0] != mc2[0][0]:\n ans = n - mc1[0][1] - mc2[0][1]\nelse:\n if len(mc1) + len(mc2) == 2:\n ans = n // 2\n elif len(mc1) == 1:\n ans = n - mc1[0][1] - mc2[1][1]\n elif len(mc2) == 1:\n ans = n - mc1[1][1] - mc2[0][1]\n else:\n if mc1[1][1] >= mc2[1][1]:\n ans = n - mc1[1][1] - mc2[0][1]\n else:\n ans = n - mc1[0][1] - mc2[1][1]\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s496871721', 's630189656'] | [3064.0, 18656.0] | [17.0, 81.0] | [313, 534] |
p03246 | u097216046 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\ndef solve(size=int(input()), ary=list(map(int, input().split()))):\n if len(set(ary)) < 2: return len(ary) // 2\n\n even, odd = Counter(ary[::2]), Counter(ary[1::2])\n (e, em), (_, es) = even.most_common(2)\n (o, om), (_, os) = odd.most_common(2)\n return size - max(em + os, es + om) if e == o else size - em - om\n\nprint(solve())', 'from collections import Counter\n\ngiven1 = int(input())\ngiven2 = [int(_) for _ in input().split()]\n\ndef solve(size=given1, ary=given2):\n even, odd = Counter(ary[::2]), Counter(ary[1::2])\n\n emst, esec = even.most_common(2)\n eme, emf = emst\n ese, esf = esec\n\n omst, osec = odd.most_common(2)\n ome, omf = omst\n ose, osf = osec\n\n return size - max(emf + osf, omf + esf) if eme == ome else size - esf - osf\n\n\nprint(solve())\n', 'from collections import Counter\ndef solve(size=int(input()), ary=list(map(int, input().split()))):\n even, odd = Counter(ary[::2]), Counter(ary[1::2])\n (e, em), (_, es) = even.most_common(2)\n (o, om), (_, os) = odd.most_common(2)\n return size - max(em + os, es + om) if e == o else size - em - om\nprint(solve())', 'from collections import Counter\n\ndef solve(size=int(input()), ary=list(map(int, input().split()))):\n even, odd = Counter(ary[::2]), Counter(ary[1::2])\n even[0], odd[0] = 0, 0\n print(even)\n print(odd)\n (e, em), (_, es) = even.most_common(2)\n (o, om), (_, os) = odd.most_common(2)\n return size - max(em + os, es + om) if e == o else size - em - om\n\nprint(solve())', 'def solve(size=int(input()), ary=list(map(int, input().split())), max_range=100001):\n even = [0 for _ in range(max_range)]\n odd = [0 for _ in range(max_range)]\n\n (em, ei), (om, oi) = (0, 0), (0, 0)\n\n for i in range(size):\n if i % 2 == 0:\n even[ary[i]] += 1\n if even[ary[i]] > em:\n em, ei = even[ary[i]], ary[i]\n else:\n odd[ary[i]] += 1\n if odd[ary[i]] > om:\n om, oi = odd[ary[i]], ary[i]\n\n if ei == oi:\n even[ei], odd[oi] = 0, 0\n return size - max(max(even) + om, max(odd) + em)\n else:\n return size - (em + om)\n\nprint(solve())'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s221644723', 's379311637', 's877253683', 's969284507', 's594239114'] | [18644.0, 18656.0, 18656.0, 21432.0, 14268.0] | [90.0, 86.0, 86.0, 162.0, 79.0] | [372, 442, 322, 382, 653] |
p03246 | u106778233 | 2,000 | 1,048,576 | 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. | ["\ndef main():\n from collections import Counter\n N=int(input())\n A=list(ma())\n evens = Counter(A[::2])\n odds = Counter(A[1::2])\n evens[0]=0 \n odds[0]=0 #\n \n e1, e2=evens.most_common(2) \n o1, o2=odds.most_common(2) #\n \n if e1[0]!=o1[0]:\n print(N - (e1[1] + o1[1]))\n else: \n print(N - max(e1[1]+o2[1], e2[1]+o1[1]))\n \nif __name__ == '__main__':\n main()\n", "def ma():\n return map(int,input().split())\n\ndef main():\n from collections import Counter\n N=int(input())\n A=list(ma())\n evens = Counter(A[::2])\n odds = Counter(A[1::2])\n evens[0]=0 \n odds[0]=0 #\n \n e1, e2=evens.most_common(2) \n o1, o2=odds.most_common(2) #\n \n if e1[0]!=o1[0]:\n print(N - (e1[1] + o1[1]))\n else: \n print(N - max(e1[1]+o2[1], e2[1]+o1[1]))\n \nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Accepted'] | ['s101626879', 's250344679'] | [3316.0, 18656.0] | [21.0, 72.0] | [498, 542] |
p03246 | u131405882 | 2,000 | 1,048,576 | 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. | ['import collections\nn = int(input())\nv = list(map(int, input().split()))\na = []\nb = []\nfor i in range(n // 2):\n a.append(v[(i+1)*2-1])\n b.append(v[(i+1)*2-2])\na = collections.Counter(a)\nb = collections.Counter(b)\n\n\nif a.most_common()[0][0] != b.most_common()[0][0]:\n print(n-a.most_common()[0][1]-b.most_common()[0][1])\nelif a.most_common()[1][0] + b.most_common()[0][0] > a.most_common()[0][0] + b.most_common()[1][0]\n print(n-a.most_common()[1][0] - b.most_common()[0][0])\nelse:\n print(n-a.most_common()[0][0] - b.most_common()[1][0])', 'import collections\nn = int(input())\nv = list(map(int, input().split()))\na = []\nb = []\nfor i in range(n // 2):\n a.append(v[(i+1)*2-1])\n b.append(v[(i+1)*2-2])\na = collections.Counter(a)\nb = collections.Counter(b)\n\n\nif a.most_common()[0][0] != b.most_common()[0][0]:\n print(n - a.most_common()[0][1] - b.most_common()[0][1])\nelif len(a.most_common()) == 1 and len(b.most_common()) == 1:\n print(n//2)\nelif a.most_common()[1][1] + b.most_common()[0][1] > a.most_common()[0][1] + b.most_common()[1][1]:\n print(n - a.most_common()[1][1] - b.most_common()[0][1])\nelse:\n print(n - a.most_common()[0][1] - b.most_common()[1][1])'] | ['Runtime Error', 'Accepted'] | ['s100801726', 's596417947'] | [3064.0, 18656.0] | [17.0, 164.0] | [550, 637] |
p03246 | u218843509 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\none = sorted(Counter([v[i] for i in range(0, n, 2)]).items(), key=lambda x: x[1], reverse=True)\ntwo = sorted(Counter([v[i] for i in range(1, n, 2)]).items(), key=lambda x: x[1], reverse=True)\n\nprint(one, two)\nif one[0][0] != two[0][0]:\n\tprint(n - one[0][1] - two[0][1])\nelse:\n\tif len(one) == 1 and len(two) == 1:\n\t\tprint(n // 2)\n\telif len(one) == 1:\n\t\tprint(n // 2 - two[1][1])\n\telif len(two) == 1:\n\t\tprint(n // 2 - one[1][1])\n\telse:\n\t\tprint(min(n - one[0][1] - two[1][1]), n - one[1][1] - two[0][1])', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\none = sorted(Counter([v[i] for i in range(0, n, 2)]).items(), key=lambda x: x[1], reverse=True)\ntwo = sorted(Counter([v[i] for i in range(1, n, 2)]).items(), key=lambda x: x[1], reverse=True)\n\n\nif one[0][0] != two[0][0]:\n\tprint(n - one[0][1] - two[0][1])\nelse:\n\tif len(one) == 1 and len(two) == 1:\n\t\tprint(n // 2)\n\telif len(one) == 1:\n\t\tprint(n // 2 - two[1][1])\n\telif len(two) == 1:\n\t\tprint(n // 2 - one[1][1])\n\telse:\n\t\tprint(min(n - one[0][1] - two[1][1], n - one[1][1] - two[0][1]))'] | ['Runtime Error', 'Accepted'] | ['s920809708', 's378338044'] | [21844.0, 20692.0] | [128.0, 115.0] | [587, 588] |
p03246 | u269623316 | 2,000 | 1,048,576 | 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. | ['from copy import *\nn=int(input())\narr=list(map(int,input().split()))\narr1=[]\narr2=[]\nfor i in range(1,100001):\n\tarr1.append([0,i])\n\tarr2.append([0,i])\n\nfor i in range(0,n,2):\n\tarr1[arr[i]-1][0]+=1\n#arr1.sort()\n#print(arr1[-1])\nfor i in range(1,n,2):\n\tarr2[arr[i]-1][0]+=1\narr1.sort(reverse=True)\narr2.sort(reverse=True)\n#print(arr1[-1],arr2[-1])\nif(arr1[0][1]==arr2[0][1]):\n\tprint(min(n-arr1[0][0]-arr2[1][0],n-arr1[1][0]-arr2[0][0]))\t\nelse:\n\tprint(n-arr1[-1][0]-arr2[-1][0])\n', 'from copy import *\nn=int(input())\narr=list(map(int,input().split()))\narr1=[]\narr2=[]\nfor i in range(1,100001):\n\tarr1.append([0,i])\n\tarr2.append([0,i])\n\nfor i in range(0,n,2):\n\tarr1[arr[i]-1][0]+=1\n#arr1.sort()\n#print(arr1[-1])\nfor i in range(1,n,2):\n\tarr2[arr[i]-1][0]+=1\narr1.sort(reverse=True)\narr2.sort(reverse=True)\n#print(arr1[-1],arr2[-1])\nif(arr1[0][1]==arr2[0][1]):\n\tprint(min(n-arr1[0][0]-arr2[1][0],n-arr1[1][0]-arr2[0][0]))\t\nelse:\n\tprint(n-arr1[0][0]-arr2[0][0])\n'] | ['Wrong Answer', 'Accepted'] | ['s063064431', 's415072457'] | [32436.0, 32180.0] | [204.0, 222.0] | [476, 474] |
p03246 | u279136325 | 2,000 | 1,048,576 | 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. | ['\nimport sys\nfrom collections import *\n\nn = int(input())\nv = [int(x) for x in input().split()]\n\nif not n:\n print(0)\n sys.exit()\n\nn1 = Counter(v[::2])\nn2 = Counter(v[1::2])\n\nmax1 = 0\n\nn1 = sorted([(count, k) for k, count in n1.items()], reverse=True)\nn2 = sorted([(count, k) for k, count in n2.items()], reverse=True)\n\nif n1[0][1] == n2[0][1]:\n if len(n1) == 1 and len(n2) == 1:\n print(n//2)\n sys.exit()\n if len(n1) == 1 or n1[0][0] > n2[0][0]:\n print(n - n1[0][0] - n2[1][0])\n sys.exit()\n if len(n2) == 1 or n1[0][0] < n2[0][0]:\n print(n - n1[1][0] - n2[0][0])\n sys.exit()\n if n1[0][0] == n2[0][0]:\n if n1[1][0] >= n2[1][0]:\n print(n - n1[1][0] - n2[0][0])\n elif n1[1][0] < n2[1][0]:\n print(n - n1[0][0] - n2[1][0])\n sys.exit()\n\ncount = n1 - n1[0][0] - n2[0][0]\nprint(count)\n', '\nimport sys\nfrom collections import *\n\nn = int(input())\nv = [int(x) for x in input().split()]\n\nif not n:\n print(0)\n sys.exit()\n\nn1 = Counter(v[::2])\nn2 = Counter(v[1::2])\n\nmax1 = 0\n\nn1 = sorted([(count, k) for k, count in n1.items()], reverse=True)\nn2 = sorted([(count, k) for k, count in n2.items()], reverse=True)\n\nif n1[0][1] == n2[0][1]:\n if len(n1) == 1 and len(n2) == 1:\n print(n//2)\n sys.exit()\n if len(n1) == 1 or n1[0][0] > n2[0][0]:\n print(n - n1[0][0] - n2[1][0])\n sys.exit()\n if len(n2) == 1 or n1[0][0] < n2[0][0]:\n print(n - n1[1][0] - n2[0][0])\n sys.exit()\n if n1[0][0] == n2[0][0]:\n if n1[1][0] >= n2[1][0]:\n print(n - n1[1][0] - n2[0][0])\n elif n1[1][0] < n2[1][0]:\n print(n - n1[0][0] - n2[1][0])\n sys.exit()\n\ncount = n - n1[0][0] - n2[0][0]\nprint(count)\n'] | ['Runtime Error', 'Accepted'] | ['s133062852', 's333257414'] | [18648.0, 18648.0] | [101.0, 100.0] | [877, 876] |
p03246 | u332253305 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn=int(input())\ns=list(map(int,input().split()))\ne=Counter(s[0::2])\no=Counter(s[1::2])\ne[0]=0\no[0]=0\ne1,e2=e.most_common(2)\no1,o2=o.most_common(2)\nif e1[0]!=o1[0]:\n print(n-(e1[1]+o1[1]))\nelse:\n print(n-max(e1[1]+o2[1],e2[1]+o1[1]))z', 'from collections import Counter\n\nn=int(input())\ns=list(map(int,input().split()))\ne=Counter(s[0::2])\no=Counter(s[1::2])\ne[0]=0\no[0]=0\ne1,e2=e.most_common(2)\no1,o2=o.most_common(2)\nif e1[0]!=o1[0]:\n print(n-(e1[1]+o1[1]))\nelse:\n print(n-max(e1[1]+o2[1],e2[1]+o1[1]))'] | ['Runtime Error', 'Accepted'] | ['s705067483', 's950254032'] | [3064.0, 18656.0] | [17.0, 78.0] | [271, 270] |
p03246 | u340781749 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nfrom itertools import takewhile\n\nn = int(input())\nvvv = list(map(int, input().split()))\ncnt1 = Counter(vvv[0::2])\ncnt2 = Counter(vvv[1::2])\nmc1 = cnt1.most_common()\nmc2 = cnt2.most_common()\nmcs1 = list(takewhile(lambda x: x[1] == mc1[0][1], mc1))\nmcs2 = list(takewhile(lambda x: x[1] == mc2[0][1], mc2))\nprint(mc1, mc2, mcs1, mcs2)\nif len(mcs1) == len(mcs2) and mcs1[0][0] == mcs2[0][0]:\n if len(mc1) > 1:\n if len(mc2) > 1:\n print(min(n - mc1[0][1] - mc2[1][1], n - mc1[1][1] - mc2[0][1]))\n else:\n print(min(n - mc1[0][1], n - mc1[1][1] - mc2[0][1]))\n else:\n if len(mc2) > 1:\n print(min(n - mc1[0][1] - mc2[1][1], n - mc2[0][1]))\n else:\n print(min(n - mc1[0][1], n - mc2[0][1]))\nelse:\n print(n - mc1[0][1] - mc2[0][1])\n', 'from collections import Counter\n\nn = int(input())\nvvv = list(map(int, input().split()))\ncnt1 = Counter(vvv[0::2])\ncnt2 = Counter(vvv[1::2])\nmc1 = cnt1.most_common(2)\nmc2 = cnt2.most_common(2)\nif mc1[0][0] == mc2[0][0]:\n sc1 = mc1[1][1] if len(mc1) > 1 else 0\n sc2 = mc2[1][1] if len(mc2) > 1 else 0\n print(min(n - mc1[0][1] - sc2, n - sc1 - mc2[0][1]))\nelse:\n print(n - mc1[0][1] - mc2[0][1])\n'] | ['Wrong Answer', 'Accepted'] | ['s040169548', 's406852386'] | [25664.0, 18656.0] | [207.0, 76.0] | [832, 405] |
p03246 | u367130284 | 2,000 | 1,048,576 | 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. | ['from collections import*\nn,*v=open(0).read().split()\nn=int(n)\na=[v[s]for s in range(0,n,2)]\nb=[v[s]for s in range(1,n,2)]\nc=Counter(a).most_common()\nd=Counter(b).most_common()\nprint(c,d)\nif len(c)==1 and len(d)==1:\n if c==d:\n print(n//2)\n else:\n print(0)\nelif c[0][1]!=d[0][1]:\n print(sum([s[1]for s in c[1:]])+sum([s[1]for s in d[1:]]))\nelse:\n x=sum([s[1]for s in c[1:]])+d[0][1]+sum([s[1]for s in d[2:]])\n y=sum([s[1]for s in d[1:]])+c[0][1]+sum([s[1]for s in c[2:]])\n print(min(x,y))', 'from collections import*\nn,*v=open(0).read().split()\nn=int(n)\na=[v[s]for s in range(0,n,2)]\nb=[v[s]for s in range(1,n,2)]\nprint(Counter(a).most_common(),Counter(b).most_common())\nc=Counter(a).most_common()\nd=Counter(b).most_common()\nif c[0][1]!=d[0][1]:\n print(sum([s[1]for s in c[1:]])+sum([s[1]for s in d[1:]]))\nelse:\n if len(c)and len(d)==1:\n if c==d:\n print(n//2)\n else:\n print(0)\n else:\n x=sum([s[1]for s in c[1:]])+d[0][1]+sum([s[1]for s in d[2:]])\n y=sum([s[1]for s in d[1:]])+c[0][1]+sum([s[1]for s in c[2:]])\n print(min(x,y)) ', 'from collections import*\nn,*a=map(int,open(0).read().split())\nodd =Counter([v for k,v in enumerate(a) if k%2==0]).most_common()\neven=Counter([v for k,v in enumerate(a) if k%2==1]).most_common()\n\n\nif len(odd)==len(even)==1:\n if odd[0][0]==even[0][0]:\n print(len(a)//2)\n else:\n print(0)\nelif odd[0][0]!=even[0][0]:\n print(sum(t for(s,t)in odd[1:])+sum(t for(s,t)in even[1:]))\nelse:\n a=odd[0][1]+sum(t for(s,t)in odd[2:])+sum(t for(s,t)in even[1:])\n b=even[0][1]+sum(t for(s,t)in even[2:])+sum(t for(s,t)in odd[1:])\n print(min(a,b))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s545241080', 's938375127', 's330490288'] | [24660.0, 24660.0, 20572.0] | [140.0, 184.0, 119.0] | [498, 566, 562] |
p03246 | u371467115 | 2,000 | 1,048,576 | 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. | ['n=int(input())\nv=list(map(int,input().split()))\na=v[0::2]\nb=v[1::2]\nc=dict()\nd=dict()\n\nfor i in a:\n if i in c:\n c[i]+=1\n else:\n c[i]=1\nfor j in d:\n if j in d:\n d[j]+=1\n else:\n d[j]=1\n\ne=sorted([[c,v] for v,c in c.items()],reverse=True)\nf=sorted([[c,v] for v,c in d.items()],reverse=True)\n\nif e[0][1]!=f[0][1]:\n print(n-e[0][0]-f[0][0])\nelif e[0][0]>f[0][0]:\n print(n-e[0][0]-f[1][0])\nelse:\n print(n-e[1][0]-f[0][0])', 'n=int(input())\nv=list(map(int,input().split()))\na=[]\nb=[]\nc=dict()\nd=dict()\n\nfor i in range(0,n,2):\n a.append(v[i])\n if v[i] in c:\n c[v[i]]+=1\n else:\n c[v[i]]=1\n \nfor j in range(1,n,2):\n b.appene(v[j])\n if v[i] in d:\n d[v[i]]+=1\n else:\n d[v[i]]=1\n\nc_max=c.pop(c.value(max(c.value())))\nc_max2=c.pop(c.value(max(c.value())))\nd_max=d.pop(d.value(max(d.value())))\nd_max2=d.pop(d.value(max(d.value())))\n \nif :\n print(n-c_max-d_max)\nelse:\n if c_max>d_max:\n print(n-c_max-d_max2)\n else:\n print(n-c_max2-d_max)', 'n=int(input())\nv=list(map(int,input().split()))\na=v[0::2]\nb=v[1::2]\nc=dict()\nd=dict()\n\nfor i in a:\n if i in c:\n c[i]+=1\n else:\n c[i]=1\nfor j in b:\n if j in d:\n d[j]+=1\n else:\n d[j]=1\n\ne=sorted([[w,v] for v,w in c.items()],reverse=True)\nf=sorted([[w,v] for v,w in d.items()],reverse=True)\n\nif len(set(a))==len(set(b))==1 and e[0][1]==f[0][1] and e[0][0]==f[0][0]:\n print(min(len(a),len(b)))\nelif e[0][1]!=f[0][1]:\n print(n-e[0][0]-f[0][0])\nelif e[0][0]>f[0][0]:\n print(n-e[0][0]-f[1][0])\nelif e[0][0]<f[0][0]:\n print(n-e[1][0]-f[0][0])\nelif e[0][0]==f[0][0] and e[0][1]==f[0][1]:\n if e[1][0]>f[1][0]:\n print(n-e[1][0]-f[0][0])\n else:\n print(n-e[0][0]-f[1][0])'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s555468693', 's651320828', 's874583749'] | [16872.0, 3064.0, 27104.0] | [81.0, 18.0, 125.0] | [434, 535, 686] |
p03246 | u375870553 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\n\ndef main():\n n = int(input())\n v = [int(i) for i in input().split()]\n ans = 0\n odd = Counter(v[1::2])\n even = Counter(v[::2])\n odd_mosts = odd.most_common(2)\n even_mosts = even.most_common(2)\n if odd_mosts[0][0] == even_mosts[0][0]:\n if len(odd) == len(even) == 1:\n ans = n//2\n else:\n ans_sel = []\n ans_sel.append(n//2-odd_mosts[0][1]+n//2-even_mosts[1][1])\n ans_sel.append(n//2-odd_mosts[1][1]+n//2-even_mosts[0][1])\n ans = min(ans_sel)\n else:\n ans+=(n//2-odd_mosts[0][1])\n ans+=(n//2-even_mosts[0][1])\n print(ans)', "from collections import Counter\n\n\ndef main():\n n = int(input())\n v = [int(i) for i in input().split()]\n ans = 0\n odd = Counter(v[1::2])\n even = Counter(v[::2])\n odd_mosts = odd.most_common(2)\n even_mosts = even.most_common(2)\n if odd_mosts[0][0] == even_mosts[0][0]:\n if len(odd) == len(even) == 1:\n ans = n//2\n else:\n ans_sel = []\n ans_sel.append(n//2-odd_mosts[0][1]+n//2-even_mosts[1][1])\n ans_sel.append(n//2-odd_mosts[1][1]+n//2-even_mosts[0][1])\n ans = min(ans_sel)\n else:\n ans+=(n//2-odd_mosts[0][1])\n ans+=(n//2-even_mosts[0][1])\n print(ans)\n\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s175378799', 's483131507'] | [3316.0, 18656.0] | [21.0, 79.0] | [662, 701] |
p03246 | u404676457 | 2,000 | 1,048,576 | 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. | ['n = input().split()\nvs = list(map(int, input().split()))\n\neve = {}\nodd = {}\n\nfor i in range(len(vs)):\n if i % 2 == 0:\n if vs[i] in eve:\n eve[vs[i]] += 1\n else:\n eve[vs[i]] = 1\n else:\n if vs[i] in odd:\n odd[vs[i]] += 1\n else:\n odd[vs[i]] = 1\n\nes = sorted(eve.items(), key=lambda x: -x[1])\nos = sorted(odd.items(), key=lambda x: -x[1])\n\ntrans = 0\n\nif es[0][0] == os[0][0]:\n if es[0][1] > os[0][1]:\n del es[0]\n if(len(os) > 1):\n del os[1]\n else:\n del os[0]\n if(len(es) > 1):\n del es[1]\nelse:\n del os[0]\n del es[0]\n\nfor i in range(1, len(es)):\n trans += es[0][1]\nfor i in range(1, len(os)):\n trans += os[0][1]\n\nprint(trans)', 'n = input().split()\nvs = list(map(int, input().split()))\n\neve = {}\nodd = {}\n\nfor i in range(len(vs)):\n if i % 2 == 0:\n if vs[i] in eve:\n eve[vs[i]] += 1\n else:\n eve[vs[i]] = 1\n else:\n if vs[i] in eve:\n eve[vs[i]] += 1\n else:\n eve[vs[i]] = 1\n\nes = sorted(eve.items(), key=lambda x: -x[1])\nos = sorted(eve.items(), key=lambda x: -x[1])\n\ntrans = 0\n\nif es[0][0] == os[0][0]:\n\n if es[0][1] > os[0][1]:\n del es[0]\n if(len(os) > 1):\n del os[1]\n else:\n del os[0]\n if(len(es) > 1):\n del es[1]\nelse:\n for i in range(1, len(es)):\n trans += es[0][1]\n for i in range(1, len(os)):\n trans += os[0][1]\n\nprint(trans)\n\n', 'n = input().split()\nvs = list(map(int, input().split()))\n\neve = {}\nodd = {}\n\nfor i in range(len(vs)):\n if i % 2 == 0:\n if vs[i] in eve:\n eve[vs[i]] += 1\n else:\n eve[vs[i]] = 1\n else:\n if vs[i] in odd:\n odd[vs[i]] += 1\n else:\n odd[vs[i]] = 1\n\nes = sorted(eve.items(), key=lambda x: -x[1])\nos = sorted(odd.items(), key=lambda x: -x[1])\n\nif es[0][0] == os[0][0]:\n if es[0][1] > os[0][1]:\n del es[0]\n if len(os) > 1 :\n del os[1]\n elif es[0][1] < os[0][1]:\n del os[0]\n if len(es) > 1 :\n del es[1]\n else:\n if len(es) == 1 and len(os) == 1:\n del os[0]\n elif len(es) == 1 and len(os) != 1:\n del es[0]\n del os[1]\n elif len(es) != 1 and len(os) == 1:\n del es[1]\n del os[0]\n else:\n if es[1][1] < os[1][1]:\n del es[0]\n del os[1]\n else:\n del es[1]\n del os[0]\nelse:\n del os[0]\n del es[0]\n\ntrans = 0\n\nfor i in range(len(es)):\n trans += es[i][1]\nfor i in range(len(os)):\n trans += os[i][1]\n\nprint(trans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s437264332', 's541700757', 's659609435'] | [22368.0, 28144.0, 20892.0] | [118.0, 135.0, 118.0] | [765, 755, 1201] |
p03246 | u430543459 | 2,000 | 1,048,576 | 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. | ['\n\nsequence_list=[]\nsequence_even_value_cnt_sortlist=[]\nsequence_odd_value_cnt_sortlist=[]\nsequence_even_value_cnt={}\nsequence_odd_value_cnt={}\neven_2_maxnum=0\nodd_2_maxnum=0\n\nsequence_num=int(input())\nsequence_list=input().split()\n\nfor i in range(sequence_num):\n if i%2==0:\n sequence_even_value_cnt[sequence_list[i]]=sequence_even_value_cnt.get(sequence_list[i],0)+1\n else:\n sequence_odd_value_cnt[sequence_list[i]]=sequence_odd_value_cnt.get(sequence_list[i],0)+1\n \nprint(sequence_odd_value_cnt)\nprint(sequence_even_value_cnt)\n \nsequence_even_value_cnt_sortlist=sorted(sequence_even_value_cnt.items(),key=lambda x:x[1],reverse=True)\nsequence_odd_value_cnt_sortlist=sorted(sequence_odd_value_cnt.items(),key=lambda x:x[1],reverse=True)\n\neven_1_maxnum=sequence_even_value_cnt_sortlist[0][1]\nodd_1_maxnum=sequence_odd_value_cnt_sortlist[0][1]\n\nfor j in sequence_even_value_cnt_sortlist:\n \n if even_1_maxnum!=j[1]:\n even_2_maxnum=j[1]\n break\n\nfor k in sequence_odd_value_cnt_sortlist:\n \n if odd_1_maxnum!=k[1]:\n odd_2_maxnum=k[1]\n break\n\nif sequence_even_value_cnt_sortlist[0][0]!=sequence_odd_value_cnt_sortlist[0][0]:\n ans=sequence_num-(even_1_maxnum+odd_1_maxnum)\nelse:\n if even_2_maxnum>=odd_2_maxnum:\n ans=sequence_num-(even_2_maxnum+odd_1_maxnum)\n else:\n ans=sequence_num-(even_1_maxnum+odd_2_maxnum)\n\nprint(ans)\n ', '\nn = int(input())\nnums = list(map(int, input().split()))\n\nnums1 = nums[0::2] \nnums2 = nums[1::2]\nprint(nums1)\nprint(nums2)\n\nbug1 = [0] * 100001 \nbug2 = [0] * 100001\n\n\nfor num in nums1:\n bug1[num] += 1\n\nfor num in nums2:\n bug2[num] += 1\n\nmax_v_1 = max(bug1)\nmax_i_1 = bug1.index(max_v_1) \nmax_v_2 = max(bug2)\nmax_i_2 = bug2.index(max_v_2)\n\nif max_i_1 == max_i_2:\n bug1[max_i_1] = 0 \n bug2[max_i_2] = 0\n sec_max_v_1 = max(bug1)\n sec_max_v_2 = max(bug2)\n\t\n print(n - max(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))\nelse:\n print(n - max_v_1 - max_v_2) \n\n', 'import collections\n\nsequence_num=int(input())\ncount=0\neven_sequence_list=[]\nodd_sequence_list=[]\nsequence_list=list(map(int,input().split()))\nfor i in range(sequence_num):\n\tif i%2 == 0:\n\t\teven_sequence_list.append(sequence_list[i])\n\telse:\n\t\todd_sequence_list.append(sequence_list[i])\neven_mode=collections.Counter(even_sequence_list).most_common()[0][0]\nodd_mode=collections.Counter(odd_sequence_list).most_common()[0][0]\nif even_mode != odd_mode:\n\tfor i in even_sequence_list:\n\t\tif i != even_mode:\n\t\t\tcount+=1\n\tfor j in odd_sequence_list:\n\t\tif j != odd_mode:\n\t\t\tcount+=1\n\tprint(count)\nelse:\n\teven_counter=collections.Counter(even_sequence_list)\n\todd_counter=collections.Counter(odd_sequence_list)\n\tif len(even_counter.keys()) == 1 and len(odd_counter.keys()) == 1:\n\t\teven_mode=0\n\t\tfor i in even_sequence_list:\n\t\t\tif i != even_mode:\n\t\t\t\tcount+=1\n\t\tfor j in odd_sequence_list:\n\t\t\tif j != odd_mode:\n\t\t\t\tcount+=1\n\t\tprint(count)\n\telif len(even_counter.keys()) != 1 and len(odd_counter.keys()) == 1:\n\t\teven_mode=collections.Counter(even_sequence_list).most_common()[1][0]\n\t\tfor i in even_sequence_list:\n\t\t\tif i != even_mode:\n\t\t\t\tcount+=1\n\t\tfor j in odd_sequence_list:\n\t\t\tif j != odd_mode:\n\t\t\t\tcount+=1\n\t\tprint(count)\n\telif len(even_counter.keys()) == 1 and len(odd_counter.keys()) != 1:\n\t\todd_mode=collections.Counter(odd_sequence_list).most_common()[1][0]\n\t\tfor i in even_sequence_list:\n\t\t\tif i != even_mode:\n\t\t\t\tcount+=1\n\t\tfor j in odd_sequence_list:\n\t\t\tif j != odd_mode:\n\t\t\t\tcount+=1\n\t\tprint(count)\n\telse:\n\t\teven_2_mode=collections.Counter(even_sequence_list).most_common()[1][0]\n\t\todd_2_mode=collections.Counter(odd_sequence_list).most_common()[1][0]\n\t\teven_change_count=0\n\t\todd_change_count=0\n\t\tfor i in even_sequence_list:\n\t\t\tif i != even_2_mode:\n\t\t\t\teven_change_count+=1\n\t\tfor j in odd_sequence_list:\n\t\t\tif j != odd_mode:\n\t\t\t\teven_change_count+=1\n\t\tfor i in even_sequence_list:\n\t\t\tif i != even_mode:\n\t\t\t\todd_change_count+=1\n\t\tfor j in odd_sequence_list:\n\t\t\tif j != odd_2_mode:\n\t\t\t\todd_change_count+=1\n\t\tif even_change_count < odd_change_count:\n\t\t\tprint(even_change_count)\n\t\telse:\n\t\t\tprint(odd_change_count)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s132520909', 's471638752', 's334296502'] | [25316.0, 14404.0, 23452.0] | [136.0, 70.0, 177.0] | [1413, 1028, 2108] |
p03246 | u452557250 | 2,000 | 1,048,576 | 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. | ["import collections\nimport numpy as np\n\nn = int(input())\nl = input().split()\nv = [ int(s) for s in l ]\n\nn = 8\nnpv = np.array( v, dtype=np.int32)\n#npv = np.array( [1,1,1,1,1,3,2,3], dtype=np.int32)\nnpv_dic = {}\nnpv_dic['even'] = npv[0::2]\nnpv_dic['odd'] = npv[1::2]\n\n#print('n = ', n)\n#print('npv = ', npv)\n#print('npv_dic[\\'even\\'] = ', npv_dic['even'])\n#print('npv_dic[\\'odd\\'] = ', npv_dic['odd'])\n\ndict0 = collections.Counter(npv_dic['even'])\ndict1 = collections.Counter(npv_dic['odd'])\n\nlist0 = list(dict0.items())\nlist1 = list(dict1.items())\n\nlist0.sort(key= lambda x:x[1], reverse=True)\nlist1.sort(key= lambda x:x[1], reverse=True)\n\nif list0[0][0] == list1[0][0]:\n if list0[0][1] > list1[0][1]:\n del list1[0]\n else:\n del list0[0]\n\nchange0 = n//2 - list0[0][1]\nchange1 = n//2 - list1[0][1]\n#print('change:', change0, change1)\n\nprint(change0 + change1)", "import collections\nimport numpy as np\n\nn = int(input())\nl = input().split()\nv = [ int(s) for s in l ]\n\n#n = 4\nnpv = np.array( v, dtype=np.int32)\n#npv = np.array( [3,1,3,2], dtype=np.int32)\nnpv_dic = {}\nnpv_dic['even'] = npv[0::2]\nnpv_dic['odd'] = npv[1::2]\n\n#print('n = ', n)\n#print('npv = ', npv)\n#print('npv_dic[\\'even\\'] = ', npv_dic['even'])\n#print('npv_dic[\\'odd\\'] = ', npv_dic['odd'])\n\ndict0 = collections.Counter(npv_dic['even'])\ndict1 = collections.Counter(npv_dic['odd'])\n\nlist0 = list(dict0.items())\nlist1 = list(dict1.items())\n\nlist0.sort(key= lambda x:x[1], reverse=True)\nlist1.sort(key= lambda x:x[1], reverse=True)\n\nprint(list0[0] ,list1[0])\nprint(list0[1] ,list1[1])\n\nif list0[0][0] == list1[0][0]:\n if list0[0][1] == list1[0][1]:\n if list0[1][1] > list1[1][1]:\n del list0[0]\n else:\n del list1[0]\n elif list0[0][1] > list1[0][1]:\n del list1[0]\n else:\n del list0[0]\n#print(list0[0] ,list1[0])\n#print(list0[1] ,list1[1])\n\nif list0.__len__() != 0:\n change0 = n//2 - list0[0][1]\nelse:\n change0 = n//2\nchange1 = n//2 - list1[0][1]\n#print('change:', change0, change1)\n\nprint(change0 + change1)\n", 'n = int(input())\n', "import collections\nimport numpy as np\n\nn = int(input())\nl = input().split()\nv = [ int(s) for s in l ]\n\n#n = 4\nnpv = np.array( v, dtype=np.int32)\n#npv = np.array( [3,1,3,2], dtype=np.int32)\nnpv_dic = {}\nnpv_dic['even'] = npv[0::2]\nnpv_dic['odd'] = npv[1::2]\n\n#print('n = ', n)\n#print('npv = ', npv)\n#print('npv_dic[\\'even\\'] = ', npv_dic['even'])\n#print('npv_dic[\\'odd\\'] = ', npv_dic['odd'])\n\ndict0 = collections.Counter(npv_dic['even'])\ndict1 = collections.Counter(npv_dic['odd'])\n\nlist0 = list(dict0.items())\nlist1 = list(dict1.items())\n\nlist0.sort(key= lambda x:x[1], reverse=True)\nlist1.sort(key= lambda x:x[1], reverse=True)\n\n#print(list0[0] ,list1[0])\n#print(list0[1] ,list1[1])\n\nif list0[0][0] == list1[0][0]:\n if (list0[0][1] == list1[0][1]) and \\\n (list0.__len__() > 1) and (list0.__len__() > 1):\n if list0[1][1] > list1[1][1]:\n del list0[0]\n else:\n del list1[0]\n elif list0[0][1] > list1[0][1]:\n del list1[0]\n else:\n del list0[0]\n#print(list0[0] ,list1[0])\n#print(list0[1] ,list1[1])\n\nif list0.__len__() != 0:\n change0 = n//2 - list0[0][1]\nelse:\n change0 = n//2\nif list1.__len__() != 0:\n change1 = n//2 - list1[0][1]\nelse:\n change1 = n//2\n#print('change:', change0, change1)\n\nprint(change0 + change1)\n"] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s523411138', 's766409146', 's918345865', 's704391595'] | [39700.0, 39764.0, 2940.0, 39680.0] | [252.0, 439.0, 17.0, 356.0] | [877, 1171, 17, 1291] |
p03246 | u476038506 | 2,000 | 1,048,576 | 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. | ['N = int(input())\nV = [int(i) for i in input().split()]\nV1 = [V[2*j-2] for j in range(1, N//2+1)]\nV2 = [V[2*j-1] for j in range(1, N//2+1)]\n#print(V1, V2)\n\ndef dict(x):\n D = {}\n for i in x:\n if i in D:\n D[i] += 1\n else:\n D.setdefault(i, 1)\n return D\n\ndictV1 = dict(V1)\ndictV2 = dict(V2)\n\n\nsortdictV1 = sorted(dictV1.items(), key=lambda x:x[1], reverse=True)\nsortdictV2 = sorted(dictV2.items(), key=lambda x:x[1], reverse=True)\na = 0\nif sortdictV1[0][0] != sortdictV2[0][0]:\n a = N - sortdictV1[0][1] - sortdictV2[0][1]\nelse:\n if len(dictV1) == len(dictV2) == 1:\n a = N // 2\n else:\n if len(dictV1) == 1:\n a = N - sortdictV1[0][1] - sortdictV2[1][1]\n elif len(dictV2) == 1:\n a = N - sortdictV1[1][1] - sortdictV2[0][1]\n else:\n a = min(N - sortdictV1[0][1] - sortdictV2[1][1], N - sortdictV1[1][1] - sortdictV2[0][1])\n print(a)', 'N = int(input())\nV = [int(i) for i in input().split()]\nV1 = [V[2*j-2] for j in range(1, N//2+1)]\nV2 = [V[2*j-1] for j in range(1, N//2+1)]\n#print(V1, V2)\n\ndef dict(x):\n D = {}\n for i in x:\n if i in D:\n D[i] += 1\n else:\n D.setdefault(i, 1)\n return D\n\ndictV1 = dict(V1)\ndictV2 = dict(V2)\n\n\nsortdictV1 = sorted(dictV1.items(), key=lambda x:x[1], reverse=True)\nsortdictV2 = sorted(dictV2.items(), key=lambda x:x[1], reverse=True)\na = 0\nif len(dictV1) == 1:\n a = a + 0\nelse:\n a = a + N/2 - sortdictV1[0][1]\nif len(dictV2) == 1:\n a = a + 0\nelse:\n a = a + N/2 - sortdictV2[0][1]\nif sortdictV1[0][0] == sortdictV2[0][0]:\n a = 0\n a = a + min(N/2 - sortdiictV1[0][1] + N/2 - sortdictV2[1][1], N/2 - sortdiictV2[0][1] + N/2 - sortdictV1[1][1])\nprint(a)\n', 'N = int(input())\nV = [int(i) for i in input().split()]\nV1 = [V[2*j-2] for j in range(1, N//2+1)]\nV2 = [V[2*j-1] for j in range(1, N//2+1)]\n#print(V1, V2)\n\ndef dict(x):\n D = {}\n for i in x:\n if i in D:\n D[i] += 1\n else:\n D.setdefault(i, 1)\n return D\n\ndictV1 = dict(V1)\ndictV2 = dict(V2)\n\n\nsortdictV1 = sorted(dictV1.items(), key=lambda x:x[1], reverse=True)\nsortdictV2 = sorted(dictV2.items(), key=lambda x:x[1], reverse=True)\na = 0\nif sortdictV1[0][0] != sortdictV2[0][0]:\n a = N - sortdictV1[0][1] - sortdictV2[0][1]\nelse:\n if len(dictV1) == len(dictV2) == 1:\n a = N // 2\n else:\n if len(dictV1) == 1:\n a = N - sortdictV1[0][1] - sortdictV2[1][1]\n elif len(dictV2) == 1:\n a = N - sortdictV1[1][1] - sortdictV2[0][1]\n else:\n a = min(N - sortdictV1[0][1] - sortdictV2[1][1], N - sortdictV1[1][1] - sortdictV2[0][1])\nprint(a)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s807658403', 's945863611', 's858573311'] | [21568.0, 21408.0, 23332.0] | [109.0, 108.0, 105.0] | [898, 790, 897] |
p03246 | u478870821 | 2,000 | 1,048,576 | 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. | ['from sys import exit, setrecursionlimit, stderr\nfrom functools import reduce\nfrom itertools import *\nfrom collections import defaultdict, Counter\nfrom bisect import bisect\n\ndef read():\n return int(input())\n\ndef reads():\n return [int(x) for x in input().split()]\n\nn = read()\nv = reads()\n\nevens = sorted((v, k) for k, v in Counter(v[::2]).items()) + [(0, -1)]\nodds = sorted((v, k) for k, v in Counter(v[1::2]).items()) + [(0, -1)]\n\nprint(evens, odds)\n\nif evens[0][1] != odds[0][1]:\n ans = n - evens[0][0] - odds[0][0]\nelse:\n ans = n - max(evens[0][0] + odds[1][0], evens[1][0] + odds[0][0])\n\nprint(ans)', 'from sys import exit, setrecursionlimit, stderr\nfrom functools import reduce\nfrom itertools import *\nfrom collections import defaultdict, Counter\nfrom bisect import bisect\n\ndef read():\n return int(input())\n\ndef reads():\n return [int(x) for x in input().split()]\n\nn = read()\nv = reads()\n\nevens = sorted(((v, k) for k, v in Counter(v[::2]).items()), reverse=True) + [(0, -1)]\nodds = sorted(((v, k) for k, v in Counter(v[1::2]).items()), reverse=True) + [(0, -1)]\n\nif evens[0][1] != odds[0][1]:\n ans = n - evens[0][0] - odds[0][0]\nelse:\n ans = n - max(evens[0][0] + odds[1][0], evens[1][0] + odds[0][0])\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s669802350', 's257686642'] | [20808.0, 20808.0] | [136.0, 143.0] | [604, 616] |
p03246 | u552357043 | 2,000 | 1,048,576 | 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. | ['import collections\nn = int(input())\nv = list(map(int, input().split()))\neven = [v[2*i] for i in range(n//2)]\nodd = [v[2**i+1] for i in range(n//2)]\ndEven = collections.Counter(even).most_common()\ndOdd = collections.Counter(odd).most_common()\nif dEven[0][0] != dOdd[0][0]:\n ans = n - dEven[0][1] - dOdd[0][1]\nelse:\n ans = n - max(dEven[0][1]+dOdd[1][0], dEven[1][0]+dOdd[0][1])\nprint(ans)', 'import collections\nn = int(input())\nv = list(map(int, input().split()))\neven = [v[2*i] for i in range(n//2)]\nodd = [v[2*i+1] for i in range(n//2)]\ndEven = collections.Counter(even).most_common()\ndOdd = collections.Counter(odd).most_common()\nif dEven[0][0] != dOdd[0][0]:\n ans = n - dEven[0][1] - dOdd[0][1]\nelse:\n if len(dEven) >=2 and len(dOdd) >= 2:\n ans = n - max(dEven[0][1]+dOdd[1][1], dEven[1][1]+dOdd[0][1])\n elif len(dEven) < len(dOdd):\n ans = n - (dEven[0][1]+dOdd[1][1])\n elif len(dEven) > len(dOdd):\n ans = n - (dEven[1][1]+dOdd[0][1])\n else:\n ans = n//2\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s195102101', 's737939625'] | [14908.0, 21084.0] | [48.0, 97.0] | [394, 620] |
p03246 | u555947166 | 2,000 | 1,048,576 | 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. | ['from statistics import mode\nn = int(input())\nvlist = list(map(int, input().split()))\n\n\na = vlist[::2]\nb = vlist[1::2]\n\nfreq_a = mode(a)\nfreq_b = mode(b)\n\n\nx = len(a) - freq_a\ny = len(b) - freq_b\n\nprint(a)\nprint(b)\nprint(freq_a)\nprint(freq_b)\n\nif len(set(vlist)) == 1:\n print(min(len(a), len(b)))\nelse:\n print(x+y)\n', 'from statistics import mode\nn = int(input())\nvlist = list(map(int, input().split()))\n\n\na = vlist[::2]\nb = vlist[1::2]\n\nfreq_a = mode(a)\nfreq_b = mode(b)\n\n\nx = len(a) - freq_a\ny = len(b) - freq_b\n\n\nif len(set(vlist)) == 1:\n print(min(len(a), len(b)))\nelse:\n print(x+y)\n', 'n = int(input())\nvlist = list(map(int, input().split()))\n\na = max(vlist[::2])\nb = max(vlist[1::2])\n\nx = len(a) - vlist[::2].count(a)\ny = len(b) - vlist[1::2].count(b)\n\nprint(x+y)', "from collections import Counter\n\nn = int(input())\nvlist = list(map(int, input().split()))\n\n\nCounter_evens = Counter(vlist[::2])\nCounter_odds = Counter(vlist[1::2])\n\n\n# even_indexes\ntop2_even = Counter_evens.most_common(2) \n\nE_most_common = top2_even[0][0]\nEmnum = top2_even[0][1]\n\nif len(top2_even) == 2:\n E_2nd_common = top2_even[1][0]\n E2num = top2_even[1][1]\nelse:\n E_2nd_common = 'foo'\n E2num = 0\n\n\ntop2_odd = Counter_odds.most_common(2)\n\nO_most_common = top2_odd[0][0]\nOmnum = top2_odd[0][1]\n\nif len(top2_odd) == 2:\n O_2nd_common = top2_odd[1][0]\n O2num = top2_odd[1][1]\nelse:\n O_2nd_common = 'foo'\n O2num = 0\n\n\nif E_most_common == O_most_common: \n \n \n\n \n x = len(vlist[::2]) - Emnum + len(vlist[1::2]) - O2num\n \n y = len(vlist[::2]) - E2num + len(vlist[1::2]) - Omnum\n\n print(min(x, y))\nelse:\n \n \n print(len(vlist[::2]) - Emnum + len(vlist[1::2]) - Omnum)\n"] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s214498701', 's449885458', 's910700749', 's754386129'] | [17680.0, 17552.0, 14396.0, 18656.0] | [101.0, 90.0, 47.0, 81.0] | [320, 274, 178, 1766] |
p03246 | u557659226 | 2,000 | 1,048,576 | 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. | ['# coding: utf-8\n# Your code here!\n\nimport numpy as np\n\ndef canbe_solved(positions):\n flg = np.dot(positions[0],np.ones(2,int))%2\n for p in positions:\n flg ^= (np.dot(p,np.ones(2,int)) %2 )\n if flg:\n return False\n return True\n\ndef solutions(p,vals):\n u = np.dot(p, np.array([1,1]))\n v = np.dot(p, np.array([1,-1]))\n for val in vals:\n if u >=0:\n if v >= 0:\n print(\'R\',end="")\n u -= val\n v -= val\n else:\n print(\'U\',end="")\n u -= val\n v += val\n else:\n if v >= 0:\n print(\'D\',end="")\n u += val\n v -= val\n else:\n print(\'L\',end="")\n u += val\n v += val\n print()\n \n \ndef main():\n #input\n n = int(input().rstrip())\n positions = [np.asarray(list(map(int,input().rstrip().split()))) for _ in range(n)]\n vals = [1<<i for i in range(30,-1,-1)]\n if np.dot(positions[0], np.ones(2,int)) % 2 == 0:\n vals.append(1)\n\n if canbe_solved(positions):\n print(len(vals))\n for i,p in enumerate(vals):\n print(p,end="")\n if i == len(vals)-1:\n print(\'\')\n else:\n print(\' \', end="")\n\n for p in positions:\n solutions(p,vals)\n else:\n print(\'-1\')\n \nmain()\n\n ', 'import collections\n\narr_length = int(input().rstrip())\narr = list(map(int,input().rstrip().split()))\n\narr_odd = arr[0::2]\narr_even = arr[1::2]\n\ndef count_strange(arr):\n c = collections.Counter(arr)\n keys, vals = zip(*c.most_common())\n return keys, vals\n\ndef proc(arr1, arr2):\n keys1, vals1 = count_strange(arr1)\n keys2, vals2 = count_strange(arr2)\n \n if keys1[0] == keys2[0]:\n if len(keys1) == 1 and len(keys2) == 1:\n print(vals1[0])\n elif len(keys1) == 1 and len(keys2) > 1:\n print(len(arr2)-vals2[1])\n elif len(keys1) > 1 and len(keys2) == 1:\n print(len(arr1)-vals1[1])\n else: #>1\n print(\n min(\n len(arr1)-vals1[1] + len(arr2)-vals2[0],\n len(arr1)-vals1[0] + len(arr2)-vals2[1]\n )\n )\n else:\n print(len(arr1)-vals1[0] + len(arr2)-vals2[0])\n \nproc(arr_odd, arr_even)'] | ['Runtime Error', 'Accepted'] | ['s740399902', 's013714926'] | [31372.0, 21160.0] | [308.0, 117.0] | [1444, 980] |
p03246 | u560889512 | 2,000 | 1,048,576 | 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. | ['n=int(input())\narr=map(int,input().split())\nfrom collections import Counter\neven=Counter(arr[::2])\neven[0]=0\nodd=Counter(arr[1::2])\nodd[0]=0\neven1,even2=even.most_common(2)\nodd1,odd2=odd.most_common(2)\nif even1[0]!=odd1[0]:\n print(n-(even1[1]+odd1[1]))\nelse:\n print(n-max(even1[1]+odd2[1],even2[1]+odd1[1]))', 'n=int(input())\narr=list(map(int,input().split()))\nfrom collections import Counter\neven=Counter(arr[::2])\neven[0]=0\nodd=Counter(arr[1::2])\nodd[0]=0\neven1,even2=even.most_common(2)\nodd1,odd2=odd.most_common(2)\nif even1[0]!=odd1[0]:\n print(n-(even1[1]+odd1[1]))\nelse:\n print(n-max(even1[1]+odd2[1],even2[1]+odd1[1]))\n'] | ['Runtime Error', 'Accepted'] | ['s249508352', 's387804371'] | [10620.0, 18528.0] | [31.0, 76.0] | [309, 316] |
p03246 | u561992253 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nl = list(map(int, input().split()))\n\nif n == 2:\n if l[0] == l[1]:\n print(1)\n else:\n print(0)\nelse:\n a = []\n b = []\n for i in range(n):\n if i % 2 == 0:\n a.append(l[i])\n else:\n b.append(l[i])\n\n da = {}\n for e in a:\n if e not in da:\n da[e] = (1,e)\n else:\n da[e] = (da[e][0]+1,da[e][1])\n\n db = {}\n for e in b:\n if e not in db:\n db[e] = (1,e)\n else:\n db[e] = (db[e][0]+1,db[e][1])\n\n la = list(reversed(sorted(list(da.values()))))\n lb = list(reversed(sorted(list(db.values()))))\n #print(la)\n #print(lb)\n\n la[-1] = (0,-1)\n lb[-1] = (0,-1)\n\n if la[0][1] == lb[0][1]:\n ans = n- (la[0][0] + max(la[1][0],lb[1][0]))\n else:\n ans = n - (la[0][0] + lb[0][0])\n print(ans)\n', 'n = int(input())\nl = list(map(int, input().split()))\n\na = []\nb = []\n\nfor i in range(n):\n if i % 2 == 0:\n a.append(l[i])\n else:\n b.append(l[i])\n\ndef createMyList(li):\n d = {-1:(0,-1)}\n for e in li:\n if e not in d:\n d[e] = (1,e)\n else:\n d[e] = (d[e][0] + 1, d[e][1])\n return list(reversed(sorted(list(d.values()))))\n\nla = createMyList(a)\nlb = createMyList(b)\n#print(la)\n#print(lb)\n\nif la[0][1] == lb[0][1]:\n ans = n- max(lb[0][0] + la[1][0], la[0][0] +lb[1][0])\nelse:\n ans = n - (la[0][0] + lb[0][0])\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s646554045', 's073555983'] | [23392.0, 20724.0] | [135.0, 119.0] | [864, 581] |
p03246 | u590211278 | 2,000 | 1,048,576 | 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. | ["import collections\nn = int(input())\nv=[]\nv=list(map(int,input().split(' ')))\n\nodv = []\nevv = []\n\nfor i in range(n):\n if i%2 == 1:\n odv.append(v[i])\n else:\n evv.append(v[i])\n\nodvc=collections.Counter(odv)\nevvc=collections.Counter(evv)\n\nodvs=len(odvc.most_common())\nevvs=len(evvc.most_common()) \n\nif evvc.most_common()[0][0] != odvc.most_common()[0][0]:\n print( odvs-odvc.most_common()[0][1] + evvs-evvc.most_common()[0][1] )\nelse:\n if odvs > 1 and evvs > 1:\n print( min(odvs-odvc.most_common()[0][1] + evvs-evvc.most_common()[1][1] ,\n odvs-odvc.most_common()[1][1] + evvs-evvc.most_common()[0][1] ) )\n else:\n if odvs > 1:\n print( odvs-odvc.most_common()[0][1] )\n elif evvs > 1:\n print( evvs-evvc.most_common()[0][1] )\n else:\n print(min(odvs,evvs))\n\n\n", "import collections\nn = int(input())\nv=[]\nv=list(map(int,input().split(' ')))\n\nodv = []\nevv = []\n\nfor i in range(n):\n if i%2 == 1:\n odv.append(v[i])\n else:\n evv.append(v[i])\n\nodvc=collections.Counter(odv)\nevvc=collections.Counter(evv)\n\nodvs=len(odv)\nevvs=len(evv)\n\nodv_kind=len(odvc.most_common())\nevv_kind=len(evvc.most_common()) \n\nif evvc.most_common()[0][0] != odvc.most_common()[0][0]:\n print( odvs-odvc.most_common()[0][1] + evvs-evvc.most_common()[0][1] )\nelse:\n if odv_kind > 1 and evv_kind > 1:\n print( min(odvs-odvc.most_common()[0][1] + evvs-evvc.most_common()[1][1] ,\n odvs-odvc.most_common()[1][1] + evvs-evvc.most_common()[0][1] ) )\n else:\n if odv_kind > 1:\n print( odvs-odvc.most_common()[0][1] )\n elif evv_kind > 1:\n print( evvs-evvc.most_common()[0][1] )\n else:\n print(min(odvs,evvs))\n\n\n"] | ['Wrong Answer', 'Accepted'] | ['s602785778', 's005203693'] | [20576.0, 20568.0] | [181.0, 156.0] | [857, 910] |
p03246 | u624475441 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\nc1 = Counter(A[::2])\nc2 = Counter(A[1::2])\nc1m = max(c1.items(), key=lambda x:x[1])\nc2m = max(c2.items(), key=lambda x:x[1])\nc1m[0] = 0\nc2m[0] = 0\nc1c2 = max(c for k,c in c2.items() if c1m[0]!=k)\nc2c1 = max(c for k,c in c1.items() if c2m[0]!=k)\nprint(min(N - c1m[1] - c1c2, N - c2m[1] - c2c1))', 'from collections import Counter\nn = int(input())\nV = list(map(int, input().split()))\nc1 = Counter(V[::2])\nc2 = Counter(V[1::2])\nc1[0] = 0\nc2[0] = 0\n(x, cx), (_, cxx) = c1.most_common(2)\n(y, cy), (_, cyy) = c2.most_common(2)\nif x == y:\n print(n - max(cx + cyy, cy + cxx))\nelse:\n print(n - cx + cy)', 'from collections import Counter\nn = int(input())\nV = list(map(int, input().split()))\nc1 = Counter(V[::2])\nc2 = Counter(V[1::2])\nc1[0] = 0\nc2[0] = 0\n(x, cx), (_, cxx) = c1.most_common(2)\n(y, cy), (_, cyy) = c2.most_common(2)\nif x == y:\n print(n - max(cx + cyy, cy + cxx))\nelse:\n print(n - cx - cy)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s149330120', 's244139605', 's852847158'] | [18648.0, 18656.0, 18656.0] | [74.0, 78.0, 76.0] | [378, 302, 302] |
p03246 | u631277801 | 2,000 | 1,048,576 | 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. | ['import sys\nstdin = sys.stdin\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom collections import Counter\n\nn = ni()\na = list(li())\n\neven = Counter(a[::2])\nodd = Counter(a[1::2])\n\nes = [(0,0)]\nfor ek,ev in even.items():\n es.append((ev,ek))\n \nes.sort(reverse=True)\n \n \nos = [(0,0)]\nfor ok,ov in odd.items():\n os.append((ov,ok))\n \nos.sort(reverse=True)\n \n\nif es[-1][1] != os[-1][1]:\n print((n//2-es[-1][0]) + (n//2-os[-1][0]))\nelse:\n print(max((n//2-es[-1][0]) + (n//2-os[-2][0]),\n (n//2-es[-2][0]) + (n//2-os[-1][0])))', 'import sys\nstdin = sys.stdin\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom collections import Counter\n\nn = ni()\na = list(li())\n\neven = Counter(a[::2])\nodd = Counter(a[1::2])\n\nes = even.most_common(2)\nos = odd.most_common(2)\n\nes = es + [(0,0)]\nos = os + [(0,0)]\n\nif es[0][0] != os[0][0]:\n print((n//2-es[0][1]) + (n//2-os[0][1]))\nelse:\n print(min((n//2-es[1][1]) + (n//2-os[0][1]),\n (n//2-es[0][1]) + (n//2-os[1][1])))'] | ['Wrong Answer', 'Accepted'] | ['s748771861', 's873171026'] | [20736.0, 18720.0] | [107.0, 82.0] | [880, 764] |
p03246 | u652737716 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nl = list(map(int, input().split()))\nl1 = [li for i, li in enumerate(l) if i % 2 == 0]\nl2 = [li for i, li in enumerate(l) if i % 2 == 1]\nprint(l1, l2)\ndef cnt(l):\n d = {}\n for li in l:\n if li in d:\n d[li] += 1\n else:\n d[li] = 1\n d = [(li, cnt) for li, cnt in d.items()]\n d = sorted(d, key=lambda di: di[0], reversed=True)\n return d\n\nk1 = cnt(l1)[:2]\nk2 = cnt(l2)[:2]\n\nans = 10000000\nif k1[0][0] != k2[0][0]:\n ans = n - k1[0][1] - k2[0][1]\nelse:\n if len(k1) == 2:\n ans = n - k1[1][1] - k2[0][1]\n if len(k2) == 2:\n ans = min(ans, n - k1[0][1] - k2[0][1])\n if ans == 10000000:\n ans = n - max(k1[0][1], k2[0][1])\nprint(ans)\n\n\n', 'n = int(input())\nl = list(map(int, input().split()))\nl1 = [li for i, li in enumerate(l) if i % 2 == 0]\nl2 = [li for i, li in enumerate(l) if i % 2 == 1]\ndef cnt(l):\n d = {}\n for li in l:\n if li in d:\n d[li] += 1\n else:\n d[li] = 1\n d = [(li, cnt) for li, cnt in d.items()]\n return sorted(d, key=lambda di: di[1], reverse=True)\n\nk1 = cnt(l1)[:2]\nk2 = cnt(l2)[:2]\nans = 10000000\nif k1[0][0] != k2[0][0]:\n ans = n - k1[0][1] - k2[0][1]\nif len(k1) == 2:\n ans = min(ans, n - k1[1][1] - k2[0][1])\nif len(k2) == 2:\n ans = min(ans, n - k1[0][1] - k2[1][1])\nif ans == 10000000:\n ans = n - max(k1[0][1], k2[0][1])\nprint(ans)\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s612164797', 's873253587'] | [16356.0, 17116.0] | [90.0, 115.0] | [722, 676] |
p03246 | u667084803 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\ncnt1 = Counter(v[::2]).most_common()\ncnt2 = Counter(v[1::2]).most_common()\ncnt1 += [(-1,0)]\ncnt2 += [(-1,0)]\nprint(cnt1, cnt2)\nif cnt1[0][0] != cnt2[0][0]:\n print(n - (cnt1[0][1] + cnt2[0][1]))\nelse:\n print(n - max(cnt1[1][1] + cnt2[0][1], cnt1[1][1] + cnt2[0][1]))', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\ncnt1 = Counter(v[::2]).most_common()\ncnt2 = Counter(v[1::2]).most_common()\ncnt1 += [(-1,0)]\ncnt2 += [(-1,0)]\nif cnt1[0][0] != cnt2[0][0]:\n print(n - (cnt1[0][1] + cnt2[0][1]))\nelse:\n print(n - max(cnt1[1][1] + cnt2[0][1], cnt1[0][1] + cnt2[1][1]))'] | ['Wrong Answer', 'Accepted'] | ['s961192212', 's186147194'] | [21852.0, 20572.0] | [119.0, 84.0] | [358, 340] |
p03246 | u692453235 | 2,000 | 1,048,576 | 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. | ['from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\ndef f(x, y):\n return n - ( x + y )\n\nv0 = Counter(v[::2])\nv1 = Counter(v[1::2])\nL = v0.most_common(2)\nR = v1.most_common(2)\n\nprint(L, R)\n\nif L[0][0] != R[0][0]:\n print(f(L[0][1], R[0][1]))\nelif len(L) > len(R):\n print(f(L[1][1], R[0][1]))\nelif len(L) < len(R):\n print(f(L[0][1], R[1][1]))\nelif len(L) == 2:\n print(min(f(L[1][1], R[0][1]), f(L[0][1], R[1][1])))\nelse:\n print(n//2)\n', '\nfrom collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\ndef f(x, y):\n return n - ( x + y )\n\nv0 = Counter(v[::2])\nv1 = Counter(v[1::2])\nL = v0.most_common(2)\nR = v1.most_common(2)\n\n#print(L, R)\n\nif L[0][0] != R[0][0]:\n print(f(L[0][1], R[0][1]))\nelif len(L) > len(R):\n print(f(L[1][1], R[0][1]))\nelif len(L) < len(R):\n print(f(L[0][1], R[1][1]))\nelif len(L) == 2:\n print(min(f(L[1][1], R[0][1]), f(L[0][1], R[1][1])))\nelse:\n print(n//2)'] | ['Wrong Answer', 'Accepted'] | ['s718856822', 's982411007'] | [18656.0, 18656.0] | [81.0, 82.0] | [472, 473] |
p03246 | u698919163 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nv = list(map(int,input().split()))\n\nv1 = []\nv2 = []\n\n\n\nif max(v) == min(v):\n print(int(n/2))\nelif v[0] == v[1]:\n j=0\n for i in range(int(n/2)):\n v1.append(v[j])\n j+=2\n j=0\n for i in range(int(n/2)):\n v2.append(v[j+1])\n j+=2\n\n import collections\n\n v1n = collections.Counter(v1)\n values, counts1 = zip(*v1n.most_common())\n\n v2n = collections.Counter(v2)\n values, counts2 = zip(*v2n.most_common())\n\n print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)) + 1)\nelse:\n j=0\n for i in range(int(n/2)):\n v1.append(v[j])\n j+=2\n \n j=0\n\n for i in range(int(n/2)):\n v2.append(v[j+1])\n j+=2\n\n import collections\n\n v1n = collections.Counter(v1)\n values, counts1 = zip(*v1n.most_common())\n\n v2n = collections.Counter(v2)\n values, counts2 = zip(*v2n.most_common())\n\n print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)) + 1)', 'n = int(input())\nv = list(map(int,input().split()))\n\nv1 = []\nv2 = []\n\nif max(v) == min(v):\n print(int(n/2))\nelse:\n j=0\n for i in range(int(n/2)):\n v1.append(v[j])\n j+=2\n \n j=0\n\n for i in range(int(n/2)):\n v2.append(v[j+1])\n j+=2\n\n import collections\n\n v1n = collections.Counter(v1)\n values1, counts1 = zip(*v1n.most_common())\n\n v2n = collections.Counter(v2)\n values2, counts2 = zip(*v2n.most_common())\n \n if max(counts1) != 1 and max(counts2) != 1:\n print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))\n else:\n print( int(n/2) + min((len(v1)-max(counts1)),(len(v2)-max(counts2))) )', 'n = int(input())\nv = list(map(int,input().split()))\n\nv1 = []\nv2 = []\n\n\n\nif max(v) == min(v):\n print(int(n/2))\nelse:\n j=0\n for i in range(int(n/2)):\n v1.append(v[j])\n j+=2\n \n j=0\n\n for i in range(int(n/2)):\n v2.append(v[j+1])\n j+=2\n\n import collections\n\n v1n = collections.Counter(v1)\n values1, counts1 = zip(*v1n.most_common())\n\n v2n = collections.Counter(v2)\n values2, counts2 = zip(*v2n.most_common())\n \n if values1 != values2 and max(counts1) != 1 and max(counts2) != 1:\n print( (len(v1)-max(counts1)) + (len(v2)-max(counts2)))\n else:\n print( int(n/2) + min((len(v1)-max(counts1)),(len(v2)-max(counts2))) )', 'n = int(input())\nv = list(map(int,input().split()))\n\ncount = 0\n\nif max(v) == min(v):\n print(int(n/2))\nelse:\n for i in range(int(n/2)):\n if v[0] != v[j+2]:\n count += 1\n if v[1] != v[j+3]:\n count =+ 1\n j = j+2\n print(count) ', 'n = int(input())\nv = list(map(int,input().split()))\n\nv1 = []\nv2 = []\n\nj=0\nfor i in range(int(n/2)):\n v1.append(v[j])\n j+=2\n \nj=0\nfor i in range(int(n/2)):\n v2.append(v[j+1])\n j+=2\n\nimport collections\n\nv1n = collections.Counter(v1)\nv2n = collections.Counter(v2)\n\nif v1n.most_common()[0][0] != v2n.most_common()[0][0]:\n print(n - v1n.most_common()[0][1] - v2n.most_common()[0][1])\nelse:\n if len(v1n) == 1 and len(v2n) == 1:\n print(int(n/2))\n else:\n xxx=(len(v1)-v1n.most_common()[0][1])+(len(v2)-v2n.most_common()[1][1])\n yyy=(len(v1)-v1n.most_common()[1][1])+(len(v2)-v2n.most_common()[0][1])\n print(min(xxx,yyy))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s271356503', 's341090018', 's505810401', 's532356402', 's303739258'] | [24112.0, 24112.0, 24240.0, 14396.0, 19040.0] | [146.0, 143.0, 179.0, 46.0, 175.0] | [949, 668, 693, 277, 664] |
p03246 | u729133443 | 2,000 | 1,048,576 | 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. | ['from collections import*\nn,*v=map(int,open(0).read().split())\na=Counter(v[::2]).most_common()+[(0,0)]\nb=Counter(v[1::2]).most_common()+[(0,0)]\nprint(a,b)\nif a[0][0]==b[0][0]:\n print(min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1]))\nelse:\n print(n-a[0][1]-b[0][1])', 'from collections import*\nn,*v=map(int,open(0).read().split())\na=Counter(v[::2]).most_common()+[(0,0)]\nb=Counter(v[1::2]).most_common()+[(0,0)]\nif a[0][0]==b[0][0]:\n print(min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1]))\nelse:\n print(n-a[0][1]-b[0][1])'] | ['Wrong Answer', 'Accepted'] | ['s273126297', 's895539687'] | [20572.0, 20524.0] | [118.0, 87.0] | [261, 250] |
p03246 | u745561510 | 2,000 | 1,048,576 | 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. | ['n = int(input())\nv = list(map(int, input().split()))\n\nodd = {}\neven = {}\n\nfor i in range(len(v)):\n if i % 2 == 1:\n if v[i] in odd:\n odd[v[i]] += 1\n else:\n odd[v[i]] = 1\n else:\n if v[i] in even:\n even[v[i]] += 1\n else:\n even[v[i]] = 1\n\n\nodd_sorted = sorted(odd.items(), key = lambda x : -x[1])\neven_sorted = sorted(even.items(), key = lambda x : -x[1])\n\n\ncandidate_odd = []\ncandidate_even = []\n\ncandidate_odd.append\n\n\n\ndef count_rewrite(odd, even):\n ans = 0\n for i in range(len(v)):\n if i % 2:\n if v[i] != ans_odd:\n ans += 1\n else:\n if v[i] != ans_even:\n ans += 1\n return ans\n\n\nans = 1000002\n\nif odd_sorted[0][0] == even_sorted[0][0]:\n \n if len(odd.keys()) > 1 and len(even.keys()) > 1:\n ans = min(ans, count_rewrute(odd_sorted[0][0], even_sorted[1][0]))\n ans = min(ans, count_rewrute(odd_sorted[1][0], even_sorted[0][0]))\n \n elif len(odd.keys()) == 1 and len(even.keys()) == 1:\n ans = min(ans, count_rewrute(-1, even_sorted[0][0]))\n \n elif len(odd.keys()):\n ans = min(ans, count_rewrute(odd_sorted[0][0], even_sorted[1][0]))\n \n else: \n ans = min(ans, count_rewrute(odd_sorted[1][0], even_sorted[0][0]))\n\nelse:\n ans = min(ans, count_rewrute(odd_sorted[0][0], even_sorted[0][0]))\n\n\nprint(ans)', 'n = int(input())\nv = list(map(int, input().split()))\n\nodd = {}\neven = {}\n\nfor i in range(len(v)):\n if i % 2 == 1:\n if v[i] in odd:\n odd[v[i]] += 1\n else:\n odd[v[i]] = 1\n else:\n if v[i] in even:\n even[v[i]] += 1\n else:\n even[v[i]] = 1\n\n\nodd_sorted = sorted(odd.items(), key = lambda x : -x[1])\neven_sorted = sorted(even.items(), key = lambda x : -x[1])\n\n\ndef count_rewrite(odd, even):\n ans = 0\n for i in range(len(v)):\n if i % 2:\n if v[i] != odd:\n ans += 1\n else:\n if v[i] != even:\n ans += 1\n return ans\n\n\nans = 1000002\n\nif odd_sorted[0][0] == even_sorted[0][0]:\n \n if len(odd.keys()) > 1 and len(even.keys()) > 1:\n ans = min(ans, count_rewrite(odd_sorted[0][0], even_sorted[1][0]))\n ans = min(ans, count_rewrite(odd_sorted[1][0], even_sorted[0][0]))\n \n elif len(odd.keys()) == 1 and len(even.keys()) == 1:\n ans = min(ans, count_rewrite(-1, even_sorted[0][0]))\n \n elif len(odd.keys()):\n ans = min(ans, count_rewrite(odd_sorted[0][0], even_sorted[1][0]))\n \n else: \n ans = min(ans, count_rewrite(odd_sorted[1][0], even_sorted[0][0]))\n\nelse:\n ans = min(ans, count_rewrite(odd_sorted[0][0], even_sorted[0][0]))\n\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s950595333', 's193287304'] | [21940.0, 20764.0] | [107.0, 136.0] | [1700, 1628] |
p03246 | u786153999 | 2,000 | 1,048,576 | 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. | ['import collections\nN = int(input())\na = input().split( )\n\nret = [0]\n\nodds = []\nevens = []\nfor i in range(N):\n if i % 2 == 0:\n odds.append(int(a[i]))\n else:\n evens.append(int(a[i]))\n\ncodds = collections.Counter(odds)\ncevens = collections.Counter(evens)\n\nif codds.most_common()[0][0] ==cevens.most_common()[0][0]:\n if codds.most_common()[0][1] > cevens.most_common()[0][1]:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds.pop(-1)\n else:\n codds = [0]\n if len(cevens) > 1:\n cevens = sorted(cevens)\n cevens.pop(-2)\n else:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds.pop(-2)\n if len(cevens) > 1:\n cevens = sorted(cevens)\n cevens.pop(-1)\n else:\n cevens = [0]\nelse:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds.pop(-1)\n if len(cevens) > 1:\n cevens = sorted(cevens)\n cevens.pop(-1)\n\nprint(sum(codds) + sum(cevens))', 'import collections\nN = int(input())\na = input().split( )\n\nret = [0]\n\nodds = []\nevens = []\nfor i in range(N):\n if i % 2 == 0:\n evens.append(int(a[i]))\n else:\n odds.append(int(a[i]))\n\ncodds = collections.Counter(odds)\ncevens = collections.Counter(evens)\n\nif codds.most_common()[0][0] ==cevens.most_common()[0][0]:\n if codds.most_common()[0][1] > cevens.most_common()[0][1]:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds=codds[1:]\n else:\n codds = [0]\n if len(cevens) > 1:\n cevens = sorted(cevens)\n evens = evens.pop(1)\n else:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds.pop(1)\n if len(cevens) > 1:\n cevens = sorted(cevens)\n cevens = cevens[1:]\n else:\n cevens = [0]\nelse:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds=codds[1:]\n if len(cevens) > 1:\n cevens = sorted(cevens)\n cevens = cevens[1:]\n\nprint(sum(codds) + sum(cevens))', 'import collections\nN = int(input())\na = input().split( )\n\nret = [0]\n\nodds = []\nevens = []\nfor i in range(N):\n if i % 2 == 0:\n odds.append(int(a[i]))\n else:\n evens.append(int(a[i]))\n\ncodds = collections.Counter(odds)\ncevens = collections.Counter(evens)\nprint(codds)\nprint(cevens)\n\nif codds.most_common()[0][0] ==cevens.most_common()[0][0]:\n if codds.most_common()[0][1] > cevens.most_common()[0][1]:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds.pop(-1)\n else:\n codds = [0]\n print(1)\n if len(cevens) > 1:\n print(3)\n cevens = sorted(cevens)\n cevens.pop(-2)\n else:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds.pop(-2)\n if len(cevens) > 1:\n cevens = sorted(cevens)\n cevens.pop(-1)\n else:\n cevens = [0]\nelse:\n codds = list(codds.values())\n cevens = list(cevens.values())\n if len(codds) > 1:\n codds=sorted(codds)\n codds.pop(-1)\n if len(cevens) > 1:\n cevens = sorted(cevens)\n cevens.pop(-1)\n\nprint(sum(codds) + sum(cevens))', 'import collections\nN = int(input())\na = input().split( )\n\nret = [0]\n\nodds = []\nevens = []\nfor i in range(N):\n if i % 2 == 0:\n odds.append(int(a[i]))\n else:\n evens.append(int(a[i]))\n\ncodds = collections.Counter(odds)\ncevens = collections.Counter(evens)\n\nif codds.most_common()[0][0] ==cevens.most_common()[0][0]:\n if codds.most_common()[0][1] > cevens.most_common()[0][1]:\n codds = sorted(list(codds.values()))\n cevens = sorted(list(cevens.values()))\n if len(codds) > 1:\n codds.pop(-1)\n else:\n codds = [0]\n if len(cevens) > 1:\n cevens.pop(-2)\n elif codds.most_common()[0][1] < cevens.most_common()[0][1]:\n codds = sorted(list(codds.values()))\n cevens = sorted(list(cevens.values()))\n if len(codds) > 1:\n codds.pop(-2)\n if len(cevens) > 1:\n cevens.pop(-1)\n else:\n cevens = [0]\n else:\n if len(codds) == 1 and len(cevens) == 1:\n codds = [0]\n cevens = sorted(list(cevens.values()))\n elif codds.most_common()[1][1] > cevens.most_common()[1][1]:\n codds = sorted(list(codds.values()))\n cevens = sorted(list(cevens.values()))\n codds.pop(-2)\n cevens.pop(-1)\n else:\n codds = sorted(list(codds.values()))\n cevens = sorted(list(cevens.values()))\n codds.pop(-1)\n cevens.pop(-2)\n\nelse:\n codds = sorted(list(codds.values()))\n cevens = sorted(list(cevens.values()))\n if len(codds) > 1:\n codds.pop(-1)\n else:\n codds= [0]\n if len(cevens) > 1:\n cevens.pop(-1)\n else:\n cevens = [0]\n\nprint(sum(codds) + sum(cevens))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s188112882', 's672919100', 's758749841', 's596038626'] | [26092.0, 26032.0, 29548.0, 25904.0] | [145.0, 135.0, 184.0, 173.0] | [1244, 1263, 1309, 1735] |
p03246 | u810735437 | 2,000 | 1,048,576 | 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. | ['\n# arr1, arr2\n\nfrom collections import *\nN = int(input())\nAs = list(map(int, input().split()))\n\ndef solve(arr1, arr2):\n cnt1 = Counter(arr1)\n cnt2 = Counter(arr2)\n\n \n \n most1 = cnt1.most_common(1)\n most2 = cnt2.most_common(1)\n\n if len(most1) > 1 or len(most2) > 1:\n return len(arr1) - most1[0][1] + len(arr2) - most2[0][1]\n elif most1[0][0] != most2[0][0]:\n return 0\n else:\n try:\n ans1 = len(arr1) - most1[0][1] \\\n + len(arr2) - cnt2.most_common(2)[1][1]\n except:\n ans1 = len(arr1) - most1[0][1] \\\n + len(arr2)\n try:\n ans2 = len(arr2) - most2[0][1] \\\n + len(arr1) - cnt1.most_common(2)[1][1]\n except:\n ans2 = len(arr2) - most2[0][1] \\\n + len(arr1)\n return min(ans1, ans2)\n\n\narr1 = As[0::2]\narr2 = As[1::2]\nprint(solve(arr1, arr2))\n', "from collections import *\nN = int(input())\nAs = list(map(int, input().split()))\n\ndef solve(arr1, arr2):\n cnt1 = Counter(arr1)\n cnt2 = Counter(arr2)\n\n most1 = cnt1.most_common()\n most2 = cnt2.most_common()\n\n \n most1.append(('_', 0))\n most2.append(('_', 0))\n\n \n if most1[0][0] != most2[0][0]:\n return len(arr1) * 2 - most1[0][1] - most2[0][1]\n \n else:\n ans1 = len(arr1) * 2 - most1[0][1] - most2[1][1]\n ans2 = len(arr1) * 2 - most1[1][1] - most2[0][1]\n return min(ans1, ans2)\n\narr1 = As[0::2]\narr2 = As[1::2]\nprint(solve(arr1, arr2))\n"] | ['Wrong Answer', 'Accepted'] | ['s963236907', 's010853839'] | [19040.0, 21944.0] | [86.0, 98.0] | [1063, 842] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.