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
|
u073852194
| 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_odd = []\nV_even = []\nfor i in range(n):\n if i % 2 == 0:\n V_odd += [V[i]]\n else:\n V_even += [V[i]]\nV_odd = list(Counter(V_odd).most_common()) + [(-1,0)]\nV_even = list(Counter(V_even).most_common()) + [(-2,0)]\nprint(V_odd,V_even)\nif V_odd[0][0] != V_even[0][0]:\n print(len(V)-V_odd[0][1]-V_even[0][1],'a')\nelif V_odd[1][1] >= V_even[1][1]:\n print(len(V)-V_odd[1][1]-V_even[0][1],'b')\nelse:\n print(len(V)-V_odd[0][1]-V_even[1][1],'c')", 'from collections import Counter\nn = int(input())\nV = list(map(int,input().split()))\nV_odd = []\nV_even = []\nfor i in range(n):\n if i % 2 == 0:\n V_odd += [V[i]]\n else:\n V_even += [V[i]]\nV_odd = list(Counter(V_odd).most_common()) + [(-1,0)]\nV_even = list(Counter(V_even).most_common()) + [(-2,0)]\nif V_odd[0][0] != V_even[0][0]:\n print(len(V)-V_odd[0][1]-V_even[0][1])\nelif V_odd[1][1] >= V_even[1][1]:\n print(len(V)-V_odd[1][1]-V_even[0][1])\nelse:\n print(len(V)-V_odd[0][1]-V_even[1][1])']
|
['Wrong Answer', 'Accepted']
|
['s449943733', 's642027125']
|
[22236.0, 21084.0]
|
[161.0, 120.0]
|
[546, 514]
|
p03244
|
u076917070
| 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\ninput=sys.stdin.readline\n\ninput = open(sys.argv[1], "r").readline\n\ndef main():\n N = int(input())\n V1 = {}\n V2 = {}\n V = list(map(int, input().split()))\n for i,v in enumerate(V):\n if i%2 == 0:\n V1[v] = V1[v] + 1 if v in V1 else 1\n else:\n V2[v] = V2[v] + 1 if v in V2 else 1\n\n V1 = sorted(V1.items(), key=lambda x:x[1], reverse=True)\n V2 = sorted(V2.items(), key=lambda x:x[1], reverse=True)\n\n if V1[0] != V2[0]:\n ans = 0\n for v in V1[1:]:\n ans += v[1]\n for v in V2[1:]:\n ans += v[1]\n print(ans)\n else:\n a1 = 0\n for v in V1[1:]:\n a1 += v[1]\n a1 += V2[0][1]\n for v in V2[2:]:\n a1 += v[1]\n a2 = 0\n a2 += V1[0][1]\n for v in V1[2:]:\n a2 += v[1]\n for v in V2[1:]:\n a1 += v[1]\n print(min(a1,a2))\n\nif __name__ == \'__main__\':\n main()\n', "import sys\ninput=sys.stdin.readline\n\ndef main():\n N = int(input())\n V1 = {}\n V2 = {}\n V = list(map(int, input().split()))\n for i,v in enumerate(V):\n if i%2 == 0:\n V1[v] = V1[v] + 1 if v in V1 else 1\n else:\n V2[v] = V2[v] + 1 if v in V2 else 1\n\n V1 = sorted(V1.items(), key=lambda x:x[1], reverse=True)\n V2 = sorted(V2.items(), key=lambda x:x[1], reverse=True)\n\n if V1[0] != V2[0]:\n ans = 0\n for v in V1[1:]:\n ans += v[1]\n for v in V2[1:]:\n ans += v[1]\n print(ans)\n else:\n a1 = 0\n for v in V1[1:]:\n a1 += v[1]\n a1 += V2[0][1]\n for v in V2[2:]:\n a1 += v[1]\n a2 = 0\n a2 += V1[0][1]\n for v in V1[2:]:\n a2 += v[1]\n for v in V2[1:]:\n a2 += v[1]\n print(min(a1,a2))\n\nif __name__ == '__main__':\n main()\n"]
|
['Runtime Error', 'Accepted']
|
['s563839286', 's256964505']
|
[3064.0, 17752.0]
|
[18.0, 106.0]
|
[958, 917]
|
p03244
|
u085717502
| 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# coding: utf-8\n\n# In[129]:\n\n\nfrom collections import Counter\n\n\n# In[130]:\n\n\nn = int(input())\nv = list(map(int, input().split()))\n\n\n# In[134]:\n\n\nv_even = Counter(v[::2]).most_common()\nv_odd = Counter(v[1::2]).most_common()\n\n\n# In[136]:\n\n\nif len(v_even) == 1:\n v_even.append([0,0])\nif len(v_odd) == 1:\n v_odd.append([0,0])\n\n\n# In[ ]:\n\n\nif v_even[0][0] == v_odd[0][0]:\n if v_even[1][1] > v_odd[1][1]:\n ret\n\n', '\n# coding: utf-8\n\n# In[129]:\n\n\nfrom collections import Counter\n\n\n# In[141]:\n\n\nn = int(input())\nv = list(map(int, input().split()))\n\n\n# In[142]:\n\n\nv_even = Counter(v[::2]).most_common()\nv_odd = Counter(v[1::2]).most_common()\n\n\n# In[146]:\n\n\nif len(v_even) == 1:\n v_even.append([0,0])\nif len(v_odd) == 1:\n v_odd.append([0,0])\nif v_even[0][0] == v_odd[0][0]:\n if v_even[1][1] > v_odd[1][1]:\n ret = n - v_even[1][1] - v_odd[0][1]\n else:\n ret = n - v_even[0][1] - v_odd[1][1]\nelse:\n ret = n - v_even[0][1] - v_odd[0][1]\n\n\n# In[147]:\n\n\nprint(ret)\n\n']
|
['Runtime Error', 'Accepted']
|
['s835433334', 's014518113']
|
[20572.0, 20692.0]
|
[87.0, 85.0]
|
[422, 570]
|
p03244
|
u087917227
| 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())\nvn = list(map(int,input().split()))\nvn_odd = [vn[i] for i in range(n) if i%2==1]\nvn_even = [vn[i] for i in range(n) if i%2==0]\nodd_freq = Counter(vn_odd).most_common(2)\neven_freq = Counter(vn_even).most_common(2)\n\nans = 0\n\nif odd_freq[0][0] != even_freq[0][0]:\n ans += n - odd_freq[0][1] - even_freq[0][1]\nelse:\n ans += n - max(odd_freq[0][1]+even_freq[1][1], odd_freq[1][1]+even_freq[0][1])\n \nprint(ans)\n', 'import collections\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 \ninput()\nvals = list(map(int, input().split()))\ns1, a = conv_seq(vals[::2])\ns2, b = conv_seq(vals[1::2])\nif a != b:\n print(s1 + s2)\nelse:\n s1_new, _ = conv_seq(vals[::2], exclude=b)\n s2_new, _ = conv_seq(vals[1::2], exclude=a)\n print(min(s1_new + s2, s1 + s2_new))']
|
['Runtime Error', 'Accepted']
|
['s194834565', 's050645053']
|
[14404.0, 17116.0]
|
[62.0, 124.0]
|
[476, 546]
|
p03244
|
u090436701
| 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())\n\na = [int(l) for l in input().split()]\n\nac = collections.Counter(a[::2]).most_common()\nbc = collections.Counter(a[1::2]).most_common()\n\n\nmin_trans = n//2\nfor x in ac:\n for y in bc:\n if x[0] == y[0]:\n continue\n else:\n print(x, y)\n min_trans = min(n-x[1]-y[1], min_trans)\n\nprint(min_trans)\n \n\n\n\n\n\n', 'import collections\n\nn = int(input())\n\nal = [int(l) for l in input().split()]\n\na = []\nb = []\nfor i, x in enumerate(al):\n if i%2 == 0:\n a.append(x)\n else:\n b.append(x)\n\nac = collections.Counter(a).most_common()\nbc = collections.Counter(b).most_common()\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-max(ac[0][1], bc[0][1]))\n elif len(ac) == 1:\n print(n-max(ac[0][1], ac[1][1]+bc[0][1]))\n elif len(ac) == 1:\n print(n-max(bc[0][1], ac[0][1]+bc[1][1]))\n else:\n print(n-max(ac[1][1]+bc[0][1], ac[0][1]+bc[1][1]))\n \n']
|
['Wrong Answer', 'Accepted']
|
['s952405422', 's934494363']
|
[37596.0, 21084.0]
|
[2105.0, 112.0]
|
[385, 633]
|
p03244
|
u094565093
| 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()))\neven=v[0::2]\nodd=v[1::2]\nimport collections\nc=collections.Counter(even)\nd=collections.Counter(odd)\ne=c.most_common()[0][0]\no=d.most_common()[0][0]\ne2=c.most_common()[0][1]\no2=d.most_common()[0][1]\nif e==o:\n \tif even.count(e)==odd.count(o)==len(even):\n print(n/2)\n elif even.count(e)>odd.count(o):\n o=o2\n else:\n e=e2\ncount=len(v)-(even.count(e)+odd.count(o))\nprint(count)\n \n', 'n=int(input())\nN=list(map(int,input().split()))\neven=[]\nodd=[]\nfor i in range(len(N)):\n if i%2==0:\n even.append(N[i])\n if i%2==1:\n odd.append(N[i])\nimport collections\nc = collections.Counter(even)\nx=c.most_common()[0][0]\no=even.count(x)\nd= collections.Counter(odd)\ny=d.most_common()[0][0]\np=odd.count(y)\ns=len(even)-even.count(x)\nt=len(odd)-odd.count(y)\nif x!=y and o==len(even) and p==len(odd):\n print(0)\nelif x==y and o==len(even) and p==len(odd):\n print(n/2)\nelif x==y and (o!=len(even) or p!=len(odd)):\n if o>p:\n y=d.most_common()[1][0]\n s=len(even)-even.count(x)\n t=len(odd)-odd.count(y)\n print(s+t)\n else:\n x=c.most_common()[1][0]\n s=len(even)-even.count(x)\n t=len(odd)-odd.count(y)\n print(s+t)\nelif:\n print(s+t)\n \n \n', 'n = int(input())\nA = [int(x) for x in input().split()]\n\nfrom collections import Counter\nimport operator\ndef f():\n a = Counter(A[::2]).most_common(2)\n b = Counter(A[1::2]).most_common(2)\n ac, bc = a[0][1], b[0][1]\n ret = n - (ac + bc)\n if a[0][0] == b[0][0]:\n bc_2 = b[1][1] if len(b) != 1 else 0\n ac_2 = a[1][1] if len(a) != 1 else 0\n ret = n - max(ac + bc_2, ac_2 + bc)\n return ret\nprint(f())']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s538623603', 's661483886', 's396851274']
|
[3064.0, 3064.0, 15460.0]
|
[17.0, 18.0, 79.0]
|
[452, 824, 432]
|
p03244
|
u094815239
| 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().strip())\na = list(map(int, input().strip().split()))\n \nc1 = Counter(a[::2])\nc2 = Counter(a[1::2])\nc1f1 = max(c1, key = lambda k:c1[k])\nc2f1 = max(c2, key = lambda k:c2[k])\n \nif c1f1 != c2f1:\n return n - c1[c1f1] - c2[c2f1]\nelse:\n if c1[c1f1] > c2[c2f1]:\n del c2[c2f1]\n if not c2: return n-c1[c1f1]\n c2f1 = max(c2, key = lambda k:c2[k])\n return n-c1[c1f1] - c2[c2f1]\n else:\n del c1[c1f1]\n if not c1: return n-c2[c2f1]\n c1f1 = max(c1, key = lambda k:c1[k])\n return n-c1[c1f1] - c2[c2f1]', "from collections import Counter\nn = int(input().strip())\na = list(map(int, input().strip().split()))\ncnt1 = Counter(a[::2]).most_common(2)\nc11, c12 = (cnt1 if len(cnt1) == 2 else cnt1+[('', 0)])\ncnt2 = Counter(a[1::2]).most_common(2)\nc21, c22 = (cnt2 if len(cnt2) == 2 else cnt2+[('', 0)])\n\nif c11[0] != c21[0]:\n print(n - c11[1] - c21[1])\nelse:\n print(n - max(c11[1]+c22[1], c12[1]+c21[1]))"]
|
['Runtime Error', 'Accepted']
|
['s165420180', 's232421517']
|
[3064.0, 15588.0]
|
[17.0, 74.0]
|
[559, 397]
|
p03244
|
u102960641
| 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()))\neven1 = v[0::2]\nodd1 = v[1::2]\neven2 = Counter(v1)\nodd2 = Counter(v2)\na = even2.most_common()[0][0]\nb = odd2.most_common()[0][0]\nc = even2.most_common()[0][1]\nd = odd2.most_common()[0][1]\nif a != b:\n print(len(even1)-c+len(odd1)-d)\nelse:\n if len(list(set(even1))) == 1 and len(list(set(odd1))) == 1:\n print(len(even1))\n\n else:\n if c <= d:\n print(len(even1)*2-d-even2.most_common()[1][1])\n else:\n print(len(even1)*2-c-odd2.most_common()[1][1])\n', 'from collections import Counter\n\nn = int(input())\nv = list(map(int,input().split()))\neven1 = v[0::2]\nodd1 = v[1::2]\neven2 = Counter(even1)\nodd2 = Counter(odd1)\na = even2.most_common()[0][0]\nb = odd2.most_common()[0][0]\nc = even2.most_common()[0][1]\nd = odd2.most_common()[0][1]\nif a != b:\n print(len(even1)-c+len(odd1)-d)\nelse:\n if len(list(set(even1))) == 1 and len(list(set(odd1))) == 1:\n print(len(even1))\n elif len(list(set(even1))) == 1:\n print(len(odd1)-odd2.most_common()[1][1])\n elif len(list(set(odd1))) == 1:\n print(len(even1)-even2.most_common()[1][1])\n else:\n e = even2.most_common()[1][1]\n f = odd2.most_common()[1][1]\n if c-e >= d-f:\n print(len(even1)*2-c-f)\n else:\n print(len(even1)*2-d-e)']
|
['Runtime Error', 'Accepted']
|
['s814667220', 's833841913']
|
[14892.0, 19968.0]
|
[45.0, 132.0]
|
[535, 715]
|
p03244
|
u109632368
| 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 calculate_mode(data):\n c = Counter(data)\n \n freq_scores = c.most_common()\n \n max_count = freq_scores[0][1]\n\n modes = []\n \n for num in freq_scores:\n if num[1] == max_count:\n modes.append(num[0])\n return(modes)\n\n\n\nn = int(input())\nv = list(map(int, input().split()))\na = v[0::2]\nb = v[1::2]\nc = v[0::2]\nd = v[1::2]\nans = 0\n\nf = max(calculate_mode(a))\ng = max(calculate_mode(b))\nprint(f,g)\nif f == g :\n for i in range(len(a)):\n if f == a[i]:\n a.remove(f)\n if g == b[i]:\n b.remove(g)\n f = calculate_mode(a)\n g = calculate_mode(b)\n\n\nfor i in range(len(a)):\n if f != c[i]:\n ans += 1\n if g != d[i]:\n ans += 1\n\nprint(ans)', '\nfrom collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\ne = v[1::2] \no = v[0::2] \nans = 0\n\na = Counter(e) \nb = Counter(o)\n\nc = a.most_common(2) \nd = b.most_common(2)\n\nif c[0][0] != d[0][0]: \n ans = n -c[0][1] -d[0][1]\nelse: \n if len(c) == 1:\n if len(d) == 1:\n ans = n//2\n else:\n ans = n -d[0][1]\n elif len(d) == 1 and len(c) != 1:\n ans = n -c[0][1]\n elif c[0][1] > d[0][1]:\n ans = n -c[0][1] -d[1][1]\n else:\n if c[0][1]==d[0][1]:\n ans = min(n-c[0][1]-d[1][1],n-c[1][1]-d[0][1])\n else:\n ans = n -c[1][1] -d[0][1]\n \nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s544972715', 's299037386']
|
[18268.0, 19040.0]
|
[2104.0, 84.0]
|
[978, 1041]
|
p03244
|
u114641312
| 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 math import factorial,sqrt,ceil #,gcd\n# from itertools import permutations,combinations,combinations_with_replacement\nfrom collections import deque,Counter\n# from bisect import bisect_left\n# from heapq import heappush,heappop\n# from numba import njit\n\n# from fractions import gcd\n\n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\n# import numpy as np # numpy.lcm()\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n\n# import networkx as nx\n# G = Graph()\n\n\nN = int(input())\nlisA = list(map(int,input().split()))\n\nkv1 = Counter(lisA[0:N:2]).most_common()\nkv2 = Counter(lisA[1:N:2]).most_common()\n\nif len(kv1)==len(kv2)==1 and kv1[0]==kv2[0]:\n print(N//2)\n exit()\n\nprint(kv1,kv2)\nans1 = N\nans2 = N\nfor i in range(0,N//2-1):\n try:\n if kv1[0][0]!=kv2[i][0]:\n ans1 = min(ans1,N-(kv1[0][1]+kv2[i][1]))\n if kv1[i][0]!=kv2[0][0]:\n ans2 = min(ans1,N-(kv1[i][1]+kv2[0][1]))\n except:\n pass\n\nprint(min(ans1,ans2))\n# for row in board:\n\n# print("{:.10f}".format(ans))\n# print("{:0=10d}".format(ans))\n', '# from math import factorial,sqrt,ceil #,gcd\n# from itertools import permutations,combinations,combinations_with_replacement\nfrom collections import deque,Counter\n# from bisect import bisect_left\n# from heapq import heappush,heappop\n# from numba import njit\n\n# from fractions import gcd\n\n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\n# import numpy as np # numpy.lcm()\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n\n# import networkx as nx\n# G = Graph()\n\n\nN = int(input())\nlisA = list(map(int,input().split()))\n\nkv1 = Counter(lisA[0:N:2]).most_common()\nkv2 = Counter(lisA[1:N:2]).most_common()\n\nif len(kv1)==len(kv2)==1 and kv1[0]==kv2[0]:\n print(N//2)\n exit()\n\nans1 = N\nans2 = N\nfor i in range(0,N//2-1):\n try:\n if kv1[0][0]!=kv2[i][0]:\n ans1 = min(ans1,N-(kv1[0][1]+kv2[i][1]))\n if kv1[i][0]!=kv2[0][0]:\n ans2 = min(ans2,N-(kv1[i][1]+kv2[0][1]))\n except:\n pass\n\nprint(min(ans1,ans2))\n# for row in board:\n\n# print("{:.10f}".format(ans))\n# print("{:0=10d}".format(ans))\n']
|
['Wrong Answer', 'Accepted']
|
['s284092869', 's827960159']
|
[21852.0, 20700.0]
|
[183.0, 151.0]
|
[1437, 1422]
|
p03244
|
u118019047
| 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(input().split())\n\nfor i in range(len(v)-2):\n v[i+2] = v[i]\n \nfor i in v:\n print(i,end=" ")', 'from collections import Counter\nn = int(input())\nv = list(map(int,input().split()))\n \nc1 = Counter(v[::2])\nc2 = Counter(v[1::2])\nm1 = c1.most_common()\nm2 = c2.most_common()\nt2 = n//2\nt1 = n - t2\n \nif len(m1) == len(m2) == 1:\n print(n//2 if m1[0][0] == m2[0][0] else 0)\nelif len(m1) == 1:\n if m1[0][0] != m2[0][0]:\n print(t1 - m2[0][1])\n else:\n print(t1 - m2[1][1])\nelif len(m2) == 1:\n if m1[0][0] != m2[0][0]:\n print(t2 - m1[0][1])\n else:\n print(t2 - m1[1][1])\nelse:\n if m1[0][0] != m2[0][0]:\n print(n - m1[0][1] - m2[0][1])\n else:\n ans = n - m1[1][1] - m2[1][1]\n if m1[0][0] != m2[1][0]:\n ans = min(ans, n - m1[0][1] - m2[1][1])\n if m1[1][0] != m2[0][0]:\n ans = min(ans, n - m1[1][1] - m2[0][1])\n print(ans)']
|
['Wrong Answer', 'Accepted']
|
['s977587844', 's450888423']
|
[11196.0, 21184.0]
|
[137.0, 92.0]
|
[125, 814]
|
p03244
|
u123824541
| 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())\n\nv = list(map(int,input().split()))\nv_odd = []\nv_eve = []\nv_odd_set = []\nv_eve_set = []\nv_odd_count = []\nv_eve_count = []\nv_o_max = 0\nv_e_max = 0\n\n\nfor i in range(N):\n if i % 2 == 0:\n v_odd.append(v[i])\n else:\n v_eve.append(v[i])\n\nv_odd_set = list(set(v_odd))\nv_eve_set = list(set(v_eve))\n\nfor c in v_odd_set:\n a = v_odd.count(c)\n v_odd_count.append(a)\n if a == max(v_odd_count):\n v_o_max = c\n else:\n continue\n\nfor c in v_eve_set:\n a = v_eve.count(c)\n v_eve_count.append(a)\n if a == max(v_eve_count):\n v_e_max = c\n else:\n continue\n\nv_odd_count.sort()\nv_eve_count.sort()\n\n\nif len(v_odd_count) != 1 and len(v_eve_count) != 1:\n if v_o_max == v_e_max:\n if v_odd_count[-1] >= v_eve_count[-2]:\n print(N - v_eve_count[-1] - v_eve_count[-2])\n else:\n print(N - v_odd_count[-1] - v_eve_count[-2])\n else:\n print(N - v_eve_count[-1] - v_odd_count[-1])\nelse:\n if v_o_max == v_e_max:\n print(int(N/2))\n else:\n print(0)', 'import collections\nc = collections.Counter\n\nN = int(input())\nv = list(map(int,input().split()))\n\nv_odd = v[::2]\nv_eve = v[1::2]\n\nc1 = c(v_odd).most_common(2)\nc2 = c(v_eve).most_common(2)\n\nif len(c1) == 1 and len(c2) == 1:\n if c1[0][0] != c2[0][0]:\n ans = 0\n else:\n ans = int(N/2)\nelse:\n if c1[0] != c2[0]:\n ans = N - c1[0][1] - c2[0][1]\n else:\n if c1[1][1] >= c2[1][1]:\n ans = N - c1[1][1] - c2[0][1]\n else:\n ans = N - c1[0][1] - c2[1][1]\n\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s420372014', 's139200224']
|
[14008.0, 15972.0]
|
[2104.0, 74.0]
|
[1061, 519]
|
p03244
|
u124498235
| 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()))\nif len(set(v)) == 1:\n\tprint (n//2)\n\texit()\na = v[1::2]\nb = v[0::2]\nif len(set(a)) == 1 and len(set(b)) == 1:\n\tprint (0)\n\texit()\n\naa = collections.Counter(a)\nbb = collections.Counter(b)\n\nyousoa = aa.most_common()[0][0]\nmaa = aa.most_common()[0][1]\nyousob = bb.most_common()[0][0]\nmbb = bb.most_common()[0][1]\nif yousoa == yousob\n\tif len(a) == 1:\n\t\tans = (len(a) - maa) + (len(b) - bb.most_common()[1][1])\n\telif len(b) == 1:\n\t\tans = (len(a) - aa.most_common()[1][1]) + (len(b)-mbb)\n\telse:\n\t\tans = (len(a) - maa) + (len(b) - bb.most_common()[1][1])\nelse:\n\tans = len(a)-maa + len(b)-mbb\nprint (ans)', 'import collections\nn = int(input())\nv = list(map(int, input().split()))\nif len(set(v)) == 1:\n\tprint (n//2)\n\texit()\na = v[1::2]\nb = v[0::2]\nif len(set(a)) == 1 and len(set(b)) == 1:\n\tprint (0)\n\texit()\nans = 0\n\naa = collections.Counter(a)\nbb = collections.Counter(b)\n\nyousoa = aa.most_common()[0][0]\nmaa = aa.most_common()[0][1]\nyousob = bb.most_common()[0][0]\nmbb = bb.most_common()[0][1]\nif len(set(a)) == 1:\n\tans += len(b) - mbb\n\tprint (ans)\n\texit()\nif len(set(b)) == 1:\n\tans += len(a) - maa\n\tprint (ans)\n\texit()\nmaa2 = aa.most_common()[1][1]\nmbb2 = bb.most_common()[1][1]\nif yousoa == yousob:\n\tans = min(n//2-maa + n//2-mbb2,n//2-maa2 + n//2-mbb)\n\tprint (ans)\nelse:\n\tprint (n-maa-mbb)']
|
['Runtime Error', 'Accepted']
|
['s651210143', 's081353611']
|
[3064.0, 20572.0]
|
[17.0, 132.0]
|
[666, 686]
|
p03244
|
u126232616
| 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\nE = V[::2]\nO = V[1::2]\n\nfrom collections import Counter\nEd = Counter(E)\nOd = Counter(O)\nEdn = Ed.most_common(2)\nOdn = Od.most_common(2)\nprint(Edn,Odn)\nif Edn[0][0] != Odn[0][0]:\n print(n- Edn[0][1] - Odn[0][1])\nelse:\n if len(Edn) == 1:\n if len(Odn) == 1:\n print(n//2)\n else:\n print(n//2-Odn[1][1])\n if len(Odn) == 1:\n print(n//2-Edn[1][1])\n else:\n print(min(n-Edn[0][1]-Odn[1][1],m-Edn[1][1]-Odn[0][1]))', 'n = int(input())\nV = list(map(int, input().split()))\n\nDic = [[i,0] for i in range(1,(10**5)+1)]\nDic2 = [[i,0] for i in range(1,(10**5)+1)]\nfor i in range(n):\n if i%2 == 0:\n Dic[V[i]-1][1] += 1\n else:\n Dic2[V[i]-1][1] += 1\nDic.sort(key = lambda x:x[1],reverse = True)\nDic2.sort(key = lambda x:x[1], reverse = True)\n#print(Dic,Dic2)\ncn = 0\nif Dic[0][0] != Dic2[0][0]:\n cn += n - Dic[0][1] - Dic2[0][1]\nelse:\n cn += n - max((Dic[0][1]+Dic2[1][1]), (Dic[1][1]+Dic2[0][1]))\nprint(cn)']
|
['Runtime Error', 'Accepted']
|
['s044652647', 's352291149']
|
[18936.0, 35068.0]
|
[82.0, 180.0]
|
[519, 504]
|
p03244
|
u129315407
| 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())\nAi = list(map(int, input().split()))\n\ndef calc(start): \n di = dict()\n for i in range(start, N, 2):\n if Ai[i] in di:\n n = di[Ai[i]]\n di[Ai[i]] = n + 1\n else:\n di[Ai[i]] = 1\n return di\n\nd1 = calc(0)\nd2 = calc(1)\n\nmin_v = 10000000000\nfor k1 in d1.keys():\n for k2 in d2.keys():\n if k1 == k2:\n continue\n v = N - d1[k1] - d2[k2]\n if v < min_v:\n v = min_v\nif min_v == 10000000000:\n print(N // 2)\nelse:\n print(min_v)\n', 'N = int(input())\nAi = list(map(int, input().split()))\n\ndef calc(start): \n di = dict()\n for i in range(start, N, 2):\n if Ai[i] in di:\n n = di[Ai[i]]\n di[Ai[i]] = n + 1\n else:\n di[Ai[i]] = 1\n l = []\n for k in di.keys():\n l.append([k, di[k]])\n l.sort(key=lambda x: x[1], reverse=True)\n return l\n\nl1 = calc(0)\nl2 = calc(1)\n\nif l1[0][0] != l2[0][0]:\n print(N - l1[0][1] - l2[0][1])\nelif len(l1) == 1 and len(l2) == 1:\n print(N // 2)\nelse:\n v1 = 100000000000000\n v2 = 100000000000000\n\n if len(l1) > 1:\n v1 = N - l1[1][1] - l2[0][1]\n if len(l2) > 1:\n v2 = N - l1[0][1] - l2[1][1]\n print(min(v1, v2))']
|
['Wrong Answer', 'Accepted']
|
['s727283325', 's627614359']
|
[17912.0, 21340.0]
|
[2104.0, 135.0]
|
[534, 699]
|
p03244
|
u146597538
| 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\narray1 = v[::2]\narray2 = v[1::2]\n\ndict1 = {}\ndict2 = {}\nfor i in array1:\n if i not in dict1:\n dict1[i] = 1\n else:\n dict1[i] = dict1[i] + 1\n\nfor i in array2:\n if i not in dict2:\n dict2[i] = 1\n else:\n dict2[i] = dict2[i] + 1\n\nsort_array1 = []\nsort_array2 = []\nfor k, v in sorted(dict1.items(), key=lambda x: -x[1]):\n sort_array1.append({k:v})\nfor k, v in sorted(dict2.items(), key=lambda x: -x[1]):\n sort_array2.append({k:v})\n\none_num1 = 0\none_num2 = 0\n\nfor k1,v1 in sort_array1[0].items():\n if len(sort_array1) != 1:\n one_num1 = len(array1) - v1\n for k2,v2 in sort_array2[0].items():\n if len(sort_array2) != 1:\n one_num2 = len(array2) - v2\n if k1 != k2:\n print(one_num1 + one_num2)\n break\n\n if len(sort_array1) == 1 and len(sort_array2) == 1:\n print(len(array1))\n break\n if len(sort_array1) == 1:\n for k,v in sort_array2[1].items():\n two_num2 = v\n print(1+two_num2)\n break\n if len(sort_array2) == 1:\n for k,v in sort_array1[1].items():\n two_num1 = v\n print(1+two_num1)\n break\n\n for k,v in sort_array1[1].items():\n two_num1 = len(array1) - v\n for k,v in sort_array2[1].items():\n two_num2 = len(array2) - v\n if two_num1 <= two_num2:\n print (one_num2 + two_num1)\n else:\n print (one_num1 + two_num2)\n~', 'n = int(input())\nv = list(map(int, input().split()))\n\narray1 = v[::2]\narray2 = v[1::2]\n\ndict1 = {}\ndict2 = {}\nfor i in array1:\n if i not in dict1:\n dict1[i] = 1\n else:\n dict1[i] = dict1[i] + 1\n\nfor i in array2:\n if i not in dict2:\n dict2[i] = 1\n else:\n dict2[i] = dict2[i] + 1\n\nsort_array1 = []\nsort_array2 = []\nfor k, v in sorted(dict1.items(), key=lambda x: -x[1]):\n sort_array1.append({k:v})\nfor k, v in sorted(dict2.items(), key=lambda x: -x[1]):\n sort_array2.append({k:v})\n\none_num1 = 0\none_num2 = 0\n\nprint (sort_array1)\nprint (sort_array2)\n\nfor k1,v1 in sort_array1[0].items():\n if len(sort_array1) != 1:\n one_num1 = len(array1) - v1\n for k2,v2 in sort_array2[0].items():\n if len(sort_array2) != 1:\n one_num2 = len(array2) - v2\n if k1 != k2:\n print(one_num1 + one_num2)\n break\n\n if len(sort_array1) == 1 and len(sort_array2) == 1:\n print(1)\n break\n if len(sort_array1) == 1:\n for k,v in sort_array2[1].items():\n two_num2 = v\n print(1+two_num2)\n break\n if len(sort_array2) == 1:\n for k,v in sort_array1[1].items():\n two_num1 = v\n print(1+two_num1)\n break\n\n for k,v in sort_array1[1].items():\n two_num1 = len(array1) - v\n for k,v in sort_array2[1].items():\n two_num2 = len(array2) - v\n if two_num1 <= two_num2:\n print (one_num1 + two_num2)\n else:\n print (one_num2 + two_num1)', 'n = int(input())\nv = list(map(int, input()))\n\narray1 = v[::2]\narray2 = v[1::2]\n\ndict1 = {}\ndict2 = {}\nfor i in array1:\n if i not in dict1:\n dict1[i] = 1\n else:\n dict1[i] = dict1[i] + 1\n\nfor i in array2:\n if i not in dict2:\n dict2[i] = 1\n else:\n dict2[i] = dict2[i] + 1\n\nsort_array1 = []\nsort_array2 = []\nfor k, v in sorted(dict1.items(), key=lambda x: -x[1]):\n sort_array1.append({k:v})\nfor k, v in sorted(dict2.items(), key=lambda x: -x[1]):\n sort_array2.append({k:v})\n\none_num1 = 0\none_num2 = 0\n\nfor k1,v1 in sort_array1[0].items():\n if len(sort_array1) != 1:\n one_num1 = len(array1) - v1\n for k2,v2 in sort_array2[0].items():\n if len(sort_array2) != 1:\n one_num2 = len(array2) - v2\n if k1 != k2:\n print(one_num1 + one_num2)\n break\n\n if len(sort_array1) == 1 and len(sort_array2) == 1:\n print(1)\n break\n if len(sort_array1) == 1:\n for k,v in sort_array2[1].items():\n two_num2 = v\n print(1+two_num2)\n break\n if len(sort_array2) == 1:\n for k,v in sort_array1[1].items():\n two_num1 = v\n print(1+two_num1)\n break\n\n for k,v in sort_array1[1].items():\n two_num1 = v\n for k,v in sort_array2[1].items():\n two_num2 = v\n if two_num1 <= two_num2:\n print (one_num1 + two_num2)\n else:\n print (one_num2 + two_num1)', 'n = int(input())\nv = list(map(int, input().split()))\n\narray1 = v[::2]\narray2 = v[1::2]\n\ndict1 = {}\ndict2 = {}\nfor i in array1:\n if i not in dict1:\n dict1[i] = 1\n else:\n dict1[i] = dict1[i] + 1\n\nfor i in array2:\n if i not in dict2:\n dict2[i] = 1\n else:\n dict2[i] = dict2[i] + 1\n\nsort_array1 = []\nsort_array2 = []\nfor k, v in sorted(dict1.items(), key=lambda x: -x[1]):\n sort_array1.append({k:v})\nfor k, v in sorted(dict2.items(), key=lambda x: -x[1]):\n sort_array2.append({k:v})\n\none_num1 = 0\none_num2 = 0\n\nprint (sort_array1)\nprint (sort_array2)\n\nfor k1,v1 in sort_array1[0].items():\n if len(sort_array1) != 1:\n one_num1 = len(array1) - v1\n for k2,v2 in sort_array2[0].items():\n if len(sort_array2) != 1:\n one_num2 = len(array2) - v2\n if k1 != k2:\n print(one_num1 + one_num2)\n break\n\n if len(sort_array1) == 1 and len(sort_array2) == 1:\n print(1)\n break\n if len(sort_array1) == 1:\n for k,v in sort_array2[1].items():\n two_num2 = v\n print(1+two_num2)\n break\n if len(sort_array2) == 1:\n for k,v in sort_array1[1].items():\n two_num1 = v\n print(1+two_num1)\n break\n\n for k,v in sort_array1[1].items():\n two_num1 = len(array1) - v\n for k,v in sort_array2[1].items():\n two_num2 = len(array2) - v\n if two_num1 <= two_num2:\n print (one_num2 + two_num1)\n else:\n print (one_num1 + two_num2)', 'n = int(input())\nv = list(map(int, input().split()))\n\narray1 = v[::2]\narray2 = v[1::2]\n\ndict1 = {}\ndict2 = {}\nfor i in array1:\n if i not in dict1:\n dict1[i] = 1\n else:\n dict1[i] = dict1[i] + 1\n\nfor i in array2:\n if i not in dict2:\n dict2[i] = 1\n else:\n dict2[i] = dict2[i] + 1\n\nsort_array1 = []\nsort_array2 = []\nfor k, v in sorted(dict1.items(), key=lambda x: -x[1]):\n sort_array1.append({k:v})\nfor k, v in sorted(dict2.items(), key=lambda x: -x[1]):\n sort_array2.append({k:v})\n\none_num1 = 0\none_num2 = 0\n\nfor k1,v1 in sort_array1[0].items():\n if len(sort_array1) != 1:\n one_num1 = len(array1) - v1\n for k2,v2 in sort_array2[0].items():\n if len(sort_array2) != 1:\n one_num2 = len(array2) - v2\n if k1 != k2:\n print(one_num1 + one_num2)\n break\n\n if len(sort_array1) == 1 and len(sort_array2) == 1:\n print(len(array1))\n break\n if len(sort_array1) == 1:\n for k,v in sort_array2[1].items():\n two_num2 = v\n print(1+two_num2)\n break\n if len(sort_array2) == 1:\n for k,v in sort_array1[1].items():\n two_num1 = v\n print(1+two_num1)\n break\n\n for k,v in sort_array1[1].items():\n two_num1 = len(array1) - v\n for k,v in sort_array2[1].items():\n two_num2 = len(array2) - v\n if two_num1 <= two_num2:\n print (one_num2 + two_num1)\n else:\n print (one_num1 + two_num2)\n~', 'n = int(input())\nv = list(map(int, input().split()))\n\narray1 = v[::2]\narray2 = v[1::2]\n\ndict1 = {}\ndict2 = {}\nfor i in array1:\n if i not in dict1:\n dict1[i] = 1\n else:\n dict1[i] = dict1[i] + 1\n\nfor i in array2:\n if i not in dict2:\n dict2[i] = 1\n else:\n dict2[i] = dict2[i] + 1\n\nsort_array1 = []\nsort_array2 = []\nfor k, v in sorted(dict1.items(), key=lambda x: -x[1]):\n sort_array1.append({k:v})\nfor k, v in sorted(dict2.items(), key=lambda x: -x[1]):\n sort_array2.append({k:v})\n\none_num1 = 0\none_num2 = 0\n\nprint (sort_array1)\nprint (sort_array2)\n\nfor k1,v1 in sort_array1[0].items():\n if len(sort_array1) != 1:\n one_num1 = len(array1) - v1\n for k2,v2 in sort_array2[0].items():\n if len(sort_array2) != 1:\n one_num2 = len(array2) - v2\n if k1 != k2:\n print(one_num1 + one_num2)\n break\n\n if len(sort_array1) == 1 and len(sort_array2) == 1:\n print(1)\n break\n if len(sort_array1) == 1:\n for k,v in sort_array2[1].items():\n two_num2 = v\n print(1+two_num2)\n break\n if len(sort_array2) == 1:\n for k,v in sort_array1[1].items():\n two_num1 = v\n print(1+two_num1)\n break\n\n for k,v in sort_array1[1].items():\n two_num1 = len(array1) - v\n for k,v in sort_array2[1].items():\n two_num2 = len(array2) - v\n if two_num1 <= two_num2:\n print (one_num2 + two_num1)\n else:\n print (one_num1 + two_num2)', 'n = int(input())\nv = list(map(int, input().split()))\n\narray1 = v[::2]\narray2 = v[1::2]\n\ndict1 = {}\ndict2 = {}\nfor i in array1:\n if i not in dict1:\n dict1[i] = 1\n else:\n dict1[i] = dict1[i] + 1\n\nfor i in array2:\n if i not in dict2:\n dict2[i] = 1\n else:\n dict2[i] = dict2[i] + 1\n\nsort_array1 = []\nsort_array2 = []\nfor k, v in sorted(dict1.items(), key=lambda x: -x[1]):\n sort_array1.append({k:v})\nfor k, v in sorted(dict2.items(), key=lambda x: -x[1]):\n sort_array2.append({k:v})\n\none_num1 = 0\none_num2 = 0\n\nfor k1,v1 in sort_array1[0].items():\n if len(sort_array1) != 1:\n one_num1 = len(array1) - v1\n for k2,v2 in sort_array2[0].items():\n if len(sort_array2) != 1:\n one_num2 = len(array2) - v2\n if k1 != k2:\n print(one_num1 + one_num2)\n break\n\n if len(sort_array1) == 1 and len(sort_array2) == 1:\n print(len(array1))\n break\n if len(sort_array1) == 1:\n for k,v in sort_array2[1].items():\n two_num2 = v\n print(1+two_num2)\n break\n if len(sort_array2) == 1:\n for k,v in sort_array1[1].items():\n two_num1 = v\n print(1+two_num1)\n break\n\n for k,v in sort_array1[1].items():\n two_num1 = len(array1) - v\n for k,v in sort_array2[1].items():\n two_num2 = len(array2) - v\n if two_num1 <= two_num2:\n print (one_num2 + two_num1)\n else:\n print (one_num1 + two_num2)']
|
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
|
['s039584186', 's160054492', 's398157875', 's721335853', 's751332676', 's888436000', 's637296513']
|
[3064.0, 49432.0, 4852.0, 49388.0, 3064.0, 49384.0, 47276.0]
|
[18.0, 205.0, 19.0, 175.0, 17.0, 175.0, 144.0]
|
[1393, 1422, 1345, 1422, 1393, 1422, 1391]
|
p03244
|
u152638361
| 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()))\nve = [v[2*i] for i in range(n//2)]\nvo = [v[2*i + 1] for i in range(n//2)]\nCve = collections.Counter(ve)\nCvo = collections.Counter(vo)\nCve1 = Cve.most_common()[0]\nCvo1 = Cvo.most_common()[0]\n\n\nif len(Cve) == 1 and len(Cvo) == 1:\n if Cve1[0] == Cvo1[0]:\n ans = n//2 - Cvo1[1]\n else:\n ans = 0\nelif len(Cve) == 1 and len(Cvo) != 1:\n Cvo2 = Cvo.most_common()[1]\n if Cve1[0] == Cvo1[0]:\n ans = n//2 - Cvo2[1]\n else:\n ans = n//2 - Cvo1[1]\n\nelif len(Cve) != 1 and len(Cvo) == 1:\n Cve2 = Cve.most_common()[1]\n if Cve1[0] == Cvo1[0]:\n ans = n//2 - Cve2[1]\n else:\n ans = n//2 - Cve1[2]\nelse:\n Cve2 = Cve.most_common()[1]\n Cvo2 = Cvo.most_common()[1]\n\n if Cve1[0] != Cvo1[0]:\n ans = n - Cve1[1] - Cvo1[1] \n if Cve1[0] == Cvo1[0]:\n if Cve1[1] > Cvo1[1]:\n ans = n - Cve1[1] - Cvo2[1]\n else:\n an', 'import collections\nn = int(input())\nv = list(map(int,input().split()))\nve = [v[2*i] for i in range(n//2)]\nvo = [v[2*i + 1] for i in range(n//2)]\nCve = collections.Counter(ve)\nCvo = collections.Counter(vo)\nCve1 = Cve.most_common()[0]\nCvo1 = Cvo.most_common()[0]\nif len(Cve) == 1 and len(Cvo) == 1: \n if Cve1[0] == Cvo1[0]: ans = n//2 \n else: ans = 0 \nelif len(Cve) == 1 and len(Cvo) > 1: \n Cvo2 = Cvo.most_common()[1]\n if Cve1[0] == Cvo1[0]: ans = n//2 - Cvo2[1] \n else: ans = n//2 - Cvo1[1] \nelif len(Cve) > 1 and len(Cvo) == 1: \n Cve2 = Cve.most_common()[1]\n if Cve1[0] == Cvo1[0]: ans = n//2 - Cve2[1] \n else: ans = n//2 - Cve1[1] \nelse:\n Cve2 = Cve.most_common()[1]\n Cvo2 = Cvo.most_common()[1]\n if Cve1[0] != Cvo1[0]: ans = n - Cve1[1] - Cvo1[1] \n if Cve1[0] == Cvo1[0]:\n if Cve1[1] < Cvo1[1]: ans = n - Cve2[1] - Cvo1[1]\n elif Cve2[1] > Cvo2[1] : ans = n - Cve2[1] - Cvo1[1]\n else: ans = n - Cve1[1] - Cvo2[1]\nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s690677531', 's333539734']
|
[19040.0, 19040.0]
|
[116.0, 115.0]
|
[1013, 1124]
|
p03244
|
u153094838
| 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"""\nCreated on Sun May 31 18:36:13 2020\n\n@author: NEC-PCuser\n"""\nn = int(input())\nl = list(map(int, input().split()))\ndic_gusu = {}\ndic_kisu = {}\n\nfor i in range(0, n):\n if (i % 2 == 0):\n if (l[i] in dic_gusu):\n dic_gusu[l[i]] += 1\n else:\n dic_gusu[l[i]] = 1\n if (i % 2 == 1):\n if (l[i] in dic_kisu):\n dic_kisu[l[i]] += 1\n else:\n dic_kisu[l[i]] = 1\ndic_kisu = sorted(dic_kisu.items(), key = lambda x : x[1])\ndic_gusu = sorted(dic_gusu.items(), key = lambda x : x[1])\n\n\nif (len(dic_kisu) == 1 and len(dic_gusu) == 1 and dic_kisu[len(dic_kisu) - 1][0] == dic_gusu[len(dic_gusu) - 1][0]):\n count = n // 2\nelif (dic_kisu[len(dic_kisu) - 1][0] != dic_gusu[len(dic_gusu) - 1][0]):\n for i in range(0, len(dic_kisu) - 1):\n count += dic_kisu[i][1]\n for i in range(0, len(dic_gusu) - 1):\n count += dic_kisu[i][1]\nelse:\n for i in range(0, len(dic_kisu)):\n count += dic_kisu[i][1]\n for i in range(0, len(dic_kisu)):\n count += dic_kisu[i][1]\n count_tmp = count\n count_ans = count_tmp - dic_kisu[len(dic_kisu) - 1][1] - dic_kisu[len(dic_gusu) - 2][1] \n count_ans2 = count_tmp - dic_kisu[len(dic_kisu) - 2][1] - dic_kisu[len(dic_gusu) - 1][1]\n count = min([count_ans, count_ans2]) \n \nprint(count)', '# -*- coding: utf-8 -*-\n"""\nCreated on Sun May 31 18:36:13 2020\n\n@author: NEC-PCuser\n"""\nn = int(input())\nl = list(map(int, input().split()))\ndic_gusu = {}\ndic_kisu = {}\n\nfor i in range(0, n):\n if (i % 2 == 0):\n if (l[i] in dic_gusu):\n dic_gusu[l[i]] += 1\n else:\n dic_gusu[l[i]] = 1\n if (i % 2 == 1):\n if (l[i] in dic_kisu):\n dic_kisu[l[i]] += 1\n else:\n dic_kisu[l[i]] = 1\ndic_kisu = sorted(dic_kisu.items(), key = lambda x : x[1])\ndic_gusu = sorted(dic_gusu.items(), key = lambda x : x[1])\n\ncount = 0\nif (len(dic_kisu) == 1 and len(dic_gusu) == 1 and dic_kisu[len(dic_kisu) - 1][0] == dic_gusu[len(dic_gusu) - 1][0]):\n count = n // 2\nelif (dic_kisu[len(dic_kisu) - 1][0] != dic_gusu[len(dic_gusu) - 1][0]):\n for i in range(0, len(dic_kisu) - 1):\n count += dic_kisu[i][1]\n for i in range(0, len(dic_gusu) - 1):\n count += dic_gusu[i][1]\nelse:\n for i in range(0, len(dic_kisu)):\n count += dic_kisu[i][1]\n for i in range(0, len(dic_gusu)):\n count += dic_gusu[i][1]\n count_tmp = count\n count_ans = count_tmp - dic_kisu[len(dic_kisu) - 1][1] - dic_gusu[len(dic_gusu) - 2][1] \n count_ans2 = count_tmp - dic_kisu[len(dic_kisu) - 2][1] - dic_gusu[len(dic_gusu) - 1][1]\n count = min([count_ans, count_ans2]) \n \nprint(count)']
|
['Runtime Error', 'Accepted']
|
['s342763386', 's912442713']
|
[17688.0, 17688.0]
|
[112.0, 127.0]
|
[1350, 1358]
|
p03244
|
u154756110
| 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=[0]*(10**5+1)\nB=[0]*(10**5+1)\nfor i in range(N):\n if(i%2==0):\n A[V[i]]+=1\n else:\n B[V[i]]+=1\nMA=0\nNA=A[0]\nNA2=A[0]\nMB=0\nNB=B[0]\nNB2=B[0]\nfor i in range(10**5+1):\n if(A[i]>=NA):\n NA2=NA\n NA=A[i]\n MA=i\n if(B[i]>=NB):\n NB2=NB\n NB=B[i]\n MB=i\nif(MA!=MB):\n print(N-NA-NB)\nelse:\n print(min(N-NA-NB2,N-NA2-NB))\nprint(MA,MB,NA,NA2,NB,NB2)', 'N=int(input())\nV=list(map(int,input().split()))\nA=[0]*(10**5+1)\nB=[0]*(10**5+1)\nfor i in range(N):\n if(i%2==0):\n A[V[i]]+=1\n else:\n B[V[i]]+=1\nMA=0\nNA=A[0]\nMB=0\nNB=B[0]\nfor i in range(10**5+1):\n if(A[i]>=NA):\n NA=A[i]\n MA=i\n if(B[i]>=NB):\n NB=B[i]\n MB=i\nA.sort(reverse=True)\nB.sort(reverse=True)\nif(MA!=MB):\n print(N-NA-NB)\nelse:\n print(min(N-A[0]-B[1],N-A[1]-B[0]))\n\n']
|
['Wrong Answer', 'Accepted']
|
['s539564009', 's640851234']
|
[14268.0, 14404.0]
|
[94.0, 110.0]
|
[409, 392]
|
p03244
|
u156815136
| 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 median\n#import collections\n#aa = collections.Counter(a) # list to list\n#from itertools import combinations # (string,3) 3回\n#from collections import deque\n#import collections.defaultdict(list)\n\n#\n#\n\n#\n#\n\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\ndef main():\n n = int(input())\n V = readInts()\n from collections import Counter\n a = Counter(V[0::2]).most_common(1) \n b = Counter(V[1::2]).most_common(1)\n a.append([0,0])\n b.append([0,0])\n print(a,b)\n if a[0][0] != b[0][0]:\n \n print(n - (a[0][1] + b[0][1]))\n else:\n print(min(n-(a[1][1] - b[0][1]), n-(a[0][1] + b[1][1])))\nif __name__ == '__main__':\n main()\n", 'n = int(input())\nv = list(map(int,input().split()))\nfrom collections import Counter\neven = Counter(v[::2]).most_common(2)\nodd = Counter(v[1::2]).most_common(2)\neven.append((0,0))\nodd.append((0,0))\nyouso = n//2\nif even[0][0] == odd[0][0]: \n print(min(youso - even[1][1] + youso - odd[0][1],youso - odd[1][1] + youso - even[0][1]))\nelse: \n print(youso - even[0][1] + youso - odd[0][1])\n']
|
['Wrong Answer', 'Accepted']
|
['s118247605', 's934814155']
|
[15472.0, 15460.0]
|
[66.0, 78.0]
|
[834, 503]
|
p03244
|
u157232135
| 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 v0=sorted(Counter(v[::2]).items(), key=lambda x: x[1])\n v1=sorted(Counter(v[1::2]).items(), key=lambda x: x[1])\n vv = v1[-1][0]\n if v0[-1][0] == v1[-1][0]:\n if len(v0) > 1 and len(v1) > 0:\n vv = min(v0[-2][1], v1[-2][1])\n elif len(v0) > 1:\n vv = v0[-2][1]\n elif len(v1) > 1:\n vv = v1[-2][1]\n else:\n print(n//2)\n return\n print(n-v0[-1][1]-vv)\n \nif __name__ == "__main__":\n main()', 'from collections import Counter\ndef main():\n n=int(input())\n v=list(map(int,input().split()))\n v0=Counter(v[0::2]).most_common(2)\n v1=Counter(v[1::2]).most_common(2)\n \n print(v0)\n print(v1)\n print(n, v0[0], v1[0])\n if v0[0][0] != v1[0][0]:\n print(n - v0[0][1] - v1[0][1])\n else:\n if len(v0) == 1 and len(v1) == 1:\n print(n//2)\n else:\n print(n-max(v0[0][1]+v1[1][1], v0[1][1]+v1[0][1]))\n \nif __name__ == "__main__":\n main()', 'from collections import Counter\ndef main():\n n=int(input())\n v=list(map(int,input().split()))\n v0=sorted(Counter(v[::2]).items(), key=lambda x: x[1])\n v1=sorted(Counter(v[1::2]).items(), key=lambda x: x[1])\n \n if v0[-1][0] != v1[-1][0]:\n print(n-v0[-1][1]-v1[-1][1])\n else:\n if len(v0) == 1 and len(v1) == 1:\n print(n//2)\n else:\n a = (v0[-1][1] + v1[-2][1]) if len(v1) > 1 else 0\n b = (v0[-2][1] + v1[-1][1]) if len(v0) > 1 else 0\n print(n - max(a, b))\n \nif __name__ == "__main__":\n main()']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s184201014', 's345962669', 's518420485']
|
[25200.0, 21412.0, 25252.0]
|
[82.0, 68.0, 81.0]
|
[583, 501, 581]
|
p03244
|
u163320134
| 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=list(map(int,input().split()))\ncnt1=[0]*(10**5+1)\ncnt2=[0]*(10**5+1)\nfor i in range(n):\n if i%2==0:\n cnt1[arr[i]]+=1\n else:\n cnt2[arr[i]]+=1\nm1=max(cnt1)\nm2=max(cnt2)\np1=cnt1.index(m1)\np2=cnt2.index(m2)\ncnt1=sorted(cnt1,reverse=True)\ncnt2=sorted(cnt2,reverse=True)\nif n==2:\n if arr[0]!=arr[1]:\n print(0)\n else:\n print(1)\nelse:\n if p1==p2:\n if m1>m2:\n m2=cnt2[1]\n else:\n m1=cnt1[1]\n ans=(n-m1)+(n-m2)\n print(ans)', 'n=int(input())\narr=list(map(int,input().split()))\ncnt1=[0]*(10**5+1)\ncnt2=[0]*(10**5+1)\nfor i in range(n):\n if i%2==0:\n cnt1[arr[i]]+=1\n else:\n cnt2[arr[i]]+=1\nm1=max(cnt1)\nm2=max(cnt2)\np1=cnt1.index(m1)\np2=cnt2.index(m2)\ncnt1=sorted(cnt1,reverse=True)\ncnt2=sorted(cnt2,reverse=True)\nif n==2:\n if arr[0]!=arr[1]:\n print(0)\n else:\n print(1)\nelse:\n if p1==p2:\n ans=min(n-m1-cnt2[1],n-cnt1[1]-m2)\n else:\n ans=n-m1-m2\n print(ans)']
|
['Wrong Answer', 'Accepted']
|
['s386256277', 's554394986']
|
[14268.0, 14404.0]
|
[87.0, 86.0]
|
[465, 450]
|
p03244
|
u163449343
| 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()))\ngu = [::2]\nki = [1::2]\nans = 0\nk,g = False,False\n\nif v.count(v[0]) == n:\n ans += n // 2\nelse:\n kic = Counter(ki)\n guc = Counter(gu)\n k1 = kic.most_common(2)\n g1 = guc.most_common(2)\n if k1[0][0] == g1[0][0]:\n if k1[1][1] < g1[1][1]:\n k = True\n elif k1[1][1] > g1[1][1]:\n g = True\n\n kic = list(kic.values())\n guc = list(guc.values())\n kic.sort(reverse = True)\n guc.sort(reverse = True)\n if len(kic) != 1:\n if k:\n ans += kic[0]\n ans += sum(kic[2::])\n else:\n ans += sum(kic[1::]) \n if len(guc) != 1:\n if g:\n ans += guc[0]\n ans += sum(guc[2::])\n else:\n ans += sum(guc[1::])\n\nprint(ans)', 'from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\ngu = v[::2]\nki = v[1::2]\nans = 0\nk,g = False,False\n\n\n\nif v.count(v[0]) == n\n ans += n // 2\nelse:\n kic = Counter(ki)\n guc = Counter(gu)\n k1 = kic.most_common(2)\n g1 = guc.most_common(2)\n if k1[0][0] == g1[0][0]:\n if k1[1][1] < g1[1][1]:\n g = True\n else:\n k = True\n\n kic = list(kic.values())\n guc = list(guc.values())\n kic.sort(reverse = True)\n guc.sort(reverse = True)\n if len(kic) != 1:\n if k:\n ans += kic[0]\n ans += sum(kic[2::])\n else:\n ans += sum(kic[1::]) \n if len(guc) != 1:\n if g:\n ans += guc[0]\n ans += sum(guc[2::])\n else:\n ans += sum(guc[1::])\n\nprint(ans)', 'from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\ngu = v[::2]\nki = v[1::2]\nans = 0\nk,g = False,False\n\n\n\nif v.count(v[0]) == n:\n ans += n // 2\nelse:\n kic = Counter(ki)\n guc = Counter(gu)\n k1 = kic.most_common(2)\n g1 = guc.most_common(2)\n if k1[0][0] == g1[0][0]:\n if k1[1][1] < g1[1][1]:\n g = True\n else:\n k = True\n\n kic = list(kic.values())\n guc = list(guc.values())\n kic.sort(reverse = True)\n guc.sort(reverse = True)\n if len(kic) != 1:\n if k:\n ans += kic[0]\n ans += sum(kic[2::])\n else:\n ans += sum(kic[1::]) \n if len(guc) != 1:\n if g:\n ans += guc[0]\n ans += sum(guc[2::])\n else:\n ans += sum(guc[1::])\n\nprint(ans)']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s435029845', 's955957832', 's649366188']
|
[3060.0, 2940.0, 19040.0]
|
[17.0, 17.0, 80.0]
|
[845, 897, 898]
|
p03244
|
u172035535
| 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\n\ne,o = 0,0\nans = 0\nE,O = [],[]\nfor v,i in zip(V,range(N)):\n if i%2 == 0:\n E.append(v)\n else:\n O.append(v)\nEC = c(E).most_common()\nOC = c(O).most_common()\nn = N//2\n\nEC01=EC[0][1]\n\nOC01=OC[0][1]\n\nif len(EC) == 1:\n EC11 = 0\nelse:\n EC11=EC[1][1]\nif len(OC) == 1:\n OC11 = 0\nelse:\n OC11=OC[1][1]\nif len(EC) == 1 and len(OC) == 1 and EC[0][0]==OC[0][0]:\n ans = EC01\nelif EC01+OC11 > EC11+OC01:\n ans += n - EC01\n ans += n - OC11\nelif EC01+OC11 < EC11+OC01:\n ans += n - EC11\n ans += n - OC01\nelif EC01 == OC01:\n ans = 0\nprint(EC01,EC11,OC01,OC11)\nprint(ans)', 'from collections import Counter as c\n\ne,o = 0,0\nans = 0\nE,O = [],[]\nfor v,i in zip(V,range(N)):\n if i%2 == 0:\n E.append(v)\n else:\n O.append(v)\nEC = c(E).most_common()\nOC = c(O).most_common()\nn = N//2\n\nEC01=EC[0][1]\n\nOC01=OC[0][1]\n\nif len(EC) == 1:\n EC11 = 0\nelse:\n EC11=EC[1][1]\nif len(OC) == 1:\n OC11 = 0\nelse:\n OC11=OC[1][1]\nif len(EC) == 1 and len(OC) == 1 and EC[0][0]==OC[0][0]:\n ans = EC01\nelif EC01+OC11 > EC11+OC01:\n ans += n - EC01\n ans += n - OC11\nelif EC01+OC11 < EC11+OC01:\n ans += n - EC11\n ans += n - OC01\nelif EC01 == OC01:\n ans = 0\nprint(ans)', 'from collections import Counter as c\n\nN = int(input())\nV = list(map(int,input().split()))\nev = c(V[::2]).most_common(2)\nod = c(V[1::2]).most_common(2)\n\nif ev[0][0] == od[0][0]:\n if len(ev) == 1 and len(od) == 1:\n print(N//2)\n else:\n print(N-max(ev[0][1]+od[1][1],ev[1][1]+od[0][1]))\nelse:\n print(N-ev[0][1]-od[0][1])']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s331230528', 's886977124', 's554933975']
|
[3316.0, 3316.0, 15588.0]
|
[21.0, 21.0, 73.0]
|
[635, 608, 339]
|
p03244
|
u174603263
| 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 = [int(x) for x in input().split()]\nv_odd = [x for x in v_list if v_list.index(x) % 2 == 1]\nv_even = [x for x in v_list if v_list.index(x) % 2 == 0]\n\nprint(v_odd, v_even)\nif len(list(set(v_list))) > 1:\n\n odd_max1 = list(set(v_odd))[-1]\n \n even_max1 = list(set(v_even))[-1]\n \n \n if odd_max1 == even_max1:\n odd_max2 = list(set(v_odd))[-2]\n even_max2 = list(set(v_even))[-2]\n\n p = N -v_odd.count(odd_max1) - v_even.count(even_max2)\n q = N -v_odd.count(odd_max2) - v_even.count(even_max1)\n\n if p > q:\n n = p\n else:\n n = q\n else:\n n = N -v_odd.count(odd_max1) - v_even.count(even_max1)\n\nelse:\n n = int(N / 2)\n\n\n\nprint(n)', 'from collections import defaultdict\nimport sys\nn = int(input())\nv = list(map(int, input().split()))\n\ndd_even = defaultdict(int)\ndd_odd = defaultdict(int)\n\n\nfor i in range(0, n, 2):\n dd_even[v[i]] += 1\n\nl_even = list(dd_even.items())\nl_even.sort(key= lambda x:x[1])\ntop_even = l_even[-1][0]\n#print(l_even)\n\n\nfor i in range(1, n, 2):\n dd_odd[v[i]] += 1\n\nl_odd = list(dd_odd.items())\nl_odd.sort(key= lambda x:x[1])\n#print(l_odd)\ntop_odd = l_odd[-1][0]\n\nif top_even == top_odd:\n if len(l_odd) == 1: \n res = int(n / 2)\n print(res)\n sys.exit()\n else:\n \n l_odd_1 = [l for l in l_odd if l[0] != l_odd[-2][0]]\n sum_odd_1 = sum(l[1] for l in l_odd_1)\n l_even_1 = [l for l in l_even if l[0] != top_even]\n sum_even_1 = sum(l[1] for l in l_even_1)\n sum_1 = sum_odd_1 + sum_even_1\n\n l_odd_2 = [l for l in l_odd if l[0] != top_odd]\n sum_odd_2 = sum(l[1] for l in l_odd_2)\n l_even_2 = [l for l in l_even if l[0] != l_even[-2][0]]\n sum_even_2 = sum(l[1] for l in l_even_2)\n sum_2 = sum_odd_2 + sum_even_2\n\n if sum_1 < sum_2:\n print(sum_1)\n else:\n print(sum_2)\n sys.exit()\nelse:\n l_odd = [l for l in l_odd if l[0] != top_odd]\n\nsum_odd = sum(l[1] for l in l_odd)\n#print(l_odd, sum_odd)\n\nl_even = [l for l in l_even if l[0] != top_even]\nsum_even = sum(l[1] for l in l_even)\n\n\nres = sum_odd + sum_even\nprint(res)\n']
|
['Wrong Answer', 'Accepted']
|
['s857508279', 's404997161']
|
[14396.0, 22024.0]
|
[2104.0, 162.0]
|
[846, 1620]
|
p03244
|
u181195295
| 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())\neven = [input() for i in range(N) if i%2==0]\nodd =[ input() for i in range(N) if i%2!=0]\n\ne = collections.Counter(even)\no = collections.Counter(odd)\n\nec=e[0][1]\noc=o[0][1]\n\nif e[0][0]==o[0][0]:\n if e[0][1] > o[0][1]:\n oc=o[1][1]\n else:\n ec=e[1][1]\n \nans = N-(ec+oc)\nprint(ans)', 'from collections import Counter\n\nans = int(input())\nV = [int(i) for i in input().split()]\n\nv1 = []\nv2 = []\n\nfor i, v in enumerate(V):\n if i % 2 == 0:\n v1.append(v)\n else:\n v2.append(v)\n\nv1c = Counter(v1).most_common()\nv2c = Counter(v2).most_common()\n\nk1, v1 = v1c[0][0], v1c[0][1]\nk2, v2 = v2c[0][0], v2c[0][1]\n\nif k1 == k2:\n ans -= v2\n m = 0\n if len(v1c) >= 2:\n m = max(m, v1c[1][1])\n if len(v2c) >= 2:\n m = max(m, v2c[1][1])\n ans -= m\nelse:\n ans -= v1 + v2\n\nprint(ans)\n']
|
['Runtime Error', 'Accepted']
|
['s145670494', 's514388637']
|
[4980.0, 21084.0]
|
[23.0, 110.0]
|
[324, 522]
|
p03244
|
u181526702
| 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())\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n count = n//2\nelse:\n odd = defaultdict(lambda: 0)\n even = defaultdict(lambda: 0)\n for i in v[0::2]:\n odd[i] += 1\n for i in v[1::2]:\n even[i] += 1\n o1, o2, *_ = sorted(odd.items(), key=lambda x: x[1], reverse=True)\n e1, e2, *_ = sorted(even.items(), key=lambda x: x[1], reverse=True)\n if o1[0] != e1[0]:\n count = n - o1[1] - e1[1]\n elif o1[1] >= e1[1]:\n count = n - o1[1] - e2[1]\n elif o1[1] < e1[1]:\n count = n - o2[1] - e1[1]\n\nprint(count)', 'from collections import defaultdict\n\nn = int(input())\nv = list(map(int, input().split()))\n\nodd = defaultdict(lambda: 0)\neven = defaultdict(lambda: 0)\nodd[None] = 0\neven[None] = 0\nfor i in v[0::2]:\n odd[i] += 1\nfor i in v[1::2]:\n even[i] += 1\n\nodd = sorted(odd.items(), key=lambda x: x[1], reverse=True)\neven = sorted(even.items(), key=lambda x: x[1], reverse=True)\nif odd[0][0] != even[0][0]:\n count = n - odd[0][1] - even[0][1]\nelse:\n count = n - max(odd[0][1]+even[1][1], odd[1][1]+even[0][1])\n\nprint(count)\n']
|
['Runtime Error', 'Accepted']
|
['s902688856', 's456193373']
|
[23260.0, 18648.0]
|
[133.0, 116.0]
|
[617, 522]
|
p03244
|
u185688520
| 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()))\nif v.count(v[0]) == n:\n print(n // 2)\n exit()\ne = []\no = []\nfor i in range(n):\n if i % 2 == 0:\n e.append(v[i])\n else:\n o.append(v[i])\ne_counter = Counter(e)\no_counter = Counter(o)\nE1 = list(e_counter.keys())[0]\nif len(list(e_counter.keys())) > 1:\n E2 = list(e_counter.keys())[1]\nelse:\n E2 = E1\nO1 = list(o_counter.keys())[0]\nif len(list(o_counter.keys())) > 1:\n O2 = list(o_counter.keys())[1]\nelse:\n O2 = O1\ne_cnt = n // 2 - e.count(E1)\no_cnt = n // 2 - o.count(O1)\nprint(e_cnt, o_cnt)\nif e_cnt == 0 and o_cnt == 0:\n print(0)\nelse:\n print(e_cnt + o_cnt)\n', 'from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\nif v.count(v[0]) == n:\n print(n // 2)\n exit()\ne = []\no = []\nfor i in range(n):\n if i % 2 == 0:\n e.append(v[i])\n else:\n o.append(v[i])\ne_counter = Counter(e)\no_counter = Counter(o)\nE1 = list(e_counter.keys())[0]\nif len(list(e_counter.keys())) > 1:\n E2 = list(e_counter.keys())[1]\nelse:\n E2 = E1\nO1 = list(o_counter.keys())[0]\nif len(list(o_counter.keys())) > 1:\n O2 = list(o_counter.keys())[1]\nelse:\n O2 = O1\ne_cnt = n // 2 - max(e.count(E1))\no_cnt = n // 2 - max(o.count(O1))\nif e_cnt == 0 and o_cnt == 0:\n print(0)\nelse:\n print(e_cnt + o_cnt)\n', 'from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\ne = []\no = []\nfor i in range(n):\n if i % 2 == 0:\n e.append(v[i])\n else:\n o.append(v[i])\ne_counter = Counter(e)\no_counter = Counter(o)\ne_most = e_counter.most_common()\no_most = o_counter.most_common()\nE1 = e_most[0][0]\nE2 = E1\nif len(e_most) > 1:\n E2 = e_most[1][0]\nO1 = o_most[0][0]\nO2 = O1\nif len(o_most) > 1:\n O2 = o_most[1][0]\ne_cnt = n // 2 - e.count(E1)\no_cnt = n // 2 - o.count(O1)\nif e_cnt == 0 and o_cnt == 0:\n if e[0] == o[0]:\n print(n // 2)\n else:\n print(0)\nelse:\n if E1 != O1:\n print(e_cnt + o_cnt)\n else:\n if E1 == O2:\n e_cnt = n // 2 - e.count(E2)\n print(e_cnt + o_cnt)\n elif E2 == O1:\n o_cnt = n // 2 - o.count(O2)\n print(e_cnt + o_cnt)\n else:\n cnt1 = n // 2 - e.count(E2) + o_cnt\n cnt2 = e_cnt + n // 2 - o.count(O2)\n print(min(cnt1, cnt2))\n']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s436682620', 's649469603', 's568120427']
|
[19168.0, 19160.0, 23776.0]
|
[90.0, 91.0, 117.0]
|
[683, 673, 998]
|
p03244
|
u187205913
| 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()))\nl1 = []\nl2 = []\nfor i,v_ in enumerate(v):\n if i%2==0:\n l1.append(v_)\n else:\n l2.append(v_)\n\nfrom collections import Counter\nif set(l1)==set(l2):\n print(n//2)\nelse:\n c1 = Counter(l1).most_common(2)\n c2 = Counter(l2).most_common(2)\n if c1[0][0]==c2[0][0]:\n print(n-max(v[0][1]+v[1][1], v[1][1]+v[0][1]))\n else:\n print(n-v[0][1]-v[0][1])\n', 'n = int(input())\nv = list(map(int,input().split()))\nl1 = []\nl2 = []\nfor i,v_ in enumerate(v):\n if i%2==0:\n l1.append(v_)\n else:\n l2.append(v_)\n\nfrom collections import Counter\nif len(set(v))==1:\n print(n//2)\nelse:\n c1 = Counter(l1).most_common(2)\n c2 = Counter(l2).most_common(2)\n if c1[0][0]==c2[0][0]:\n print(n-max(c1[0][1]+c2[1][1], c1[1][1]+c2[0][1]))\n else:\n print(n-c1[0][1]-c2[0][1])']
|
['Runtime Error', 'Accepted']
|
['s910264498', 's124733894']
|
[15904.0, 16612.0]
|
[105.0, 100.0]
|
[436, 439]
|
p03244
|
u188244611
| 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())\nE = []\nO = []\nV = [int(el) for el in input().split(' ')]\nfor i in range(n):\n if i % 2 == 0:\n O.append(V[i])\n else:\n E.append(V[i])\n\nE_count = Counter(E).most_common(1)[0][1]\nO_count = Counter(O).most_common(1)[0][1]\n\nif len(set(V)) == 1:\n print(n//2)\nelse:\n E_change = n // 2 - E_count\n O_change = n //2 - O_count\n print(E_change, O_change)\n print(E_change + O_change)\n", "from collections import Counter\nn = int(input())\nV = [int(el) for el in input().split(' ')]\n\na = Counter(V[0::2]).most_common() + [(0,0)]\nb = Counter(V[1::2]).most_common() + [(0,0)]\n\nif a[0][0]!=b[0][0]:\n print(n-a[0][1]-b[0][1])\nelse:\n print(n-max(a[1][1]+b[0][1],a[0][1]+b[1][1]))\n"]
|
['Wrong Answer', 'Accepted']
|
['s649190508', 's871580607']
|
[20188.0, 20572.0]
|
[98.0, 89.0]
|
[455, 290]
|
p03244
|
u189023301
| 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())\nlis = list(map(int, input().split()))\n\na = Counter(lis[::2])\nb = Counter(lis[1::2])\n\naa = sorted(a.items(), key=lambda x:x[1], reverse=True)\nbb = sorted(b.items(), key=lambda x:x[1], reverse=True)\nprint(aa)\nprint(bb)\n\nif aa[0][0] == bb[0][0]:\n if len(aa) > 1 and len(bb) > 1:\n res = n - max(aa[0][1]+bb[1][1], aa[1][1]+bb[0][1])\n elif len(aa) == 1 and len(bb) > 1:\n res = n - aa[0][1] - bb[1][1]\n elif len(aa) > 1 and len(bb) == 1:\n res = n - aa[1][1] - bb[0][1]\n else:\n res = n - aa[0][1]\nelse:\n res = n - aa[0][1] - bb[0][1]\n\nprint(res)\n', 'from collections import Counter\nn = int(input())\nlis = list(map(int, input().split()))\n\na = Counter(lis[::2])\nb = Counter(lis[1::2])\n\naa = sorted(a.items(), key=lambda x:x[1], reverse=True)\nbb = sorted(b.items(), key=lambda x:x[1], reverse=True)\n\naa.append((0, 0))\nbb.append((0, 0))\n\nif aa[0][0] == bb[0][0]:\n res = n - max(aa[0][1]+bb[1][1], aa[1][1]+bb[0][1])\nelse:\n res = n - aa[0][1] - bb[0][1]\nprint(res)\n']
|
['Wrong Answer', 'Accepted']
|
['s305152001', 's783203690']
|
[23616.0, 21184.0]
|
[141.0, 98.0]
|
[631, 416]
|
p03244
|
u202570162
| 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 itertools\nfrom collections import Counter\nN = int(input())\nV = list(map(int,input().split()))\neven_counter = Counter(V[::2])\nodd_counter = Counter(V[1::2])\neven_counter[-1] = 0\nodd_counter[-1] = 0\neven = even_counter.most_common(2)\nodd = odd_counter.most_common(2)\nprint(even,odd)\nans = N\nfor (k1,v1),(k2,v2) in itertools.product(even,odd):\n if k1 == k2:\n continue\n ans = min(ans,N - v1 - v2)\nprint(ans)', "N=int(input())\nV=[int(i) for i in input().split()]\nK=list(set(V))\nif len(K)==1:\n print(N//2)\n exit()\n\ncnt={}\ncnt[-1]=0\nfor k in K:\n cnt[k]=0\nfor i in range(0,N,2):\n cnt[V[i]]+=1\nev_MAX=0\nsec_ev_MAX=0\nev=-1\nev_cnt=[(cnt[k],k) for k in K]\nev_cnt.sort(key=lambda x: x[0],reverse=True)\nev=ev_cnt[0][1]\nev_MAX=ev_cnt[0][0]\nsec_ev_MAX=0 if len(ev_cnt)<2 else ev_cnt[1][0]\n# print(ev_cnt)\ncnt={}\ncnt[-1]=0\nfor k in K:\n cnt[k]=0\nfor i in range(1,N,2):\n cnt[V[i]]+=1\nod_MAX=0\nsec_od_MAX=0\nod=-1\nod_cnt=[(cnt[k],k) for k in K]\nod_cnt.sort(key=lambda x: x[0],reverse=True)\nod=od_cnt[0][1]\nod_MAX=od_cnt[0][0]\nsec_od_MAX=0 if len(od_cnt)<2 else od_cnt[1][0]\n\nans=0\nif od!=ev:\n # print('#',1)\n ans+=N//2-ev_MAX\n ans+=N//2-od_MAX\nelse:\n # print(sec_ev_MAX,od_MAX,sec_od_MAX,ev_MAX)\n ans+=min(N//2-sec_ev_MAX+N//2-od_MAX,N//2-sec_od_MAX+N//2-ev_MAX)\nprint(ans)"]
|
['Wrong Answer', 'Accepted']
|
['s571894491', 's729176580']
|
[18528.0, 33564.0]
|
[81.0, 167.0]
|
[415, 878]
|
p03244
|
u203843959
| 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())\nvlist=list(map(int,input().split()))\n\nvlist1=[vlist[2*i] for i in range(n//2)]\nvlist2=[vlist[2*i+1] for i in range(n//2)]\n#print(vlist1)\n#print(vlist2)\n\nvc1=collections.Counter(vlist1).most_common()\nvc2=collections.Counter(vlist2).most_common()\nprint(vc1)\nprint(vc2)\n\nif vc1[0][0]!=vc2[0][0]:\n print(n-vc1[0][1]-vc2[0][1])\nelif len(vc1)==1 and len(vc2)==1:\n print(n//2)\nelif len(vc1)==1:\n print(n//2-vc2[1][1])\nelif len(vc2)==1:\n print(n//2-vc1[1][1])\nelse:\n if vc1[0][1]>vc2[0][1]:\n print(n-vc1[0][1]-vc2[1][1])\n elif vc1[0][1]<vc2[0][1]:\n print(n-vc1[1][1]-vc2[0][1])\n else:\n max_2nd=max(vc1[1][1],vc2[1][1])\n print(n-vc1[0][1]-max_2nd)', 'import collections\n\nn=int(input())\nvlist=list(map(int,input().split()))\n\nvlist1=[vlist[2*i] for i in range(n//2)]\nvlist2=[vlist[2*i+1] for i in range(n//2)]\n#print(vlist1)\n#print(vlist2)\n\nvc1=collections.Counter(vlist1).most_common()\nvc2=collections.Counter(vlist2).most_common()\n#print(vc1)\n#print(vc2)\n\nif vc1[0][0]!=vc2[0][0]:\n print(n-vc1[0][1]-vc2[0][1])\nelif len(vc1)==1 and len(vc2)==1:\n print(n//2)\nelif len(vc1)==1:\n print(n//2-vc2[1][1])\nelif len(vc2)==1:\n print(n//2-vc1[1][1])\nelse:\n if vc1[0][1]>vc2[0][1]:\n print(n-vc1[0][1]-vc2[1][1])\n elif vc1[0][1]<vc2[0][1]:\n print(n-vc1[1][1]-vc2[0][1])\n else:\n max_2nd=max(vc1[1][1],vc2[1][1])\n print(n-vc1[0][1]-max_2nd)']
|
['Wrong Answer', 'Accepted']
|
['s218787912', 's737657197']
|
[22236.0, 21084.0]
|
[133.0, 95.0]
|
[692, 694]
|
p03244
|
u215115622
| 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.
|
['a = input()\ndict1 = dict()\ndict2 = dict()\ncounter = 0\nb = input()\nfor i in b:\n\tif counter % 2 == 0:\n\t\tif i not in dict1:\n\t\t\tdict1[i] = 1\n\t\telse:\n\t\t\tdict1[i] += 1\n\telif counter % 2 == 1:\n\t\tif i not in dict2:\n\t\t\tdict2[i] = 1\n\t\telse:\n\t\t\tdict2[i] += 1\n\t\t\t\n\tcounter += 1\n\ndict1list = []\nfor i in dict1.keys():\n\tdict1list.append([i, dict1[i]])\n\ndict2list = []\nfor i in dict2.keys():\n\tdict2list.append([i, dict2[i]])\n\ndict1list.sort(key = lambda x: x[1])\ndict2list.sort(key = lambda x: x[1])\nprint(dict1list,dict2list)\nif dict1list[-1][0] == dict2list[-1][0] and len(dict2list) > 1 and dict1list[-1][1] > dict2list[-1][1]:\n\tprint(len(b) - dict1list[-1][1] - dict2list[-2][1])\nelif dict1list[-1][0] == dict2list[-1][0] and len(dict2list) == 1 and dict1list[-1][1] > dict2list[-1][1]:\n\tprint(len(b) - dict1list[-1][1])\nelif dict1list[-1][0] == dict2list[-1][0] and len(dict1list) > 1 and dict1list[-1][1] < dict2list[-1][1]:\n\tprint(len(b) - dict1list[-2][1] - dict2list[-1][1])\nelif dict1list[-1][0] == dict2list[-1][0] and len(dict1list) == 1 and dict1list[-1][1] < dict2list[-1][1]:\n\tprint(len(b) - dict2list[-1][1])\nelif dict1list[-1][0] == dict2list[-1][0] and dict1list[-1][1] == dict2list[-1][1]:\n\tif len(dict1list) == 1 and len(dict2list) == 1:\n\t\tprint(len(b) - dict2list[-1][1])\n\telif len(dict1list) == 1 and len(dict2list) > 1:\n\t\tprint(len(b) - dict2list[-2][1] - dict1list[-1][1])\n\telif len(dict1list) > 1 and len(dict2list) == 1:\n\t\tprint(len(b) - dict2list[-1][1] - dict1list[-2][1])\n\telse:\n\t\tif (dict2list[-2][-1] >= dict1list[-2][-1]):\n\t\t\tprint(len(b) - dict2list[-2][1] - dict1list[-1][1])\n\t\telif (dict2list[-2][-1] < dict1list[-2][-1]):\n\t\t\tprint(len(b) - dict2list[-1][1] - dict1list[-2][1])\nelse:\n\tprint(len(b) - dict1list[-1][1] - dict2list[-1][1])\n', 'a = input()\ndict1 = dict()\ndict2 = dict()\ncounter = 0\nb = input().split()\nfor i in b:\n\tif counter % 2 == 0:\n\t\tif i not in dict1:\n\t\t\tdict1[i] = 1\n\t\telse:\n\t\t\tdict1[i] += 1\n\telif counter % 2 == 1:\n\t\tif i not in dict2:\n\t\t\tdict2[i] = 1\n\t\telse:\n\t\t\tdict2[i] += 1\n\t\t\t\n\tcounter += 1\n\ndict1list = []\nfor i in dict1.keys():\n\tdict1list.append([i, dict1[i]])\n\ndict2list = []\nfor i in dict2.keys():\n\tdict2list.append([i, dict2[i]])\n\ndict1list.sort(key = lambda x: x[1])\ndict2list.sort(key = lambda x: x[1])\nif dict1list[-1][0] == dict2list[-1][0] and len(dict2list) > 1 and dict1list[-1][1] > dict2list[-1][1]:\n\tprint(len(b) - dict1list[-1][1] - dict2list[-2][1])\nelif dict1list[-1][0] == dict2list[-1][0] and len(dict2list) == 1 and dict1list[-1][1] > dict2list[-1][1]:\n\tprint(len(b) - dict1list[-1][1])\nelif dict1list[-1][0] == dict2list[-1][0] and len(dict1list) > 1 and dict1list[-1][1] < dict2list[-1][1]:\n\tprint(len(b) - dict1list[-2][1] - dict2list[-1][1])\nelif dict1list[-1][0] == dict2list[-1][0] and len(dict1list) == 1 and dict1list[-1][1] < dict2list[-1][1]:\n\tprint(len(b) - dict2list[-1][1])\nelif dict1list[-1][0] == dict2list[-1][0] and dict1list[-1][1] == dict2list[-1][1]:\n\tif len(dict1list) == 1 and len(dict2list) == 1:\n\t\tprint(len(b) - dict2list[-1][1])\n\telif len(dict1list) == 1 and len(dict2list) > 1:\n\t\tprint(len(b) - dict2list[-2][1] - dict1list[-1][1])\n\telif len(dict1list) > 1 and len(dict2list) == 1:\n\t\tprint(len(b) - dict2list[-1][1] - dict1list[-2][1])\n\telse:\n\t\tif (dict2list[-2][-1] >= dict1list[-2][-1]):\n\t\t\tprint(len(b) - dict2list[-2][1] - dict1list[-1][1])\n\t\telif (dict2list[-2][-1] < dict1list[-2][-1]):\n\t\t\tprint(len(b) - dict2list[-1][1] - dict1list[-2][1])\nelse:\n\tprint(len(b) - dict1list[-1][1] - dict2list[-1][1])\n']
|
['Wrong Answer', 'Accepted']
|
['s116867426', 's769217101']
|
[4980.0, 26084.0]
|
[260.0, 141.0]
|
[1762, 1743]
|
p03244
|
u223646582
| 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, K = map(int, input().split())\nprint('N:{}, K:{}'.format(N, K))\n\nif K % 2 == 0:\n print(((N-K//2)//K+1)**3+(N//K)**3)\nelse:\n print((N//K)**3)\n", 'n=int(input())\nv=list(map(int,input().split()))\nv1=v[0::2]\nv2=v[1::2]\n\nprint((len(v1)-v1.most_common()[0][1]) + (len(v2)-v2.most_common()[0][1]))', 'N, K = map(int, input().split())\n\n\nif K % 2 == 0:\n print(((N-K//2)//K+1)**3+(N//K)**3)\nelse:\n print((N//K)**3)\n', 'import collections\n\nn=int(input())\nv=list(map(int,input().split()))\nv1=collections.Counter(v[0::2])\nv2=collections.Counter(v[1::2])\n\nif len(set(v)) == 1:\n ans=len(v[1::2])\nelse:\n if len(v1.most_common())==1:\n v1.append((0,0))\n if len(v2.most_common())==1:\n v2.append((0,0))\n ans=min(len(v) - v1.most_common()[0][1] - v2.most_common()[0][1],len(v) - v1.most_common()[0][1] - v2.most_common()[1][1],len(v) - v1.most_common()[1][1] - v2.most_common()[0][1])\n\nprint(ans)\n\n', 'import collections\nN = int(input())\nV = [int(i) for i in input().split()]\n\nC0 = collections.Counter(V[0::2])\nC0[0] = 0\n\nC1 = collections.Counter(V[1::2])\nC1[0] = 0\n\nif C0.most_common()[0][0] != C1.most_common()[0][0]:\n print(N-C0.most_common()[0][1]-C1.most_common()[0][1])\nelse:\n print(min(N-C0.most_common()[0][1]-C1.most_common()[1][1],\n N-C0.most_common()[1][1]-C1.most_common()[0][1]))\n']
|
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
|
['s168221157', 's226871821', 's672073222', 's934431878', 's424727179']
|
[2940.0, 14404.0, 2940.0, 22336.0, 18656.0]
|
[17.0, 42.0, 17.0, 140.0, 125.0]
|
[149, 145, 151, 494, 410]
|
p03244
|
u223663729
| 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# C - /\\/\\/\\/\n\nfrom collections import Counter\n\nN, *A = map(int, open(0).read().split())\n\nev = A[0::2]\nod = A[1::2]\n\nev_C = Counter(ev)\nod_C = Counter(od)\n\nev_most = ev_C.most_common()[0][1]\nod_most = od_C.most_common()[0][1]\nev_second = ev_C.most_common()[1][1]\nod_second = od_C.most_common()[1][1]\n\n\nif ev == od:\n print(N//2)\nelse:\n print(min(\n N-ev_most-od_most,\n N-ev_most-od_second,\n N-ev_second-od_most\n ))\n', '\n# C - /\\/\\/\\/\n\nfrom collections import Counter\n\nN, *A = map(int, open(0).read().split())\n\nev = A[0::2]\nod = A[1::2]\n\nev_C = Counter(ev)\nod_C = Counter(od)\n\n\nif ev == od and ev_C.most_common()[0][1] == N//2:\n print(N//2)\nelse:\n ans = N\n ev_common = ev_C.most_common()\n od_common = od_C.most_common()\n ev_most = ev_common[0][1]\n od_most = od_common[0][1]\n if ev_common[0][0] == od_common[0][0]:\n ev_second = ev_common[1][1]\n od_second = od_common[1][1]\n ans = min(ans, N-ev_most-od_second)\n ans = min(ans, N-ev_second-od_most)\n else:\n ans = min(ans, N-ev_most-od_most)\n\n print(ans)\n']
|
['Runtime Error', 'Accepted']
|
['s940793150', 's310336117']
|
[18912.0, 21732.0]
|
[106.0, 100.0]
|
[525, 724]
|
p03244
|
u223904637
| 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())\n\nl=list(map(int,input().split()))\n\nki=[0]*100001\ngu=[0]*100001\n\nfor i in range(n):\n if i%2==0:\n ki[l[i]]+=1\n else:\n gu[l[i]]+=1\nkm1=[max(ki),ki.index(max(ki))]\nkm2=[sorted(ki)[-2],ki.index(sorted(ki)[-2])]\ngm1=[max(gu),gu.index(max(gu))]\ngm2=[sorted(gu)[-2],gu.index(sorted(gu)[-2])]\n\nif km1[1]!=gm1[1]:\n print(n-km1[0]-gm[0])\nelse:\n if km1[1]-km2[1]>=gm1[1]-gm2[1]:\n print(n-km1[0]-gm2[0])\n else:\n print(n-gm1[0]-km2[0])\n\n', 'n=int(input())\n\nl=list(int,input().split())\n\nki=[0]*100001\ngu=[0]*100001\n\nfor i in range(n):\n if i%2==0:\n ki[l[i]]+=1\n else:\n gu[l[i]]+=1\nkm1=[max(ki),ki.index(max(ki))]\nkm2=[sorted(ki)[-2],ki.index(sorted(ki)[-2])]\ngm1=[max(gu),gu.index(max(gu))]\ngm2=[sorted(gu)[-2],gu.index(sorted(gu)[-2])]\n\nif km1[1]!=gm1[1]:\n print(n-km1[0]-gm[0])\nelse:\n if km1[1]-km2[1]>=gm1[1]-gm2[1]:\n print(n-km1[0]-gm2[0])\n else:\n print(n-gm1[0]-km2[0])\n\n', 'n=int(input())\n\nl=list(map(int,input().split()))\n\nki=[0]*100001\ngu=[0]*100001\n\nfor i in range(n):\n if i%2==0:\n ki[l[i]]+=1\n else:\n gu[l[i]]+=1\nkm1=[max(ki),ki.index(max(ki))]\nkm2=[sorted(ki)[-2],ki.index(sorted(ki)[-2])]\ngm1=[max(gu),gu.index(max(gu))]\ngm2=[sorted(gu)[-2],gu.index(sorted(gu)[-2])]\n\nif km1[1]!=gm1[1]:\n print(n-km1[0]-gm1[0])\nelse:\n if km1[0]-km2[0]>=gm1[0]-gm2[0]:\n print(n-km1[0]-gm2[0])\n else:\n print(n-gm1[0]-km2[0])\n']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s124902686', 's167797345', 's780512004']
|
[14268.0, 10616.0, 14404.0]
|
[105.0, 25.0, 106.0]
|
[481, 476, 481]
|
p03244
|
u225642513
| 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 = [int(i) for i in input().split()]\n\nif len(set(a)) == 1:\n p = int(n/2)\nelse:\n b0 = set(a[::2])\n if len(b0)==1:\n q0 = 0\n mark00 = b0[0]\n count00, count01 = n/2, 0\n else:\n c = Counter(l)\n q0 = int(n/2) - c.most_common(1)[0][1]\n mark00, mark01 = c.most_common(2)[0][0], c.most_common(2)[1][0]\n count00, count01 = c.most_common(2)[0][1], c.most_common(2)[1][1]\n\n b1 = set(a[1::2])\n if len(b1)==1:\n q1 = 0\n mark10 = b1[0]\n count10, count11 = n/2, 0\n else:\n c = Counter(l)\n q1 = int(n/2) - c.most_common(1)[0][1]\n mark10, mark11 = c.most_common(2)[0][0], c.most_common(2)[1][0]\n count10, count11 = c.most_common(2)[0][1], c.most_common(2)[1][1]\n if mark00==mark10:\n if count00+count01>count10+count11:\n p = n - (count00+count01)\n else:\n p = n - (count10+count11)\n else:\n p = n - (count00 + count10)\n\nprint(p)\n\n', 'from collections import Counter\nn = int(input())\na = [int(i) for i in input().split()]\n\nif len(set(a)) == 1:\n p = int(n/2)\nelse:\n b0 = set(a[::2])\n if len(b0)==1:\n q0 = 0\n mark00 = a[0]\n count00, count01 = n/2, 0\n else:\n c = Counter(l)\n q0 = int(n/2) - c.most_common(1)[0][1]\n mark00, mark01 = c.most_common(2)[0][0], c.most_common(2)[1][0]\n count00, count01 = c.most_common(2)[0][1], c.most_common(2)[1][1]\n\n b1 = set(a[1::2])\n if len(b1)==1:\n q1 = 0\n mark10 = a[1]\n count10, count11 = n/2, 0\n else:\n c = Counter(l)\n q1 = int(n/2) - c.most_common(1)[0][1]\n mark10, mark11 = c.most_common(2)[0][0], c.most_common(2)[1][0]\n count10, count11 = c.most_common(2)[0][1], c.most_common(2)[1][1]\n if mark00==mark10:\n if count00+count01>count10+count11:\n p = n - (count00+count01)\n else:\n p = n - (count10+count11)\n else:\n p = n - (count00 + count10)\n\nprint(p)\n', 'from collections import Counter\nn = int(input())\na = [int(i) for i in input().split()]\n\nif len(set(a)) == 1:\n p = int(n/2)\nelse:\n b0 = set(a[::2])\n if len(b0)==1:\n q0 = 0\n mark00 = a[0]\n count00, count01 = int(n/2), 0\n else:\n c = Counter(a[::2])\n q0 = int(n/2) - c.most_common(1)[0][1]\n mark00, mark01 = c.most_common(2)[0][0], c.most_common(2)[1][0]\n count00, count01 = c.most_common(2)[0][1], c.most_common(2)[1][1]\n\n b1 = set(a[1::2])\n if len(b1)==1:\n q1 = 0\n mark10 = a[1]\n count10, count11 = int(n/2), 0\n else:\n c = Counter(a[1::2])\n q1 = int(n/2) - c.most_common(1)[0][1]\n mark10, mark11 = c.most_common(2)[0][0], c.most_common(2)[1][0]\n count10, count11 = c.most_common(2)[0][1], c.most_common(2)[1][1]\n if mark00==mark10:\n if count00+count01>count10+count11:\n p = n - (count00+count01)\n else:\n p = n - (count10+count11)\n else:\n p = n - (count00 + count10)\n\nprint(p)\n\n']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s121127215', 's661359008', 's073375357']
|
[16228.0, 16228.0, 23260.0]
|
[58.0, 59.0, 172.0]
|
[1026, 1023, 1045]
|
p03244
|
u227082700
| 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=list(map(int,input().split()))\na1=collections.Counter(a[0::2]).most_common()\na2=collections.Counter(a[1::2]).most_common()\nprint(a1,a2)\na1.append((0,0))\na2.append((0,0))\nif a1[0]!=a2[0]:print(n-a1[0][1]-a2[0][1])\nelse:print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))', 'import collections\nn=int(input())\na=list(map(int,input().split()))\na1=collections.Counter(a[0::2]).most_common()\na2=collections.Counter(a[1::2]).most_common()\na1.append((0,0))\na2.append((0,0))\nif a1[0]!=a2[0]:print(n-a1[0][1]-a2[0][1])\nelse:print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))']
|
['Wrong Answer', 'Accepted']
|
['s551088694', 's043888875']
|
[21852.0, 20700.0]
|
[119.0, 85.0]
|
[305, 292]
|
p03244
|
u228232845
| 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())\n*v, = map(int, input().split())\nv_even, v_odd = [v[i] for i in range(n) if i % 2 == 0], [v[i] for i in range(n) if i % 2 != 0]\n\ncounter_even = collections.Counter(v_even)\ncounter_odd = collections.Counter(v_odd)\n\ncount_even = sorted(counter_even.items(), key=lambda x:x[1], reverse=True)\nprint(count_even)\ncount_odd = sorted(counter_odd.items(), key=lambda x:x[1], reverse=True)\nprint(count_odd)\n\nif len(counter_even) == 1 and len(counter_odd) == 1:\n if count_even[0][0] != count_odd[0][0]:\n ans = 0\n else:\n ans1 = 0\n for i in range(n // 2):\n if v_even[i] != count_even[1][0]:\n v_even[i] = count_even[1][0]\n ans1 += 1\n \n if v_odd[i] != count_odd[0][0]:\n v_odd[i] = count_odd[0][0]\n ans1 += 1\n \n ans2 = 0\n for i in range(n // 2):\n if v_even[i] != count_even[0][0]:\n v_even[i] = count_even[0][0]\n ans2 += 1\n \n if v_odd[i] != count_odd[1][0]:\n v_odd[i] = count_odd[1][0]\n ans2 += 1\n \n ans = min(ans1, ans2)\n\nelse:\n ans = 0 \n for i in range(n // 2):\n if v_even[i] != count_even[0][0]:\n v_even[i] = count_even[0][0]\n ans += 1\n \n if v_odd[i] != count_odd[0][0]:\n v_odd[i] = count_odd[0][0]\n ans += 1\n\nprint(ans)', 'import collections\nn = int(input())\n*v, = map(int, input().split())\nv_even, v_odd = [v[i] for i in range(n) if i % 2 == 0], [v[i] for i in range(n) if i % 2 != 0]\n\ncounter_even = collections.Counter(v_even)\ncounter_odd = collections.Counter(v_odd)\n\nmax_count_even = max(counter_even.items(), key=lambda x:x[1])\n#print(max_count_even[0])\nmax_count_odd = max(counter_odd.items(), key=lambda x:x[1])\n#print(max_count_odd[0])\nans = 0\nfor i in range(n // 2):\n if v_even[i] != max_count_even[0]:\n v_even[i] = max_count_even[0]\n ans += 1\n \n if v_odd[i] != max_count_odd[0]:\n v_odd[i] = max_count_odd[0]\n ans += 1\n \nif len(counter_even) == 1 and len(max_count_odd):\n ans = n // 2\n\nprint(ans)', 'from collections import Counter\nn = int(input())\n*v, = map(int, input().split())\nv_even, v_odd = v[::2], v[1::2]\neven = Counter(v_even).most_common(2)\nodd = Counter(v_odd).most_common(2)\n\nans = 0\n\nif even[0][0] != odd[0][0]:\n ans = n - odd[0][1] - even[0][1]\n\nelse:\n if len(even) == 1 and len(odd) == 1:\n ans = n // 2\n \n elif len(even) == 1:\n ans = n - even[0][1] - odd[1][1]\n \n elif len(odd) == 1:\n ans = n - even[1][1] - odd[0][1]\n \n else:\n ans = min(n - even[0][1] - odd[1][1], \n n - even[1][1] - odd[0][1])\n \nprint(ans)']
|
['Runtime Error', 'Wrong Answer', 'Accepted']
|
['s053969607', 's961963540', 's669819254']
|
[24512.0, 19032.0, 15972.0]
|
[187.0, 125.0, 74.0]
|
[1464, 755, 621]
|
p03244
|
u231095456
| 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\nn = int(input())\nv = list(map(int,input().split()))\na = v[::2]\nb = v[1::2]\ndef calc(l):\n d = defaultdict(int)\n for x in l:\n d[x] += 1\n return sorted([(d[x], x) for x in d],reverse=True)\nA = calc(a)\nB = calc(b)\nal,ax = A[0]\nbl,bx = B[0]\nprint(a,b)\nif ax != bx:\n print(n-al-bl)\nelif al > bl:\n if len(B) > 1:\n bl,bx = B[1]\n print(n-al-bl)\nelif al < bl:\n if len(A) > 1:\n al,ax = A[1]\n print(n-al-bl)\nelse:\n print(n//2)', 'from collections import defaultdict\nn = int(input())\nv = list(map(int,input().split()))\na = v[::2]\nb = v[1::2]\ndef calc(l):\n d = defaultdict(int)\n for x in l:\n d[x] += 1\n return sorted([(d[x], x) for x in d],reverse=True)\nA = calc(a)\nB = calc(b)\nal,ax = A[0]\nbl,bx = B[0]\nif ax != bx:\n print(n-al-bl)\nelse:\n ar,ay = A[1] if len(A) > 1 else (0,None)\n br,by = B[1] if len(B) > 1 else (0,None)\n print(min(n-al-br,n-ar-bl))']
|
['Wrong Answer', 'Accepted']
|
['s761808404', 's965981010']
|
[21844.0, 21212.0]
|
[120.0, 112.0]
|
[498, 447]
|
p03244
|
u243699903
| 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 = [int(i) for i in input().split()] \n\nodd=v[1::2]\neven=v[::2]\n\nif len(collections.Counter(v)):\n max_eq = max(len(odd),len(even))\n print(n - max_eq)\n exit()\n\nodd_most = collections.Counter(odd).most_common(2)\neven_most = collections.Counter(even).most_common(2)\n\nmax_count=0\nfor odd_top in odd_most:\n for even_top in even_most:\n max_count = max(max_count,odd_top[1]+even_top[1])\nprint(n-max_count)', 'import collections\n\nn = int(input())\nv = [int(i) for i in input().split()] \n\nodd=v[1::2]\neven=v[::2]\n\nif len(collections.Counter(v))==1:\n max_eq = max(len(odd),len(even))\n print(n - max_eq)\n exit()\n\nodd_most = collections.Counter(odd).most_common(2)\neven_most = collections.Counter(even).most_common(2)\n\nmax_count=0\nfor odd_top in odd_most:\n for even_top in even_most:\n if odd_top[0] == even_top[0]:\n continue\n max_count = max(max_count,odd_top[1]+even_top[1])\nprint(n-max_count)']
|
['Wrong Answer', 'Accepted']
|
['s270122124', 's651527498']
|
[20576.0, 20576.0]
|
[59.0, 129.0]
|
[454, 516]
|
p03244
|
u246820565
| 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\n\n\n\n\nodd = Counter(v[1::2]).most_common()\neven = Counter(v[0::2]).most_common()\n\nprint(len(odd),len(even))\n\n\nif odd[0][0] != even[0][0]:\n\tanswer = n - odd[0][1] - even[0][1]\n\nelse:\n\tif len(odd) == 1 and len(even) >1:\n\t\tanswer = n - even[0][1]\n\telif len(even) == 1 and len(odd) >1:\n\t\tanswer = n - odd[0][1]\n\telif len(even) == 1 and len(odd) ==1:\n\t\tanswer = n - even[0][1]\n\telse:\t\t\n\t\tif odd[0][1] > even[0][1]:\n\t\t\tanswer = n - odd[0][1] - even[1][1]\n\t\telif odd[0][1] < even[0][1]:\n\t\t\tanswer = n - even[0][1] - odd[1][1]\n\t\telse:\n\t\t\tif odd[1][1] > even[1][1]:\n\t\t\t\tanswer = n - even[0][1] - odd[1][1]\n\t\t\telif odd[1][1] < even[1][1]:\n\t\t\t\tanswer = n - odd[0][1] - even[1][1]\n\t\t\telse:\n\t\t\t\tanswer = n - odd[0][1] - even[1][1]\n\t\t\nprint(answer)\n\n\n\n\n\n', 'from collections import Counter\n\nn = int(input())\nv = list(map(int,input().split()))\n\n\n\n\n\nodd = Counter(v[1::2]).most_common()\neven = Counter(v[0::2]).most_common()\n\n\n\nif odd[0][0] != even[0][0]:\n\tanswer = n - odd[0][1] - even[0][1]\n\nelse:\n\tif len(odd) == 1 and len(even) >1:\n\t\tanswer = n - even[0][1]\n\telif len(even) == 1 and len(odd) >1:\n\t\tanswer = n - odd[0][1]\n\telif len(even) == 1 and len(odd) ==1:\n\t\tanswer = n - even[0][1]\n\telse:\t\t\n\t\tif odd[0][1] > even[0][1]:\n\t\t\tanswer = n - odd[0][1] - even[1][1]\n\t\telif odd[0][1] < even[0][1]:\n\t\t\tanswer = n - even[0][1] - odd[1][1]\n\t\telse:\n\t\t\tif odd[1][1] > even[1][1]:\n\t\t\t\tanswer = n - even[0][1] - odd[1][1]\n\t\t\telif odd[1][1] < even[1][1]:\n\t\t\t\tanswer = n - odd[0][1] - even[1][1]\n\t\t\telse:\n\t\t\t\tanswer = n - odd[0][1] - even[1][1]\n\t\t\nprint(answer)\n\n\n\n\n\n']
|
['Wrong Answer', 'Accepted']
|
['s154861087', 's802709540']
|
[20700.0, 20700.0]
|
[86.0, 85.0]
|
[1253, 1227]
|
p03244
|
u248670337
| 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()))\nE=Counter(V[::2]).most_common()\nO=Counter(V[1::2]).most_common()\nE2=Counter(V[1::2]).most_common()[1][1] if len(E)>1 else 0\nO2=Counter(V[::2]).most_common()[1][1] if len(O)>1 else 0 \nprint(n-E[0][1]-O[0][1] if E[0][0]!=O[0][0] else n-max(E[0][1]+E2,O[0][1]+O2))', 'from collections import Counter\nn=int(input())\nV=list(map(int,input().split()))\nE=Counter(V[::2]).most_common()+[(0,0)]\nO=Counter(V[1::2]).most_common()+[(0,0)]\nprint(n-E[0][1]-O[0][1] if E[0][0]!=O[0][0] else n-max(E[0][1]+O[1][1],O[0][1]+E[1][1]))']
|
['Runtime Error', 'Accepted']
|
['s832559039', 's542768237']
|
[24284.0, 20572.0]
|
[131.0, 87.0]
|
[341, 249]
|
p03244
|
u252828980
| 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())\nh=[int(i) for i in input().split()]\n\nh_o_l = len(h[1::2])\nh_e_l = len(h[::2])\n\nh_o = collections.Counter(h[1::2])\nh_e = collections.Counter(h[::2])\n\no_ = h_o.most_common()\ne_ = h_e.most_common()\no_.append((0,0))\ne_.append((0,0))\n\nif o_[0][0] != e_[0][0]:\n print(N-o_[1][1]-e_[1][1])\nelif o_[0][0] == e_[0][0]:\n a =min(N-o_[0][1]-e_[1][1],N-e_[0][1]-o_[1][1])\n print(a)', 'import collections\nN=int(input())\nh=[int(i) for i in input().split()]\n\nh_o_l = len(h[1::2])\nh_e_l = len(h[::2])\n\nh_o = collections.Counter(h[1::2])\nh_e = collections.Counter(h[::2])\n\no_ = h_o.most_common()\ne_ = h_e.most_common()\no_.append((0,0))\ne_.append((0,0))\n\nif o_[0][0] != e_[0][0]:\n print(N-o_[0][1]-e_[0][1])\nelif o_[0][0] == e_[0][0]:\n a =min(N-o_[0][1]-e_[1][1],N-e_[0][1]-o_[1][1])\n print(a)']
|
['Wrong Answer', 'Accepted']
|
['s302623465', 's614984400']
|
[21184.0, 21184.0]
|
[95.0, 101.0]
|
[411, 411]
|
p03244
|
u254086528
| 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()] \nlv0 = []\ndv0 = {}\nlv1 = []\ndv1 = {}\n\nv.sort()\nans = -1\n\ndef func():\n count0 = 0\n count1 = 0\n for i,x in enumerate(v):\n if i%2 == 0:\n if x not in lv0:\n lv0.append(x)\n dv0[x] = 1\n else:\n dv0[x] += 1\n if dv0[x] > count0:\n count0 = dv0[x]\n else:\n if x not in lv1:\n lv1.append(x)\n dv1[x] = 1\n else:\n dv1[x] += 1\n if dv1[x] > count1:\n count1 = dv1[x]\n ans = n - count0 - count1\n\n\n\nfor i in range(int(n/2)):\n i0 = 2*i\n i1 = 2*i + 1\n if v[0] != v[1]:\n func()\n break\n if v[i0] != v[i1]:\n count = 0\n if v[i0] != v[i0-2]:\n for x in range(i,int(n/2)):\n x0 = 2*x\n if v[i0] != v[x0]:\n break\n count += 1\n if v[i1] != v[i1-2]:\n for x in range(i,int(n/2)):\n x1 = 2*x + 1\n if v[i1] != v[x1]:\n break\n count += 1\n ans = n - (i+1) - count\n break\nprint(ans)', 'from collections import Counter\n\nn = int(input())\nv = list(map(int,input().split()))\nv0 = []\nv1 = []\nfor i,ev in enumerate(v):\n if i%2 == 0:\n v0.append(ev)\n else:\n v1.append(ev)\n\nmcv0 = Counter(v0).most_common(2)\nmcv1 = Counter(v1).most_common(2)\ncmcv0 = mcv0[0][1]\ncmcv1 = mcv1[0][1]\nans = n - cmcv0 - cmcv1\nif mcv0[0][0] == mcv1[0][0]:\n if (len(mcv0) == 1) and (len(mcv1) == 1):\n ans = int(n/2)\n else:\n ans = min(n - mcv0[1][1] - cmcv1, n - cmcv1 - mcv1[1][1])\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s823548046', 's572284065']
|
[14240.0, 16092.0]
|
[2104.0, 95.0]
|
[1278, 513]
|
p03244
|
u263753244
| 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()))\nd1=[0]*(10**5+1)\nd2=[0]*(10**5+1)\n\nfor i in range(n):\n if i%2==0:\n d1[v[i]]+=1\n else:\n d2[v[i]]+=1\nassert n-max(d1)-max(d2)<0\nprint(n-max(d1)-max(d2))\n', 'n=int(input())\nv=list(map(int,input().split()))\nd1=[0]*(10**5+1)\nd2=[0]*(10**5+1)\n\nfor i in range(n):\n if i%2==0:\n d1[v[i]]+=1\n else:\n d2[v[i]]+=1\nif d1.index(max(d1))==d2.index(max(d2)):\n d1n=sorted(d1,reverse=True)\n d2n=sorted(d2,reverse=True)\n if d1n[1]>d2n[1]:\n print(n-d1n[1]-d2n[0])\n else:\n print(n-d1n[0]-d2n[1])\nelse:\n print(n-max(d1)-max(d2))']
|
['Runtime Error', 'Accepted']
|
['s030256023', 's058410745']
|
[20684.0, 20612.0]
|
[67.0, 79.0]
|
[219, 400]
|
p03244
|
u268318377
| 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()))\ncountA = []\ncountB = []\nif len(set(V)) == 1:\n print(n//2)\nelse:\n A = V[::2]\n B = V[1::2]\n for i in range(N//2):\n countA.append(A.count(A[i]))\n countB.append(B.count(B[i]))\n max_countA = max(countA)\n max_countB = max(countB)\n \n print(len(A)-max_countA + len(A)-max_countB)', 'n = int(input())\nV = list(map(int, input().split()))\nif len(set(V)) == 1:\n print(n//2)\nelse:\n A = V[::2]\n B = V[1::2]\n for _ in range(N//2):\n countA = [A.count(a) for a in set(A)]\n countB = [B.count(b) for b in set(B)]\n max_countA = max(countA)\n max_countB = max(countB)\n \n print(len(A)-max_countA + len(A)-max_countB)', 'n = int(input())\nV = list(map(int, input().split()))\ncountA = []\ncountB = []\nif len(set(V)) == 1:\n print(n//2)\nelse:\n A = V[::2]\n B = V[1::2]\n for i in range(n//2):\n print(A.count(A[i]))\n countA.append(A.count(A[i]))\n countB.append(B.count(B[i]))\n max_countA = max(countA)\n max_countB = max(countB)\n \n print(len(A)-max_countA + len(A)-max_countB)', 'from collections import Counter\nfrom statistics import mode\n\n\nn = int(input())\nV = list(map(int, input().split()))\n\nA = V[::2]\nB = V[1::2]\ncountA = sorted(list(Counter(A).items()), key=lambda x: -x[1])\ncountB = sorted(list(Counter(B).items()), key=lambda x: -x[1])\nif len(set(V)) == 1:\n print(n//2)\nelif countA[0][0] != countB[0][0]:\n print(len(A)-countA[0][1] + len(B)-countB[0][1])\nelse:\n print(min(\n len(A)-countA[0][1] + len(B)-countB[1][1],\n len(A)-countA[1][1] + len(B)-countB[0][1]\n ))']
|
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
|
['s520154981', 's673258308', 's815144524', 's542526438']
|
[15484.0, 15484.0, 15844.0, 27008.0]
|
[46.0, 48.0, 2104.0, 114.0]
|
[362, 356, 391, 522]
|
p03244
|
u272557899
| 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.
|
['s2.sort(reverse=True)\nt2.sort(reverse=True)\nsc = -1\ntc = -1\nsk = 0\ntk = 0\n\nfor i in s2:\n if sc == -1:\n sk = i\n elif sc == 0:\n sk = i\n break\n sc += 1\nif sc == 0:\n sk = 0\n\nfor i in t2:\n if tc == -1:\n tk = i\n elif tc == 0:\n tk = i\n break\n tc += 1\nif tc == 0:\n tk = 0\n\nif q[s.index(max(s))] != r[t.index(max(t))]:\n print(n - max(s) - max(t))\nelse:\n if sk >= tk:\n print(n - sk - max(t))\n else:\n print(n - max(s) - tk)\n', 'import copy\nn = int(input())\nv = input().split()\n\nx = []\ny = []\n\nfor i in range(n):\n if i % 2 == 0:\n x.append(v[i])\n else:\n y.append(v[i])\n\nx.sort()\ny.sort()\n\nq = []\nr = []\ns = []\nt = []\ncountx = 1\ncounty = 1\n\nfor j in range(int(n / 2)):\n if x[j - 1] == x[j] and j != 0:\n countx += 1\n if j == n / 2 - 1:\n s.append(countx)\n q.append(x[j])\n countx = 1\n elif x[j - 1] != x[j] and j != 0:\n s.append(countx)\n q.append(x[j - 1])\n countx = 1\n\n\nfor k in range(int(n / 2)):\n if y[k - 1] == y[k] and k != 0:\n county += 1\n if k == n / 2 - 1:\n t.append(county)\n r.append(y[k])\n county = 1\n elif y[k - 1] != y[k] and k != 0:\n t.append(county)\n r.append(y[k - 1])\n county = 1\ns2 = copy.deepcopy(s)\nt2 = copy.deepcopy(t)\n#a = [int(m) for m in a]\ns2.sort(reverse=True)\nt2.sort(reverse=True)\nsc = -1\ntc = -1\nsk = 0\ntk = 0\n\nssym = 0\nfor i in s2:\n if sc == -1:\n sk = i\n elif sc == 0:\n sk = i\n ssym = 1\n break\n sc += 1\nif sc == 0 and ssym == 0:\n sk = 0\n\ntsym = 0\nfor i in t2:\n if tc == -1:\n tk = i\n elif tc == 0:\n tk = i\n tsym = 1\n break\n tc += 1\nif tc == 0 and tsym == 0:\n tk = 0\n\nif q[s.index(max(s))] != r[t.index(max(t))]:\n print(n - max(s) - max(t))\nelse:\n if sk >= tk:\n print(n - sk - max(t))\n else:\n print(n - max(s) - tk)\n']
|
['Runtime Error', 'Accepted']
|
['s523550904', 's547697487']
|
[3064.0, 13556.0]
|
[17.0, 268.0]
|
[502, 1449]
|
p03244
|
u276204978
| 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 c1 = Counter(v[0::2])\n c2 = Counter(v[1::2])\n \n c1m = c1.most_common(1)[0]\n c2m = c2.most_common(1)[0]\n \n ans1 = n//2-c2m[1]\n if c1m[0] != c2m[0]:\n ans1 += n//2-c1m[1]\n else:\n ans1 += n//2-c1.most_common(2)[1][1]\n \n ans2 += n//2-c1m[1]\n if c1m[0] != c2m[0]:\n ans2 += n//2-c2m[1]\n else:\n ans2 += n//2-c2.most_common(2)[1][1]\n print(min(ans1, ans2))', '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 c1 = Counter(v[0::2])\n c2 = Counter(v[1::2])\n \n c1m = c1.most_common(1)[0]\n c2m = c2.most_common(1)[0]\n \n ans1 = n//2-c2m[1]\n if c1m[0] != c2m[0]:\n ans1 += n//2-c1m[1]\n else:\n ans1 += n//2-c1.most_common(2)[1][1]\n \n ans2 += n//2-c1m[1]\n if c1m[0] != c2m[0]:\n ans2 += n//2-c2m[1]\n else:\n ans2 += n//2-c2.most_common(2)[1][1]\n print(min(ans1, ans2))', '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 c1 = Counter(v[0::2])\n c2 = Counter(v[1::2])\n \n c1m = c1.most_common(2)\n c2m = c2.most_common(2)\n \n if c1m[0][0] != c2m[0][0]:\n print(n-c1m[0][1]-c2m[0][1])\n else:\n mn = n\n if len(set(c1)) > 1:\n mn = min(mn, n-c1m[1][1]-c2m[0][1])\n if len(set(c2)) > 1:\n mn = min(mn, n-c1m[0][1]-c2m[1][1])\n \n print(mn)']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s028937778', 's723740251', 's482269742']
|
[18652.0, 3060.0, 18652.0]
|
[89.0, 17.0, 94.0]
|
[548, 548, 525]
|
p03244
|
u278057806
| 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\nVodd = V[: len(V):2]\nVeven = V[1: len(V):2]\n\nfor i in range(n):\n if V[0] != V[i]:\n break\n elif i == n - 1:\n print(min(len(Veven), len(Vodd)))\n exit()\n\n\nVoc = Counter(Vodd)\nVec = Counter(Veven)\n\nnum = Voc.most_common()[0][1] + Voc.most_common()[0][1]\n\nif Voc.most_common()[0][0] == Vec.most_common()[0][0]:\n if len(Vodd) - Voc.most_common()[0][1] < len(Veven) - Vec.most_common()[0][1]:\n num -= Voc.most_common()[0][1]\n num += Voc.most_common()[1][1]\n else:\n num -= Vec.most_common()[0][1]\n num += Vec.most_common()[1][1]\n\n\nprint(n - num)\n', 'from collections import Counter\n\nn = int(input())\nV = list(map(int, input().split()))\n\nVodd = V[: len(V):2]\nVeven = V[1: len(V):2]\n\nfor i in range(n):\n if V[0] != V[i]:\n break\n elif i == n - 1:\n print(min(len(Veven), len(Vodd)))\n exit()\n\n\nVoc = Counter(Vodd)\nVec = Counter(Veven)\n\nnum = Voc.most_common()[0][1] + Voc.most_common()[0][1]\n\nif Voc.most_common()[0][0] == Vec.most_common()[0][0]:\n if len(Vodd) - Voc.most_common()[0][1] < len(Veven) - Voc.most_common()[0][1]:\n num -= Voc.most_common()[0][1]\n num += Voc.most_common()[1][1]\n else:\n num -= Vec.most_common()[0][1]\n num += Vec.most_common()[1][1]\n\n\nprint(n - num)\n', 'from collections import Counter\n\nn = int(input())\nV = list(map(int, input().split()))\n\nVodd = V[: len(V):2]\nVeven = V[1: len(V):2]\n\nVoc = Counter(Vodd)\nVec = Counter(Veven)\n\nVoc_val, Voc_cnt = zip(*Voc.most_common())\nVec_val, Vec_cnt = zip(*Vec.most_common())\n\nVoc_val, Voc_cnt = list(Voc_val), list(Voc_cnt)\nVec_val, Vec_cnt = list(Vec_val), list(Vec_cnt)\n\nnum = Voc.most_common()[0][1] + Vec.most_common()[0][1]\n\nif Voc_val[0] == Vec_val[0]:\n Voc_cnt.append(0)\n Vec_cnt.append(0)\n num += max(Voc_cnt[1] - Voc_cnt[0], Vec_cnt[1] - Vec_cnt[0])\n\nprint(n - num)\n']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s305276465', 's896446841', 's912753234']
|
[19040.0, 19040.0, 22660.0]
|
[138.0, 138.0, 155.0]
|
[686, 686, 569]
|
p03244
|
u278670845
| 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\nn = int(input())\na = list(map(int, input().split()))\nx1, x2 = [], []\ny1, y2 = [], []\nfor i in range(n//2):\n if not a[2*i] in x1:\n x1.append(a[2*i])\n y1.append(1)\n else:\n y1[x1.index(a[2*i])] += 1\n \n if not a[2*i+1] in x2:\n x2.append(a[2*i+1])\n y2.append(1)\n else:\n y2[x2.index(a[2*i+1])] += 1\nprint(x1,y1,x2,y2)\nif len(x1)==1 and len(x2)==1 and x1[0]!=x2[0]:\n print(0)\n sys.exit()\n\ntotal = 0\nif x1[y1.index(max(y1))]!=x2[y2.index(max(y2))]:\n total = sum(y1)-max(y1) + sum(y2) - max(y2)\nelif len(x1)==1:\n y3 = y2.remove(x2.index(x1[0]))\n total = sum(y1)-max(y1) + sum(y2) - max(y3)\nelif len(x2)==1:\n y3 = y1.remove(x1.index(x2[0]))\n total = sum(y1)-max(y3) + sum(y2) - max(y2)\nelse:\n y3 = y1.remove(max(y1))\n y4 = y2.remove(max(y2))\n if max(y3) >= max(y4):\n total = sum(y1) - max(y3) + sum(y2) - max(y2)\n else:\n total = sum(y1) - max(y1) + sum(y2) - max(y4)\nprint(total)', 'from collections import Counter\n \ndef f(n,v):\n\ta=Counter(v[0::2]).most_common()\n\tb=Counter(v[1::2]).most_common()\n\t\n\ta.append([0,0])\n\tb.append([0,0])\n\tif a[0][0]!=b[0][0]:\n\t\treturn n-(a[0][1]+b[0][1])\n\telse:\n\t\treturn min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1]))\n \nif __name__=="__main__":\n\tx=int(input())\n\tdata=[int(i) for i in input().split()]\n\tprint(f(x,data))']
|
['Runtime Error', 'Accepted']
|
['s394858839', 's805783313']
|
[14120.0, 20692.0]
|
[2104.0, 90.0]
|
[920, 362]
|
p03244
|
u282228874
| 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 = [0]*10000000\nb = [0]*10000000\nv1=[]\nv2=[]\n\nif len(set(V)) == 1:\n print(n//2)\n\nelse:\n for i in range(n):\n if i%2 == 0:\n a[V[i]-1] += 1\n v1.append(V[i])\n else:\n b[V[i]-1] += 1\n v2.append(V[i])\n\n max1 = 0\n max2 = 0\n\n for j in range(len(a)):\n if max1 < a[j]:\n max1 = a[j]\n c1 = j\n for k in range(len(b)):\n if max2 < b[k]:\n max2=b[k]\n c2=k\n\n if c1 != c2:\n print(n-max1-max2)\n else:\n a.sort()\n b.sort()\n print(min(n-max1-b[-2],n-max2-a[-2]))\n', 'from collections import Counter\nN = int(input())\nV = list(map(int,input().split()))\nzero = Counter(V[::2]).most_common()\none = Counter(V[1::2]).most_common()\nif zero[0][0] != one[0][0]:\n print(N-zero[0][1]-one[0][1])\nelse:\n if len(zero) == 1 and len(one) == 1:\n print(N//2)\n elif len(zero) == 1:\n print(N-zero[0][1]-one[1][1])\n elif len(one) == 1:\n print(N-zero[1][1]-one[0][1])\n else:\n print(min(N-zero[1][1]-one[0][1],N-zero[0][1]-one[1][1]))']
|
['Time Limit Exceeded', 'Accepted']
|
['s693879011', 's749152814']
|
[172132.0, 20700.0]
|
[2105.0, 87.0]
|
[660, 487]
|
p03244
|
u284124455
| 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())\n\nc = [int(x) for x in input().split()]\n\neven = [[int(x),0] for x in range(1,10**5+1)]\n\nodd = [[int(x),0] for x in range(1,10**5/2+1)]\n\nfor i in range(len(c)):\n if i % 2 == 0:\n even[c[i]][1] += 1\n else:\n odd[c[i]][1] += 1\n\neven = sorted(even,key = lambda x:-x[1])\nodd = sorted(odd,key = lambda x:-x[1])\n\nif even[0][0] == odd[0][0]:\n print(min(n-even[0][1]-odd[1][1],n-even[1][1]-odd[0][1]))\nelse:\n print(n-even[0][1]-odd[0][1])\n', 'n = int(input())\n\nc = [int(x) for x in input().split()]\n\neven = [[int(x),0] for x in range(1,10**5/2+1)]\n\nodd = [[int(x),0] for x in range(1,10**5+1/2+1)]\n\nfor i in range(len(c)):\n if i % 2 == 0:\n even[c[i]][1] += 1\n else:\n odd[c[i]][1] += 1\n\neven = sorted(even,key = lambda x:-x[1])\nodd = sorted(odd,key = lambda x:-x[1])\n\nif even[0][0] == odd[0][0]:\n print(min(n-even[0][1]-odd[1][1],n-even[1][1]-odd[0][1]))\nelse:\n print(n-even[0][1]-odd[0][1])\n', 'n = int(input())\n\nc = [int(x) for x in input().split()]\n\neven = [[int(x),0] for x in range(10**5+1)]\n\nodd = [[int(x),0] for x in range(10**5+1)]\n\nfor i in range(len(c)):\n if i % 2 == 0:\n even[c[i]][1] += 1\n else:\n odd[c[i]][1] += 1\n\neven = sorted(even,key = lambda x:-x[1])\nodd = sorted(odd,key = lambda x:-x[1])\n\nif even[0][0] == odd[0][0]:\n print(min(n-even[0][1]-odd[1][1],n-even[1][1]-odd[0][1]))\nelse:\n print(n-even[0][1]-odd[0][1])\n']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s230224876', 's949014486', 's258957377']
|
[20784.0, 14404.0, 35848.0]
|
[85.0, 44.0, 209.0]
|
[470, 474, 464]
|
p03244
|
u286955577
| 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 math import min\n\nN = int(input())\n\narr = [input() for i in range(0,N)]\n\nodd = arr[0::2]\neven = arr[1::2]\n\nodd_counter = Counter(odd)\neven_counter = Counter(even)\n\nodd_mode = odd_counter.most_common()[0][0]\neven_mode = even_counter.most_common()[0][0]\n\nodd_diff = (N / 2) - odd_counter.most_common()[0][1]\neven_diff = (N / 2) - even_counter.most_common()[0][1]\n\nif odd_mode != even_mode:\n\tprint(odd_diff + even_diff)\nelse:\n \todd_diff2 = (N / 2) - odd_counter.most_common()[1][1]\n\teven_diff2 = (N / 2) - even_counter.most_common()[1][1]\n if odd_diff2 > even_diff2:\n\t\tprint(odd_diff + even_diff2)\n else:\n\t\tprint(odd_diff2 + even_diff)', 'from collections import Counter\n\nN = int(input())\n\narr = [input() for i in range(0,N)]\n\nodd = arr[0::2]\neven = arr[1::2]\n\nodd_counter = Counter(odd)\neven_counter = Counter(even)\n\nodd_mode = odd_counter.most_common()[0][0]\neven_mode = even_counter.most_common()[0][0]\n\nodd_diff = (N / 2) - odd_counter.most_common()[0][1]\neven_diff = (N / 2) - even_counter.most_common()[0][1]\n\nif odd_mode != even_mode:\n\tprint(odd_diff + even_diff)\nelse:\n \todd_diff2 = (N / 2) - odd_counter.most_common()[1][1]\n\teven_diff2 = (N / 2) - even_counter.most_common()[1][1]\n if odd_diff2 > even_diff2:\n\t\tprint(odd_diff + even_diff2)\n else:\n\t\tprint(odd_diff2 + even_diff)\n', "from collections import Counter\n\nN = int(input())\n\narr = list(map(int, input().split(' ')))\n\nprint(arr)\n\nodd = arr[0::2]\neven = arr[1::2]\n\nodd_counter = Counter(odd)\neven_counter = Counter(even)\n\nprint(odd_counter.most_common())\nprint(even_counter.most_common())\n\nodd_mode = odd_counter.most_common()[0][0]\neven_mode = even_counter.most_common()[0][0]\n\nodd_diff = (N / 2) - odd_counter.most_common()[0][1]\neven_diff = (N / 2) - even_counter.most_common()[0][1]\n\nif odd_mode != even_mode:\n\tprint(int(odd_diff + even_diff))\n\nelif odd_diff == N /2:\n\tprint(N / 2)\nelse:\n\todd_diff2 = (N / 2) - odd_counter.most_common()[1][1]\n\teven_diff2 = (N / 2) - even_counter.most_common()[1][1]\n\tif odd_diff2 > even_diff2:\n\t\tprint(int(odd_diff + even_diff2))\n\telse:\n\t\tprint(int(odd_diff2 + even_diff))\n", "from collections import Counter\n\nN = int(input())\n\narr = list(map(int, input().split(' ')))\n\nodd = arr[0::2]\neven = arr[1::2]\n\nodd_counter = Counter(odd)\neven_counter = Counter(even)\n\nodd_mode = odd_counter.most_common()[0][0]\neven_mode = even_counter.most_common()[0][0]\n\nodd_diff = (N / 2) - odd_counter.most_common()[0][1]\neven_diff = (N / 2) - even_counter.most_common()[0][1]\n\nif odd_mode != even_mode:\n\tprint(int(odd_diff + even_diff))\nelif odd_diff == 0:\n\tprint(int(N / 2))\nelse:\n\todd_diff2 = (N / 2) - odd_counter.most_common()[1][1]\n\teven_diff2 = (N / 2) - even_counter.most_common()[1][1]\n\tif odd_diff2 > even_diff2:\n\t\tprint(int(odd_diff + even_diff2))\n\telse:\n\t\tprint(int(odd_diff2 + even_diff))\n"]
|
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
|
['s364228754', 's562933580', 's716365891', 's465051978']
|
[3064.0, 3064.0, 21568.0, 19040.0]
|
[17.0, 17.0, 178.0, 123.0]
|
[674, 654, 785, 706]
|
p03244
|
u294385082
| 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()))\nd1 = {}\nd2 = {}\n\nfor i in range(0,n//2+2,2):\n a1 = v[i]\n a2 = v[i+1]\n print(a1,a2)\n if a1 not in d1:\n d1[a1] = 1\n else:\n d1[a1] += 1\n \n if a2 not in d2:\n d2[a2] = 1\n else:\n d2[a2] += 1\n\n\nl1 = list(sorted(d1.items(), key=lambda x:x[1]))\nl2 = list(sorted(d2.items(), key=lambda x:x[1]))\n\n\nif len(set(v)) == 1:\n print(n//2)\n\nif l1[-1][0] == l2[-1][0] and len(l1) >= 2 and len(l2) >= 2:\n print(min(n - l1[-1][1] - l2[-2][1],n - l1[-2][1] - l2[-1][1]))\nelif l1[-1][0] == l2[-1][0] and len(l1) == 1 and len(l2) >= 2:\n print(n - l1[-1][1] - l2[-2][1])\nelif l1[-1][0] == l2[-1][0] and len(l1) >= 2 and len(l2) == 1:\n print(n - l1[-2][1] - l2[-1][1])\nelse:\n print(n - l1[-1][1] - l2[-1][1])', 'n = int(input())\nv = list(map(int,input().split()))\nd1 = {}\nd2 = {}\n\nfor i in range(0,n//2):\n a1 = v[2*i]\n a2 = v[2*i+1]\n \n if a1 not in d1:\n d1[a1] = 1\n else:\n d1[a1] += 1\n \n if a2 not in d2:\n d2[a2] = 1\n else:\n d2[a2] += 1\n\n\nl1 = list(sorted(d1.items(), key=lambda x:x[1]))\nl2 = list(sorted(d2.items(), key=lambda x:x[1]))\n\n\nif len(set(v)) == 1:\n print(n//2)\n exit()\nif l1[-1][0] == l2[-1][0] and len(l1) >= 2 and len(l2) >= 2:\n print(min(n - l1[-1][1] - l2[-2][1],n - l1[-2][1] - l2[-1][1]))\nelif l1[-1][0] == l2[-1][0] and len(l1) == 1 and len(l2) >= 2:\n print(n - l1[-1][1] - l2[-2][1])\nelif l1[-1][0] == l2[-1][0] and len(l1) >= 2 and len(l2) == 1:\n print(n - l1[-2][1] - l2[-1][1])\nelse:\n print(n - l1[-1][1] - l2[-1][1])']
|
['Wrong Answer', 'Accepted']
|
['s549207454', 's708266726']
|
[25628.0, 32252.0]
|
[89.0, 96.0]
|
[760, 756]
|
p03244
|
u297109012
| 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 solve(V):\n n = len(V)\n odd = Counter()\n even = Counter()\n total = Counter()\n for i, c in enumerate(V):\n total.update([c])\n if i % 2 == 0:\n even.update([c])\n else:\n odd.update([c])\n\n total_max = total.most_common()[0]\n if total_max[1] == len(V):\n return len(V) / 2\n\n even_maxs = even.most_common(2)\n odd_maxs = odd.most_common(2)\n if len(odd_maxs) > 1:\n odd_max, odd_2nd_max = odd_maxs[0], odd_maxs[1]\n else:\n odd_max, odd_2nd_max = odd_maxs[0], None\n\n if len(even_maxs) > 1:\n even_max, even_2nd_max = even_maxs[0], even_maxs[1]\n else:\n even_max, even_2nd_max = even_maxs[0], None\n\n ans = 0\n if odd_max[0] != even_max[0]:\n return n - odd_maxs[0][0] - even_maxs[0][0]\n elif odd_2nd_max != None and even_2nd_max == None:\n return n - odd_maxs[1][0] - even_maxs[0][1]\n elif odd_2nd_max == None and even_2nd_max != None:\n return n - odd_maxs[0][1] - even_maxs[1][1]\n else: # odd_2nd_max != None and even_2nd_max != None:\n return n - max(even_maxs[0][1] + odd_maxs[1][1], \n even_maxs[1][1] + odd_maxs[0][1])\n\n for key, count in even.items():\n if key != even_max:\n ans += count\n for key, count in odd.items():\n if key != odd_max:\n ans += count\n return ans\n\n\nif __name__ == "__main__":\n n = int(input())\n l = input()\n print(solve(l.split(" ")))\n', 'from collections import Counter\n\n\ndef solve(V):\n n = len(V)\n odd = Counter()\n even = Counter()\n total = Counter()\n for i, c in enumerate(V):\n total.update([c])\n if i % 2 == 0:\n even.update([c])\n else:\n odd.update([c])\n\n total_max = total.most_common()[0]\n if total_max[1] == len(V):\n return len(V) / 2\n\n even_maxs = even.most_common(2)\n odd_maxs = odd.most_common(2)\n if len(odd_maxs) > 1:\n odd_max, odd_2nd_max = odd_maxs[0], odd_maxs[1]\n else:\n odd_max, odd_2nd_max = odd_maxs[0], None\n\n if len(even_maxs) > 1:\n even_max, even_2nd_max = even_maxs[0], even_maxs[1]\n else:\n even_max, even_2nd_max = even_maxs[0], None\n\n ans = 0\n if odd_max[0] != even_max[0]:\n return n - odd_maxs[0][1] - even_maxs[0][1]\n elif odd_2nd_max != None and even_2nd_max == None:\n return n - odd_maxs[1][1] - even_maxs[0][1]\n elif odd_2nd_max == None and even_2nd_max != None:\n return n - odd_maxs[0][1] - even_maxs[1][1]\n else: # odd_2nd_max != None and even_2nd_max != None:\n return n - max(even_maxs[0][1] + odd_maxs[1][1],\n even_maxs[1][1] + odd_maxs[0][1])\n\n for key, count in even.items():\n if key != even_max:\n ans += count\n for key, count in odd.items():\n if key != odd_max:\n ans += count\n return ans\n', 'from collections import Counter\n\n\ndef solve(V):\n n = len(V)\n odd = Counter()\n even = Counter()\n total = Counter()\n for i, c in enumerate(V):\n total.update([c])\n if i % 2 == 0:\n even.update([c])\n else:\n odd.update([c])\n\n total_max = total.most_common()[0]\n if total_max[1] == len(V):\n return len(V) / 2\n\n even_maxs = even.most_common(2)\n odd_maxs = odd.most_common(2)\n if len(odd_maxs) > 1:\n odd_max, odd_2nd_max = odd_maxs[0], odd_maxs[1]\n else:\n odd_max, odd_2nd_max = odd_maxs[0], None\n\n if len(even_maxs) > 1:\n even_max, even_2nd_max = even_maxs[0], even_maxs[1]\n else:\n even_max, even_2nd_max = even_maxs[0], None\n\n ans = 0\n if odd_max[0] != even_max[0]:\n odd_max = odd_max[0]\n even_max = even_max[0]\n elif odd_2nd_max != None and even_2nd_max == None:\n even_max = even_max[0]\n odd_max = odd_2nd_max[0]\n elif odd_2nd_max == None and even_2nd_max != None:\n odd_max = odd_max[0]\n even_max = even_2nd_max[0]\n else: # odd_2nd_max != None and even_2nd_max != None:\n return n - max(even_maxs[0][1] + odd_maxs[1][1], \n even_maxs[1][1] + odd_maxs[0][1])\n\n for key, count in even.items():\n if key != even_max:\n ans += count\n for key, count in odd.items():\n if key != odd_max:\n ans += count\n return ans\n', 'from collections import Counter\n\n\ndef solve(V):\n n = len(V)\n odd = Counter(V[1::2])\n even = Counter(V[::2])\n\n even_max = even.most_common(2)\n odd_max = odd.most_common(2)\n\n if odd_max[0][0] != even_max[0][0]:\n return n - odd_max[0][0] - even_max[0][0]\n elif len(odd_max[0][0]) != 1 and len(even_max[0][0]) == 1:\n return n - odd_max[1][0] - even_max[0][1]\n elif len(odd_max[0][0]) == 1 and len(even_max[0][0]) != 1:\n return n - odd_max[0][1] - even_max[1][1]\n else:\n return n - max(even_max[0][1] + odd_max[1][1],\n even_max[1][1] + odd_max[0][1])\n\nif __name__ == "__main__":\n n = int(input())\n l = input()\n print(solve(l.split(" ")))\n', 'from collections import Counter\n\n\ndef solve(V):\n n = len(V)\n odd_max = Counter(V[1::2]).most_common(2)\n even_max = Counter(V[::2]).most_common(2)\n\n if odd_max[0][0] != even_max[0][0]:\n return n - odd_max[0][1] - even_max[0][1]\n elif len(odd_max) == 1 and len(even_max) == 1:\n return n // 2\n elif len(odd_max) != 1 and len(even_max) == 1:\n return n - odd_max[1][1] - even_max[0][1]\n elif len(odd_max) == 1 and len(even_max) != 1:\n return n - odd_max[0][1] - even_max[1][1]\n else:\n return n - max(even_max[0][1] + odd_max[1][1],\n even_max[1][1] + odd_max[0][1])\n\nif __name__ == "__main__":\n n = int(input())\n l = input()\n print(solve(l.split(" ")))\n']
|
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s226368055', 's289102805', 's668191915', 's970789180', 's359647272']
|
[31780.0, 3316.0, 3316.0, 19876.0, 16800.0]
|
[663.0, 21.0, 21.0, 69.0, 65.0]
|
[1511, 1413, 1446, 719, 738]
|
p03244
|
u300579805
| 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 numpy as np\nfrom fractions import gcd\nimport fractions\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nodd = []\neven = []\nfor i in range(N):\n if (i%2 != 0):\n odd.append(A[i])\n else:\n even.append(A[i])\n\nodd_c = collections.Counter(odd)\neven_c = collections.Counter(even)\n\nodd_sorted = dict(sorted(odd_c.items(), key=lambda x:x[1], reverse=True))\neven_sorted = dict(sorted(even_c.items(), key=lambda x:x[1], reverse=True))\n\nodd_keys = list(odd_sorted.keys())\neven_keys = list(even_sorted.keys())\n\nans = 0\nif (even_keys[0] != odd_keys[0]):\n for i in range(N):\n if (i%2 != 0 and A[i] != odd_keys[0]):\n ans += 1\n elif (i%2 == 0 and A[i] != even_keys[0]):\n ans += 1\nelif(len(even_keys) >= 2 and len(odd_keys) >=2):\n tmp1 = 0\n tmp2 = 0\n for i in range(N):\n if (i%2 != 0 and A[i] != odd_keys[0]):\n tmp1 += 1\n elif (i%2 == 0 and A[i] != even_keys[1]):\n tmp1 += 1\n for i in range(N):\n if (i%2 != 0 and A[i] != odd_keys[1]):\n tmp2 += 1\n elif (i%2 == 0 and A[i] != even_keys[0]):\n tmp2 += 1\n ans = min(tmp1,tmp2)\nelif(len(even_keys) == 1 and len(odd_keys) ==1):\n ans = N//2\nelse:\n ans = min(even_keys[-1], odd_keys[-1])\nprint(ans)', 'import math\nimport numpy as np\nfrom fractions import gcd\nimport fractions\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nC = collections.Counter(A)\nc_sorted = dict(sorted(C.items(), key=lambda x:x[1], reverse=True))\n\nval = list(c_sorted.values())\nif (len(val) == 1):\n print(val[0]//2)\nelse:\n print(sum(val[2:]))\n', 'import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\nodd = [0] * (n//2)\neven = [0] * (n//2)\nfor i in range(n):\n if i % 2 == 0:\n even[i//2] = v[i]\n else:\n odd[i//2] = v[i]\n\neven_cnt = collections.Counter(even)\nodd_cnt = collections.Counter(odd)\n\n\nif even_cnt.most_common()[0][0] != odd_cnt.most_common()[0][0]:\n ans = n - even_cnt.most_common()[0][1]- odd_cnt.most_common()[0][1]\nelse:\n if even_cnt.most_common()[0][1] == odd_cnt.most_common()[0][1]:\n if len(even_cnt.most_common()) >= 2:\n ans = n - even_cnt.most_common()[0][1]- max(even_cnt.most_common()[1][1],odd_cnt.most_common()[1][1])\n else:\n ans = n//2\n else:\n if even_cnt.most_common()[0][1] > odd_cnt.most_common()[0][1]:\n ans = n - even_cnt.most_common()[0][1] - odd_cnt.most_common()[1][1]\n else:\n ans = n - odd_cnt.most_common()[0][1] - even_cnt.most_common()[1][1]\nprint(ans)']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s180745550', 's469492078', 's541550988']
|
[36872.0, 42960.0, 19040.0]
|
[331.0, 241.0, 172.0]
|
[1315, 345, 960]
|
p03244
|
u300968187
| 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()))\ncnt_o = Counter(v[::2]).most_common(2)\ncnt_e = Counter(v[1::2]).most_common(2)\n\nmo = cnt_o[0][0]\nme = cnt_e[0][0]\nif mo == me:\n print(n - cnt_o[0][1] - cnt_e[0][1])\nelse:\n del1 = cnt_o[0][1] - cnt_o[1][1]\n del2 = cnt_e[0][1] - cnt_e[1][1]\n print(n - cnt_o[0][1] - cnt_e[0][1] + min(del1, del2))', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\ncnt_o = Counter(v[::2]).most_common(2)\ncnt_e = Counter(v[1::2]).most_common(2)\ncnt_o.append((0, 0))\ncnt_e.append((0, 0))\n\nif cnt_o[0][0] != cnt_e[0][0]:\n print(n - cnt_o[0][1] - cnt_e[0][1])\nelse:\n del1 = cnt_o[0][1] - cnt_o[1][1]\n del2 = cnt_e[0][1] - cnt_e[1][1]\n print(n - cnt_o[0][1] - cnt_e[0][1] + min(del1, del2))']
|
['Runtime Error', 'Accepted']
|
['s417247897', 's511085992']
|
[15588.0, 15588.0]
|
[73.0, 74.0]
|
[392, 418]
|
p03244
|
u301624971
| 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\ndef myAnswer(N:int,V:list) -> int:\n odd = []\n even = []\n if len(set(V)) == 1:\n return N//2\n\n for n,v in enumerate(V):\n even.append(v) if n % 2 == 0 else odd.append(v)\n \n oddCounter = collections.Counter(odd)\n evenCounter = collections.Counter(even)\n oddCounter = sorted(oddCounter.items(),key=lambda x:x[1])\n evenCounter = sorted(evenCounter.items(),key=lambda x:x[1])\n oddMAX = oddCounter[-1][0]\n evenMAX = evenCounter[-1][0]\n if oddMAX == evenMAX:\n evenLen = len(evenCounter)\n oddLen = len(oddCounter)\n if evenLen >= 2 and oddLen >= 2:\n if evenCounter[-2][1] > oddCounter[-2][1]:\n evenMAX = evenCounter[-2][0]\n else:\n oddMAX = oddCounter[-2][0]\n elif evenLen >= 2:\n evenMAX = evenCounter[-2][0]\n else:\n oddMAX = oddCounter[-2][0]\n\n print(oddCounter,evenCounter,oddMAX,evenMAX)\n total = 0\n for n,v in enumerate(V):\n if n % 2 == 1:\n if oddMAX != v:\n total += 1\n else:\n if evenMAX != v:\n total += 1\n return total\ndef modelAnswer():\n return\ndef main():\n N = int(input())\n V = list(map(int,input().split()))\n print(myAnswer(N,V))\n\n\nif __name__ == '__main__':\n main()\n", "\nimport collections\ndef myAnswer(N:int,V:list) -> int:\n odd = []\n even = []\n if len(set(V)) == 1:\n return N//2\n\n for n,v in enumerate(V):\n even.append(v) if n % 2 == 0 else odd.append(v)\n \n oddCounter = collections.Counter(odd)\n evenCounter = collections.Counter(even)\n oddCounter = sorted(oddCounter.items(),key=lambda x:x[1])\n evenCounter = sorted(evenCounter.items(),key=lambda x:x[1])\n oddMAX = oddCounter[-1][0]\n evenMAX = evenCounter[-1][0]\n if oddMAX == evenMAX:\n evenLen = len(evenCounter)\n oddLen = len(oddCounter)\n if evenLen >= 2 and oddLen >= 2:\n if evenCounter[-2][1] > oddCounter[-2][1]:\n evenMAX = evenCounter[-2][0]\n else:\n oddMAX = oddCounter[-2][0]\n elif evenLen >= 2:\n evenMAX = evenCounter[-2][0]\n else:\n oddMAX = oddCounter[-2][0]\n\n \n total = 0\n for n,v in enumerate(V):\n if n % 2 == 1:\n if oddMAX != v:\n total += 1\n else:\n if evenMAX != v:\n total += 1\n return total\ndef modelAnswer():\n return\ndef main():\n N = int(input())\n V = list(map(int,input().split()))\n print(myAnswer(N,V))\n\n\nif __name__ == '__main__':\n main()\n"]
|
['Wrong Answer', 'Accepted']
|
['s407893975', 's105772947']
|
[27740.0, 27880.0]
|
[129.0, 104.0]
|
[1416, 1372]
|
p03244
|
u314089899
| 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.
|
['#111c\nimport collections\nimport copy\n\nn = int(input()) \nv_list = [int(e) for e in input().split()]\n\n\n\n\n\n\n\n\n\n\nv_list_odd = [v_list[i] for i in range(n) if i%2==1]\nv_list_even = [v_list[i] for i in range(n) if i%2==0]\n\n#print(v_list_odd)\n#print(v_list_even)\n\nc = collections.Counter(v_list_odd)\nv_list_odd_counter = copy.copy(c)\nif len(c)>1:\n fix_picklist_for_v_list_odd = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1],((c.most_common(2))[1])[0],((c.most_common(2))[1])[1]]\nelse:\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1]]\n \nc = collections.Counter(v_list_even)\nv_list_even_counter = copy.copy(c)\nif len(c)>1:\n fix_picklist_for_v_list_even = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1],((c.most_common(2))[1])[0],((c.most_common(2))[1])[1]]\nelse:\n fix_picklist_for_v_list_even = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1]]\n \n\n\nif fix_picklist_for_v_list_even[0] != fix_picklist_for_v_list_odd[0]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\n\n\nelif len(fix_picklist_for_v_list_even) == 2 and len(fix_picklist_for_v_list_odd) == 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = "!"\n\nelif len(fix_picklist_for_v_list_even) == 2 and len(fix_picklist_for_v_list_odd) != 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[2]\nelif len(fix_picklist_for_v_list_even) != 2 and len(fix_picklist_for_v_list_odd) == 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[2]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\nelif fix_picklist_for_v_list_even[1]+fix_picklist_for_v_list_odd[3] > fix_picklist_for_v_list_even[3]+fix_picklist_for_v_list_odd[1]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[2]\nelif fix_picklist_for_v_list_even[1]+fix_picklist_for_v_list_odd[3]= fix_picklist_for_v_list_even[3]+fix_picklist_for_v_list_odd[1]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[2]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\n#print(fix_char_for_v_list_odd)\n#print(fix_char_for_v_list_even)\n \n\nans_odd = n/2 - v_list_odd_counter[fix_char_for_v_list_odd]\nans_even = n/2 - v_list_even_counter[fix_char_for_v_list_even]\nprint(int(ans_odd + ans_even))', '#111c\nimport collections\nimport copy\n\nn = int(input()) \nv_list = [int(e) for e in input().split()]\n\n\n\n\n\n\n\n\n\n\nv_list_odd = [v_list[i] for i in range(n) if i%2==1]\nv_list_even = [v_list[i] for i in range(n) if i%2==0]\n\n#print(v_list_odd)\n#print(v_list_even)\n\nc = collections.Counter(v_list_odd)\nv_list_odd_counter = copy.copy(c)\nif len(c)>1:\n fix_picklist_for_v_list_odd = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1],((c.most_common(2))[1])[0],((c.most_common(2))[1])[1]]\nelse:\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1]]\n \nc = collections.Counter(v_list_even)\nv_list_even_counter = copy.copy(c)\nif len(c)>1:\n fix_picklist_for_v_list_even = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1],((c.most_common(2))[1])[0],((c.most_common(2))[1])[1]]\nelse:\n fix_picklist_for_v_list_even = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1]]\n \n\n\nif fix_picklist_for_v_list_even[0] != fix_picklist_for_v_list_odd[0]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\n\n\nelif len(fix_picklist_for_v_list_even) == 2 and len(fix_picklist_for_v_list_odd) == 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = "!"\n\nelif len(fix_picklist_for_v_list_even) == 2 and len(fix_picklist_for_v_list_odd) != 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[2]\nelif len(fix_picklist_for_v_list_even) != 2 and len(fix_picklist_for_v_list_odd) == 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[2]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\nelif fix_picklist_for_v_list_even[1] + fix_picklist_for_v_list_odd[3] > fix_picklist_for_v_list_even[3]+fix_picklist_for_v_list_odd[1]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[2]\nelif fix_picklist_for_v_list_even[1] + fix_picklist_for_v_list_odd[3] =< fix_picklist_for_v_list_even[3]+fix_picklist_for_v_list_odd[1]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[2]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\n#print(fix_char_for_v_list_odd)\n#print(fix_char_for_v_list_even)\n \n\nans_odd = n/2 - v_list_odd_counter[fix_char_for_v_list_odd]\nans_even = n/2 - v_list_even_counter[fix_char_for_v_list_even]\nprint(int(ans_odd + ans_even))', '#111c\nimport collections\nimport copy\n\nn = int(input()) \nv_list = [int(e) for e in input().split()]\n\n\n\n\n\n\n\n\n\n\nv_list_odd = [v_list[i] for i in range(n) if i%2==1]\nv_list_even = [v_list[i] for i in range(n) if i%2==0]\n\n#print(v_list_odd)\n#print(v_list_even)\n\nc = collections.Counter(v_list_odd)\nv_list_odd_counter = copy.copy(c)\nif len(c)>1:\n fix_picklist_for_v_list_odd = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1],((c.most_common(2))[1])[0],((c.most_common(2))[1])[1]]\nelse:\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1]]\n \nc = collections.Counter(v_list_even)\nv_list_even_counter = copy.copy(c)\nif len(c)>1:\n fix_picklist_for_v_list_even = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1],((c.most_common(2))[1])[0],((c.most_common(2))[1])[1]]\nelse:\n fix_picklist_for_v_list_even = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1]]\n \n\n\nif fix_picklist_for_v_list_even[0] != fix_picklist_for_v_list_odd[0]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\n\n\nelif len(fix_picklist_for_v_list_even) == 2 and len(fix_picklist_for_v_list_odd) == 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = "!"\n\nelif len(fix_picklist_for_v_list_even) == 2 and len(fix_picklist_for_v_list_odd) != 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[2]\nelif len(fix_picklist_for_v_list_even) != 2 and len(fix_picklist_for_v_list_odd) == 2:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[2]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\nelif fix_picklist_for_v_list_even[1] + fix_picklist_for_v_list_odd[3] > fix_picklist_for_v_list_even[3]+fix_picklist_for_v_list_odd[1]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[2]\nelif fix_picklist_for_v_list_even[1] + fix_picklist_for_v_list_odd[3] <= fix_picklist_for_v_list_even[3] + fix_picklist_for_v_list_odd[1]:\n fix_char_for_v_list_even = fix_picklist_for_v_list_even[2]\n fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]\n\n#print(fix_char_for_v_list_odd)\n#print(fix_char_for_v_list_even)\n \n\nans_odd = n/2 - v_list_odd_counter[fix_char_for_v_list_odd]\nans_even = n/2 - v_list_even_counter[fix_char_for_v_list_even]\nprint(int(ans_odd + ans_even))']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s094528621', 's511974816', 's666398537']
|
[3064.0, 3064.0, 25168.0]
|
[17.0, 18.0, 182.0]
|
[3399, 3404, 3406]
|
p03244
|
u316386814
| 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\nv = [v[::2], v[1::2]]\n\nfrom collections import Counter\nfrom operator import itemgetter\nfrom itertools import product\nc = list(map(Counter, v))\ns = [sorted(d.items(), key=itemgetter(1), reverse=True) for d in c]\nprint(s)\ns = [(d + [(0, 0)])[:2] for d in s]\nkeep = 0\nfor e, o in product(*s):\n print(e, o)\n if e[0] == o[0]:\n continue\n tmp = e[1] + o[1]\n if tmp > keep:\n keep = tmp\nans = n - keep\nprint(ans)', 'n = int(input())\nv = list(map(int, input().split()))\n\nv = [v[::2], v[1::2]]\n\nfrom collections import Counter\nfrom operator import itemgetter\nfrom itertools import product\nc = list(map(Counter, v))\ns = [sorted(d.items(), key=itemgetter(1), reverse=True) for d in c]\ns = [(d + [(0, 0)])[:2] for d in s]\nkeep = 0\nfor e, o in product(*s):\n if e[0] == o[0]:\n continue\n tmp = e[1] + o[1]\n if tmp > keep:\n keep = tmp\nans = n - keep\nprint(ans)']
|
['Wrong Answer', 'Accepted']
|
['s115787661', 's645107574']
|
[24704.0, 20888.0]
|
[127.0, 108.0]
|
[483, 458]
|
p03244
|
u321035578
| 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 main():\n n = int(input())\n v = list(map(int,input().split()))\n\n odd = v[1::2]\n count_e = collections.Counter(even)\n count_o = collections.Counter(odd)\n ce = count_e.most_common()\n co = count_o.most_common()\n if ce[0][0] != co[0][0]:\n print(n-ce[0][1] - co[0][1])\n else:\n if len(ce) == 1 and len(co) == 1:\n print(n//2)\n elif len(ce) == 1:\n print(n-co[1][1])\n elif len(co) == 1:\n print(n-ce[1][1])\n else:\n print(min(n-ce[0][1]-co[1][1], n-ce[1][1]-co[0][1]))\n\n\n\n\nif __name__ == '__main__':\n main()\n", "import collections\ndef main():\n n = int(input())\n v = list(map(int,input().split()))\n\n even = v[::2]\n odd = v[1::2]\n count_e = collections.Counter(even)\n count_o = collections.Counter(odd)\n ce = count_e.most_common()\n co = count_o.most_common()\n if ce[0][0] != co[0][0]:\n print(n-ce[0][1] - co[0][1])\n else:\n if len(ce) == 1 and len(co) == 1:\n print(n//2)\n elif len(ce) == 1:\n print(n-co[1][1])\n elif len(co) == 1:\n print(n-ce[1][1])\n else:\n print(min(n-ce[0][1]-co[1][1], n-ce[1][1]-co[0][1]))\n\n\n\n\nif __name__ == '__main__':\n main()\n"]
|
['Runtime Error', 'Accepted']
|
['s065299276', 's831239816']
|
[14788.0, 21952.0]
|
[44.0, 86.0]
|
[628, 646]
|
p03244
|
u325956328
| 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\nimport sys\n\nN = int(input())\nV = list(map(int, input().split()))\n\nA = V[0::2]\nB = V[1::2]\n\nprint(A, B)\n\ncnt = 0\n\nif len(set(V)) == 1:\n print(N // 2)\n sys.exit()\n\nif set(A) != 1:\n cnt += len(A) - max(Counter(A).values())\nif set(B) != 1:\n cnt += len(B) - max(Counter(B).values())\n\nprint(cnt)\n', 'from collections import Counter\nimport sys\n\nN = int(input())\nV = list(map(int, input().split()))\n\nA = V[0::2]\nB = V[1::2]\n\n\n\ncnt = 0\n\nif len(set(V)) == 1:\n print(N // 2)\n sys.exit()\n\nA_counter = Counter(A)\nB_counter = Counter(B)\n\nA_top2 = A_counter.most_common(2)\nB_top2 = B_counter.most_common(2)\n\nif A_top2[0][0] != B_top2[0][0]:\n cnt += len(A) - A_top2[0][1]\n cnt += len(B) - B_top2[0][1]\nelse:\n cnt = min(\n len(A) - A_top2[0][1] + len(B) - B_top2[1][1],\n len(A) - A_top2[1][1] + len(B) - B_top2[0][1],\n )\n\nprint(cnt)']
|
['Wrong Answer', 'Accepted']
|
['s354867869', 's056818015']
|
[17764.0, 19036.0]
|
[73.0, 82.0]
|
[334, 565]
|
p03244
|
u328207927
| 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=[i for i in input().strip().split()]\n\nv1,v2=[v[i] for i in range(n) if i%2==0],[v[i] for i in range(n) if not i%2==0]\nv1c=Counter(v1).most_common()+[(0,0)]\nv2c=Counter(v2).most_common()+[(0,0)]\n\n\nprint(v1c,v2c)\nif v1c[0][0]==v2c[0][0]:\n if v1c[0][1]<v2c[1][1]:\n print(n-v1c[0][1]-v2c[1][1])\n else:\n print(n-v1c[1][1]-v2c[0][1])\nelse:\n print(n-v1c[0][1]-v2c[0][1])', 'from collections import Counter\nn=int(input())\nv=[i for i in input().strip().split()]\n\nv1,v2=[v[i] for i in range(n) if i%2==0],[v[i] for i in range(n) if not i%2==0]\nv1c=Counter(v1).most_common()+[(0,0)]\nv2c=Counter(v2).most_common()+[(0,0)]\n\nif v1c[0][0]==v2c[0][0]:\n print(min(n-v1c[0][1]-v2c[1][1],n-v1c[1][1]-v2c[0][1]))\n\nelse:\n print(n-v1c[0][1]-v2c[0][1])']
|
['Wrong Answer', 'Accepted']
|
['s536063523', 's897588399']
|
[24916.0, 23636.0]
|
[149.0, 106.0]
|
[435, 368]
|
p03244
|
u328755070
| 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 as cole\n\n\nn = int(input())\nv = list(map(int, input().split()))\n\nv1 = v[::2] #odd\nv2 = v[1::2] #even\n\nd1 = cole.Counter(v1)\nd2 = cole.Counter(v2)\n\nvalues1, counts1 = zip(*d1.most_common())\nvalues2, counts2 = zip(*d2.most_common())\n\nmax1 = values1[0]\nmax2 = values2[0]\n\nif max1 == max2:\n if len(counts1) != 1 and counts1[0] == counts1[1]:\n max1 = values[1]\n elif len(counts2) != 1 and counts2[0] == counts[1]:\n max2 = values[1]\n elif len(counts1) != 1 and len(counts2) != 1:\n if counts1[1] > counts2[1]:\n max1 = values1[1]\n else:\n max2 = values2[1]\n elif len(counts1) != 1:\n max1 = values1[1]\n elif len(counts2) != 1:\n max2 = values2[1]\n\nprint(max1, max2)\ncount = 0\nif max1 != max2:\n count += len([x for x in v1 if x != max1])\n count += len([y for y in v2 if y != max2])\n\nelse:\n count += len(v1)\n\n\nprint(count)\n', 'import collections as cole\n\n\nn = int(input())\nv = list(map(int, input().split()))\n\nv1 = v[::2] #odd\nv2 = v[1::2] #even\n\nd1 = cole.Counter(v1)\nd2 = cole.Counter(v2)\n\nvalues1, counts1 = zip(*d1.most_common())\nvalues2, counts2 = zip(*d2.most_common())\n\nmax1 = values1[0]\nmax2 = values2[0]\n\nif max1 == max2:\n if len(counts1) != 1 and counts1[0] == counts1[1]:\n max1 = values1[1]\n elif len(counts2) != 1 and counts2[0] == counts2[1]:\n max2 = values2[1]\n elif len(counts1) != 1 and len(counts2) != 1:\n if counts1[1] > counts2[1]:\n max1 = values1[1]\n else:\n max2 = values2[1]\n elif len(counts1) != 1:\n max1 = values1[1]\n elif len(counts2) != 1:\n max2 = values2[1]\n\n\ncount = 0\nif max1 != max2:\n count += len([x for x in v1 if x != max1])\n count += len([y for y in v2 if y != max2])\n\nelse:\n count += len(v1)\n\n\nprint(count)\n']
|
['Runtime Error', 'Accepted']
|
['s222544705', 's386502688']
|
[22668.0, 22668.0]
|
[127.0, 124.0]
|
[919, 905]
|
p03244
|
u329058683
| 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())\nL=list(map(int,input().split()))\nE=[i for i in L[::2]]\nO=[i for i in L[1::2]]\ne = collections.Counter(E).most_common()\no = collections.Counter(O).most_common()\nif e[0][0] != o[0][0]:\n print(n - e[0][1] - o[0][1])\nelse:\n if len(e) == 1 or len(o) == 1:\n print(N // 2)\n else:\n a = n - e[1][1] - o[0][1]\n b = n - e[0][1] - o[1][1]\n print(min(a, b))', 'import collections\nN=int(input())\nL=list(map(int,input().split()))\nE=[i for i in L[::2]]\nO=[i for i in L[1::2]]\ne = collections.Counter(E).most_common()\no = collections.Counter(O).most_common()\nif e[0][0] != o[0][0]:\n print(N - e[0][1] - o[0][1])\nelse:\n if len(e) == 1 or len(o) == 1:\n print(N // 2)\n else:\n a = N - e[1][1] - o[0][1]\n b = N - e[0][1] - o[1][1]\n print(min(a, b))']
|
['Runtime Error', 'Accepted']
|
['s351079588', 's351039203']
|
[21084.0, 21084.0]
|
[91.0, 87.0]
|
[415, 415]
|
p03244
|
u339503988
| 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 a = Counter(v[0::2]).most_common()\n b = Counter(v[1::2]).most_common()\n\n if a[0] != b[0]:\n q = ((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[0][1]))\n w = ((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))\n e = ((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))\n print(min(q, w, e))\nelse:\n print(len(v[1::2]))\n', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\nif len(set(v)) != 1:\n a = Counter(v[0::2]).most_common()\n b = Counter(v[1::2]).most_common()\n print(a)\n print(b)\n if a[0][0] != b[0][0]:\n print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[0][1]))\n else:\n if a[0][1] < b[0][1]:\n print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))\n elif a[0][1] > b[0][1]:\n print((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))\n elif a[0][1] == b[0][1]:\n if len(a) != 1:\n print((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))\n elif len(b) != 1:\n print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))\nelse:\n print(len(v[1::2]))\n', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\nif len(set(v)) != 1:\n a = Counter(v[0::2]).most_common()\n b = Counter(v[1::2]).most_common()\n if a[0][0] != b[0][0]:\n print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[0][1]))\n else:\n if a[0][1] < b[0][1]:\n print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))\n elif a[0][1] > b[0][1]:\n print((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))\n elif a[0][1] == b[0][1]:\n if len(a) != 1 and len(b) != 1:\n if a[1][1] > b[1][1]:\n print((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))\n elif a[1][1] < b[1][1]:\n print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))\n elif a[1][1] == b[1][1]:\n print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))\n elif len(a) != 1:\n print((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))\n elif len(b) != 1:\n print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))\nelse:\n print(len(v[1::2]))\n']
|
['Runtime Error', 'Wrong Answer', 'Accepted']
|
['s507429777', 's561800949', 's114673546']
|
[20700.0, 21852.0, 20700.0]
|
[87.0, 122.0, 89.0]
|
[464, 791, 1167]
|
p03244
|
u341347211
| 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 stdin\n\nn = int(stdin.readline().rstrip())\nv = [int(i) for i in stdin.readline().rstrip().split()]\n\nleft = [0] * 10**5 + 1\nright = [0] * 10**5 + 1\n\nfor i in range(len(v)):\n if i % 2 == 0:\n left[v[i]] += 1\n else:\n right[v[i]] += 1\n\nleft_max = 0\nleft_max_second = 0\nright_max = 0\nright_max_second = 0\nleft_flag = 0\nright_flag = 0\nfor i in range(len(left)):\n if left_max < left[i]:\n left_max_second = left_max\n left_max = left[i]\n left_flag = i\n\n if right_max < right[i]:\n right_max_second = right_max\n right_max = right[i]\n right_flag = i\n\nif left_flag == right_flag:\n tmp = min(left_max + right_max_second, right_max + left_max_second)\n \n print(n - tmp)\nelse:\n print((n // 2 - left_max) + (n // 2 - right_max))\n', 'from collections import Counter\nfrom sys import stdin\n\nn = int(stdin.readline().rstrip())\na = [int(i) for i in stdin.readline().rstrip().split()]\n\neven = []\nodd = []\nfor i in range(n):\n if i % 2 == 0:\n even.append(a[i])\n else:\n odd.append(a[i])\n\neven_conter = Counter(even)\nodd_conter = Counter(odd)\n\neven_sorted = even_conter.most_common()\nodd_sorted = odd_conter.most_common()\n\neven_key1 = even_sorted[0][0]\neven_val1 = even_sorted[0][1]\nodd_key1 = odd_sorted[0][0]\nodd_val1 = odd_sorted[0][1]\n\nans = n\nif even_key1 == odd_key1:\n if len(even_sorted) >= 2:\n even_val2 = even_sorted[1][1]\n odd_val2 = odd_sorted[1][1]\n ans -= max((even_val1 + odd_val2), (odd_val1 + even_val2))\n else:\n ans -= max(even_val1, odd_val1)\nelse:\n ans -= (even_val1 + odd_val1)\n\nprint(ans)\n']
|
['Runtime Error', 'Accepted']
|
['s259366931', 's210433775']
|
[14396.0, 23776.0]
|
[45.0, 118.0]
|
[868, 824]
|
p03244
|
u344959886
| 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()))\nw=[]\nfor i in range(n//2):\n w.append(v.pop(i))\nprint(v)\nprint(w)\nimport collections\ncv = collections.Counter(v)\ncw = collections.Counter(w)\nscv = sorted(cv.items(), key=lambda x:-x[1])\nscw = sorted(cw.items(), key=lambda x:-x[1])\n\nv1=scv[0][0]\nw1=scw[0][0]\n\nif v1==w1:\n if len(scv)==1:\n v2=0\n else:\n v2=scv[1][1]\n if len(scw)==1:\n w2=0\n else:\n w2=scw[1][1]\n \n print(min(n-scv[0][1]-w2, n-scw[0][1]-v2))\n \nelse:\n print(n-scv[0][1]-scw[0][1])', 'n=int(input())\nv=list(map(int,input().split()))\nw=[]\nfor i in range(n//2):\n w.append(v.pop(i))\n\nimport collections\ncv = collections.Counter(v)\ncw = collections.Counter(w)\nscv = sorted(cv.items(), key=lambda x:-x[1])\nscw = sorted(cw.items(), key=lambda x:-x[1])\n\nv1=scv[0][0]\nw1=scw[0][0]\n\nif v1==w1:\n if len(scv)==1:\n v2=0\n else:\n v2=scv[1][1]\n if len(scw)==1:\n w2=0\n else:\n w2=scw[1][1]\n \n print(min(n-scv[0][1]-w2, n-scw[0][1]-v2))\n \nelse:\n print(n-scv[0][1]-scw[0][1])']
|
['Wrong Answer', 'Accepted']
|
['s038778249', 's228959317']
|
[21732.0, 21092.0]
|
[848.0, 840.0]
|
[551, 534]
|
p03244
|
u353797797
| 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 ct\n\nn = int(input())\ns = input().split()\na = ct(s[::2])\nb = ct(s[1::2])\nsa = sorted(a.items(), key=lambda x: -x[1])\nsb = sorted(b.items(), key=lambda x: -x[1])\nprint(sa)\nprint(sb)\n\nif sa[0][0] == sb[0][0]:\n if len(sa)*len(sb)==1:\n dt=n//2\n elif sa[0][1] - sa[1][1] < sb[0][1] - sb[1][1] or len(sb)==1:\n dt = sa[1][1] + sb[0][1]\n else:\n dt = sa[0][1] + sb[1][1]\nelse:\n dt = sa[0][1] + sb[0][1]\nprint(sum([x for x in a.values()]+[y for y in b.values()])-dt)\n', 'from collections import Counter as ct\n\nn = int(input())\ns = input().split()\na = ct(s[::2])\nb = ct(s[1::2])\nsa = sorted(a.items(), key=lambda x: -x[1])\nsb = sorted(b.items(), key=lambda x: -x[1])\nif sa[0][0] == sb[0][0]:\n if len(sa)*len(sb)==1:\n dt=n//2\n elif sa[0][1] - sa[1][1] < sb[0][1] - sb[1][1] or len(sb)==1:\n dt = sa[1][1] + sb[0][1]\n else:\n dt = sa[0][1] + sb[1][1]\nelse:\n dt = sa[0][1] + sb[0][1]\nprint(sum([x for x in a.values()]+[y for y in b.values()])-dt)\n']
|
['Wrong Answer', 'Accepted']
|
['s805834640', 's891024420']
|
[26988.0, 25572.0]
|
[125.0, 88.0]
|
[524, 503]
|
p03244
|
u362771726
| 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(n, v):\n \n if len(set(v)) == 1:\n return len(v) / 2\n\n odd = []\n even = []\n\n for i, k in enumerate(v):\n if i % 2 == 0:\n even.append(k)\n else:\n odd.append(k)\n\n odd_dic = Counter(odd).most_common()\n even_dic = Counter(even).most_common()\n\n ans = 0\n\n if odd_dic[0][0] == even_dic[0][0]:\n if odd_dic[0][1] > even_dic[0][1]:\n odd_v = odd_dic[0][0]\n even_v = even_dic[1][0]\n elif odd_dic[0][1] < even_dic[0][1]:\n odd_v = odd_dic[1][0]\n even_v = even_dic[0][0]\n else:\n if odd_dic[1][1] >= even_dic[1][1]:\n odd_v = odd_dic[1][0]\n even_v = even_dic[0][0]\n else\n odd_v = odd_dic[0][0]\n even_v = even_dic[1][0]\n else:\n odd_v = odd_dic[0][0]\n even_v = even_dic[0][0]\n\n for i in range(len(even)):\n if even_v != even[i]:\n ans += 1\n\n if odd_v != odd[i]:\n ans += 1\n\n return ans\n\ndef test():\n assert solve(4, [3, 1, 3, 2]) == 1\n assert solve(6, [105, 119, 105, 119, 105, 119]) == 0\n assert solve(4, [1, 1, 1, 1]) == 2\n\ndef main():\n n = int(input())\n v = list(map(int, input().split()))\n ans = solve(n, v)\n print(ans)\n\nif __name__ == '__main__':\n # test()\n main()", "from collections import Counter\n\ndef solve(n, v):\n \n if len(set(v)) == 1:\n return len(v) / 2\n\n odd = []\n even = []\n\n for i, k in enumerate(v):\n if i % 2 == 0:\n even.append(k)\n else:\n odd.append(k)\n\n odd_dic = Counter(odd).most_common()\n even_dic = Counter(even).most_common()\n\n ans = 0\n\n if odd_dic[0][0] == even_dic[0][0]:\n if odd_dic[0][1] > even_dic[0][1]:\n odd_v = odd_dic[0][0]\n even_v = even_dic[1][0]\n elif odd_dic[0][1] < even_dic[0][1]:\n odd_v = odd_dic[1][0]\n even_v = even_dic[0][0]\n else:\n if odd_dic[1][1] >= even_dic[1][1]:\n odd_v = odd_dic[1][0]\n even_v = even_dic[0][0]\n else:\n odd_v = odd_dic[0][0]\n even_v = even_dic[1][0]\n else:\n odd_v = odd_dic[0][0]\n even_v = even_dic[0][0]\n\n for i in range(len(even)):\n if even_v != even[i]:\n ans += 1\n\n if odd_v != odd[i]:\n ans += 1\n\n return ans\n\ndef test():\n assert solve(4, [3, 1, 3, 2]) == 1\n assert solve(6, [105, 119, 105, 119, 105, 119]) == 0\n assert solve(4, [1, 1, 1, 1]) == 2\n\ndef main():\n n = int(input())\n v = list(map(int, input().split()))\n ans = solve(n, v)\n print(int(ans))\n\nif __name__ == '__main__':\n # test()\n main()"]
|
['Runtime Error', 'Accepted']
|
['s686935615', 's894723308']
|
[3064.0, 21076.0]
|
[18.0, 112.0]
|
[1407, 1413]
|
p03244
|
u368796742
| 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()))\ndic1={}\ndic2={}\nfor i in range(n):\n if i%2==0:\n if l[i] in dic1:\n dic1[l[i]] += 1\n else:\n dic1[l[i]].append(1)\n else:\n if l[i] in dic2:\n dic2[l[i]] += 1\n else:\n dic2[l[i]].append(1)\n \ncount = 0\nma = 0\ncheck=0\nfor i in dic1.values():\n ma = max(ma,i)\n check += i\ncount += check-ma\nma = 0\ncheck=0\nfor i in dic2.values():\n ma = max(ma,i)\n check += i\ncount += check-ma\n\nprint(count)\n\n', 'n = int(input())\nl = list(map(int,input().split()))\ndic1={}\ndic2={}\nfor i in range(n):\n if i%2==0:\n if l[i] in dic1:\n dic1[l[i]] += 1\n else:\n dic1[l[i]]=1\n else:\n if l[i] in dic2:\n dic2[l[i]] += 1\n else:\n dic2[l[i]]=1\ndic1a = sorted(dic1.items(),key = lambda x:x[1])\ndic2a = sorted(dic2.items(),key = lambda x:x[1]) \n \nif dic1a[-1][0] == dic2a[-1][0]:\n if len(dic1a) == len(dic2a) == 1:\n print(n//2)\n else:\n if dic1a[-2][1] >= dic2a[-2][1]:\n print(sum(dic2.values())-dic2a[-1][1]+sum(dic1.values())-dic1a[-2][1])\n else:\n print(sum(dic1.values())-dic1a[-1][1]+sum(dic2.values())-dic2a[-2][1])\nelse:\n print(sum(dic1.values())-dic1a[-1][1]+sum(dic2.values())-dic2a[-1][1])\n']
|
['Runtime Error', 'Accepted']
|
['s397018016', 's365441531']
|
[14404.0, 22368.0]
|
[41.0, 104.0]
|
[474, 756]
|
p03244
|
u371763408
| 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()))\nif len(set(V))==1:\n print(n//2)\nelse:\n v1=Counter(V[::2])\n v2=Counter(V[1::2])\n ans=0\n if v1.most_common()[0][0]==v2.most_common()[0][0]:\n if v1.most_common()[0][1]>v2.most_common()[0][1]:\n v1_s=v1.most_common()[0][1]\n v2_s=v2.most_common()[1][1]\n else:\n v1_s=v1.most_common()[1][1]\n v2_s=v2.most_common()[0][1]\n if len(v1)!=1:\n ans+=len(list(v1.elements()))-v1_s\n if len(v2)!=1:\n ans+=len(list(v2.elements()))-v2_s\n print(ans)', 'from collections import Counter\nn=int(input())\nV=list(map(int,input().split()))\nv1=Counter(V[::2]).most_common()\nv2=Counter(V[1::2]).most_common()\nif len(v1) ==1:\n v1.append([0,0])\nif len(v2) == 1:\n v2.append([0,0])\nif v1[0][0]==v2[0][0]:\n print(min(n-v1[0][1]-v2[1][1],n-v1[1][1]-v2[0][1]))\nelse:\n print(n-v1[0][1]-v2[0][1])']
|
['Runtime Error', 'Accepted']
|
['s315143574', 's149060486']
|
[20188.0, 20700.0]
|
[137.0, 86.0]
|
[547, 329]
|
p03244
|
u373047809
| 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, b = map(lambda x: Counter(x).most_common(), [v[::2], v[1::2]])\ntry:\n print(n-a[0][1]-b[0][1] if a[0][0]!=a[0][0] else n - max(a[0][1]+b[1][1], a[1][1]+b[0][1]))\nexcept IndexError:\n print(n//2)', 'from collections import*\nn, v = map(int, open(0).read().split())\ndef l(x):\n o = Counter(x).most_common()\n return [o[0][0], o[0][1], o[1][1]]\na, b = map(l, [v[::2], v[1::2]])\nprint(n-a[1]-b[1] if a[0]!=a[0] else n - max(a[1]+b[2], a[2]+b[1])\n', 'from collections import*\nn,*v=map(int,open(0).read().split())\na,b=[Counter(v[i::2]).most_common()+[(0,0)]for i in(0,1)]\ns,x=a[0]\nt,y=b[0]\nprint(n-[x+y,max(x+b[1][1],y+a[1][1])][s==t])']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s145263196', 's820639111', 's643459922']
|
[20908.0, 3064.0, 25336.0]
|
[98.0, 18.0, 81.0]
|
[261, 247, 183]
|
p03244
|
u379692329
| 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()]\nv1 = v[::2]\nv2 = v[1::2]\n\nif v1 == v2:\n print(len(v1))\nelse:\n cv1 = Counter(v1)\n cv2 = Counter(v2)\n if cv1.most_common()[0][0] != cv2.most_common()[0][0]:\n ch1 = len(v1) - cv1.most_common()[0][1]\n ch2 = len(v2) - cv2.most_common()[0][1]\n else:\n if cv1.most_common()[0][1] > cv2.most_common()[0][1]:\n ch1 = len(v1) - cv1.most_common()[0][1]\n ch2 = len(v2) - cv2.most_common()[1][1]\n else:\n ch1 = len(v1) - cv1.most_common()[1][1]\n ch2 = len(v2) - cv2.most_common()[0][1]\n print(ch1 + ch2)', 'import sys\ninput = sys.stdin.readline\n\nn = int(input())\nv = [int(_) for _ in input().split()]\noddcnt = [[0, i] for i in range(10**5+1)]\nevencnt = [[0, i] for i in range(10**5+1)]\n\nfor i, j in enumerate(v):\n if i % 2 == 0:\n oddcnt[j][0] += 1\n else:\n evencnt[j][0] += 1\n\noddcnt = sorted(oddcnt, key=lambda x: (-x[0], x[1]))\nevencnt = sorted(evencnt, key=lambda x: (-x[0], -x[1]))\n\nif oddcnt[0][1] != evencnt[0][1]:\n print(n-oddcnt[0][0]-evencnt[0][0])\nelif oddcnt[0][0] > evencnt[0][0]:\n print(n-oddcnt[0][0]-evencnt[1][0])\nelif oddcnt[0][0] < evencnt[0][0]:\n print(n-oddcnt[1][0]-evencnt[0][0])\nelif oddcnt[1][0] > evencnt[1][0]:\n print(n-oddcnt[1][0]-evencnt[0][0])\nelse:\n print(n-oddcnt[0][0]-evencnt[1][0])']
|
['Wrong Answer', 'Accepted']
|
['s277161285', 's407194126']
|
[19040.0, 45844.0]
|
[107.0, 251.0]
|
[673, 743]
|
p03244
|
u388323466
| 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()\narr = list(map(int, input().split()))\n\na = [arr[i] for i in range(0,n,2)]\nb = [arr[y] for y in range(1,n,2)]\n\nimport collections\nacnt = collections.Counter(a)\nbcnt = collections.Counter(b)\n\namaxval = acnt[list(acnt)[0]]\nbmaxval = bcnt[list(bcnt)[0]]\n\namaxkey = list(acnt)[0]\nbmaxkey = list(bcnt)[0]\n\ndef val(ab, abcnt):\n\tif len(ab) < 2:\n\t\treturn 0\n\telse:\n\t\treturn abcnt[list(abcnt)[0]]\n\nif amaxkey != bmaxkey:\n\tans = n - amaxval - bmaxval\nelse:\n\tif amaxval >= bmaxval:\n\t\tans = n - amaxval - val(b,bcnt)\n\telse:\n\t\tans = n - val(a,acnt) - bmaxval\n\nprint(ans)\n\t\n\n\t', 'n = int(input())\narr = list(map(int, input().split()))\n\na = [arr[i] for i in range(0,n,2)]\nb = [arr[y] for y in range(1,n,2)]\n\nimport collections\nacnt = collections.Counter(a)\nbcnt = collections.Counter(b)\n\nlsacnt = sorted(acnt.items(), key=lambda x: x[1],reverse=True)\nlsbcnt = sorted(bcnt.items(), key=lambda j: j[1],reverse=True)\n\ndef val(abcnt, ablscnt):\n\tif len(list(abcnt)) < 2:\n\t\treturn 0\n\telse:\n\t\treturn ablscnt[1][1]\n\nif lsacnt[0][0] != lsbcnt[0][0]:\n\tans = n - lsacnt[0][1] - lsbcnt[0][1]\nelif lsacnt[0][0] == lsbcnt[0][0]:\n\tif lsacnt[0][1] > lsbcnt[0][1]:\n\t\tans = n - lsacnt[0][1] - val(bcnt,lsbcnt)\n\telif lsacnt[0][1] < lsbcnt[0][1]:\n\t\tans = n - val(acnt,lsacnt) - lsbcnt[0][1]\n\telif lsacnt[0][1] == lsbcnt[0][1]:\n\t\tans = n - lsacnt[0][1] - max(val(acnt,lsacnt),val(bcnt,lsbcnt))\n\nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s228361246', 's214442794']
|
[14236.0, 21776.0]
|
[41.0, 109.0]
|
[572, 803]
|
p03244
|
u396890425
| 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\nVo=V[::2]\nVe=V[1::2]\n\noddmost = collections.Counter(Vo).most_common()[0][1]\noddsec = collections.Counter(Vo).most_common()[1][1]\nevenmost = collections.Counter(Ve).most_common()[0][1]\nevensec = collections.Counter(Ve).most_common()[1][1]\n\nif oddmost!=evenmost:\n print(len(V)-oddmost-evenmost)\nelse:\n print(min(len(V)-oddmost-evensec, len(V)-evenmost-oddsec))', 'import collections\n\nn=int(input())\nvs=list(map(int,input().split()))\n\nvs_odd=vs[::2]\nc_odd=collections.Counter(vs_odd) \nC1=c_odd.most_common()\nC1.append((0,0))\ncommon1=C1[0][1] \ncommon1sec=C1[1][1] \n\nvs_even=vs[1::2]\nc_even=collections.Counter(vs_even) \nC2=c_even.most_common()\nC2.append((0,0))\ncommon2=C2[0][1] \ncommon2sec=C2[1][1] \n\nAns1=len(vs_odd)-common1\nAns2=len(vs_even)-common2\nAns3=len(vs_odd)-common1sec\nAns4=len(vs_even)-common2sec\n\nif c_odd.most_common()[0][0] == c_even.most_common()[0][0]:\n \n print(min(Ans1+Ans4, Ans2+Ans3))\nelse:\n print(Ans1+Ans2)']
|
['Runtime Error', 'Accepted']
|
['s123457562', 's935879131']
|
[17508.0, 25528.0]
|
[128.0, 109.0]
|
[433, 657]
|
p03244
|
u406755737
| 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 = [int(i) for i in input().split()]\nodd = collections.Counter(v[1::2])\neven = collections.Counter(v[0::2])\n# print(odd)\n\nmax_odd = max(odd, key=odd.get)\n# print(max_odd)\nmax_even = max(even, key=even.get)\n# print(max_even)\n\nif max_odd == max_even:\n del(even[max_even])\n try:\n max_even = max(even, key=even.get)\n max_even_v = even[max_even]\n except:\n max_even_v = 0\n \nmax_odd_v = odd[max_odd]\nnum_change_odd = n / 2 - max_odd_v\nnum_change_even = n / 2 - max_even_v\nprint(int(num_change_odd + num_change_even))', 'import collections\n\nn = int(input())\nv = [int(i) for i in input().split()]\nodd = collections.Counter(v[1::2])\neven = collections.Counter(v[0::2])\n# print(odd)\n\nmax_odd = max(odd, key=odd.get)\n# print(max_odd)\nmax_even = max(even, key=even.get)\n# print(max_even)\n\nmax_odd_v = odd[max_odd]\nmax_even_v = even[max_even]\n\nif max_odd == max_even:\n if len(odd) > 1:\n max_2nd_odd = odd.most_common(2)[1][0]\n max_2nd_odd_v = odd[max_2nd_odd]\n else:\n max_2nd_odd_v = 0\n if len(even) > 1:\n max_2nd_even = even.most_common(2)[1][0]\n max_2nd_even_v = even[max_2nd_even]\n else:\n max_2nd_even_v = 0\n if (max_odd_v + max_2nd_even_v) < (max_even_v + max_2nd_odd_v):\n print(n - (max_even_v + max_2nd_odd_v))\n else:\n print(n - (max_odd_v + max_2nd_even_v))\nelse:\n print(n - (max_odd_v + max_even_v))']
|
['Runtime Error', 'Accepted']
|
['s899483220', 's696213910']
|
[18656.0, 18656.0]
|
[75.0, 89.0]
|
[580, 857]
|
p03244
|
u409831002
| 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\n\n\n\n\n#################################\ndef separate(values,a,b):\n for v in values:\n a.append(v)\n a,b = b,a\n\n\n##############################\n\n\n\n\n\n##############################\ndef getCount(values):\n currentNum=0\n currentCount=0\n ret={\'First\' :{\'Num\':[],\'Cnt\':0},\n \'Second\':{\'Num\':[],\'Cnt\':0}}\n for v in values:\n if v==currentNum:\n currentCount+=1\n else:\n \n if ret[\'First\'][\'Cnt\'] < currentCount:\n \n ret[\'Second\']=ret[\'First\'].copy()\n ret[\'First\']={\'Num\':[currentNum],\'Cnt\':currentCount}\n elif ret[\'First\'][\'Cnt\'] == currentCount:\n \n ret[\'First\'][\'Num\'].append(currentNum)\n elif ret[\'Second\'][\'Cnt\'] < currentCount:\n \n ret[\'Second\']={\'Num\':[currentNum],\'Cnt\':currentCount}\n elif ret[\'Second\'][\'Cnt\'] == currentCount:\n \n ret[\'Second\'][\'Num\'].append(currentNum)\n\n currentNum=v\n currentCount=1\n\n \n if ret[\'First\'][\'Cnt\'] < currentCount:\n ret[\'Second\']=ret[\'First\'].copy()\n ret[\'First\']={\'Num\':[currentNum],\'Cnt\':currentCount}\n elif ret[\'First\'][\'Cnt\'] == currentCount:\n ret[\'First\'][\'Num\'].append(currentNum)\n elif ret[\'Second\'][\'Cnt\'] < currentCount:\n ret[\'Second\']={\'Num\':[currentNum],\'Cnt\':currentCount}\n elif ret[\'Second\'][\'Cnt\'] == currentCount:\n ret[\'Second\'][\'Num\'].append(currentNum)\n\n return ret\n\n\n#############################\n\n#############################\nvars = input ()\na=[]\nb=[]\nvarArray=vars.split(" ")\nseparate(varArray,a,b)\na.sort()\nb.sort()\na_result=getCount(a)\nb_result=getCount(b)\nif (len(a_result[\'First\'][\'Num\'])>1 or\n len(b_result[\'First\'][\'Num\'])>1):\n \n xa=len(a)-a_result[\'First\'][\'Cnt\']\n xb=len(b)-b_result[\'First\'][\'Cnt\']\n x=xa+xb\nelse:\n \n if a_result[\'First\'][\'Num\'][0]!=b_result[\'First\'][\'Num\'][0]:\n \n xa=len(a)-a_result[\'First\'][\'Cnt\']\n xb=len(b)-b_result[\'First\'][\'Cnt\']\n x=xa+xb\n else:\n \n xaa=len(a)-a_result[\'First\'][\'Cnt\']\n xab=len(b)-b_result[\'Second\'][\'Cnt\']\n xa=xaa+xab\n xba=len(a)-a_result[\'Second\'][\'Cnt\']\n xbb=len(b)-b_result[\'First\'][\'Cnt\']\n xb=xba+xbb\n x=xa if xa<xb else xb\n\nprint(x)\n', '\n#################################\n\n\n\n\n\n\n#################################\ndef separate(values,a,b):\n for v in values:\n a.append(v)\n a,b = b,a\n\n\n##############################\n\n\n\n\n\n##############################\ndef getCount(values):\n currentNum=0\n currentCount=0\n ret={\'First\' :{\'Num\':[],\'Cnt\':0},\n \'Second\':{\'Num\':[],\'Cnt\':0}}\n for v in values:\n if v==currentNum:\n currentCount+=1\n else:\n \n if ret[\'First\'][\'Cnt\'] < currentCount:\n \n ret[\'Second\']=ret[\'First\'].copy()\n ret[\'First\']={\'Num\':[currentNum],\'Cnt\':currentCount}\n elif ret[\'First\'][\'Cnt\'] == currentCount:\n \n ret[\'First\'][\'Num\'].append(currentNum)\n elif ret[\'Second\'][\'Cnt\'] < currentCount:\n \n ret[\'Second\']={\'Num\':[currentNum],\'Cnt\':currentCount}\n elif ret[\'Second\'][\'Cnt\'] == currentCount:\n \n ret[\'Second\'][\'Num\'].append(currentNum)\n\n currentNum=v\n currentCount=1\n\n \n if ret[\'First\'][\'Cnt\'] < currentCount:\n ret[\'Second\']=ret[\'First\'].copy()\n ret[\'First\']={\'Num\':[currentNum],\'Cnt\':currentCount}\n elif ret[\'First\'][\'Cnt\'] == currentCount:\n ret[\'First\'][\'Num\'].append(currentNum)\n elif ret[\'Second\'][\'Cnt\'] < currentCount:\n ret[\'Second\']={\'Num\':[currentNum],\'Cnt\':currentCount}\n elif ret[\'Second\'][\'Cnt\'] == currentCount:\n ret[\'Second\'][\'Num\'].append(currentNum)\n\n return ret\n\n\n#############################\n\n#############################\nn = input()\nvars = input ()\na=[]\nb=[]\nvarArray=vars.split(" ")\nseparate(varArray,a,b)\na.sort()\nb.sort()\na_result=getCount(a)\nb_result=getCount(b)\nif (len(a_result[\'First\'][\'Num\'])>1 or\n len(b_result[\'First\'][\'Num\'])>1):\n \n xa=len(a)-a_result[\'First\'][\'Cnt\']\n xb=len(b)-b_result[\'First\'][\'Cnt\']\n x=xa+xb\nelse:\n \n if a_result[\'First\'][\'Num\'][0]!=b_result[\'First\'][\'Num\'][0]:\n \n xa=len(a)-a_result[\'First\'][\'Cnt\']\n xb=len(b)-b_result[\'First\'][\'Cnt\']\n x=xa+xb\n else:\n \n xaa=len(a)-a_result[\'First\'][\'Cnt\']\n xab=len(b)-b_result[\'Second\'][\'Cnt\']\n xa=xaa+xab\n xba=len(a)-a_result[\'Second\'][\'Cnt\']\n xbb=len(b)-b_result[\'First\'][\'Cnt\']\n xb=xba+xbb\n x=xa if xa<xb else xb\n\nprint(x)\n']
|
['Wrong Answer', 'Accepted']
|
['s212918263', 's369644654']
|
[3192.0, 11764.0]
|
[18.0, 123.0]
|
[3093, 3106]
|
p03244
|
u411435121
| 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 as col\nfrom functools import reduce\nfrom operator import add\nn = int(input())\n\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n print(int(n / 2))\n exit()\n\nodd = v[1::2]\neven = v[0::2]\n\nco = col.Counter(odd).most_common()\ncoli = list(co.values())\nce = col.Counter(even).most_common()\nceli = list(ce.values())\n\ncov = list(co.keys())\ncev = list(ce.keys())\n\nif cov[0] != cev[0]:\n a = reduce(add, coli[1:], 0)\n b = reduce(add, celi[1:], 0)\n print(n - coli[0] - coli[0])\nelse:\n # a1 = reduce(add, coli[1:], 0)\n # b1 = reduce(add, celi[2:], 0)\n # b1 = celi[0] + b1\n\n # a2 = reduce(add, coli[2:], 0)\n # b2 = reduce(add, celi[1:], 0)\n # a2 = a2 + coli[0]\n if len(coli) <= 1:\n coli.append(0)\n if len(celi) <= 1:\n celi.append(0)\n\n ans1 = n - coli[1] - celi[0]\n ans2 = n - coli[0] - celi[1]\n\n print(min(ans1, ans2))', 'import collections as col\nfrom functools import reduce\nfrom operator import add\nn = int(input())\n\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n print(int(n / 2))\n exit()\n\nodd = v[1::2]\neven = v[0::2]\n\nco = col.Counter(odd)\ncoli = list(co.values())\nce = col.Counter(even)\nceli = list(ce.values())\n\ncov = list(co.keys())\ncev = list(ce.keys())\n\nif cov[0] != cev[0]:\n a = reduce(add, coli[1:], 0)\n b = reduce(add, celi[1:], 0)\n print(a + b)\n print(n - coli[0] - coli[0])\nelse:\n # a1 = reduce(add, coli[1:], 0)\n # b1 = reduce(add, celi[2:], 0)\n # b1 = celi[0] + b1\n\n # a2 = reduce(add, coli[2:], 0)\n # b2 = reduce(add, celi[1:], 0)\n # a2 = a2 + coli[0]\n if len(coli) <= 1:\n coli.append(0)\n if len(celi) <= 1:\n celi.append(0)\n\n ans1 = n - coli[1] - celi[0]\n ans2 = n - coli[0] - celi[1]\n\n print(min(ans1, ans2))', 'import collections as col\nfrom functools import reduce\nfrom operator import add\nn = int(input())\n\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n print(int(n / 2))\n exit()\n\nodd = v[1::2]\neven = v[0::2]\n\nco = col.Counter(odd).most_common()\nce = col.Counter(even).most_common()\n\nif co[0][0] != ce[0][0]:\n print(n - co[0][1] - ce[0][1])\nelse:\n # a1 = reduce(add, coli[1:], 0)\n # b1 = reduce(add, celi[2:], 0)\n # b1 = celi[0] + b1\n\n # a2 = reduce(add, coli[2:], 0)\n # b2 = reduce(add, celi[1:], 0)\n # a2 = a2 + coli[0]\n if len(co) <= 1:\n co.append((0, 0))\n if len(ce) <= 1:\n ce.append((0, 0))\n\n ans1 = n - co[1][1] - ce[0][1]\n ans2 = n - co[0][1] - ce[1][1]\n\n print(min(ans1, ans2))']
|
['Runtime Error', 'Wrong Answer', 'Accepted']
|
['s579712362', 's617343963', 's703463373']
|
[17620.0, 20564.0, 21204.0]
|
[72.0, 76.0, 98.0]
|
[894, 883, 745]
|
p03244
|
u411858517
| 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())\nl = list(map(int, input().split()))\n\na = []\nb = []\na_f = 0\nb_f = 0\na_s = 0\nb_s = 0\nfor i in range(N):\n if i%2 == 0:\n a.append(l[i])\n else:\n b.append(l[i])\n \nc_a = collections.Counter(a)\nc_b = collections.Counter(b)\n\na_f = c_a.most_common()[0]\nb_f = c_b.most_common()[0]\n\nif a_f[0] != b_f[0]:\n print(N - a_f[1] - b_f[1])\n\nelif len(set(a)) == 1 and len(set(b)) == 1:\n print(int(N/2))\nelif len(set(a)) == 1:\n print(int(N/2 - c_b.most_common()[1][1]))\nelif len(set(b)) == 1:\n print(int(N/2 - c_a.most_common()[1][1]))\nelif a_f[1] == b_f[1]:\n second_a = c_a.most_common()[1][1]\n second_b = c_b.most_common()[1][1]\n if second_a >= second_b:\n print(int(N - b_f[1] - second_a)\n else:\n print(int(N - a_f[1] - second_b)\nelif a_f[1] > b_f[1]:\n print(int(N - a_f[1] - c_b.most_common()[1][1]))\nelse:\n print(int(N - b_f[1] - c_a.most_common()[1][1]))', 'import collections\n\nN = int(input())\nl = list(map(int, input().split()))\n\na = []\nb = []\na_f = 0\nb_f = 0\na_s = 0\nb_s = 0\nfor i in range(N):\n if i%2 == 0:\n a.append(l[i])\n else:\n b.append(l[i])\n \nc_a = collections.Counter(a)\nc_b = collections.Counter(b)\n\na_f = c_a.most_common()[0]\nb_f = c_b.most_common()[0]\n\nif a_f[0] != b_f[0]:\n print(N - a_f[1] - b_f[1])\n\nelif len(set(a)) == 1 and len(set(b)) == 1:\n print(int(N/2))\nelif len(set(a)) == 1:\n print(int(N/2 - c_b.most_common()[1][1]))\nelif len(set(b)) == 1:\n print(int(N/2 - c_a.most_common()[1][1]))\nelif a_f[1] == b_f[1]:\n second_a = c_a.most_common()[1][1]\n second_b = c_b.most_common()[1][1]\n if second_a >= second_b:\n print(int(N - b_f[1] - second_a))\n else:\n print(int(N - a_f[1] - second_b))\nelif a_f[1] > b_f[1]:\n print(int(N - a_f[1] - c_b.most_common()[1][1]))\nelse:\n print(int(N - b_f[1] - c_a.most_common()[1][1]))']
|
['Runtime Error', 'Accepted']
|
['s609219655', 's799226552']
|
[3064.0, 20576.0]
|
[17.0, 142.0]
|
[945, 947]
|
p03244
|
u412481017
| 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())\nr=list(map(int,input().split()))\n\neNum=collections.Counter(r[1::2])\noNum=collections.Counter(r[::2])\n\n\nif eNum.keys()[0]==oNum.keys()[0]:\n print(len(r)-max(eNum[eNum.keys()[0]]+oNum[oNum.keys()[1]],eNum[eNum.keys()[1]]+oNum[oNum.keys()[0]]))\nelse:\n print(len(r)-eNum[eNum.keys()[0]]-oNum[oNum.keys()[1]])', 'import collections\n\nn=int(input())\nr=list(map(int,input().split()))\n\neNum=collections.Counter(r[1::2]).most_common()\noNum=collections.Counter(r[::2]).most_common()\neNum.append((0,0))\noNum.append((0,0))\n\n\n\nif eNum[0][0]==oNum[0][0]:\n print(len(r)-max(eNum[0][1]+oNum[1][1],eNum[1][1]+oNum[0][1]))\nelse:\n print(len(r)-eNum[0][1]-oNum[0][1])\n']
|
['Runtime Error', 'Accepted']
|
['s904799762', 's724113178']
|
[18656.0, 20700.0]
|
[59.0, 92.0]
|
[341, 341]
|
p03244
|
u416758623
| 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\nn = int(input())\nlst_v = list(map(int, input().split()))\n\n\nlst_o = lst_v[::2]\nlst_e = lst_v[1::2]\ncnt_o = Counter(lst_o).most_common() + [(0, 0)]\ncnt_e = Counter(lst_e).most_common() + [(0, 0)]\nprint(cnt_o)\nprint(cnt_e)\n\nif cnt_o[0][0] == cnt_e[0][0]:\n rem_number = max(cnt_o[0][1] + cnt_e[1][1], cnt_o[1][1] + cnt_e[0][1])\nelse:\n rem_number = cnt_o[0][1] + cnt_e[0][1]\nans = n - rem_number\n\n\nprint(ans)', 'from collections import Counter\n\nn = int(input())\nls = list(map(int, input().split()))\n\nac = Counter(ls[::2]).most_common(2)\nbd = Counter(ls[1::2]).most_common(2)\n\nif ac[0][0] != bd[0][0]:\n print(n-ac[0][1]-bd[0][1])\nelse:\n if len(ac) == 1 or len(bd) == 1:\n print(n//2)\n else:\n print(n-max(ac[0][1] + bd[1][1], ac[1][1] + bd[0][1]))']
|
['Wrong Answer', 'Accepted']
|
['s612320454', 's224824976']
|
[22364.0, 15588.0]
|
[126.0, 78.0]
|
[443, 355]
|
p03244
|
u419686324
| 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())\nA = [int(x) for x in input().split()]\n\nfrom collections import Counter\nimport operator\ndef f():\n evn = Counter(A[::2])\n odd = Counter(A[1::2])\n\n a = sorted(odd.most_common(2), key=operator.itemgetter(1, 0), reverse=True)\n b = sorted(evn.most_common(2), key=operator.itemgetter(1, 0), reverse=True)\n\n ac = a[0][1]\n bc = b[0][1]\n ret = n - ac + bc\n if a[0][0] == b[0][0]:\n bc_2 = b[1][1] if len(b) != 1 else n // 2\n ac_2 = a[1][1] if len(a) != 1 else n // 2\n ret = n - max(ac + bc_2, ac_2 + bc)\n return ret\nprint(f())', 'n = int(input())\nA = [int(x) for x in input().split()]\n\nfrom collections import Counter\nimport operator\ndef f():\n evn = Counter(A[::2])\n odd = Counter(A[1::2])\n\n a = sorted(odd.most_common(2), key=operator.itemgetter(1, 0), reverse=True)\n b = sorted(evn.most_common(2), key=operator.itemgetter(1, 0), reverse=True)\n\n ac = a[0][1]\n bc = b[0][1]\n ret = n - ac + bc\n if a[0][0] == b[0][0]:\n bc_2 = b[1][1] if len(b) != 1 else 0\n ac_2 = a[1][1] if len(a) != 1 else 0\n ret = n - max(ac + bc_2, ac_2 + bc)\n return ret\nprint(f())', 'n = int(input())\nA = [int(x) for x in input().split()]\n\nfrom collections import Counter\nimport operator\ndef f():\n a, b = Counter(A[::2]), Counter(A[1::2])\n ac, bc = a[0][1], b[0][1]\n ret = n - (ac + bc)\n if a[0][0] == b[0][0]:\n bc_2 = b[1][1] if len(b) != 1 else 0\n ac_2 = a[1][1] if len(a) != 1 else 0\n ret = n - max(ac + bc_2, ac_2 + bc)\n return ret\nprint(f())', 'n = int(input())\nA = [int(x) for x in input().split()]\n\nfrom collections import Counter\nimport operator\ndef f():\n a = Counter(A[::2]).most_common(2)\n b = Counter(A[1::2]).most_common(2)\n ac, bc = a[0][1], b[0][1]\n ret = n - (ac + bc)\n if a[0][0] == b[0][0]:\n bc_2 = b[1][1] if len(b) != 1 else 0\n ac_2 = a[1][1] if len(a) != 1 else 0\n ret = n - max(ac + bc_2, ac_2 + bc)\n return ret\nprint(f())']
|
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s364249429', 's621702762', 's914568261', 's074634664']
|
[18588.0, 18592.0, 18464.0, 15516.0]
|
[84.0, 79.0, 65.0, 86.0]
|
[580, 570, 398, 432]
|
p03244
|
u421828301
| 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\nfrom collections import defaultdict\n\n\nn = int(input())\nv = list(int, input().split())\n\ndef f(v):\n d = defaultdict(int)\n d[0] = 0\n\n for i in v:\n d[i] += 1\n return sorted(d.items(), key=lambda x: x[1], reverse=True)\n\nt1 = f(v[::2])\nt2 = f(v[1::2])\n\nif t1[0][0] == t2[0][0]:\n if t1[0][1] + t2[1][1] > t1[1][1] + t2[0][1]:\n print(n - t1[0][1] - t2[1][1])\n else:\n print(n - t1[1][1] - t2[0][1])\nelse:\n print(n - t1[0][1] - t2[0][1])', '# -*- coding: utf-8 -*-\n\nfrom collections import defaultdict\n\n\nn = int(input())\nv = tuple(int(i) for i in input().split())\n\ndef f(v):\n d = defaultdict(int)\n d[0] = 0\n\n for i in v:\n d[i] += 1\n return sorted(d.items(), key=lambda x: x[1], reverse=True)\n\nt1 = f(v[::2])\nt2 = f(v[1::2])\n\nif t1[0][0] == t2[0][0]:\n if t1[0][1] + t2[1][1] > t1[1][1] + t2[0][1]:\n print(n - t1[0][1] - t2[1][1])\n else:\n print(n - t1[1][1] - t2[0][1])\nelse:\n print(n - t1[0][1] - t2[0][1])\n']
|
['Runtime Error', 'Accepted']
|
['s391891014', 's074851760']
|
[10896.0, 20696.0]
|
[29.0, 110.0]
|
[504, 517]
|
p03244
|
u426572476
| 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 itertools\nimport math\nimport sys\n\nn = int(input())\nv = list(map(int, input().split()))\nif len(set(v)) == 1:\n print(n // 2)\nelse:\n odd_cnt = [0] * 10 ** 5\n even_cnt = [0] * 10 ** 5\n for i in range(len(v)):\n if i % 2 == 0:\n even_cnt[v[i]] += 1\n else:\n odd_cnt[v[i]] += 1\n odd = odd_cnt.index(max(odd_cnt))\n even = even_cnt.index(max(even_cnt))\n ans = 0\n print("odd =", odd)\n print("even =", even)\n for i in range(len(v)):\n if i % 2 == 0:\n if v[i] != even:\n ans += 1\n else:\n if v[i] != odd:\n ans += 1\n print(ans)\n', 'import itertools\nimport math\nimport sys\nfrom collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\ne = Counter(v[0::2]).most_common()\no = Counter(v[1::2]).most_common()\nif len(e) == 1 and len(o) == 1:\n if e[0][0] == o[0][0]:\n print(n // 2)\n else:\n print(0)\nelif len(e) == 1:\n if e[0][0] != o[0][0]:\n print(n - e[0][1] - o[0][1])\n else:\n print(n - max(e[0][1] + o[0][1], o[1][1]))\nelif len(o) == 1:\n if e[0][0] != o[0][0]:\n print(n - e[0][1] - o[0][1])\n else:\n print(n - max(e[0][1] + o[0][1], e[1][1]))\nelse:\n if e[0][0] != o[0][0]:\n print(n - e[0][1] - o[0][1])\n else:\n print(n - max(e[0][1] + o[1][1], e[1][1] + o[0][1]))\n\n\n']
|
['Runtime Error', 'Accepted']
|
['s879440339', 's576462615']
|
[15712.0, 20700.0]
|
[103.0, 84.0]
|
[652, 733]
|
p03244
|
u431981421
| 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_array = list(map(int,input().split()))\n \nv_odd = v_array[0::2]\nv_even = v_array[1::2]\n \nv_odd_common = Counter(v_odd).most_common()\nv_even_common = Counter(v_even).most_common()\n\nv_odd_common.append((0,0))\nv_even_common.append((0,0))\n\nprint(v_odd_common[0])\n\nif v_odd_common[0] != v_even_common[0]:\n print(n-v_odd_common[0][1]-v_even_common[0][1])\nelse:\n print(min(n-v_odd_common[0][1]-v_even_common[1][1],n-v_odd_common[1][1]-v_even_common[0][1]))', 'from collections import Counter\n \nn = int(input())\nv_array = list(map(int,input().split()))\n \nv_odd = v_array[0::2]\nv_even = v_array[1::2]\n \nv_odd_common = Counter(v_odd).most_common()\nv_even_common = Counter(v_even).most_common()\n\nv_odd_common.append((0,0))\nv_even_common.append((0,0))\n\nprint(v_odd_common[0])\n\nif v_odd_common[0] != v_even_common[0]:\n print(n-v_odd_common[0][1]-v_even_common[0][1])\nelse:\n print(min(n-v_odd_common[0][1]-v_even_common[1][1],n-v_odd_common[1][1]-v_even_common[0][1]))', 'from collections import Counter\n \nn = int(input())\nv_array = list(map(int,input().split()))\n \nv_odd = v_array[0::2]\nv_even = v_array[1::2]\n \nv_odd_common = Counter(v_odd).most_common()\nv_even_common = Counter(v_even).most_common()\n\nv_odd_common.append((0,0))\nv_even_common.append((0,0))\n\nif v_odd_common[0] != v_even_common[0]:\n print(n-v_odd_common[0][1]-v_even_common[0][1])\nelse:\n print(min(n-v_odd_common[0][1]-v_even_common[1][1],n-v_odd_common[1][1]-v_even_common[0][1]))\n ']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s052527603', 's843435078', 's923910349']
|
[21084.0, 21084.0, 21084.0]
|
[87.0, 86.0, 88.0]
|
[507, 507, 486]
|
p03244
|
u440161695
| 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()))\nV0=Counter(V[::2]).most_common()\nV1=Counter(V[1::2]).most_common()\nans=0\nfor i in range(1,len(V0)-1):\n ans+=V0[i][1]\nfor i in range(1,len(V1)-1):\n ans+=V1[i][1]\nprint(ans)', 'V=list(map(int,input().split()))\nV0=Counter(V[::2]).most_common()\nV1=Counter(V[1::2]).most_common()\nans=0\nif V0[0][0]==V1[0][0]:\n if len(V0)==1 and len(V1)==1:\n print(N//2)\n exit()\n elif len(V0)!=1 and len(V1)!=1:\n if V0[1][0]>=V1[1][0]:\n V0[0],V0[1]=V0[1],V0[0]\n else:\n V1[0],V1[1]=V1[1],V1[0]\n elif len(V0)>len(V1):\n V0[0],V0[1]=V0[1],V0[0]\n else:\n V1[0],V1[1]=V1[1],V1[0]\nfor i in range(1,len(V0)):\n ans+=V0[i][1]\nfor i in range(1,len(V1)):\n ans+=V1[i][1]\nprint(ans)', 'from collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\na=Counter(v[0::2]).most_common()\nb=Counter(v[1::2]).most_common()\na.append([0,0])\nb.append([0,0])\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])))']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s278787469', 's602169356', 's852692463']
|
[20700.0, 3064.0, 20572.0]
|
[103.0, 18.0, 87.0]
|
[253, 504, 291]
|
p03244
|
u442030035
| 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 = input().split()\n\nvv = list(set(v))\n\nif len(vv) >= 2:\n vvv = vv.copy()\n\n min = 10**6\n for i in vv:\n vvv.remove(i)\n for j in vvv:\n if 10-(v.count(i)+v.count(j)) > min:\n pass\n else:\n ct = 0\n a = [i if k % 2 == 0 else j for k in range(n)]\n print(' '.join(a))\n for k in range(n):\n if a[k] != v[k]:\n ct += 1\n if ct < min:\n min = ct\n vvv.append(i)\n print(min)\nelse:\n print(int(n/2))\n", 'import collections\n\nn = int(input())\nv = input().split()\n\ne = [v[i] for i in range(n) if i % 2 == 0]\no = [v[i] for i in range(n) if i % 2 == 1]\n\nc_e = collections.Counter(e).most_common()\nc_o = collections.Counter(o).most_common()\n\ne_0 = c_e[0]\no_0 = c_o[0]\n\nif e_0 != o_0:\n print(len(e) - e_0[1] + len(o) - o_0[1])\nelse:\n if len(c_e) == 1:\n e_1 = [0, 0]\n else:\n e_1 = c_e[1]\n if len(c_o) == 1:\n o_1 = [0, 0]\n else:\n o_1 = c_o[1]\n print(min(len(e)-e_0[1]+len(o)-o_1[1], len(e)-e_1[1]+len(o)-o_0[1]))\n']
|
['Wrong Answer', 'Accepted']
|
['s481238733', 's522575269']
|
[47280.0, 23528.0]
|
[2104.0, 96.0]
|
[606, 546]
|
p03244
|
u442581202
| 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.
|
['6\n105 119 105 119 105 119', 'n = int(input())\n\ndata = list(map(int,input().split()))\n\nodd = [data[i] for i in range(0,n,2)]\neven = [data[i] for i in range(1,n,2)]\n\nodd_dict = dict({})\neven_dict = dict({})\n\nfor i in range(n//2):\n if odd_dict.__contains__(odd[i]):\n odd_dict[odd[i]]+=1\n else:\n odd_dict[odd[i]] = 1\n if even_dict.__contains__(even[i]):\n even_dict[even[i]]+=1\n else:\n even_dict[even[i]] = 1\n\nodd = sorted(odd_dict.items(), key=lambda d:d[1],reverse=True)\neven = sorted(even_dict.items(), key=lambda d:d[1],reverse=True)\n\nodd.append((0,0))\neven.append((0,0))\nif odd[0][0] == even[0][0]:\n print(min(n-odd[0][1]-even[1][1],n-odd[1][1]-even[0][1]))\nelse:\n print(n-odd[0][1]-even[0][1])\n']
|
['Runtime Error', 'Accepted']
|
['s038319765', 's453839542']
|
[2940.0, 21244.0]
|
[17.0, 110.0]
|
[25, 712]
|
p03244
|
u451017206
| 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 = [int(i) for i in input().split()]\ne = []\no = []\nfor i, a in enumerate(v):\n if i % 2:\n o.append(a)\n else:\n e.append(a)\noc = Counter(o)\nec = Counter(e)\nh = n//2\nans = h\n\na = []\nfor i, (k, v) in enumerate(oc.most_common()):\n if not v in a:\n a.append(v)\n if len(a) >= 3:\n break\na = []\nfor j, (k, v) in enumerate(ec.most_common()):\n if not v in a:\n a.append(v)\n if len(a) >= 3:\n break\nfor k, v in oc.most_common(i):\n for k2, v2 in ec.most_common(j):\n if k == k2:\n continue\n ans = min(ans, h - v + h - v2)\nprint(ans)\n', 'from collections import Counter\nn = int(input())\nv = [int(i) for i in input().split()]\ne = []\no = []\nfor i, a in enumerate(v):\n if i % 2:\n o.append(a)\n else:\n e.append(a)\noc = Counter(o)\nec = Counter(e)\nh = n//2\nif oc.most_common(1)[0][0] != ec.most_common(1)[0][0]:\n a = h - oc.most_common(1)[0][1]\n b = h - ec.most_common(1)[0][1]\n print(a+b)\nelse:\n if len(oc) == 1:\n print(h)\n exit()\n E1 = E2 = 0\n for i, (k, v) in enumerate(ec.most_common(2)):\n if i == 0:\n E2 = E1 = k\n else:\n E2 = k\n O1 = O2 = 0\n for i, (k, v) in enumerate(oc.most_common(2)):\n if i == 0:\n O2 = O1 = k\n else:\n O2 = k\n print(min(h-ec[E1] + h - oc[O2], h - ec[E2] + h - oc[O1]))\n']
|
['Wrong Answer', 'Accepted']
|
['s019160199', 's936538240']
|
[28112.0, 19040.0]
|
[2105.0, 113.0]
|
[652, 782]
|
p03244
|
u454524105
| 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 = [i for i in map(int, input().split())]\ncnt = Counter(v)\nif len(cnt) == 1:\n print(n//2)\n exit()\nval = list(cnt.values())\nval.sort()\nval = val[::-1]\nif len(val) == 2:\n print(abs(n//2 - val[0]))\n exit()\nelse:\n print(val)\n print(max(val[0] - n//2, 0) + sum(val[2:]))\n exit()', 'from collections import Counter\nn = int(input())\nv = [i for i in map(int, input().split())]\nv_e, v_o = v[0::2], v[1::2]\ncnt_e, cnt_o = Counter(v_e), Counter(v_o)\nval_e, val_o = list(cnt_e.values()), list(cnt_o.values())\nval_e.sort()\nval_o.sort()\nval_e, val_o = val_e[::-1], val_o[::-1]\ncnt_e = sorted(cnt_e.items(), key=lambda x:x[1])[::-1]\ncnt_o = sorted(cnt_o.items(), key=lambda x:x[1])[::-1]\nkey_e, key_o = cnt_e[0][0], cnt_o[0][0]\nif key_e == key_o:\n if len(val_e) == len(val_o) == 1:\n print(n // 2)\n elif len(val_e) == 1:\n print(n // 2 - val_o[1])\n elif len(val_o) == 1:\n print(n // 2 - val_e[1])\n else:\n print(min(n - val_e[0] - val_o[1], n - val_e[1] - val_o[0]))\nelse:\n if len(val_e) == len(val_o) == 1:\n print(0)\n elif len(val_e) == 1:\n print(n // 2 - val_o[0])\n elif len(val_o) == 1:\n print(n // 2 - val_e[0])\n else:\n print(n - val_o[0] - val_e[0])']
|
['Wrong Answer', 'Accepted']
|
['s838953476', 's721450768']
|
[19936.0, 19644.0]
|
[79.0, 99.0]
|
[344, 939]
|
p03244
|
u454557108
| 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\n\nn = int(input())\nv = list(map(int,input().split()))\n\na1 = {}\na2 = {}\nfor i in range(n) :\n a = v[i]\n if i%2 == 0 :\n if a in a1 :\n a1[a] += 1\n else :\n a1[a] = 1\n else :\n if a in a2 :\n a2[a] += 1\n else :\n a2[a] = 1\n\na1_s = sorted(a1.items(), key = lambda x : x[1], reverse = True)\na2_s = sorted(a2.items(), key = lambda x : x[1], reverse = True)\n\nans = n\nfor i in range(2) :\n for j in range(2) :\n if a1_s[i][0] == a2_s[j][0] :\n continue\n ans = min(ans,n-a1_s[i][1]-a2_s[j][1])\n \nprint(ans)', 'import sys\n\nn = int(input())\nv = list(map(int,input().split()))\n\na1 = {}\na2 = {}\nfor i in range(n) :\n a = v[i]\n if i%2 == 0 :\n if a in a1 :\n a1[a] += 1\n else :\n a1[a] = 1\n else :\n if a in a2 :\n a2[a] += 1\n else :\n a2[a] = 1\n\na1_s = sorted(a1.items(), key = lambda x : x[1], reverse = True)\na2_s = sorted(a2.items(), key = lambda x : x[1], reverse = True)\n\nans = n\nfor i in range(min(2,len(a1_s))) :\n for j in range(min(2,len(a2_s))) :\n if a1_s[i][0] == a2_s[j][0] :\n continue\n ans = min(ans,n-a1_s[i][1]-a2_s[j][1])\n\nif len(a1_s) == 1 and len(a2_s) == 1 and ans == n :\n ans = n//2\n\nprint(ans)']
|
['Runtime Error', 'Accepted']
|
['s953128560', 's968776203']
|
[20720.0, 20764.0]
|
[102.0, 105.0]
|
[548, 640]
|
p03244
|
u455696302
| 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 = [int(i) for i in input().split()]\n\nv1 = [v[i] for i in range(0,n,2)]\nv2 = [v[i] for i in range(1,n,2)]\n\ncount1 = collections.Counter(v1)\ncount2 = collections.Counter(v2)\n\nif len(count1) == 1 and len(count2) == 1:\n if v1 == v2:\n print(len(v1))\n else:\n print(0)', 'import collections\n \nn = int(input())\nv = [int(i) for i in input().split()]\n \nv1 = [v[i] for i in range(0,n,2)]\nv2 = [v[i] for i in range(1,n,2)]\n \ncount1 = collections.Counter(v1).most_common(2)\ncount2 = collections.Counter(v2).most_common(2)\n\nif count1[0][0] != count2[0][0]:\n res = len(v1) - max(count1.values()) + len(v2) - max(count2.values())\n print(res)\nelse:\n if len(count1) == 1:\n print(len(v1))\n else:\n res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]\n res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]\n print(min(res1,res2))\n', 'import collections\n \nn = int(input())\nv = [int(i) for i in input().split()]\n \nv1 = [v[i] for i in range(0,n,2)]\nv2 = [v[i] for i in range(1,n,2)]\n \ncount1 = collections.Counter(v1).most_common(2)\ncount2 = collections.Counter(v2).most_common(2)\n\nif max(count1.values()) != max(count2.values()):\n res = len(v1) - max(count1.values()) + len(v2) - max(count2.values())\n print(res)\nelse:\n if len(count1) == 1:\n print(len(v1))\n else:\n res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]\n res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]\n print(min(res1,res2))\n', 'import collections\n \nn = int(input())\nv = [int(i) for i in input().split()]\n \nv1 = [v[i] for i in range(0,n,2)]\nv2 = [v[i] for i in range(1,n,2)]\n \ncount1 = collections.Counter(v1).most_common(2)\ncount2 = collections.Counter(v2).most_common(2)\n\nif count1[0][0] != count2[0][0]:\n res = len(v1) - count1[0][0] + len(v2) - count2[0][0]\n print(res)\nelse:\n if len(count1) == 1:\n print(len(v1))\n else:\n res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]\n res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]\n print(min(res1,res2))\n', 'import collections\n \nn = int(input())\nv = [int(i) for i in input().split()]\n \nv1 = [v[i] for i in range(0,n,2)]\nv2 = [v[i] for i in range(1,n,2)]\n \ncount1 = collections.Counter(v1).most_common(2)\ncount2 = collections.Counter(v2).most_common(2)\n\nif count1[0][0] != count2[0][0]:\n res = len(v1) - count1[0][1] + len(v2) - count2[0][1]\n print(res)\nelse:\n if len(count1) == 1:\n print(len(v1))\n else:\n res1 = len(v1) - count1[0][1] + len(v2) - count2[1][1]\n res2 = len(v1) - count1[1][1] + len(v2) - count2[0][1]\n print(min(res1,res2))']
|
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
|
['s152227865', 's187286362', 's951677790', 's991751392', 's425551303']
|
[19032.0, 15964.0, 15964.0, 15964.0, 15964.0]
|
[67.0, 83.0, 83.0, 87.0, 82.0]
|
[320, 587, 603, 571, 570]
|
p03244
|
u462329577
| 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()))\nfreq_odd = [0] * (10 ** 5 + 1)\nfreq_even = [0] * (10 ** 5 + 1)\nfor i in range(n // 2):\n freq_odd[v[2 * i]] += 1\n freq_even[v[2 * i + 1]] += 1\n# print(freq_odd[:10], freq_even[:10])\nfreq_even, id_even = zip(*sorted(zip(freq_even, range(10 ** 5 + 1))))\nfreq_odd, id_odd = zip(*sorted(zip(freq_odd, range(10 ** 5 + 1))))\n# print(freq_odd[-2:], freq_even[-2:])\nprint(id_even[-1], id_odd[-1])\nif id_even[-1] != id_odd[-1]:\n print(n - freq_even[-1] - freq_odd[-1])\nelse:\n print(min(n - freq_even[-2] - freq_odd[-1], n - freq_even[-1] - freq_odd[-2]))\n', 'n = int(input())\nv = list(map(int, input().split()))\nfreq_odd = [0] * (10 ** 5 + 1)\nfreq_even = [0] * (10 ** 5 + 1)\nfor i in range(n // 2):\n freq_odd[v[2 * i]] += 1\n freq_even[v[2 * i + 1]] += 1\n# print(freq_odd[:10], freq_even[:10])\nfreq_even, id_even = zip(*sorted(zip(freq_even, range(10 ** 5 + 1))))\nfreq_odd, id_odd = zip(*sorted(zip(freq_odd, range(10 ** 5 + 1))))\n# print(freq_odd[-2:], freq_even[-2:])\n# print(id_even[-1], id_odd[-1])\nif id_even[-1] != id_odd[-1]:\n print(n - freq_even[-1] - freq_odd[-1])\nelse:\n print(min(n - freq_even[-2] - freq_odd[-1], n - freq_even[-1] - freq_odd[-2]))\n']
|
['Wrong Answer', 'Accepted']
|
['s633100163', 's419548237']
|
[32112.0, 32084.0]
|
[175.0, 180.0]
|
[610, 612]
|
p03244
|
u466331465
| 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 as col\nN= int(input())\nA = [int(x) for x in input().split()]\na = A[::2]\nprint(a)\na = col.Counter(a)\nb = A[1::2]\nprint(b)\nb = col.Counter(b)\nans = 0\ni = 0\nj = 0\nif len(a.most_common())==1 and len(b.most_common())==1 and a.most_common()[i][0]==b.most_common()[j][0]:\n print(N//2)\n exit()\nwhile a.most_common()[i][0]==b.most_common()[j][0]:\n m=a.most_common()[i][1]\n n=b.most_common()[j][1]\n if m>n:\n j +=1\n elif m==n:\n if a.most_common()[i+1][1]>b.most_common()[j+1][1]:\n i+=1\n else:\n j +=1\n else:\n i +=1\n#print(i,j,a,b)\nans += sum(a.values())+sum(b.values())-a.most_common()[i][1]-b.most_common()[j][1]\nprint(ans)', 'import collections as col\nN= int(input())\nA = [int(x) for x in input().split()]\na = A[::2]\na = col.Counter(a)\nb = A[1::2]\nb = col.Counter(b)\nans = 0\ni = 0\nj = 0\n#while a.most_common()[i][0]!=b.most_common()[j][0]:\nif a.most_common(1)[0][0]!=b.most_common(1)[0][0]:\n ans += sum(a.values())+sum(b.values)-a.most_common(1)[0][1]-b.most_common(1)[0][1]\nprint(ans)', 'import collections as col\nN= int(input())\nA = [int(x) for x in input().split()]\na = A[::2]\n\na = col.Counter(a)\nb = A[1::2]\n\nb = col.Counter(b)\nans = 0\ni = 0\nj = 0\nif len(a.most_common())==1 and len(b.most_common())==1 and a.most_common()[i][0]==b.most_common()[j][0]:\n print(N//2)\n exit()\nwhile a.most_common()[i][0]==b.most_common()[j][0]:\n m=a.most_common()[i][1]\n n=b.most_common()[j][1]\n if m>n:\n j +=1\n elif m==n:\n if a.most_common()[i+1][1]>b.most_common()[j+1][1]:\n i+=1\n else:\n j +=1\n else:\n i +=1\n#print(i,j,a,b)\nans += sum(a.values())+sum(b.values())-a.most_common()[i][1]-b.most_common()[j][1]\nprint(ans)']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s120665132', 's717916554', 's254364694']
|
[19296.0, 18656.0, 18656.0]
|
[190.0, 75.0, 172.0]
|
[668, 360, 652]
|
p03244
|
u469953228
| 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\na = Counter(v[0::2]).most_common()\nb = Counter(v[1::2]).most_common()\nprint(a)\nprint(b)\na.append([0,0])\nb.append([0,0])\nif a[0][0] != b[0][0]:\n print(n-(a[0][1]+b[0][1])\nelse:\n print(min(n-(a[0][1]+b[1][1]),n-(a[1][1]+b[0][1])))', '\n \nfrom collections import Counter\n \nn = int(input())\nv = list(map(int, input().split()))\n\na = Counter(v[0::2]).most_common()\nb = Counter(v[1::2]).most_common()\nprint(a)\nprint(b)\na.append([0,0])\nb.append([0,0])\nif a[0][0] != b[0][0]:\n print(n-(a[0][1]+b[0][1]))\nelse:\n print(min(n-(a[0][1]+b[1][1]),n-(a[1][1]+b[0][1])))', 'from collections import Counter\n \nn = int(input())\nv = list(map(int, input().split()))\n\na = Counter(v[0::2]).most_common()\nb = Counter(v[1::2]).most_common()\nprint(a)\nprint(b)\na.append([0,0])\nb.append([0,0])\nif a[0][0] != b[0][0]:\n print(n-(a[0][0]+b[0][0])\nelse:\n print(min(n-(a[0][0]+b[1][0]),n-(a[1][0]+b[0][0])))', 'from collections import Counter\n \nn = int(input())\nv = list(map(int, input().split()))\n\na = Counter(v[0::2]).most_common()\nb = Counter(v[1::2]).most_common()\na.append([0,0])\nb.append([0,0])\nif a[0][0] != b[0][0]:\n print(n-(a[0][1]+b[0][1]))\nelse:\n print(min(n-(a[0][1]+b[1][1]),n-(a[1][1]+b[0][1])))']
|
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s328059369', 's949775577', 's981401937', 's250749858']
|
[3064.0, 21852.0, 3064.0, 20572.0]
|
[17.0, 122.0, 17.0, 89.0]
|
[321, 328, 321, 304]
|
p03244
|
u476435125
| 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())\nlv=list(map(int,input().split()))\ndev={}\ndod={}\n\n\nmax1_ev=[0,0]\nmax2_ev=[0,0]\nmax1_od=[0,0]\nmax2_od=[0,0]\n\nfor i in range(N):\n if i%2==0:#even\n #max1_ev=[0,0]\n #max2_ev=[0,0]\n \n\n if lv[i] in dev:\n dev[lv[i]]+=1\n else:\n dev[lv[i]]=1\n \n #cev+=1\n #if cev==1:\n # max1_ev=[i,lv[i]]\n #elif cev==2:\n # max2_ev=[i,lv[i]]\n \n \n if dev[lv[i]]>max1_ev[1]:\n max1_ev=[lv[i],dev[lv[i]]]\n \n elif dev[lv[i]]>=max2_ev[1]:\n max2_ev=[lv[i],dev[lv[i]]]\n #print("dev[lv[i]]",dev[lv[i]])\n #print("max1__ev[1]",max1_ev[1])\n #print("max1_ev",max1_ev)\n #print("max2_ev",max2_ev)\n #if i==0:\n # max1=[0,1]\n #elif i==1:\n # max2\n else:#odd\n #max1_od=[0,0]\n #max2_od=[0,0]\n if lv[i] in dod:\n dod[lv[i]]+=1\n else:\n dod[lv[i]]=1\n if dod[lv[i]]>max1_od[1]:\n max1_od=[lv[i],dod[lv[i]]]\n \n elif dod[lv[i]]>=max2_od[1]:\n max2_od=[lv[i],dod[lv[i]]]\nprint("dev",dev)#ok\nprint("dod",dod)#ok\nprint("max1_ev",max1_ev)\nprint("max2_ev",max2_ev)\n\n\n#if len(dev)==1 and len(dod)==1:\n# print(int(N/2))\n#elif len(dev)==1:\n \n # if i==0:\n # max1_od=\n# if max1_ev[0]!=max1_od[0]:\n# print(N-max1_ev[1]-max1_od[1])\n## print(max)\nif max1_ev[0]!=max1_od[0]:\n print(N-max1_ev[1]-max1_od[1])\nelif len(dev)==1 and len(dod)==1:\n print(int(N/2))\nelif len(dev)==1:\n print(int(N/2)-max2_od[1])\nelif len(dod)==1:\n print(int(N/2)-max2_ev[1])\nelse:\n \n print(min(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1]))\n', 'N=int(input())\nlv=list(map(int,input().split()))\ndev={}\ndod={}\n\n\nmax1_ev=[0,0]\nmax2_ev=[0,0]\nmax1_od=[0,0]\nmax2_od=[0,0]\n\nfor i in range(N):\n if i%2==0:#even\n #max1_ev=[0,0]\n #max2_ev=[0,0]\n \n\n if lv[i] in dev:\n dev[lv[i]]+=1\n else:\n dev[lv[i]]=1\n \n #cev+=1\n #if cev==1:\n # max1_ev=[i,lv[i]]\n #elif cev==2:\n # max2_ev=[i,lv[i]]\n \n \n if dev[lv[i]]>max1_ev[1]:\n a=max1_ev\n max1_ev=[lv[i],dev[lv[i]]]\n max2_ev=a\n \n elif dev[lv[i]]>=max2_ev[1]:\n max2_ev=[lv[i],dev[lv[i]]]\n #print("dev[lv[i]]",dev[lv[i]])\n #print("max1__ev[1]",max1_ev[1])\n #print("max1_ev",max1_ev)\n #print("max2_ev",max2_ev)\n #if i==0:\n # max1=[0,1]\n #elif i==1:\n # max2\n else:#odd\n #max1_od=[0,0]\n #max2_od=[0,0]\n if lv[i] in dod:\n dod[lv[i]]+=1\n else:\n dod[lv[i]]=1\n if dod[lv[i]]>max1_od[1]:\n a=max1_od\n max1_od=[lv[i],dod[lv[i]]]\n max2_od=a\n \n elif dod[lv[i]]>=max2_od[1]:\n max2_od=[lv[i],dod[lv[i]]]\n#print("dev",dev)#ok\n#print("dod",dod)#ok\n#print("max1_ev",max1_ev)\n#print("max2_ev",max2_ev)\n\n\n#if len(dev)==1 and len(dod)==1:\n# print(int(N/2))\n#elif len(dev)==1:\n \n # if i==0:\n # max1_od=\n# if max1_ev[0]!=max1_od[0]:\n# print(N-max1_ev[1]-max1_od[1])\n## print(max)\nif max1_ev[0]!=max1_od[0]:\n print(N-max1_ev[1]-max1_od[1])\nelif len(dev)==1 and len(dod)==1:\n print(int(N/2))\nelif len(dev)==1:\n print(int(N/2)-max2_od[1])\nelif len(dod)==1:\n print(int(N/2)-max2_ev[1])\nelse:\n \n print(min(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1]))\n']
|
['Wrong Answer', 'Accepted']
|
['s052535872', 's339171746']
|
[17396.0, 17644.0]
|
[161.0, 141.0]
|
[2118, 2235]
|
p03244
|
u480200603
| 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\ns = len(set(v))\nif s == 1:\n print(n // 2)\n exit()\n\nodd = v[::2]\neven = v[1::2]\nmo = collections.Counter(odd).most_common()[0]\nmo2 = collections.Counter(odd).most_common()[1]\nme = collections.Counter(even).most_common()[0]\nme2 = collections.Counter(even).most_common()[1]\n\nif mo[0] == me[0]:\n if me2[1] < mo2[1]:\n mo = mo2\n else:\n me = me2\nprint(abs((n // 2) - mo[1]) + abs((n // 2) - me[1]))\n', '# coding: utf-8\n# Your code here!\n\nimport collections\n\nn = int(input())\nv_l = list(map(int, input().split()))\n\nif len(set(v_l)) == 1:\n print(n // 2)\n exit()\n\nv_l_odd = []\nv_l_even = []\n\nfor i in range(n):\n if i % 2 == 0:\n v_l_odd.append(v_l[i])\n else:\n v_l_even.append(v_l[i])\n\nmax_odd = collections.Counter(v_l_odd)\nmon = max_odd.most_common(1)[0][0]\nmax_even = collections.Counter(v_l_even)\nmen = max_even.most_common(1)[0][0]\n\nif mon == men:\n if max(max_odd.most_common(2)[1][1], max_even.most_common(2)[1][1]) \n== max_odd.most_common(2)[1][1]:\n mon = max_odd.most_common(2)[1][1]\n else:\n men = max_even.most_common(2)[1][1]\n\nv_l_odd_l = []\nv_l_even_l = []\n\nfor i in range(n):\n if i % 2 == 0:\n if v_l[i] != mon:\n v_l_odd_l.append(v_l[i])\n else:\n if v_l[i] != men:\n v_l_even_l.append(v_l[i])\n\nprint(len(v_l_odd_l) + len(v_l_even_l))\n\n\n', 'import collections\n\nn = int(input())\nv_l = list(map(int, input().split()))\n\nif len(set(v_l)) == 1:\n print(n // 2)\n exit()\nelif len(set(v_l)) == n // 2:\n print(n // 2)\n exit()\n\nv_l_odd = []\nv_l_even = []\n\nfor i in range(n):\n if i % 2 == 0:\n v_l_odd.append(v_l[i])\n else:\n v_l_even.append(v_l[i])\ntimes = 0\ncount_odd = collections.Counter(v_l_odd)\ncount_even = collections.Counter(v_l_even)\nprint(count_even)\nwhile True:\n print(str(times) + "times")\n mon = count_odd.most_common()[times][0]\n print(mon)\n print(count_odd.most_common()[times][0])\n men = count_even.most_common()[times][0]\n print(men)\n\n v_l_odd_diff = []\n v_l_even_diff = []\n\n for i in range(n):\n if i % 2 == 0:\n if v_l[i] != mon:\n v_l_odd_diff.append(v_l[i])\n v_l[i] = mon\n else:\n if v_l[i] != men:\n v_l_even_diff.append(v_l[i])\n v_l[i] = men\n\n if len(set(v_l)) != 1:\n print(len(v_l_odd_diff) + len(v_l_even_diff))\n exit()\n else:\n times = times + 1\n', '# coding: utf-8\n# Your code here!\n\nimport collections\n\nn = int(input())\nv_l = list(map(int, input().split()))\n\nif len(set(v_l)) == 1:\n print(n // 2)\n exit()\n\nv_l_odd = []\nv_l_even = []\n\nfor i in range(n):\n if i % 2 == 0:\n v_l_odd.append(v_l[i])\n else:\n v_l_even.append(v_l[i])\n\nmax_odd = collections.Counter(v_l_odd)\nmon = max_odd.most_common(1)[0][0]\nmax_even = collections.Counter(v_l_even)\nmen = max_even.most_common(1)[0][0]\n\nif mon == men:\n if max(max_odd.most_common(2)[1][1], max_even.most_common(2)[1][1]) \n== max_odd.most_common(2)[1][1]:\n mon = max_odd.most_common(2)[1][1]\n else:\n men = max_even.most_common(2)[1][1]\n\nv_l_odd_l = []\nv_l_even_l = []\n\nfor i in range(n):\n if i % 2 == 0:\n if v_l[i] != mon:\n v_l_odd_l.append(v_l[i])\n else:\n if v_l[i] != men:\n v_l_even_l.append(v_l[i])\n\nprint(len(v_l_odd_l) + len(v_l_even_l))\n\n\n', 'import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\ns = len(set(v))\nif s == 1:\n print(n // 2)\n exit()\n\nodd = v[::2]\neven = v[1::2]\nmo = collections.Counter(odd).most_common(2)\nme = collections.Counter(even).most_common(2)\n\nif mo[0][0] != me[0][0]:\n print(n - mo[0][1] - me[0][1])\nelif len(mo) == 1:\n print(n - mo[0][1] - me[1][1])\nelif len(me) == 1:\n print(n - mo[1][1] - me[0][1])\nelse:\n print(n - max(mo[0][1] + me[1][1], mo[1][1] + me[0][1]))\n']
|
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s099535148', 's633304479', 's882438774', 's968535041', 's820706206']
|
[17508.0, 3064.0, 23644.0, 3064.0, 16228.0]
|
[122.0, 17.0, 196.0, 17.0, 79.0]
|
[492, 925, 1094, 925, 486]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.