criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin>>n;
    map<int,int> a,b;
    for (int i=0;i<n;i++) {
        int x;cin>>x;
        if (i%2==0)
            a[x]++;
        else
            b[x]++;
    }
    vector<pair<int,int>> c,d;
    for (auto p:a)
        c.push_back({p.second,p.first});
    for (auto p:b)
        d.push_back({p.second,p.first});
    sort(c.begin(),c.end(),greater<pair<int,int>>);
    sort(d.begin(),d.end(),greater<pair<int,int>>);
    int ans;
    n/=2;
    c.push_back({0,0});
    d.push_back({0,0});
    if (c[0].second==d[0].second)
        ans=min(n-c[0].first+n-d[1].first,n-c[1].first+n-d[0].first);
    else
        ans=n-c[0].first+n-d[0].first;
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:50: error: expected primary-expression before ')' token
   21 |     sort(c.begin(),c.end(),greater<pair<int,int>>);
      |                                                  ^
a.cc:22:50: error: expected primary-expression before ')' token
   22 |     sort(d.begin(),d.end(),greater<pair<int,int>>);
      |                                                  ^
Language: C++

import numpy as np
n = int(input())
v = list(map(int, input().split()))
v_odd = []
v_even = []
for i in range(n):
    if i%2 == 0:
        v_odd.append(v[i])
    else:
        v_even.append(v[i])

vs_odd = np.array(v_odd)
vs_even = np.array(v_even)
count_odd = np.bincount(vs_odd)
count_even = np.bincount(vs_even)
mode_odd = np.argmax(count_odd)
mode_even = np.argmax(count_even)
a = v_odd.count(mode_odd)
b = v_even.count(mode_even)
if mode_odd != mode_even:
    print(n-a-b)
else:
    v_odd2 = [i for i in v_odd if i != mode_odd]
    v_even2 = [i for i in v_even if i != mode_even]
    v_odd2.append(0)
    v_even2.append(0)
    vs_odd2 = np.array(v_odd2)
    vs_even2 = np.array(v_even2)
    count_odd2 = np.bincount(vs_odd2)
    count_even2 = np.bincount(vs_even2)
    mode_odd2 = np.argmax(count_odd2)
    mode_even2 = np.argmax(count_even2)
    a2 = v_odd.count(mode_odd2)
    b2 = v_even.count(mode_even2)
    if a2 > b2:
        print(n-a2-b)
    else:
        print(n-a-b2)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
#include <vector>
#include <utility>

using namespace std;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if(a.second!=b.second) {
        return a.second > b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int n;
    cin >> n;
    
    int v[n];
    vector<pair<int, int> > ev;
    vector<pair<int , int> > od;
    for(int i=0; i<n; i++) {
        cin >> v[i];
        bool flag=true;
        if(i%2) {
            for(int j=0; j<ev.size(); j++) {
                if(ev[j].first==v[i]) {
                    ev[j].second++;
                    flag=false;
                    break;
                }
            }
            if(flag) {
                ev.push_back(make_pair(v[i], 1));
            }
        } else {
            for(int j=0; j<od.size(); j++) {
                if(od[j].first==v[i]) {
                    od[j].second++;
                    flag=false;
                    break;
                }
            }
            if(flag) {
                od.push_back(make_pair(v[i], 1));
            }
        }
    }

    od.push_back(make_pair(0, 0));
    ev.push_back(make_pair(0, 0));
    
    sort(od.begin(), od.end(), cmp);
    sort(ev.begin(), ev.end(), cmp);
    
    if(od[0].first!=ev[0].first) {
        cout << n - od[0].second - ev[0].second << endl;
    } else {
        if(od[0].second+ev[1].second>od[1].second+ev[0].second) {
            cout << n - od[0].second - ev[1].second << endl;
        } else {
            cout << n - od[1].second - ev[0].second << endl;
        }
    }

    return 0;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   53 |     sort(od.begin(), od.end(), cmp);
      |     ^~~~
      |     short
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int INF = 1000000007;

 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int A[N];
  map<int, int> mp1, mp2;
  rep(i, N){
    cin >> A[i];
    if(i % 2 == 0){
      mp1[A[i]]++;
    }
    else{
      mp2[A[i]]++;
    }
  }
  pair<int, int> P1[N/2], P2[N/2];
  int i = 0;
  for(pair<int, int> P : mp1){
    P1[i].first = P.second;
    P1[i].second = P.first;
    i++;
  }
  int j = 0;
  for(pair<int, int> P : mp2){
    P2[j].first = P.second;
    P2[j].second = P.first;
    j++;
  }
  sort(P1, P1+i);
  reverse(P1, P1+i);
  sort(P2, P2+j);
  reverse(P2, P2+j);
  if(i == 1 && j == 1){
    if(P1[0].second == P2[0].second){
      cout << N/2 << endl;
      return 0;
    }
    else{
      cout << 0 << endl;
      return 0;
    }
  }
  else if(i == 1){
    if(P1[0].second == P2[0].second){
      cout << N/2 - P2[1].first << endl;
      return 0;
    }
    else{
      cout << N/2 - P2[0].first << endl;
      return 0;
    }
  }
  else if(j == 1){
    if(P1[0].second == P2[0].second){
      cout << N/2 - P1[1].first << endl;
      return 0;
    }
    else{
      cout << N/2 - P1[0].first << endl;
      return 0;
    }
  }
  else{
    if(P1[0].second != P2[0].second){
      cout << N - (P1[0].first + P2[0].first) << endl;
    }
    else{
      int a = max(P1[0].first + P2[1].first, P1[1].first + P2[0].first);
      cout << N - a << endl;
    }
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:79:4: error: expected '}' at end of input
   79 |   }
      |    ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <utility>

using namespace std;

bool cmp(pair<long long int, long long int> a, pair<long long int, long long int> b) {
    if(a.second!=b.second) {
        return a.second > b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int n;
    cin >> n;

    vector<pair<long long int, long long int> > ev;
    vector<pair<long long int, long long int> > od;
    
    for(int i=0; i<n; i++) {
        long long int v;
        cin >> v;
        if(i%2) {
            if(od.size()==0) {
                od.push_back(make_pair(v, 1));
            } else {
                bool flod=true;
                for(int j=0; j<od.size(); j++) {
                    if(od[j].first==v) {
                        od[j].second++;
                        flod=false;
                    }
                }
                if(flod) {
                    od.push_back(make_pair(v, 1));
                }
            }
        } else {
            if(ev.size()==0) {
                ev.push_back(make_pair(v, 1));
            } else {
                bool flev=true;
                for(int j=0; j<ev.size(); j++) {
                    if(ev[j].first==v) {
                        ev[j].second++;
                        flev=false;
                    }
                }
                if(flev) {
                    ev.push_back(make_pair(v, 1));
                }
            }
        }
    }

    sort(od.begin(), od.end(), cmp);
    sort(ev.begin(), ev.end(), cmp);

    if(od[0].first!=ev[0].first) {
        cout << n - od[0].second - ev[0].second << endl;
    } else {
        if(od[0].second>ev[0].second) {
            cout << n - od[0].second - ev[1].second << endl;
        } else {
            cout << n - od[1].second - ev[0].second << endl;
        }
    }

    return 0;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   58 |     sort(od.begin(), od.end(), cmp);
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <map>
using namespace std;

int main() {
  int N;
  map<int, int> A, B;
  cin >> N;
  
  for(int i=1; i<=N; i++) {
    cin >> tmp;
    if(i%2==0) {
      if(A[tmp]==A.end()) {
        A.insert(make_pair(tmp,1))
      } else {
        A[tmp]++;
      }
    } else {
      if(B[tmp]==B.end()) {
        B.insert(make_pair(tmp,1))
      } else {
        B[tmp]++;
      }
    }
  }
  
  int max_A = 0;
  for(auto itr=A.begin(); itr!=A.end(), itr++) {
    if(itr->first>max_A) {
      max_A = itr->first;
    }
  }
  
  int max_B = 0;
  for(auto itr=B.begin(); itr!=B.end(), itr++) {
    if(itr->first>max_B) {
      max_B = itr->first;
    }
  }
  
  cout << N - maxA - maxB << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   11 |     cin >> tmp;
      |            ^~~
      |            tm
a.cc:28:39: error: could not convert '(((void)std::operator!=(itr, A.std::map<int, int>::end())), itr.std::_Rb_tree_iterator<std::pair<const int, int> >::operator++(0))' from 'std::_Rb_tree_iterator<std::pair<const int, int> >::_Self' to 'bool'
   28 |   for(auto itr=A.begin(); itr!=A.end(), itr++) {
      |                           ~~~~~~~~~~~~^~~~~~~
      |                                       |
      |                                       std::_Rb_tree_iterator<std::pair<const int, int> >::_Self
a.cc:28:46: error: expected ';' before ')' token
   28 |   for(auto itr=A.begin(); itr!=A.end(), itr++) {
      |                                              ^
      |                                              ;
a.cc:35:39: error: could not convert '(((void)std::operator!=(itr, B.std::map<int, int>::end())), itr.std::_Rb_tree_iterator<std::pair<const int, int> >::operator++(0))' from 'std::_Rb_tree_iterator<std::pair<const int, int> >::_Self' to 'bool'
   35 |   for(auto itr=B.begin(); itr!=B.end(), itr++) {
      |                           ~~~~~~~~~~~~^~~~~~~
      |                                       |
      |                                       std::_Rb_tree_iterator<std::pair<const int, int> >::_Self
a.cc:35:46: error: expected ';' before ')' token
   35 |   for(auto itr=B.begin(); itr!=B.end(), itr++) {
      |                                              ^
      |                                              ;
a.cc:41:15: error: 'maxA' was not declared in this scope; did you mean 'max_A'?
   41 |   cout << N - maxA - maxB << endl;
      |               ^~~~
      |               max_A
a.cc:41:22: error: 'maxB' was not declared in this scope; did you mean 'max_B'?
   41 |   cout << N - maxA - maxB << endl;
      |                      ^~~~
      |                      max_B
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
int main()
{
  int n;
  std::cin >> n;
  n /= 2;

  std::vector<int> e(n);
  std::vector<int> o(n);

  for (int i = 0; i < n; i++) {
    std::cin >> e[i];
    std::cin >> o[i];
  }

  std::sort(std::begin(e), std::end(e));
  std::sort(std::begin(o), std::end(o));

  int es = 0;
  std::vector<std::pair<int, int>> emode;
  for (int i = 1; i <= n; i++) {
    if (i == n || e[i - 1] != e[i]) {
      emode.push_back(std::make_pair(i - es, e[i - 1]));
      es = i;
    }
  }

  es = 0;
  std::vector<std::pair<int, int>> omode;
  for (int i = 1; i <= n; i++) {
    if (i == n || o[i - 1] != o[i]) {
      omode.push_back(std::make_pair(i - es, o[i - 1]));
      es = i;
    }
  }

  std::sort(std::begin(emode), std::end(emode), std::greater<std::pair<int, int>>());
  std::sort(std::begin(omode), std::end(omode), std::greater<std::pair<int, int>>());

  int ans = 0;

  if (emode[0].second != omode[0].second) {
    ans = (n - emode[0].first) + (n - omode[0].first);
  }
  else {
    if (emode.size() == 1 && omode.size() == 1) {
        ans = n;
    }
    else if (emode.size() == 1) {
      ans = (n - emode[0].first) + (n - omode[1].first);
    }
    else if (omode.size() == 1) {
      ans = (n - omode[0].first) + (n - emode[1].first);
    }
    else {
      if (emode[0].first > omode[0].first) {
        ans = (n - emode[0].first) + (n - omode[1].first);
      }
      else if (emode[0].first < omode[0].first{
        ans = (n - omode[0].first) + (n - emode[1].first);
      }
      else {
          if (emode[1].first >= omode[1].first) {
              ans = (n - omode[0].first) + (n - emode[1].first);
          }
          else {
              ans = (n - emode[0].first) + (n - omode[1].first);
          }
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:47: error: expected ')' before '{' token
   62 |       else if (emode[0].first < omode[0].first{
      |               ~                               ^
      |                                               )
a.cc:73:5: error: expected primary-expression before '}' token
   73 |     }
      |     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	int n;
	cin>>n;
	int a[n],b[n/2],c[n/2],d=0,e=0;
	rep(i,n){
		cin>>a[i];
		if(i%2==0){
			b[i/2]=a[i];
		}
		else{
			c[(i-1)/2]=a[i];
		}
	}
	int n=0;
	sort(b,b+n/2);
	sort(c,c+n/2);
	rep(i,n/2-1){
		if(b[i]!=b[i+1){
			d=max(i-n+1,d);
			n=i+1;
		}
	}
	n=0;
	rep(i,n/2-1){
		if(c[i]!=c[i+1]){
			e=max(e,i-n+1);
			n=i+1;
		}
	}
	if(d!=e){
		cout<<n-d-e<<endl;
	}
	else{
		
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: redeclaration of 'long long int n'
   18 |         int n=0;
      |             ^
a.cc:6:13: note: 'long long int n' previously declared here
    6 |         int n;
      |             ^
a.cc:22:31: error: expected ']' before ')' token
   22 |                 if(b[i]!=b[i+1){
      |                               ^
      |                               ]
Language: C++

#define _USE_MATH_DEFINES 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <math.h>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <set>
#include <locale>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;
//cout << fixed << setprecision(6);
//cout << setfill('0') << right << setw(2);

int main() {
  int n; cin >> n;
  int v, w, mode1, mode2, max1 = 0, max2 = 0;
  unordered_map<int, int> mod1, mod2;
  rep(i, n){
    if(i % 2){
      cin >> v;
      mod1[v]++;
      if(max1 < mod1[v]){
        mode1 = v;
        max1 = mod1[v];
      }
    } else {
      cin >> w;
      mod2[w]++;
      if(max2 < mod2[w]){
        mode2 = w;
        max2 = mod2[w]
      }
    }
  }
  if(n == max1 + max2 && mode1 == mode2) cout << n / 2 << endl;
  else cout << n - max1 - max2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:23: error: expected ';' before '}' token
   56 |         max2 = mod2[w]
      |                       ^
      |                       ;
   57 |       }
      |       ~
Language: C++

int main() {
  //int long long total=0,H,W,i,j;
  int n,i,a,b,ans;
  cin>>n;
  int an[n];
  for(i,n) cin>>an[i];
  a=an[0];
  b=an[1];
  for(i,n){
      if(i%2==0){
          if(an[i]!=a) ans++;
      }
      else{
          if(an[i]!=b) ans++;
      }
  }
  cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin>>n;
      |   ^~~
a.cc:6:10: error: expected ';' before ')' token
    6 |   for(i,n) cin>>an[i];
      |          ^
      |          ;
a.cc:8:10: error: expected ')' before ';' token
    8 |   b=an[1];
      |          ^
      |          )
a.cc:6:6: note: to match this '('
    6 |   for(i,n) cin>>an[i];
      |      ^
a.cc:9:10: error: expected ';' before ')' token
    9 |   for(i,n){
      |          ^
      |          ;
a.cc:17:3: error: 'cout' was not declared in this scope
   17 |   cout<<ans;
      |   ^~~~
a.cc:18:1: error: expected primary-expression before '}' token
   18 | }
      | ^
a.cc:17:13: error: expected ')' before '}' token
   17 |   cout<<ans;
      |             ^
      |             )
   18 | }
      | ~            
a.cc:9:6: note: to match this '('
    9 |   for(i,n){
      |      ^
a.cc:18:1: error: expected primary-expression before '}' token
   18 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
 int c=0,n,modeg,modek,cntk,cntg,tempk,tempg;cin>>n;int vk[n/2],vg[n/2];
  for(int i=0;i<n/2;i++){
    cin>>vg[i]>>vk[i];
  }
 
  modek = 0;
 cntk = 0;
 for(int i = 1; i < n/2; i++){
  tempk = 1;
  for(int j = i + 1; j < n/2; j++){
   if( vk[i] == vk[j]){
    tempk++;
   }
  }
  if( tempk > cntk){
   cntk = tempk;
   modek = vk[i]; 
  }
 }
  
  
  
    modeg = 0;
 cntg = 0;
 for(int i = 1; i < n/2; i++){
  tempg = 1;
  for(int j = i + 1; j < n/2; j++){
   if( vg[i] == vg[j]){
    tempg++;
   }
  }
  if( tempg > cntg){
   cntg = tempg;
   modeg = vg[i]; 
  }
 }
  

  for(int i=0;i<n/2;i++){
    if(vg[i]!=modeg)c++;
     if(vk[i]!=modek)c++;
  }
   c= (modeg!=modek) ? c:n/2
  cout<<c<<endl;
  
  
  
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:29: error: expected ';' before 'cout'
   47 |    c= (modeg!=modek) ? c:n/2
      |                             ^
      |                             ;
   48 |   cout<<c<<endl;
      |   ~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  int v[n];
  REP(i,n){
    cin>>v[i];
  }
  
  map<int,int> mpe,mpo;
  for(int i=0;i<n;i+=2){
    mpe[v[i]]++;
  }
  for(int i=1;i<n;i+=2){
    mpo[v[i]]++;
  }
  
  int cnte=0,cnto=0;
  int cntes=0,cntos=0;
  int max_e,max_o;
  for(auto p:mpe){
    if(cnte==0){
      cnte = p.second;
    }else if(cnte<p.second){
      cntes = cnte;
      cnte = p.second;
    }else if(cntes<p.second){
      cntes = p.second;
    }else{
      continue;
    }
  }
  for(auto p:mpo){
    if(cnto==0){
      cnto = p.second;
    }else if(cnto<p.second){
      cntos = cnto;
      cnto = p.second;
    }else if(cntos<p.second){
      cntos = p.second;
    }else{
      continue;
    }
  }
  int ans;
  ans = 
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:135:3: error: expected primary-expression before 'return'
  135 |   return 0;
      |   ^~~~~~
Language: C++


x=[]
y=[]
for i in range(10**5//2+1):
	x.append([i,0])
	y.append([i,0])
n=int(input())
a=list(map(int,input().split()))
for i in range(n//2):
	x[a[i*2]][1]+=1
	y[a[i*2+1]][1]+=1
x.sort(key=lambda x:-x[1])
y.sort(key=lambda x:-x[1])
if x[0][0]!=y[0][0]:
	print(n-x[0][1]-y[0][1])
else:
	print(n-max(x[0][1]+y[1][1],
		x[1][1]+y[0][1]))


Compiler output:
a.cc:2:1: error: 'x' does not name a type
    2 | x=[]
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
  int n;
  cin >> n;
  int v;
  vector<pair<int, int> > odd(MAX + 1); // cnt, num
  vector<pair<int, int> > even(MAX + 1); // cnt, num
  // init
  for ( int i = 0; i <= MAX; i++)odd[i] = even[i] = make_pair(0, i);

  for ( int i = 1; i <= n; i++){
    cin >> v;
    if ( i % 2 == 1){
        odd[v].first ++;
    } else {
        even[v].first ++;
    }
  }

  sort(odd.begin(), odd.end(), greater<pair<int,int>>);
  sort(even.begin(), even.end(), greater<pair<int,int>>);
  if( odd[MAX].second != even[MAX].second){
    cout << n - odd[MAX].first - even[MAX].first << endl;
  } else {
    cout << n - max(odd[MAX].first + even[MAX-1].first, odd[MAX-1].first - even[MAX].first)  << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:54: error: expected primary-expression before ')' token
   23 |   sort(odd.begin(), odd.end(), greater<pair<int,int>>);
      |                                                      ^
a.cc:24:56: error: expected primary-expression before ')' token
   24 |   sort(even.begin(), even.end(), greater<pair<int,int>>);
      |                                                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int n;cin >> n;
    vector<int> v(n);   //全体の配列
    rep(i,n){
        cin >> v[i];
    }
    int lim = n / 2;
    cout << lim << endl;
    vector<int> even(lim);
    vector<int> odd(lim);

    for(int i = 0;i<n;i += 2){  //偶奇の配列を作る
        even[i/2] = v[i];
        odd[i/2] = v[i+1];
    }

    //ここからmodeを求める（最頻値）(二番目も求める必要あり)

    int mode_e = even[0];
    int mode_o = odd[0];
    int mode2e = even[0];   //mode2
    int mode2o = odd[0];
    sort(all(even));
    sort(all(odd));
    int tmp = 0;    //一時
    int ct1 = 0;    //mode1の個数
    int yct1 = 0;   //mode2の個数
    int ct2 = 0;    
    int yct2 = 0;
    int tmp2;
    rep(i,lim){
        cout << even[i] << " " << odd[i] << endl;
    }


    
    rep(j,lim){
        if(j == 0)continue;
        if(even[j-1] == even[j]){
            tmp++;
            if(j == lim-1){
                tmp2 = ct1;
                ct1 = max(ct1,tmp);
                if(ct1 == tmp){ 
                    mode2e = mode_e;    //mode2の更新
                    yct1 = tmp2;        //mode2の個数
                    mode_e = even[j-1]; //modeの更新
                }
            }
        }
        else{
            tmp2 = ct1;
            ct1 = max(ct1,tmp);
            if(ct1 == tmp){ 
                mode2e = mode_e;    //mode2の更新
                yct1 = tmp2;        //mode2の個数
                mode_e = even[j-1]; //modeの更新
            }
        }
    }

    tmp = 0;
    tmp2 = 0;
    rep(k,lim){
        if(k == 0)continue;
        if(odd[k-1] == odd[k]){
            tmp++;
            if(k == lim -1){
                tmp2 = ct2;
                ct2 = max(ct2,tmp);
                if(ct2 == tmp){ //modeの更新
                    mode2o = mode_o;
                    yct2 = tmp2;
                    mode_o = odd[k-1];
                }
            }
        }
        else{
            tmp2 = ct2;
            ct2 = max(ct2,tmp);
            if(ct2 == tmp){ //modeの更新
                mode2o = mode_o;
                yct2 = tmp2;
                mode_o = odd[k-1];
            }
        }
    }

    if(mode_e == mode_o){           //1111のようなパターンを排除
        int t1 = ct1 + yct2;                        //mode2同士の大小によって、最頻値が多いほうを消すか、第二頻値を消すかの選択をする。
        int t2 = yct1 + ct2;                        //結局、even_mode1とodd_mode2 : even_mode2とodd_mode1 のペアのどちらかになるはず。
        int ans = (t1 >= t2) ? (n-t1) : (n-t2);
        cout << ans << endl;
        }
    }
    else{
        cout << n - (ct1 + ct2) - 2 << endl;
    }
}

Compiler output:
a.cc:107:5: error: expected unqualified-id before 'else'
  107 |     else{
      |     ^~~~
a.cc:110:1: error: expected declaration before '}' token
  110 | }
      | ^
Language: C++

#include "../library/lib.hpp"

class C {
public:
    ll N;
    ll V[100001]{0};
    ll ocnt[100001]{0};
    ll ecnt[100001]{0};
    ll omax = -1;
    ll oelem = -1;
    ll emax = -1;
    ll eelem = -1;
    ll omax2 = -1;
    ll emax2 = -1;

    void solve(std::istream& in, std::ostream& out) {
        in >> N;
        REP(i, N) {
            in >> V[i];
            if ((i+1) % 2 != 0) ocnt[V[i]]++;
            else ecnt[V[i]]++;

            if ((i+1) % 2 != 0 && ocnt[V[i]] > omax) {
                omax = ocnt[V[i]];
                oelem = V[i];
            } else if ((i+1) % 2 == 0 && ecnt[V[i]] > emax) {
                emax = ecnt[V[i]];
                eelem = V[i];
            }
        }

        if (oelem != eelem) {
            out << N - omax - emax << endl;
        } else {
            REP(i, N) {
                if ((i+1) % 2 != 0 && i != oelem && ocnt[i+1] > omax2) omax2 = ocnt[i];
                if ((i+1) % 2 == 0 && i != eelem && ecnt[i+1] > emax2) emax2 = ecnt[i];
            }

            out << max(N - omax - emax2, N - emax - omax2) << endl;
        }
    }
};


Compiler output:
a.cc:1:10: fatal error: ../library/lib.hpp: No such file or directory
    1 | #include "../library/lib.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
    //input
    int n,omax,emax,om,em,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];om=a;}
        if(e[b]>emax){emax=e[b];em=b;}
    }
    
    sort(o.begin(),o.end());
    sort(e.begin(),e.end());

    if(om!=em){
        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:25: error: expected ']' before ',' token
    8 |     vector<int> o[100001,0];
      |                         ^
      |                         ]
a.cc:8:26: error: expected unqualified-id before numeric constant
    8 |     vector<int> o[100001,0];
      |                          ^
a.cc:9:25: error: expected ']' before ',' token
    9 |     vector<int> e[100001,0];
      |                         ^
      |                         ]
a.cc:9:26: error: expected unqualified-id before numeric constant
    9 |     vector<int> e[100001,0];
      |                          ^
a.cc:13:9: error: 'o' was not declared in this scope
   13 |         o[a]++; e[b]++;
      |         ^
a.cc:13:17: error: 'e' was not declared in this scope
   13 |         o[a]++; e[b]++;
      |                 ^
a.cc:18:10: error: 'o' was not declared in this scope
   18 |     sort(o.begin(),o.end());
      |          ^
a.cc:19:10: error: 'e' was not declared in this scope
   19 |     sort(e.begin(),e.end());
      |          ^
Language: C++

#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
#define int long long
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
void keta(string s) {
	for (int i = 0; i < s.size(); i++) {

	}
}
int main() {
	int n = 0;
	cin >> n;
	int a = 0;
	int kisu[200000] = { 0 }, gusu[200000] = {0};
	vector<int> kisuv, gusuv;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (i % 2 == 0) {
			if (kisu[a - 1] == 0) {
				kisuv.push_back(a);
              //cout<<a<<endl;
				
			}
			kisu[a - 1]++;
		}
		else {
			if (gusu[a - 1] == 0) {
				gusuv.push_back(a);
              //cout<<a<<endl;

			}
			gusu[a - 1]++;
		}
      //cout<<gusu[1]<<endl;
	}
	int kisuf = 0, kisus = 0,kisum=0;
  //cout<<kisuv.size()<<endl;
	for (int i = 0; i < kisuv.size(); i++) {
		kisum = kisuf;
      //cout<<kisuv[i]-1<<endl;
      if(kisuf==0||kisu[kisuv[i]-1]>kisu[kisuf-1]){
		kisuf =kisuv[i];
      }
      
		if (kisuf != kisuv[i]) {
           if(kisum==0||kisu[kisuv[i]-1]>kisu[kisum-1]){
		      kisum =kisuv[i];
           }
		}
		else{
			kisus = kisum;
		}
      //cout<<kisus<<kisuf<<endl;
	}
	int gusuf = 0, gusus = 0, gusum = 0;
	for (int i = 0; i < gusuv.size(); i++) {
		if(gusuf==0||gusu[gusuv[i]-1]>gusu[gusuf-1]){
		gusuf =gusuv[i];
      }
      
		if (gusuf != gusuv[i]) {
           if(gusum==0||gusu[gusuv[i]-1]>gusu[gusum-1]){
		      gusum =gusuv[i];
           }
		}
		else{
			gusus = gusum;
		}
      //cout<<gusus<<gusuf<<endl;
	}
	
	if (gusuf != kisuf) {
		cout << n - kisu[kisuf - 1] - gusu[gusuf - 1];
      
		return 0;
	}
 // cout<<gusuf<<endl;
  //cout<<kisuf<<endl;
	int ans1 = 0, ans2 = 0;
	ans1=n- kisu[kisum - 1] - gusu[gusuf - 1];
	ans2= kisu[kisuf - 1] - gusu[gusum - 1];
	cout << max(ans1, ans2) << endl;
	return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

int main(){
    int n; cin>>n;
    int odd[100010],even[100010];
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(1%2==0)odd[v[i]]++;
        else even[v[i]]++;
    }
    sort(odd,odd+n/2);
    sort(even,even+n/2);
    
    int ans=0;
    if(odd[0]!=even[0]){
        for(int i=0;i<n;i++){
            if(i%2==0){
                if(v[i]!=odd[0])ans++;
            }else{
                if(v[i]!=even[0])ans++;
            }
        }
    }else{
        int res1=INT_MAX,res2=INT_MAX;
        for(int i=0;i<n;i++){
            if(i%2==0){
                if(v[i]!=odd[0])ans++;
            }else{
                if(v[i]!=even[1])ans++;
            }
        }
        
        for(int i=0;i<n;i++){
            if(%2==0){
                if(v[i]!=odd[1])ans++;
            }else{
                if(v[i]!=even[0])ans++;
            }
        }
        ans=min(res1,res2);
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:16: error: expected primary-expression before '%' token
   37 |             if(%2==0){
      |                ^
Language: C++

#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


int main_C() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vi V(N); REP(i, N) cin >> V[i];

    map<int, int> odd, even;
    REP(i, N) {
        if (i % 2 == 0) odd[V[i]]++;
        else even[V[i]]++;
    }

    vector<pii> oddH;
    for(auto p : odd) oddH.push_back(pii(p.first, p.second));
    vector<pii> evenH;
    for(auto p : even) evenH.push_back(pii(p.first, p.second));

    sort(oddH.begin(), oddH.end(), second_greater);
    sort(evenH.begin(), evenH.end(), second_greater);

    int ans = 0;
    if (odd.size() == 1 && even.size() == 1) {
        ans = V[0]==V[1] ? N / 2 : 0;
    } else {
        if (oddH[0].first != evenH[0].first) {
            ans = (N / 2 - oddH[0].second) + (N / 2 - evenH[0].second);
        } else {
            if (oddH[0].second + evenH[1].second >= oddH[1].second + evenH[0].second) {
                ans = (N / 2 - oddH[0].second) + (N / 2 - evenH[1].second);
            } else {
                ans = (N / 2 - oddH[1].second) + (N / 2 - evenH[0].second);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:36: error: 'second_greater' was not declared in this scope
   47 |     sort(oddH.begin(), oddH.end(), second_greater);
      |                                    ^~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;   //nは偶数
    int m = n/2;
    int v[n];
    rep(i, n) {
        cin >> v[i];
    }
    int o[m], e[m];     //v[n]の奇数番目の項がo[m],偶数番目の項がe[m]
    for(int i = 0; i < n; i += 2) {
        o[i/2] = v[i];
    }
    for(int i = 1; i < n; i += 2) {
        e[(i-1)/2] = v[i];
    }

    sort(o, o+m);
    sort(e, e+m);

    int t1 = o[0];
    int k1 = 0;
    int count_o[m];
    for(int i = 0; i < m; i++) {
        count_o[i] = 0;
    }   

    for(int i = 0; i < m; i++) {
        if(t1 < o[i]) {
            t1 = count_o[i];
            k1++;
            count_o[k1]++;
        } 
        else {
            count_o[k1]++;
        }
    }

    int t2 = e[0];
    int k2 = 0;
    int count_e[m];
    for(int i = 0; i < m; i++) {
        count_e[i] = 0;
    }   

    for(int i = 0; i < m; i++) {
        if(t2 < e[i]) {
            t2 = count_e[i];
            k2++;
            count_e[k2]++;
        } 
        else {
            count_e[k2]++;
        }
    }

    sort(cont_o, count_o + m);
    sort(cont_e, count_e + m);

    int ans = (m - count_o[m-1]) + (m - count_e[m-1]);

    cout << ans;

    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:10: error: 'cont_o' was not declared in this scope; did you mean 'count_o'?
   66 |     sort(cont_o, count_o + m);
      |          ^~~~~~
      |          count_o
a.cc:67:10: error: 'cont_e' was not declared in this scope; did you mean 'count_e'?
   67 |     sort(cont_e, count_e + m);
      |          ^~~~~~
      |          count_e
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
  int n;
  vector<int> even;
  vector<int> odd;
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    if(i%2==0){
      even.push_back(tmp);
    }else{
      odd.push_back(tmp);
    }
  }
  sort(even.begin(),even.end());
  even.push_back(0);
  sort(odd.begin(),odd.end());
  odd.push_back(0);
  int mxev=0;
  int mxevp;
  int mxod=0;
  int mxodp;
  int nw = 1;
  vector<int> evnum;
  vector<int> odnum;
  for(int i = 1; even.size() > i; i++){
    if(even[i] == even[i-1])nw++;
    else{
      if(mxev < nw){
        mxev = nw;
        mxenp = even[i-1];
      }
      evnum.push_back(nw);
      nw = 1;
    }
  }
  for(int i = 1; odd.size() > i; i++){
    if(odd[i] == odd[i-1])nw++;
    else{
      if(mxod < nw){
        mxod = nw;
        mxodp = odd[i-1];
      }
      odnum.push_back(nw);
      nw = 1;
    }
  }
  sort(odnum.begin(),odnum.end() greater<int>);
  sort(evnum.begin(),evnum.end() greater<int>);
  if(mxodp == mxevp){
    cout << n - max(odnum[1]+evnum[0],odnum[0]+evnum[1]) << endl;
  }else{
    cout << n - mxodp+mxevp << endl;
    
}
      
      
      
      
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'mxenp' was not declared in this scope; did you mean 'mxevp'?
   34 |         mxenp = even[i-1];
      |         ^~~~~
      |         mxevp
a.cc:51:33: error: expected ')' before 'greater'
   51 |   sort(odnum.begin(),odnum.end() greater<int>);
      |       ~                         ^~~~~~~~
      |                                 )
a.cc:52:33: error: expected ')' before 'greater'
   52 |   sort(evnum.begin(),evnum.end() greater<int>);
      |       ~                         ^~~~~~~~
      |                                 )
a.cc:58:2: error: expected '}' at end of input
   58 | }
      |  ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int n;
  cin >> n;
  vector< vector<int> > v(2, vector<int>(n/2));
  vector< vector<pair<int, int> > > ans_cnt(2);
  rep(i, n/2) cin >> v[0][i] >> v[1][i];

  sort(all(v[0]));
  sort(all(v[1]));

  int ans = 0;
  rep(k, 2) {
    int cnt = 1, tmp_ans = 1;
    for (int i = 1; i < n/2; i++) {
      if (v[k][i] == v[k][i-1]) {
        cnt++;
        tmp_ans = max(tmp_ans, cnt);
      } else {
        ans_cnt[k].push_back(make_pair(cnt, v[k][i-1]));
        cnt = 1;
      }
    }
    if (cnt != 1) ans_cnt[k].push_back(make_pair(cnt, v[k][n/2-1]));
    ans += tmp_ans;
  }

  sort(all(ans_cnt[0]));
  sort(all(ans_cnt[1]));
  reverse(all(ans_cnt[0]));
  reverse(all(ans_cnt[1]));

  if (ans_cnt[0][0].second == ans_cnt[1][0].second) {
    if (ans == n) {
      ans = n / 2;
    } else {
      ans = n - max(abs(ans_cnt[0][0].first+ans_cnt[1][1].first),
                    abs(ans_cnt[0][1].first+ans_cnt[1][0].first));
    }
  } else {
    ans = n - ans;
  }

  cout << ans << endl;

  return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:51:12: error: expected '}' at end of input
   51 |   return 0;
      |            ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int a[100005]={},b[100005]={};
    int n;
    cin >> n;
    rep(i,n){
        int tmp;
        cin >> tmp;
        if(i%2)b[tmp]++;
        else a[tmp]++;
    }
    int ma=0,mb=0,res=0,ia,ib,ma2,mb2;
    rep(i,100005){
        res+=a[i];
        if(ma<=a[i]){
            ma2=ma;
            ma=a[i];
            ia=i;
        }else if(ma2<=a[i])ma2=a[i];
    }
    rep(i,100005){
       res+=b[i];
        if(mb=<b[i]){
            mb2=mb;
            mb=b[i];
            ib=i;
        }else if(mb2<=b[i])mb2=b[i];
    }
    if(ia==ib)cout << min(res-ma-mb2,res-ma2-mb) << endl;
    else cout << res-ma-mb << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:15: error: expected primary-expression before '<' token
   30 |         if(mb=<b[i]){
      |               ^
Language: C++

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll n;
  cin >> n;
  ll v[n];
  rep(i, n) cin >> v[i];

  ll cnt[2][100001] = {};
  rep(odd, 2) rep(i, n/2) cnt[odd][v[2*i+odd]]++;
  P first[] = {P(-1, 0), P(-1, 0)};
  P second[] = {P(-1, 0), P(-1, 0)};
  rep(odd, 2) rep(i, 100001){
    if(first[odd].second < cnt[odd][i]){
      second[odd] = first[odd];
      first[odd] = P(i, cnt[odd][i]);
    }
    else if(second[odd].second < cnt[odd][i]){
      second[odd] = P(i, cnt[odd][i])
    }
  }

  ll ans;
  if(first[0].first != first[1].first) ans = n - first[0].second - first[1].second;
  else if(second[0].second < second[1].second) ans = n - first[0].second - second[1].second;
  else ans = n - first[1].second - second[0].second;
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:38: error: expected ';' before '}' token
   32 |       second[odd] = P(i, cnt[odd][i])
      |                                      ^
      |                                      ;
   33 |     }
      |     ~
Language: C++

//#include <bits/stdc++.h>
#include <stack>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	//入力
	long a[100000], b[100000], x[100000] = {};
	long N, M = 1000000000, ans = 100000,ans1 =100000, C = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) cin >> a[i / 2];
		else cin >> b[i / 2];
	}
	//処理
	for (int j = 0; j < N / 2; j++){
		x[a[j]]++;
	}
	for (int l = 0; l < 100000; l++) {
		ans = min(N/2 -x[l],ans);
	}
	long x[100000] = {};
	for (int k = 0; k < N / 2; k++) {
		x[b[k]]++;
	}
	for (int m = 0; m < 100000; m++) {
		ans1 = min(N / 2 - x[m], ans);
	}
	//出力
	cout << ans + ans1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: redeclaration of 'long int x [100000]'
   23 |         long x[100000] = {};
      |              ^
a.cc:9:36: note: 'long int x [100000]' previously declared here
    9 |         long a[100000], b[100000], x[100000] = {};
      |                                    ^
Language: C++

//#include <bits/stdc++.h>
#include <stack>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	//入力
	long a[100000], b[100000], x[100000] = {};
	long N, M = 1000000000, ans = 0,ans1 =0, C = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) cin >> a[i / 2];
		else cin >> b[i / 2];
	}
	//処理
	for (int j = 0; j < N / 2; j++){
		x[a[j]]++;
	}
	for (int l = 0; l < 100000; l++) {
		ans = min(N/2 -x[l],ans);
	}
	long x[100000] = {};
	for (int k = 0; k < N / 2; k++) {
		x[b[k]]++;
	}
	for (int m = 0; m < 100000; m++) {
		ans1 = min(N / 2 - x[m], ans);
	}
	//出力
	cout << ans + ans1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: redeclaration of 'long int x [100000]'
   23 |         long x[100000] = {};
      |              ^
a.cc:9:36: note: 'long int x [100000]' previously declared here
    9 |         long a[100000], b[100000], x[100000] = {};
      |                                    ^
Language: C++


n = input()

v = list(map(int,input().split()))

eve = []
odd = []

for i in range(len(v)):

    if (i % 2 == 1):
        eve.append(v[i])
    else:
        odd.append(v[i])

dic_o = {}
dic_e = {}

dic_o[-1] = 0
dic_e[-1] = 0
#print (dic_o)

for i in odd:

    if ( i in dic_o.keys() ):
        dic_o[i] += 1
    else:
        dic_o[i] = 1


for i in eve:

    if ( i in dic_e.keys() ):
        dic_e[i] += 1
    else:
        dic_e[i] = 1

omax = 0
emax = 0
bul = True

while bul:

    omax = -1
    emax = -1

    for i in dic_o:
        
        if omax < 0:
            omax = i
        
        elif dic_o[i] > dic_o[omax] :
            omax = i

    for i in dic_e:

        if emax < 0:
            emax = i
        
        elif dic_e[i] > dic_e[emax] :
            emax = i

    if omax != emax :
        bul = False

    else:

        print(dic_o,dic_e)
        
        flag = True
        
        for i in dic_e:
            if dic_e[i] == dic_e[emax] and i != emax:
                emax = i
                flag = False
                bul = False

        if flag:
            for i in dic_o:
                if dic_o[i] == dic_o[emax] and i != omax:
                    omax = i
                    flag = False
                    bul = False

        if flag:
        
            if dic_o[omax] > dic_e[emax]:
        
                dic_e.pop(emax)

            else:

                dic_o.pop(omax)

    
emax_n = dic_e[emax]
omax_n = dic_o[omax]

#print (dic_o,dic_e)
#print (omax,emax)
print ( (len(odd) - omax_n) + (len(eve) - emax_n))

Compiler output:
a.cc:21:2: error: invalid preprocessing directive #print
   21 | #print (dic_o)
      |  ^~~~~
a.cc:99:2: error: invalid preprocessing directive #print
   99 | #print (dic_o,dic_e)
      |  ^~~~~
a.cc:100:2: error: invalid preprocessing directive #print
  100 | #print (omax,emax)
      |  ^~~~~
a.cc:2:1: error: 'n' does not name a type
    2 | n = input()
      | ^
a.cc:17:1: error: 'dic_e' does not name a type
   17 | dic_e = {}
      | ^~~~~
a.cc:19:1: error: 'dic_o' does not name a type
   19 | dic_o[-1] = 0
      | ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int v[N];
  vector<int> A,B;
  int testa[100000];
  int testb[100000];
  for (int i = 0; i < 100001; ++i) testa[i] = 0;
  for (int i = 0; i < 100001; ++i) testb[i] = 0;
  
  for (int i = 0; i < N; ++i) {
    scanf("%d", &v[i]);
    if(i%2==0){
      A.push_back(v[i]);
      ++testa[v[i]];
    }
    else{
      B.push_back(v[i]);
      ++testb[v[i]];
    }
  }

  int maxa=v[0];
  int nexta=0;
  int maxb=v[1]; 
  int nextb = 0;
  for (int i = 0; i < 100001; ++i){
    if(testa[maxa]=<testa[i]){
      nexta = maxa;
      maxa = i;
    }
    if(testb[maxb]=<testb[i]){
      nextb = maxb;
      maxb = i;
    }
  }


  //cout << maxa << endl;
  //cout << maxb << endl;
  //cout << nexta << endl;
  //cout << nextb << endl;




  bool flip = true;
  int count = 0;
  int ans = 0;

  if(maxa==maxb){
    for (int i = 0; i < N; ++i){
      if(flip){
        if(v[i]!=nexta) ++count;
        flip = false;
      }
      else{
        if(v[i]!=maxb) ++count;
        flip = true;
      }
    }
    ans = count;
    count = 0;
    flip = true;
    for (int i = 0; i < N; ++i){
      if(flip){
        if(v[i]!=maxa) ++count;
        flip = false;
      }
      else{
        if(v[i]!=nextb) ++count;
        flip = true;
      }
    }
    if(count<ans) ans = count;
  }



  else{

  for (int i = 0; i < N; ++i){
    if(flip){
      if(v[i]!=maxa) ++ans;
      flip = false;
    }
    else{
      if(v[i]!=maxb) ++ans;
      flip = true;
    }
  }

  }

  cout << ans << endl;


}



Compiler output:
a.cc: In function 'int main()':
a.cc:31:20: error: expected primary-expression before '<' token
   31 |     if(testa[maxa]=<testa[i]){
      |                    ^
a.cc:35:20: error: expected primary-expression before '<' token
   35 |     if(testb[maxb]=<testb[i]){
      |                    ^
Language: C++

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define pii pair<int,int>
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vi e(1e5+1,0),o(1e5+1,0);
	REP(i,n){
		int v;
		cin>>v;
		if(i%2) o[v]++;
		else e[v]++;
	}
	
	int nume,numo,cnte=0,cnte2=0,cnto=0,cnto2=0;
	for(int i=1;i<=100000;++i){
		if(e[i]>cnte){
			cnte2=cnte;
			cnte=e[i];
			nume=i;
		}else if(e[i]>cnte2){
			cnte2=e[i];
		}
		
		if(o[i]>cnto){
			cnto2=cnto;
			cnto=o[i];
			numo=i;
		}else if(o[i]>cnto2){
			cnto2=o[i];
		}
	}
	
	if(nume!=numo) cout<<n-(cnte+cnto)<<endl;
	else n-max(cnte+cnto2,cnte2+cnto)<<endl;
}//解説解答参考.

Compiler output:
a.cc: In function 'int main()':
a.cc:45:42: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   45 |         else n-max(cnte+cnto2,cnte2+cnto)<<endl;
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~