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

//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>data(n);
	map<int, int>Omp;
	map<int, int>Emp;
	for (int i = 0; i < n; i++) {
		cin >> data[i];
		if (i % 2 == 0) {
			Omp[data[i]]++;
		}
		else {
			Emp[data[i]]++;
		}
	}
	int OM, Om, EM, Em, On, En;
	OM = EM = 0;
	for (auto it = Omp.begin(); it != Omp.end(); it++) {
		if (OM <= it->second) {
			Om = OM;
			OM = it->second;
			On = it->first;
		}
	}
	for (auto it = Emp.begin(); it != Emp.end(); it++) {
		if (EM <= it->second) {
			Em = EM;
			EM = it->second;
			En = it->first;
		}
	}
	else {
		if (On == En) {
			if (OM <= EM) {
				cout << n - (EM + Om) << endl;
			}
			else {
				cout << n - (OM + Em) << endl;
			}
			return 0;
		}
		else {
			cout << n - (OM + EM) << endl;
			return 0;
		}
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:135:9: error: 'else' without a previous 'if'
  135 |         else {
      |         ^~~~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector<pii> cnt0(100001), cnt1(100001);
    for (int i = 0; i < cnt0.size(); ++i) {
        cnt0[i] = cnt1[i] = {0, i};
    }
    for (int i = 0; i < n; ++i) {
        if (i & 1) {
            cnt1[a[i]].first++;
        }
        else {
            cnt0[a[i]].first++;
        }
    }
    sort(cnt0.rbegin(), cnt0.rend());
    sort(cnt1.rbegin(), cnt1.rend());
    int res = n;
    if (cnt0[0].second != cnt1[0].second) {
        cout << n - cnt0[0].first - cnt1[0].first << endl;
        return;
    }
    else {
        res = min(res - cnt0[0].first - cnt1[1].first, res - cnt1[0].first - cnt0[1].first) << endl;
    }
    cout << res << endl;


}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
        solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:73:93: error: invalid operands of types 'const int' and '<unresolved overloaded function type>' to binary 'operator<<'
   73 |         res = min(res - cnt0[0].first - cnt1[1].first, res - cnt1[0].first - cnt0[1].first) << endl;
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
Language: C++

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

ll ans = 0;

const int N = pow(10,5)/2 + 5;
ll x[N] = {},y[N] = {};

int main(){
    int n;
    cin >> n;
    int k = 0,l = 0;
    for(int i = 0; i < n; ++i){
        if(i % 2 == 0){
            cin >> x[k];
            k++;
        }else{
            cin >> y[l];
            l++;
        }
    }

    sort(x,x+n/2);
    sort(y,y+n/2);

    int a = -1,b = -1,c1=1,c2=1,aa = -1,bb=-1,aaa,bbb;

    for(int i = 1; i < n/2; ++i){
        if(x[i] == x[i - 1]){
            c1++;
        }else{
            if(a < c1){
                aaa = x[i - 1];
                aa = a;
                a = c1;
            }
            else if(aa < c1) aa = c1
            c1 = 1;
        }
        if(y[i] == y[i - 1]){
            c2++;
        }else{
            if(b < c2){
                bbb = y[i-1];
                bb = b;
                b = c2;
            }
            else if(bb < c1) bb = c1;
            c2 = 1;
        }
    }

    if(a < c1){
        aaa = x[n/2-1];
        aa = a;
        a = c1;
    }
    else if(aa < c1) aa = c1;

    if(b < c2){
        bbb = y[n/2-1];
        bb = b;
        b = c2;
    }
    else if(bb < c1) bb = c1;


    if(aaa == bbb){
        if(a > b) cout << n - a - bb << endl;
        else cout << n - aa - b << endl;
    }else{
        cout << n - a - b << endl;
    }


}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:37: error: expected ';' before 'c1'
   38 |             else if(aa < c1) aa = c1
      |                                     ^
      |                                     ;
   39 |             c1 = 1;
      |             ~~
Language: C++

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

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

int main() {
  int n;
  scanf("%d", &n);

  map<int, int> om;
  map<int, int> em;
  int check = 0;
  for (int i = 0; i < n / 2; i++) {
    int o, e;
    scanf("%d%d", &o, &e);
    om[o]++;
    em[e]++;
    check ^= o ^ e;
  }

  if (check == 0) {
    printf("%d", n / 2);
    return 0;
  }

  vector<pair<int, int>> ov;
  for (auto oe : om) ov.push_back(make_pair(oe.first, oe.second));
  vector<pair<int, int>> ev;
  for (auto ee : em) ev.push_back(make_pair(ee.first, ee.second));
  sort(ov.begin(), ov.end(), compare);
  sort(ev.begin(), ev.end(), compare);

  int ans = 0;
  int O1_key = ov.at(0).first;
  int O1 = ov.at(0).second;
  int E1_key = ev.at(0).first;
  int E1 = ev.at(0).second;
  ans = n - O1 - E1;
  if (O1_key == E1_key) {
    int O2 = ov.at(1).second;
    int E2 = ev.at(1).second;
    ans = min((n - O1 - E2), (n - O2 - E1));
    }
  }

  printf("%d", ans);
  return 0;
}

Compiler output:
a.cc:49:9: error: expected constructor, destructor, or type conversion before '(' token
   49 |   printf("%d", ans);
      |         ^
a.cc:50:3: error: expected unqualified-id before 'return'
   50 |   return 0;
      |   ^~~~~~
a.cc:51:1: error: expected declaration before '}' token
   51 | }
      | ^
Language: C++

#include <bits/stdc++.h>

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int n;
	
	cin >> n;
	
	int v[n], count_a[100000]  = {}, count_e[100000] = {};
	
	rep(i, n){
		cin >> v[i];
		if(i % 2 == 0)
			count_e[v[i]]++;
		else
			count_a[v[i]]++;
	}
	
	sort(count_a, count_a + 100000, greater<int>());
	sort(count_e, count_e + 100000, greater<int>());
	
	int ans = 0;
	
	rep(i, 100000){
		ans += count_a[i + 1];
		ans += count_e[i + 1];
	}
	
	bool same = true;
	rep(i, n - 1)
		if(v[i] != v[i + 1])
			same = false;
		
	if(same){
		cout << n / 2;
		return 0;
	}
		
	if(ans != 0)
		cout << ans;
	else{
		cout << 0;
	}
	
	return 0;
}v

Compiler output:
a.cc:54:2: error: 'v' does not name a type
   54 | }v
      |  ^
Language: C++

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

int main(){
    int n; cin>>n;
    vector<int> v(n);
    vector<int> odd_count(1e5+1,0);
    vector<int> even_count(1e5+1,0);

    for(int i=0; i<n; i++)cin>>v[i];    
    
    for(int i=0; i<n; i += 2){
        odd_count[v[i]]++;
    }

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

    sort(odd_count.begin(),odd_count.end());
    sort(even_count.begin(),even_count.end());

    int p1 = n-(odd_count[1e5]+even_count[1e5-1]);
    int p2 = n-(odd_count[1e5-1]+even_count[1e5]);
    
    cout<<min(p1,p2)<<endl;
    
    return 0;
}#include <bits/stdc++.h>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> v(n);
    vector<int> odd_count(1e5+1,0);
    vector<int> even_count(1e5+1,0);

    for(int i=0; i<n; i++)cin>>v[i];    
    
    for(int i=0; i<n; i += 2){
        odd_count[v[i]]++;
    }

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

    sort(odd_count.begin(),odd_count.end());
    sort(even_count.begin(),even_count.end());

    int p1 = n-(odd_count[1e5]+even_count[1e5-1]);
    int p2 = n-(odd_count[1e5-1]+even_count[1e5]);
    
    cout<<min(p1,p2)<<endl;
    
    return 0;
}

Compiler output:
a.cc:29:2: error: stray '#' in program
   29 | }#include <bits/stdc++.h>
      |  ^
a.cc:29:3: error: 'include' does not name a type
   29 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:32:5: error: redefinition of 'int main()'
   32 | int main(){
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main(){
      |     ^~~~
Language: C++

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

int main(){
    int n,v,ans;
    cin >> n;
    map<int, int> V0,V1;
    pair<int, int> v1top = make_pair(-1, 0),v1sec = make_pair(-1, 0), v0top = make_pair(-1, 0), v0sec = make_pair(-1, 0);

    
    for(int i=0;i<n;i++){
        cin >> v;
        if(i%2){
            V1[v]++;
        }else{
            V0[v]++;
        }
    }

    for(auto iter = V0.begin();iter!=V0.end();iter++){
        if(v0top.second < iter->second){
            v0top.first = iter->first;
            v0top.second = iter->second;
        }else if(v0sec.second < iter->second){
            v0sec.first = iter->first;
            v0sec.second = iter->second;
        }
    }
  
    for(auto iter = V1.begin();iter!=V1.end();iter++){
        if(v1top.second < iter->second){
            v1top.first = iter->first;
            v1top.second = iter->second;
        }else if(v1sec.second < iter->second){
            v1sec.first = iter->first;
            v1sec.second = iter->second;
        }
    }
  
    if(v0top.first==v1top.first){
        if(v0top.second == v1top.second){
            if(v0sec.second < v1sec.second){
            ans = n-v0top.secon-v1sec.second;
            }else{
            ans = n-v0sec.second-v1top.second;
            }
        }else if(v0top.second > v1top.second){
            ans = n-v0top.second-v1sec.second;
        }else{
            ans = n-v0sec.second-v1top.second;
        }
    }else{
        ans = n-v0top.second-v1top.second;
    }
    cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:43:27: error: 'struct std::pair<int, int>' has no member named 'secon'; did you mean 'second'?
   43 |             ans = n-v0top.secon-v1sec.second;
      |                           ^~~~~
      |                           second
Language: C++

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

int main(){
  int j,n,t,ans,v[2][100001],m[2],c[2];cin>>n;
  REP(i,n){
    j=i%2;
    cin>>t;v[j][t]++;
    if(v[j][t]>m[j]) m[j]=v[j][t],c[j]=t;
  }
  if(c[0]!=c[1]) ans=n-m[0]-m[1];
  else{
    sort(v[0],v[0]+100001,greater<int>);
    sort(v[1],v[1]+100001,greater<int>);
    ans=n-max(m[0]+v[1][1],m[1]+v[0][1]);
  }  
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:39: error: expected primary-expression before ')' token
   14 |     sort(v[0],v[0]+100001,greater<int>);
      |                                       ^
a.cc:15:39: error: expected primary-expression before ')' token
   15 |     sort(v[1],v[1]+100001,greater<int>);
      |                                       ^
Language: C++

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

int main(){
  int n,t,ans,mo=0,me=0,co,ce;cin>>n;
  vector<int> ve(100001,0),vo(100001,0);
  REP(i,n){
    cin>>t;
    if(i%2){
      vo.at(t)++;
      if(vo.at(t)>mo) mo=vo.at(t),co=t;
    }else{
      ve.at(t)++;
      if(ve.at(t)>me) me=ve.at(t),ce=t;
    }
  if(co!=ce) ans=n-mo-me;
  else{
    sort(ve.begin(),ve.end(),greater<int>());
    sort(vo.begin(),vo.end(),greater<int>());
    ans=n-max(mo+ve.at(1),me+vo.at(1));
  }  
  cout<<ans;
}

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

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(x, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  ll ans = 0;
  
  int n; cin >> n;
  vector<int> seq(n);
  rep(i, n) cin >> seq[i];
  
  rep(i, numss.size())
  map<int, int> nums0;
  map<int, int> nums1;
  rep(i, n / 2){
    nums0[seq[i * 2 + 0]]++;
    nums1[seq[i * 2 + 1]]++;
  }
  int cnt0 = -1;
  int cnt1 = -1;
  int max0;
  int max2 = 0;
  int max1;
  int max3 = 0;
  rep(i, n / 2){
    if(chmax(cnt0, nums0[seq[i * 2 + 0]])) max0 = seq[i * 2 + 0];
    if(chmax(cnt1, nums1[seq[i * 2 + 1]])) max1 = seq[i * 2 + 1];
  }
  if(max0 != max1) ans = n - nums0[max0] - nums1[max1];
 
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:10: error: 'numss' was not declared in this scope
   55 |   rep(i, numss.size())
      |          ^~~~~
a.cc:2:43: note: in definition of macro 'rep'
    2 | #define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
      |                                           ^
a.cc:59:5: error: 'nums0' was not declared in this scope; did you mean 'nums1'?
   59 |     nums0[seq[i * 2 + 0]]++;
      |     ^~~~~
      |     nums1
a.cc:69:20: error: 'nums0' was not declared in this scope; did you mean 'nums1'?
   69 |     if(chmax(cnt0, nums0[seq[i * 2 + 0]])) max0 = seq[i * 2 + 0];
      |                    ^~~~~
      |                    nums1
a.cc:72:30: error: 'nums0' was not declared in this scope; did you mean 'nums1'?
   72 |   if(max0 != max1) ans = n - nums0[max0] - nums1[max1];
      |                              ^~~~~
      |                              nums1
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int v[n];
  int i;
  int odd[100001] = {};
  int even[100001] = {};
  int oddMax = 0;
  int evenMax = 0;
  int odd2nd = 0;
  int even2nd = 0;
  for(i=0;i<n;i++){
    cin >> v[i];
    if(i%2 == 0) even[v[i]]++;
    else odd[v[i]]++;
  }
for(i=1;i<=100000){
  if(odd[i]>odd[oddMax]){
    odd2nd = oddMax;
    oddMax = i;
  }
  if(even[i]>even[evenMax]){
    even2nd = evenMax;
    evenMax = i;
  }
}
if(evenMax == oddMax){
  if(odd[oddMax]-odd[odd2nd]>even[evenMax]-even[even2nd]) evenMax=even2nd;
  else oddMax = odd2nd;
}
cout << n-odd[oddMax]-even[evenMax];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: expected ';' before ')' token
   19 | for(i=1;i<=100000){
      |                  ^
      |                  ;
Language: C++

#include<bits/stdc++.h>
using namespase std;
int main(){
  int n;
  cin >> n;
  int v[n];
  int i;
  for(i=0;i<n;i++){
    cin >> v[i];
  }
  int odd[100000];
  int even[100000];
  for(i=0;i<n;i++){
    if(i%2==0)even[v[i]]++;
    else odd[v[i]]++;
  }
  int maxOdd=0;
  int maxEven = 0;
  int secondOdd = 0;
  int secondEven = 0;
  
  for(i=1;i<=100000;i++){
    if(odd[i]>odd[maxOdd]){
      secondOdd = maxOdd;
      maxOdd = i;
    }
    if(even[i]>even[maxEven]){
      secondEven = maxEven;
      maxEven = i;
    }
  }
    if(maxOdd==maxEven){
      if(odd[maxOdd]-odd[secondOdd]>even[maxEven]-even[secondEven])maxEven = secondEven;
      else maxOdd = secondOdd;
    }
    cout << n-odd[maxOdd]-even[maxEven];
  }
    
  
  

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namespase'
    2 | using namespase std;
      |       ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:36:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   36 |     cout << n-odd[maxOdd]-even[maxEven];
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
int main(){
  int n;
  cin >> n;
  int v[n];
  int i;
  for(i=0;i<n;i++){
    cin >> v[i];
  }
  int odd[100000];
  int even[100000];
  for(i=0;i<n;i++){
    if(i%2==0)even[v[i]]++;
    else odd[v[i]]++;
  }
  int maxOdd=0;
  int maxEven = 0;
  int secondOdd = 0;
  int secondEven = 0;
  
  for(i=1;i<=100000;i++){
    if(odd[i]>odd[maxOdd]){
      secondOdd = maxOdd;
      maxOdd = i;
    }
    if(even[i]>even[maxEven]){
      secondEven = maxEven;
      maxEven = i;
    }
  }
    if(maxOdd==maxEven){
      if(odd[maxOdd]-odd[secondOdd]>even[maxEven]-even[secondEven])maxEven = secondEven;
      else maxOdd = secondOdd;
    }
    cout << n-odd[maxOdd]-even[maxEven];
  }
    
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:35:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   35 |     cout << n-odd[maxOdd]-even[maxEven];
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
int main(){
  int n;
  cin >> n;
  int v[n];
  int i;
  for(i=0;i<n;i++){
    cin >> v[i];
  }
  int maxEven=0;
  int secondEven = 0;
  int maxOdd=0;
  int secondOdd = 0;
  int even[100000]={};
  int odd[100000]={};
  for(i=0;i<n;i++){
    if(i%2==0){
      even[v[i]]++;
    }else{
      odd[v[i]]++;
    }
for(i=1;i<n;i++){
  if(even[i]>even[maxEven]){
    secondEven = maxEven;
    maxEven = i;
  } 
  if(odd[i]>odd[maxOdd]){
    secondOdd = maxOdd;
    maxOdd = i;
  } 
}
if(maxEven == maxOdd){
  if(even[maxEven]>odd[maxOdd]) maxOdd=secondOdd;
  else maxEven=secondEven;
}
cout << n-maxOdd-maxEven;

    
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:36:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   36 | cout << n-maxOdd-maxEven;
      | ^~~~
      | std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <bits/stdc++.h>

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;

ll main() {
  ll n, a, mp1s, mp0s;
  cin >> n;
  map<ll, ll, greater<ll>> mp0, mp1;

  for (ll i = 0; i < n; ++i) {
    cin >> a;
    if (i % 2 == 0)
      mp0[a]++;
    else
      mp1[a]++;
  }

  ll tot0 = 0, max0 = 0;
  for (auto x : mp0) {
    tot0 += x.second;
    max0 = max(max0, x.second);
    mp0s = x.first;
  }
  if (mp0.size() != 1)
    tot0 -= max0;
  else
    tot0 = 0;

  ll tot1 = 0, max1 = 0;
  for (auto x : mp1) {
    tot1 += x.second;
    max1 = max(max1, x.second);
    mp1s = x.first;
  }
  if (mp1.size() != 1)
    tot1 -= max1;
  else
    tot1 = 0;

  ll ans = tot0 + tot1;
  if (tot1 == tot0 && tot0 == 0 && mp1s == mp0s) ans = n / 2;

  cout << ans << endl;
  return 0;
}


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

#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

#define keta setprecision(10) //10桁表示

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<ll> v(n);
	vector<vector<ll>> buc(2, vector<ll>(1e5 + 1, 0));
	rep(i, n)
	{
		cin >> v[i];
		buc[i % 2][v[i]]++;
	}


	ll maL = 0, maR = 0;
	ll maL2 = 0, maR2 = 0;
	int maC1, maC2;

	rep(i, 1e5 + 1)
	{
		int tmp = maL;
		maL = max(maL, buc[0][i]);
		if (tmp < maL || tmp==buc[0][i])
		{
			maC1 = i;
			maL2 = tmp;
		}
		tmp = maR;
		maR = max(maR, buc[1][i]);
		if (tmp < maR || tmp==buc[1][i])
		{
			maC2 = i;
			maR2 = tmp;
		}
	}

	ll ans = 0;
	if (maC1 != maC2)
	{
		ans = n - maR - maL;
	}
	else
	{
		if (maL < maR)
		{
			ans = n - maR - maL2;
		}
		else if (maL > maR)
		{
			ans = n - maL - maR2;
		}
		else
		{
			ans = n - maL - max(maL2, maR2);
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

bool comp(pair<ll,ll> p1, pair<ll,ll> p2){
	if(p1.se == p2.se) return p1.fi < p2.fi;
	return p1.se > p2.se;
}

int main(){
	ll n;cin>>n;
	ll odd[n/2],even[n/2];rep(i,0,n/2)cin>>odd[i]>>even[i];
	vector<ll> v1(100001,0),v2(100001,0);
	rep(i,0,n/2){v1[odd[i]]++;v2[even[i]]++;}
	vector<pair<ll,ll>> p1,p2;
	rep(i,0,100001)if(v1[i]!=0)p1.pb(mp(i,v1[i]));
	rep(i,0,100001)if(v2[i]!=0)p2.pb(mp(i,v2[i]));
  	p1.pb(mp(1000001,-1);p2.pb(mp(1000001,-1);
	sort(all(p1),comp);sort(all(p2),comp);
	if(p1[0].fi == p2[0].fi){
		if(p1.size() == p2.size()) cout<<n/2<<ednl;
		else if(p1[1].se+p2[0].se > p1[0].se+p2[1].se) cout<<n-(p1[1].se+p2[0].se)<<ednl;
		else cout<<n-(p1[0].se+p2[1].se)<<ednl;
	}else{
		cout<<n-(p1[0].se+p2[0].se)<<ednl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:29: error: expected ')' before ';' token
   42 |         p1.pb(mp(1000001,-1);p2.pb(mp(1000001,-1);
      |              ~              ^
      |                             )
a.cc:42:50: error: expected ')' before ';' token
   42 |         p1.pb(mp(1000001,-1);p2.pb(mp(1000001,-1);
      |                                   ~              ^
      |                                                  )
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

bool comp(pair<ll,ll> p1, pair<ll,ll> p2){
	if(p1.se == p2.se) return p1.fi < p2.fi;
	return p1.se > p2.se;
}

int main(){
	ll n;cin>>n;
	ll odd[n/2],even[n/2];rep(i,0,n/2)cin>>odd[i]>>even[i];
	vector<ll> v1(100001,0),v2(100001,0);
	rep(i,0,n/2){v1[odd[i]]++;v2[even[i]]++;}
	vector<pair<ll,ll>> p1,p2;
	rep(i,0,100001)if(v1[i]!=0)p1.pb(mp(i,v1[i]));
	rep(i,0,100001)if(v2[i]!=0)p2.pb(mp(i,v2[i]));
  	p1.pb(mp(1000001,-1);p2.pb(mp(1000001,-1);
	sort(all(p1),comp);sort(all(p2),comp);
	if(p1[0].fi == p2[0].fi){
		if(p1.size() == p2.size() && ) cout<<n/2<<ednl;
		else if(p1[1].se+p2[0].se > p1[0].se+p2[1].se) cout<<n-(p1[1].se+p2[0].se)<<ednl;
		else cout<<n-(p1[0].se+p2[1].se)<<ednl;
	}else{
		cout<<n-(p1[0].se+p2[0].se)<<ednl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:29: error: expected ')' before ';' token
   42 |         p1.pb(mp(1000001,-1);p2.pb(mp(1000001,-1);
      |              ~              ^
      |                             )
a.cc:42:50: error: expected ')' before ';' token
   42 |         p1.pb(mp(1000001,-1);p2.pb(mp(1000001,-1);
      |                                   ~              ^
      |                                                  )
a.cc:45:46: error: expected primary-expression before ')' token
   45 |                 if(p1.size() == p2.size() && ) cout<<n/2<<ednl;
      |                                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

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

int main(){
  int n;cin >> n;
  int a[n/2],b[n/2];
  rep(i,n){
      if(i%2 == 0) cin >> a[i/2];
      else cin >> b[i/2];
  }
  sort(a,a+n/2); sort(b,b+n/2);
  int af,bf,as,bs,Anum = a[0],Bnum = b[0];
  af = bf = as = bs = 0;
  int i = 1;
  while(i<(n/2)){
    int l = 1;
    while(a[i-1]==a[i]) {
      l++;i++;
    }
    if(l>af){
        as = af;af = l;Anum = a[i-1];
    }else if(l > as) as = l;
    
    i++;
  }
  i = 1;
  while(i<(n/2)){
    int l = 1;
    while(b[i-1]==b[i]){
        l++;i++;
    }
    if(l>bf){
        bs = bf; bf = l;Bnum = Bnum[i-1];
    }else if(l>bs) bs = l;

    i++;
  }
  if(Anum == Bnum){
      cout << min(n-af-bs, n-as-bf) << endl;
  }else{
      cout << n-af-bf << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:36: error: invalid types 'int[int]' for array subscript
   37 |         bs = bf; bf = l;Bnum = Bnum[i-1];
      |                                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;
ll main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll N;
    cin >> N;
    vector<ll> v(N);
    rep(i, N) cin >> v[i];
    ll ans = 0;
    map<ll, ll> xmp;
    map<ll, ll> ymp;
    for(ll i = 0; i < N; i++) {
        ll key = v[i];
        if(i % 2 == 0) {
            if(ymp.count(key)) {
                ymp[key]++;
            } else {
                ymp[key] = 1;
            }
        } else {
            if(xmp.count(v[i])) {
                xmp[key]++;
            } else {
                xmp[key] = 1;
            }
        }
    }

    ll ymax = 0;
    ll ykey = 0;
    vector<pair<ll, ll>> p;
    for(auto y : ymp) {
        if(ymax < y.second) {
            ykey = y.first;
        }
    }
    for(auto x : xmp) {
        pair<ll, ll> tmpp = make_pair(x.second, x.first);
        p.push_back(tmpp);
    }
    sort(p.begin(), p.end());
    // cout << ykey << endl;
    // cout << p[p.size() - 2].second << endl;
    ll xkey = p[p.size() - 1].second;

    if(ykey == xkey) {
        if(p.size() == 1) {
            xkey = ykey + 1;
        } else {
            xkey = p[p.size() - 2].second;
        }
    }

    for(ll i = 0; i < N; i++) {
        if(i % 2 == 0) {
            if(v[i] != ykey) {
                ans++;
            }
        } else {
            if(v[i] != xkey) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,j,x,N,cnt=0;
  cin>>N;
  vec e,o;
  pvec ve,vo;
  rep(i,N){
    cin>>x;
    if(i%2){
      e.pb(x);
    }else{
      o.pb(x);
    }
  }
  e.pb(0);o.pb(0);
  vsort(e);
  vsort(o);
  rep1(i,e.size()){
    if(e[i]==e[i-1]){
      ve[v.size()-1].first++;
    }else{
      ve.pb(datas(1,e[i]));
    }
  }
  rep1(i,o.size()){
    if(o[i]==o[i-1]){
      vo[v.size()-1].first++;
    }else{
      vo.pb(datas(1,e[i]));
    }
  }
  vrsort(ve);vrsort(vo);
  ve.pb(datas(0,0));
  vo.pb(datas(0,0));
  i=j=0;
  if(ve[i].second!=vo[j].second){
    if(ve[i+1].first-ve[i].first<vo[j+1].first-vo[j].first)i++;
    else j++;
  }
  cout<<N-ve[i].first-vo[j].first<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:110:10: error: 'v' was not declared in this scope; did you mean 'vo'?
  110 |       ve[v.size()-1].first++;
      |          ^
      |          vo
a.cc:117:10: error: 'v' was not declared in this scope; did you mean 'vo'?
  117 |       vo[v.size()-1].first++;
      |          ^
      |          vo
Language: C++

#include <bits/stdc++.h>
 
int main()
{
    int n;
    std::cin >> n;
    std::unorderd_map<int,int> v[2];
    for (int i = 0; i < n; i+=2) {
        int o,e;
        std::cin >> o >> e;
        v[0][o]++;
        v[1][e]++;
    }
 
    int key[2][2] = {};
    int val[2][2] = {};

    for (auto x : v[0]) {
        if (x.second > val[0][0]) {
            key[0][1] = key[0][0];
            val[0][1] = val[0][0];
            key[0][0] = x.first;
            val[0][0] = x.second;
        } else if (x.second > val[0][1]) {
            key[0][1] = x.first;
            val[0][1] = x.second;
        }
    }
    for (auto x : v[1]) {
        if (x.second > val[1][0]) {
            key[1][1] = key[1][0];
            val[1][1] = val[1][0];
            key[1][0] = x.first;
            val[1][0] = x.second;
        } else if (x.second > val[1][1]) {
            key[1][1] = x.first;
            val[1][1] = x.second;
        }
    }

    if (key[0][0] != key[1][0]) {
        std::cout << n - val[0][0] - val[1][0] << std::endl;
        return 0;
    }
 
    std::cout << n - std::max(val[0][0]+val[1][1], val[1][0]+val[0][1]) << std::endl;
 
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: 'unorderd_map' is not a member of 'std'; did you mean 'unordered_map'?
    7 |     std::unorderd_map<int,int> v[2];
      |          ^~~~~~~~~~~~
      |          unordered_map
a.cc:7:23: error: expected primary-expression before 'int'
    7 |     std::unorderd_map<int,int> v[2];
      |                       ^~~
a.cc:11:9: error: 'v' was not declared in this scope
   11 |         v[0][o]++;
      |         ^
a.cc:18:19: error: 'v' was not declared in this scope
   18 |     for (auto x : v[0]) {
      |                   ^
a.cc:29:19: error: 'v' was not declared in this scope
   29 |     for (auto x : v[1]) {
      |                   ^
Language: C++

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


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n;
  cin>>n;
  map<long long int,long long int> v,w;
  rep(i,n){
    long long int a;cin>>a;
    if(i%2==0){
      v[a]++;
    }else{
      w[a]++;
    }
  }
  long long int key1=0,key2=0,key3=0,key4=0,value1=0,value2=0,value3=0,value4=0;
  for(auto a:v){
    if(a.second>=value1){
    }else
  }
  
  
  
  
  
  
}

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

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,max1=0,max2=0,max3=0,max4=0,ans1,ans2;
  cin>>n;
  vector<int> a(n/2),b(n/2);
  map<int,int> mp1,mp2;
  rep(i,n){
    int m;
    cin>>m;
    if(i%2==0){
      a[i/2]=m;
    }else{
      b[i/2]=m;
    }
  }
  rep(i,n/2){
    mp1[a[i]]++;
    mp2[b[i]]++;
    if(max1<mp1[a[i]]){
      ans3=ans1;
      max1=mp1[a[i]];
      ans1=a[i];
    }
    if(max2<mp2[b[i]]){
      ans4=ans2;
      max2=mp2[b[i]];
      ans2=b[i];
    }
  }
  if(ans1==ans2){
    cout<<min(n-ans1-ans4,n-ans2-ans3)<<endl;
  }else{
    cout<<n-ans1-ans2<<endl;
  }
  
}
///////////////////////////



Compiler output:
a.cc: In function 'int main()':
a.cc:87:7: error: 'ans3' was not declared in this scope; did you mean 'ans2'?
   87 |       ans3=ans1;
      |       ^~~~
      |       ans2
a.cc:92:7: error: 'ans4' was not declared in this scope; did you mean 'ans2'?
   92 |       ans4=ans2;
      |       ^~~~
      |       ans2
a.cc:98:22: error: 'ans4' was not declared in this scope; did you mean 'ans2'?
   98 |     cout<<min(n-ans1-ans4,n-ans2-ans3)<<endl;
      |                      ^~~~
      |                      ans2
a.cc:98:34: error: 'ans3' was not declared in this scope; did you mean 'ans2'?
   98 |     cout<<min(n-ans1-ans4,n-ans2-ans3)<<endl;
      |                                  ^~~~
      |                                  ans2
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>


int main() {
    int N;
    scanf("%d", &N);
    int i;
    int *list_odd = (int*)malloc((100000+1) * sizeof(int));
    int *list_even= (int*)malloc((100000+1) * sizeof(int));
    for(i=0; i<100000+1; i++) {
        list_odd[i] = 0;
        list_even[i] = 0;
    }
    int max_odd = -1;
    int max_odd_index = 0;
    int max_even = -1;
    int max_even_index = 0;
    for(i=0; i<N; i++) {
        scanf("%d", &v[i]);
        if(i % 2 == 0) {
            list_odd[v[i]]++;
            if(list_odd[v[i]] > max_odd) {
                max_odd = list_odd[v[i]];
                max_odd_index = v[i];
            }
        }
        else {
            list_even[v[i]]++;
            if(list_even[v[i]] > max_even) {
                max_even = list_even[v[i]];
                max_even_index = v[i];
            }
        }
    }
    int modify_even = N/2 - max_even;
    int modify_odd = N/2 - max_odd;
    if(v[0] == v[1]) {
        printf("%d\n", N/2);
    }
    else {
        printf("%d\n", modify_even + modify_odd);
    }
    free(v);
    free(list_odd);
    free(list_even);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:21:22: error: 'v' undeclared (first use in this function)
   21 |         scanf("%d", &v[i]);
      |                      ^
main.c:21:22: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>


int main() {
    int N;
    scanf("%d", &N);
    int i;
    int *list_odd = (int*)malloc((100000+1) * sizeof(int));
    int *list_even= (int*)malloc((100000+1) * sizeof(int));
    for(i=0; i<100000+1; i++) {
        list_odd[i] = 0;
        list_even[i] = 0;
    }
    int max_odd = -1;
    int max_odd_index = 0;
    int max_even = -1;
    int max_even_index = 0;
    for(i=0; i<N; i++) {
        int temp;
        scanf("%d", &temp);
        if(i % 2 == 0) {
            list_odd[temp]++;
            if(list_odd[temp] > max_odd) {
                max_odd = list_odd[temp];
                max_odd_index = temp;
            }
        }
        else {
            list_even[temp]++;
            if(list_even[temp] > max_even) {
                max_even = list_even[temp];
                max_even_index = temp;
            }
        }
    }
    int modify_even = N/2 - max_even;
    int modify_odd = N/2 - max_odd;
    if(v[0] == v[1]) {
        printf("%d\n", N/2);
    }
    else {
        printf("%d\n", modify_even + modify_odd);
    }
    free(list_odd);
    free(list_even);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:40:8: error: 'v' undeclared (first use in this function)
   40 |     if(v[0] == v[1]) {
      |        ^
main.c:40:8: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#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 reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e10
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> bool chmax(T &a, T &b){ if(a<b) { a=b; return 1; }}
template<typename T> bool chmin(T &a, T &b){ if(b<a) { a=b; return 1; }}
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T arrdebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, tmp;
    vector<int> evenind(100001, 0);
    vector<int> oddind(100001, 0);
    cin >> n;
    rep(i, n){
        cin >> tmp;
        if(i%2==0) oddind[tmp]++;
        else evenind[tmp]++;
    }

    int evenmax = 0;
    int oddmax = 0;
    bool flg = false;
    int buf = 0;
    rep(i, 1e5){
        int even=-1, odd=-1;
        if(evenind[i] == 0 && oddind[i] == 0) continue;
        if(evenind[i] > evenmax) even = i;
        if(oddind[i] > oddmax) odd = i;
        if(even > 0 && odd > 0){
            if(evenind[i] > oddind[i]){
                evenmax = evenind[i];
            }else if(evenind[i] < oddind[i]){
                oddmax = oddind[i];
            }else{
                flg = true;
                buf = i;
            }
            continue;
        }
        evenmax = max(evenmax, evenind[i]);
        oddmax = max(oddmax, oddind[i]);
    }

    if(flg){
        if(evenmax > oddmax){
            oddmax = max(oddmax, oddind[buf]);
        }else{
            evenmax = max(evenmax, evenind[buf]);
        }
    }

    cout << n/2-evenmax + ceil(n/2)-oddmax << endl;

    return 0;
}

Compiler output:
a.cc:72:35: error: macro "ceil" requires 2 arguments, but only 1 given
   72 |     cout << n/2-evenmax + ceil(n/2)-oddmax << endl;
      |                                   ^
a.cc:9:9: note: macro "ceil" defined here
    9 | #define ceil(a, b) (a+b-1)/b
      |         ^~~~
a.cc: In function 'int main()':
a.cc:72:25: error: invalid operands of types 'll' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator+'
   72 |     cout << n/2-evenmax + ceil(n/2)-oddmax << endl;
      |             ~~~~~~~~~~~~^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 500;
int main() {
  int N;
  cin>>N;
  vector<int> V(N);
  rep(i,N) cin>>V[i];
  map<int,int> mp1;
  map<int,int> mp2;
  int mx1=0,x1;
  int mx2=0,x2;
  rep(i,N/2){//基準の数値をV[2*i], V[2*i+1]とする。
    mp1[V[2*i]]++;
    mx1=max(mx1,mp[V[2*i]]);
    if(mx1==mp[V[2*i]]) x1=V[2*i];
    mp2[V[2*i+1]]++;
    mx2=max(mx2,mp[V[2*i+1]]);
    if(mx2==mp[V[2*i+1]]) x2=V[2*i+1];
  }
  int ans=0;
  int ans1=0,ans2=0;
  if(x1==x2){
    rep(j,N/2){
      if(V[2*j]!=x1) ans1++;
      if(V[2*j+1]!=x2) ans2++;
    }
    ans=min(ans1,ans2);
  }
  
  rep(j,N/2){
    if(V[2*j]!=x1) ans++;
    if(V[2*j+1]!=x2) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'mp' was not declared in this scope; did you mean 'mp2'?
   17 |     mx1=max(mx1,mp[V[2*i]]);
      |                 ^~
      |                 mp2