Language: C++

//  Created by liszt on 2019/07/31.
#include<bits/stdc++.h>
using namespace std;

int main(){
    //input
    int n,omax,emax,o,e,i,a,b;
    vector<int> o(100001,0);
    vector<int> e(100001,0);
    
    for(i=0;i<n/2;i++){
        cin>>a >>b;
        o[a]++; e[b]++;
        if(o[a]>omax){omax=o[a];o=a;}
        if(e[b]>emax){emax=e[b];e=b;}
    }
    
    sort(o.begin(),o.end());
    sort(e.begin(),e.end());
    
    if(o!=e){
        cout<<n-o[0]-e[0]<<endl;
        return 0;
    }
    
    cout<<min(n-o[0]-e[1],n-o[1]-e[0])<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: conflicting declaration 'std::vector<int> o'
    8 |     vector<int> o(100001,0);
      |                 ^
a.cc:7:21: note: previous declaration as 'int o'
    7 |     int n,omax,emax,o,e,i,a,b;
      |                     ^
a.cc:9:17: error: conflicting declaration 'std::vector<int> e'
    9 |     vector<int> e(100001,0);
      |                 ^
a.cc:7:23: note: previous declaration as 'int e'
    7 |     int n,omax,emax,o,e,i,a,b;
      |                       ^
a.cc:13:10: error: invalid types 'int[int]' for array subscript
   13 |         o[a]++; e[b]++;
      |          ^
a.cc:13:18: error: invalid types 'int[int]' for array subscript
   13 |         o[a]++; e[b]++;
      |                  ^
a.cc:14:13: error: invalid types 'int[int]' for array subscript
   14 |         if(o[a]>omax){omax=o[a];o=a;}
      |             ^
a.cc:14:29: error: invalid types 'int[int]' for array subscript
   14 |         if(o[a]>omax){omax=o[a];o=a;}
      |                             ^
a.cc:15:13: error: invalid types 'int[int]' for array subscript
   15 |         if(e[b]>emax){emax=e[b];e=b;}
      |             ^
a.cc:15:29: error: invalid types 'int[int]' for array subscript
   15 |         if(e[b]>emax){emax=e[b];e=b;}
      |                             ^
a.cc:18:12: error: request for member 'begin' in 'o', which is of non-class type 'int'
   18 |     sort(o.begin(),o.end());
      |            ^~~~~
a.cc:18:22: error: request for member 'end' in 'o', which is of non-class type 'int'
   18 |     sort(o.begin(),o.end());
      |                      ^~~
a.cc:19:12: error: request for member 'begin' in 'e', which is of non-class type 'int'
   19 |     sort(e.begin(),e.end());
      |            ^~~~~
a.cc:19:22: error: request for member 'end' in 'e', which is of non-class type 'int'
   19 |     sort(e.begin(),e.end());
      |                      ^~~
a.cc:22:18: error: invalid types 'int[int]' for array subscript
   22 |         cout<<n-o[0]-e[0]<<endl;
      |                  ^
a.cc:22:23: error: invalid types 'int[int]' for array subscript
   22 |         cout<<n-o[0]-e[0]<<endl;
      |                       ^
a.cc:26:18: error: invalid types 'int[int]' for array subscript
   26 |     cout<<min(n-o[0]-e[1],n-o[1]-e[0])<<endl;
      |                  ^
a.cc:26:23: error: invalid types 'int[int]' for array subscript
   26 |     cout<<min(n-o[0]-e[1],n-o[1]-e[0])<<endl;
      |                       ^
a.cc:26:30: error: invalid types 'int[int]' for array subscript
   26 |     cout<<min(n-o[0]-e[1],n-o[1]-e[0])<<endl;
      |                              ^
a.cc:26:35: error: invalid types 'int[int]' for array subscript
   26 |     cout<<min(n-o[0]-e[1],n-o[1]-e[0])<<endl;
      |                                   ^