Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
  num = int(input())
  if num in A:
    A.remove(num)
  else:
    A.append(num)

print(len(A))

Fixed submission:
import collections
N = int(input())
A = [int(input()) for _ in range(N)]
count = collections.Counter(A)

l = []
for i in list(count):
  if count[i] % 2 != 0:
    l.append(count[i])

print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
  num = int(input())
  if num in A:
    A.remove(num)
  else:
    A.append(num)

ans = len(A)
print(ans)

Fixed submission:
import collections
N = int(input())
A = [int(input()) for _ in range(N)]
count = collections.Counter(A)

l = []
for i in list(count):
  if count[i] % 2 != 0:
    l.append(count[i])

print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in set(A):
  if A.count(i) % 2 != 0:
    ans += 1

print(ans)

Fixed submission:
import collections
N = int(input())
A = [int(input()) for _ in range(N)]
count = collections.Counter(A)

l = []
for i in list(count):
  if count[i] % 2 != 0:
    l.append(count[i])

print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in set(A):
  if A.count(i) % 2 != 0:
    ans += 1

print(ans)


Fixed submission:
import collections
N = int(input())
A = [int(input()) for _ in range(N)]
count = collections.Counter(A)

l = []
for i in list(count):
  if count[i] % 2 != 0:
    l.append(count[i])

print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

ans = 0
for i in set(A):
  if A.count(i) % 2 != 0:
    ans += 1

print(ans)

Fixed submission:
import collections
N = int(input())
A = [int(input()) for _ in range(N)]
count = collections.Counter(A)

l = []
for i in list(count):
  if count[i] % 2 != 0:
    l.append(count[i])

print(len(l))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

ans = 0
for i in set(A):
  if A.count(i) % 2 != 0:
    ans += 1

print(ans)

Fixed submission:
import collections
N = int(input())
A = [int(input()) for _ in range(N)]
count = collections.Counter(A)

l = []
for i in list(count):
  if count[i] % 2 != 0:
    l.append(count[i])

print(len(l))
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
  if p[i]==i+1:
    p[i], p[i+1]=p[i+1],p[i]
    cnt+=1
print(cnt)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  if p[i]==i+1:
    p[i], p[i+1]=p[i+1],p[i]
    cnt+=1

if p[-1]==n:
  cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
seta = list(set(a))

if len(a) <= len(seta)+1:
  print(0)
  exit()

seta.sort(reverse=True)
c2 = []
c4 = 0
for i in seta:
  if a.count(i)>=2:
    c2.append(i)
    if len(c2) == 2:
      break
  
for i in seta:
  if a.count(i)>=4:
    c4=i
    break

if c4 == 0 and len(c2)<2:
  print(0)
elif c4 == 0 and len(c2)>=2:
  print(c2[0]*c2[1])
elif c4 > 0 and len(c2)<2:
  print(c4**2)
else:
  print(max(c4**2,c2[0]*c2[1]))

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

e=[]
a.sort(reverse=True)
for i in range(len(a)-1):
  if a[i] == a[i+1] and a[i] not in e:
    e.append(a[i])
    if len(e) == 2:
      break
e.sort(reverse=True)

c4 = 0
for i in e:
  if a.count(i)>=4:
    c4=i
    break

if c4 == 0 and len(e)<2:
  print(0)
elif c4 == 0 and len(e)>=2:
  print(e[0]*e[1])
elif c4 > 0 and len(e)<2:
  print(c4**2)
else:
  print(max(c4**2,e[0]*e[1]))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
seta = list(set(a))

seta.sort(reverse=True)
c2 = []
c4 = 0
for i in seta:
  if a.count(i)>=2:
    c2.append(i)
    if len(c2) == 2:
      break
  
for i in seta:
  if a.count(i)>=4:
    c4=i
    break

if c4 == 0 and len(c2)<2:
  print(0)
elif c4 == 0 and len(c2)>=2:
  print(c2[0]*c2[1])
elif c4 > 0 and len(c2)<2:
  print(c4**2)
else:
  print(max(c4**2,c2[0]*c2[1]))

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

e=[]
a.sort(reverse=True)
for i in range(len(a)-1):
  if a[i] == a[i+1] and a[i] not in e:
    e.append(a[i])
    if len(e) == 2:
      break
e.sort(reverse=True)

c4 = 0
for i in e:
  if a.count(i)>=4:
    c4=i
    break

if c4 == 0 and len(e)<2:
  print(0)
elif c4 == 0 and len(e)>=2:
  print(e[0]*e[1])
elif c4 > 0 and len(e)<2:
  print(c4**2)
else:
  print(max(c4**2,e[0]*e[1]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
seta = list(set(a))

c4 = []
c2 = []
for i in seta:
  if Counter(a)[i] >= 4:
    c4.append(i)
  if Counter(a)[i] >= 2:
    c2.append(i)

c2.sort(reverse=True)
c4.sort(reverse=True)
if len(c4) == 0 and len(c2)<2:
  print(0)
elif len(c4) == 0 and len(c2)>=2:
  print(c2[0]*c2[1])
elif len(c4) > 0 and len(c2)<2:
  print(c4[0]**2)
else:
  print(max(c4[0]**2,c2[0]*c2[1]))

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

e=[]
a.sort(reverse=True)
for i in range(len(a)-1):
  if a[i] == a[i+1] and a[i] not in e:
    e.append(a[i])
    if len(e) == 2:
      break
e.sort(reverse=True)

c4 = 0
for i in e:
  if a.count(i)>=4:
    c4=i
    break

if c4 == 0 and len(e)<2:
  print(0)
elif c4 == 0 and len(e)>=2:
  print(e[0]*e[1])
elif c4 > 0 and len(e)<2:
  print(c4**2)
else:
  print(max(c4**2,e[0]*e[1]))
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))

o = 0
f = 0
t = 0
for i in a:
  if i % 2 == 1:
    o += 1
  if i % 4 == 0:
    f += 1
  if i % 4 == 2:
    t += 1
if f >=0 o-1 and t == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
N=int(input())
a=list(map(int,input().split()))

o = 0
f = 0
t = 0
for i in a:
  if i % 2 == 1:
    o += 1
  if i % 4 == 0:
    f += 1
  if i % 4 == 2:
    t += 1
if f >o-1:
  print('Yes')
elif f == o-1 and t==0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
ab.sort()
mid = []
cand = []
mid_id = 0
for i in range(m):
  if ab[i][0] == 1:
    mid.append(ab[i][1])
  elif ab[i][0] == n or ab[i][1] == n:
    cand.append(ab[i])

if len(mid) == 0:
  print('IMPOSSIBLE')
  exit()
  
for j in range(len(cand)):
  if cand[j][0] in mid and cand[j][1] == n:
    print('POSSIBLE')
    exit()
  elif cand[j][1] in mid and cand[j][0] == n:
    print('POSSIBLE')
    exit()

print('IMPOSSIBLE')

Fixed submission:
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
ab.sort()
mid = []
cand = []
for i in range(m):
  if ab[i][0] == 1:
    mid.append(ab[i][1])
  elif ab[i][0] == n:
    cand.append(ab[i][1])
  elif ab[i][1] == n:
    cand.append(ab[i][0])    

if len(set(mid) & set(cand)) > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
mid = []
for i in range(m):
  if ab[i][0] == 1:
    mid.append(ab[i][1])
  elif ab[i][1] == 1:
    mid.append(ab[i][0])

for j in range(m):
  if ab[j][0] in mid and ab[j][1] == n:
    print('POSSIBLE')
    exit()
  elif ab[j][1] in mid and ab[j][0] == n:
    print('POSSIBLE')
    exit()

print('IMPOSSIBLE')

Fixed submission:
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
ab.sort()
mid = []
cand = []
for i in range(m):
  if ab[i][0] == 1:
    mid.append(ab[i][1])
  elif ab[i][0] == n:
    cand.append(ab[i][1])
  elif ab[i][1] == n:
    cand.append(ab[i][0])    

if len(set(mid) & set(cand)) > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
  b.append(a[i])
  b = list(reversed(b))
print(*b)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
o = []
e = []
for i in range(n):
  if i%2 == 0:e.append(a[i])
  else: o.append(a[i])

if n%2 == 0:
  b = list(reversed(o))+e
else:
  b = list(reversed(e))+o
print(*b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

a = []
i = 1
cnt = 0
while i != 2:
  a.append(i)
  cnt += 1
  i = A[i-1]
  if i == 2 or i in a:
    break

if i == 2:
  print(cnt)
else:
  print(-1)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

i = 1
cnt = 0
while i != 2 and cnt <= N:
  cnt += 1
  i = A[i-1]
  if i == 2:
    break

if i == 2:
  print(cnt)
else:
  print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

a = []
i = 1
cnt = 0
while i != 2 and i not in a:
  a.append(i)
  cnt += 1
  i = A[i-1]
  if i == 2:
    break

if i == 2:
  print(cnt)
else:
  print(-1)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

i = 1
cnt = 0
while i != 2 and cnt <= N:
  cnt += 1
  i = A[i-1]
  if i == 2:
    break

if i == 2:
  print(cnt)
else:
  print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

a = []
i = 1
cnt = 0
while i != 2 and i not in a:
  a.append(i)
  i = A[i-1]
  cnt += 1

if i == 2:
  print(cnt)
else:
  print(-1)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

i = 1
cnt = 0
while i != 2 and cnt <= N:
  cnt += 1
  i = A[i-1]
  if i == 2:
    break

if i == 2:
  print(cnt)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N = int(input())
s = [int(input()) for _ in range(N)]
a = list(product(range(2),repeat = N))
s.sort(reverse=True)
while len(s) >0 and sum(s)%10==0:
  s.pop()
print(sum(s))

Fixed submission:
N = int(input())
s = sorted([int(input()) for _ in range(N)])

if sum(s)%10 != 0:
  print(sum(s))
else:
  for i in range(N):
    if s[i] %10 != 0:
      print(sum(s)-s[i])
      exit()
  print(0)
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
a=v[:A]
b=v[:B]
avg=sum(a)/A
print(avg)
c=[[0]*51 for _ in range(51)]
c[0][0]=1
for i in range(50):
  c[i+1][0]=1
  c[i+1][i+1]=1
  for j in range(i):
    c[i+1][j+1]=c[i][j]+c[i][j+1]
if a[0]==a[-1]:
  ans=0
  x=v.count(a[0])
  for i in range(A,B+1):
    if i<=x:
      ans+=C[x][i]
else:
  x=v.count(a[-1])
  y=a.count(a[-1])
  ans=c[x][y]
print(ans)

Fixed submission:
N,A,B=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
a=v[:A]
b=v[:B]
avg=sum(a)/A
print(avg)
c=[[0]*51 for _ in range(51)]
c[0][0]=1
for i in range(50):
  c[i+1][0]=1
  c[i+1][i+1]=1
  for j in range(i):
    c[i+1][j+1]=c[i][j]+c[i][j+1]
if a[0]==a[-1]:
  ans=0
  x=v.count(a[0])
  for i in range(A,B+1):
    if i<=x:
      ans+=c[x][i]
else:
  x=v.count(a[-1])
  y=a.count(a[-1])
  ans=c[x][y]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,C,K = map(int,input().split())
T = []
for i in range(N):
  T.append(int(input()))

T.sort()
counter = 0
while len(T) > 0:
  if len(T) == 1:
    T.pop()
    counter += 1
  else:
    c = 1
    while c <= len(T)-1:
      if T[c] - T[0] <= K:
        c += 1
      else:
        break
  
    del T[:min(c,C)]
    counter += 1

print(counter)

Fixed submission:
N,C,K = map(int,input().split())
T = []
for i in range(N):
  T.append(int(input()))

T.sort()
counter = 0
while len(T) > 0:
  if len(T) == 1:
    T.pop()
    counter += 1
  else:
    c = 1
    while c <= len(T)-1 and c < C:
      if T[c] - T[0] <= K:
        c += 1
      else:
        break
  
    del T[:c]
    counter += 1

print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
while n < m//2:
  n += 1
  m -=2

print(min(n,m//2))

Fixed submission:
n,m = map(int,input().split())
if n*2 <= m:
  x = (m-2*n)//4
  print(min(n+x,(m-2*x)//2))
else:
  print(m//2)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
while n*2 < m:
  n += 1
  m -=2

print(min(n,m//2))

Fixed submission:
n,m = map(int,input().split())
if n*2 <= m:
  x = (m-2*n)//4
  print(min(n+x,(m-2*x)//2))
else:
  print(m//2)
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
counter = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == S:
        counter += 1
print(counter)

Fixed submission:
K,S = map(int,input().split())
counter = 0
for x in range(K+1):
  for y in range(K+1):
    if 0 <= S - (x + y) <= K:
      counter += 1

print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

if n%2 == 0:
  for i in range(1,n//2+1):
    if a.count(i*2-1) != 2:
      print(0)
      exit()
  print(2**(n//2))
else:
  if a.count(0) != 1:
    print(0)
    exit()
  for i in range(1,n//2):
    if a.count(i*2) != 2:
      print(0)
      exit()
  print(2**(n//2))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
m = 10**9+7
if n%2 == 0:
  l = []
  for i in range(1,n//2+1):
    l.append(i*2-1)
    l.append(i*2-1)
  if a != l:
    print(0)
    exit()
  print(2**(n//2) %m)
else:
  l = [0]
  for i in range(1,n//2+1):
    l.append(i*2)
    l.append(i*2)
  if a != l:
    print(0)
    exit()
  print(2**(n//2) %m)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(h)]
for i in range(h):
  print(c[i])
  print(c[i])

Fixed submission:
h,w=map(int,input().split())
c=[input() for _ in range(h)]
for i in range(h):
  print(c[i])
  print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

while len(S) > 0:
  if "dreameraser" in S:
    S = S.replace("dreameraser","")
  elif "dreamer" in S:
    S = S.replace("dreamer","")
  elif "dream" in S:
    S = S.replace("dream","")
  elif "eraseer" in S:
    S = S.replace("eraser","")
  elif "erase" in S:
    S = S.replace("erase","")
  else:
    break
    
if len(S) == 0:
  print("YES")
else:
  print("NO")

Fixed submission:
S = input()
 
while len(S) > 0:
  if "dreameraser" in S:
    S = S.replace("dreameraser","")
  elif "dreamerase" in S:
    S = S.replace("dreamerase","")
  elif "dreamer" in S:
    S = S.replace("dreamer","")
  elif "dream" in S:
    S = S.replace("dream","")
  elif "eraser" in S:
    S = S.replace("eraser","")
  elif "erase" in S:
    S = S.replace("erase","")
  else:
    break
    
if len(S) == 0:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Time Limit Exceeded):
S = input()

while len(S) > 0:
  if "dreameraser" in S:
    S = S.replace("dreameraser","")
  elif "dream" in S:
    S = S.replace("dreamer","")
  elif "dreamer" in S:
    S = S.replace("dream","")
  elif "erase" in S:
    S = S.replace("eraser","")
  elif "eraser" in S:
    S = S.replace("erase","")
  else:
    break
    
if len(S) == 0:
  print("YES")
else:
  print("NO")

Fixed submission:
S = input()
 
while len(S) > 0:
  if "dreameraser" in S:
    S = S.replace("dreameraser","")
  elif "dreamerase" in S:
    S = S.replace("dreamerase","")
  elif "dreamer" in S:
    S = S.replace("dreamer","")
  elif "dream" in S:
    S = S.replace("dream","")
  elif "eraser" in S:
    S = S.replace("eraser","")
  elif "erase" in S:
    S = S.replace("erase","")
  else:
    break
    
if len(S) == 0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    X = 0
    Y = 0
    for j in range(N):
        if ((i >> j) & 1):
            X += V[j]
            Y += C[j]
    ans = max(ans, X-Y)

print(ans)
    


Fixed submission:
N = int(input())

V = list(map(int,input().split()))
C = list(map(int,input().split()))

import copy

flag = [0]*N
def dfs(x, y):
    if y==1:
        flag[x] = 1
    else:
        flag[x] = 0
    if x==N-1:
        value = 0
        cost = 0
        for i in range(N):
            if flag[i] == 1:
                value += V[i]
                cost += C[i]
        # print(flag)
        # for i in range(N):
        #     flag[i] = 0
        return value - cost

    
    return max(dfs(x+1, 0),dfs(x+1, 1))

print(dfs(-1,0))

Buggy python submission (verdict: Runtime Error):
N = int(input())

V = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    X = 0
    Y = 0
    for j in range(N):
        if ((i >> j) & 1):
            X += V[j]
            Y += C[i]
    ans = max(ans, X-Y)

print(ans)
    


Fixed submission:
N = int(input())

V = list(map(int,input().split()))
C = list(map(int,input().split()))

import copy

flag = [0]*N
def dfs(x, y):
    if y==1:
        flag[x] = 1
    else:
        flag[x] = 0
    if x==N-1:
        value = 0
        cost = 0
        for i in range(N):
            if flag[i] == 1:
                value += V[i]
                cost += C[i]
        # print(flag)
        # for i in range(N):
        #     flag[i] = 0
        return value - cost

    
    return max(dfs(x+1, 0),dfs(x+1, 1))

print(dfs(-1,0))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()

ans = []
for i in range(Q):
    count = 0
    l,r = map(int,input().split())
    l -= 1
    r -= 1
    last = ''
    for j in range(l,r+1):
        if S[j] == 'C' and last == 'A':
            count += 1
        last = S[j]
    ans.append(count)

for a in ans:
    print(a)


Fixed submission:
N,Q = map(int,input().split())
S = input()
ans = []

ac = [0]*(len(S)+1)
last = ''
for i in range(len(S)):
    s = S[i]
    if s=='C' and last == 'A':
        ac[i-1] = 1
    last = s

add = [0]*(len(S)+2)
for i in range(len(ac)):
    add[i+1] = add[i] + ac[i]

for j in range(Q):
    l,r = map(int,input().split())
    l -= 1
    r -= 1
    sub = add[r] - add[l]
    ans.append(sub)

for a in ans:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

stack = []

ans = 0
for s in S:
    if len(stack)==0 or s==stack[-1]:
        stack.append(s)
    else:
        stack = stack[:-1]
        ans += 2

print(ans)


Fixed submission:
S = input()
 
c0=0
c1=0
 
for s in S:
  if s=='0':
    c0 += 1
  else:
    c1 += 1
print(min(c0,c1)*2)
Buggy python submission (verdict: Runtime Error):
    N, K = map(int,input().split())
    H = []
    for i in range(N):
        h = int(input())
        H.append(h)
     
    H.sort()
    l = 0
    r = K-1
    from math import inf
    ans = inf
    while r <= N-1:
        sub = H[r] - H[l]
        ans = min(ans, sub)
        r += 1
        l += 1
     
    print(ans)

Fixed submission:
N, K = map(int,input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)

H.sort()
l = 0
r = K-1
ans = 10**10
while r <= N-1:
    sub = H[r] - H[l]
    ans = min(ans, sub)
    r += 1
    l += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)

H.sort()
l = 0
r = K-1
from math import inf
ans = inf
while r <= N-1:
    sub = H[r] - H[l]
    ans = min(ans, sub)
    r += 1
    l += 1

print(ans)


Fixed submission:
N, K = map(int,input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)

H.sort()
l = 0
r = K-1
ans = 10**10
while r <= N-1:
    sub = H[r] - H[l]
    ans = min(ans, sub)
    r += 1
    l += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**7) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 
# h,w = li()
# ss = [ns() for _ in range(h)]

n = int(input())

vs = li()
v_odd = []
v_even = []

i=0
for v in vs:
    if i % 2 == 0:
        v_even.append(v)
    else:
        v_odd.append(v)
    i = i + 1

max_count_odd = 0

m_odd = 0
m_even = 0
for ss in set(v_odd):
    count = v_odd.count(ss)
    if count > max_count_odd:
        max_count_odd = count
        m_odd = ss
# import pdb;pdb.set_trace() 
max_count_even = 0
for ss in set(v_even):
    count = v_even.count(ss)
    if count > max_count_even:
        max_count_even = count
        m_even = ss
# import pdb;pdb.set_trace() 
ans = len(v_even)-max_count_even  +  len(v_odd)-max_count_odd

m2_oddmax = 0
m2_evenmax = 0
import copy
# import pdb;pdb.set_trace()
if(m_even==m_odd):
    temp = set(v_odd)
    temp.remove(m_odd)
    m2_odd = 0
    # import pdb;pdb.set_trace()
    for ss in temp:
        count = v_odd.count(ss)
        if count > m2_oddmax:
            m2_oddmax = count
            m2_odd = ss
    temp = set(v_even)
    temp.remove(m_even)
    m2_even = 0
    for ss in temp:
        count = v_even.count(ss)
        if count > m2_evenmax:
            m2_evenmax = count
            m2_even = ss
    if m2_evenmax > m2_oddmax:
        # import pdb;pdb.set_trace()
        ans = len(v_even)-m2_evenmax + len(v_odd)-max_count_odd
    elif m2_evenmax <= m2_oddmax:
        # import pdb;pdb.set_trace()
        ans = len(v_even)-max_count_even + len(v_odd)-m2_oddmax
    if m2_even == 0 and m2_odd == 0:
        ans = int(n/2)
    # import pdb;pdb.set_trace()


print(ans)


Fixed submission:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**7) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())



a = str(input())
ans=''
for c in a:
    if c=='1':
        ans = ans + '9'
    elif c=='9':
        ans = ans + '1'
    else:
        ans = ans + c

print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()

ans = 0
for n in N:
    ans += n

print(ans)


Fixed submission:
N = input()

ans = 0
for n in N:
    ans += int(n)

if ans == 1:
    ans = 10

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

left = []
for h in range(1,3500):
    left.append(4/N-1/h)

left.sort()

import bisect
ans = [0,0,0]
flag = 0
for n in range(1,3500):
    if flag == 1:
        break
    for w in range(1,3500):
        temp = 1/n + 1/w
        index = bisect.bisect_left(left, temp)
        if index < len(left) and left[index] == temp:
            ans[1] = n
            ans[2] = w
            flag = 1
            break

n = ans[1]
w = ans[2]
h = N*n*w // (4*n*w - N*w - N*n)

print('{} {} {}'.format(h,n,w))



Fixed submission:
N = int(input())

flag = 0
for n in range(1,3500):
    if flag == 1:
        break
    for w in range(1,3500):
        if (4*n*w - N*w - N*n) == 0:
            continue
        h = N*n*w / (4*n*w - N*w - N*n)
        if h%1 == 0 and 1 <= h <= 3500:
            flag = 1
            break

print('{} {} {}'.format(int(h), n-1, w))