Language: C++

//#include <bits/stdc++.h> 
#include<cstdio>
#include<iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;

const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    int a[10001]={};
    int b[10001]={};
    rep(i,n){
        if(i%2==0)a[v[i]]++;
        else b[v[i]]++;
    }
    int maxa[2]={},maxb[2]={};
    int indexa[2]={},indexb[2]={};
    rep(i,10001){
        if(a[i]>maxa[0]){
            maxa[0]=a[i];
            indexa[0]=i;
        }else if(a[i]>maxa[1]){
            maxa[1]=a[i];
            indexa[1]=i;
        }
        if(b[i]>maxb[0]){
            maxb[0]=b[i];
            indexb[0]=i;
        }else if(b[i]>maxb[1]){
            maxb[1]=b[i];
            indexb[1]=i;
        }
    }
    if(maxa[0]==n/2&&maxb[0]==n/2){
        if(indexa[0]==indexb[0]){
            cout<<n/2<<endl;
        }else{
            cout<<0<<endl;
        }
    }else{
        if(indexa[0]==indexb[0]){
            cout<<min(n-maxa[0]-maxb[1],n-maxa[1]-maxb[0])<<endl;
        }else{
            cout<<(n-maxa[0]-maxb[0])<<endl;
        }
    }
    return 0;
}/#include <bits/stdc++.h> 
#include<cstdio>
#include<iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;

const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    int a[10001]={};
    int b[10001]={};
    rep(i,n){
        if(i%2==0)a[v[i]]++;
        else b[v[i]]++;
    }
    int maxa[2]={},maxb[2]={};
    int indexa[2]={},indexb[2]={};
    rep(i,10001){
        if(a[i]>maxa[0]){
            maxa[0]=a[i];
            indexa[0]=i;
        }else if(a[i]>maxa[1]){
            maxa[1]=a[i];
            indexa[1]=i;
        }
        if(b[i]>maxb[0]){
            maxb[0]=b[i];
            indexb[0]=i;
        }else if(b[i]>maxb[1]){
            maxb[1]=b[i];
            indexb[1]=i;
        }
    }
    if(maxa[0]==n/2&&maxb[0]==n/2){
        if(indexa[0]==indexb[0]){
            cout<<n/2<<endl;
        }else{
            cout<<0<<endl;
        }
    }else{
        if(indexa[0]==indexb[0]){
            cout<<min(n-maxa[0]-maxb[1],n-maxa[1]-maxb[0])<<endl;
        }else{
            cout<<(n-maxa[0]-maxb[0])<<endl;
        }
    }
    return 0;
}

Compiler output:
a.cc:58:3: error: stray '#' in program
   58 | }/#include <bits/stdc++.h>
      |   ^
a.cc:7:13: error: 'vector' does not name a type
    7 | using Graph=vector<vector<int>>;
      |             ^~~~~~
a.cc:8:13: error: 'vector' does not name a type
    8 | using Field=vector<string>;
      |             ^~~~~~
a.cc: In function 'int main()':
a.cc:18:5: error: 'vector' was not declared in this scope
   18 |     vector<int> v(n);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include<iostream>
  +++ |+#include <vector>
    4 | #define rep(i,n) for (int i = 0; i < (n); ++i)
a.cc:18:12: error: expected primary-expression before 'int'
   18 |     vector<int> v(n);
      |            ^~~
a.cc:19:18: error: 'v' was not declared in this scope
   19 |     rep(i,n)cin>>v[i];
      |                  ^
a.cc:23:21: error: 'v' was not declared in this scope
   23 |         if(i%2==0)a[v[i]]++;
      |                     ^
a.cc:24:16: error: 'v' was not declared in this scope
   24 |         else b[v[i]]++;
      |                ^
a.cc: At global scope:
a.cc:58:2: error: expected unqualified-id before '/' token
   58 | }/#include <bits/stdc++.h>
      |  ^
a.cc:64:13: error: 'vector' does not name a type
   64 | using Graph=vector<vector<int>>;
      |             ^~~~~~
a.cc:65:13: error: 'vector' does not name a type
   65 | using Field=vector<string>;
      |             ^~~~~~
a.cc:68:10: error: redefinition of 'const ll mod'
   68 | const ll mod=1000000007;
      |          ^~~
a.cc:11:10: note: 'const ll mod' previously defined here
   11 | const ll mod=1000000007;
      |          ^~~
a.cc:69:11: error: redefinition of 'const int dx []'
   69 | const int dx[]={0,1,0,-1};
      |           ^~
a.cc:12:11: note: 'const int dx [4]' previously defined here
   12 | const int dx[]={0,1,0,-1};
      |           ^~
a.cc:70:11: error: redefinition of 'const int dy []'
   70 | const int dy[]={1,0,-1,0};
      |           ^~
a.cc:13:11: note: 'const int dy [4]' previously defined here
   13 | const int dy[]={1,0,-1,0};
      |           ^~
a.cc:72:5: error: redefinition of 'int main()'
   72 | int main(){
      |     ^~~~
a.cc:15:5: note: 'int main()' previously defined here
   15 | int main(){
      |     ^~~~
a.cc: In function 'int main()':
a.cc:75:5: error: 'vector' was not declared in this scope
   75 |     vector<int> v(n);
      |     ^~~~~~
a.cc:75:5: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:75:12: error: expected primary-expression before 'int'
   75 |     vector<int> v(n);
      |            ^~~
a.cc:76:18: error: 'v' was not declared in this scope
   76 |     rep(i,n)cin>>v[i];
      |                  ^
a.cc:80:21: error: 'v' was not declared in this scope
   80 |         if(i%2==0)a[v[i]]++;
      |                     ^
a.cc:81:16: error: 'v' was not declared in this scope
   81 |         else b[v[i]]++;
      |                ^