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
u485716382
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
["from collections import Counter\n\n\ndef main():\n n = int(input())\n v_n = input().split(' ')\n \n gu = Counter(v_n[::2])\n ki = Counter(v_n[1::2])\n\n guusuu = gu.most_common()\n kisuu = ki.most_common()\n\n print(guusuu)\n print(kisuu)\n print('len: ', len(guusuu), ', ', len(kisuu))\n if guusuu[0][0]==kisuu[0][0]:\n if len(guusuu)==1 and len(kisuu)==1:\n print(len(gu))\n else:\n print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))\n else:\n print(n - guusuu[0][1] - kisuu[0][1])\n\nmain()\n", "from collections import Counter\n\n\ndef main():\n n = int(input())\n v_n = input().split(' ')\n\n \n \n a_n = Counter(v_n[::2])\n a_n2 = Counter(v_n[1::2])\n\n\n # print(a_n)\n # print(a_n2)\n\n a_n = a_n.most_common()\n a_n2 = a_n2.most_common()\n\n\n\n # print(a_n)\n # print(a_n2)\n\n max_an = a_n[0][1]\n max_an2 = a_n2[0][1]\n\n # print(max_an)\n # print(max_an2)\n\n if len(set(a_n)) == 1:\n print(n/2 - 1)\n elif len(set(a_n2)) == 1:\n print(n/2 - 1)\n\n\n\n\nmain()", "from collections import Counter\n\n\ndef main():\n n = int(input())\n v_n = input().split(' ')\n \n gu = Counter(v_n[::2])\n ki = Counter(v_n[1::2])\n\n guusuu = gu.most_common()\n kisuu = ki.most_common()\n\n print(guusuu, len(guusuu))\n print(kisuu, len(kisuu))\n \n if guusuu[0][0]==kisuu[0][0]:\n if len(guusuu)==1 and len(kisuu)==1:\n # n=4, `4 4 4 4`\n # print('----------')\n print(guusuu[0][1])\n else:\n print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))\n else:\n print(n - guusuu[0][1] - kisuu[0][1])\n\nmain()", "from collections import Counter\n\n\ndef main():\n n = int(input())\n v_n = input().split(' ')\n \n gu = Counter(v_n[::2])\n ki = Counter(v_n[1::2])\n\n guusuu = gu.most_common()\n kisuu = ki.most_common()\n\n \n \n \n if guusuu[0][0]==kisuu[0][0]:\n if len(guusuu)==1 and len(kisuu)==1:\n # n=4, `4 4 4 4`\n # print('----------')\n print(guusuu[0][1])\n else:\n print(min(n - guusuu[0][1] - kisuu[1][1], n - guusuu[1][1] - kisuu[0][1]))\n else:\n print(n - guusuu[0][1] - kisuu[0][1])\n\nmain()"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s601325042', 's837084853', 's966718367', 's815912484']
[26988.0, 22504.0, 26988.0, 25580.0]
[136.0, 89.0, 134.0, 86.0]
[573, 500, 620, 624]
p03244
u494058663
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(" "))\ncount = 0\nprint(v)\n\nfor i in range(0,n-2):\n if v[i]!=v[i+2]:\n v[i+2]=v[i]\n count+=1\n \n if v[i]==v[i+1]:\n count+=1\n \nprint(count) ', 'import collections\nn = int(input())\nv = [int(i) for i in input().split()]\nkisu = []\ngusu = []\n\nkisu = v[::2]\ngusu = v[1::2]\n\nkisu_cnt = collections.Counter(kisu)\ngusu_cnt = collections.Counter(gusu)\n\nkisu_cnt = kisu_cnt.most_common(2)\ngusu_cnt = gusu_cnt.most_common(2)\nkisu_most = 0\ngusu_most = 0\nif kisu_cnt[0][0]!=gusu_cnt[0][0]:\n print(n-kisu_cnt[0][1]-gusu_cnt[0][1])\n exit()\nelse:\n if len(kisu_cnt)==1 or len(gusu_cnt)==1:\n print(n//2)\n exit()\n else:\n print(n-max(kisu_cnt[0][1]+gusu_cnt[1][1],kisu_cnt[1][1]+gusu_cnt[0][1]))']
['Wrong Answer', 'Accepted']
['s707031774', 's179242213']
[13160.0, 23452.0]
[91.0, 67.0]
[220, 649]
p03244
u497952650
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 main():\n \n N = int(input())\n V = list(map(int,input().split()))\n odd = V[1::2]\n even = V[0::2]\n mode_o = Counter(odd).most_common()\n mode_o.append([0,0])\n mode_e = Counter(even).most_common()\n mode_e.append([0,0])\n ans = 0\n if mode_o[0][0] != mode_e[0][0]:\n ans = N-mode_o[0][1]-mode_e[0][1]\n else:\n if mode_e[0][1] < mode_o[0][1]:\n ans = N - mode_e[0][1] - mode_o[1][1]\n else:\n ans = N - mode_e[1][1] - mode_o[0][1]\n \n print(ans)', 'from collections import Counter\n\ndef main():\n \n N = int(input())\n V = list(map(int,input().split()))\n odd = V[1::2]\n even = V[0::2]\n mode_o = Counter(odd).most_common()\n mode_o.append([0,0])\n mode_e = Counter(even).most_common()\n mode_e.append([0,0])\n ans = 0\n if mode_o[0][0] != mode_e[0][0]:\n ans = N-mode_o[0][1]-mode_e[0][1]\n else:\n ans = N - max(mode_e[0][1]+mode_o[1][1],mode_e[1][1]+mode_o[0][1])\n print(ans)\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s527443625', 's244636058']
[3316.0, 21084.0]
[20.0, 84.0]
[552, 507]
p03244
u501952592
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\nx = Counter(v[::2])\ny = Counter(v[1::2])\n\nans = n\nif len(x) > 1:\n ans -= x.most_common(1)[0][1]\nif len(y) > 1:\n ans -= y.most_common(1)[0][1]\nprint(ans)', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\n\nx = Counter(v[::2]).most_common(2)\ny = Counter(v[1::2]).most_common(2)\nans = n\nif x[0][0] == y[0][0]:\n if len(x) == len(y) == 1:\n ans = n//2\n else:\n s = max([a[1] for a in x]) + min([b[1] for b in y])\n t = min([a[1] for a in x]) + max([b[1] for b in y])\n ans -= max(s, t)\nelse:\n ans -= x[0][1] + y[0][1]\nprint(ans)']
['Wrong Answer', 'Accepted']
['s452273004', 's164386917']
[23176.0, 21468.0]
[71.0, 69.0]
[241, 416]
p03244
u503228842
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['n = int(input())\nl = list(map(int,input().split()))\n\nfrom collections import Counter\nl1 = Counter(l[0::2])\nmostl1 = l1.most_common()[0]\nsemimostl1 = l1.most_common()[1]\n\nl2 = Counter(l[1::2])\nmostl2 = l2.most_common()[0]\nsemimostl2 = l2.most_common()[1]\n\nif mostl1[0] != mostl2[0]:\n print(n-mostl1[1]-mostl2[1])\n#elif print(min(n-mostl1[1]-mostl2[1],n-mostl1[1]-mostl2[1]))', 'n = int(input())\nl = list(map(int,input().split()))\n\nfrom collections import Counter\nl1 = Counter(l[0::2])\nmostl1 = l1.most_common()[0]\n\n\nl2 = Counter(l[1::2])\nmostl2 = l2.most_common()[0]\n\n\nif mostl1[0] != mostl2[0]:\n print(n-mostl1[1]-mostl2[1])\nelif len(l1.keys()) == 1 and len(l2.keys()) == 1:\n print(int(n/2))\n\nelse:\n semimostl1 = l1.most_common()[1]\n semimostl2 = l2.most_common()[1]\n print(min(n - mostl1[1] - semimostl2[1], n - semimostl1[1] - mostl2[1]))\n\n\n#elif print(min(n-mostl1[1]-mostl2[1],n-mostl1[1]-mostl2[1]))']
['Runtime Error', 'Accepted']
['s239979722', 's498053346']
[19060.0, 18784.0]
[100.0, 106.0]
[376, 608]
p03244
u518042385
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\ndic1=defaultdict(int)\ndic2=defaultdict(int)\nn=int(input())\nl=list(map(int,input().split()))\nif n%2==0:\n for i in range(0,n-1,2):\n dic1[l[i]]+=1\n for i in range(1,n,2):\n dic2[l[i]]+=1\n max11=0\n i1=0\n max12=0\n i2=0\n max21=0\n i3=0\n max22=0\n i4=0\n for i in dic1:\n if dic1[i]>max11:\n max12=max11\n max11=dic1[i]\n i2=i1\n i1=i\n elif dic1[i]>max12:\n max12=dic1[i]\n i2=i\n for i in dic1:\n if dic1[i]>max11:\n max12=max11\n max11=dic1[i]\n i4=i3\n i3=i\n elif dic1[i]>max12:\n max12=dic1[i]\n i4=i\n if i1!=i3:\n print(n-max11-max21)\n elif l1==l3:\n print(min(n-max11-max22,n-max21-max12))\n\n \n \n ', 'from collections import defaultdict\ndic1=defaultdict(int)\ndic2=defaultdict(int)\nn=int(input())\nl=list(map(int,input().split()))\nfor i in range(0,n-1,2):\n dic1[l[i]]+=1\nfor i in range(1,n,2):\n dic2[l[i]]+=1\nmax11=0\ni1=0\nmax12=0\ni2=0\nmax21=0\ni3=0\nmax22=0\ni4=0\nfor i in dic1:\n if dic1[i]>=max11:\n max12=max11\n max11=dic1[i]\n i2=i1\n i1=i\n elif dic1[i]>max12:\n max12=dic1[i]\n i2=i\nfor i in dic2:\n if dic2[i]>=max21:\n max22=max21\n max21=dic2[i]\n i4=i3\n i3=i\n elif dic2[i]>max22:\n max22=dic2[i]\n i4=i\nif i1!=i3:\n print(n-max11-max21)\nelif i1==i3:\n print(min(n-max11-max22,n-max21-max12))']
['Wrong Answer', 'Accepted']
['s283135778', 's329266299']
[18400.0, 18400.0]
[104.0, 120.0]
[715, 624]
p03244
u519078363
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 = 12\nv = list(map(int, '1 1 1 1 2 2 2 2 2 2 3 3'.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[1][1]+b[0][1]), n-(a[0][1]+b[1][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()\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', 'Accepted']
['s408677925', 's949945646']
[3316.0, 20572.0]
[20.0, 84.0]
[321, 313]
p03244
u527261492
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['import collections\nn=int(input())\nv=list(map(int,input().split()))\na=[]\nb=[]\nfor i in range(0,n,1):\n a.append(v[i])\n b.append(v[i+1])\nc=collections.Counter(a)\nd=collections.Counter(b)\nC=sorted(c.items(), key=lambda x:-x[1])\nD=sorted(d.items(), key=lambda x:-x[1])\nA=int(C[0][0])\nB=int(D[0][0])\ncnt=0\nfor i in range(n):\n if a[i]!=A:\n cnt+=1\nfor j in range(n):\n if b[j]!=B:\n cnt+=1\nprint(cnt)\n\n \n\n\n\n', 'import collections\nn=int(input())\nv=list(map(int,input().split()))\na=[]\nb=[]\nfor i in range(0,n,1):\n a.append(v[i-1])\n b.append(v[i])\nc=collections.Counter(a)\nd=collections.Counter(b)\nC=sorted(c.items(), key=lambda x:-x[1])\nD=sorted(d.items(), key=lambda x:-x[1])\nA=int(C[0][0])\nB=int(D[0][0])\ncnt=0\nfor i in range(n//2):\n if a[i]!=A:\n cnt+=1\nfor j in range(n//2):\n if b[j]!=B:\n cnt+=1\nprint(cnt)\n\n \n\n\n\n', 'import collections,sys\nn=int(input())\nv=list(map(int,input().split()))\na=[]\nb=[]\nfor i in range(0,n,2):\n a.append(v[i-1])\n b.append(v[i])\nc=collections.Counter(a)\nd=collections.Counter(b)\nC=sorted(c.items(), key=lambda x:-x[1])\nD=sorted(d.items(), key=lambda x:-x[1])\nA=int(C[0][0])\nB=int(D[0][0])\ncnt=0\nif len(set(v))==1:\n print(n//2)\n sys.exit()\nif A!=B:\n for i in range(n//2):\n if a[i]!=A:\n cnt+=1\n for j in range(n//2):\n if b[j]!=B:\n cnt+=1\n print(cnt)\n sys.exit()\nif A==B:\n totla=0\n A_=int(C[1][0]) if len(set(a))!=1 else A\n for i in range(n//2):\n if a[i]!=A_:\n totla+=1\n for j in range(n//2):\n if b[j]!=B:\n totla+=1\n totlb=0\n B_=int(D[1][0]) if len(set(b))!=1 else B\n for i in range(n//2):\n if a[i]!=A:\n totlb+=1\n for j in range(n//2):\n if b[j]!=B_:\n totlb+=1\n print(min(totla,totlb))\n sys.exit()\n \n \n \n \n \n \n \n\n \n\n\n\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s305110550', 's797346532', 's765932245']
[14788.0, 40540.0, 29920.0]
[76.0, 187.0, 160.0]
[410, 416, 905]
p03244
u533232830
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['n = int(input())\nl = list(map(int, input().split()))\n\nl0 = l[::2]\nl1 = l[1::2]\n\nl0.sort()\nl1.sort()\n\n# print(l0)\n# print(l1)\n\nmemo0 = [[1, l0[0]]]\nmemo1 = [[1, l1[0]]]\nfor i in range(1, n//2):\n if memo0[-1][1] == l0[i]:\n memo0[-1][0] += 1\n else:\n memo0.append([1, l0[i]])\n\n if memo1[-1][1] == l1[i]:\n memo1[-1][0] += 1\n else:\n memo1.append([1, l1[i]])\n\nmemo0.sort(reverse=True)\nmemo1.sort(reverse=True)\n\nmemo0.append([0, -1])\nmemo1.append([0, -1])\n\nprint(memo0)\nprint(memo1)\n\nif memo0[0][1]!=memo1[0][1]:\n print(n-memo0[0][0]-memo1[0][0])\nelse:\n ans1 = n- memo0[0][0]-memo1[1][0]\n ans2 = n- memo0[1][0]-memo1[0][0]\n print(min(ans1, ans2))', 'n = int(input())\nl = list(map(int, input().split()))\n\nl0 = l[::2]\nl1 = l[1::2]\n\nl0.sort()\nl1.sort()\n\n# print(l0)\n# print(l1)\n\nmemo0 = [[1, l0[0]]]\nmemo1 = [[1, l1[0]]]\nfor i in range(1, n//2):\n if memo0[-1][1] == l0[i]:\n memo0[-1][0] += 1\n else:\n memo0.append([1, l0[i]])\n\n if memo1[-1][1] == l1[i]:\n memo1[-1][0] += 1\n else:\n memo1.append([1, l1[i]])\n\nmemo0.sort(reverse=True)\nmemo1.sort(reverse=True)\n\nmemo0.append([0, -1])\nmemo1.append([0, -1])\n\n# print(memo0)\n# print(memo1)\n\nif memo0[0][1]!=memo1[0][1]:\n print(n-memo0[0][0]-memo1[0][0])\nelse:\n ans1 = n- memo0[0][0]-memo1[1][0]\n ans2 = n- memo0[1][0]-memo1[0][0]\n print(min(ans1, ans2))']
['Wrong Answer', 'Accepted']
['s395195542', 's649277352']
[21348.0, 18560.0]
[182.0, 143.0]
[690, 694]
p03244
u536034761
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()))\nx = len(set(V))\nif x == 1:\n print(n // 2)\nelse:\n V = Counter(V)\n a, b = V.most_common(2)\n a = a[1]\n b = b[1]\n if x == 2:\n y = abs(a - b)\n if y <= 1:\n print(0)\n else:\n print(y)\n else:\n print(n - a - b + max(a, b) - min(a, b) + 1)', 'from collections import Counter\nn = int(input())\nV = list(map(int, input().split()))\nx = len(set(V))\nif x == 1:\n print(n // 2)\nelse:\n A = list()\n B = list()\n for i, v in enumerate(V):\n if i & 1:\n A.append(v)\n else:\n B.append(v)\n A = Counter(A).most_common()\n B = Counter(B).most_common()\n a = A[0]\n b = B[0]\n if a[0] == b[0]:\n if len(A) == 1:\n b = B[1]\n elif len(B) == 1:\n a = A[1]\n else:\n if A[1][1] >= B[1][1]:\n a = A[1]\n else:\n b = B[1]\n print(n - a[1] - b[1])\n']
['Wrong Answer', 'Accepted']
['s517916014', 's007785204']
[25324.0, 25500.0]
[72.0, 101.0]
[384, 625]
p03244
u536113865
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.
['ai = lambda: list(map(int,input().split()))\nai_ = lambda: [int(x)-1 for x in input().split()]\n\nn = int(input())\na = ai()\nif all(i == a[0] for i in a):\n print(n//2)\n exit()\n\na1 = a[::2]\na2 = a[1::2]\n\nfrom collections import Counter\nc1 = Counter(a1)\nc2 = Counter(a2)\nm1 = c1.most_common(2)\nm2 = c2.most_common(2)\nif m1[0][0] == m2[0][0]:\n if len(c1) == 1:\n print(n-m1[0][1]-m2[1][1])\n elif len(c2) == 1:\n print(n - m1[0][1] - m2[1][1])\n else:\n print(min(n-m1[0][1]-m2[1][1], n-m1[1][1]-m2[0][1]))\nelse:\n print(n-m1[0', 'ai = lambda: list(map(int,input().split()))\nai_ = lambda: [int(x)-1 for x in input().split()]\n\nn = int(input())\na = ai()\nif all(i == a[0] for i in a):\n print(n//2)\n exit()\n\na1 = a[::2]\na2 = a[1::2]\n\nfrom collections import Counter\nc1 = Counter(a1)\nc2 = Counter(a2)\nm1 = c1.most_common(2)\nm2 = c2.most_common(2)\nif m1[0][0] == m2[0][0]:\n if len(c1) == 1:\n print(n-m1[0][1]-m2[1][1])\n elif len(c2) == 1:\n print(n - m1[0][1] - m2[1][1])\n else:\n print(min(n-m1[0][1]-m2[1][1], n-m1[1][1]-m2[0][1]))\nelse:\n print(n-m1[0][1] - m2[0][1])']
['Runtime Error', 'Accepted']
['s043630189', 's417097585']
[3064.0, 19040.0]
[17.0, 86.0]
[553, 569]
p03244
u537782349
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 = int(input())\nb = list(map(int, input().split()))\nc = []\nfor i in range(a):\n d = False\n for j in range(0, len(c)):\n if c[j][0] == b[i]:\n c[j][1] += 1\n d = True\n break\n if not d:\n c.append([b[i], 1])\nc = sorted(c, key=lambda x: x[0], reverse=True)\nprint("test")\nexit()\nif len(c) <= 1:\n print(a // 2)\nelse:\n e = [c[0][0], c[1][0]] + b\n f = [c[1][0], c[0][0]] + b\n ec = 0\n fc = 0\n for i in range(2, len(e)):\n if e[i] != e[i-2]:\n e[i] = e[i-2]\n ec += 1\n if f[i] != f[i-2]:\n f[i] = f[i-2]\n fc += 1\n print(min(ec, fc))\n', 'a = int(input())\nb = list(map(int, input().split()))\nc = {}\nfor i in range(a):\n if str(b[i]) in c:\n c[str(b[i])] += 1\n else:\n c[str(b[i])] = 1\nc = sorted(c.items(), key=lambda x: x[1], reverse=True)\nif len(c) <= 1:\n print(a // 2)\nelif len(c) == 2:\n e = [int(c[0][0]), int(c[1][0])] + b\n f = [int(c[1][0]), int(c[0][0])] + b\n ec = 0\n fc = 0\n for i in range(2, len(e)):\n if e[i] != e[i-2]:\n e[i] = e[i-2]\n ec += 1\n if f[i] != f[i-2]:\n f[i] = f[i-2]\n fc += 1\n print(min(ec, fc))\nelif len(c) >= 3:\n e = [int(c[0][0]), int(c[1][0])] + b\n f = [int(c[1][0]), int(c[0][0])] + b\n g = [int(c[0][0]), int(c[2][0])] + b\n h = [int(c[1][0]), int(c[2][0])] + b\n j = [int(c[2][0]), int(c[0][0])] + b\n k = [int(c[2][0]), int(c[1][0])] + b\n\n ec = 0\n fc = 0\n gc = 0\n hc = 0\n jc = 0\n kc = 0\n for i in range(2, len(e)):\n if e[i] != e[i-2]:\n e[i] = e[i-2]\n ec += 1\n if f[i] != f[i-2]:\n f[i] = f[i-2]\n fc += 1\n if g[i] != g[i-2]:\n g[i] = g[i-2]\n gc += 1\n if h[i] != h[i-2]:\n h[i] = h[i-2]\n hc += 1\n if j[i] != j[i-2]:\n j[i] = j[i-2]\n jc += 1\n if k[i] != k[i-2]:\n k[i] = k[i-2]\n kc += 1\n print(min(ec, fc, gc, hc, jc, kc))\n']
['Wrong Answer', 'Accepted']
['s665277198', 's212903948']
[14236.0, 27284.0]
[2104.0, 343.0]
[651, 1414]
p03244
u539517139
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=list(map(int,input().split()))\no=[]\ne=[]\nfor i in range(n):\n if i%2==0:\n o.append(a[i])\n else:\n e.append(a[i])\nfrom collections import Counter as co\no=co(o)\ne=co(e)\no['x']=0\ne['x']=0\nov=o.values()+[0]\nev=e.values()+[0]\nmo=max(ov)\nme=max(ev)\nif n==2:\n if a[0]==a[1]:\n print(1)\n else:\n print(0)\nelse:\n if max(o,key=o.get)==max(e,key=e.get):\n if mo>me:\n me=sorted(ev)[-2]\n else:\n mo=sorted(ov)[-2]\n print(n-mo-me)", 'n=int(input())\na=list(map(int,input().split()))\no=[]\ne=[]\nfor i in range(n):\n if i%2==0:\n o.append(a[i])\n else:\n e.append(a[i])\nfrom collections import Counter as co\no=co(o)\ne=co(e)\nov=o.values()+[0]\nev=e.values()+[0]\nmo=max(ov)\nme=max(ev)\nif n==2:\n if a[0]==a[1]:\n print(1)\n else:\n print(0)\nelse:\n if max(o,key=o.get)==max(e,key=e.get):\n if mo>me:\n me=sorted(ev)[-2]\n else:\n mo=sorted(ov)[-2]\n print(n-mo-me)', "n=int(input())\na=list(map(int,input().split()))\no=[]\ne=[]\nfor i in range(n):\n if i%2==0:\n o.append(a[i])\n else:\n e.append(a[i])\nfrom collections import Counter as co\no=co(o)\ne=co(e)\no['x']=0\ne['x']=0\nov=o.values()\nev=e.values()\nmo=max(ov)\nme=max(ev)\nif n==2:\n if a[0]==a[1]:\n print(1)\n else:\n print(0)\nelse:\n if max(o,key=o.get)==max(e,key=e.get):\n if mo>me:\n me=sorted(ev)[-2]\n elif mo<me:\n mo=sorted(ov)[-2]\n else:\n mo=max(sorted(ev)[-2],sorted(ov)[-2])\n print(n-mo-me)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s744215483', 's880526241', 's149962165']
[18528.0, 18656.0, 18552.0]
[82.0, 85.0, 104.0]
[461, 443, 513]
p03244
u545368057
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 numpy as np\nn = int(input())\nAs = input().split()\nAs = [int(A) for A in As]\n# n=4\n# As = [3,1,3,2,4,3,1,1]\n# As = [1,1,1,2,1,1,1,1]\n\n# print(As)\nA_odd = As[::2] \nA_even = As[1:][::2] \n\nprint(A_odd,A_even)\n\ndef num_pair(l):\n counts_pair = []\n for i in set(l):\n counts_pair.append([i,l.count(i)])\n odd = np.array(counts_pair)\n return odd[odd[:,1].argsort()[::-1],:]\n\nodd_pair = num_pair(A_odd)\neven_pair = num_pair(A_even)\n\n\nif odd_pair[0][0] != even_pair[0][0]:\n print(n-odd_pair[0][1]-even_pair[0][1])\nelse:\n if len(odd_pair) == 1 and len(even_pair) == 1:\n print(n/2)\n elif len(odd_pair) == 1:\n print(n-even_pair[1][1])\n elif len(even_pair) == 1:\n print(n-odd_pair[1][1]) \n elif odd_pair[1][1] > even_pair[1][1]:\n print(n-even_pair[0][1]-odd_pair[1][1])\n else:\n print(n-odd_pair[0][1]-odd_pair[1][1])\n', 'import numpy as np\nfrom collections import Counter\nn = int(input())\nAs = input().split()\nAs = [int(A) for A in As]\n\nA_odd = As[::2] \nA_even = As[1:][::2] \n\n\nodd_pair = Counter(A_odd).most_common(2)\neven_pair = Counter(A_even).most_common(2)\n\nif odd_pair[0][0] != even_pair[0][0]: \n N = n-odd_pair[0][1]-even_pair[0][1]\nelse: \n if len(odd_pair) == 1 and len(even_pair) == 1: \n N = n/2\n elif len(odd_pair) == 1: \n N = n-even_pair[1][1]\n elif len(even_pair) == 1: \n N = n-odd_pair[1][1] \n elif odd_pair[1][1] > even_pair[1][1]: \n N = n-even_pair[0][1]-odd_pair[1][1]\n else:\n N = n-odd_pair[0][1]-even_pair[1][1] \nprint(int(N))']
['Wrong Answer', 'Accepted']
['s888993824', 's076162931']
[23436.0, 32900.0]
[2111.0, 351.0]
[911, 1022]
p03244
u547167033
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 Counter\nn=int(input())\nv=list(map(int,input().split()))\ns1,s2=[],[]\nfor i in range(n):\n if i%2==0:\n s1.append(v[i])\n else:\n s2.append(v[i])\nc1=Counter(s1)\nc2=Counter(s2)\nd1=c1.most_common()\nd2=c2.most_common()\nif d1[0][0]!=d2[0][0]:\n print(n-d1[0][1]-d2[0][1])\nelse:\n print(min(n-d1[0][1]-d2[1][1],n-d1[1][1]-d2[0][1]))', 'from collections import Counter\nn=int(input())\nv=list(map(int,input().split()))\ns1,s2=[],[]\nfor i in range(n):\n if i%2==0:\n s1.append(v[i])\n else:\n s2.append(v[i])\nc1=Counter(s1)\nc2=Counter(s2)\nd1=c1.most_common()\nd2=c2.most_common()\nif d1[0][0]!=d2[0][0]:\n print(n-d1[0][1]-d2[0][1])\nelse:\n if len(d1)>1 and len(d2)>1:\n print(min(n-d1[0][1]-d2[1][1],n-d1[1][1]-d2[0][1]))\n elif len(d1)==1 and len(d2)==1:\n print(n//2)\n elif len(d1)==1:\n print(n//2-d2[0][1])\n else:\n print(n//2-d1[0][1])']
['Runtime Error', 'Accepted']
['s746258247', 's509038052']
[3064.0, 23776.0]
[17.0, 122.0]
[336, 512]
p03244
u548303713
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()))\nv.insert(0,0) \ncheck=0 \nnow=v[1]\nfor i in range(2,n):\n if now!=v[i]:\n check=1\n break\n \nodd=[]\neven=[]\nfor i in range(1,n+1):\n if i%2==1:\n odd.append(v[i])\n else:\n even.append(v[i])\n \nodd2=sorted(odd)\neven2=sorted(even)\nnow_odd,now_even=odd2[0],even2[0]\nrensa_odd,rensa_even=1,1\nhalf=n//2\ncount_odd=[]\ncount_even=[]\n\nfor i in range(1,half):\n if odd2[i]==now_odd:\n rensa_odd+=1\n else:\n count_odd.append([rensa_odd,now_odd])\n now_odd=odd2[i]\n rensa_odd=1\ncount_odd.append([rensa_odd,now_odd])\n\nfor i in range(1,half):\n if even2[i]==now_even:\n rensa_even+=1\n else:\n count_even.append([rensa_even,now_even])\n now_even=even2[i]\n rensa_even=1\ncount_even.append([rensa_even,now_even])\ncount_odd2=sorted(count_odd,reverse=True)\ncount_even2=sorted(count_odd,reverse=True)\n\nif check==0:\n print(half)\nelse:\n if count_odd2[0][1]!=count_even2[0][1]: \n print((half-count_odd2[0][0])+(half-count_even2[0][0]))\n else:\n if len(count_odd2)==1:\n print((half-count_odd2[0][0])+(half-count_even2[1][0]))\n elif len(count_even2)==1:\n print((half-count_odd2[1][0])+(half-count_even2[0][0]))\n else:\n print(min((half-count_odd2[0][0])+(half-count_even2[1][0]),(half-count_odd2[1][0])+(half-count_even2[0][0])))', 'n=int(input())\nv=list(map(int,input().split()))\nv.insert(0,0)\ncheck=0 \nnow=v[0]\nfor i in range(1,n):\n if now!=v[i]:\n check=1\n break\nodd=[]\neven=[]\nfor i in range(1,n+1):\n if i%2==1:\n odd.append(v[i])\n else:\n even.append(v[i])\nans=0\nodd2=sorted(odd)\neven2=sorted(even)\nnow_odd,now_even=odd2[0],even2[0]\nrensa_odd,rensa_even=1,1\nmax_rensa_odd,max_rensa_even=1,1\nhalf=n//2\nfor i in range(1,half):\n if odd2[i]==now_odd:\n rensa_odd+=1\n else:\n now_odd=odd2[i]\n if rensa_odd>max_rensa_odd:\n max_rensa_odd=rensa_odd\n rensa_odd=1\nif rensa_odd>max_rensa_odd:\n max_rensa_odd=rensa_odd\nfor i in range(1,half):\n if even2[i]==now_even:\n rensa_even+=1\n else:\n now_even=even2[i]\n if rensa_even>max_rensa_even:\n max_rensa_even=rensa_even\n rensa_even=1\nif rensa_even>max_rensa_even:\n max_rensa_even=rensa_even\nprint(n-max_rensa_odd-max_rensa_even if check==0 else half)', 'n=int(input())\nv=list(map(int,input().split()))\nodd=[[0,0] for i in range(10**5+1)]\neven=[[0,0] for i in range(10**5+1)]\nfor i in range(1,10**5+1):\n odd[i][1]=i\n even[i][1]=i\nfor i in range(n):\n if (i+1)%2==1:\n odd[v[i]][0]+=1\n else:\n even[v[i]][0]+=1\nodd=sorted(odd,reverse=True)\neven=sorted(even,reverse=True)\nans=0\nif(odd[0][0]+even[0][0]==n): #odd[0][0]=n//2\n if(odd[0][1]==even[0][1]):\n ans=n//2\n else:\n ans=0\n\nelse:\n \n if(odd[0][1]==even[0][1]):\n if(odd[0][0]+even[1][0]<=odd[1][0]+even[0][0]):\n ans=(n//2-odd[1][0])+(n//2-even[0][0])\n else:\n ans=(n//2-odd[0][0])+(n//2-even[1][0])\n\n else:\n ans=(n//2-odd[0][0])+(n//2-even[0][0])\nprint(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s531690877', 's847411777', 's753352285']
[19584.0, 14208.0, 32644.0]
[171.0, 123.0, 221.0]
[1502, 1050, 833]
p03244
u550943777
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()))\nv_even = [0 for i in range(max(v)+1)]\nv_odd = [0 for i in range(max(v))+1]\nsum_even = 0\nsum_odd = 0\nfor i in range(N):\n if i%2 :\n v_odd[v[i]] += 1\n sum_odd += 1\n else:\n v_even[v[i]] += 1\n sum_even += 1\nmax_odd = 0\nodd = 0\nmax_even = 0\neven = 0\nfor i in range(len(v_odd)):\n if v_odd[i] > max_odd:\n max_odd = v_odd[i]\n odd = i\n\nfor i in range(len(v_even)):\n if v_even[i] > max_even:\n max_even = v_even[i]\n even = i\n\nif odd != even:\n ans = sum_even - max_even + sum_odd - max_odd\nelse:\n v_odd[odd] = 0\n v_even[even] = 0\n ans = min((sum_even - max_even + sum_odd - max(v_odd)), sum_even - max(v_even) + sum_odd - max_odd)\n\nprint(ans)', 'N = int(input())\nv = list(map(int,input().split()))\nv_even = [0 for i in range(max(v)+1)]\nv_odd = [0 for i in range(max(v)+1)]\nsum_even = 0\nsum_odd = 0\nfor i in range(N):\n if i%2 :\n v_odd[v[i]] += 1\n sum_odd += 1\n else:\n v_even[v[i]] += 1\n sum_even += 1\nmax_odd = 0\nodd = 0\nmax_even = 0\neven = 0\nfor i in range(len(v_odd)):\n if v_odd[i] > max_odd:\n max_odd = v_odd[i]\n odd = i\n\nfor i in range(len(v_even)):\n if v_even[i] > max_even:\n max_even = v_even[i]\n even = i\n\nif odd != even:\n ans = sum_even - max_even + sum_odd - max_odd\nelse:\n v_odd[odd] = 0\n v_even[even] = 0\n ans = min((sum_even - max_even + sum_odd - max(v_odd)), sum_even - max(v_even) + sum_odd - max_odd)\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s799868092', 's595852767']
[14232.0, 14200.0]
[51.0, 112.0]
[761, 762]
p03244
u557494880
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()))\nv_odd = []\nv_even = []\nfor i in range(n//2):\n v_odd.append()\n v_even.append()\np1 = 0\np2 = 0\nq1 = 0\nq2 = 0\no_max = -1\ne_max = -1\nfor i in range(n//2):\n a = v_odd[i]\n b = v_even[i]\n x = v_odd.count(a)\n y = v_even.count(b)\n if p1 <= x:\n if o_max != a:\n o_max = a\n p2 = p1\n p1 = x\n else:\n if x > p2:\n p2 = x\n if q1 <= y:\n if e_max != b:\n e_max = b\n q2 = q1\n q1 = y\n else:\n if y > q2:\n q2 = y\ns = p1 + q1\nif p1 == q1:\n if o_max == e_max:\n s = max(p2,q2) + p1\nelif p1 > q2:\n if o_max == e_max:\n s = p1 + q2\nelse: \n if o_max == e_max:\n s = p2 + q1\nans = n - s\nprint(ans)\n \n \n', 'n = int(input())\nv = list(map(int,input().split()))\nv_odd = []\nv_even = []\nd_odd = {}\nd_even = {}\no = []\ne = []\nfor i in range(n//2):\n a = v[2*i]\n b = v[2*i+1]\n if a in d_odd:\n d_odd[a] += 1\n else:\n d_odd[a] = 1\n o.append(a)\n if b in d_even:\n d_even[b] += 1\n else:\n d_even[b] = 1\n e.append(b)\nO = 0\nE = 0\no_max = 0\no_second = 0\ne_max = 0\ne_second = 0\nfor i in o:\n x = d_odd[i]\n if x >= o_max:\n O = i\n o_max = x\nd_odd.pop(O)\no.remove(O)\nfor i in o:\n x = d_odd[i]\n if x >= o_second:\n o_second = x\nfor i in e:\n y = d_even[i]\n if y >= e_max:\n E = i\n e_max = y\nd_even.pop(E)\ne.remove(E)\nfor i in e:\n y = d_even[i]\n if y >= e_second:\n e_second = y\nif O == E:\n m = max(o_max+e_second,e_max+o_second)\nelse:\n m = o_max + e_max\nprint(n-m)']
['Runtime Error', 'Accepted']
['s800326448', 's520858035']
[14356.0, 17312.0]
[41.0, 130.0]
[804, 860]
p03244
u558242240
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\nn = len(v)\nfrom collections import defaultdict\nc0 = defaultdict(int)\nfor vi in v[0::2]:\n c0[vi] += 1\nc1 = defaultdict(int)\nfor vi in v[1::2]:\n c1[vi] += 1\n\nsc0 = sorted(c0.items(), key=lambda x: x[1])\nsc1 = sorted(c1.items(), key=lambda x: x[1])\n\nprint(sc0)\nprint('-----------')\nprint(sc1)\nif sc0[-1][0] != sc1[-1][0]:\n #print('--1')\n print(n//2 - sc0[-1][1] + n//2 - sc1[-1][1])\n exit()\nif len(sc0) == 1 and len(sc1) == 1:\n #print('--2')\n print(n//2)\n exit()\nif sc0[-1][1] == sc1[-1][1]:\n if sc0[-2][1] > sc1[-2][1]:\n print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])\n else:\n print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])\n exit()\nif sc0[-1][1] > sc1[-1][1]:\n #print('--3')\n print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])\n exit()\nelse:\n #print('--4')\n print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])\n exit()\n (2054, 12394), (27775, 12395)\n(50652, 12393), (27775, 12395)\n", "n = int(input())\nv = list(map(int , input().split()))\n\nn = len(v)\nfrom collections import defaultdict\nc0 = defaultdict(int)\nfor vi in v[0::2]:\n c0[vi] += 1\nc1 = defaultdict(int)\nfor vi in v[1::2]:\n c1[vi] += 1\n\nsc0 = sorted(c0.items(), key=lambda x: x[1])\nsc1 = sorted(c1.items(), key=lambda x: x[1])\n\nprint(sc0, sc1)\nif sc0[-1][0] != sc1[-1][0]:\n print('--1')\n print(n//2 - sc0[-1][1] + n//2 - sc1[-1][1])\n exit()\nif len(sc0) == 1 and len(sc1) == 1:\n print('--2')\n print(n//2)\n exit()\nif sc0[-1][1] >= sc1[-1][1]:\n print('--3')\n print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])\n exit()\nelse:\n print('--4')\n print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])\n exit()\n\n", "n = int(input())\nv = list(map(int , input().split()))\n\nn = len(v)\nfrom collections import defaultdict\nc0 = defaultdict(int)\nfor vi in v[0::2]:\n c0[vi] += 1\nc1 = defaultdict(int)\nfor vi in v[1::2]:\n c1[vi] += 1\n\nsc0 = sorted(c0.items(), key=lambda x: x[1])\nsc1 = sorted(c1.items(), key=lambda x: x[1])\n#print(n)\n#print(sc0)\n#print('------------------')\n#print(sc1)\nif sc0[-1][0] != sc1[-1][0]:\n #print('--1')\n print(n//2 - sc0[-1][1] + n//2 - sc1[-1][1])\n exit()\nif len(sc0) == 1 and len(sc1) == 1:\n #print('--2')\n print(n//2)\n exit()\nif sc0[-1][1] > sc1[-1][1]:\n #print('--3')\n print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])\n exit()\nif sc0[-1][1] < sc1[-1][1]:\n #print('--4')\n print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])\n exit()\nif sc0[-1][1] == sc1[-1][1]:\n if sc0[-2][1] < sc1[-2][1]:\n #print('--1',sc0[-1][1],sc1[-1][1], sc0[-2][1],sc1[-2][1])\n print(n//2 - sc0[-1][1] + n//2 - sc1[-2][1])\n else:\n #print('--1',sc0[-1][1],sc1[-1][1], sc0[-2][1],sc1[-2][1])\n print(n//2 - sc0[-2][1] + n//2 - sc1[-1][1])\n exit()\n\n#(92753, 12393), (2054, 12394), (27775, 12395)\n#(55530, 10), (50652, 12393), (27775, 12395)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s131468945', 's705593573', 's029952001']
[3064.0, 23488.0, 20976.0]
[17.0, 154.0, 121.0]
[979, 700, 1189]
p03244
u559823804
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 heapq\n\nn=int(input())\nve=[0 for _ in range(100010)]\nvo=[0 for _ in range(100010)]\nv = list(map(int,input().split()))\n\nfor nn in range(n):\n vv = v[nn]\n if(nn%2==0):\n ve[vv]+=1\n else:\n vo[vv]+=1\nhve = heapq.nlargest(2,range(len(ve)),key=ve.__getitem__)\nhvo = heapq.nlargest(2,range(len(vo)),key=vo.__getitem__)\n\nif hve[0]==hvo[0]:\n ans = min((n-ve[hve[0]]-vo[hvo[1]]),(n-ve[hve[1]]-vo[hvo[0]]))\nelse:\n ans = n-ve[hve[0]]-vo[hve[0]]\n\nprint(ans)\n', 'import heapq\n\nn=int(input())\nve=[0 for _ in range(100010)]\nvo=[0 for _ in range(100010)]\nv = list(map(int,input().split()))\n\nfor nn in range(n):\n vv = v[nn]\n if(nn%2==0):\n ve[vv]+=1\n else:\n vo[vv]+=1\nhve = heapq.nlargest(2,range(len(ve)),key=ve.__getitem__)\nhvo = heapq.nlargest(2,range(len(vo)),key=vo.__getitem__)\n\nif ve[hve[0]]==vo[hvo[0]]:\n ans = min((n-ve[hve[0]]-vo[hvo[1]]),(n-ve[hve[1]]-vo[hvo[0]]))\nelse:\n ans = n-ve[hve[0]]-vo[hve[0]]\n\nprint(ans)\n', 'import heapq\n\nn=int(input())\nve=[0 for _ in range(100010)]\nvo=[0 for _ in range(100010)]\nv = list(map(int,input().split()))\n\nfor nn in range(n):\n vv = v[nn]\n if(nn%2==0):\n ve[vv]+=1\n else:\n vo[vv]+=1\nhve = heapq.nlargest(2,range(len(ve)),key=ve.__getitem__)\nhvo = heapq.nlargest(2,range(len(vo)),key=vo.__getitem__)\n\nif hve[0]==hvo[0]:\n ans = min((n-ve[hve[0]]-vo[hvo[1]]),(n-ve[hve[1]]-vo[hvo[0]]))\nelse:\n ans = n-ve[hve[0]]-vo[hvo[0]]\n\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s140695415', 's769935711', 's447249133']
[16160.0, 15620.0, 16160.0]
[104.0, 105.0, 109.0]
[514, 522, 514]
p03244
u561339958
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(int(x) for x in input().split())\nel = []\nol = []\nfor i in range(n):\n if i % 2 == 0:\n el.append(l[i])\n else:\n ol.append(l[i])\ne1 = collections.Counter(el).most_common()[0][0]\ne2 = collections.Counter(el).most_common()[1][0]\no1 = collections.Counter(ol).most_common()[0][0]\no2 = collections.Counter(ol).most_common()[1][0]\ncnt1 = 0\ncnt2 = 0\nif e1 != o1:\n for i in range(n//2):\n if el[i] != e1:\n cnt1 += 1\n if ol[i] != o1:\n cnt1 += 1\n print(cnt1)\nelse:\n for i in range(n//2):\n if el[i] != e1:\n cnt1 += 1\n if ol[i] != o2:\n cnt1 += 1\n if el[i] != e2:\n cnt2 += 1\n if ol[i] != o1:\n cnt2 += 1\n print(min(cnt1,cnt2))', 'import collections\nn = int(input())\nl = list(int(x) for x in input().split())\nel = []\nol = []\nfor i in range(n):\n if i % 2 == 0:\n el.append(l[i])\n else:\n ol.append(l[i])\nif len(set(el + ol)) == 1:\n print(int(len(l)/2))\n exit()\ne1 = collections.Counter(el).most_common()[0][0]\no1 = collections.Counter(ol).most_common()[0][0]\ncnt1 = 0\ncnt2 = 0\nif e1 != o1:\n print(len(el) - collections.Counter(el).most_common()[0][1] + len(ol) - collections.Counter(ol).most_common()[0][1])\nelse:\n print(min(len(el)-collections.Counter(el).most_common()[0][1]+len(ol)-collections.Counter(ol).most_common()[1][1],len(el)-collections.Counter(el).most_common()[1][1]+len(ol)-collections.Counter(ol).most_common()[0][1]))\n']
['Runtime Error', 'Accepted']
['s580956205', 's639332183']
[17500.0, 17548.0]
[169.0, 174.0]
[712, 713]
p03244
u564589929
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\nsys.setrecursionlimit(10 ** 6)\n# input = sys.stdin.readline ####\nint1 = lambda x: int(x) - 1\ndef II(): return int(input())\n\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\n\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n\nINF = float('inf')\n\nfrom collections import Counter\n\ndef solve():\n n = II()\n V = LI()\n \n even = V[::2]\n odd = V[1::2]\n harf = n // 2\n \n ec = Counter(even).most_common()\n oc = Counter(odd).most_common()\n print(n)\n print(ec[:3])\n print(oc[:3])\n\n \n if ec[0][0] == oc[0][0]:\n \n if ec[0][1] < oc[0][1]:\n ans = n - oc[0][1] - (ec[1][1] if len(ec) > 1 else 0)\n elif ec[0][1] == oc[0][1]:\n ans = n - ec[0][1] - max((ec[1][1] if len(ec) > 1 else 0), (oc[1][1] if len(oc) > 1 else 0))\n else:\n ans = n - ec[0][1] - (oc[1][1] if len(oc) > 1 else 0)\n else:\n ans = n - ec[0][1] - oc[0][1]\n \n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n", "import sys\nsys.setrecursionlimit(10 ** 6)\n# input = sys.stdin.readline ####\nint1 = lambda x: int(x) - 1\ndef II(): return int(input())\n\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\n\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n\nINF = float('inf')\n\nfrom collections import Counter\n\ndef solve():\n n = II()\n V = LI()\n \n even = V[::2]\n odd = V[1::2]\n harf = n // 2\n \n ec = Counter(even).most_common()\n oc = Counter(odd).most_common()\n #print(n)\n #print(ec[:3])\n #print(oc[:3])\n e1 = ec[0][1]\n o1 = oc[0][1]\n \n if ec[0][0] == oc[0][0]:\n \n e2 = ec[1][1] if len(ec) > 1 else 0\n o2 = oc[1][1] if len(oc) > 1 else 0\n \n ans = min(n - e1 - o2, n - o1 - e2)\n else:\n ans = n - e1 - o1\n \n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n"]
['Wrong Answer', 'Accepted']
['s591347970', 's415832255']
[21084.0, 21084.0]
[84.0, 84.0]
[1145, 1004]
p03244
u570018655
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['from statistics import mode\n\nn = int(input())\nv = list(map(int, input.split()))\na = v[::1]\nb = v[1::1]\nslash = mode(a)\nback_slash = mode(b)\na = [i for i in a if i == slash]\nb = [j for j in b if j == back_slash]\nprint(len(a) + len(b))\n', 'from statistics import mode\n\nn = int(input())\nv = list(map(int, input.split()))\na = v[::1]\nb = v[1::1]\nslash = mode(a)\nback_slash = mode(b)\na = [i for i in a if i != slash]\nb = [j for j in b if j != back_slash]\nprint(len(a) + len(b))\n', 'from collections import Counter\n\nn = int(input())\nv = list(map(int, input().split()))\nv_odd = v[0::2]\nv_even = v[1::2]\nans = 0\nc_odd = Counter(v_odd)\nc_even = Counter(v_even)\nv_o, c_o = zip(*c_odd.most_common())\nv_e, c_e = zip(*c_even.most_common())\nif len(c_o) == 1:\n odd1 = 0\nelse:\n odd1 = c_o[1]\nif len(c_e) == 1:\n even1 = 0\nelse:\n even1 = c_e[1]\nif not v_o[0] == v_e[0]:\n print(sum(c_o) - c_o[0] + sum(c_e) - c_e[0])\nelse:\n ans = min(sum(c_o) - c_o[0] + sum(c_e) - even1, sum(c_o) - odd1 + sum(c_e) - c_e[0])\n print(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s325790621', 's850974654', 's261133987']
[5384.0, 5128.0, 22672.0]
[39.0, 36.0, 119.0]
[234, 234, 546]
p03244
u571718615
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\nimport collections\n\n\n\nn = int(stdin.readline())\nv = [int(x) for x in stdin.readline().rstrip().split()]\n\n\n# [start:stop:step]\nv1 = v[0::2]\nv2 = v[1::2]\n\ntmp = len(v1) - len(v2)\n\nv_c = collections.Counter(v)\nv1_c = collections.Counter(v1)\nv2_c = collections.Counter(v2)\n\nif v1_c.most_common()[0][0] == v2_c.most_common()[0][0]:\n\n # print(len(v))\n # print(v_c.most_common()[0][0])\n\n if len(v) == (v_c.most_common()[0][1]):\n print(1)\n ans = len(v) // 2\n\n else:\n ansA = len(v1) - v1_c.most_common()[0][1] + \\\n len(v2) - v2_c.most_common()[1][1]\n\n ansB = len(v1) - v1_c.most_common()[1][1] + \\\n len(v2) - v2_c.most_common()[0][1]\n\n print(2)\n ans = min(ansA, ansB)\n\nelse:\n print(3)\n ans = len(v1) - v1_c.most_common()[0][1] + \\\n len(v2) - v2_c.most_common()[0][1]\n\nprint(ans)\n', 'from sys import stdin\nimport collections\n\n\n\nn = int(stdin.readline())\nv = [int(x) for x in stdin.readline().rstrip().split()]\n\n\n# [start:stop:step]\nv1 = v[0::2]\nv2 = v[1::2]\n\ntmp = len(v1) - len(v2)\n\nv_c = collections.Counter(v)\nv1_c = collections.Counter(v1)\nv2_c = collections.Counter(v2)\n\nif v1_c.most_common()[0][0] == v2_c.most_common()[0][0]:\n\n if len(v) == (v_c.most_common()[0][1]):\n ans = len(v) // 2\n\n else:\n ansA = len(v1) - v1_c.most_common()[0][1] + \\\n len(v2) - v2_c.most_common()[1][1]\n\n ansB = len(v1) - v1_c.most_common()[1][1] + \\\n len(v2) - v2_c.most_common()[0][1]\n\n ans = min(ansA, ansB)\n\nelse:\n ans = len(v1) - v1_c.most_common()[0][1] + \\\n len(v2) - v2_c.most_common()[0][1]\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s504818788', 's798614129']
[26716.0, 26716.0]
[149.0, 162.0]
[1091, 986]
p03244
u572373398
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\n\na = [v[i] for i in range(n) if i % 2 == 0]\nb = [v[i] for i in range(n) if not i % 2 == 0]\n\na_count = Counter(a)\nb_count = Counter(b)\n\na_sorted = sorted(a_count.items(), key=lambda x:x[1], reverse=True)\nb_sorted = sorted(b_count.items(), key=lambda x:x[1], reverse=True)\nprint(a_sorted)\nprint(b_sorted)\nans = 0\nif not a_sorted[0][0] == b_sorted[0][0]:\n ans = n - a_sorted[0][1] - b_sorted[0][1]\nelse:\n if len(b_sorted) == 1 and len(a_sorted) == 1:\n ans = n - a_sorted[0][1]\n elif len(b_sorted) == 1:\n ans = n - a_sorted[0][1]\n elif len(a_sorted) == 1:\n ans = n - b_sorted[0][1]\n else:\n ans = n - max(a_sorted[0][1] + b_sorted[1][1], a_sorted[1][1] + b_sorted[0][1])\n\nprint(ans)', 'from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\n\na = [v[i] for i in range(n) if i % 2 == 0]\nb = [v[i] for i in range(n) if not i % 2 == 0]\n\na_count = Counter(a)\nb_count = Counter(b)\n\na_sorted = sorted(a_count.items(), key=lambda x:x[1], reverse=True)\nb_sorted = sorted(b_count.items(), key=lambda x:x[1], reverse=True)\nans = 0\nif not a_sorted[0][0] == b_sorted[0][0]:\n ans = n - a_sorted[0][1] - b_sorted[0][1]\nelse:\n if len(b_sorted) == 1 and len(a_sorted) == 1:\n ans = n - a_sorted[0][1]\n elif len(b_sorted) == 1:\n ans = n - a_sorted[0][1]\n elif len(a_sorted) == 1:\n ans = n - b_sorted[0][1]\n else:\n ans = n - max(a_sorted[0][1] + b_sorted[1][1], a_sorted[1][1] + b_sorted[0][1])\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s039360732', 's479898323']
[24376.0, 21944.0]
[166.0, 116.0]
[805, 774]
p03244
u578953945
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['n = int(input())\ns = map(int, input().split())\nfrom collections import defaultdict\nans = defaultdict(int)\nresult = int(n / 2)\nfor i in s:\n ans[i] += 1\n\nln = len(ans)\nif ln == 1:\n print(result)\nelif ln == 2:\n ind = 0\n a = 0\n z = sorted(ans.items(), key=lambda x: x[1], reverse=True)\n for _, v in z:\n if ind < 2:\n a += abs(result - v)\n else:\n break\n ind += 1\n print(a)\nelse:\n z = sorted(ans.items(), key=lambda x: x[1], reverse=True)\n print(n - z[0][1])', 'N = int(input())\nL = input().split(" ")\n\nimport collections\n\neven = collections.Counter(L[::2]).most_common(2)\nodd = collections.Counter(L[1::2]).most_common(2)\n\nif even[0][0] != odd[0][0]:\n print(N - even[0][1] - odd[0][1])\nelse:\n \n if len(even) == 1 or len(odd) == 1:\n print(N // 2)\n else:\n print(N - max(even[0][1] + odd[1][1], even[1][1] + odd[0][1]))']
['Wrong Answer', 'Accepted']
['s098701824', 's593234893']
[22508.0, 16176.0]
[106.0, 71.0]
[479, 406]
p03244
u580258754
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 = [i for i in map(int,input().split())]\nv_odd = v[::2]\nv_even = v[1::2]\nodd_nums = (collections.Counter(v_odd)).most_common()\neven_nums = (collections.Counter(v_even)).most_common()\nprint(odd_nums)\nprint(even_nums)\nans = 0\nif odd_nums[0][0] != even_nums[0][0]: \n for i in range(1,len(odd_nums)):\n ans += odd_nums[i][1]\n for i in range(1,len(even_nums)):\n ans += even_nums[i][1]\nelse: \n ans += min(even_nums[0][1], odd_nums[0][1])\n \nprint(ans)', 'import collections\nn = int(input())\nv = [i for i in map(int,input().split())]\nv_odd = v[::2]\nv_even = v[1::2]\nodd_nums = (collections.Counter(v_odd)).most_common()\neven_nums = (collections.Counter(v_even)).most_common()\nans = 0\nif odd_nums[0][0] != even_nums[0][0]: \n for i in range(1,len(odd_nums)):\n ans += odd_nums[i][1]\n for i in range(1,len(even_nums)):\n ans += even_nums[i][1]\nelse: \n ans1=0\n ans2=0\n for i in range(1,len(odd_nums)):\n ans1 += odd_nums[i][1]\n for i in range(len(even_nums)):\n if i==1:\n continue\n ans1 += even_nums[i][1]\n for i in range(len(odd_nums)):\n if i==1:\n continue\n ans2 += odd_nums[i][1]\n for i in range(1,len(even_nums)):\n ans2 += even_nums[i][1]\n ans = min(ans1,ans2)\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s025635495', 's942922477']
[22228.0, 21212.0]
[136.0, 121.0]
[568, 834]
p03244
u581187895
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 = 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])))', '\nfrom collections import Counter\n\n\ndef resolve():\n N = int(input())\n A = list(map(int, input().split()))\n\n O = Counter(A[::2])\n E = Counter(A[1::2])\n\n most_O = O.most_common(2)\n most_E = E.most_common(2)\n \n most_O.append((0, 0))\n most_E.append((0, 0))\n\n cnt = 0\n # key comp\n if most_O[0][0] == most_E[0][0]:\n # value\n res1 = most_O[0][1] + most_E[1][1]\n res2 = most_O[1][1] + most_E[0][1]\n cnt = max(res1, res2)\n else:\n cnt = most_O[0][1] + most_E[0][1]\n\n \n print(N - cnt)\n\n\nif __name__ == "__main__":\n resolve()\n']
['Runtime Error', 'Accepted']
['s495185164', 's295365577']
[20700.0, 23140.0]
[84.0, 66.0]
[289, 664]
p03244
u593005350
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())\nn=list(map(int,input().split()))\n#Divide it into even and odd\nn1=[]\nn2=[]\nfor i in range(N//2):\n n1.append(n[i*2])\n n2.append(n[i*2-1])\n#end\n#make lile {key,value}\ncn1=[]\ns=0\nwhile n1!=[]:\n cn1.append([n1.count(n1[0]),n1[0]])\n for j in range(cn1[s][0]):\n n1.remove(cn1[s][1])\n s+=1\n\ncn2=[]\ns=0\nwhile n2!=[]:\n cn2.append([n2.count(n2[0]),n2[0]])\n for j in range(cn2[s][0]):\n n2.remove(cn2[s][1])\n s+=1\n#end\n\n#sort\ncn1.sort(key=lambda x:x[0])\ncn1.sort(key=lambda x:x[1])\ncn2.sort(key=lambda x:x[0])\ncn2.sort(key=lambda x:x[1])\n#end\n\n#for example(4,1 1 1 1)\ncn1.append([0,0])\ncn2.append([0,0])\n\n#answer\nans=0\nif cn1[0][1]!=cn2[0][1]:\n for i in range(1,len(cn1)):\n ans+=cn1[i][0]\n for j in range(1,len(cn2)):\n ans+=cn2[i][0]\nelif cn1[0][0]-cn1[1][0] > cn2[0][0]-cn2[1][0]:\n ans+=cn1[0][0]\n ans+=cn2[1][0]\n for i in range(2,len(cn1)):\n ans+=cn1[i][0]\n for j in range(2,len(cn2)):\n ans+=cn2[i][0]\nelse:\n ans+=cn1[1][0]\n ans+=cn2[0][0]\n for i in range(2,len(cn1)):\n ans+=cn1[i][0]\n for j in range(2,len(cn2)):\n ans+=cn2[i][0]\nprint(ans)\n#end', 'from collections import Counter\n\nN=int(input())\nn=list(map(int,input().split()))\n#Divide it into even and odd\nn1=[]\nn2=[]\nfor i in range(N//2):\n n1.append(n[i*2])\n n2.append(n[i*2-1])\n#end\n\n\ncm1=Counter(n1).most_common(2)\ncm2=Counter(n2).most_common(2)\n#end\n\n#for example(4,1 1 1 1)\ncm1.append([0,0])\ncm2.append([0,0])\n#end\n\n\n#answer\nif cm1[0][0] != cm2[0][0]:\n ans=N-cm1[0][1]-cm2[0][1]\nelif cm1[0][1]-cm1[1][1] > cm2[0][1]-cm2[1][1]:\n ans=N-cm1[0][1]-cm2[1][1]\nelse:\n ans=N-cm1[1][1]-cm2[0][1]\nprint(ans)\n#end']
['Wrong Answer', 'Accepted']
['s563308665', 's497124656']
[14008.0, 16092.0]
[2108.0, 91.0]
[1195, 609]
p03244
u597455618
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\nv1, v2 = v[::2], [1::2]\nvv1 = Counter(v1).most_common()\nvv2 = Counter(v2).most_common()\n\nif len(set(v)) == 1:\n print(n//2)\nif vv1[0] != vv2[0]:\n print(n - vv1[0][1] - vv2[0][1])\nelse:\n print(n - max(vv1[1][1] + vv2[0][1], vv1[0][1] + vv2[1][1]))', 'from collections import Counter\nn = int(input())\nv = list(map(int, input().split()))\nv1, v2 = v[::2], v[1::2]\nvv1 = Counter(v1).most_common()\nvv2 = Counter(v2).most_common()\n\nif len(set(v)) == 1:\n print(n//2)\nelif vv1[0] != vv2[0]:\n print(n - vv1[0][1] - vv2[0][1])\nelse:\n print(n - max(vv1[1][1] + vv2[0][1], vv1[0][1] + vv2[1][1]))']
['Runtime Error', 'Accepted']
['s890086581', 's955130308']
[2940.0, 25180.0]
[17.0, 90.0]
[339, 342]
p03244
u600402037
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\ns1 = Counter(V).most_common(2)[0]\ns2 = Counter(V).most_common(2)[0]\nV1 = V[0::2]\nV2 = V[1::2]\nx1, c1 = Counter(V1).most_common(1)[0]\nx2, c2 = Counter(V2).most_common(1)[0]\nx3, c3 = Counter(V1).most_common(2)[1]\nx4, c4 = Counter(V2).most_common(2)[1]\nif x1 == x2:\n a = max(c1+c4, c2+c3)\n print(N-a)\nelse:\n print(N - c1 - c2)', '# coding: utf-8\nimport sys\nfrom collections import Counter\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\n\nN = ir()\nV = lr()\nodd = V[::2]\neven = V[1::2]\ncnt_odd = Counter(odd)\ncnt_even = Counter(even)\ncnt_odd_most = cnt_odd.most_common()\ncnt_even_most = cnt_even.most_common()\nif cnt_odd_most[0][0] == cnt_even_most[0][0]:\n answer = N\n if len(cnt_odd_most) > 1:\n temp = N - cnt_odd_most[1][1] - cnt_even_most[0][1]\n answer = min(answer, temp)\n if len(cnt_even_most) > 1:\n temp = N - cnt_odd_most[0][1] - cnt_even_most[1][1]\n answer = min(answer, temp)\n if answer == N:\n answer = N // 2\nelse:\n answer = N - cnt_odd_most[0][1] - cnt_even_most[0][1]\n\nprint(answer)\n']
['Runtime Error', 'Accepted']
['s833432414', 's581981065']
[21464.0, 21944.0]
[153.0, 100.0]
[419, 849]
p03244
u602715823
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 = input().split()\n\nv1 = v[::2]\nv2 = v[1::2]\nc1 = Counter(v1).most_common(2)\nc2 = Counter(v2).most_common(2)\n\nif c1[0][0] != c2[0][0]:\n print(n=c1[0][1] - c2[0][1])\nelse:\n print(min(n - c1[0][1] - c2[1][1], n - c1[1][1] - c2[0][1]))\n', 'from collections import Counter\n\nn = int(input())\nv = input().split()\n\nv1 = v[::2]\nv2 = v[1::2]\nc1 = Counter(v1).most_common(2)\nc2 = Counter(v2).most_common(2)\n\nif len(set(v)) == 1:\n print(len(v) // 2)\nelif c1[0][0] != c2[0][0]:\n print(n - c1[0][1] - c2[0][1])\nelse:\n print(min(n - c1[0][1] - c2[1][1], n - c1[1][1] - c2[0][1]))']
['Runtime Error', 'Accepted']
['s419341491', 's658968822']
[16616.0, 20712.0]
[65.0, 73.0]
[290, 337]
p03244
u604896914
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 operator\n\nn=int(input().strip())\nlst=input().split(' ')\nmap(int, lst)\n\nd1 = {}\nd2 = {}\n\nfor i in range(len(lst)):\n if i % 2 == 0:\n if lst[i] in d1:\n d1[lst[i]] += 1\n else:\n d1[lst[i]] = 1\n else:\n if lst[i] in d2:\n d2[lst[i]] += 1\n else:\n d2[lst[i]] = 1\n\nsd1 = sorted(d1.values(), reverse=True)\nsd2 = sorted(d2.values(), reverse=True)\nkey1 = max(d1.items(), key=operator.itemgetter(1))[0]\nkey2 = max(d2.items(), key=operator.itemgetter(1))[0]\n\nif(key1 == key2):\n\n v11 = sd1[0]\n if(len(d1) == 1):\n v12 = 0\n else:\n v12 = sd1[1]\n\n v21 = sd2[0]\n if(len(d2) == 1):\n v22 = 0\n else:\n v22 = sd2[1]\n\n print(min(n-v11-v22, n-v12-v21))\n\nelse:\n print(n-sd1[0]-sd2[key2])\n", "import operator\n\nn=int(input().strip())\nlst=input().split(' ')\nmap(int, lst)\n\nd1 = {}\nd2 = {}\n\nfor i in range(len(lst)):\n if i % 2 == 0:\n if lst[i] in d1:\n d1[lst[i]] += 1\n else:\n d1[lst[i]] = 1\n else:\n if lst[i] in d2:\n d2[lst[i]] += 1\n else:\n d2[lst[i]] = 1\n\nsd1 = sorted(d1.values(), reverse=True)\nsd2 = sorted(d2.values(), reverse=True)\nkey1 = max(d1.items(), key=operator.itemgetter(1))[0]\nkey2 = max(d2.items(), key=operator.itemgetter(1))[0]\n\nif(key1 == key2):\n\n v11 = sd1[0]\n if(len(d1) == 1):\n v12 = 0\n else:\n v12 = sd1[1]\n\n v21 = sd2[0]\n if(len(d2) == 1):\n v22 = 0\n else:\n v22 = sd2[1]\n\n print(min(n-v11-v22, n-v12-v21))\n\nelse:\n print(n-sd1[0]-sd2[0])"]
['Runtime Error', 'Accepted']
['s512051843', 's043594668']
[18228.0, 18280.0]
[89.0, 88.0]
[795, 791]
p03244
u606033239
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[0::2]\nvo=v[1::2]\nprint(ve,vo)\n\nce=collections.Counter(vo).most_common(2)\nco=collections.Counter(ve).most_common(2)\nprint(ce,co)\nif ce[0][0] != co[0][0]:\n ans = len(v)-ce[0][1]-co[0][1]\nelif len(ce)==1 and len(co)==1:\n ans = len(v)//2\nelif len(ce)==1:\n ans = len(v)//2 - co[1][1]\nelif len(co)==1:\n ans = len(v)//2-ce[1][1]\nelse:\n ans = len(v)-max(ce[0][1]+co[1][1],ce[1][1]+co[0][1])\nprint(ans)', 'import collections\nn=int(input())\nv=list(map(int,input().split()))\nve=v[0::2]\nvo=v[1::2]\n\nce=collections.Counter(ve).most_common(2)\nco=collections.Counter(vo).most_common(2)\n\nif len(set(v))==1:\n ans=n//2\nelse:\n if ce[0][0]!=co[0][0]:\n ans=n-ce[0][1]-co[0][1]\n elif ce[0][0]==co[0][0] and len(ce)==1:\n ans=n//2-co[0][0]\n elif ce[0][0]==co[0][0] and len(co)==1:\n ans=n//2-ce[0][0]\n else:\n ans=n-max(ce[0][1],co[0][1])-max(ce[1][1],co[1][1])\nprint(ans)']
['Wrong Answer', 'Accepted']
['s836052873', 's213633256']
[16740.0, 16564.0]
[87.0, 82.0]
[480, 492]
p03244
u608726540
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 deque\nn=int(input())\nv=list(map(int,input().split()))\nd1={}\nd2={}\nl1=[]\nl2=[]\nfor i in range(n):\n num=v[i]\n if i%2==0:\n try:\n d1[num]+=1\n except:\n d1[num]=1\n else:\n try:\n d2[num]+=1\n except:\n d2[num]=1\nfor i in d1:\n l1.append([d1[i],i])\nfor i in d2:\n l2.append([d2[i],i])\nl1.sort(reverse=True)\nl2.sort(reverse=True)\nans=n\nif l1[0][1]!=l2[0][1]:\n ans-=(l1[0][0]+l2[0][0])\nelif len(l1)==1 and len(l2)==1:\n ans//=2\nelif len(l1)==1:\n ans-=l2[1][0]\nelif len(l2)==1\n ans-=l1[1][0]\nelse:\n a=ans-l1[0][0]-l2[1][0]\n b=ans-l1[1][0]-l2[0][0]\n ans=min(a,b)\nprint(ans)\n', 'n=int(input())\nv=list(map(int,input().split()))\nd1={}\nd2={}\nl1=[]\nl2=[]\nfor i in range(n):\n num=v[i]\n if i%2==0:\n try:\n d1[num]+=1\n except:\n d1[num]=1\n else:\n try:\n d2[num]+=1\n except:\n d2[num]=1\nfor i in d1:\n l1.append([d1[i],i])\nfor i in d2:\n l2.append([d2[i],i])\nl1.sort(reverse=True)\nl2.sort(reverse=True)\nans=n\nif l1[0][1]!=l2[0][1]:\n ans-=(l1[0][0]+l2[0][0])\nelif len(l1)==1 and len(l2)==1:\n ans//=2\nelif len(l1)==1:\n ans-=l2[1][0]\nelif len(l2)==1:\n ans-=l1[1][0]\nelse:\n a=ans-l1[0][0]-l2[1][0]\n b=ans-l1[1][0]-l2[0][0]\n ans=min(a,b)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s165873300', 's518270913']
[8980.0, 27272.0]
[22.0, 205.0]
[688, 659]
p03244
u612975321
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 copy\nimport numpy as np\n\nn = int(input())\nv = list(map(int,input().split()))\na = v[0::2] \nb = v[1::2]\n\ncnta = np.zeros(10**5+1, dtype=int)\ncntb = np.zeros(10**5+1, dtype=int)\nfor i in range(n//2):\n ca, cb = a[i], b[i]\n cnta[ca] += 1\n cntb[cb] += 1\nprint(a, cnta[:5])\nprint(b, cntb[:5])\nla = np.zeros((2,2), dtype=int)\nlb = np.zeros((2,2), dtype=int)\nfor i in range(2):\n ia = cnta.argmax()\n ib = cntb.argmax()\n la[i][0], la[i][1] = ia, cnta[ia]\n lb[i][0], lb[i][1] = ib, cntb[ib]\n cnta[ia] = -1\n cntb[ib] = -1\nprint(la)\nprint(lb)\nif la[0][0] != lb[0][0]:\n ans = n//2 - la[0][1] + n//2 - lb[0][1]\nelif la[0][1] > lb[0][1]:\n ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])\nprint(ans)', 'import copy\nimport numpy as np\n\nn = int(input())\nv = list(map(int,input().split()))\na = v[0::2] \nb = v[1::2]\n\ncnta = np.zeros(10**5+1, dtype=int)\ncntb = np.zeros(10**5+1, dtype=int)\nfor i in range(n//2):\n ca, cb = a[i], b[i]\n cnta[ca] += 1\n cntb[cb] += 1\n\nla = np.zeros((2,2), dtype=int)\nlb = np.zeros((2,2), dtype=int)\nfor i in range(2):\n ia = cnta.argmax()\n ib = cntb.argmax()\n la[i][0], la[i][1] = ia, cnta[ia]\n lb[i][0], lb[i][1] = ib, cntb[ib]\n cnta[ia] = 0\n cntb[ib] = 0\n\nif la[0][0] != lb[0][0]:\n ans = n//2 - la[0][1] + n//2 - lb[0][1]\nelse:\n ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s128219729', 's211778803']
[39072.0, 38504.0]
[191.0, 187.0]
[752, 675]
p03244
u620846115
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())\nalist = list(map(int,input().split()))\nlist1 = alist[1::2]\nlist2 = alist[0::2]\nfrom collections import Counter\ndic1 = Counter(list1)\ndic2 = Counter(list2)\nsortdic1 = sorted(dic1.items(),key=lambda x:x[1], reverse=True)\nsortdic2 = sorted(dic2.items(),key=lambda x:x[1], reverse=True)\nvlist1 = list(sortdic1.items())\nvlist2 = list(sortdic2.items())\nif vlist1[0][0]!=vlist[0][0]:\n print(n - vlist1[0][1] - vlist2[0][1])\nelse:\n if (vlist1[0][1] + vlist2[1][1])>(vlist1[1][1] + vlist2[0][1]):\n print(n - vlist1[0][1] - vlist2[1][1])\n else:\n print(n -vlist1[1][1] - vlist2[0][1])\n \n ', 'n = int(input())\nalist = list(map(int,input().split()))\nlist1 = alist[1::2]\nlist2 = alist[0::2]\nfrom collections import Counter\ndic1 = Counter(list1)\ndic2 = Counter(list2)\nsortdic1 = sorted(dic1.items(),key=lambda x:x[1], reverse=True)\nsortdic2 = sorted(dic2.items(),key=lambda x:x[1], reverse=True)\nvlist1 = list(sortdic1.items())\nvlist2 = list(sortdic2.items())\nif vlist1[0][0]!=vlist2[0][0]:\n print(n - vlist1[0][1] - vlist2[0][1])\nelse:\n if (vlist1[0][1] + vlist2[1][1])>(vlist1[1][1] + vlist2[0][1]):\n print(n - vlist1[0][1] - vlist2[1][1])\n else:\n print(n -vlist1[1][1] - vlist2[0][1])', 'n = int(input())\nalist = list(map(int,input().split()))\nlist1 = alist[1::2]\nlist2 = blist[0::2]\nfrom collections import Counter\ndic1 = Counter(list1)\ndic2 = Counter(list2)\nvlist1 = sorted(list(dic1.values()))\nvlist2 = sorted(list(dic2.values()))\nprint(n - vlist1[-1] - vlist2[-1])', 'n = int(input())\nalist = list(map(int,input().split()))\nlist1 = alist[1::2]\nlist2 = alist[0::2]\nfrom collections import Counter\ndic1 = Counter(list1).most_common()\ndic2 = Counter(list2).most_common()\ndic1.append([0,0])\ndic2.append([0,0])\nif dic1[0][0]!=dic2[0][0]:\n print(n - dic1[0][1] - dic2[0][1])\nelse:\n print(min(n - dic1[0][1] - dic2[1][1], n -dic1[1][1] - dic2[0][1]))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s103545874', 's294138787', 's732150742', 's728667284']
[27520.0, 27712.0, 20724.0, 25628.0]
[91.0, 93.0, 57.0, 88.0]
[610, 601, 281, 378]
p03244
u623601489
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['def main(n:int,lst:list)->int:\n lst1 = lst[::2]\n lst2 = lst[1::2]\n ans1 =count2(lst1)\n ans2 =count2(lst2)\n if ans1[0][0] == ans2[0][0]:\n if ans1[1] and ans2[1]:\n return n - max(ans1[0][1] + ans2[1],ans2[0][1] + ans1[1])\n else:\n return n//2\n else:\n return n - ans1[0][1] - ans2[0][1]\ndef count2(lst):\n lst.sort()\n ans = [["",0],0]\n last =lst[0]\n a = 0\n for e in lst:\n if last == e:\n a +=1\n else:\n ans = check(a,ans)\n last = e\n a = 1\n return check(a,ans)\ndef check(a,ans):\n if a > ans[0][1]:\n ans[1] = ans[0][1]\n ans[0][0] = e\n ans[0][1] = a\n elif a > ans[1]:\n ans[1] = a\n return ans\nn = int(input())\nlst = input().split()\nprint(main(n,lst))\n', 'def count2(lst):\n ans = [["",0],0]\n def check():\n nonlocal ans\n if a > ans[0][1]:\n ans[1] = ans[0][1]\n ans[0][0] = last\n ans[0][1] = a\n elif a > ans[1]:\n ans[1] = a\n lst.sort()\n last =lst[0]\n a = 0\n for e in lst:\n if last == e:\n a +=1\n else:\n check()\n last = e\n a = 1\n check()\n return ans\n\ndef main(lst:list)->int:\n n = len(lst)\n ans1 =count2(lst[::2])\n ans2 =count2(lst[1::2])\n if ans1[0][0] == ans2[0][0]:\n if ans1[1] and ans2[1]:\n return n - max(ans1[0][1] + ans2[1],ans2[0][1] + ans1[1])\n else:\n return n//2\n else:\n return n - ans1[0][1] - ans2[0][1]', 'def main(n:int,lst:list)->int:\n b = True\n lst1 = []\n lst2 = []\n for e in lst:\n if b:\n lst1.append(e)\n else:\n lst2.append(e)\n b = not b\n lst1.sort()\n lst2.sort()\n c1 = [["",0],0]\n c2 = [["",0],0]\n last =lst1[0]\n a = 0\n for e in lst1:\n if last == e:\n a +=1\n else:\n if a >= c1[0][1]:\n c1[1] = c1[0][1]\n c1[0][0] = e\n c1[0][1] = a\n elif a > c1[1]:\n c1[1] = a\n last = e\n a = 1\n if a >= c1[0][1]:\n c1[1] = c1[0][1]\n c1[0][0] = e\n c1[0][1] = a\n elif a > c1[1]:\n c1[1] = a\n\n last =lst2[0]\n a = 0\n for e in lst2:\n if last == e:\n a +=1\n else:\n if a >= c2[0][1]:\n c2[1] = c2[0][1]\n c2[0][0] = e\n c2[0][1] = a\n elif a > c2[1]:\n c2[1] = a\n last = e\n a = 1\n if a >= c2[0][1]:\n c2[1] = c2[0][1]\n c2[0][0] = e\n c2[0][1] = a\n elif a > c2[1]:\n c2[1] = a\n\n if c1[0][0] == c2[0][0]:\n if c1[0][1] > c2[0][1] or(c1[0][1] == c2[0][1] and c2[1] > c1[1]):\n return n - c1[0][1] - c2[1]\n else:\n return n - c2[0][1] - c1[1]\n else:\n return n - c1[0][1] - c2[0][1]\n\nn = int(input())\nlst = input().split())\nprint(main(n,lst))\n', 'from collections import Counter\ndef main(n:int,lst:list)->int:\n lst1 = [::2]\n lst2 = [1::2]\n c1 = Counter(lst1).most_common(2)\n c2 = Counter(lst2).most_common(2)\n if c1[0][0] == c2[0][0]:\n if len(c1)!=1 and len(c2)!=1:\n return n - max(c1[0][1] + c2[1],c2[0][1] + c1[1])\n else:\n return n//2\n else:\n return n - c1[0][1] - c2[0][1]\n\nn = int(input())\nlst = input().split()\nprint(main(n,lst))\n', 'def main(n:int,lst:list)->int:\n b = True\n lst1 = []\n lst2 = []\n for e in lst:\n if b:\n lst1.append(e)\n else:\n lst2.append(e)\n b = not b\n lst1.sort()\n lst2.sort()\n c1 = [["",0],["",0]]\n c2 = [["",0],["",0]]\n last =lst1[0]\n a = 1\n for e in lst1[1:]:\n if last == e:\n a +=1\n else:\n if a > c1[0][1]:\n c1[0][0] = e\n c1[0][1] = a\n\n elif a > c1[1][1]:\n c1[1][0] = e\n c1[1][1] = a\n last = e\n a = 1\n if a > c1[0][1]:\n c1[0][0] = e\n c1[0][1] = a\n\n elif a > c1[1][1]:\n c1[1][0] = e\n c1[1][1] = a\n\n last =lst2[0]\n a = 1\n for e in lst2[1:]:\n if last == e:\n a +=1\n else:\n if a > c2[0][1]:\n c2[0][0] = e\n c2[0][1] = a\n\n elif a > c2[1][1]:\n c2[1][0] = e\n c2[1][1] = a\n last = e\n a = 1\n if a > c2[0][1]:\n c2[0][0] = e\n c2[0][1] = a\n\n elif a > c2[1][1]:\n c2[1][0] = e\n c2[1][1] = a\n if c1[0][0] == c2[0][0]:\n if c1[0][1] > c2[0][1]:\n print(c1,c1)\n return n - c1[0][1] - c2[1][1]\n else:\n print(c1,c1)\n return n - c2[0][1] - c1[1][1]\n else:\n print(c1,c1)\n return n - c1[0][1] - c2[0][1]\n\nn = int(input())\nlst = list(map(int,input().split()))\nprint(main(n,lst))\n', 'def count2(lst):\n ans = [["",0],0]\n def check():\n nonlocal ans\n if a > ans[0][1]:\n ans[1] = ans[0][1]\n ans[0][0] = last\n ans[0][1] = a\n elif a > ans[1]:\n ans[1] = a\n lst.sort()\n last =lst[0]\n a = 0\n for e in lst:\n if last == e:\n a +=1\n else:\n check()\n last = e\n a = 1\n check()\n return ans\n\ndef main(n:int,lst:list)->int:\n ans1 =count2(lst[::2])\n ans2 =count2(lst[1::2])\n if ans1[0][0] == ans2[0][0]:\n return n - max(ans1[0][1] + ans2[1],ans2[0][1] + ans1[1])\n else:\n return n - ans1[0][1] - ans2[0][1]\nn = int(input())\nlst = input().split()\nprint(main(n,lst))']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s000351755', 's028148723', 's195698448', 's623800709', 's866458172', 's728634093']
[10592.0, 3064.0, 3192.0, 2940.0, 13992.0, 10844.0]
[56.0, 19.0, 18.0, 18.0, 102.0, 102.0]
[814, 759, 1455, 449, 1528, 732]
p03244
u623687794
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())\nnums=list(map(int,input().split()))\na=set(nums)\nif len(a)==1:\n print(n//2)\nelse:\n odd=nums[::2]\n even=nums[1::2]\n o=Counter(odd)\n e=Counter(even)\n ans=n-o.most_common()[0][1]-e.most_common()[0][1]\n if o.most_common[0][0]==e.most_common[0][0]:\n print(ans+min(o.most_common[1][1]-o.most_common[0][1],e.most_common[1][1]-e.most_common[0][1]))\n else: \n print(ans)\n', 'from collections import Counter\nn=int(input())\nnums=list(map(int,input().split()))\na=set(nums)\nif len(a)==1:\n print(n//2)\nelse:\n odd=nums[::2]\n even=nums[1::2]\n o=Counter(odd)\n e=Counter(even)\n print(n-o.most_common()[0][0]-e.most_common()[0][0])', 'from collections import Counter\nn=int(input())\nnums=list(map(int,input().split()))\na=set(nums)\nif len(a)==1:\n print(n//2)\nelse:\n odd=nums[::2]\n even=nums[1::2]\n o=Counter(odd)\n e=Counter(even)\n ans=n-o.most_common()[0][1]-e.most_common()[0][1]\n if o.most_common()[0][0]==e.most_common()[0][0]:\n print(ans+min(o.most_common()[0][1]-o.most_common()[1][1],e.most_common()[0][1]-e.most_common()[1][1]))\n else: \n print(ans)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s209589494', 's607192973', 's541541520']
[24672.0, 24672.0, 24672.0]
[100.0, 104.0, 149.0]
[422, 252, 434]
p03244
u623814058
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*V,=map(int,input().split())\nimport Counter from collections \n\nc1=Counter(V[0::2]).most_common()+[(0,0)]\nc2=Counter(V[1::2]).most_common()+[(0,0)]\nif c1[0][0]!=c2[0][0]:\n print(N-c1[0][1]-c2[0][1])\nelse:\n print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))', 'N=int(input())\n*V,=map(int,input().split())\nimport collections import Counter\n\nc1=Counter(V[0::2]).most_common()+[(0,0)]\nc2=Counter(V[1::2]).most_common()+[(0,0)]\nif c1[0][0]!=c2[0][0]:\n print(N-c1[0][1]-c2[0][1])\nelse:\n print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))', 'N=int(input())\n*V,=map(int,input().split())\nfrom collections import Counter\n\nc1=Counter(V[0::2]).most_common()+[(0,0)]\nc2=Counter(V[1::2]).most_common()+[(0,0)]\nif c1[0][0]!=c2[0][0]:\n print(N-c1[0][1]-c2[0][1])\nelse:\n print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s197002289', 's283892956', 's732858805']
[8952.0, 8864.0, 25344.0]
[30.0, 26.0, 77.0]
[277, 278, 276]
p03244
u625554679
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(aa) for aa in input().split()]\n\ndef add_entry(hist, aa):\n if aa in hist:\n hist[aa] += 1\n else:\n hist[aa] = 1\n\n\ndef make_hist(a):\n even_hist = {}\n odd_hist = {}\n\n for i in range(len(a)//2):\n add_entry(even_hist, a[2*i])\n add_entry(odd_hist, a[2*i+1])\n\n return even_hist, odd_hist\n\n\ndef get_sorted_hist(hist):\n return sorted(hist.items(), key=lambda x: x[0])\n\neh, oh = make_hist(a)\nseh = get_sorted_hist(eh)\nsoh = get_sorted_hist(oh)\n\nprint(soh, seh)\n\n\nif seh[0][0] != soh[0][0]:\n print(len(a) - seh[0][1] - soh[0][1])\nelse:\n if len(seh) == 1 and len(soh) == 1:\n print(len(a)//2)\n elif len(seh) == 1:\n print(len(a) - seh[0][1] - soh[1][1])\n elif len(soh) == 1:\n print(len(a) - soh[0][1] - seh[1][1])\n else:\n print(min(len(a) - seh[0][1] - soh[1][1], len(a) - soh[0][1] - seh[1][1]))\n\n', 'n = int(input())\na = [int(aa) for aa in input().split()]\n\ndef add_entry(hist, aa):\n if aa in hist:\n hist[aa] += 1\n else:\n hist[aa] = 1\n\n\ndef make_hist(a):\n even_hist = {}\n odd_hist = {}\n\n for i in range(len(a)//2):\n add_entry(even_hist, a[2*i])\n add_entry(odd_hist, a[2*i+1])\n\n return even_hist, odd_hist\n\n\ndef get_sorted_hist(hist):\n return sorted(hist.items(), key=lambda x: -x[0])\n\n\neh, oh = make_hist(a)\nseh = get_sorted_hist(eh)\nsoh = get_sorted_hist(oh)\n\nif seh[0][0] != soh[0][0]\n print(len(a) - seh[0][1] - soh[0][1])\nelse:\n if seh[0][1] >= soh[0][1]:\n print(len(a) - seh[0][1] - soh[1][1])\n else:\n print(len(a) - seh[1][1] - soh[0][1])\n', 'n = int(input())\na = [int(aa) for aa in input().split()]\n\ndef add_entry(hist, aa):\n if aa in hist:\n hist[aa] += 1\n else:\n hist[aa] = 1\n\n\ndef make_hist(a):\n even_hist = {}\n odd_hist = {}\n\n for i in range(len(a)//2):\n add_entry(even_hist, a[2*i])\n add_entry(odd_hist, a[2*i+1])\n\n return even_hist, odd_hist\n\n\ndef get_sorted_hist(hist):\n return sorted(hist.items(), key=lambda x: -x[1])\n\neh, oh = make_hist(a)\nseh = get_sorted_hist(eh)\nsoh = get_sorted_hist(oh)\n\n\nif seh[0][0] != soh[0][0]:\n print(len(a) - seh[0][1] - soh[0][1])\nelse:\n if len(seh) == 1 and len(soh) == 1:\n print(len(a)//2)\n elif len(seh) == 1:\n print(len(a) - seh[0][1] - soh[1][1])\n elif len(soh) == 1:\n print(len(a) - soh[0][1] - seh[1][1])\n else:\n print(min(len(a) - seh[0][1] - soh[1][1], len(a) - soh[0][1] - seh[1][1]))\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s335034351', 's405971918', 's087020712']
[23324.0, 3064.0, 20764.0]
[169.0, 17.0, 103.0]
[900, 717, 883]
p03244
u625963200
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()))\nE=Counter(V[::2]).most_common()\nO=Counter(V[1::2]).most_common()\n\nE1=E[0][1]\nO1=O[0][1]\nif E[0][0]==O[0][0]:\n print(n//2)\nelif E1==O1==n//2:\n print(0)\nelse:\n E2=E[1][1] if len(E)>1 else 0\n O2=O[1][1] if len(O)>1 else 0\n if E2!=0 and O2!=0:\n print(min(n//2-E2+n//2-O1,n//2-E1+n//2-O2))\n else:\n print(min(n//2-E2+n//2-O1,n//2-E1+n//2-O2))', 'import collections\nn=int(input())\nvs=[int(i) for i in input().split()]\nvs1=[v for i,v in enumerate(vs) if i%2==0]\nvs2=[v for i,v in enumerate(vs) if i%2==1]\n\nans=0\nif len(list(set(vs)))==1:\n ans+=len(vs2)\n \ncounted=collections.Counter(vs1)\nvs1most=counted.most_common()[0][0]\ncounted=collections.Counter(vs2)\nvs2most=counted.most_common()[0][0]\n\nprint(len(vs1)-vs1.count(vs1most))\nprint(len(vs2)-vs2.count(vs2most))\n\nans+=len(vs1)-vs1.count(vs1most)\nans+=len(vs2)-vs2.count(vs2most)\n\nprint(ans)', 'from collections import Counter\nn=int(input())\nV=list(map(int,input().split()))\n\nE=Counter(V[::2]).most_common() + [(0, 0)]\nO=Counter(V[1::2]).most_common() + [(0, 0)]\nif E[0][0]!=O[0][0]:\n print(n-E[0][1]+O[0][1])\nelse:\n print(n-max(E[1][1]+O[0][1],E[0][1]+O[1][1]))', 'from collections import Counter\nn=int(input())\nV=list(map(int,input().split()))\n\nE=Counter(V[::2]).most_common() + [(0, 0)]\nO=Counter(V[1::2]).most_common() + [(0, 0)]\nif E[0][0]!=O[0][0]:\n print(n-E[0][1]-O[0][1])\nelse:\n print(n-max(E[1][1]+O[0][1],E[0][1]+O[1][1]))']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s078874710', 's352500324', 's580490544', 's274523007']
[14404.0, 20564.0, 20572.0, 20572.0]
[40.0, 129.0, 87.0, 86.0]
[396, 496, 269, 269]
p03244
u626468554
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\ndic0 = [0 for i in range(10**5+1)]\ndic1 = [0 for i in range(10**5+1)]\nfor i in range(n):\n if i%2==0: \n dic0[v[i]] += 1\n if i%2==1:\n dic1[v[i]] += 1\n\nMX0_1 = max(dic0)\nMX1_1 = max(dic1)\n\nli0 = []\nli1 = []\n\n\nfor i in range(10**5+1):\n if dic0[i]>10:\n #print(i,dic0[i])\n if dic1[i]>10:\n #print(i,dic1[i],"\\n")\n \n if dic0[i] == MX0_1:\n li0.append(i)\n dic0[i] = 0\n if dic1[i] == MX1_1:\n li1.append(i)\n dic1[i] = 0\n\n# print(li0,li1)\n# print(MX0_1,MX0_1)\n\nif len(li0)>=2 or len(li1)>=2:\n print(n-MX0_1-MX1_1)\nelif li0[0] == li1[0]:\n if MX0_1+max(dic1) >= MX1_1+max(dic0):\n print(n-MX0_1-max(dic1))\n else:\n print(n-MX1_1-max(dic0))\n print(1/0)\n\nelif li0[0] != li1[0]:\n print(n-MX0_1-MX1_1)', 'n=int(input())#int(input())\nv = list(map(int,input().split()))\n\ndic0 = [0 for i in range(10**5+1)]\ndic1 = [0 for i in range(10**5+1)]\nfor i in range(n):\n if i%2==0: \n dic0[v[i]] += 1\n if i%2==1:\n dic1[v[i]] += 1\n\nMX0_1 = max(dic0)\nMX1_1 = max(dic1)\n\nli0 = []\nli1 = []\n\n\nfor i in range(10**5+1):\n if dic0[i] == MX0_1:\n li0.append(i)\n dic0[i] = 0\n if dic1[i] == MX1_1:\n li1.append(i)\n dic1[i] = 0\n\nprint(li0,li1)\nprint(MX0_1,MX1_1)\n\n\nif len(li0)>=2 or len(li1)>=2:\n print(n-MX0_1-MX1_1)\nelif li0[0] == li1[0]:\n if MX0_1+max(dic1) >= MX1_1+max(dic0):\n print(n-MX0_1-max(dic1))\n else:\n print(MX1_1+max(dic0))\n\nelif li0[0] != li1[0]:\n print(n-MX0_1-MX1_1)', 'n=int(input())\nv = list(map(int,input().split()))\n\ndic0 = [0 for i in range(10**5+1)]\ndic1 = [0 for i in range(10**5+1)]\nfor i in range(n):\n if i%2==0: \n dic0[v[i]] += 1\n if i%2==1:\n dic1[v[i]] += 1\n\nMX0_1 = max(dic0)\nMX1_1 = max(dic1)\n\nli0 = []\nli1 = []\n\n\nfor i in range(10**5+1):\n # if dic0[i]>10:\n # print(i,dic0[i])\n # if dic1[i]>10:\n # print(i,dic1[i],"\\n")\n \n if dic0[i] == MX0_1:\n li0.append(i)\n dic0[i] = 0\n if dic1[i] == MX1_1:\n li1.append(i)\n dic1[i] = 0\n\n# print(li0,li1)\n# print(MX0_1,MX0_1)\n\nif len(li0)>=2 or len(li1)>=2:\n print(n-MX0_1-MX1_1)\nelif li0[0] == li1[0]:\n print(min(n-MX0_1-max(dic1), n-MX1_1-max(dic0)))\nelif li0[0] != li1[0]:\n print(n-MX0_1-MX1_1)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s488628222', 's662411274', 's081497917']
[3064.0, 14692.0, 14236.0]
[24.0, 123.0, 125.0]
[844, 733, 764]
p03244
u628581330
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()))\nodd = v[::2 ]\neven = v[1::2]\n\n# if len(set(aaa))!=1:\n\n\n\n# else:\n\n\n# return int(aaa_min),most_aaa\nif len(set(v))==1:\n print(int(n/2))\nelse:\n if len(set(even))!=1:\n even_max = Counter(even).most_common(1)[0][1]\n even_min = len(even)-even_max\n even_most = Counter(even).most_common(1)[0][0]\n else:\n aaa_min = 0\n even_most = set(even)[0]\n if len(set(odd))!=1:\n odd_most = Counter(odd).most_common()\n for key in odd_most:\n if key[0]!=even_most:\n odd_max = key[1]\n odd_min = len(odd)-odd_max\n break\n else:\n odd_min = 0\n odd_most = set(odd)[0]\n print(even_min+odd_min)', 'from collections import Counter\n \nn = int(input())\nv = list(map(int,input().split()))\nac = Counter(v[::2]).most_common(2)\nbc = Counter(v[1::2]).most_common(2)\n\n\nif ac[0][0] != bc[0][0]: \n ans = n - ac[0][1] - bc[0][1] \nelse: \n if len(bc) == 1 or len(ac) == 1:\n ans = n // 2\n else: \n ans = n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])\nprint(ans)']
['Runtime Error', 'Accepted']
['s370146609', 's543017343']
[17500.0, 15588.0]
[94.0, 74.0]
[1007, 413]
p03244
u629350026
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()))\ntemp1=[]\ntemp2=[]\nfor i in range(0,n):\n if i%2==0:\n temp1.append(v[i])\n else:\n temp2.append(v[i])\ncount=0\nfrom collections import Counter\nc1=Counter(temp1)\nmode1=c1.most_common()[0][1]\nmode1s=c1.most_common()[1][1]\nc2=Counter(temp2)\nmode2=c2.most_common()[0][1]\nmode2s=c2.most_common()[1][1]\nif c1.most_common()[0][0]==c2.most_common()[0][0]:\n if mode1s>=mode2s:\n count=len(temp1)-mode1s\n else:\n count=len(temp2)-mode2s\nelse:\n count=len(temp1)-mode1+len(temp2)-mode2\nprint(count)', 'n=int(input())\nv=list(map(int,input().split()))\ntemp1=[]\ntemp2=[]\nfor i in range(0,n):\n if i%2==0:\n temp1.append(v[i])\n else:\n temp2.append(v[i])\ncount=0\nfrom collections import Counter\nc1=Counter(temp1)\nvalues1,counts1=zip(*c1.most_common())\ncounts1=list(counts1)\nmode1=counts1[0]\nif len(counts1)>1:\n mode1s=counts1[1]\nc2=Counter(temp2)\nvalues2,counts2=zip(*c2.most_common())\ncounts2=list(counts2)\nmode2=counts2[0]\nif len(counts2)>1:\n mode2s=counts2[1]\nif len(counts1)==1 and len(counts2)==1 and c1.most_common()[0][0]==c2.most_common()[0][0]:\n count=min(mode1,mode2)\nelif c1.most_common()[0][0]==c2.most_common()[0][0]:\n if len(temp1)-mode1s>=len(temp2)-mode2s:\n count=len(temp1)-mode1+len(temp2)-mode2s\n else:\n count=len(temp2)-mode2+len(temp1)-mode1s\nelse:\n count=len(temp1)-mode1+len(temp2)-mode2\nprint(count)']
['Runtime Error', 'Accepted']
['s834612432', 's665907690']
[19168.0, 24272.0]
[146.0, 174.0]
[544, 834]
p03244
u638282348
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()))\na1, a2, *_ = Counter(V[0::2]).most_common() + [(0, 0)]\nb1, b2, *_ = Counter(V[1::2]).most_common() + [(0, 0)]\nprint(N - max(a1[1] + b2[1], a2[1] + b1[1]) if a1[0] == b1[0] else N - a1[1] + b1[1])\n', 'from collections import Counter\nN = int(input())\nV = list(map(int, input().split()))\na1, a2, *_ = Counter(V[0::2]).most_common() + [(0, 0)]\nb1, b2, *_ = Counter(V[1::2]).most_common() + [(0, 0)]\nprint(N - max(a1[1] + b2[1], a2[1] + b1[1]) if a1[0] == b1[0] else N - (a1[1] + b1[1]))\n']
['Wrong Answer', 'Accepted']
['s752780321', 's681563312']
[20572.0, 20572.0]
[89.0, 89.0]
[281, 283]
p03244
u640319601
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\n\nn = int(input())\nl = list(map(int, input().split()))\n\nif len(set(l)) == 1:\n print(n//2)\n exit()\n\nleven = [x for x in l[::2]]\nlodd = [x for x in l[1::2]]\n\nce = collections.Counter(leven)\nco = collections.Counter(lodd)\nce = sorted(ce.items(), key=lambda x:x[1])\nco = sorted(co.items(), key=lambda x:x[1])\n\nif ce[-1][0] != ce[-1][0]:\n\tprint(n - ce[-1][1] - co[-1][1])\nelif ce[-2][1] > co[-2][1]:\n print(n - ce[-2][1] - co[-1][1])\nelse:\n print(n - ce[-1][1] - co[-2][1])\n', 'import collections\n\n\nn = int(input())\nl = list(map(int, input().split()))\n\nif len(set(l)) == 1:\n print(n//2)\n exit()\n\nleven = [x for x in l[::2]]\nlodd = [x for x in l[1::2]]\nce = collections.Counter(leven)\nco = collections.Counter(lodd)\n\nce = sorted(ce.items(), key=lambda x:x[1])\nco = sorted(co.items(), key=lambda x:x[1])\n\nif ce[-1][0] != ce[-1][0]:\n\tprint(n - ce[-1][1] - co[-1][1])\nelif ce[-2][1] > co[-2][1]:\n print(n - ce[-2][1] - ce[-1][1])\nelse:\n print(n - ce[-1][1] - ce[-2][1])\n', 'import collections\n\n\nn = int(input())\nl = list(map(int, input().split()))\n\nif len(set(l)) == 1:\n print(n//2)\n exit()\n\nleven = [x for x in l[::2]]\nlodd = [x for x in l[1::2]]\n\nce = collections.Counter(leven)\nco = collections.Counter(lodd)\nce = sorted(ce.items(), key=lambda x:x[1])\nco = sorted(co.items(), key=lambda x:x[1])\n\nif ce[-1][0] != co[-1][0]:\n\tprint(n - ce[-1][1] - co[-1][1])\nelif ce[-2][1] > co[-2][1]:\n print(n - ce[-2][1] - co[-1][1])\nelse:\n print(n - ce[-1][1] - co[-2][1])\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s592306526', 's825389451', 's264990325']
[23764.0, 23764.0, 23764.0]
[97.0, 97.0, 99.0]
[501, 501, 501]
p03244
u642012866
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()\no = {"":0}\ne = {"":0}\nfor s in v[::2]:\n if s in o:\n o[s] += 1\n else:\n o[s] = 1\n\nfor s in v[1::2]:\n if s in e:\n e[s] += 1\n else:\n e[s] = 1\n\no = sorted(o.items(), key=lambda x:x[1])\ne = sorted(e.items(), key=lambda x:x[1])\n\nif o[0][0] != e[0][0]:\n print(n-o[0][1]-e[0][1])\nelse:\n print(n - max(o[0][1]+e[1][1], o[1][1]+e[0][1]))', 'n = int(input())\nv = input().split()\no = {"":0}\ne = {"":0}\nfor s in v[::2]:\n if s in o:\n o[s] += 1\n else:\n o[s] = 1\n\nfor s in v[1::2]:\n if s in e:\n e[s] += 1\n else:\n e[s] = 1\n\no = sorted(o.items(), key=lambda x:x[1])\ne = sorted(e.items(), key=lambda x:x[1])\n\nif o[-1][0] != e[-1][0]:\n print(n-o[-1][1]-e[-1][1])\nelse:\n print(n - max(o[-1][1]+e[-2][1], o[-2][1]+e[-1][1]))']
['Wrong Answer', 'Accepted']
['s860658017', 's174222866']
[20040.0, 20016.0]
[81.0, 80.0]
[409, 417]
p03244
u642528832
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())\na = list(map(int,input().split()))\na1 = collections.Counter(a[0::2]).most_common()\na2 = collections.Counter(a[1::2]).most_common()\n#a1.append((0,0))\n#a2.append((0,0))\nprint(a1)\nprint(a2)\n\nif a1[0] != a2[0]:\n print(n-a1[0][1]-a2[0][1])\nelse:\n print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))\n\n', 'import collections\n\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))\n#print(a1)\n#print(a2)\n\nif a1[0] != a2[0]:\n print(n-a1[0][1]-a2[0][1])\nelse:\n print(min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1]))\n\n']
['Runtime Error', 'Accepted']
['s222983102', 's361757736']
[25308.0, 25124.0]
[99.0, 76.0]
[338, 338]
p03244
u642823003
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_list = [0] * (n + 1)\nodd_list = [0] * (n + 1)\n\nfor i in range(n):\n if i % 2 == 0:\n even_list[i] += 1\n\n else:\n odd_list[i] += 1\n\nif even_list.index(max(even_list)) == odd_list.index(max(odd_list)):\n even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)\n print(n - min(even_sorted[-1] - odd_sorted[-2], n - even_sorted[-2] - odd_sorted[-1]))\n\nelse:\n print(n - max(even_list) - max(odd_list))\n', 'n = int(input())\nv = list(map(int, input().split()))\neven_list = [0] * (n + 1)\nodd_list = [0] * (n + 1)\n\nfor i in range(n):\n if i % 2 == 0:\n even_list[i] += 1\n\n else:\n odd_list[i] += 1\n\nif even_list.index(max(even_list)) == odd_list.index(max(odd_list)):\n even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)\n print(min(even_sorted[-1] + odd_sorted[-2], even_sorted[-2] + odd_sorted[-1]))\n\nelse:\n print(n - max(even_list) - max(odd_list))\n', 'n = int(input())\nv = list(map(int, input().split()))\neven_list = [0] * (n + 1)\nodd_list = [0] * (n + 1)\n\nfor i in range(n):\n if i % 2 == 0:\n even_list[i] += 1\n\n else:\n odd_list[i] += 1\n\nif even_list.index(max(even_list)) == odd_list.index(max(odd_list)):\n even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)\n print(min(n - even_sorted[-1] - odd_sorted[-2], n - even_sorted[-2] - odd_sorted[-1]))\n\nelse:\n print(n - max(even_list) - max(odd_list))\n', 'n = int(input())\nv = list(map(int, input().split()))\neven_list = [0] * (100000 + 1)\nodd_list = [0] * (100000 + 1)\n\nfor i in range(n):\n if i % 2 == 0:\n even_list[v[i]] += 1\n\n else:\n odd_list[v[i]] += 1\n\nif even_list.index(max(even_list)) == odd_list.index(max(odd_list)):\n even_sorted, odd_sorted = sorted(even_list), sorted(odd_list)\n print(min(n - even_sorted[-1] - odd_sorted[-2], n - even_sorted[-2] - odd_sorted[-1]))\n\nelse:\n print(n - max(even_list) - max(odd_list))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s078221327', 's334339440', 's630520464', 's485329211']
[14404.0, 14404.0, 14396.0, 14268.0]
[68.0, 68.0, 68.0, 85.0]
[485, 477, 485, 501]
p03244
u645250356
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,fractions\nfrom collections import Counter\nn = int(input())\nv = [int(i) for i in input().split()]\na = Counter(v[1::2]).most_common()\nb = Counter(v[0::2]).most_common()\na.append(0,0)\nb.append(0,0)\n\nif a[0][0] != b[0][0]:\n print(n//2 - a[0][1] + n//2 - b[0][1])\nelse:\n tmp_x = n//2 - a[1][1] + n//2 - b[0][1]\n tmp_y = n//2 - a[0][1] + n//2 - b[1][1]\n print(min(tmp_x, tmp_y))\n', 'import math,fractions\nfrom collections import Counter\nn = int(input())\nv = [int(i) for i in input().split()]\na = Counter(v[1::2]).most_common()\nb = Counter(v[0::2]).most_common()\na.append((0,0))\nb.append((0,0))\n\nif a[0][0] != b[0][0]:\n print(n//2 - a[0][1] + n//2 - b[0][1])\nelse:\n tmp_x = n//2 - a[1][1] + n//2 - b[0][1]\n tmp_y = n//2 - a[0][1] + n//2 - b[1][1]\n print(min(tmp_x, tmp_y))\n']
['Runtime Error', 'Accepted']
['s808515628', 's597779834']
[22348.0, 22348.0]
[105.0, 106.0]
[397, 401]
p03244
u648212584
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 corections import Counter \nn = int(input())\nv = list(map(int,input().split()))\n \nodd = []\neven = []\nfor i in range(n//2):\n\todd.append(v[2*i+1])\n\teven.append(v[2*i])\n \nodd = sorted(odd)\neven = sorted(even)\nac = Counter(odd).most_common(2)\nbc = Counter(even).most_common(2)\ndef cnt(X):\n\tcount = 0\n\tans = 0\n\tfor i in range(len(X)-1):\n\t\tif X[i+1] == X[i]:\n\t\t\tcount += 1\n\t\t\tans = max(ans,count)\n\t\telse:\n\t\t\tcount = 0\n\treturn ans+1\n \nif ac[0][0] != bc[0][0]:\n print(len(v)-cnt(odd)-cnt(even))\nelif len(ac) == 1 and len(bc) == 1:\n\tprint(n//2)\nelse:\n\tprint(n-max(ac[0][1]+bc[1][1],ac[1][1]+bc[0][1]))', 'from collections import Counter \nn = int(input())\nv = list(map(int,input().split()))\n \nodd = []\neven = []\nfor i in range(n//2):\n\todd.append(v[2*i+1])\n\teven.append(v[2*i])\n\nodd = sorted(odd)\neven = sorted(even)\nac = Counter(odd).most_common(2)\nbc = Counter(even).most_common(2)\ndef cnt(X):\n\tcount = 0\n\tans = 0\n\tfor i in range(len(X)-1):\n\t\tif X[i+1] == X[i]:\n\t\t\tcount += 1\n\t\t\tans = max(ans,count)\n\t\telse:\n\t\t\tcount = 0\n\treturn ans+1\n \nif ac[0][0] != bc[0][0]:\n print(len(v)-cnt(odd)-cnt(even))\nelif len(ac) == 1 and len(bc) == 1:\n\tprint(n//2)\nelse:\n\tprint(n-max(ac[0][1]+bc[1][1],ac[1][1]+bc[0][1]))\n']
['Runtime Error', 'Accepted']
['s501039437', 's909677567']
[3064.0, 16100.0]
[17.0, 137.0]
[608, 609]
p03244
u649126012
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['#!/usr/bin/env python3\nimport sys\nimport statistics\nimport collections\n\ndef solve(n: int, v: "List[int]"):\n half_length = len(v) // 2\n O = [v[i] for i in range(1, n, 2)]\n E = [v[i] for i in range(0, n, 2)]\n\n co = list(collections.Counter(O).most_common())\n ce = list(collections.Counter(E).most_common())\n o1 = co[0][0]\n e1 = ce[0][0]\n\n O_ = list(filter(lambda o: o != o1, O))\n E_ = list(filter(lambda e: e != e1, E))\n num_o_1 = len(O_) \n num_e_1 = len(E_)\n\n print(0)\n return\n\n if e1 != o1:\n num = num_o_1 + num_e_1\n else:\n if len(co) == 1 and len(ce) == 1:\n num = half_length\n elif len(co) == 1:\n e2 = ce[1][0]\n num_e_2 = len(list(filter(lambda e: e != e2, E)))\n num = num_o_1 + num_e_2\n elif len(ce) == 1:\n o2 = co[1][0]\n num_o_2 = len(list(filter(lambda o: o != o2, O)))\n num = num_o_2 + num_e_1\n else:\n e2 = ce[1][0]\n o2 = co[1][0]\n num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)\n print(num)\n return\n\n\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n n = int(next(tokens)) # type: int\n v = [ int(next(tokens)) for _ in range(n) ] # type: "List[int]"\n solve(n, v)\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python3\nimport sys\nimport statistics\nimport collections\n\ndef solve(n: int, v: "List[int]"):\n half_length = len(v) // 2\n O = [v[i] for i in range(1, n, 2)]\n E = [v[i] for i in range(0, n, 2)]\n\n co = list(collections.Counter(O).most_common())\n ce = list(collections.Counter(E).most_common())\n o1 = co[0][0]\n e1 = ce[0][0]\n\n O_ = list(filter(lambda o: o != o1, O))\n E_ = list(filter(lambda e: e != e1, E))\n num_o_1 = len(O_) \n num_e_1 = len(E_)\n\n if e1 != o1:\n num = num_o_1 + num_e_1\n else:\n if True and len(co) == 1 and len(ce) == 1:\n num = half_length\n elif len(co) == 1:\n e2 = ce[1][0]\n num_e_2 = len(list(filter(lambda e: e != e2, E)))\n num = num_o_1 + num_e_2\n elif len(ce) == 1:\n o2 = co[1][0]\n num_o_2 = len(list(filter(lambda o: o != o2, O)))\n num = num_o_2 + num_e_1\n else:\n e2 = ce[1][0]\n o2 = co[1][0]\n num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)\n num = 0\n print(num)\n return\n\n\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n n = int(next(tokens)) # type: int\n v = [ int(next(tokens)) for _ in range(n) ] # type: "List[int]"\n solve(n, v)\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python3\nimport sys\nimport statistics\nimport collections\n\ndef solve(n: int, v: "List[int]"):\n half_length = len(v) // 2\n O = [v[i] for i in range(1, n, 2)]\n E = [v[i] for i in range(0, n, 2)]\n\n co = list(collections.Counter(O).most_common())\n ce = list(collections.Counter(E).most_common())\n o1 = co[0][0]\n e1 = ce[0][0]\n\n O_ = list(filter(lambda o: o != o1, O))\n E_ = list(filter(lambda e: e != e1, E))\n num_o_1 = len(O_) \n num_e_1 = len(E_)\n\n if e1 != o1:\n num = num_o_1 + num_e_1\n else:\n if True:\n num = half_length\n elif len(co) == 1:\n e2 = ce[1][0]\n num_e_2 = len(list(filter(lambda e: e != e2, E)))\n num = num_o_1 + num_e_2\n elif len(ce) == 1:\n o2 = co[1][0]\n num_o_2 = len(list(filter(lambda o: o != o2, O)))\n num = num_o_2 + num_e_1\n else:\n e2 = ce[1][0]\n o2 = co[1][0]\n num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)\n num = 0\n print(num)\n return\n\n\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n n = int(next(tokens)) # type: int\n v = [ int(next(tokens)) for _ in range(n) ] # type: "List[int]"\n solve(n, v)\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python3\nimport sys\nimport statistics\nimport collections\n\ndef solve(n: int, v: "List[int]"):\n half_length = len(v) // 2\n O = [v[i] for i in range(1, n, 2)]\n E = [v[i] for i in range(0, n, 2)]\n\n co = list(collections.Counter(O).most_common())\n ce = list(collections.Counter(E).most_common())\n len(co)\n len(ce)\n o1 = co[0][0]\n e1 = ce[0][0]\n\n O_ = list(filter(lambda o: o != o1, O))\n E_ = list(filter(lambda e: e != e1, E))\n num_o_1 = len(O_) \n num_e_1 = len(E_)\n\n print(0)\n return\n\n if e1 != o1:\n num = num_o_1 + num_e_1\n else:\n if len(co) == 1 and len(ce) == 1:\n num = half_length\n elif len(co) == 1:\n e2 = ce[1][0]\n num_e_2 = len(list(filter(lambda e: e != e2, E)))\n num = num_o_1 + num_e_2\n elif len(ce) == 1:\n o2 = co[1][0]\n num_o_2 = len(list(filter(lambda o: o != o2, O)))\n num = num_o_2 + num_e_1\n else:\n e2 = ce[1][0]\n o2 = co[1][0]\n num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)\n print(num)\n return\n\n\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n n = int(next(tokens)) # type: int\n v = [ int(next(tokens)) for _ in range(n) ] # type: "List[int]"\n solve(n, v)\n\nif __name__ == \'__main__\':\n main()\n', '#!/usr/bin/env python3\nimport sys\nimport statistics\nimport collections\n\ndef solve(n: int, v: "List[int]"):\n half_length = len(v) // 2\n O = [v[i] for i in range(1, n, 2)]\n E = [v[i] for i in range(0, n, 2)]\n\n co = list(collections.Counter(O).most_common())\n ce = list(collections.Counter(E).most_common())\n o1 = co[0][0]\n e1 = ce[0][0]\n\n O_ = list(filter(lambda o: o != o1, O))\n E_ = list(filter(lambda e: e != e1, E))\n num_o_1 = len(O_) \n num_e_1 = len(E_)\n\n num = 0\n if e1 != o1:\n num = num_o_1 + num_e_1\n else:\n if len(co) == 1 and len(ce) == 1:\n num = half_length\n elif len(co) == 1:\n e2 = ce[1][0]\n num_e_2 = len(list(filter(lambda e: e != e2, E)))\n num = num_o_1 + num_e_2\n elif len(ce) == 1:\n o2 = co[1][0]\n num_o_2 = len(list(filter(lambda o: o != o2, O)))\n num = num_o_2 + num_e_1\n else:\n e2 = ce[1][0]\n o2 = co[1][0]\n num_e_2 = len(list(filter(lambda e: e != e2, E)))\n num_o_2 = len(list(filter(lambda o: o != o2, O)))\n num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)\n print(num)\n return\n\ndef len2(l):\n n = 0\n for i in l:\n n += 1\n return n\n\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n n = int(next(tokens)) # type: int\n v = [ int(next(tokens)) for _ in range(n) ] # type: "List[int]"\n solve(n, v)\n\nif __name__ == \'__main__\':\n main()\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s190319454', 's290929348', 's470097670', 's572462749', 's580659674']
[29828.0, 29828.0, 29764.0, 29828.0, 29836.0]
[137.0, 139.0, 144.0, 141.0, 149.0]
[1430, 1426, 1392, 1454, 1608]
p03244
u651879504
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())\nu = list(map(int,input().split()))\n\nhantei = 0\n\nfor i in range(1,n):\n if u[0] != u[i]:\n hantei = 1\n break\n\nif hantei == 0:\n print(n // 2)\nelse:\n u1 = [] \n u2 = [] \n ans = 0\n for j in range(n):\n if j % 2 == 0:\n u2.append(u[j])\n else:\n u1_list =collections.Counter(u1)\n u2_list =collections.Counter(u2)\n values1, counts1 = u1_list.most_common()[0]\n values2, counts2 = u2_list.most_common()[0]\n ans += n // 2 - counts1\n ans += n // 2 - counts2\n print(ans)', 'import collections\n\nn = int(input())\nu = list(map(int,input().split()))\n\nhantei = 0\n\nfor i in range(0,n):\n if u[0] != u[i]:\n hantei = 1\n break\n\nif hantei == 0:\n print(n // 2)\nelse:\n u1 = [] \n u2 = [] \n ans = 0\n for j in range(n):\n if j % 2 == 0:\n u2.append(u[j])\n else:\n u1.append(u[j])\n u1_list =collections.Counter(u1)\n u2_list =collections.Counter(u2)\n values1, counts1 = u1_list.most_common()[0]\n values2, counts2 = u2_list.most_common()[0]\n if values1 != values2:\n ans += n // 2 - counts1\n ans += n // 2 - counts2\n else:\n if len(u1_list) > 1 and len(u2_list) > 1:\n values3, counts3 = u1_list.most_common()[1]\n values4, counts4 = u2_list.most_common()[1]\n ans1 = n - counts1 - counts4\n ans2 = n - counts2 - counts3\n ans = max(ans1,ans2)\n elif len(u1_list) > 1 and len(u2_list) < 2:\n values3, counts3 = u1_list.most_common()[1]\n ans = n - counts2 - counts3\n elif len(u1_list) < 2 and len(u2_list) > 1:\n values3, counts3 = u2_list.most_common()[1]\n ans = n - counts1 - counts3\n\n ans = min(ans1,ans2)\n print(ans)\n']
['Runtime Error', 'Accepted']
['s006779469', 's184152360']
[2940.0, 20576.0]
[17.0, 126.0]
[553, 1214]
p03244
u652150585
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#print(l)\ne=[None]*(n//2)\no=[None]*(n//2)\nfor i in range(n//2):\n e[i]=l[2*i]\n o[i]=l[2*i+1]\nprint(e,o)\nce=collections.Counter(e)\nco=collections.Counter(o)\nce=ce.most_common()\nco=co.most_common()\n#print(co)\nce.append((0,0))\nco.append((0,0))\nif ce[0][0]!=co[0][0]:\n print(n-co[0][1]-ce[0][1])\nelse:\n print(min(n-ce[1][1]-co[0][1],n-ce[0][1]-co[1][1]))', 'import collections\n\nn=int(input())\nl=list(map(int,input().split()))\n#print(l)\ne=[None]*(n//2)\no=[None]*(n//2)\nfor i in range(n//2):\n e[i]=l[2*i]\n o[i]=l[2*i+1]\n#print(e,o)\nce=collections.Counter(e)\nco=collections.Counter(o)\nce=ce.most_common()\nco=co.most_common()\n#print(co)\nce.append((0,0))\nco.append((0,0))\nif ce[0][0]!=co[0][0]:\n print(n-co[0][1]-ce[0][1])\nelse:\n print(min(n-ce[1][1]-co[0][1],n-ce[0][1]-co[1][1]))']
['Wrong Answer', 'Accepted']
['s253396523', 's962175762']
[19680.0, 19032.0]
[109.0, 101.0]
[429, 430]
p03244
u656995812
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(str, input().split()))\ngu_row = []\nki_row = []\n\nfor i in range(n):\n if i % 2 == 0:\n gu_row.append(v[i])\n elif i % 2 == 1:\n ki_row.append(v[i])\n\ngu_count = collections.Counter(gu_row).most_common()\nki_count = collections.Counter(ki_row).most_common()\nprint(gu_count)\nprint(ki_count)\n\nif len(gu_count) > 1 and len(ki_count) > 1:\n if gu_count[0][0] != ki_count[0][0]:\n ans = n - gu_count[0][1] - ki_count[0][1]\n elif gu_count[0][0] == ki_count[0][0] and len(gu_count) == 1:\n ans = n - gu_count[0][1] - ki_count[1][1]\n elif gu_count[0][0] == ki_count[0][0] and len(ki_count) == 1:\n ans = n - gu_count[1][1] - ki_count[0][1]\n else:\n ans = n - max(gu_count[0][1] + ki_count[1][1], gu_count[1][1] + ki_count[0][1])\nelse:\n if gu_count[0][0] != ki_count[0][0]:\n ans = n - gu_count[0][1] - ki_count[0][1]\n else:\n ans = gu_count[0][1]\n\nprint(ans)', 'import collections\nn = int(input())\nv = list(map(str, input().split()))\ngu_row = []\nki_row = []\n\nfor i in range(n):\n if i % 2 == 0:\n gu_row.append(v[i])\n elif i % 2 == 1:\n ki_row.append(v[i])\n\ngu_count = collections.Counter(gu_row).most_common()\nki_count = collections.Counter(ki_row).most_common()\n\nif len(gu_count) > 1 and len(ki_count) > 1:\n if gu_count[0][0] != ki_count[0][0]:\n ans = n - gu_count[0][1] - ki_count[0][1]\n elif gu_count[0][0] == ki_count[0][0] and len(gu_count) == 1:\n ans = n - gu_count[0][1] - ki_count[1][1]\n elif gu_count[0][0] == ki_count[0][0] and len(ki_count) == 1:\n ans = n - gu_count[1][1] - ki_count[0][1]\n else:\n ans = n - max(gu_count[0][1] + ki_count[1][1], gu_count[1][1] + ki_count[0][1])\nelse:\n if gu_count[0][0] != ki_count[0][0]:\n ans = n - gu_count[0][1] - ki_count[0][1]\n else:\n ans = gu_count[0][1]\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s904066276', 's838040286']
[24924.0, 23516.0]
[151.0, 118.0]
[964, 932]
p03244
u657994700
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-v_odd_common[0][1]-v_even_common[1][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])', 'from collections import Counter\nfrom sys import exit\n\nn = 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\nif len(set(v_array)) == 1:\n print(int(len(v_array)/2))\n exit()\n\nprint(v_odd_common, v_even_common)\nfor i in range(0,min(len(v_odd_common),len(v_even_common))):\n if v_odd_common[i] == v_even_common[i]:\n if v_odd_common[i+1][1] > v_even_common[i+1][1]:\n v_odd_common_candidate = v_odd_common[i][1]\n v_even_common_candidate = v_even_common[i+1][i]\n break\n elif v_odd_common[i+1][1] < v_even_common[i+1][1]:\n v_odd_common_candidate = v_odd_common[i+1][1]\n v_even_common_candidate = v_even_common[i][i]\n break\n else:\n v_odd_common_candidate = v_odd_common[i][1]\n v_even_common_candidate = v_even_common[i][i]\n break\n else:\n v_odd_common_candidate = v_odd_common[0][1]\n v_even_common_candidate = v_even_common[0][1]\n \nprint(len(v_odd) - v_odd_common_candidate + len(v_even) - v_even_common_candidate)', '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-v_odd_common[0][1]-v_even_common[1][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]))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s046679602', 's137154310', 's355757321', 's848447132', 's886307799', 's968445990']
[2940.0, 3064.0, 25172.0, 3064.0, 2940.0, 21084.0]
[17.0, 18.0, 145.0, 17.0, 18.0, 88.0]
[40, 482, 1190, 482, 40, 483]
p03244
u664884522
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\nn = int(input())\nv = [int(x) for x in input().split()]\ntest = [x == v[0] for x in v]\nif all(test):\n print(0)\n sys.exit()\nodd = [int(x) for x in v[0::2]]\neven = [int(x) for x in v[1::2]]\nodd_count = Counter(odd)\nkey1 = list(odd_count)\neven_count = Counter(even)\nkey2 = list(even_count)\nnum = 0\nif key1[0] == key2[0]:\n num = min(odd_count[key1[0]]-odd_count[key1[1]],even_count[key2[0]]-even_count[key2[1]])\n print(n-odd_count[key1[0]]-even_count[key2[0]]+num)\nelse:\n print(odd_count[key1[0]],even_count[key2[0]])\n print(n-odd_count[key1[0]]-even_count[key2[0]])\n', 'from collections import Counter\nimport sys\nn = int(input())\nv = [int(x) for x in input().split()]\ntest = [x == v[0] for x in v]\nif all(test):\n print(int(n/2))\n sys.exit()\nodd = [int(x) for x in v[0::2]]\neven = [int(x) for x in v[1::2]]\nodd_count = Counter(odd)\nkey1 = list(odd_count)\neven_count = Counter(even)\nkey2 = list(even_count)\nnum = 0\nif key1[0] == key2[0]:\n num = min(odd_count[key1[0]]-odd_count[key1[1]],even_count[key2[0]]-even_count[key2[1]])\n print(n-odd_count[key1[0]]-even_count[key2[0]]+num)\nelse:\n print(odd_count[key1[0]],even_count[key2[0]])\n print(n-odd_count[key1[0]]-even_count[key2[0]])\n', 'from collections import Counter\n\n\ndef solve(V):\n n = len(V)\n ac = Counter(V[::2]).most_common(2)\n bc = Counter(V[1::2]).most_common(2)\n\n if ac[0][0] != bc[0][0]:\n return n - ac[0][1] - bc[0][1]\n else:\n if len(bc) == 1 or len(ac) == 1:\n return n // 2\n else:\n return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])\n\n\nif __name__ == "__main__":\n n = int(input())\n l = input()\n print(solve(l.split(" ")))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s695551149', 's802054540', 's857693767']
[24864.0, 24524.0, 22476.0]
[75.0, 83.0, 62.0]
[622, 629, 469]
p03244
u665038048
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())\ncount=0\nv=[]\nv=[int(i) for i in input().split()]\nfor i in range(n-2):\n if v[i]==v[i+2]:\n pass\n else:\n count+=1\nnum=v[0]\nfor i in range(n):\n v.remove(num)\nprint(v)\nif len(v)==0:\n if n%2==0:\n count=int(n/2)\n else:\n count=int((n-1)/2)\nprint(count)\n', 'import itertools\nfrom collections import Counter\n\n\nn = int(input())\nv = list(map(int, input().split()))\nev_cnt = Counter(v[::2])\nod_cnt = Counter(v[1::2])\nev_cnt[-1] = 0\nod_cnt[-2] = 0\nev = ev_cnt.most_common(2)\nod = od_cnt.most_common(2)\nans = n\nfor (k1, v1), (k2, v2) in itertools.product(ev, od):\n if k1 == k2:\n continue\n x = (n - v1 - v2)\n ans = min(ans, x)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s547903085', 's128432625']
[14268.0, 18520.0]
[2104.0, 78.0]
[303, 389]
p03244
u667469290
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 -*-\nfrom collections import Counter\nfrom operator import itemgetter\ndef solve():\n input()\n V = list(map(int, input().split()))\n l = sorted(Counter(V[::2]).items()+[(0,0)], key=itemgetter(1), reverse=True)\n u = sorted(Counter(V[1::2]).items()+[(0,0)], key=itemgetter(1), reverse=True)\n res = sum(map(itemgetter(1), l+u)) - (max(l[0][1]+u[1][1], l[1][1]+u[0][1]) if l[0][0]==u[0][0] else (l[0][1]+u[0][1]))\n return str(res)\n\nif __name__ == '__main__':\n print(solve())\n\n", "# -*- coding: utf-8 -*-\nfrom collections import Counter\nfrom operator import itemgetter\ndef solve():\n input()\n V = list(map(int, input().split()))\n l = sorted(list(Counter(V[::2]).items())+[(0,0)], key=itemgetter(1), reverse=True)\n u = sorted(list(Counter(V[1::2]).items())+[(0,0)], key=itemgetter(1), reverse=True)\n res = sum(map(itemgetter(1), l+u)) - (max(l[0][1]+u[1][1], l[1][1]+u[0][1]) if l[0][0]==u[0][0] else (l[0][1]+u[0][1]))\n return str(res)\n\nif __name__ == '__main__':\n print(solve())\n\n"]
['Runtime Error', 'Accepted']
['s136665526', 's276413388']
[15588.0, 20572.0]
[49.0, 92.0]
[508, 520]
p03244
u669173971
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()))\nc1=collections.Counter(v[::2])\nc2=collections.Counter(v[1::2])\nc1_v1=c1.most_common()[0][0]\nc2_v1=c2.most_common()[0][0]\nc1_n1=c1.most_common()[0][1]\nc2_n1=c2.most_common()[0][1]\nc1_n2=c1.most_common(2)[1][1]\nc2_n2=c2.most_common(2)[1][1]\n\nif c1_v1!=c2_v1:\n print(n-c1_n1-c2_n1)\nelse:\n if c1_n1==n//2:\n if c2_n1==n//2:\n print(n//2)\n else:\n print(n-c1_n1-c2_n2)\n else:\n if c2_n1==n//2:\n print(n-c1_n2-c2_n1)\n else:\n print(n-c1_n2-c2_n2)', 'import collections\nn=int(input())\nv=list(map(int,input().split()))\nc1=collections.Counter(v[::2])\nc2=collections.Counter(v[1::2])\nc1_v1=c1.most_common()[0][0]\nc2_v1=c2.most_common()[0][0]\nc1_n1=c1.most_common()[0][1]\nc2_n1=c2.most_common()[0][1]\n\nif c1_v1!=c2_v1:\n print(n-c1_n1-c2_n1)\nelse:\n if c1_n1==n//2:\n if c2_n1==n//2:\n print(n//2)\n else:\n c2_n2=c2.most_common(2)[1][1]\n print(n-c1_n1-c2_n2)\n else:\n c1_n2=c1.most_common(2)[1][1]\n if c2_n1==n//2:\n print(n-c1_n2-c2_n1)\n else:\n c2_n2=c2.most_common(2)[1][1]\n print(min(n-c1_n2-c2_n1,n-c1_n1-c2_n2))\n']
['Runtime Error', 'Accepted']
['s889300601', 's887306860']
[18656.0, 18656.0]
[121.0, 123.0]
[583, 665]
p03244
u671446913
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\nif len(set(v)) == 1:\n print(n//2)\nelse:\n v1 = v[::2]\n v2 = v[1::2]\n \n cl1 = collections.Counter(v1)\n cl2 = collections.Counter(v2)\n \n cmc_1st_1 = cl1.most_common()[0][1]\n cmc_1st_2 = cl2.most_common()[0][1]\n cmc_2nd_1 = cl1.most_common()[1][1]\n cmc_2nd_2 = cl2.most_common()[1][1] \n \n if cmc_1st_1 == cmc_1st_2:\n if cmc_2nd_1 > cmc_2nd_2:\n ans = len(v1) - cmc_2nd_1\n ans += len(v2) - cmc_1st_2\n else:\n ans = len(v1) - cmc_1st_1\n ans += len(v2) - cmc_2nd_2\n else:\n ans = len(v1) - cmc_1st_1\n ans += len(v2) - cmc_1st_2\n \n print(ans)', 'import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n print(n//2)\nelse:\n v1 = v[::2]\n v2 = v[1::2]\n \n cmc1 = collections.Counter(v1).most_common()\n cmc2 = collections.Counter(v2).most_common()\n \n print(cmc1[:5])\n print(cmc2[:5])\n \n if cmc1[0][0] == cmc2[0][0]: \n ans1 = (len(v1) - cmc1[0][1]) + (len(v2) - cmc2[1][1])\n ans2 = (len(v1) - cmc1[1][1]) + (len(v2) - cmc2[0][1])\n print(min(ans1, ans2))\n else:\n ans = (len(v1) - cmc1[0][1]) + (len(v2) - cmc2[0][1])\n print(ans)', 'import collections\n\nn = int(input())\nv = list(map(int, input().split()))\n\nif len(set(v)) == 1:\n print(n//2)\nelse:\n v1 = v[::2]\n v2 = v[1::2]\n \n cmc1 = collections.Counter(v1).most_common()\n cmc2 = collections.Counter(v2).most_common()\n \n if cmc1[0][0] == cmc2[0][0]: \n ans1 = (len(v1) - cmc1[0][1]) + (len(v2) - cmc2[1][1])\n ans2 = (len(v1) - cmc1[1][1]) + (len(v2) - cmc2[0][1])\n print(min(ans1, ans2))\n else:\n ans = (len(v1) - cmc1[0][1]) + (len(v2) - cmc2[0][1])\n print(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s431820253', 's806439293', 's227593981']
[20572.0, 21084.0, 21084.0]
[108.0, 90.0, 90.0]
[653, 543, 504]
p03244
u673361376
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 heapq\n\nN = int(input())\n\nif str(N)[0]*len(str(N)) == str(N):\n print(N//2)\n exit()\n\nVeve, Vodd = [],[]\nidx = 0\nfor v in map(int,input().split()):\n if idx%2 == 0: Veve.append(v)\n else: Vodd.append(v)\n idx += 1\n\nVeve_cnt, Vodd_cnt = [], []\n[heapq.heappush(Veve_cnt, [-num,val]) for val, num in Counter(Veve).items()]\n[heapq.heappush(Vodd_cnt, [-num,val]) for val, num in Counter(Vodd).items()]\n\neve_val, odd_val = None, None\nwhile eve_val == odd_val:\n if eve_val is None:\n neg_num, val = heapq.heappop(Veve_cnt)\n eve_val = val\n eve_num = -neg_num\n if odd_val is None:\n neg_num, val = heapq.heappop(Vodd_cnt)\n odd_val = val\n odd_num = -neg_num\nprint(N-eve_num-odd_num)', 'N = int(input())\nV = list(map(int, input().split()))\n\neven_idx_cnt = {}\nodd_idx_cnt = {}\nfor idx, v in enumerate(V):\n if idx % 2 == 0:\n if v not in even_idx_cnt:\n even_idx_cnt[v] = 0\n even_idx_cnt[v] += 1\n else:\n if v not in odd_idx_cnt:\n odd_idx_cnt[v] = 0\n odd_idx_cnt[v] += 1\n\nif len(even_idx_cnt) == 1 and len(odd_idx_cnt) == 1:\n if even_idx_cnt.keys() == odd_idx_cnt.keys():\n print(N - even_idx_cnt[V[0]])\n else:\n print(0)\n exit()\n\neven_idx_cnt = sorted(even_idx_cnt.items(), key=lambda x:x[1], reverse=True)\nodd_idx_cnt = sorted(odd_idx_cnt.items(), key=lambda x:x[1], reverse=True)\n\nif even_idx_cnt[0][0] != odd_idx_cnt[0][0]:\n print(N - even_idx_cnt[0][1] - odd_idx_cnt[0][1])\nelif len(even_idx_cnt) == 1:\n print(N - even_idx_cnt[0][1] - odd_idx_cnt[1][1])\nelif len(odd_idx_cnt) == 1:\n print(N - even_idx_cnt[1][1] - odd_idx_cnt[0][1])\nelse:\n if even_idx_cnt[1][1] > odd_idx_cnt[1][1]:\n print(N - even_idx_cnt[1][1] - odd_idx_cnt[0][1])\n else:\n print(N - even_idx_cnt[0][1] - odd_idx_cnt[1][1])\n']
['Wrong Answer', 'Accepted']
['s560192609', 's578760087']
[22016.0, 19292.0]
[2105.0, 113.0]
[728, 1113]
p03244
u676496404
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()))\neven = Counter(v[::2]).most_common(2)\nodd = Counter(n[1::2]).most_common(2)\nif even[0][0] != odd[0][0]:\n ans = n - even[0][1] - odd[0][1]\nelse:\n if len(even) == 1:\n ans = n//2\n else:\n ans = n - max(even[0][1] + odd[1][1],even[1][1],odd[0][1])\nprint(ans)\n', 'from collections import Counter\nn = int(input())\nv = list(map(int,input().split()))\neven = Counter(v[::2]).most_common(2)\nodd = Counter(n[1::2]).most_common(2)\nif even[0][0] != odd[0][0]:\n ans = n - even[0][1] - odd[0][1]\nelse:\n if len(even) == 1:\n ans = n//2:\n else:\n ans = n - max(even[0][1] + odd[1][1],even[1][1],odd[0][1])\nprint(ans)', 'from collections import Counter\nn = int(input())\nv = list(map(int,input().split()))\neven = Counter(v[::2]).most_common(2)\nodd = Counter(v[1::2]).most_common(2)\n\nif even[0][0] != odd[0][0]:\n ans = n - even[0][1] - odd[0][1]\nelse:\n if len(even) == 1 or len(odd)==1:\n ans = n//2\n else:\n ans = n - max(even[0][1] + odd[1][1],even[1][1]+odd[0][1])\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s155566305', 's196132638', 's672649350']
[15588.0, 3064.0, 15588.0]
[58.0, 17.0, 76.0]
[363, 363, 420]
p03244
u677440371
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()] \n\nfrom statistics import mode\nif len(set(v)) == 1:\n print(int(len(v) / 2))\nelse:\n print(len(v[0::2]) - collections.Counter(v[0::2]).most_common()[0][1] + len(v[1::2]) - collections.Counter(v[1::2]).most_common()[0][1])', 'n = int(input())\nv = [int(i) for i in input().split()] \n\nfrom statistics import mode\nif len(set(v)) == 1:\n print(int(len(v) / 2))\nelse:\n print(len(v[0::2]) - collections.Counter(v[0::2]).most_common()[0][1] + len(v[1::2]) - collections.Counter(v[1::2]).most_common()[0][1])', 'n = int(input())\nv = [int(i) for i in input().split()] \nimport collections\nif len(set(v)) == 1:\n print(int(len(v) / 2))\nelse:\n a = collections.Counter(v[0::2]).most_common()\n b = collections.Counter(v[1::2]).most_common() \n if a[0][0] == b[0][0]:\n print(min((len(v[0::2]) - a[1][1] + len(v[1::2]) - b[0][1]),(len(v[0::2]) - a[0][1] + len(v[1::2]) - b[1][1])))\n else:\n print(len(v[0::2]) - a[0][1] + len(v[1::2]) - b[0][1])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s130332139', 's338233244', 's111624094']
[16412.0, 16480.0, 20512.0]
[70.0, 81.0, 97.0]
[280, 280, 452]
p03244
u677705680
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['n = int(input())\nV = list(map(int, input().split()))\n\neven = []\nodd = []\nfor nn in range(n):\n if nn % 2 == 0:\n even.append(V[nn])\n else:\n odd.append(V[nn])\n\ne = collections.Counter(even).most_common()\no = collections.Counter(odd).most_common()\n\nif e[0][0] != o[0][0]:\n print(n - e[0][1] - o[0][1])\nelse:\n if len(e) == 1 and len(o) == 1:\n print(n // 2)\n elif len(e) == 1 and len(o) >= 2:\n print(n - o[0][1])\n elif len(e) >= 2 and len(o) == 1:\n print(n - e[0][1])\n else:\n print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))', 'import collections\nn = int(input())\nV = list(map(int, input().split()))\n\neven = [0] * (n//2)\nodd = [0] * (n//2)\nfor nn in range(n):\n if nn % 2 == 0:\n even.append(V[nn])\n else:\n odd.append(V[nn])\n\ne = collections.Counter(even).most_common()\no = collections.Counter(odd).most_common()\n\nif e[0][0] != o[0][0]:\n print(n - e[0][1] - o[0][1])\nelse:\n if len(e) == 1 and len(o) == 1:\n print(n // 2)\n elif len(e) == 1 and len(o) >= 2:\n print(n - o[0][1])\n elif len(e) >= 2 and len(o) == 1:\n print(n - e[0][1])\n else:\n print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))\n\n\n', 'import collections\nn = int(input())\nV = list(map(int, input().split()))\n\neven = [0] * 100001\nodd = [0] * 100001\nfor nn in range(n):\n if nn % 2 == 0:\n even.append(V[nn])\n else:\n odd.append(V[nn])\n\ne = collections.Counter(even).most_common()\no = collections.Counter(odd).most_common()\n\nif e[0][0] != o[0][0]:\n print(n - e[0][1] - o[0][1])\nelse:\n if len(e) == 1 and len(o) == 1:\n print(n // 2)\n elif len(e) == 1 and len(o) >= 2:\n print(n - o[0][1])\n elif len(e) >= 2 and len(o) == 1:\n print(n - e[0][1])\n else:\n print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))\n\n\n', 'import collections\nn = int(input())\nV = list(map(int, input().split()))\n\neven = []\nodd = []\nfor nn in range(n):\n if nn % 2 == 0:\n even.append(V[nn])\n else:\n odd.append(V[nn])\n\ne = collections.Counter(even).most_common()\no = collections.Counter(odd).most_common()\n\nif e[0][0] != o[0][0]:\n print(n - e[0][1] - o[0][1])\nelse:\n if len(e) == 1 and len(o) == 1:\n print(n // 2)\n elif len(e) == 1 and len(o) >= 2:\n print(n - o[0][1])\n elif len(e) >= 2 and len(o) == 1:\n print(n - e[0][1])\n else:\n print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))\n\n\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s061576829', 's585677601', 's759648353', 's122589673']
[14404.0, 22236.0, 22620.0, 21212.0]
[65.0, 152.0, 132.0, 106.0]
[585, 627, 627, 607]
p03244
u682467216
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 = [i for i in input().split()]\n \nodd = Counter(V[::2]).most_common(2)\neven = Counter(V[1::2]).most_common(2)\n\nprint(odd)\n \nif odd[0][0] != even[0][0]:\n print(N - odd[0][1] - even[0][1])\nelif len(odd) == 1:\n print(N // 2)\nelse:\n o0e1 = N - odd[0][1] - even[1][1]\n o1e0 = N - odd[1][1] - even[0][1]\n print(min(o0e1, o1e0))', 'from collections import Counter\n \nN = int(input())\nV = [i for i in input().split()]\n \nodd = Counter(V[::2]).most_common(2)\neven = Counter(V[1::2]).most_common(2)\n\nif odd[0][0] != even[0][0]:\n print(N - odd[0][1] - even[0][1])\nelif len(odd) == 1:\n print(N // 2)\nelse:\n o0e1 = N - odd[0][1] - even[1][1]\n o1e0 = N - odd[1][1] - even[0][1]\n print(min(o0e1, o1e0))']
['Wrong Answer', 'Accepted']
['s397042751', 's253203788']
[16228.0, 16228.0]
[69.0, 67.0]
[388, 375]
p03244
u682730715
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\nimport sys\n\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\nn = int(input())\nv = list(map(int, input().split()))\na = defaultdict(int)\nb = defaultdict(int)\n\nnn = n // 2\nfor i in range(nn):\n a[v[i * 2]] += 1\n b[v[i * 2 + 1]] += 1\n\nma1 = max(a, key=a.get)\nmb1 = max(b, key=b.get)\na[ma1] = 0\nb[mb1] = 0\nma2 = max(a, key=a.get)\nmb2 = max(b, key=b.get)\na[ma2] = 0\nb[mb2] = 0\n\nma = [ma1, ma2]\nmb = [mb1, mb2]\nmx = 0xFFFFFFFF\nfor i in ma:\n for j in mb:\n mx = min(sum(a.values()) + i + sum(b.values()) + j, mx)\n \nprint(mx)', '# coding: UTF-8\nimport sys\n\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\nn = int(input())\nv = list(map(int, input().split()))\na = defaultdict(int)\nb = defaultdict(int)\n\nnn = n // 2\nfor i in range(nn):\n a[v[i * 2]] += 1\n b[v[i * 2 + 1]] += 1\n\nma1 = max(a, key=a.get)\nmb1 = max(b, key=b.get)\nmva1 = a[ma1]\nmvb1 = b[mb1]\na[ma1] = 0\nb[mb1] = 0\nma2 = max(a, key=a.get)\nmb2 = max(b, key=b.get)\nmva2 = a[ma2]\nmvb2 = b[mb2]\na[ma2] = 0\nb[mb2] = 0\n\nma = [(ma1, mva1), (ma2, mva2)]\nmb = [(mb1, mvb1), (mb2, mvb2)]\nmx = 0xFFFFFFFF\nfor i in ma:\n for j in mb:\n if i[0] == j[0]:\n pass\n else:\n mx = min(sum(a.values()) + i[1] + sum(b.values()) + j[1], mx)\nif mx == 0xFFFFFFFF:\n print(0)\nelse:\n print(mx', '# coding: UTF-8\nimport sys\n\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\nn = int(input())\na = list(map(int, input().split()))\neven = defaultdict(int)\nodd = defaultdict(int)\nfor i in range(n):\n if i % 2 == 0:\n even[a[i]] += 1\n else:\n odd[a[i]] += 1\nx = sorted(even.items(), reverse=True, key=lambda t:t[1])\ny = sorted(odd.items(), reverse=True, key=lambda t:t[1])\neven_index = 0\nodd_index = 0\nif x[0][0] == y[0][0]:\n if x[0][1] > y[0][1]:\n even_index = 0\n odd_index = 1\n elif x[0][1] < y[0][1]:\n odd_index = 0\n even_index = 1\n else:\n if len(x) > 1:\n print(n - x[0][1] - max(x[1][1], y[1][1]))\n else:\n print(n // 2)\n exit()\n \nelse:\n even_index = 0\n odd_index = 0\nprint(n - x[even_index][1] - y[odd_index][1])\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s610615393', 's684678718', 's192420035']
[18752.0, 3064.0, 24640.0]
[129.0, 17.0, 161.0]
[701, 889, 976]
p03244
u684204084
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['n = int(input())\nv = list(map(int, input().split()))\nv1 = []\nv2 = []\nfor i in range(n):\n\tif i%2 == 0:\n\t\tv1.append(v[i])\n\telse:\n\t\tv2.append(v[i])\nv1.sort()\nv2.sort()\n\ncnt1 = []\ncnt2 = []\nnow = v1[0]\ncon = 1\nfor i in range(1, len(v1)):\n\tif now == v1[i]:\n\t\tcon += 1\n\telse:\n\t\tnow = v1[i]\n\t\tcnt1.append(con)\n\t\tcon = 1\ncnt1.append(con)\nnow = v2[0]\ncon = 1\nfor i in range(1, len(v2)):\n\tif now == v2[i]:\n\t\tcon += 1\n\telse:\n\t\tnow = v2[i]\n\t\tcnt2.append(con)\n\t\tcon = 1\ncnt2.append(con)\nif cnt1.index(max(cnt1)) != cnt2.index(max(cnt2)):\n\tcnt1.sort()\n\tcnt2.sort()\n\tprint(sum(cnt1[:len(cnt1)-1])+sum(cnt2[:len(cnt2)-1]))\nelse:\n\tcnt1.sort()\n\tcnt2.sort()\n\tans = max(sum(cnt1[:len(cnt1)-2])+cnt1[len(cnt1)-1]+sum(cnt2[:len(cnt2)-1]), sum(cnt1[:len(cnt1)-1])+cnt2[len(cnt2)-1]+sum(cnt2[:len(cnt2)-2]))\n\tprint(ans)', 'n = int(input())\nv = list(map(int, input().split()))\nv1 = []\nv2 = []\nfor i in range(n):\n\tif i%2 == 0:\n\t\tv1.append(v[i])\n\telse:\n\t\tv2.append(v[i])\nv1.sort()\nv2.sort()\n\ncnt1 = []\ncnt2 = []\nnow = v1[0]\ncon = 1\nfor i in range(1, len(v1)):\n\tif now == v1[i]:\n\t\tcon += 1\n\telse:\n\t\tcnt1.append([con, now])\n\t\tnow = v1[i]\n\t\tcon = 1\ncnt1.append([con, now])\nnow = v2[0]\ncon = 1\nfor i in range(1, len(v2)):\n\tif now == v2[i]:\n\t\tcon += 1\n\telse:\n\t\tcnt2.append([con, now])\n\t\tnow = v2[i]\n\t\tcon = 1\ncnt2.append([con, now])\n\ncnt1.sort()\ncnt2.sort()\nif cnt1[len(cnt1)-1][1] != cnt2[len(cnt2)-1][1]:\n\tp1 = [cnt1[i][0] for i in range(len(cnt1))]\n\tp2 = [cnt2[i][0] for i in range(len(cnt2))]\n\tprint(sum(p1[:len(p1)-1])+sum(p2[:len(p2)-1]))\nelse:\n\tp1 = [cnt1[i][0] for i in range(len(cnt1))]\n\tp2 = [cnt2[i][0] for i in range(len(cnt2))]\n\tans = min(sum(p1[:len(p1)-2])+p1[len(p1)-1]+sum(p2[:len(p2)-1]), sum(p1[:len(p1)-1])+p2[len(p2)-1]+sum(p2[:len(p2)-2]))\n\tprint(ans)']
['Wrong Answer', 'Accepted']
['s709280580', 's880275061']
[14052.0, 19212.0]
[132.0, 178.0]
[795, 942]
p03244
u687343821
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=list(map(int,input().split(" ")))\nlist_odd=N[::2]\nlist_even=N[1::2]\nc_odd = collections.Counter(list_odd)\nc_even = collections.Counter(list_even)\nmost_odd=c_odd.most_common()[0][1]\nmost_even=c_even.most_common()[0][1]\nprint(len(list_even)+len(list_odd)-most_even-most_odd)', 'import collections\n\nN=list(map(int,input().split(" ")))\nlist_odd=N[::2]\nlist_even=N[1::2]\nc_odd = collections.Counter(list_odd)\nc_even = collections.Counter(list_even)\nmost_odd=c_odd.most_common()[0][1]\nmost_even=c_even.most_common()[0][1]\nprint(len(list_even)+len(list_odd)-most_even-most_odd)\n', 'import collections\nn=int(input())\nN=list(map(int,input().split(" ")))\nlist_odd=N[::2]\nlist_even=N[1::2]\nc_odd = collections.Counter(list_odd)\nc_even = collections.Counter(list_even)\nmost_odd=c_odd.most_common()[0][1]\nmost_even=c_even.most_common()[0][1]\nif (n<=2):\n print("0")\nelif (len(list_even)==most_even and len(list_odd)==most_odd and c_odd.most_common()[0][0]==c_even.most_common()[0][0]):\n print(most_odd)\nelse:\n if(c_odd.most_common()[0][0]==c_even.most_common()[0][0]):\n M=max(c_odd.most_common()[1][1],c_even.most_common()[1][1])\n print(min((len(list_even)+len(list_odd)-M-most_odd),(len(list_even)+len(list_odd)-M-most_even)))\n else:\n print(len(list_even)+len(list_odd)-most_even-most_odd)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s619047446', 's690489176', 's144855032']
[3316.0, 3316.0, 19040.0]
[24.0, 22.0, 123.0]
[293, 295, 789]
p03244
u691896522
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['import collections\nn = int(input())\nv = list(map(int, input().split()))\neven = []\neven_c = 0\nodd = []\nodd_c = 0\nans = 0\nfor i in range(len(v)):\n print(i)\n if i % 2 == 0:\n even.append(v[i])\n even_c += 1\n else:\n odd.append(v[i])\n odd_c += 1\n \neven = collections.Counter(even)\nodd = collections.Counter(odd)\neven_max = max(list(even.items()), key = lambda x: x[1])\nodd_max = max(list(odd.items()), key = lambda x: x[1])\nif even_max[0] == odd_max[0]:\n even_sec = [i for i in list(even.items()) if i[0] != even_max[0]] \n odd_sec = [i for i in list(odd.items()) if i[0] != odd_max[0]]\n if len(even_sec) == 0 and len(odd_sec) == 0:\n print(min(even_max[1], odd_max[1]))\n exit()\n if len(even_sec) == 0:\n ans += min(even_max[1], odd_c - odd_max[1])\n print(ans)\n exit()\n if len(odd_sec) == 0:\n ans += min(odd_max[1], even_c - even_max[1])\n print(ans)\n exit()\n even_sec = max(even_sec, key = lambda x: x[1])\n odd_sec = max(odd, key = lambda x: x[1])\n if even_max[1] > odd_max[1]:\n ans += even_c - even_max[1]\n ans += odd_c - odd_sec[1]\n elif even_max[1] < odd_max[1]:\n ans += odd_c - odd_max[1]\n ans += even_c - even_sec[1]\n else:\n if odd_sec[1] < even_sec[1]:\n ans += even_c - even_sec[1]\n ans += odd_c - odd_max[1]\n elif odd_sec[1] > even_sec[1]:\n ans += odd_c - odd_sec[1]\n ans += even_c - even_max[1]\n else:\n ans += even_c - even_max[1]\n ans += odd_c - odd_sec[1]\nelse:\n ans += even_c - even_max[1]\n ans += odd_c - odd_max[1]\nprint(ans)\n', 'import collections\nn = int(input())\nv = list(map(int, input().split()))\neven = []\nodd = []\nfor i in range(n):\n if i % 2 == 0:\n even += [v[i]]\n else:\n odd += [v[i]]\neven_dict = collections.Counter(even)\nodd_dict = collections.Counter(odd)\nmax_even = max(even_dict.items(), key = lambda x:x[1])\nmax_odd = max(odd_dict.items(), key = lambda x:x[1])\n\nif max_even[0] != max_odd[0]:\n print(len(even) - max_even[1] + len(odd) - max_odd[1])\nelse:\n \n if max_even[1] == len(even) and max_odd[1] == len(odd):\n second_even = (-1,0)\n second_odd = (-1,0)\n elif max_even[1] == len(even):\n second_even = (-1,0)\n second_odd = max([i for i in odd_dict.items() if i != max_odd], key = lambda x:x[1])\n elif max_odd[1] == len(odd):\n second_even = max([i for i in even_dict.items() if i != max_even], key = lambda x:x[1])\n second_odd = (-1,0)\n else:\n second_even = max([i for i in even_dict.items() if i != max_even], key = lambda x:x[1])\n second_odd = max([i for i in odd_dict.items() if i != max_odd], key = lambda x:x[1])\n \n if second_even[1] > second_odd[1]:\n print(len(even) - second_even[1] + len(odd) - max_odd[1])\n else:\n print(len(even) - max_even[1] + len(odd) - second_odd[1])\n\n\n']
['Runtime Error', 'Accepted']
['s672282997', 's317654939']
[21472.0, 19032.0]
[239.0, 143.0]
[1680, 1387]
p03244
u695261159
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 = map(int, input().split())\nV = list(map(int, input().split()))\n\nans = 0\neve = V[0::2]\nodd = V[1::2]\ncntEve = collections.Counter(eve)\ncntOdd = collections.Counter(odd)\n\nif cntEve.most_common()[0][0] == cntOdd.most_common()[0][0]:\n ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - max(cntEve.most_common()[1][1],cntOdd.most_common()[1][1])\nelse:\n ans = N - cntEve.most_common()[0][1] - cntOdd.most_common()[0][1]\n\nprint(ans)', 'import collections\nN = int(input())\nV = list(map(int, input().split()))\n\nans = 0\neve = V[0::2]\nodd = V[1::2]\ncntEve = collections.Counter(eve)\ncntOdd = collections.Counter(odd)\n\nif cntEve.most_common()[0][0] == cntOdd.most_common()[0][0]:\n if len(cntEve) == 1 and len(cntOdd) > 1:\n ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - cntOdd.most_common()[1][1]\n elif len(cntEve) > 1 and len(cntOdd) == 1:\n ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - cntEve.most_common()[1][1]\n elif len(cntEve) == 1 and len(cntOdd) == 1:\n ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1])\n else:\n ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - max(cntEve.most_common()[1][1],cntOdd.most_common()[1][1])\nelse:\n ans = N - int(cntEve.most_common()[0][1]) - int(cntOdd.most_common()[0][1])\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s357751596', 's486604076']
[24612.0, 24620.0]
[85.0, 99.0]
[473, 913]
p03244
u705418271
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())\nalist = list(map(int,input().split()))\nlist1 = alist[1::2]\nlist2 = alist[0::2]\nfrom collections import Counter\ndic1 = Counter(list1).most_common()\ndic2 = Counter(list2).most_common()\n\nif dic1[0][0]!=dic2[0][0]:\n print(n - dic1[0][1] - dic2[0][1]+1)\nelse:\n print(min(n - dic1[0][1] - dic2[1][1]+1, n -dic1[1][1] - dic2[0][1]+1))', 'n = int(input())\nalist = list(map(int,input().split()))\nlist1 = alist[1::2]\nlist2 = alist[0::2]\nfrom collections import Counter\ndic1 = Counter(list1).most_common()\ndic2 = Counter(list2).most_common()\ndic1.append([0,0])\ndic2.append([0,0])\nif dic1[0][0]!=dic2[0][0]:\n print(n - dic1[0][1] - dic2[0][1])\nelse:\n print(min(n - dic1[0][1] - dic2[1][1], n -dic1[1][1] - dic2[0][1]))']
['Runtime Error', 'Accepted']
['s079629797', 's905430347']
[25732.0, 25608.0]
[82.0, 84.0]
[347, 378]
p03244
u709304134
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\nimport numpy as np\nimport collections\nN = 1000000\nls = list(map(int,input().split()))\nls.append(N)\nls.append(N)\narray = np.array(ls).reshape(-1,2).T\nc_even = collections.Counter(array[0])\nc_odd = collections.Counter(array[1])\nif len(set(ls))==2:\n print (int((len(ls)-2)/2))\nelif c_even.most_common()[0][0] != c_odd.most_common()[0][0]:\n print (len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[0][1]-2)\nelse:\n print (min(len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[1][1]-2,len(ls)-c_even.most_common()[1][1]-c_odd.most_common()[0][1]-2))\n', '#coding:utf-8\nimport numpy as np\nimport collections\nN = 1000000\n_ = int(input())\nls = list(map(int,input().split()))\nls.append(N)\nls.append(N)\narray = np.array(ls).reshape(-1,2).T\nc_even = collections.Counter(array[0])\nc_odd = collections.Counter(array[1])\nif len(set(ls))==2:\n print (int((len(ls)-2)/2))\nelif c_even.most_common()[0][0] != c_odd.most_common()[0][0]:\n print (len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[0][1]-2)\nelse:\n print (min(len(ls)-c_even.most_common()[0][1]-c_odd.most_common()[1][1]-2,len(ls)-c_even.most_common()[1][1]-c_odd.most_common()[0][1]-2))\n']
['Runtime Error', 'Accepted']
['s874493491', 's669998705']
[21280.0, 33976.0]
[1059.0, 301.0]
[577, 594]
p03244
u713830790
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.
["if __name__ == '__main__': n = int(input())\n vs = list(map(int, input().split()))\n\n even = vs[::2]\n odd = vs[1::2]\n\n from collections import Counter\n\n result = 0\n \n c = Counter(even)\n emode = c.most_common(1)[0][0]\n for i in range(len(even)):\n if even[i] != emode:\n result += 1\n\n c = Counter(odd)\n if c.most_common(1)[0][0] != emode:\n omode = c.most_common(1)[0][0]\n else:\n if len(c.most_common()) == 1:\n omode = -1\n else:\n omode = c.most_common(2)[0][0]\n\n\n for i in range(len(odd)):\n if odd[i] != omode:\n result += 1\nif __name__ == '__main__': n = int(input())\n vs = list(map(int, input().split()))\n\n even = vs[::2]\n odd = vs[1::2]\n\n from collections import Counter\n\n result = 0\n \n c = Counter(even)\n emode = c.most_common(1)[0][0]\n for i in range(len(even)):\n if even[i] != emode:\n result += 1\n\n c = Counter(odd)\n if c.most_common(1)[0][0] != emode:\n omode = c.most_common(1)[0][0]\n else:\n if len(c.most_common()) == 1:\n omode = -1\n else:\n omode = c.most_common(2)[0][0]\n\n\n for i in range(len(odd)):\n if odd[i] != omode:\n result += 1\n print(result) ", "if __name__ == '__main__': n = int(input())\n vs = list(map(int, input().split()))\n\n even = vs[::2]\n odd = vs[1::2]\n\n from collections import Counter\n\n result = 0\n \n ce = Counter(even)\n emode = ce.most_common(1)[0]\n\n oe = Counter(odd)\n omode = oe.most_common(1)[0]\n if emode[0] == omode[0]:\n if emode[1] > omode[1]:\n for i in range(len(even)):\n if even[i] != emode[0]:\n result += 1\n if len(oe.most_common()) == 1:\n omode = -1\n result += len(odd)\n else:\n omode = oe.most_common(2)[0][0]\n for i in range(len(odd)):\n if odd[i] != omode:\n result += 1\n\n else:\n for i in range(len(odd)):\n if odd[i] != omode[0]:\n result += 1\n if len(ce.most_common()) == 1:\n emode = -1\n result += len(even)\n else:\n emode = ce.most_common(2)[0][0]\n for i in range(len(even)):\n if even[i] != emode:\n result += 1\n else:\n for i in range(len(even)):\n if even[i] != emode[0]:\n result += 1\n for i in range(len(odd)):\n if odd[i] != omode[0]:\n result += 1\n\n print(result)", "from collections import Counter\n\nif __name__ == '__main__':\n n = int(input())\n vs = list(map(int, input().split()))\n\n even = vs[::2]\n odd = vs[1::2]\n\n def solve(even, odd):\n ce = Counter(even)\n co = Counter(odd)\n \n emode = ce.most_common()\n omode = co.most_common()\n \n result = 0\n if emode[0][0] != omode[0][0]:\n for i in range(1, len(emode)):\n result += emode[i][1]\n for i in range(1, len(omode)):\n result += omode[i][1]\n \n return result\n \n else:\n temp1 = 0\n temp2 = 0\n for i in range(1, len(emode)):\n temp1 += emode[i][1]\n \n if len(omode) == -1:\n temp1 += len(odd)\n else:\n for i in range(len(omode)):\n if i == 1:\n continue\n else:\n temp1 += omode[i][1]\n \n \n for i in range(1, len(omode)):\n temp2 += omode[i][1]\n \n if len(emode) == -1:\n temp2 += len(even)\n else:\n for i in range(len(emode)):\n if i == 1:\n continue\n else:\n temp2 += emode[i][1]\n result = min(temp1, temp2)\n \n return result\n \n print(solve(even, odd))\n \n "]
['Runtime Error', 'Runtime Error', 'Accepted']
['s145564406', 's521605115', 's860326674']
[2940.0, 2940.0, 21952.0]
[17.0, 17.0, 107.0]
[1612, 1554, 1544]
p03244
u721970149
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(x) for x in input().split()]\n\neven = [v[2*i] for i in range(N//2)]\nodd = [v[2*i+1] for i in range(N//2)]\n\nfrom collections import Counter\ndev = Counter(even)\ndod = Counter(odd)\n\nevmax = sorted(dev, key=dev.get, reverse = True)[0]\nif len(dev) != 1 :\n ev2nd = sorted(dev, key=dev.get, reverse = True)[1]\nodmax = sorted(dod, key=dod.get, reverse = True)[0]\nif len(dod) != 1 :\n od2nd = sorted(dod, key=dod.get, reverse = True)[1]\n\nif evmax != odmax :\n print(N//2 - max(dev[evmax],dod[odmax]))\nelif len(dev) == 1 and len(dod) == 1 :\n print(N//2)\nelif len(dev) == 1 :\n print(N//2 - max(dev[evmax],dod[od2nd]))\nelif len(dod) == 1 :\n print(N//2 - max(dev[ev2nd],dod[odmax]))\nelse :\n print(min(N//2 - max(dev[evmax],dod[od2nd]), N//2 - max(dev[ev2nd],dod[odmax])))\n', 'N = int(input())\nv = [int(x) for x in input().split()]\n\neven = v[::2]\nodd = v[1::2]\n\nfrom collections import Counter\ndev = Counter(even).most_common(2)\ndod = Counter(odd).most_common(2)\n\nif dev[0][0] == dod[0][0] :\n if len(dev) == len(dod) == 1 :\n print(N//2)\n elif len(dev) < len(dod) :\n print(N//2 - dod[1][1])\n elif len(dev) > len(dod) :\n print(N//2 - dev[1][1])\n else :\n print(N - max(dod[1][1] + dev[0][1], dod[0][1] + dev[1][1]))\nelse :\n print(N - dod[0][1]- dev[0][1])\n\n']
['Wrong Answer', 'Accepted']
['s982064122', 's731299254']
[19040.0, 15900.0]
[93.0, 87.0]
[803, 520]
p03244
u724892495
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 = [[], []]\n[a[i%2].append(t) for i, t in enumerate(map(int, input().split()))]\nprint(sum([(lambda x: len(x) -max([x.count(xi) for xi in x]))(ai) for ai in a]))', 'N = int(input())\na = [[],[]]\n[a[i%2].append(t) for i, t in enumerate(map(int, input().split()))]\n\na_cnt = [{},{}]\nfor i in range(2):\n for j in range(len(a[i])):\n if a[i][j] in a_cnt[i]:\n a_cnt[i][a[i][j]] += 1\n else:\n a_cnt[i][a[i][j]] = 1\n\nfor i in range(2):\n # print(list(a_cnt[i].items()))\n a_cnt[i] = list(sorted(list(a_cnt[i].items()),\\\n key=(lambda x:x[1]), reverse=True))[:2]\n\n# print(a_cnt)\nif a_cnt[0][0][0] != a_cnt[1][0][0]:\n print(N -a_cnt[0][0][1] -a_cnt[1][0][1])\nelse:\n if len(a_cnt[0])==1 and len(a_cnt[1])==1:\n print(N//2)\n else:\n ans1 = N -a_cnt[0][0][1] -a_cnt[1][1][1]\n ans2 = N -a_cnt[0][1][1] -a_cnt[1][0][1]\n print(min(ans1, ans2))\n']
['Runtime Error', 'Accepted']
['s041070766', 's730344895']
[3060.0, 19632.0]
[18.0, 123.0]
[161, 744]
p03244
u727787724
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['# coding: utf-8\n# Your code here!\nn=int(input())\nw=list(map(int,input().split()))\nans=0\nif len(set(w))==1:\n print(len(w)//2)\nelif len(set(w))==2:\n w.sort()\n print(abs(w.count(w[0])-w.count(w[len(w)-1])))\nelse:\n cnt=[]\n ans=0\n w.sort()\n t=w[0]\n for j in range(n):\n if w[j]==t:\n ans+=1\n else:\n cnt.append(ans)\n t=w[j]\n ans=1\n if j==n-1:\n cnt.append(ans)\n print(cnt)\n cnt.sort(reverse=True)\n if cnt[0]+cnt[1]>n:\n print(cnt[0]+cnt[1]-n)\n elif cnt[0]+cnt[1]<n:\n if cnt[0]>=n//2:\n print(n//2-cnt[1])\n else:\n print(n-cnt[1]-cnt[0])\n else:\n print(cnt[0]-cnt[1])\n ', '# coding: utf-8\n# Your code here!\nn=int(input())\nw=list(map(int,input().split()))\nans=0\nif len(set(w))==1:\n print(len(w)//2)\nelse:\n a=[]\n a1=[]\n for i in range(n):\n if i%2==0:\n a.append(w[i])\n else:\n a1.append(w[i])\n a.sort()\n a1.sort()\n ans=0\n t=a[0]\n cnt1=[]\n cnt=[]\n b=[]\n b1=[]\n for j in range(len(a)):\n if a[j]==t:\n ans+=1\n else:\n cnt.append([ans,t])\n t=a[j]\n ans=1\n if j==len(a)-1:\n cnt.append([ans,t])\n s=a1[0]\n ans=0\n for j in range(len(a)):\n if a1[j]==s:\n ans+=1\n else:\n cnt1.append([ans,s])\n s=a1[j]\n ans=1\n if j==len(a1)-1:\n cnt1.append([ans,s])\n cnt.sort(reverse=True)\n cnt1.sort(reverse=True)\n """\n print(a)\n print(a1)\n print(cnt)\n print(cnt1)\n """\n if cnt[0][1]!=cnt1[0][1]:\n print(n-cnt[0][0]-cnt1[0][0])\n else:\n if cnt[0][0]>cnt1[0][0]:\n print(n-cnt[0][0]-cnt1[1][0])\n elif cnt[0][0]<cnt1[0][0]:\n print(n-cnt1[0][0]-cnt[1][0])\n else:\n t=0\n s=0\n for i in range(1,min(len(cnt),len(cnt1))):\n if cnt[i][0]!=cnt1[i][0]:\n if cnt[i][0]==max(cnt[i][0],cnt1[i][0]):\n t=cnt[i][0]\n s=cnt1[0][0]\n break\n if cnt[i][0]!=cnt1[i][0]:\n if cnt1[i][0]==max(cnt[i][0],cnt1[i][0]):\n t=cnt1[i][0]\n s=cnt[0][0]\n break\n if i==-1+min(len(cnt),len(cnt1)):\n t=cnt[0][0]\n s=cnt1[1][0]\n print(n-t-s)']
['Wrong Answer', 'Accepted']
['s980430867', 's777110767']
[15736.0, 18012.0]
[125.0, 219.0]
[723, 1805]
p03244
u731368968
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\nvv = [[], []]\nfor i in range(n):\n vv[i % 2].append(v[i])\n\nimport collections\nitems0 = sorted(collections.Counter(vv[0]).items(), key=lambda x: -x[1])\nitems1 = sorted(collections.Counter(vv[1]).items(), key=lambda x: -x[1])\nkey0 = [x[0] for x in items0]\nkey1 = [x[0] for x in items1]\nval0 = [x[1] for x in items0]\nval1 = [x[1] for x in items1]\n\nif key0[0] = ! key1[0]:\n if len(items0) == 1:\n print(n//2)\n else:\n print(min(n - val0[0] - val1[1], min(n - val0[1] - val1[0])))\nelse key0[0] != key1[0]:\n print(n - val0[0] - val1[0])\n', 'n = int(input())\nv = list(map(int, input().split()))\n\nvv = [[], []]\nfor i in range(n):\n vv[i % 2].append(v[i])\n\nimport collections\nitems0 = sorted(collections.Counter(vv[0]).items(), key=lambda x: -x[1])\nitems1 = sorted(collections.Counter(vv[1]).items(), key=lambda x: -x[1])\nkey0 = [x[0] for x in items0]\nkey1 = [x[0] for x in items1]\nval0 = [x[1] for x in items0]\nval1 = [x[1] for x in items1]\n\nans = n - val0[0] - val1[0]\n\nif key0[0] == key1[0]:\n tmp0=tmp1=1000000000000000\n if len(items0) > 1:\n tmp0 = n - val0[1] - val1[0]\n if len(items1) > 1:\n tmp1 = n - val0[0] - val1[1]\n ans = min(tmp0, tmp1)\n if len(items0) == 1 and len(items1) == 1:\n ans=n//2\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s887635554', 's130572026']
[3064.0, 21212.0]
[17.0, 125.0]
[608, 706]
p03244
u732870425
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['n = int(input())\nv = list(map(int, input().split()))\n\neven = {}\nodd = {}\n\nfor i in range(n):\n if i % 2 == 0:\n if v[i] not in even:\n even[v[i]] = 0\n even[v[i]] += 1\n else:\n if v[i] not in odd:\n odd[v[i]] = 0\n odd[v[i]] += 1\n\neven_sorted = sorted(even.items(), key=lambda x:x[i])[::-1]\nodd_sorted = sorted(odd.items(), key=lambda x:x[i])[::-1]\n\nans = 0\nif even_sorted[0][0] != odd_sorted[0][0]:\n ans += n - even_sorted[0][1] - odd_sorted[0][1]\nelse:\n x = n - even_sorted[0][1] - odd_sorted[1][1]\n y = n - even_sorted[1][1] - odd_sorted[0][1]\n ans += min(x, y)\n\nprint(ans)', 'n = int(input())\nv = list(map(int, input().split()))\n\neven = {}\nodd = {}\n\nfor i in range(n):\n if i % 2 == 0:\n if v[i] not in even:\n even[v[i]] = 0\n even[v[i]] += 1\n else:\n if v[i] not in odd:\n odd[v[i]] = 0\n odd[v[i]] += 1\n\neven_sorted = sorted(even.items(), key=lambda x:x[1])[::-1]\nodd_sorted = sorted(odd.items(), key=lambda x:x[1])[::-1]\n\nans = 0\nif even_sorted[0][0] != odd_sorted[0][0]:\n ans += n - even_sorted[0][1] - odd_sorted[0][1]\nelse:\n if len(even_sorted) == 1 or len(odd_sorted) == 1:\n even_sorted.append((-1, 0))\n odd_sorted.append((-1, 0))\n x = n - even_sorted[0][1] - odd_sorted[1][1]\n y = n - even_sorted[1][1] - odd_sorted[0][1]\n ans += min(x, y)\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s481705609', 's009771499']
[17404.0, 20896.0]
[98.0, 123.0]
[637, 762]
p03244
u734548018
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\nimport math\nimport sys\nimport heapq\nfrom operator import itemgetter\nimport itertools\ninput = sys.stdin.readline\n\n# a = int(input().rstrip())\n# a, b = map(int, input().rstrip().split())\n# D = list(map(int, input().rstrip().split()))\n# H = [int(input().rstrip()) for _ in range(L)]\n# DD = [[0 for j in range(100)] for i in range(200)]\n\n\n# a = sorted(a, key=lambda x: x[1]))\n# if __name__ == '__main__':\n\nn = int(input().rstrip())\nv = list(map(int, input().rstrip().split()))\nv_even = dict()\nv_odd = dict()\n\ndef solve(d1, d2):\n\td1_max = [[0, 0], [0, 0]]\n\td2_max = [[0, 0], [0, 0]]\n\tfor i in d1:\n\t\tif d1_max[0][1] <= d1[i]:\n\t\t\td1_max[1] = d1_max[0]\n\t\t\td1_max[0] = [i, d1[i]]\n\tfor i in d2:\n\t\tif d2_max[0][1] <= d2[i]:\n\t\t\td2_max[1] = d2_max[0]\n\t\t\td2_max[0] = [i, d2[i]]\n\n\tprint(d1_max)\n\tprint(d2_max)\n\n\tif d1_max[0][0] != d2_max[0][0]:\n\t\treturn(n - d1_max[0][1]- d2_max[0][1])\n\telse:\n\t\treturn(min(n - d1_max[1][1]- d2_max[0][1], n - d1_max[0][1]- d2_max[1][1]))\n\nfor i in range(len(v)):\n\tif i % 2 == 0:\n\t\tif v[i] not in v_even:\n\t\t\tv_even[v[i]] = 1\n\t\telse:\n\t\t\tv_even[v[i]] += 1\n\telse:\n\t\tif v[i] not in v_odd:\n\t\t\tv_odd[v[i]] = 1\n\t\telse:\n\t\t\tv_odd[v[i]] += 1\n\t\nprint(solve(v_even, v_odd))\n", '# /user/bin/python\n# -*- coding: utf-8 -*-\nfrom collections import Counter\nimport sys\n\nn = int(sys.stdin.readline().rstrip())\nv_s = list(map(int, sys.stdin.readline().rstrip().split()))\n\nv_even = Counter(v_s[0::2]).most_common()\nv_even.append((0,0))\nv_odd = Counter(v_s[1::2]).most_common()\nv_odd.append((0,0))\n\nif v_even[0][0] != v_odd[0][0]:\n print(n-v_even[0][1]-v_odd[0][1])\nelse:\n print(min(n-v_even[0][1]-v_odd[1][1], n-v_odd[0][1]-v_even[1][1]))\n']
['Wrong Answer', 'Accepted']
['s961688867', 's763892352']
[16928.0, 20700.0]
[112.0, 85.0]
[1229, 455]
p03244
u736729525
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['#! /usr/bin/python3\nfrom collections import Counter\nimport sys\n\ndef debug(*f):\n print(*f, file=sys.stderr)\n\ndef f(odd, even, N):\n debug(N, odd, even)\n\n\ndef main(N, V):\n debug("N=",N)\n debug("V=",V)\n N = int(N)\n V = [int(x) for x in V.split(" ")]\n\n odd = Counter(V[0::2]).most_common()\n even = Counter(V[1::2]).most_common()\n\n if odd[0][0] != even[0][0]: \n return N - odd[0][1] - even[0][1]\n else:\n if odd[0][1] > even[0][1]:\n return N - odd[0][1] - even[1][1]\n elif odd[0][1] < even[0][1]:\n return N - odd[1][1] - even[0][1]\n elif odd[0][1] == N // 2:\n return N // 2\n else:\n return N - odd[0][1] - max(odd[1][1], even[1][1])\n\n\n\nif 0==1:\n import sys\n assert main("4", "3 1 3 2") == 1\n assert main("4", "1 1 1 1") == 2\n assert main("6", "105 119 105 119 105 119") == 0\n assert main("14", "1 1 1 1 1 1 2 2 2 2 3 4 3 5") == 9\n\n print("OK", file=sys.stderr)\n\n\nN = input()\nV = input()\nmain(N, V)\n', '#! /usr/bin/python3\nfrom collections import Counter\n\n\ndef main(N, V):\n N = int(N)\n V = [int(x) for x in V.split(" ")]\n\n odd = Counter(V[0::2]).most_common()\n even = Counter(V[1::2]).most_common()\n\n if odd[0][0] != even[0][0]: \n return N - odd[0][1] - even[0][1]\n else: \n if odd[0][1] == N // 2:\n r = N // 2\n print(r)\n return r\n if odd[0][1] > even[0][1]:\n r = N - odd[0][1] - even[1][1]\n print(r)\n return r\n else:\n r = N - odd[1][1] - even[0][1]\n print(r)\n return r\n\n\nif 0==1:\n assert main("4", "3 1 3 2") == 1\n assert main("4", "1 1 1 1") == 2\n assert main("6", "105 119 105 119 105 119") == 0\n\n\nN = input()\nV = input()\nmain(N, V)\n', '#! /usr/bin/python3\nfrom collections import Counter\nimport sys\n\ndef debug(*f):\n print(*f, file=sys.stderr)\n\ndef f(odd, even, N):\n debug(N, odd, even)\n\n\ndef main(N, V):\n debug("N=",N)\n debug("V=",V)\n N = int(N)\n V = [int(x) for x in V.split(" ")]\n\n odd = Counter(V[0::2]).most_common()\n even = Counter(V[1::2]).most_common()\n\n if odd[0][0] != even[0][0]: \n return N - odd[0][1] - even[0][1]\n else:\n if odd[0][1] > even[0][1]:\n return N - odd[0][1] - even[1][1]\n elif odd[0][1] < even[0][1]:\n return N - odd[1][1] - even[0][1]\n elif odd[0][1] == N // 2:\n return N // 2\n else:\n return N - odd[0][1] - max(odd[1][1], even[1][1])\n\n\n\nif 0==1:\n import sys\n assert main("4", "3 1 3 2") == 1\n assert main("4", "1 1 1 1") == 2\n assert main("6", "105 119 105 119 105 119") == 0\n assert main("14", "1 1 1 1 1 1 2 2 2 2 3 4 3 5") == 9\n\n print("OK", file=sys.stderr)\n\n\nN = input()\nV = input()\nprint(main(N, V))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s078758707', 's852442813', 's651556061']
[21272.0, 21276.0, 21272.0]
[88.0, 86.0, 89.0]
[1035, 817, 1042]
p03244
u740284863
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 itertools import accumulate\nfrom collections import Counter\n\nN = int(input())\nv = list(map(int,input().split()))\nd = Counter(v).most_common()\nmost_common = d[0][0]\ntry:\n second_common = d[1][0]\nexcept:\n print(N//2)\n exit()\ntry:\n third_common = d[2][0]\nexcept:\n third_common = float('Inf')\n\ndef f(v,m,s):\n cnt = 0\n for j in range(N):\n if j % 2 != 0:\n if v[j] != m:\n cnt += 1\n else:\n if v[j] != s:\n cnt += 1\n return cnt\n\np = [most_common,second_common,third_common]\np = list(product(p,p))\np = [i for i in p if i[0] != i[1]]\nans = float('inf')\nfor i in p:\n tmp = f(v,i[0],i[1])\n ans = min(ans,tmp)\nprint(ans)\n", 'from collections import Counter\nn = int(input())\nv = list(map(int,input().split()))\no = Counter(v[::2]).most_common()\no.append((0,0))\ne = Counter(v[1::2]).most_common()\ne.append((0,0))\nif o[0][0] == e[0][0]:\n ans = min(n - o[0][1] - e[1][1], n - o[1][1] - e[0][1])\nelse:\n ans = n - o[0][1] - e[0][1]\nprint(ans)']
['Runtime Error', 'Accepted']
['s347530703', 's875014234']
[21364.0, 20572.0]
[79.0, 85.0]
[707, 316]
p03244
u745561510
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['n = int(input())\nv = list(map(int, input().split()))\n\nodd = {}\neven = {}\n\nfor i in range(len(v)):\n if i % 2 == 1:\n if v[i] in odd:\n odd[v[i]] += 1\n else:\n odd[v[i]] = 1\n else:\n if v[i] in even:\n even[v[i]] += 1\n else:\n even[v[i]] = 1\n\n\nodd_sorted = sorted(odd.items(), key = lambda x : -x[1])\neven_sorted = sorted(even.items(), key = lambda x : -x[1])\n\n\n\n\n\nif odd_sorted[0][0] == even_sorted[0][0]:\n \n if len(odd.keys()) > 1 and len(even.keys()) > 1:\n \n if odd_sorted[0][1] > even_sorted[0][1]:\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[1][0]\n elif odd_sorted[0][1] < even_sorted[0][1]:\n ans_odd = odd_sorted[1][0]\n ans_even = even_sorted[0][0]\n else:\n \n if odd_sorted[1][1] >= even_sorted[1][1]:\n ans_odd = odd_sorted[1][0]\n ans_even = even_sorted[0][0]\n elif odd_sorted[1][1] < even_sorted[1][1]:\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[1][0]\n\n \n elif len(odd.keys()) == 1 and len(even.keys()) == 1:\n ans_odd = -1\n ans_even = even_sorted[0][0]\n \n elif len(odd.keys()):\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[1][0]\n \n else: \n ans_odd = odd_sorted[1][0]\n ans_even = even_sorted[0][0]\n\nelse:\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[0][0]\n\nans = 0\nfor i in range(len(v)):\n if i % 2:\n if v[i] != ans_odd:\n ans += 1\n else:\n if v[i] != ans_even:\n ans += 1\n\n\nprint(odd_sorted)\nprint(even_sorted)\n\nprint(ans_odd, ans_even)\nprint(ans)', 'n = int(input())\nv = list(map(int, input().split()))\n\nodd = {}\neven = {}\n\nfor i in range(len(v)):\n if i % 2 == 1:\n if v[i] in odd:\n odd[v[i]] += 1\n else:\n odd[v[i]] = 1\n else:\n if v[i] in even:\n even[v[i]] += 1\n else:\n even[v[i]] = 1\n\n\nodd_sorted = sorted(odd.items(), reversed = True, key = lambda x : x[1])\neven_sorted = sorted(even.items(), reversed = True, key = lambda x : x[1])\n\n\n\n\n\nif odd_sorted[0][0] == even_sorted[0][0]:\n \n if len(odd.keys()) > 1 and len(even.keys()) > 1:\n \n if odd_sorted[0][1] >= even_sorted[0][1]:\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[1][0]\n else:\n ans_odd = odd_sorted[1][0]\n ans_even = even_sorted[0][0]\n \n elif len(odd.keys()) == 1 and len(even.keys()) == 1:\n ans_odd = -1\n ans_even = even_sorted[0][0]\n \n elif len(odd.keys()):\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[1][0]\n \n else: \n ans_odd = odd_sorted[1][0]\n ans_even = even_sorted[0][0]\n\nelse:\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[0][0]\n\nans = 0\nfor i in range(len(v)):\n if i % 2:\n if v[i] != ans_odd:\n ans += 1\n else:\n if v[i] != ans_even:\n ans += 1\n\n\nprint(ans)', 'n = int(input())\nv = list(map(int, input().split()))\n\nodd = {}\neven = {}\n\nfor i in range(len(v)):\n if i % 2 == 1:\n if v[i] in odd:\n odd[v[i]] += 1\n else:\n odd[v[i]] = 1\n else:\n if v[i] in even:\n even[v[i]] += 1\n else:\n even[v[i]] = 1\n\n\nodd_sorted = sorted(odd.items(), key = lambda x : -x[1])\neven_sorted = sorted(even.items(), key = lambda x : -x[1])\n\n\n\n\n\nif odd_sorted[0][0] == even_sorted[0][0]:\n \n if len(odd.keys()) > 1 and len(even.keys()) > 1:\n \n if odd_sorted[0][1] > even_sorted[0][1]:\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[1][0]\n elif odd_sorted[0][1] < even_sorted[0][1]:\n ans_odd = odd_sorted[1][0]\n ans_even = even_sorted[0][0]\n else:\n \n if odd_sorted[1][1] >= even_sorted[1][1]:\n ans_odd = odd_sorted[1][0]\n ans_even = even_sorted[0][0]\n elif odd_sorted[1][1] < even_sorted[1][1]:\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[1][0]\n\n \n elif len(odd.keys()) == 1 and len(even.keys()) == 1:\n ans_odd = -1\n ans_even = even_sorted[0][0]\n \n elif len(odd.keys()):\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[1][0]\n \n else: \n ans_odd = odd_sorted[1][0]\n ans_even = even_sorted[0][0]\n\nelse:\n ans_odd = odd_sorted[0][0]\n ans_even = even_sorted[0][0]\n\nans = 0\nfor i in range(len(v)):\n if i % 2:\n if v[i] != ans_odd:\n ans += 1\n else:\n if v[i] != ans_even:\n ans += 1\n\n\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s180590153', 's423478487', 's160260003']
[23324.0, 17760.0, 20720.0]
[162.0, 83.0, 134.0]
[2081, 1673, 2018]
p03244
u757030836
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['from collections import Counter\nn = int(input())\nv = list(map(int,input().split()))\na = Counter(v[0::2]).most_common()\nb = Counter(v[1::2]).most_common()\na.append([0,0])\nb.append([0,0])\n\nif a[0][0] != b[0][0]:\n print(n-(a[0][1]+b[0][1]))\nelse:\n print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1]))\n ', '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])\n\nif a[0][0] != b[0][0]:\n print(n-(a[0][1]+b[0][1]))\nelse:\n print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))\n \n\n \n ']
['Runtime Error', 'Accepted']
['s265748019', 's599558165']
[3064.0, 20572.0]
[17.0, 85.0]
[307, 318]
p03244
u757274384
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['from collections import Counter\nn = int(input())\nV = list(map(int,input().split()))\nA = Counter(V[0::2]).most_common(2)\nA = Counter(V[1::2]).most_common(2)\nA.append((0,0))\nA.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])))\n', 'from collections import Counter\nn = int(input())\nV = list(map(int,input().split()))\nA = Counter(V[0::2]).most_common(2)\nB = Counter(V[1::2]).most_common(2)\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])))\n']
['Runtime Error', 'Accepted']
['s442191470', 's397981966']
[15588.0, 15588.0]
[75.0, 74.0]
[302, 302]
p03244
u760794812
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['n = int(input())\nS = list(input())\nS0 = {}\nS1 = {}\nfor i, item in enumerate(S):\n if i%2 == 0:\n if item not in S0:\n S0[item] =1\n else:\n S0[item] += 1\n else:\n if item not in S1:\n S1[item] =1\n else:\n S1[item] += 1\n\nS0list = list(S0.values()).sort(reverse=True)\nS1list = list(S1.values()).sort(reverse=True)\n\nS00 = S0list[0]\nif len(S0list) == 1:\n S01 = 0\nelse:\n S01 = S0list[1]\nS10 = S1list[0]\nif len(S1list) == 1:\n S11 = 0\nelse:\n S11 = S1list[1]\nAnswer = min(len(S) - S00 - S11,len(S) - S01 - S10)\n\nprint(Answer)', 'n = int(input())\nS = [int(x) for x in input().split()]\n\nS0 = {}\nS1 = {}\nfor i in range(len(S)):\n if i%2 == 0:\n if S[i] not in S0:\n S0[S[i]] =1\n else:\n S0[S[i]] += 1\n else:\n if S[i] not in S1:\n S1[S[i]] =1\n else:\n S1[S[i]] += 1\n\nif max(S0, key = S0.get) != max(S1, key = S1.get):\n Answer = len(S) - max(S0.values()) -max(S1.values())\n print(Answer)\n exit()\n \nS0list = sorted(list(S0.values()),reverse = True)\nS1list = sorted(list(S1.values()),reverse = True)\n\nS00 = S0list[0]\n\nif len(S0list) == 1:\n S01 = 0\nelse:\n S01 = S0list[1]\nS10 = S1list[0]\nif len(S1list) == 1:\n S11 = 0\nelse:\n S11 = S1list[1]\nAnswer = min(len(S) - S00 - S11,len(S) - S01 - S10)\n\nprint(Answer)']
['Runtime Error', 'Accepted']
['s918941406', 's995630646']
[8880.0, 17632.0]
[211.0, 101.0]
[547, 710]
p03244
u763534217
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 copy\n\nn = int(input())\nv = list(map(int, input().split()))\n# print(v)\n\nla = [0 for i in range(5+10**5)]\nlb = [0 for i in range(5+10**5)]\n\nfor i in range(0, n, 2):\n la[v[i]] += 1\nfor i in range(1, n, 2):\n lb[v[i]] += 1\n\n# print(sum(la))\n# print(sum(lb))\n# print(max(la))\n# print(max(lb))\n# print(la.index(max(la)))\n# print(lb.index(max(lb)))\n\nsla = sum(la)\nslb = sum(lb)\nmaxla = max(la)\nmaxlb = max(lb)\nargmaxla = la.index(max(la))\nargmaxlb = lb.index(max(lb))\n\nif argmaxla != argmaxlb:\n if maxla != maxlb:\n print(0)\n else:\n print(sla-maxla+slb-maxlb)\nelse:\n \n _la = copy.deepcopy(la)\n _la[argmaxla] = 0\n _maxla = max(_la)\n aa = sla-_maxla+slb-maxlb\n \n _lb = copy.deepcopy(lb)\n _lb[argmaxlb] = 0\n _maxlb = max(_lb)\n bb = sla-maxla+slb-_maxlb\n if bb>aa:\n print(aa)\n else:\n print(bb)\n', 'import copy\n\nn = int(input())\nv = list(map(int, input().split()))\n# print(v)\n\nla = [0 for i in range(5+10**5)]\nlb = [0 for i in range(5+10**5)]\n\nfor i in range(0, n, 2):\n la[v[i]] += 1\nfor i in range(1, n, 2):\n lb[v[i]] += 1\n\n# print(sum(la))\n# print(sum(lb))\n# print(max(la))\n# print(max(lb))\n# print(la.index(max(la)))\n# print(lb.index(max(lb)))\n\nsla = sum(la)\nslb = sum(lb)\nmaxla = max(la)\nmaxlb = max(lb)\nargmaxla = la.index(max(la))\nargmaxlb = lb.index(max(lb))\n\nif argmaxla != argmaxlb:\n if sla-maxla == 0 and slb-maxlb == 0:\n print(0)\n else:\n print(sla-maxla+slb-maxlb)\nelse:\n \n _la = copy.deepcopy(la)\n _la[argmaxla] = 0\n _maxla = max(_la)\n aa = sla-_maxla+slb-maxlb\n \n _lb = copy.deepcopy(lb)\n _lb[argmaxlb] = 0\n _maxlb = max(_lb)\n bb = sla-maxla+slb-_maxlb\n if bb > aa:\n print(aa)\n else:\n print(bb)\n']
['Wrong Answer', 'Accepted']
['s040619332', 's952476820']
[21284.0, 21228.0]
[148.0, 154.0]
[940, 961]
p03244
u779455925
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['import collections\nN=int(input())\nV=list(map(int,input().split()))\na=[V[i] for i in range(N) if i%2==0]\nb=[V[i] for i in range(N) if i%2==1]\n\na=collections.Counter(a)\nb=collections.Counter(b)\na=a.most_common()\nb=b.most_common()\nprint(a)\nprint(b)\nif len(a)==len(b)==1:\n if a[0][0]==b[0][0]:\n print(int(N/2))\n else:\n print(0)\nelif len(a)==1 and len(b)>=2:\n print(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1])\nelif len(a)>=2 and len(b)==1:\n print(N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1])\nelif len(a)>=2 and len(a)>=2:\n print(min(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1],N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1]))\n', 'import collections\nN=int(input())\nV=list(map(int,input().split()))\na=[V[i] for i in range(N) if i%2==0]\nb=[V[i] for i in range(N) if i%2==1]\n\na=collections.Counter(a)\nb=collections.Counter(b)\na=a.most_common()\nb=b.most_common()\nif len(a)==len(b)==1:\n if a[0][0]==b[0][0]:\n print(int(N/2))\n else:\n print(0)\nelif len(a)==1 and len(b)>=2:\n print(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1])\nelif len(a)>=2 and len(b)==1:\n print(N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1])\nelif len(a)>=2 and len(a)>=2:\n print(min(N-(b[0][1] if a[0][0]!=b[0][0] else b[1][1])-a[0][1],N-(a[0][1] if a[0][0]!=b[0][0] else a[1][1])-b[0][1]))\n']
['Wrong Answer', 'Accepted']
['s389596439', 's574030317']
[18784.0, 18784.0]
[142.0, 108.0]
[684, 666]
p03244
u780962115
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\nseq=list(map(int,input().split()))\noddlist=[]\nevenlist=[]\n\nfor i in range(n):\n if ( i+1)%2!=0:\n \n oddlist.append(seq[i])\n else: \n evenlist.append(seq[i])\nprint(seq)\nprint(oddlist)\nprint(evenlist)\nmaxi=n/2\nmini=n/2\nif oddlist!=evenlist:\n for j in set(evenlist):\n if evenlist.count(j)==int(n/2):\n maxi=0\n else:\n if evenlist.count(j)<maxi:\n maxi=evenlist.count(j)\n else:\n maxi=maxi\n\n for k in set(oddlist):\n if oddlist.count(k)==int(n/2):\n mini=0\n else:\n \n if oddlist.count(k)<mini:\n mini=oddlist.count(k)\n else:\n mini=mini\n \n print(maxi+mini) \nelse:\n print(2)\n', '\nfrom collections import Counter as ct\n\nn = int(input())\na = [int(i) for i in input().split()]\noddlists=[a[i] for i in range(n)if i%2==0]\nevenlists=[a[i]for i in range(n) if i%2!=0]\n\na1=ct(oddlists).most_common()\na2=ct(evenlists).most_common()\n\n\nmin1=a1[0][1]\nmin2=a2[0][1]\nif a1[0][0]!=a2[0][0]:\n print(n-min1-min2)\nif a1[0][0]==a2[0][0]:\n if a1[0][1]==int(n/2):\n print(int(n/2))\n elif a1[0][1]<int(n/2):\n print(min(n-a1[0][1]-a2[1][1],n-a2[0][1]-a1[1][1]))']
['Wrong Answer', 'Accepted']
['s717431095', 's625219520']
[14908.0, 21084.0]
[2104.0, 110.0]
[779, 481]
p03244
u782930273
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.
['input()\nV = [int(v) for v in input().split()]\ncount = 0\nc1 = Counter(V[::2] + [0]).most_common()[0][0]\nfor v in V[::2]:\n if v != c1:\n count += 1\nc2 = Counter(V[1::2] + [0]).most_common()\nc2 = c2[0][0] if c1 != c2[0][0] else c2[1][0]\nfor v in V[1::2]:\n if v != c2:\n count += 1\nprint(count)', 'from collections import Counter\n\ninput()\nV = [int(v) for v in input().split()]\ncount1 = 0\ncount2 = 0\nc11 = Counter(V[::2]).most_common()[0][0]\nc12 = Counter(V[1::2]).most_common()[0][0]\nfor v1, v2 in zip(V[::2], V[1::2]):\n if v1 != c11:\n count1 += 1\n if v2 != c12:\n count2 += 1\nc21 = Counter(V[1::2]).most_common()\nc22 = Counter(V[::2]).most_common()\nc21.append((0, 1))\nc22.append((0, 1))\nc21 = c21[0][0] if c21[0][0] != c11 else c21[1][0]\nc22 = c22[0][0] if c22[0][0] != c12 else c22[1][0]\nfor v1, v2 in zip(V[1::2], V[::2]):\n if v1 != c21:\n count1 += 1\n if v2 != c22:\n count2 += 1\nprint(min(count1, count2))']
['Runtime Error', 'Accepted']
['s604598664', 's315800826']
[14396.0, 20636.0]
[45.0, 157.0]
[308, 649]
p03244
u785578220
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 = int(input())\nx = list(map(int, input().split()))\ny=[]\nz=[]\nfrom collections import Counter\nfor i in range(a):\n if i%2==0:\n y.append(x[i])\n else:\n z.append(x[i])\ny.append(0)\nz.append(0)\nc= Counter(y)\nd = Counter(z)\nc1=c.most_common()[0][1]\nif c.most_common()[1][0]==0:c2=0\nelse:c2=c.most_common()[1][1]\nd1=d.most_common()[0][1]\nif d.most_common()[1][0]==0:d2=0\nelse:d2=d.most_common()[1][1]\nprint(c1,c2,d1,d2)\nif c.most_common()[0][0]== d.most_common()[0][0]:\n s = a-max(c1+d2,c2+d1)\n print(a,c1+d2,c2+d1)\n print(c)\n print(d)\n\nelse:s= a - c.most_common()[0][1] - d.most_common()[0][1]\nprint(s)', 'a = int(input())\nx = list(map(int, input().split()))\ny=[]\nz=[]\nfrom collections import Counter\nfor i in range(a):\n if i%2==0:\n y.append(x[i])\n else:\n z.append(x[i])\ny.append(0)\nz.append(0)\nc= Counter(y)\nd = Counter(z)\nc1=c.most_common()[0][1]\nif c.most_common()[1][0]==0:c2=0\nelse:c2=c.most_common()[1][1]\nd1=d.most_common()[0][1]\nif d.most_common()[1][0]==0:d2=0\nelse:d2=d.most_common()[1][1]\n#print(c1,c2,d1,d2)\nif c.most_common()[0][0]== d.most_common()[0][0]:\n s = a-max(c1+d2,c2+d1)\n #print(a,c1+d2,c2+d1)\n #print(c)\n #print(d)\n\nelse:s= a - c.most_common()[0][1] - d.most_common()[0][1]\nprint(s)']
['Wrong Answer', 'Accepted']
['s818104757', 's085295543']
[24156.0, 20852.0]
[231.0, 163.0]
[628, 632]
p03244
u790877102
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()))\n\ns = []\nt = []\n\n\nimport collections\n\nfor i in range(0,n//2,2):\n\ts.append(v[i])\nfor i in range(1,n//2,2):\n\tt.append(v[i])\n\nS = collections.Counter(s)\n\t\nT = collections.Counter(t)\n\nx = S.most_common()[0][0] \n\nz = T.most_common()[0][0]\n\nprint(n-s.count(x)-t.count(z))\n', 'n = int(input())\n\nv = list(map(int,input().split()))\n\ns = []\nt = []\n\n\nimport collections\n\nfor i in range(0,n,2):\n\ts.append(v[i])\nfor i in range(1,n,2):\n\tt.append(v[i])\n\nS = Counter(s)\n\t\nT = Counter(t)\n\nx = S.most_common()[0][0] \n\ny = S.most_common()[1][0] \n\nz = T.most_common()[0][0]\u3000\n\nw = T.most_common()[1][0]\n\nif x!=z:\n\tprint(n-S.most_common()[0][1]-T.most_common()[0][1])\nelif y>w:\n\tprint(n-S.most_common()[0][1]-S.most_common()[1][1])\nelse:\n\tprint(n-S.most_common()[0][1]-T.most_common()[1][1])\n', 'n = int(input())\n\nv = list(map(int,input().split()))\n\ns = []\nt = []\n\n\nimport collections\n\nfor i in range(0,n//2,2):\n\ts.append(v[i])\nfor i in range(1,n//2,2):\n\tt.append(v[i])\n\nS = Counter(s)\n\t\nT = Counter(t)\n\nx = S.most_common()[0][0] \n\ny = S.most_common()[1][0] \n\nz = T.most_common()[0][0]\u3000\n\nw = T.most_common()[1][0]\n\nif x!=z:\n\tprint(n-S.most_common()[0][1]-T.most_common()[0][1])\nelif y>w:\n\tprint(n-S.most_common()[0][1]-S.most_common()[1][1])\nelse:\n\tprint(n-S.most_common()[0][1]-T.most_common()[1][1])\n', 'import collections\n\nn = int(input())\nv = list(map(int,input().split()))\na = [v[i] for i in range(n) if i%2==0]\nb = [v[i] for i in range(n) if i%2==1]\n\na = collections.Counter(a)\nb = collections.Counter(b)\n\nA = a.most_common()[:2]\nA.append(("x",0))\nB = b.most_common()[:2]\nB.append(("x",0))\nif A[0][0]==B[0][0]:\n print(n-max(A[0][1]+B[1][1],A[1][1]+B[0][1]))\nelse:\n print(n-A[0][1]-B[0][1])\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s628521031', 's642324885', 's894220224', 's222254634']
[14396.0, 3064.0, 3064.0, 18784.0]
[70.0, 18.0, 17.0, 105.0]
[319, 545, 551, 396]
p03244
u790905630
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['def rewrite_count(vi_list):\n if len(set(vi_list)) != 1:\n vi_count_list = [(i, vi_list.count(i)) for i in set(vi_list)]\n vi_count_list = sorted(vi_count_list, key=lambda x: x[1])\n return vi_count_list[-1][0], len(vi_list) - vi_count_list[-1][1], len(vi_list) - vi_count_list[-2][1]\n else:\n return vi_list[0], 0, 0\n\nN = int(input())\nv_list = input().split()\n\nif len(set(v_list)) == 1:\n print(len(v_list) // 2)\n exit()\n\nv1_list = []\nv2_list = []\n\nfor i in range(len(v_list)):\n if i%2 == 0:\n v1_list.append(i)\n else:\n v2_list.append(i)\nmax_v1, max_value_v1, second_value_v1 = rewrite_count(v1_list)\nmax_v2, max_value_v2, second_value_v2 = rewrite_count(v2_list)\n\nif max_v1 != max_v2:\n ans = max_value_v1 + max_value_v2\nelif max_value_v1 > max_value_v2:\n ans = max_value_v2 + second_value_v1\nelse:\n ans = max_value_v1 + second_value_v2\nprint(ans)', 'from collections import *\n\nN = input()\nv_list = input().split()\n\nif len(set(v_list)) == 1:\n print(len(v_list) // 2)\n exit()\n\nv1_count_list = Counter(v_list[::2]).most_common(2)\nv2_count_list = Counter(v_list[1::2]).most_common(2)\n\nif v1_count_list[0][0] != v2_count_list[0][0]:\n leave_value = v1_count_list[0][1] + v2_count_list[0][1]\nelse:\n leave_value = max(v1_count_list[1][1] + v2_count_list[0][1], v1_count_list[0][1] + v2_count_list[1][1])\nprint(len(v_list) - leave_value)']
['Wrong Answer', 'Accepted']
['s359014599', 's371569413']
[16872.0, 16884.0]
[2104.0, 70.0]
[910, 490]
p03244
u798818115
2,000
1,048,576
A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: * For each i = 1,2,..., n-2, a_i = a_{i+2}. * Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
['# coding: utf-8\n# Your code here!\n\nimport collections\n\nn=int(input())\nli=list(map(int,input().split()))\nl=[]\nr=[]\n\nfor i in range(n):\n if i%2==0:\n l.append(li[i])\n else:\n r.append(li[i])\n\nl_cnt=collections.Counter(l)\nr_cnt=collections.Counter(r)\n\n\nll=l_cnt.most_common(2)\nrr=r_cnt.most_common(2)\n\nif ll[0][0]==rr[0][0]:\n print()\n\nprint(ll,rr)\n\n\n', '# coding: utf-8\n# Your code here!\n# coding: utf-8\n# Your code here!\n\nimport collections\n\nn=int(input())\nli=list(map(int,input().split()))\nl=[]\nr=[]\n\nfor i in range(n):\n if i%2==0:\n l.append(li[i])\n else:\n r.append(li[i])\n\nl_cnt=collections.Counter(l)\nr_cnt=collections.Counter(r)\n\n\nll=l_cnt.most_common(2)\nrr=r_cnt.most_common(2)\n\n\nif ll[0][0]==rr[0][0]:\n if len(ll)==1 and len(rr)==1:\n print(n//2)\n elif len(ll)==1:\n print(n//2-rr[-1][1])\n elif len(rr)==1:\n print(n//2-ll[-1][1])\n else:\n print((n-max(ll[0][1]+rr[1][1],ll[1][1]+rr[0][1])))\nelse:\n print(n-ll[0][1]-rr[0][1])\n\n\n\n']
['Wrong Answer', 'Accepted']
['s146481989', 's147244777']
[19040.0, 19040.0]
[97.0, 194.0]
[381, 669]
p03244
u801807320
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())\nn2 = n/2\nv = [int(i) for i in input().split()]\nv1 = []\nv2 = []\nfor i in range(n):\n if(i % 2 == 0):\n v1.append(v[i])\n else:\n v2.append(v[i])\ncount1 = [v1.count(v1[i]) for i in range(int(n2))]\ncount2 = [v2.count(v2[i]) for i in range(int(n2))]\nif(v1[count1.index(max(count1))] == v2[count2.index(max(count2))]):\n max1 = max(count1)\n max2 = max(count2)\n count1 = list(set(count1))\n count1.remove(max(count1))\n count2 = list(set(count2))\n count2.remove(max(count2))\n if(max(count1) > max(count2)):\n print(n - max(count1) - max2)\n else:\n print(n - max(count2) - max1)\nelse:\n print(n - max1 - max2)\n', 'from collections import Counter\n\nn = int(input())\nif(n == 2):\n print(0)\nelse:\n v = [int(i) for i in input().split()]\n v1 = Counter(v[::2])\n v2 = Counter(v[1::2])\n v1mc = v1.most_common()\n v2mc = v2.most_common()\n print(len(v1mc))\n if(v1mc[0][0] == v2mc[0][0]):\n if(len(v1mc) == 1 and len(v2mc) == 1):\n print(n/2)\n elif(len(v1mc) == 1):\n print(n - (v1mc[0][1]+v2mc[1][1]))\n elif(len(v2mc) == 1):\n print(n - (v2mc[0][1]+v1mc[1][1]))\n else:\n print(n - max(v1mc[0][1]+v2mc[1][1], v2mc[0][1]+v1mc[1][1]))\n else:\n print(n - (v1mc[0][1]+v2mc[0][1]))\n', 'from collections import Counter\n\nn = int(input())\nv = [int(i) for i in input().split()]\nv1 = Counter(v[::2])\nv2 = Counter(v[1::2])\nv1mc = v1.most_common()\nv2mc = v2.most_common()\nif(v1mc[0][0] == v2mc[0][0]):\n if(len(v1mc) == 1 and len(v2mc) == 1):\n print(int(n/2))\n elif(len(v1mc) == 1):\n print(n - (v1mc[0][1]+v2mc[1][1]))\n elif(len(v2mc) == 1):\n print(n - (v2mc[0][1]+v1mc[1][1]))\n else:\n print(n - max(v1mc[0][1]+v2mc[1][1], v2mc[0][1]+v1mc[1][1]))\nelse:\n print(n - (v1mc[0][1]+v2mc[0][1]))\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s253806859', 's407585566', 's678868986']
[14268.0, 21176.0, 21184.0]
[2104.0, 95.0, 92.0]
[671, 649, 538]
p03244
u806855121
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()))\nE = {}\nO = {}\nn = 1\nfor i, v in enumerate(V):\n if n:\n if v in E.keys():\n E[v] += 1\n else:\n E[v] = 1\n else:\n if v in O.keys():\n O[v] += 1\n else:\n O[v] = 1\n n = 1 - n\nE = sorted(E.items(), key=lambda x: -x[1])\nO = sorted(O.items(), key=lambda x: -x[1])\nif E[0][0] != O[0][0]:\n ans = n - E[0][1] - O[0][1]\n print(ans)\nelse:\n if len(E) == 1 and len(O) == 1:\n print(E[0][1])\n elif len(E) == 1:\n ans = n - E[0][1] - O[1][1]\n print(ans)\n elif len(O) == 1:\n ans = n -E[1][1] - O[0][1]\n print(ans)\n else:\n ans1 = n - E[0][1] - O[1][1]\n ans2 = n - E[1][1] - O[0][1]\n print(min(ans1, ans2))', 'n = int(input())\nV = list(map(int, input().split()))\nE = {}\nO = {}\nnow = 1\nfor i, v in enumerate(V):\n if now:\n if v in E.keys():\n E[v] += 1\n else:\n E[v] = 1\n else:\n if v in O.keys():\n O[v] += 1\n else:\n O[v] = 1\n now = 1 - now\nE = sorted(E.items(), key=lambda x: -x[1])\nO = sorted(O.items(), key=lambda x: -x[1])\nif E[0][0] != O[0][0]:\n print(n - E[0][1] - O[0][1])\nelse:\n if len(E) == 1 and len(O) == 1:\n print(E[0][1])\n elif len(E) == 1:\n print(n-E[0][1]-O[1][1])\n elif len(O) == 1:\n print(n-E[1][1]-O[0][1])\n else:\n print(min(n-E[0][1]-O[1][1], n-E[1][1]-O[0][1]))']
['Wrong Answer', 'Accepted']
['s288546158', 's137030693']
[17644.0, 17648.0]
[107.0, 107.0]
[787, 690]
p03244
u807772568
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 = int(input())\n\nb = list(map(int,input().split()))\nd = max(b)\nc = [0 for i in range(pow(10,5)+1)]\ncc = [0 for i in range(pow(10,5)+1)]\nfor i in range(len(b)):\n if i % 2 == 0:\n c[b[i]-1] += 1\n else:\n cc[b[i]-1] += 1\n\none = 0\nonee = 0\ntwo = 0\ntwoo = 0\nk = 0\nkk = 0\nfor i in range(d+1):\n if one <= c[i]:\n onee = one\n one = c[i]\n k = i\n if two <= cc[i]:\n twoo = two\n two = cc[i]\n kk = i\n\nt = max(one+twoo,onee+twso)\n\nif k != kk:\n print(a-one-two)\nelse:\n print(a-t)', 'a = int(input())\n\nb = list(map(int,input().split()))\nd = max(b)\nc = [0 for i in range(pow(10,5)+100)]\ncc = [0 for i in range(pow(10,5)+100)]\nfor i in range(len(b)):\n if i % 2 == 0:\n cc[b[i]-1] += 1\n else:\n c[b[i]-1] += 1\n\none = 0\nonee = 0\ntwo = 0\ntwoo = 0\nk = 0\nkk = 0\nfor i in range(len(c)+10):\n if one <= c[i]:\n onee = one\n one = c[i]\n k = i\n if two <= cc[i]:\n twoo = two\n two = cc[i]\n kk = i\n\nt = max(one+twoo,onee+two)\n\nif k != kk:\n print(a-one-two)\nelse:\n print(a-t)\n', 'a = int(input())\n\nb = list(map(int,input().split()))\nd = max(b)\nc = [0 for i in range(pow(10,5))]\ncc = [0 for i in range(pow(10,5))]\nfor i in range(a):\n if i % 2 == 0:\n c[b[i]-1] += 1\n else:\n cc[b[i]-1] += 1\n\none = 0\nonee = 0\ntwo = 0\ntwoo = 0\np = 0\npp = 0\nfor i in range(d):\n if one < c[i]:\n onee = one\n one = c[i]\n p += 1\n if two < cc[i]:\n twoo = two\n two = cc[i]\n p += 1\n if p == 2\n pp = 1\n else:\n pp = 0\n p = 0\n\nt = max(one+twoo,onee+two)\n\nif pp == 0\n print(a-one-two)\nelse:\n print(a-t)\n', 'from collections import Counter\n\na = int(input())\n\nb = list(map(int,input().split()))\nd = max(b)\nc = [0 for i in range(pow(10,5)+1)]\ncc = [0 for i in range(pow(10,5)+1)]\nfor i in range(len(b)):\n if i % 2 == 0:\n c[b[i]] += 1\n else:\n cc[b[i]] += 1\nfirst = Counter(b[::2]).most_common(2) + [(0, 0)]\nlatter = Counter(b[1::2]).most_common(2) + [(0, 0)]\none = 0\nonee = 0\ntwo = 0\ntwoo = 0\nk = 0\nkk = 0\nfor i in range(d+1):\n if one <= c[i]:\n onee = one\n one = c[i]\n k = i\n elif onee <= c[i]:\n onee = c[i]\n if two <= cc[i]:\n twoo = two\n two = cc[i]\n kk = i\n elif twoo <= cc[i]:\n twoo = cc[i]\nt = max(one+twoo,onee+two)\n\nif k != kk:\n print(a-one-two)\nelse:\n print(a-t)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s193764617', 's781680271', 's873904726', 's644256370']
[14404.0, 14404.0, 3064.0, 17116.0]
[108.0, 111.0, 17.0, 145.0]
[536, 546, 587, 752]
p03244
u810356688
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\ndef input(): return sys.stdin.readline().rstrip()\nfrom collections import Counter\nfrom operator import itemgetter\ndef main():\n n=int(input())\n V=[int(_) for _ in input().split()]\n even=V[0::2]\n odd=V[1::2]\n even_c=Counter(even)\n odd_c=Counter(odd)\n even_ci,odd_ci=list(even_c.items()),list(odd_c.items())\n even_ci.sort(key=itemgetter(1),reverse=True)\n odd_ci.sort(key=itemgetter(1),reverse=True)\n print(even_ci)\n print(odd_ci)\n if even_ci[0][0]==odd_ci[0][0]:\n print(n//2)\n else:\n print(sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[0][1])\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nfrom collections import Counter\nfrom operator import itemgetter\ndef main():\n n=int(input())\n V=[int(_) for _ in input().split()]\n even,odd=V[0::2],V[1::2]\n even_c,odd_c=Counter(even),Counter(odd)\n even_ci,odd_ci=list(even_c.items()),list(odd_c.items())\n even_ci.sort(key=itemgetter(1),reverse=True)\n odd_ci.sort(key=itemgetter(1),reverse=True)\n if even_ci[0][0]==odd_ci[0][0]:\n if len(even_ci)>1 and len(odd_ci)>1:\n print(min(sum(even_c.values())-even_ci[1][1]+sum(odd_c.values())-odd_ci[0][1],\n sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[1][1]))\n elif len(even_ci)>1 and len(odd_ci)==1:\n print(sum(even_c.values())-even_ci[1][1]) \n elif len(even_ci)==1 and len(odd_ci)>1:\n print(sum(odd_c.values())-odd_ci[0][1]) \n else:\n print(n//2) \n else:\n print(sum(even_c.values())-even_ci[0][1]+sum(odd_c.values())-odd_ci[0][1])\n\nif __name__=='__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s180788644', 's149530823']
[24376.0, 21944.0]
[132.0, 98.0]
[656, 1080]
p03244
u811000506
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()))\nans = 0\nlia = v[::2]\nlib = v[1::2]\ntmp1 = len(lia)\ntmp2 = len(lib)\nlia.sort()\nlib.sort()\nif lia[0]==lib[-1]:\n print(n//2)\n exit()\nlib.sort(reverse=True)\nlia = collections.Counter(lia)\nlib = collections.Counter(lib)\nans += tmp1-lia.most_common()[0][1]\nans += tmp2-lib.most_common()[0][1]\nif lia.most_common()[0][1]%2==1 and lib.most_common()[0][1]2==1:\n print(ans+1)\nelse:\n print(ans)', 'from collections import Counter\nN = int(input())\nV = list(map(int, input().split()))\na = Counter(V[0::2]).most_common() + [(0,0)]\nb = Counter(V[1::2]).most_common() + [(0,0)]\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]))']
['Runtime Error', 'Accepted']
['s285608595', 's223189425']
[3064.0, 20572.0]
[17.0, 87.0]
[458, 280]