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

1>------ ビルド開始: プロジェクト: Project7, 構成: Debug Win32 ------
1>Source.cpp
1>Project7.vcxproj -> C:\Users\Takano\source\repos\Project7\Debug\Project7.exe
========== ビルド: 1 正常終了、0 失敗、0 更新不要、0 スキップ ==========


Compiler output:
a.cc:3:25: error: stray '\' in program
    3 | 1>Project7.vcxproj -> C:\Users\Takano\source\repos\Project7\Debug\Project7.exe
      |                         ^
a.cc:3:31: error: stray '\' in program
    3 | 1>Project7.vcxproj -> C:\Users\Takano\source\repos\Project7\Debug\Project7.exe
      |                               ^
a.cc:3:38: error: stray '\' in program
    3 | 1>Project7.vcxproj -> C:\Users\Takano\source\repos\Project7\Debug\Project7.exe
      |                                      ^
a.cc:3:45: error: stray '\' in program
    3 | 1>Project7.vcxproj -> C:\Users\Takano\source\repos\Project7\Debug\Project7.exe
      |                                             ^
a.cc:3:51: error: stray '\' in program
    3 | 1>Project7.vcxproj -> C:\Users\Takano\source\repos\Project7\Debug\Project7.exe
      |                                                   ^
a.cc:3:60: error: stray '\' in program
    3 | 1>Project7.vcxproj -> C:\Users\Takano\source\repos\Project7\Debug\Project7.exe
      |                                                            ^
a.cc:3:66: error: stray '\' in program
    3 | 1>Project7.vcxproj -> C:\Users\Takano\source\repos\Project7\Debug\Project7.exe
      |                                                                  ^
a.cc:4:22: error: extended character 、 is not valid in an identifier
    4 | ========== ビルド: 1 正常終了、0 失敗、0 更新不要、0 スキップ ==========
      |                      ^
a.cc:4:34: error: extended character 、 is not valid in an identifier
    4 | ========== ビルド: 1 正常終了、0 失敗、0 更新不要、0 スキップ ==========
      |                                  ^
a.cc:4:42: error: extended character 、 is not valid in an identifier
    4 | ========== ビルド: 1 正常終了、0 失敗、0 更新不要、0 スキップ ==========
      |                                          ^
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 1>------ ビルド開始: プロジェクト: Project7, 構成: Debug Win32 ------
      | ^
Language: C++

#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int main() {
	int m,n,j,k,ans;
	ans = 0;
	int a[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> b(100000);
	for (j = 0; j*2 < n; j++) {
		m = a[j*2];
		b[m]++;
	}
	vector<int>::iterator even = max_element(b.begin(), b.end());
	size_t ev = distance(b.begin(), even);
	for (j = 0; j < 100000; j++) {
		b[j] = 0;
	}
	for (j = 0; j * 2 + 1 < n; j++) {
		m = a[j * 2 + 1];
		b[m]++;
	}
	vector<int>::iterator odd = max_element(b.begin(), b.end());
	size_t od = distance(b.begin(), odd);
	if (od == ev) {
		for (j = 0; j * 2 < n; j++) {
			m = a[j * 2];
			b[m]++;
		}
		b[ev] = 0;
		vector<int>::iterator even = max_element(b.begin(), b.end());
		size_t ev = distance(b.begin(), even);
		for (j = 0; j * 2 < n; j++) {
			if (!(ev == a[j * 2])) {
				ans++;
			}
		}
		for (k = 0; k * 2 + 1 < n; k++) {
			if (!(od == a[k * 2 + 1])) {
				ans++;
			}
		}
		a1 = ans;
		ans = 0;
		for (j = 0; j * 2 + 1 < n; j++) {
			m = a[j * 2 + 1];
			b[m]++;
		}
		b[od] = 0;
		vector<int>::iterator odd = max_element(b.begin(), b.end());
		size_t od = distance(b.begin(), odd);
		for (j = 0; j * 2 < n; j++) {
			if (!(ev == a[j * 2])) {
				ans++;
			}
		}
		for (k = 0; k * 2 + 1 < n; k++) {
			if (!(od == a[k * 2 + 1])) {
				ans++;
			}
		}
		b1 = ans;
		ans = max(a1, b1);
	}
	else {
		for (j = 0; j * 2 < n; j++) {
			if (!(ev == a[j * 2])) {
				ans++;
			}
		}
		for (k = 0; (k * 2) + 1 < n; k++) {
			if (!(od == a[(k * 2) + 1])) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:17: error: 'a1' was not declared in this scope; did you mean 'a'?
   50 |                 a1 = ans;
      |                 ^~
      |                 a
a.cc:69:17: error: 'b1' was not declared in this scope; did you mean 'b'?
   69 |                 b1 = ans;
      |                 ^~
      |                 b
Language: C++

package com.company;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.lang.Math;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        List<Integer> v1=new ArrayList<>();
        List<Integer> v2=new ArrayList<>();
        for(int i=0;i<n;i++){
            if(i%2==0){
                v1.add(scanner.nextInt());
            }else{
                v2.add(scanner.nextInt());
            }
        }

        FixedPair vfp1=func(v1);
        FixedPair vfp2=func(v2);
        if(vfp1.y!=vfp2.y){
            System.out.println(n-vfp1.x-vfp2.x);
        }else{
            if(vfp1.x>vfp2.x){
                v2=v2.stream().filter(x->x!=vfp2.y).collect(Collectors.toList());
            }else{
                v1=v1.stream().filter(x->x!=vfp1.y).collect(Collectors.toList());
            }
            if(v1.size()==0||v2.size()==0){
                System.out.println(n/2);
            }else{
                System.out.println(n-Arrays.asList(func(v1),func(v2)).stream().mapToLong(x->x.x).sum());
            }
        }
    }
    public static FixedPair func(List<Integer> list){
        int[] count=new int[10001];
        for(int x:list){
            count[x]++;
        }
        int max=Integer.MIN_VALUE;
        int index=0;
        for(int i=0;i<count.length;i++){
            if(max<count[i]){
                max=count[i];
                index=i;
            }
        }
        return new FixedPair(max,index);
    }
    static class FixedPair{
        final long x,y;
        public FixedPair(long x,long y){
            this.x=x;
            this.y=y;
        }
    }
}


Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package com.company;
      | ^~~~~~~
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.ArrayList;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.Arrays;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.List;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import java.util.Scanner;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import java.lang.Math;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
    8 | import java.util.stream.Collectors;
      | ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: expected unqualified-id before 'public'
   10 | public class Main {
      | ^~~~~~
Language: C++

#include "pch.h"
#include <iostream>
#include <algorithm>
#include <tuple>
//#include <string>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;

int odds[50005] = {};
int even[50005] = {};
int num1, num2;


int main(){

	int n;
	cin >> n;
	int all=-1,allcount=0;
	rep(i, n) {
		if (i % 2) {
			cin >> odds[i / 2];
			if (all == odds[i / 2]) allcount++;
		}
		else {
			cin >> even[i / 2];
			if (all == even[i / 2]) allcount++;
		}
		all = even[i / 2];
	}

	if (allcount == n - 1) {
		cout << n / 2 << endl;
		return 0;
	}

	sort(odds, odds + n / 2);
	sort(even, even + n / 2);
	
	int len1[2] = {}, count = 0;
	int temp = -1;
	rep(i, n / 2) {
		if (temp == odds[i]) count++;
		else {
			if (len1[0] < count) {
				len1[0] = count;
				num1 = i-1;
			}
			else if(len1[1]<count){
				len1[1] = count;
			}
			count = 0;
		}
		temp = odds[i];
	}
	if (len1[0] < count) {
		len1[0] = count;
		num1 = n / 2-1;
	}
	else if (len1[1] < count) {
		len1[1] = count;
	}

	int len2[2] = {}; count = 0;	temp = -1;
	rep(i, n / 2) {
		if (temp == even[i]) count++;
		else {
			if (len2[0] < count) {
				len2[0] = count;
				num2 = i-1;
			}
			else if (len2[1] < count) {
				len2[1] = count;
			}
			count = 0;
		}
		temp = even[i];
	}
	if (len2[0] < count) {
		len2[0] = count;
		num2 = n / 2 - 1;
	}
	else if (len2[1] < count) {
		len2[1] = count;
	}

	int ans;
	if(odds[num1]!=even[num2])	ans =n-len1[0]-len2[0]-2;
	else if (len1[0] + len2[1] > len2[0] + len1[1]) ans = n - len1[0] - len2[1] - 2;
	else ans = n - len2[0] - len1[1] - 2;









	cout << ans << endl;



	/*
	
	rep(i, n) {
		cout << num[i] <<" ";
	}
	
	int len[2] = {}, count = 0, ans = 0;
	int temp=-1;
	rep(i, n) {
		if (temp == num[i]) count++;
		else {
			if (len[0] < count) len[0] = count;
			else if (len[1] < count) len[1] = count;
			count = 0;
		}
		temp = num[i];

	}
	if (len[0] < count) len[0] = count;
	else if (len[1] < count) len[1] = count;

	if(len[0]<=n/2)	cout << n - len[0] - len[1] -2 <<endl;
	else cout << n / 2 - len[1] << endl;
	*/
	return 0;
}


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

m>
using namespace std;

int n;
int x[100001];
int v[100001];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> v[i];
    int count = 0;

	for(int i = 0; i < n ; i = i + 2){
		x[v[i]]++;
	}
	
	int Max = 0;

	for(int i = 1; i < 100001; ++i){
		Max = max(Max, x[i]);
	}

	count = count + (n / 2) - Max;

	for(int i = 0; i < 100001; ++i){
		x[i] = 0;
	}

	for(int i = 1; i < n ; i = i + 2){
		x[v[i]]++;
	}

	Max = 0;

	for(int i = 1; i < 100001; ++i){
		Max = max(Max, x[i]);
	}

	count = count + (n / 2) - Max;

	int one_kind = 0;
	for(int i = 0; i < n; ++i){
		if(v[i] != v[0]) break;
		if(i == n - 1) one_kind = 1;
	}
	if(one_kind == 1) count = n / 2;

	cout << count << endl;

}

Compiler output:
a.cc:1:1: error: 'm' does not name a type
    1 | m>
      | ^
a.cc: In function 'int main()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin >> n;
      |     ^~~
a.cc:20:23: error: 'max' was not declared in this scope; did you mean 'Max'?
   20 |                 Max = max(Max, x[i]);
      |                       ^~~
      |                       Max
a.cc:36:23: error: 'max' was not declared in this scope; did you mean 'Max'?
   36 |                 Max = max(Max, x[i]);
      |                       ^~~
      |                       Max
a.cc:48:9: error: 'cout' was not declared in this scope; did you mean 'count'?
   48 |         cout << count << endl;
      |         ^~~~
      |         count
a.cc:48:26: error: 'endl' was not declared in this scope
   48 |         cout << count << endl;
      |                          ^~~~
Language: C++

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

int main() {
    int n;
    cin >> n;
    vector<vector<int> > v(2, vector<int>(100005));
    vector<int> mode(2);
    vector<int> maxi(2);
    for (int i = 0; i < n / 2; i++) {
        int x, y;
        cin >> x >> y;
        v[0][x]++;
        v[1][y]++;

        if (mode[0] < v[0][x]) {
            mode[0] = v[0][x];
            maxi[0] = x;
        }
        if (mode[1] < v[1][y]) {
            mode[1] = v[1][y];
            maxi[1] = y;
        }
    }
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());

    int ans = 0;
    if (maxi[0] != maxi[1]) {
        ans = n - mode[0] - mode[1];
    } else {
        ans = min(n - mode[0] - v[1][1], n - mode[1] - v[0][1]);
    }
    cout << ans << endl;
    return 0;
}

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

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

int main() {
    int n;
    cin >> n;
    vector<vector<int> > v(2, vector<int>(100005));
    vector<int> mode(2);
    vector<int> maxi(2);
    for (int i = 0; i < n / 2; i++) {
        int x, y;
        cin >> x >> y;
        v[0][x]++;
        v[1][y]++;

        if (mode[0] < v[0][x]) {
            mode[0] = v[0][x];
            maxi[0] = x;
        }
        if (mode[1] < v[1][y]) {
            mode[1] = v[1][y];
            maxi[1] = y;
        }
    }
    sort(v[0].begin(), v[0].end(), greater<int>());
    sort(v[1].begin(), v[1].end(), greater<int>());

    int ans = 0;
    if (maxi[0] != maxi[1]) {
        ans = n - mode[0] - mode[1];
    } else {
        ans = min(n - mode[0] - v[1][1], n - mode[1] - v[0][1]);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   26 |     sort(v[0].begin(), v[0].end(), greater<int>());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

map<ll, ll> mp_o;
map<ll, ll> mp_e;

int main() {
	ll n; cin >> n;
	repe(i, 1, n) {
		ll a; cin >> a;
		if (i & 1)mp_o[a]++;
		else mp_e[a]++;
	}

	ll cnt_o = n / 2 + ((1 & n) ? 1 : 0);
	ll cnt_e = n / 2;

	map<ll, ll>::iterator it_o = mp_o.begin();
	ll cnt_o_1 = it_o->first;
	map<ll, ll>::iterator it_e = mp_e.begin();
	ll cnt_e_1 = it_e->first;

	if (mp_o.size() == 1 && mp_e.size() == 1) {
		if (cnt_o_1 == cnt_e_1) {
			cout << n / 2 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}

	if (cnt_o_1 != cnt_e_1) {
		if (cnt_o_1 < cnt_e_1)
		{
			cout << cnt_o - cnt_o_1 << endl;
		}
		else {
			cout << cnt_e - cnt_e_1 << endl;
		}
		return 0;
	}
	else {
		if (cnt_o == cnt_e)
	}
	//ll cnt_o_2 = it->first;

	//ll cnt_1 = 0;
	//ll maxV = 0;
	//for (map<ll, ll>::iterator it = mp_o.begin(); it != mp_o.end(); it++) {
	//	if (it != mp_o.begin()) {
	//		cnt_1 += it->second;
	//	}
	//	else {
	//		maxV = it->first;
	//	}
	//}

	//bool dupl = false;
	//if (mp_e.begin()->first == maxV) {
	//	dupl = true;
	//}
	//if (dupl) {
	//	for (map<ll, ll>::iterator it = mp_e.begin(); it != mp_e.end(); it++) {
	//		cnt_1 += it->second;
	//	}
	//	cnt_1 -= mp_e.begin()->second;
	//}
	//else {
	//	for (map<ll, ll>::iterator it = mp_e.begin(); it != mp_e.end(); it++) {
	//		if (it != mp_e.begin()) {
	//			cnt_1 += it->second;
	//		}
	//	}
	//}
	//cout << cnt_1 << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:9: error: expected primary-expression before '}' token
   54 |         }
      |         ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int n;
  cin >> n;
  vi odd(1e5+1,0),end(1e5+1,0);
  REP(i,n/2){
    int tmp;
    cin >> tmp;
    odd[tmp]++;
    cin >> tmp;
    end[tmp]++;
  }
  auto om = max_element(ALL(odd));
  auto em = max_element(ALL(end));
  auto omi = distance(odd.begin(),om);
  auto emi = distance(end.begin(),em);
  if(emi==omi){
    if(*om>*em){
      *em = 0;
      em = max_element(ALL(end));
    }else{
      *om = 0;
      om = max_element(ALL(odd));
    }
  }
  cout << n-*om-*em+val << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:21: error: 'val' was not declared in this scope; did you mean 'vll'?
   46 |   cout << n-*om-*em+val << endl;
      |                     ^~~
      |                     vll
Language: C++

import collections
def main(n:int,lst:list)->int:
    b = True
    lst1 = []
    lst2 = []
    for e in lst:
        if b:
            lst1.append(e)
        else:
            lst2.append(e)
        b = not b
    c1 = collections.Counter(lst1).most_common()
    c2 = collections.Counter(lst2).most_common()
    if c1[0][0] == c2[0][0]:
        if c1[0][1] > c2[0][1]:
            if len(c2) == 1:
                return n - c1[0][1]
            else:
                return n - c1[0][1] - c2[1][1]
        else:
            if len(c1) == 1:
                return n - c2[0][1]
            else:
                return n - c2[0][1] - c1[1][1]
    else:
        return n - c1[0][1] - c2[0][1]

n = int(input())
lst = list(map(int,input().split()))
print(main(n,lst))


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

//奇数と偶数のところがすべて同じになれば良い。
#include<iostream>
using namespace std;

main(){
  int n;
  cin >> n;
  int v[n];
  for(int ii=0;ii<n;ii++){
    cin >> v[ii];
  }
  int cnt[1e5];
  for(int ii=0;ii<1e5;ii++){//初期化
    cnt[ii]=0;
  }
  for(int ii=0;ii<n;ii+=2){//増やす
    cnt[v[ii]]++;
  }
  int tmp=0;
  int max,max2;
  for(int ii=0;ii<1e5;ii+=2){
    if(tmp<cnt[ii]){
      tmp=cnt[ii];
      max=ii;
    }
  }
  tmp=0;
  for(int ii=1;ii<1e5;ii+=2){
    if(tmp<cnt[ii] && ii!=max){
      tmp=cnt[ii];
      max2=ii;
    }
  }
  //奇数の方
  for(int ii=0;ii<1e5;ii++){
    cnt[ii]=0;
  }
  for(int ii=1;ii<n;ii+=2){
    cnt[v[ii]]++;
  }
  int max3,max4;
  tmp=0;
  for(int ii=0;ii<1e5;ii+=2){
    if(tmp<cnt[ii]){
      tmp=cnt[ii];
      max3=ii;
    }
  }
  tmp=0;
  for(int ii=1;ii<1e5;ii+=2){
    if(tmp<cnt[ii] && ii!=max3){
      tmp=cnt[ii];
      max4=ii;
    }
  }
  //数える。
  if(max!=max2){
    if(max>max2){
      int ans=0;
      for(int ii=0;ii<n;ii+=2){
	if(v[ii]!=max)ans++;
      }
      for(int ii=1;ii<n;ii+=2){
	if(v[ii]==max)ans++;
      }
      cout << ans << endl;
    }
    else{
      int ans=0;
      for(int ii=0;ii<n;ii+=2){
	if(v[ii]==max)ans++;
      }
      for(int ii=1;ii<n;ii+=2){
	if(v[ii]!=max)ans++;
      }
      cout << ans << endl;
    }
  }
  else{
    int ans=0;
    for(int ii=0;ii<n;ii+=2){
      if(v[ii]==max)ans++;
    }
    for(int ii=1;ii<n;ii+=2){
      if(v[ii]!=max)ans++;
    }
    int ans2=0;
    for(int ii=0;ii<n;ii+=2){
      if(v[ii]!=max)ans2++;
    }
    for(int ii=1;ii<n;ii+=2){
      if(v[ii]==max)ans2++;
    }
    cout << min(ans,ans2) << endl;
  }
}


Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:12:11: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   12 |   int cnt[1e5];
      |           ^~~
a.cc:12:11: error: could not convert '1.0e+5' from 'double' to 'long unsigned int'
   12 |   int cnt[1e5];
      |           ^~~
      |           |
      |           double
a.cc:12:11: error: size of array 'cnt' has non-integral type 'double'
Language: C++

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>
#include<limits>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

int main(){
	int n;
	cin >> n;
	vector<int> o, e;
	int mo, me;
	int mno, mne;
	int mno2, mne2;
	int x;
	rep(i, n) {
		cin >> x;
		if (i%2 == 0) o.push_back(x);
		else e.push_back(x);
	}

	int ans;
	mo = maxelem(o);
	me = maxelem(e);
	vector<int> counto = count(o);
	vector<int> counte = count(e);
	mno = maxelem(counto);
	mne = maxelem(counte);
	mno2 = secondelem(counto);
	mne2 = secondelem(counte);

	if (mo != me) ans = n - mno - mne;
	else if (mno2 >= mne2) ans = n - mno2 - mne;
	else ans = n - mno - mne2;

	if (o == e) ans = n / 2;
	cout << ans;

	return 0;
}



Compiler output:
a.cc: In function 'int maxelem(std::vector<int>)':
a.cc:21:14: error: 'INT_MIN' was not declared in this scope
   21 | #define IMIN INT_MIN;
      |              ^~~~~~~
a.cc:25:19: note: in expansion of macro 'IMIN'
   25 |         int dst = IMIN;
      |                   ^~~~
a.cc:12:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include<map>
  +++ |+#include <climits>
   12 | #include<vector>
a.cc: In function 'int secondelem(std::vector<int>)':
a.cc:21:14: error: 'INT_MIN' was not declared in this scope
   21 | #define IMIN INT_MIN;
      |              ^~~~~~~
a.cc:33:19: note: in expansion of macro 'IMIN'
   33 |         int dst = IMIN;
      |                   ^~~~
a.cc:21:14: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   21 | #define IMIN INT_MIN;
      |              ^~~~~~~
a.cc:33:19: note: in expansion of macro 'IMIN'
   33 |         int dst = IMIN;
      |                   ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define mod MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    ll n; cin >> n;
    ll v[n];
    vector<ll> va, vb;
    map<ll, int> ma, mb;
    for(ll i = 0; i < n; i++){
        cin >> v[i];
        if(i%2 == 0) va.push_back(v[i]);
        else vb.push_back(v[i]);
    }
    for(ll i = 0; i < n/2; i++){
        ma[va[i]]++;
        mb[vb[i]]++;
    }
    int num_a= 0, num_b = 0;
    ll a_max = 0, b_max = 0;
    for(ll i = 0; i < n/2; i++){
        if(num_a < ma[va[i]]) a_max = va[i];
        num_a = max(num_a, ma[va[i]]);
        if(num_b < mb[vb[i]]) b_max = vb[i]
        num_b = max(num_b, mb[vb[i]]);
    }
    ll ans;
    if(a_max == b_max) ans = n/2;
    else ans = n - num_a - num_b;
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:44: error: expected ';' before 'num_b'
   29 |         if(num_b < mb[vb[i]]) b_max = vb[i]
      |                                            ^
      |                                            ;
   30 |         num_b = max(num_b, mb[vb[i]]);
      |         ~~~~~
Language: C++

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
//#include <vector> 

static void st_Calc( long m, long aa[], long* piMax, long* piCountMax, long* piCountSec )
{
    long max_a = 0;
    long max_a_count = 0;
    long sec_a = 0;
    long sec_a_count = 0;
    long i;
    for(i=0; i<m; i++) {
        if(max_a==aa[i]) {
            max_a_count ++;
        }
        else if(max_a < aa[i]) {
            sec_a = max_a;
            sec_a_count = max_a_count;
            max_a = aa[i];
            max_a_count = 1;
        }
        else if (sec_a == aa[i]) {
            sec_a_count ++;
        }
        else if(sec_a < aa[i]) {
            sec_a = aa[i];
            sec_a_count ++;
        }
    }

    (*piMax) = max_a;
    (*piCountMax) = max_a_count;
    (*piCountSec) = sec_a_count;
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> veven(n), vodd(n);
    const int N = 100001;
    int even[N] = {0};
    int odd[N] = {0};
    for (int i = 0; i < n / 2; ++i) { //n is even
        cin >> veven[i] >> vodd[i];
        even[veven[i]]++;
        odd[vodd[i]]++;
    }
    int maxeven = 0, maxodd = 0;
    int ideven = 0, idodd = 0;
    for (int i = 1; i < N; ++i) {
        if (maxeven < even[i]) {
            maxeven = even[i];
            ideven = i;
        }
    }
    for (int i = 1; i < N; ++i) {
        if (maxodd < odd[i]) {
            maxodd = odd[i];
            idodd = i;
        }
    }
    if (ideven != idodd) {
        cout << n - maxeven - maxodd << endl;
    } else {
        sort(even, even + N, greater<int>());
        sort(odd, odd + N, greater<int>());
        cout << n - max(even[0] + odd[1], even[1] + odd[0]) << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |         sort(even, even + N, greater<int>());
      |         ^~~~
      |         short
Language: C++

#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n;
map<int,int> p,q;
vpint tp,tq

main(){
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(i%=0)amp(p,a[i]);
		else amp(q,a[i]);
	}
	for(auto x:p){
		tp.pb(x.se,x.fi);
	}
	for(auto x:q){
		tq.pb(x.se,x.fi);
	}
	sort(rall(tp));sort(rall(tq));
	if(tp.size()==1&&tq.size()==1&&tp[0].se==tq[0].se){
		cout<<n/2<<endl;
	}else if(tp[0].se==tq[0].se){
		dump(n-min(tp[0].se+tq[1].se,tp[1].se+tq[0].se));
	}else{
		dump(n-tp[0].se-tq[0].se);
	}
}



Compiler output:
a.cc:9:9: warning: "INT_MAX" redefined
    9 | #define INT_MAX LLONG_MAX
      |         ^~~~~~~
In file included from /usr/include/c++/14/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:38,
                 from a.cc:5:
/usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:120:9: note: this is the location of the previous definition
  120 | #define INT_MAX __INT_MAX__
      |         ^~~~~~~
a.cc:49:1: error: expected initializer before 'main'
   49 | main(){
      | ^~~~
Language: C++

// http://yumai6.hatenablog.com/entry/2015/12/21/222930

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//---------------------------------------------------------------
// ２つの数字が交互にでるように修正する回数
//---------------------------------------------------------------

int N;
map<int, int> D1;
map<int, int> D2;

signed main(){
	cin >> N;
	int d;
	REP(i, N) {
		scanf("%d",&d);
		if((i % 2) == 0)	D1[d] += 1;
		else				D2[d] += 1;
	}
	
	int d1[2][2] = { {-1, 0}, {-1, 0} };
	for(auto itr = D1.begin(); itr != D1.end(); ++itr) {
		if(itr->second > d1[0][1]) {
			d1[1][0] = d1[0][0];
			d1[1][1] = d1[0][1];
			d1[0][0] = itr->first;
			d1[0][1] = itr->second;
		} else if(itr->second > d1[1][1]) {
			d1[1][0] = itr->first;
			d1[1][1] = itr->second;
		}
	}

	int d2[2][2] = { {-1, 0}, {-1, 0} };
	for(auto itr = D2.begin(); itr != D2.end(); ++itr) {
		if(itr->second > d2[0][1]) {
			d2[1][0] = d2[0][0];
			d2[1][1] = d2[0][1];
			d2[0][0] = itr->first;
			d2[0][1] = itr->second;
		} else if(itr->second > d2[1][1]) {
			d2[1][0] = itr->first;
			d2[1][1] = itr->second;
		}
	}
	int ans;
	if(d1[0][0] != d2[0][0]) {
		ans = N - d1[0][1] - d2[0][1];
	} else if(d1[0][1] + d2[1][1]) >= (d1[1][1] + d2[0][1]) {
		ans = N - d1[0][1] - d2[1][1];
	} else {
		ans = N - d1[1][1] - d2[0][1];
	}
	cout << ans << endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:40: error: expected primary-expression before '>=' token
   67 |         } else if(d1[0][1] + d2[1][1]) >= (d1[1][1] + d2[0][1]) {
      |                                        ^~
Language: C++

#include <iostream>
using namespace std;

int main(){

    int n, v[100000];
    cin >> n;
    for( int i = 0; i < n; i++ ) cin >> v[i];


    int num_even[100001] = {}, num_odd[100001] = {};
    int num_even_max = 0, num_odd_max = 0;
    int even_max = 0, odd_max = 0;

    for( int i = 0; i < n; i++ ){
        if( i % 2 == 0 ) num_even[v[i]]++;
        else num_odd[v[i]]++;
    }

    for( int i = 1; i <= 100000; i++ ){
        if( num_even_max < num_even[i] ){
            num_even_max = num_even[i];
            even_max = i;
        }
        if( num_odd_max < num_odd[i] ){
            num_odd_max = num_odd[i];
            odd_max = i;
        }
    }

    if( even_max == odd_max ){
        int num_even_sub = 0, num_odd_sub = 0;
        
        for( int i = 1; i <= 100000; i++ ){
            if( num_even_sub < num_even[i] && i != even_max ) num_even_sub = num_even[i];
            if( num_odd_sub < num_odd[i] && i != odd_max ) num_odd_sub = num_odd[i];
        }
        cout << n - max( num_even_max + num_odd_sub, num_even_sub + num_odd_max ) << endl;    
    }else{
        cout << n - num_even_max - num_odd_max << endl;
    }

    return 0;


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

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
  size_t n;
  cin >> n;
  vector<pii> v[2];
  {
    std::map<int, int> tmp[2];  // (要素, 出現数)
    for (size_t i=0; i<n; i+=2)
      for (size_t j=0; j<2; ++j) {
        int v_i;
        std::cin >> v_i;
        ++tmp[j][v_i];
      }
    for (size_t j=0; j<2; ++j) {
      for (const auto& p: tmp[j])
        v[j].emplace_back(p.second, p.first);
      sort(v[j].begin(), v[j].end(), std::greater<>());
    }
  }
  auto f0=v[0].begin();
  auto f1=v[1].begin();

  if (v[0].size() == 1 && v[1].size() == 1) {
    if (f0->second == f1->second) {
      cout << n/2 << endl;
    } else {
      cout << "0\n";
    }
    return 0;
  }

  if (f0->second != f1->second) {
    cout << n-(f0->first+f1->first) << endl;
    return 0;
  }

  
  auto g0=next(f0);  
  if (f0->first != f1->first) {
    if (f0->first > f1->first) {
      cout << n-(f0->first+g1->first) << endl;
    } else {
      cout << n-(g0->first+f1->first) << endl;
    }
    return 0;
  }

  cout << n-(f0->first+max(g0->first, g1->first)) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:28: error: 'g1' was not declared in this scope; did you mean 'g0'?
   67 |       cout << n-(f0->first+g1->first) << endl;
      |                            ^~
      |                            g0
a.cc:74:39: error: 'g1' was not declared in this scope; did you mean 'g0'?
   74 |   cout << n-(f0->first+max(g0->first, g1->first)) << endl;
      |                                       ^~
      |                                       g0
Language: C++

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

int main(){
	int n;
	cin >> n;
	int v[n];
	for(int i=0; i<n; i++) cin >> v[i];
	int count1[100002];
	int count2[100002];
	int max1=0, max2=0, max3=0, max4=0, flag1, flag2;
	for(int i=1; i<n; i=i+2) count1[v[i]]++;
	for(int i=0; i<n; i=i+2) count2[v[i]]++;
	for(int i=0; i<100002; i++){
		if(max1 < count1[i]){
			max2 = max1;
			max1 = count1[i];
			flag1 = i;
		}else if(max2 < count1[i]){
			max2 = count1[i];
		}
		if(max3 < count2[i]){
			max4 = max3;
			max3 = count2[i];
			flag2 = i;
		}else if(max4 < count2[i]){
			max4 = count2[i];
		}
	}
	int ans;
	if(flag1==flag2){
		cout << n - max(max1 + max4, max2 + max3) << endl;
	}else{
		cout << n - (max1 + max3) << endl;
	}
	for(int i=0; i<count1.size(); i++){
		if(max1 < count1[i]){
			max1 = count1[i];
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:31: error: request for member 'size' in 'count1', which is of non-class type 'int [100002]'
   36 |         for(int i=0; i<count1.size(); i++){
      |                               ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int cnt1[100003],cnt2[100003],n,x,mx1=0,mx2=0,mx3=0,mx4=0,x1,x2;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		if(i%2==0)
		{
			cnt1[x]++;
			if(mx1<cnt1[x])
				mx1=cnt1[x],
				x1=x;
			}else if(mx3<cnt1[x]){
				mx3=cnt1[x];
			}
		}
		else
		{
			cnt2[x]++;
			if(mx2<cnt2[x])
				mx2=cnt2[x],
				x2=x;
			}else if(mx4<cnt2[x]){
				mx4=cnt2[x];
			}
		}
	}
	if(x1!=x2)
		cout<<n-mx1-mx2;
	else
		cout<<n-max(mx1+mx4,mx2+mx3);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: 'else' without a previous 'if'
   19 |                 else
      |                 ^~~~
a.cc:25:26: error: 'else' without a previous 'if'
   25 |                         }else if(mx4<cnt2[x]){
      |                          ^~~~
a.cc: At global scope:
a.cc:29:9: error: expected declaration before '}' token
   29 |         }
      |         ^
a.cc:30:9: error: expected unqualified-id before 'if'
   30 |         if(x1!=x2)
      |         ^~
a.cc:32:9: error: expected unqualified-id before 'else'
   32 |         else
      |         ^~~~
a.cc:34:1: error: expected declaration before '}' token
   34 | }
      | ^
Language: C++

#include<bits/stdc++.h>
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> count1(100002);
	vector<int> count2(100002);
	int max1=0, max2=0, max3=0, max4=0, flag1, flag2;
	for(int i=1; i<n; i=i+2) count1[v[i]]++;
	for(int i=0; i<n; i=i+2) count2[v[i]]++;
	for(int i=0; i<100002; i++){
		if(max1 < count1[i]){
			max1 = count1[i];
			flag1 = i;
		}else if(max2 < count1[i]){
			max2 = count1[i];
		}
		if(max3 < count2[i]){
			max3 = count2[i];
			flag2 = i;
		}else if(max4 < count2[i]){
			max4 = count2[i];
		}
	}
	int ans;
	if(flag1==flag2){
		cout << n - ans(max1 + max4, max2 + max3) << endl;
	}else{
		cout << n - (max1 + max3) << endl;
	}
	for(int i=0; i<count1.size(); i++){
		if(max1 < count1[i]){
			max1 = count1[i];
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:32: error: 'ans' cannot be used as a function
   30 |                 cout << n - ans(max1 + max4, max2 + max3) << endl;
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  int half = n/2;
  int odd[half+1], even[half];
  for(int i=0; i<half+1; i++){
    cin >> odd[i] >> even[i];
  }
  int count1[100001], count2[100001];
  for(int i=0; i<half+1; i++){
    count1[odd[i]]++;
    count2[even[i]]++;
  }
  int max1=0, max2=0, max3=0, max4=0, flag1, flag2;
  for(int i=0; i<100001; i++){
    if(max1 < count1[i]){
      max1 = count1[i];
      int flag1 = i;
    }else if(max2 < count1[i]){
      max2 = count1[i];
    }
  }
  for(int i=0; i<100001; i++){
    if(max3 < count2[i]){
      max3 = count2[i];
      int flag2 = i;
    }else if(max4 < count2[i]){
      max4 = count2[i];
    }
  }
  if(flag1==flag2){
    cout << count1[flag1] + max(count1[flag3],count2[flag4]) << endl;
  }else{
    cout << count1[flag1] + count2[flag2] << endl;
  }
  return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:40: error: 'flag3' was not declared in this scope; did you mean 'flag2'?
   35 |     cout << count1[flag1] + max(count1[flag3],count2[flag4]) << endl;
      |                                        ^~~~~
      |                                        flag2
a.cc:35:54: error: 'flag4' was not declared in this scope; did you mean 'flag2'?
   35 |     cout << count1[flag1] + max(count1[flag3],count2[flag4]) << endl;
      |                                                      ^~~~~
      |                                                      flag2
Language: C++

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

int main(){
  int n;
  cin >> n;
  int half = n/2;
  int odd[half+1], even[half];
  for(int i=0; i<half+1; i++){
    cin >> odd[i] >> even[i];
  }
  int count1[100001], count2[100001];
  for(int i=0; i<half+1; i++){
    count1[odd[i]]++;
    count2[even[i]]++;
  }
  int max1=0, max2=0, max3=0, max4=0;
  for(int i=0; i<100001; i++){
    if(max1 < count1[i]){
      max1 = count1[i];
      int flag1 = i;
    }else if(max2 < count1[i]){
      max2 = count1[i];
    }
  }
  for(int i=0; i<100001; i++){
    if(max3 < count2[i]){
      max3 = count2[i];
      int flag2 = i;
    }else if(max4 < count2[i]){
      max4 = count2[i];
    }
  }
  if(flag1==flag2){
    cout << count1[flag1] + max(count1[flag3],count2[flag4]) << endl;
  }else{
    cout << count1[flag1] + count2[flag2] << endl;
  }
  return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:6: error: 'flag1' was not declared in this scope
   34 |   if(flag1==flag2){
      |      ^~~~~
a.cc:34:13: error: 'flag2' was not declared in this scope
   34 |   if(flag1==flag2){
      |             ^~~~~
a.cc:35:40: error: 'flag3' was not declared in this scope
   35 |     cout << count1[flag1] + max(count1[flag3],count2[flag4]) << endl;
      |                                        ^~~~~
a.cc:35:54: error: 'flag4' was not declared in this scope
   35 |     cout << count1[flag1] + max(count1[flag3],count2[flag4]) << endl;
      |                                                      ^~~~~
Language: C++

#include <iostream>
#include <map>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

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

  v = new int[n];
  REP(i,n) {
    cin >> v[i];
  }
  
  map<int, int> count_odd, count_even;
  REP(i,n) {
    if (i % 2 == 0) {
      count_odd[v[i]] += 1;
    } else {
      count_even[v[i]] += 1;
    }
  }
  const auto max_odd_pair = max_element(ALL(count_odd));
  auto max_even_pair = max_element(ALL(count_even));
  const auto [key_odd, value_odd] = *max_odd_pair;
  auto [key_even, value_even] = *max_even_pair;

  if (key_odd == key_even) {
    count_even.erase(max_even_pair);

    if (empty(count_even)) value_even = 0;
    else {
      max_even_pair = max_element(ALL(count_even));
      value_even = (*max_even_pair).second;
    }
  }

  cout << (n/2 - value_odd) + (n/2 - value_even) << endl;

  delete[] v;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:29: error: 'max_element' was not declared in this scope
   33 |   const auto max_odd_pair = max_element(ALL(count_odd));
      |                             ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <map>

using namespace std;

bool cmp(const vector<int> &a, const vector<int> &b)
{
    return a[1] > b[1];
}

int main(int argc, const char * argv[]) {
    int n = 0;
    cin >> n;
    
    int v[n];
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    map<int, int> m_even;
    map<int, int> m_odd;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            m_even[v[i]]++;
        } else {
            m_odd[v[i]]++;
        }
    }
    
    vector<vector<int>> v1;
    for (std::map<int, int>::iterator i = m_even.begin(); i != m_even.end(); i++) {
        vector<int> tmp;
        tmp.push_back(i->first);
        tmp.push_back(i->second);
        v1.push_back(tmp);
    }
    
    sort(v1.begin(), v1.end(), cmp);
    vector<int> tmp;
    tmp.push_back(0);
    tmp.push_back(0);
    v1.push_back(tmp);
    
    vector<vector<int>> v2;
    for (std::map<int, int>::iterator i = m_odd.begin(); i != m_odd.end(); i++) {
        vector<int> tmp;
        tmp.push_back(i->first);
        tmp.push_back(i->second);
        v2.push_back(tmp);
    }
    
    sort(v2.begin(), v2.end(), cmp);
    v2.push_back(tmp);
    
    if (v1[0][0] != v2[0][0]) {
        cout << n - v1[0][1] - v2[0][1] << endl;
    } else {
        cout << min(n - v1[0][1] - v2[1][1], n - v2[0][1] - v1[1][1]) << endl;
    }
    
    return 0;
}


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

    #include <iostream>
    #include <vector>
    #include <pair>
    #include <algorithm>

    using namespace std;

    #define int long long

    signed main(){
    int n;
    const int MAX = (int) 1e10;
    cin >> n;
    vector<int> O(MAX+1), E(MAX+1);
    pair<int, int> o_max, e_max, o_sec_max, e_sec_max;
    o_max.first = o_max.second = 2;
    e_max.first = e_max.second = 0;
    for(int i=0; i<n; ++i){
        int tmpin;
        cin >> tmpin;
        if(i%2){
            //Odd
            if(O[tmpin]>o_max.second){
                o_sec_max.first = o_max.first;
                o_sec_max.second = o_max.second;
                o_max.first = tmpin;
                o_max.second = O[tmpin];
            }
            else if(O[tmpin]>o_sec_max.second){
                o_sec_max.first = tmpin;
                o_sec_max.second = E[tmpin];
            }
        }
        else{
            //Even
            E[tmpin]++;
            if(E[tmpin]>e_max.second){
                e_sec_max.first = e_max.first;
                e_sec_max.second = e_max.second;
                e_max.first = tmpin;
                e_max.second = E[tmpin];
            }
            else if(E[tmpin]>e_sec_max.second){
                e_sec_max.first = tmpin;
                e_sec_max.second = E[tmpin];
            }
        }
    } 
    if(o_max.first == e_max.first){
        ans1 = n/2 - o_max.second + (n/2 + n%2) - e_sec_max.second;
        ans2 = n/2 - o_sec_max.second + (n/2 + n%2) - e_max.second;
        cout << min(ans1, ans2) << endl;
    }
    else cout << n/2 - o_max.second + (n/2 + n%2) - e_max.second; 
    return 0;
}

Compiler output:
a.cc:3:14: fatal error: pair: No such file or directory
    3 |     #include <pair>
      |              ^~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <map>
using namespace std;
int A[100001];
int B[100001];
int main(void){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int c;
        cin >> c;
        if(i % 2 == 0){
            A[c] += 1;
        }else{
            B[c] += 1;
        }
    }
    int maxia = 0;
    int indexa = 0;
    int maxib = 0;
    int indexb = 0;
    for(int i = 0; i < N; i++){
        if(maxia < A[i]){
            maxia = A[i];
            indexa = i;
        }
        if(maxib < B[i]){
            maxib = B[i];
            indexb = i;
        }
    }
    if(indexa == indexb){
        sort(A, A+N, greater<int>());
        sort(B, B+N, greater<int>());
        if(A[0] == B[0]){
            cout << maxia << endl;
        }else{
            cout << min(A[0], B[0]) << endl;
        }
    }else{
        cout <<  - maxia - maxib + N << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   34 |         sort(A, A+N, greater<int>());
      |         ^~~~
      |         short
Language: C++

#include <iostream>
#include <map>

#define ELEMENTS_MAX 99999
long long int N, counter_even[ELEMENTS_MAX], counter_odd[ELEMENTS_MAX];

int main(){
	std::cin >> N;
	for( int v, int i=0; i<N; ++i ){
		std::cin >> v;
		if( i % 2 ){
			counter_even[v]++;
		} else{
			counter_odd[v]++;
		}
	}

	int max_counted[2] = {0,0};
	for( int i=0; i<N; i++ ){
		if( counter_even[i] > max_counted[0] ){
			max_counted[0] = counter_even[i];
		}
		if( counter_odd[i] > max_counted[1] ){
			max_counted[1] = counter_odd[i];
		}
	}

	std::cout << (N-max_counted[0]) + (N-max_counted[1]) << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:21: error: expected unqualified-id before 'int'
    9 |         for( int v, int i=0; i<N; ++i ){
      |                     ^~~
a.cc:9:20: error: expected ';' before 'int'
    9 |         for( int v, int i=0; i<N; ++i ){
      |                    ^~~~
      |                    ;
a.cc:9:33: error: expected ')' before ';' token
    9 |         for( int v, int i=0; i<N; ++i ){
      |            ~                    ^
      |                                 )
a.cc:9:37: error: 'i' was not declared in this scope
    9 |         for( int v, int i=0; i<N; ++i ){
      |                                     ^