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

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll ev[200000], od[200000];
    vector<pair<ll, ll> > even, odd;
    ll n;
    ll v;
    cin>>n;
    MEMSET(ev, 0); MEMSET(od, 0);
    rep(i, n){
        cin>>v;
        if(i%2==0) ev[v]++;
        else od[v]++;
    }
    rep(i, 200000) if(ev[i]!=0) even.push_back({ev[i], i});
    rep(i, 200000) if(od[i]!=0) odd.push_back({od[i], i});
    sort(all(even)); sort(all(odd));
    if(even[even.size()-1].second!=odd[odd.size()-1].second){
        cout<<n-even[even.size()-1].first-odd[odd.size()-1].first<<endl;
    }
    else{
        ll Minim=200000;
        if(even.size()>=2) Miaxim=max(even[even.size()-2].first+odd[odd.size()-1].first, Maxim);
        if(odd.size()>=2) Maxim=max(even[even.size()-1].first+odd[odd.size()-2].first, Maxim);
        if(even.size()==odd.size()) Maxim=n/2;
        cout<<n-Maxim<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:28: error: 'Miaxim' was not declared in this scope; did you mean 'Minim'?
   44 |         if(even.size()>=2) Miaxim=max(even[even.size()-2].first+odd[odd.size()-1].first, Maxim);
      |                            ^~~~~~
      |                            Minim
a.cc:44:90: error: 'Maxim' was not declared in this scope
   44 |         if(even.size()>=2) Miaxim=max(even[even.size()-2].first+odd[odd.size()-1].first, Maxim);
      |                                                                                          ^~~~~
a.cc:45:27: error: 'Maxim' was not declared in this scope
   45 |         if(odd.size()>=2) Maxim=max(even[even.size()-1].first+odd[odd.size()-2].first, Maxim);
      |                           ^~~~~
a.cc:46:37: error: 'Maxim' was not declared in this scope
   46 |         if(even.size()==odd.size()) Maxim=n/2;
      |                                     ^~~~~
a.cc:47:17: error: 'Maxim' was not declared in this scope
   47 |         cout<<n-Maxim<<endl;
      |                 ^~~~~
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; i += 2) {
            int key = array[i];
            map.put(key, map.getOrDefault(key, 0) + 1);
            
        }
        
        int evencount = -1;
        int evennum = -1;
        for (Integer key : map.keySet()) {
            int val = map.get(key);
            if (val > evencount) {
                evennum = key;
                evencount = val;
            }
        }
        
        map = new HashMap<Integer, Integer>();
        for (int i = 1; i < n; i += 2) {
            int key = array[i];
            map.put(key, map.getOrDefault(key, 0) + 1);
            
        }
        
        int oddcount = -1;
        int oddnum = -1;
        for (Integer key : map.keySet()) {
            int val = map.get(key);
            if (val > oddcount) {
                oddnum = key;
                oddcount = val;
            }
        }
        
        if (evennum == oddnum && evencount == n / 2 && oddcount == n / 2) {
            System.out.println(n/2);
        } else if (evennum == oddnum) {
            System.out.println(Math.min(n/2-
        System.out.println(oddnum);
        
    }
}

Compiler output:
Main.java:51: error: ')' or ',' expected
        System.out.println(oddnum);
                                  ^
Main.java:54: error: reached end of file while parsing
}
 ^
2 errors
Language: C++

#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n/2), b(n/2);
    vector<int> ac(100001), bc(100001);
    for(int i=0; i<n; i++)
    {
        if(i%2 == 0)
        {
            cin >> at.(i/2);
            ac.at(a.at(i/2))++;
        }
        else
        {
            cin >> b.at(i/2);
            bc.at(b.at(i/2))++;
        }
    }
    int maxa = 0, maxb = -1, maxa2 = 0, maxb2 = -1, ansa, ansb;
    for(int i=1; i<100001; i++)
    {
        if(ac.at(i) > maxa)
        {
            maxa2 = maxa;
            maxa = ac.at(i);
            ansa = i;
        }
        else if(ac.at(i) > maxa2) maxa2 = ac.at(i);
        if(bc.at(i) > maxb)
        {
            maxb2 = maxb;
            maxb = bc.at(i);
            ansb = i;
        }
        else if(bc.at(i) > maxb2) maxb2 = bc.at(i);
    }
    if(ansa != ansb) cout << n - maxa - maxb << endl;
    else cout << min(n - maxa2 - maxb, n - maxa - maxb2) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:20: error: 'at' was not declared in this scope; did you mean 'ac'?
   38 |             cin >> at.(i/2);
      |                    ^~
      |                    ac
a.cc:38:23: error: expected unqualified-id before '(' token
   38 |             cin >> at.(i/2);
      |                       ^
Language: C++

#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n/2), b(n/2);
    vector<int> ac(100001), bc(100001);
    for(int i=0; i<n; i++)
    {
        if(i%2 == 0)
        {
            cin >> at(i/2);
            ac.at(a.at(i/2))++;
        }
        else
        {
            cin >> b.at(i/2);
            bc.at(b.at(i/2))++;
        }
    }
    int maxa = 0, maxb = -1, maxa2 = 0, maxb2 = -1, ansa, ansb;
    for(int i=1; i<100001; i++)
    {
        if(ac.at(i) > maxa)
        {
            maxa2 = maxa;
            maxa = ac.at(i);
            ansa = i;
        }
        else if(ac.at(i) > maxa2) maxa2 = ac.at(i);
        if(bc.at(i) > maxb)
        {
            maxb2 = maxb;
            maxb = bc.at(i);
            ansb = i;
        }
        else if(bc.at(i) > maxb2) maxb2 = bc.at(i);
    }
    if(ansa != ansb) cout << n - maxa - maxb << endl;
    else cout << min(n - maxa2 - maxb, n - maxa - maxb2) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:20: error: 'at' was not declared in this scope; did you mean 'ac'?
   38 |             cin >> at(i/2);
      |                    ^~
      |                    ac
Language: C++

#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <utility>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

ll main()
{
    ll n;
    cin >> n;
    map<int, int> v1, v2;
    repi(i, n, 0)
    {
        ll v;
        cin >> v;
        if (i & 1)
        {
            v1[v]++;
        }
        else
        {
            v2[v]++;
        }
    }
    ll m1 = 0, m2 = 0, val1, val2, prev1 = 0, prev2 = 0;
    for (auto itr = v1.begin(); itr != v1.end(); itr++)
    {
        if (m1 <= itr->second)
        {
            prev1 = m1;
            val1 = itr->first;
            m1 = itr->second;
        }
    }
    for (auto itr = v2.begin(); itr != v2.end(); itr++)
    {
        if (m2 <= itr->second)
        {
            prev2 = m2;
            val2 = itr->first;
            m2 = itr->second;
        }
    }
    if (val1 != val2)
    {
        cout << n - m1 - m2 << endl;
    }
    else
    {
        cout << (prev1 + m2 > prev2 + m1 ? n - prev1 - m2 : n - prev2 - m1) << endl;
    }
    return 0;
}

Compiler output:
a.cc:12:1: error: '::main' must return 'int'
   12 | ll main()
      | ^~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  vector<int> odd(5e+1,0),even(5e+1,0);
  for(int i=0;i<n;i+=2) odd[v[i]]++;
  for(int i=1;i<n;i+=2) even[v[i]]++;
  int ido=(int)(max_element(odd.begin(),odd.end())-odd.begin());
  int ide=(int)(max_element(even.begin(),even.end())-even.begin());
  int mo=*max_element(odd.begin(),odd.end());
  int me=*max_element(even.begin(),even.end());
  int ans
  if(ido==ide){
    sort(odd.begin(),odd.end());
    sort(even.begin(),even.end());
    ans=max(mo+*(even.end()-2),me+*(odd.end()-2));
  }
  else{
    ans=mo+me;
  }
  cout<<ans<<endl;
  return 0;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: expected initializer before 'if'
   18 |   if(ido==ide){
      |   ^~
a.cc:23:3: error: 'else' without a previous 'if'
   23 |   else{
      |   ^~~~
a.cc:24:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |     ans=mo+me;
      |     ^~~
      |     abs
a.cc:26:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   26 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>a[i];
  }
  int count=0;
  for(int i=1;i<=n/2;i++){
    if(a[2*i-1]!=a[2*i]){
      if(a[2*i-1]==a[1]&&a[2*i]==a[2]){
        continue;
      }
      else{
        count++;
      }
    }
    else{
      count++;
    }
  }
  cout<<count;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'a' was not declared in this scope
    7 |     cin>a[i];
      |         ^
a.cc:11:8: error: 'a' was not declared in this scope
   11 |     if(a[2*i-1]!=a[2*i]){
      |        ^
Language: C++

// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
        // return a.first < b.first; // 昇順
        return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
        ll onajif=-1;

    cin>>n;
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    multiset<ll> odd;
    multiset<ll> even;
        ll onajif=-1;
    rep(i,n-1){
        if(v[i]!=v[i+1]) onajif=0;
    }
    if(onajif){
        cout<<n/2<<endl;
        return 0;
    }

    rep(i,n){
        if(i%2){
            odd.insert(v[i]);
        }else{
            even.insert(v[i]);
        }
    }
    vector<pair<ll,ll>> od(odd.size());
    vector<pair<ll,ll>> ev(even.size());
    ll j=0;
    for(auto itr=odd.begin();itr!=odd.end();++itr,++j){
        od[j]=make_pair(odd.count(*itr),*itr);
    }
    j=0;
    for(auto itr=even.begin();itr!=even.end();++itr,++j){
        ev[j]=make_pair(even.count(*itr),*itr);
    }
    rep(i,n-1){
        if(v[i]!=v[i+1]) onajif=0;
    }
    sort(od.begin(),od.end(),my_compare);
    sort(ev.begin(),ev.end(),my_compare);
    if(od[0].second!=ev[0].second){
        cout<<n-od[0].first-ev[0].first<<endl;
    }else if(od[0].first+ev[1].first>od[1].first+ev[0].first){
        cout<<n-od[0].first-ev[1].first<<endl;
    }else{
        cout<<n-od[1].first-ev[0].first<<endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:12: error: redeclaration of 'long long int onajif'
   46 |         ll onajif=-1;
      |            ^~~~~~
a.cc:39:12: note: 'long long int onajif' previously declared here
   39 |         ll onajif=-1;
      |            ^~~~~~
Language: C++

// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
        // return a.first < b.first; // 昇順
        return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    multiset<ll> odd;
    multiset<ll> even;
        ll onajif=-1;
    rep(i,n-1){
        if(v[i]!=v[i+1]) onajif=0;
    }
    if(onajif){
        cout<<n/2<<endl;
        return 0;
    }

    rep(i,n){
        if(i%2){
            odd.insert(v[i]);
        }else{
            even.insert(v[i]);
        }
    }
    vector<pair<ll,ll>> od(odd.size());
    vector<pair<ll,ll>> ev(even.size());
    ll j=0;
    for(auto itr=odd.begin();itr!=odd.end();++itr,++j){
        od[j]=make_pair(odd.count(*itr),*itr);
    }
    j=0;
    for(auto itr=even.begin();itr!=even.end();++itr,++j){
        ev[j]=make_pair(even.count(*itr),*itr);
    }
    ll onajif=-1;
    rep(i,n-1){
        if(v[i]!=v[i+1]) onajif=0;
    }
    sort(od.begin(),od.end(),my_compare);
    sort(ev.begin(),ev.end(),my_compare);
    if(od[0].second!=ev[0].second){
        cout<<n-od[0].first-ev[0].first<<endl;
    }else if(od[0].first+ev[1].first>od[1].first+ev[0].first){
        cout<<n-od[0].first-ev[1].first<<endl;
    }else{
        cout<<n-od[1].first-ev[0].first<<endl;
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:8: error: redeclaration of 'long long int onajif'
   70 |     ll onajif=-1;
      |        ^~~~~~
a.cc:44:12: note: 'long long int onajif' previously declared here
   44 |         ll onajif=-1;
      |            ^~~~~~
Language: C++

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

int main(){
  long long n;
  cin >> n;
  
  vector<long long> v(n);
  for(long long i=0;i<n;i++){
    cin >> v[i];
  }
  
  vector<long long> o(n/2);
  for(long long i=0;i<n/2;i++){
    o[i]=v[2*i];
  }
  
  vector<long long> e(n/2);
  for(long long i=0;i<n/2;i++){
    e[i]=v[2*i+1];
  }


  map<int, int> cnt;
  for (int x : o) {
    if (cnt.count(x)) {
      // 既に含まれているならインクリメント
      cnt.at(x)++;
    } else {
      // 含まれていないなら、1を追加
      cnt[x] = 1;
    }
  }

  int max_cnt = 0;  // 出現回数の最大値を保持
  int ans = -1;     // 出現回数が最大になる値を保持
  for (int x : o) {
    // 今見ているxの出現回数が、その時点の最大よりも大きければ更新
    if (max_cnt < cnt.at(x)) {
      max_cnt = cnt.at(x);
      ans = x;
    }
  }

  map<int, int> cnt;
  for (int y : e) {
    if (cnt.count(x)) {
      // 既に含まれているならインクリメント
      cnt.at(y)++;
    } else {
      // 含まれていないなら、1を追加
      cnt[y] = 1;
    }
  }

  int max_cnth = 0;  // 出現回数の最大値を保持
  int answ = -1;     // 出現回数が最大になる値を保持
  for (int y : e) {
    // 今見ているxの出現回数が、その時点の最大よりも大きければ更新
    if (max_cnth < cnt.at(y)) {
      max_cnth = cnt.at(y);
      answ = y;
    }
  }
  
  if(x!=y){
    cout << n-max_cnt-max_cnth << endl;
  }
  
}
    
    
  


  
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:45:17: error: redeclaration of 'std::map<int, int> cnt'
   45 |   map<int, int> cnt;
      |                 ^~~
a.cc:24:17: note: 'std::map<int, int> cnt' previously declared here
   24 |   map<int, int> cnt;
      |                 ^~~
a.cc:47:19: error: 'x' was not declared in this scope
   47 |     if (cnt.count(x)) {
      |                   ^
a.cc:66:6: error: 'x' was not declared in this scope
   66 |   if(x!=y){
      |      ^
a.cc:66:9: error: 'y' was not declared in this scope
   66 |   if(x!=y){
      |         ^
Language: C++

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

const ll MOD=1000000007;

int  main(){
  int n;
  cin>>n;
  vector<pair<int,int>>K;
  vector<pair<int,int>>G;
  vector<int>KI(n/2);
  vector<int>GU(n/2);
  for(int i=0;i<n/2;i++){
    cin>>KI.at(i)>>GU.at(i);
  }
  sort(KI.begin(),KI.end());
  sort(GU.begin(),GU.end());
  K.push_back(make_pair(1,KI.at(0)));
  G.push_back(make_pair(1,GU.at(0)));
  for(int i=1;i<n/2){
    if(K.at(K.size()-1).second==KI.at(i)){
      K.at(K.size()-1).first++;
    }
    else{
      K.push_back(make_pair(1,KI.at(i)));
    }
    if(G.at(K.size()-1).second==GU.at(i)){
      G.at(K.size()-1).first++;
    }
    else{
      G.push_back(make_pair(1,GU.at(i)));
    }
  }
  K.push_back(make_pair(0,-1));
  G.push_back(make_pair(0,-1));
  sort(K.begin(),K.end());
  reverse(K.begin(),K.end());
  sort(G.begin(),G.end());
  reverse(G.begin(),G.end());
  if(K.at(0).second==G.at(0).second){
    cout<<n-max(K.at(0).first+G.at(1).first,K.at(1).first+G.at(0).first)<<endl;
  }
  else{
    cout<<n-K.at(0).first-G.at(0).first<<endl;
  }
}
    
  
  
  
    


Compiler output:
a.cc: In function 'int main()':
a.cc:22:20: error: expected ';' before ')' token
   22 |   for(int i=1;i<n/2){
      |                    ^
      |                    ;
Language: C++

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

const ll MOD=1000000007;

int  main(){
  int n;
  cin>>n;
  vector<pair<int,int>>K;
  vector<pair<int,int>>G;
  vector<int>KI(N/2);
  vector<int>GU(N/2);
  for(int i=0;i<N/2;i++){
    cin>>KI.at(i)>>GU.at(i);
  }
  sort(KI.begin(),KI.end());
  sort(GU.begin(),GU.end());
  K.push_back(make_pair(1,KI.at(0)));
  G.push_back(make_pair(1,GU.at(0)));
  for(int i=1;i<n/2){
    if(K.at(K.size()-1).second==KI.at(i)){
      K.at(K.size()-1).first++;
    }
    else{
      K.push_back(make_pair(1,KI.at(i)));
    }
    if(G.at(K.size()-1).second==GU.at(i)){
      G.at(K.size()-1).first++;
    }
    else{
      G.push_back(make_pair(1,GU.at(i)));
    }
  }
  K.push_back(make_pair(0,-1));
  G.push_back(make_pair(0,-1));
  sort(K.begin(),K.end());
  reverse(K.begin(),K.end());
  sort(G.begin(),G.end());
  reverse(G.begin(),G.end());
  if(K.at(0).second==G.at(0).second){
    cout<<n-max(K.at(0).first+G.at(1).first,K.at(1).first+G.at(0).first)<<endl;
  }
  else{
    cout<<n-K.at(0).first-G.at(0).first<<endl;
  }
}
    
  
  
  
    


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'N' was not declared in this scope
   13 |   vector<int>KI(N/2);
      |                 ^
a.cc:22:20: error: expected ';' before ')' token
   22 |   for(int i=1;i<n/2){
      |                    ^
      |                    ;
Language: C++

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

const ll MOD=1000000007;

int  main(){
  int n;
  cin>>n;
  vector<pair<int,int>>K;
  vector<pair<int,int>>G;
  vector<int>KI(N/2);
  vector<int>GU(N/2);
  for(int i=0;i<N/2;i++){
    cin>>KI.at(i)>>GU.at(i);
  }
  sort(KI.begin(),KI.end());
  sort(GU.begin(),GU.end());
  K.push_back(make_pair(1,KI.at(0)));
  G.push_back(make_pair(1,GU.at(0)));
  for(int i=1;i<N/2){
    if(K.at(K.size()-1).second==KI.at(i)){
      K.at(K.size()-1).first++;
    }
    else{
      K.push_back(make_pair(1,KI.at(i)));
    }
    if(G.at(K.size()-1).second==GU.at(i)){
      G.at(K.size()-1).first++;
    }
    else{
      G.push_back(make_pair(1,GU.at(i)));
    }
  }
  K.push_back(make_pair(0,-1));
  G.push_back(make_pair(0,-1));
  sort(K.begin(),K.end());
  reverse(K.begin(),K.end());
  sort(G.begin(),G.end());
  reverse(G.begin(),G.end());
  if(K.at(0).second==G.at(0).second){
    cout<<n-max(K.at(0).first+G.at(1).first,K.at(1).first+G.at(0).first)<<endl;
  }
  else{
    cout<<n-K.at(0).first-G.at(0).first<<endl;
  }
}
    
  
  
  
    


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'N' was not declared in this scope
   13 |   vector<int>KI(N/2);
      |                 ^
a.cc:22:20: error: expected ';' before ')' token
   22 |   for(int i=1;i<N/2){
      |                    ^
      |                    ;
Language: C++

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

const ll MOD=1000000007;

int  main(){
  int n;
  cin>>n;
  vector<pair<int,int>>K;
  vector<pair<int,int>>G;
  int A,B;
  cin>>A>>B;
  K.push_back(make_pair(1,A));
  G.push_back(make_pair(1,B));
  for(int i=0;i<N/2-1;i++){
    int a,b;
    cin>>a>>b;
    bool flagK=true;
    bool flagG=true;
    for(int i=0;i<K.size();i++){
      if(a==K.at(i).second){
        K.at(i).first=K.at(i).first+1;
        flagK=false;
      }
    }
    if(flagK){
      K.push_back(make_pair(1,a));
    }
    for(int i=0;i<G.size();i++){
      if(b==G.at(i).second){
        G.at(i).first=G.at(i).first+1;
        flagG=false;
      }
    }
    if(flagG){
      G.push_back(make_pair(1,b));
    }
  }
  K.push_back(make_pair(0,-1));
  G.push_back(make_pair(0,-1));
  sort(K.begin(),K.end());
  reverse(K.begin(),K.end());
  sort(G.begin(),G.end());
  reverse(G.begin(),G.end());
  if(K.at(0).second()==G.at(0).second){
    cout<<N-max(K.at(0).first+G.at(1).first,K.at(1).first+G.at(0).first)<<endl;
  }
  else{
    cout<<N-K.at(0).first-G.at(0).first<<endl;
  }
}
    
  
  
  
    

Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'N' was not declared in this scope
   17 |   for(int i=0;i<N/2-1;i++){
      |                 ^
a.cc:47:20: error: expression cannot be used as a function
   47 |   if(K.at(0).second()==G.at(0).second){
      |      ~~~~~~~~~~~~~~^~
a.cc:48:11: error: 'N' was not declared in this scope
   48 |     cout<<N-max(K.at(0).first+G.at(1).first,K.at(1).first+G.at(0).first)<<endl;
      |           ^
a.cc:51:11: error: 'N' was not declared in this scope
   51 |     cout<<N-K.at(0).first-G.at(0).first<<endl;
      |           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n, ve[100001], vo[100001];
  cin >> n;

  memset(ve, 0, sizeof(ve));
  memset(vo, 0, sizeof(vo));

  for (int i = 0; i < n; i++) {
    int v; cin >> v;

    if (i & 1) {
      vo[v]++;
    } else {
      ve[v]++;
    }
  }

  int ov[2], on[2], ev[2], en[2];
  memset(on, 0x7f, sizeof(on));
  memset(en, 0x7f, sizeof(en));
  on[0] = en[0] = n/2;

  for (int i = 0; i <= 100000; i++) {
    if (on[0] > n - vo[i]) {
      on[1] = on[0];
      on[0] = n - vo[i];
      ov[1] = ov[0];
      ov[0] = i;
    } else if(on[1] > n - vo[i]) {
      on[1] = n - vo[i];
      ov[1] = i;
    }
    if (en[0] > n - ve[i]) {
      en[1] = en[0];
      en[0] = n - ve[i];
      ev[1] = ev[0];
      ev[0] = i;
    } else if(en[1] > ve[i]) {
      en[1] = n - ve[i];
      ev[1] = i;
    }
  }

  if (ev[0] != ov[0]) {
    cout << en[0] + on[0] << endl;
  } else {
    cout << min(en[0] + on[1], en[1], on[0]) << endl;
  }

  return 0;
}

Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:51:16:   required from here
   51 |     cout << min(en[0] + on[1], en[1], on[0]) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: C++

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


int main() {
   int n;
    cin >> n;
    vector<int> v(n);

    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    map<int, int> p,q;
    for(int i = 0; i < n; i += 2) {
        p[v[i]] += 1;
    }

    for(int i = 1; i < n; i += 2) {
        q[v[i]] += 1;
    }   
    int max1 = -1;
    int max2 = -1;
    int a, b;
    for(int i = 0; i < n; i++) {
        if(max1 < p[v[i]] && i % 2 == 0) { max1 = p[v[i]]; a = v[i]; }
        else if(max2 < p[v[i]] && i % 2 != 0) { max2 = q[v[i]]; b = v[i];}
    }

    if(a == b && max1 == n / 2 && max2 == n / 2) { cout << max1; return 0; }
    if(a == b && max1 >= max2) {
        int s = max2;
        max2 = -1;
        for(int i = 1; i < n; i += 2) {
            if(p[v[i]] =< s && q[v[i]] >= max2 && v[i] != a) max2 = q[v[i]];
        }
    }else if(a == b && max1 < max2) {
        int t = max1;
        max1 = -1;
        for(int i = 0; i < n; i += 2) {
            if(p[v[i]] <= t && p[v[i]] >= max1 && v[i] != a) max1 = p[v[i]];
        }
    }
    int ans = n / 2 - max1 + n / 2 - max2;
   
   cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:25: error: expected primary-expression before '<' token
   35 |             if(p[v[i]] =< s && q[v[i]] >= max2 && v[i] != a) max2 = q[v[i]];
      |                         ^
Language: C++

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

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
  if(a.second != b.second) return a>b;
  else return true;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> v(n);
  for(ll i=0;i<n;++i) cin>>v[i];
  map<ll,ll> m_odd,m_even;
  for(ll i=0;i<n;i+=2){
    m_odd[v[i]]++;
  }
  for(ll i=1;i<n;i+=2){
    m_even[v[i]]++;
  }
  vector<pair<ll, ll>> odd_count;
  vector<pair<ll, ll>> even_count;
  for(auto& x : m_odd) {
    odd_count.push_back(make_pair( x.first , x.second ));
  }
  for(auto& x : m_even) {
    even_count.push_back(make_pair( x.first , x.second ));
  }
  odd_count.push_back(make_pair(0,0));
  even_count.push_back(make_pair(0,0));
  sort(odd_count.begin(),odd_count.end(),my_compare);
  sort(even_count.begin(),even_count.end(),my_compare);
  ll ans;
  ll tmp_max;
  tmp_max = max(odd_count[0].second+even_count[0].second,max(odd_count[1].second+even_count[0].second,odd_count[0].second+even_count[1].second))
  cout << n - tmp_max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:145: error: expected ';' before 'cout'
   36 |   tmp_max = max(odd_count[0].second+even_count[0].second,max(odd_count[1].second+even_count[0].second,odd_count[0].second+even_count[1].second))
      |                                                                                                                                                 ^
      |                                                                                                                                                 ;
   37 |   cout << n - tmp_max << endl;
      |   ~~~~
Language: C++

#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const ll max_co = 3234600000;
vl ans;
int mod =1000000007;
int main(){
   int n;
   cin>>n;
   vi a(n);
   rep(i,n){
       cin>>a[i];
   }
   vi even(100005,0);
   vi odd(100005,0);
   rep(i,n){
       if(i%2==0){
           even[a[i]]++;
       }
       else odd[a[i]]++;
   }
   pair<int,int>etop,otop,esec,osec;
   rep(i,100006){
       if(etop.first<=even[i]){
           esec.first =etop.first;
           esec.second = etop.second;
           etop.first=even[i];
           etop.second = i;
       }
       else if(esec.first<=even[i]){
           esec.first=even[i];
           esec.second=i;
       }
       if(otop.second<=odd[i]){
           osec.first =otop.first;
           osec.second = otop.second;
           otop.first=odd[i];
           otop.second = i;
       }
       else if(osec.first<=odd[i]){
           osec.first=odd[i;
           osec.second=i;
       }
   }
   ll ans;
   if(etop.second==otop.second){
       ans = min(n-otop.first-esec.first,n-osec.first-etop.first);
   }
   else{
       ans = n-otop.first-etop.first;
   }
   cout<<ans<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:28: error: expected ']' before ';' token
   53 |            osec.first=odd[i;
      |                            ^
      |                            ]
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,a,o=0,e=0;
  cin>>n;
  map<int,int> odd,even;
  for(int i=0;i<n/2;i++){
     cin>>a;
     odd[a]++; 
     cin>>a;
     even[a]++; 
  }
  for (auto i=odd.begin();i!=odd.end();++i){
     o=max(o,i->second);
  for (auto i=even.begin();i!=even.end();++i){
     e=max(e,i->second);
  cout<<n-o-e;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:13:44: note: to match this '{'
   13 |   for (auto i=odd.begin();i!=odd.end();++i){
      |                                            ^
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:3:12: note: to match this '{'
    3 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
#define ALL(a)  (a).begin(),(a).end()
int n;
vector<int>v0,v1;
vector<int>c0(MAX,0),c1(MAX,0);
int main(){
    int temp;
    cin>>n;
    rep(i,n){
        cin>>temp;
        if(i%2==0){
            v0.push_back(temp);
            c0[temp]++;

        }
        else {
            v1.push_back(temp);
            c1[temp]++;
            }
    }
    pair<int,int>f0(0,0),s0(0,0),f1(0,0),s1(0,0);
    rep(i,MAX){
        if(f0.second<c0[i]){
            s0.first=f0.first;s0.second=f0.second;
            f0.first=i;f0.second=c0[i];
        }
        if(f1.second<c1[i]){
            s1.first=f1.first;s1.second=f1.second;
            f1.first=i;f1.second=c1[i];
        }
    }
    int res=f0.second+f1.second;
    if(f0.first==f1.first)res=max(f0.second+s1.second,s0.second+f1.second);
    int ans=n-res;
    cout<<ans<<endl;
    return 0;

}

Compiler output:
a.cc:21:1: error: 'vector' does not name a type
   21 | vector<int>v0,v1;
      | ^~~~~~
a.cc:22:1: error: 'vector' does not name a type
   22 | vector<int>c0(MAX,0),c1(MAX,0);
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:29:13: error: 'v0' was not declared in this scope
   29 |             v0.push_back(temp);
      |             ^~
a.cc:30:13: error: 'c0' was not declared in this scope
   30 |             c0[temp]++;
      |             ^~
a.cc:34:13: error: 'v1' was not declared in this scope; did you mean '__pstl::execution::v1'?
   34 |             v1.push_back(temp);
      |             ^~
      |             __pstl::execution::v1
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from a.cc:5:
/usr/include/c++/14/pstl/execution_defs.h:19:18: note: '__pstl::execution::v1' declared here
   19 | inline namespace v1
      |                  ^~
a.cc:35:13: error: 'c1' was not declared in this scope
   35 |             c1[temp]++;
      |             ^~
a.cc:40:22: error: 'c0' was not declared in this scope; did you mean 's0'?
   40 |         if(f0.second<c0[i]){
      |                      ^~
      |                      s0
a.cc:44:22: error: 'c1' was not declared in this scope; did you mean 's1'?
   44 |         if(f1.second<c1[i]){
      |                      ^~
      |                      s1
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b,x=0,y=0;cin>>N;N/=2;
  int A[N],B[N];
  for(int i=0;i<N;i++)cin>>A[i]>>B[i];
  sort(A,A+N);sort(B,B+N);
  for(int i=0;i<N;i=upper_bound(A,A+N,A[i])-A){
    if(x<upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]))a=A[i],x=upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]);
    if(y<upper_bound(B,B+N,B[i])-lower_bound(B,B+N,B[i]))b=B[i],y=upper_bound(B,B+N,B[i])-lower_bound(B,B+N,A[i]));
  }
  if(a==b){
    int MA=0,MB=0;
    for(int i=0;i<N;i=upper_bound(A,A+N,A[i])-A){
      if(a!=A[i]&&MA<upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]))MA=upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]);
      if(b!=B[i]&&MB<upper_bound(B,B+N,B[i])-lower_bound(B,B+N,B[i]))MB=upper_bound(B,B+N,B[i])-lower_bound(B,B+N,A[i]);
    }
    cout<<2*N-min(x+MA,y+MB)<<endl;
  }
  else cout<<2*N-x-y<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:114: error: expected ';' before ')' token
   10 |     if(y<upper_bound(B,B+N,B[i])-lower_bound(B,B+N,B[i]))b=B[i],y=upper_bound(B,B+N,B[i])-lower_bound(B,B+N,A[i]));
      |                                                                                                                  ^
      |                                                                                                                  ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b,x=0,y=0;cin>>N;N/=2;
  int A[N],B[N];
  for(int i=0;i<N;i++)cin>>A[i]>>B[i];
  sort(A,A+N);sort(B,B+N);
  for(int i=0;i<N;i=upper_bound(A,A+N,A[i])-A){
    if(x<upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]))a=A[i],x=upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]));
    if(y<upper_bound(B,B+N,B[i])-lower_bound(B,B+N,B[i]))b=B[i],y=upper_bound(B,B+N,B[i])-lower_bound(B,B+N,A[i]));
  }
  if(a==b){
    int MA=0,MB=0;
    for(int i=0;i<N;i=upper_bound(A,A+N,A[i])-A){
      if(a!=A[i]&&MA<upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]))MA=upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]));
      if(b!=B[i]&&MB<upper_bound(B,B+N,B[i])-lower_bound(B,B+N,B[i]))MB=upper_bound(B,B+N,B[i])-lower_bound(B,B+N,A[i]));
    }
    cout<<2*N-min(x+MA,y+MB)<<endl;
  }
  else cout<<2*N-x-y<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:114: error: expected ';' before ')' token
    9 |     if(x<upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]))a=A[i],x=upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]));
      |                                                                                                                  ^
      |                                                                                                                  ;
a.cc:10:114: error: expected ';' before ')' token
   10 |     if(y<upper_bound(B,B+N,B[i])-lower_bound(B,B+N,B[i]))b=B[i],y=upper_bound(B,B+N,B[i])-lower_bound(B,B+N,A[i]));
      |                                                                                                                  ^
      |                                                                                                                  ;
a.cc:15:120: error: expected ';' before ')' token
   15 |       if(a!=A[i]&&MA<upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]))MA=upper_bound(A,A+N,A[i])-lower_bound(A,A+N,A[i]));
      |                                                                                                                        ^
      |                                                                                                                        ;
a.cc:16:120: error: expected ';' before ')' token
   16 |       if(b!=B[i]&&MB<upper_bound(B,B+N,B[i])-lower_bound(B,B+N,B[i]))MB=upper_bound(B,B+N,B[i])-lower_bound(B,B+N,A[i]));
      |                                                                                                                        ^
      |                                                                                                                        ;
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >> n;
    map<int ,int> mp_even;
    map<int, int> mp_odd;
    rep(i, n) {
        int tmp_num;
        cin >> tmp_num;
        if ( i&1 ) {
            ++mp_odd[tmp_num];
        }
        else {
            ++mp_even[tmp_num];
        }
    }
    int ans = 0;
    int max_odd = 0;;
    int max_odd_second = 0;
    int max_num_odd = 0;
    int max_num_odd_second = 0;
    for ( auto tmp_mp : mp_odd ) {
        if ( max_num_odd < tmp_mp.second ) {
            max_odd_second = max_odd;
            max_num_odd_second = max_num_odd;
            max_num_odd = tmp_mp.second;
            max_odd = tmp_mp.first;
        }
    }
    int max_even = 0;
    int max_even_second = 0;
    int max_num_even = 0;
    int max_num_even_second = 0;
    for ( auto tmp_mp : mp_even ) {
        if ( max_num_even < tmp_mp.second ) {
            max_even_second = max_even;
            max_num_even_second = max_num_even;
            max_num_even = tmp_mp.second;
            max_even = tmp_mp.first;
        }
    }
    if ( max_odd == max_even ) {
        ans = max( ( n / 2 ) - max_num_odd - max_num_even_second, ( n / 2 ) - max_num_odd_second, - max_num_even );
    }
    else {
        ans = n - max_num_odd - max_num_even;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:54:18:   required from here
   54 |         ans = max( ( n / 2 ) - max_num_odd - max_num_even_second, ( n / 2 ) - max_num_odd_second, - max_num_even );
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
  306 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {

  int N ;
  int ans = 0 ;
  cin >> N ;
  vector<int> A(N) ;
  rep(i,N) cin >> A.at(i) ;
  map<int,int> mp_k ;
  map<int,int> mp_g ;
  vector<pair<int,int>> G ;
  vector<pair<int,int>> K ;
  rep(i,N){
    if(i%2) mp_k[A.at(i)]++ ;
    else mp_g[A.at(i)]++ ;
  }
  for(auto p : mp_g ) G.push_back(make_pair(p.second,p.first)) ;
  for(auto p : mp_k ) K.push_back(make_pair(p.second,p.first)) ;
  sort(G.begin(),G.end()) ;
  sort(K.begin(),K.end()) ;
  reverse(G.begin(),G.end()) ;
  reverse(K.begin(),K.end()) ;
  if(G.at(0).second != K.at(0).second ){
    cout << N - G.at(0).first - K.at(0).first << endl;
    return 0 ;
  }
  if(G.at(0).first == N/2 && K.at(0).first == N/2 ){
    cout << N - G.at(0).first << endl;
    return 0 ;
  }
  if(G.at(0).first == N/2 && K.at(0).first != N/2 ){
    cout << N - G.at(0).first - K.at(1).first << endl
    return 0 ;
  }
  if(G.at(0).first != N/2 && K.at(0).first== N/2 ){
    cout << N - G.at(1).first - K.at(0).first << endl
    return 0 ;
  }
    cout << max( N - G.at(0).first - K.at(1).first , N - G.at(1).first - K.at(0).first ) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:54: error: expected ';' before 'return'
   35 |     cout << N - G.at(0).first - K.at(1).first << endl
      |                                                      ^
      |                                                      ;
   36 |     return 0 ;
      |     ~~~~~~                                            
a.cc:39:54: error: expected ';' before 'return'
   39 |     cout << N - G.at(1).first - K.at(0).first << endl
      |                                                      ^
      |                                                      ;
   40 |     return 0 ;
      |     ~~~~~~
Language: C++


#include <cstdio>
#define maxn 100010
int cnt[2][maxn], M[2], Q[2], m[2], q[2];
int n;
int main() {
	scanf("%d", &n); 
	for (int i = 1, x, p; i <= n; i++) {
		scanf("%d", &x); p = i % 2;
		cnt[p][x]++;
		if (M[p] < cnt[p][x]) M[p] = cnt[p][x], Q[p] = x;
	}
	if (Q[0] != Q[1]) {
		printf("%d\n", n - M[0] - M[1]);
		return 0;
	}
	for (int i = 1; i <= 100000; i++) {
		if (m[0] < cnt[0][i] && i != Q[0]) m[0] = cnt[0][i], q[0] = i;
		if (m[1] < cnt[1][i] && i != Q[1]) m[1] = cnt[1][i], q[1] = i;
	}
	if (M[0] - m[0] > M[1] - m[1]) printf("%d\n", n - M[0] - m[1]);
	else printf("%d\n", n - m[0] - M[1]);
	return 0;
}
　　

Compiler output:
a.cc:25:1: error: extended character 　 is not valid in an identifier
   25 | 　　
      | ^
a.cc:25:1: error: extended character 　 is not valid in an identifier
a.cc:25:1: error: '\U00003000\U00003000' does not name a type
   25 | 　　
      | ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long  n,v[100005],m1[100005]={};
  long long m2[100005]={};
  long long a1=0,a2=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>v[i];
    if((i+1)%2==0){
      m2[v[i]]++;
    }
    if((i+1)%2==1){
      m1[v[i]]++;
    }
  }
  for(int i=0;i<=100000;i++){
    if(m1[i]>m2[i]){
      a1=max(m1[i],a1);
    }
    else if(m1[i]<m2[i])
      a2=max(m2[i],a2);
  }
  else if(m1[i]-a1>=m2[i]-a2){
    a1=max(m1[i],a1);
  }
  else
     a2=max(m2[i],a2);
    cout<<n-a1-a2<<endl;
  return(0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:3: error: 'else' without a previous 'if'
   24 |   else if(m1[i]-a1>=m2[i]-a2){
      |   ^~~~
a.cc:24:14: error: 'i' was not declared in this scope
   24 |   else if(m1[i]-a1>=m2[i]-a2){
      |              ^
Language: C++

#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v.at(i);

    vector<ll> ecnt(100005, 0);
    vector<ll> ocnt(100005, 0);
    rep(i, n){
       if((i+1)%2==0) ecnt.at(v.at(i))++;
       else ocnt.at(v.at(i))++;
    }
    
    ll modd=0, meven=0;
    int oi, ei;
    rep(i, 100001){
        if(modd<ocnt.at(i+1)){
            modd = ocnt.at(i+1);
            oi = i+1;
        }
    }

    rep(i, 100001){
        if(meven<ecnt.at(i+1)){
            meven = ecnt.at(i+1);
            ei = i+1;
        }
    }
    
    if(oi==ei){
        if(ecnt.at(ei)<ocnt.at(oi)) {
            ecnt.at(ei) = 0;
            meven = 0;
            rep(i, 100000){
                meven = max(meven, ecnt.at(i+1));
            }
        }
        else {
            ocnt.at(oi) = 0;
            modd = 0;
            rep(i, 100000){
                modd = max(modd, ocnt.at(i+1));
            }
        }
        #if 1
        else{
            ll modds=0, mevens=0;
            ocnt.at(oi) = 0;
            ecnt.at(ei) = 0; 

            rep(i, 100001){
                modds = max(modds, ocnt.at(i+1));
                mevens = max(mevens, ecnt.at(i+1));
            }

            dump(modds);
            dump(mevens);

            int res = 0;
            res = min(n-modds-meven, n-modd-mevens);
            cout << res << endl;
            return 0;
        }
        #endif
    }



    cout << n - modd - meven << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:9: error: expected '}' before 'else'
   51 |         else{
      |         ^~~~
a.cc:35:15: note: to match this '{'
   35 |     if(oi==ei){
      |               ^
a.cc: At global scope:
a.cc:74:5: error: 'cout' does not name a type
   74 |     cout << n - modd - meven << endl;
      |     ^~~~
a.cc:75:1: error: expected declaration before '}' token
   75 | }
      | ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
    ll n;
    set<ll>guset,kiset;
    cin>>n;
    rep(i,n/2)
    {
        ll gu,ki;
        cin>>ki;
        cin>>gu;
        kiset.insert(ki);
        guset.insert(gu);

    }
    if(kiset==guset)
    {
        cout<<n/2<<endl;
    }
    else
    {
        cout<<kiset.size()+guset.size()-2<<endl;

    }

Compiler output:
a.cc: In function 'int main()':
a.cc:38:6: error: expected '}' at end of input
   38 |     }
      |      ^
a.cc:17:1: note: to match this '{'
   17 | {
      | ^
Language: C++

#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int v[n];
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    int ans = 0;
    int n_max = 100001;
    int s[n_max]; fill(s, s+n_max, 0);
    int t[n_max]; fill(t, t+n_max, 0);
    int s1, s2; s1 = 0; s2 = 0;
    int t1, t2; t1 = 0; t2 = 0;
    for(int i=0; i<n; i++){
        if(i%2 == 0) {
            s[v[i]]++;
        }
        else {
            t[v[i]]++;
        }        
    }
    for(int i=0; i<n_max; i++){
        if(s[i] > s2){
            if(s[i] > s1){
                s2 = s1;
                s1 = s[i];
            }
            else s2 = s[i];
        }
        if(t[i] > t2){
            if(t[i] > t1){
                t2 = t1;
                t1 = t[i];
            }
            else t2 = t[i];
        }
    }
    if(max_element(s, s + n_max) - s == max_element(t, t + n_max) - t) ans += n - max(s1 + t2, s2 + t1);
    else ans += n - (s1 + t1);
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:8: error: 'max_element' was not declared in this scope
   42 |     if(max_element(s, s + n_max) - s == max_element(t, t + n_max) - t) ans += n - max(s1 + t2, s2 + t1);
      |        ^~~~~~~~~~~