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

#include <bits/stdc++.h>
const int MAXN=100010;
int n;
int a[MAXN];
int f1[MAXN],f2[MAXN];
int maxx(int x,int y){
	return x>y?x:y;
}
int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		i%2==1?f1[a[i]]++:f2[a[i]]++;
	}
	int max1=0,max2=0;
	for(int i=1;i<=100000;i++){
		if(f1[i]>f1[max1])max1=i;
		if(f2[i+1]>f2[max2])max2=i+1;
	}
	if(max1!=max2){
		cout << n-f1[max1]-f2[max2] << endl;
	}
	else{
		int max3=0,max4=0;
		for(int i=1;i<=100000;i++)
		if(f1[i]>f1[max3]&&i!=max1)max3=i;
		for(int i=2;i<=100000;i++)
		if(f2[i]>f2[max4]&&i!=max2)max4=i;
		int ma=maxx(f1[max1]+f2[max4],f2[max2]+f1[max3]);
		cout << n-ma << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |         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:21:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   21 |                 cout << n-f1[max1]-f2[max2] << endl;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:21:48: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   21 |                 cout << n-f1[max1]-f2[max2] << endl;
      |                                                ^~~~
      |                                                std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:30:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   30 |                 cout << n-ma << endl;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:30:33: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   30 |                 cout << n-ma << endl;
      |                                 ^~~~
      |                                 std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<iostream>
#include<math.h>

using namespace std;

char dir[10001][1001];
int movea[10001];
int place[1000][2];
int realplace[2];
//  3
// 1 2
//  4
int m=0;
int n;
void func(int x1,int y1,int x2,int y2,int check){
	if(x1!=x2){
		//cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<check<<endl;
		movea[m]=abs(x1-x2);
		if(x1>x2){dir[m][check]='L';}
		else{dir[m][check]='R';}
		for(int j=0;j<n;j++){
			if(j!=check){dir[m][j]='U';}
		}
		realplace[1]-=movea[m];
		y1-=movea[m];
		m++;
	}
	if(y1!=y2){
		movea[m]=abs(y1-y2)/2;
		if(y1>y2){
			dir[m][check]='D';
			for(int j=0;j<n;j++){
				if(j!=check){dir[m][j]='U';}
			}
			realplace[1]-=movea[m];
		}
		else{
			dir[m][check]='U';
			for(int j=0;j<n;j++){
				if(j!=check){dir[m][j]='D';}
			}
			realplace[1]+=movea[m];
		}
		m++;
	}
}

int main(){
	cin>>n;
	else{
	int u;
	cin>> place[0][0]>>place[0][1];
	u=(abs(place[0][0]+place[0][1]))%2;
	bool ans=true;
	for(int i=1;i<n;i++){
		cin>>place[i][0]>>place[i][1];
		if((place[i][0]+place[i][1])%2!=u){ans=false;}
	}
	realplace[0]=place[0][0];
	realplace[1]=place[0][1];
	if(ans==false){cout<<-1<<endl;}
	else{
		//cout<<"A"<<endl;
		for(int i=1;i<n;i++){
			func(place[0][0],place[0][1],place[i][0],place[i][1],i);
		}
		if(realplace[0]!=0){
			movea[m]=abs(realplace[0]);
			if(realplace[0]<0){
				for(int j=0;j<n;j++){
					dir[m][j]='L';
				}
			}
			else{
				for(int j=0;j<n;j++){
					dir[m][j]='R';
				}
			}
			m++;
		}
		if(realplace[1]!=0){
			movea[m]=abs(realplace[1]);
			if(realplace[1]<0){
				for(int j=0;j<n;j++){
					dir[m][j]='D';
				}
			}
			else{
				for(int j=0;j<n;j++){
					dir[m][j]='U';
				}
			}
			m++;
		}
	cout<<m<<endl;
	for(int i=m-1;i>=0;i--){
		cout<<movea[i];
		if(i!=0){cout<<" ";}
	}
	cout<<endl;
	for(int i=0;i<n;i++){
		for(int j=m-1;j>=0;j--){cout<<dir[j][i];}
		cout<<endl;
	}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:9: error: 'else' without a previous 'if'
   50 |         else{
      |         ^~~~
a.cc:106:2: error: expected '}' at end of input
  106 | }
      |  ^
a.cc:48:11: note: to match this '{'
   48 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

bool func(pair<ll,ll> a , pair<ll,ll> b){
	if(a.first > b.first) return true;
	else return false;
}

int main()
{
	ll N;
	cin >> N;
	N/=2;

	vector<ll> lst[2];
	map<ll,ll> cnt[2];

	rep(i,N){
		ll a, b;
		cin >> a >> b ;
		lst[0].pb(a);
		lst[1].pb(b);
		cnt[0][a]++;
		cnt[1][b]++;
	}

	rmsame(lst[0]);
	rmsame(lst[1]);

	vector<pair<ll,ll> > res[2];
	rep(i,lst[0].size()){res[0].pb(mp(lst[0][i], cnt[0][lst[0][i]]));}
	rep(i,lst[1].size()){res[1].pb(mp(lst[1][i], cnt[1][lst[1][i]]));}

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

	ll ans = N*2-2;
	rep(i, res[0].size())rep(j, res[1].size()){
		if(i >= 1){if(res[0][i].second == res[0][i-1].second) break;}
		if(j >= 1){if(res[1][j].second == res[0][j-1].second) break;}

			ans = min(ans,  N*2- max(res[0][i].second, res[1][j].second));
		}
		else{
			ans = min(ans, N*2 - res[0][i].second - res[1][j].second);
		}
	}
	cout << ans << endl;


	return 0;
}

/*
/^[\w!\x22\#$%&@\'() * +,-.\/;:]+$/
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:69:17: error: 'else' without a previous 'if'
   69 |                 else{
      |                 ^~~~
a.cc:70:53: error: 'i' was not declared in this scope
   70 |                         ans = min(ans, N*2 - res[0][i].second - res[1][j].second);
      |                                                     ^
a.cc:70:72: error: 'j' was not declared in this scope
   70 |                         ans = min(ans, N*2 - res[0][i].second - res[1][j].second);
      |                                                                        ^
a.cc: At global scope:
a.cc:73:9: error: 'cout' does not name a type
   73 |         cout << ans << endl;
      |         ^~~~
a.cc:76:9: error: expected unqualified-id before 'return'
   76 |         return 0;
      |         ^~~~~~
a.cc:77:1: error: expected declaration before '}' token
   77 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	int v[100005];
	int v1[100005];
	int v2[100005];
	int c1[100005]={0};
	int c2[100005]={0};
	cin>>n;
	int cnt1=0;
	int cnt2=0;
	//cout<<n<<endl;
	for(int i=0;i<n;i++){
		int t=0;
		cin>>t;
		v[i]=t;
		if(i%2==0)v1[cnt1++]=t;
		else v2[cnt2++]=t;
	}
	int ans=0;	
	for(int i=0;i<n;i++)
		if(v[0]==v[i])ans++;
	if(ans==n){cout<<n/2<<endl;return 0;}
	
	int first1 = v1[0];
    int second1 = v1[0];
    for(int i=0;i<n/2;i++)
    {
        if(first1 < v1[i])
        {
            second1 = first1;
            first1 = v1[i];
        }
        else if(second1 < v1[i])
        {
            second1 = v1[i];
        }
	}
	int first2 = v2[0];
    int second2 = v2[0];
    for(int i=0;i<n/2;i++)
    {
        if(first2 < v2[i])
        {
            second2 = first2;
            first2 = v2[i];
        }
        else if(second2 < v2[i])
        {
            second2 = v2[i];
        }
	}
	//cout<<first1<<" "<<second1<<endl;
	//cout<<first2<<" "<<second2<<endl;
	if(first1!=first2){
		int cnt1=0;
		for(int i=0;i<n/2;i++)
			if(first1==v1[i])cnt1++;
		int cnt2=0;
		for(int i=0;i<n/2;i++)
			if(first2==v2[i])cnt2++;
		cout<<(n/2-cnt1)+(n/2-cnt2)<<endl;		
	}else{
		int cnt1=0;
		for(int i=0;i<n/2;i++)
			if(first1==v1[i])cnt1++;
		int cnt2=0;
		for(int i=0;i<n/2;i++)
			if(second2==v2[i])cnt2++;
		int ans1=(n/2-cnt1)+(n/2-cnt2);
		int cnt1=0;
		for(int i=0;i<n/2;i++)
			if(second1==v1[i])cnt1++;
		int cnt2=0;
		for(int i=0;i<n/2;i++)
			if(first2==v2[i])cnt2++;
		int ans2=(n/2-cnt1)+(n/2-cnt2);
		cout<<min(ans1,ans2)<<endl;		
	}	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:75:21: error: redeclaration of 'int cnt1'
   75 |                 int cnt1=0;
      |                     ^~~~
a.cc:68:21: note: 'int cnt1' previously declared here
   68 |                 int cnt1=0;
      |                     ^~~~
a.cc:78:21: error: redeclaration of 'int cnt2'
   78 |                 int cnt2=0;
      |                     ^~~~
a.cc:71:21: note: 'int cnt2' previously declared here
   71 |                 int cnt2=0;
      |                     ^~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	int v[100005];
	int v1[100005];
	int v2[100005];
	int c1[100005]={0};
	int c2[100005]={0};
	cin>>n;
	int cnt1=0;
	int cnt2=0;
	//cout<<n<<endl;
	for(int i=0;i<n;i++){
		int t=0;
		cin>>t;
		v[i]=t;
		if(i%2==0)v1[cnt1++]=t;
		else v2[cnt2++]=t;
	}
	int ans=0;	
	for(int i=0;i<n;i++)
		if(v[0]==v[i])ans++;
	if(ans==n){cout<<n/2<<endl;return 0;}
	
	int first1 = v1[0];
    int second1 = v1[0];
    for(int i=0;i<n/2;i++)
    {
        if(first1 < v1[i])
        {
            second1 = first1;
            first1 = v1[i];
        }
        else if(second1 < v1[i])
        {
            second1 = v1[i];
        }
	}
	int first2 = v2[0];
    int second2 = v2[0];
    for(int i=0;i<n/2;i++)
    {
        if(first2 < v2[i])
        {
            second2 = first2;
            first2 = v2[i];
        }
        else if(second2 < v2[i])
        {
            second2 = v2[i];
        }
	}
	cout<<first1<<" "<<second1<<endl;
	cout<<first2<<" "<<second2<<endl;
	if(first1!=first2){
		int cnt1=0;
		for(int i=0;i<n/2;i++)
			if(firts1==v1[i])cnt1++;
		int cnt2=0;
		for(int i=0;i<n/2;i++)
			if(firts2==v1[i])cnt2++;
		cout<<(n/2-cnt1)+(n/2-cnt2)<<endl;		
	}else{
		cout<<0;
	}	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:28: error: 'firts1' was not declared in this scope; did you mean 'first1'?
   62 |                         if(firts1==v1[i])cnt1++;
      |                            ^~~~~~
      |                            first1
a.cc:65:28: error: 'firts2' was not declared in this scope; did you mean 'first2'?
   65 |                         if(firts2==v1[i])cnt2++;
      |                            ^~~~~~
      |                            first2
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
class solution{
public:
    int atcode103c(vector<int> v,int n){
        vector<int> vc=v;
        auto it=unique(vc.begin(),vc.end());
        vc.resize( std::distance(vc.begin(),it) );
        if(vc.size()==1) return floor(n/2);
        else{
            vector<int> odd,even;
        for(int i=0;i<n;++i){
            if(i%2==0) even.push_back(v[i]);
            else odd.push_back(v[i]);
        }//divide into two parts.
        vector<int> oc,ec;//receive two parts count.
        for(int j:odd) oc.push_back(count(odd.begin(),odd.end(),j));
        //for(auto l:oc) cout<<l<<" ";
        for(int k:even) ec.push_back(count(even.begin(),even.end(),k));
        //for(auto l:ec) cout<<l<<" ";
        auto it1=find(ec.begin(),ec.end(),*max_element(ec.begin(),ec.end()));
        auto it2=find(oc.begin(),oc.end(),*max_element(oc.begin(),oc.end()));
        int p1=it1-ec.begin();
        int p2=it2-oc.begin();
        //cout<<p1<<" "<<p2<<endl;
        list<int> e1 (even.begin(),even.end());
        list<int> o1 (odd.begin(),odd.end());
        auto evenmaxrepeat=even[p1];
        auto oddmaxrepeat=odd[p2];
        e1.remove(evenmaxrepeat);
        o1.remove(oddmaxrepeat);
        //return e1.size()+o1.size();
        return e1.size()+o1.size();
        }
    }
};
int main()
{
    solution o;
    int n;
    cin>>n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int tmp;
        cin>>tmp;
        v.push_back(tmp);
    }
    cout<<o.atcode103c(v,n);
}


Compiler output:
a.cc: In member function 'int solution::atcode103c(std::vector<int>, int)':
a.cc:12:33: error: 'floor' was not declared in this scope
   12 |         if(vc.size()==1) return floor(n/2);
      |                                 ^~~~~
Language: C++

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

int main()
{
	int n, maxn1 = 0, max2=0;
	int v[100005];
	cin >> n;
	int u1[50005], u2[50005];
	for (int i = 0; i < n; i+=2)
	{
		cin >> v[i] >> v[i+1];
		u1[v[i]]++; u2[v[i+1]]++;
		maxn1 = max(u1[v[i]], maxn1);
		maxn2 = max(u2[v[i]], maxn2);
	}
	int ans = n - maxn1 - maxn2;
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'maxn2' was not declared in this scope; did you mean 'max2'?
   15 |                 maxn2 = max(u2[v[i]], maxn2);
      |                 ^~~~~
      |                 max2
a.cc:17:31: error: 'maxn2' was not declared in this scope; did you mean 'max2'?
   17 |         int ans = n - maxn1 - maxn2;
      |                               ^~~~~
      |                               max2
Language: Java

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        
        List<int> intlist = new ArrayList<int>();
        
        for(int i = 0; i < N; i++) {
            intList.add(sc.nextInt());
        }
        
        for(int i = 0; i < N; i++) {
            if(intList.get(i) != intList.get(i+2)) {
                count++;
            }
        }
        
        System.out.print(count);
    }

}



Compiler output:
Main.java:10: error: unexpected type
        List<int> intlist = new ArrayList<int>();
             ^
  required: reference
  found:    int
Main.java:10: error: unexpected type
        List<int> intlist = new ArrayList<int>();
                                          ^
  required: reference
  found:    int
Main.java:13: error: cannot find symbol
            intList.add(sc.nextInt());
            ^
  symbol:   variable intList
  location: class Main
Main.java:17: error: cannot find symbol
            if(intList.get(i) != intList.get(i+2)) {
               ^
  symbol:   variable intList
  location: class Main
Main.java:17: error: cannot find symbol
            if(intList.get(i) != intList.get(i+2)) {
                                 ^
  symbol:   variable intList
  location: class Main
5 errors
Language: Java

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        
        List<int> intlist = new List<int>();
        
        for(int i = 0; i < N; i++) {
            intList.add(sc.nextInt());
        }
        
        for(int i = 0; i < N; i++) {
            if(intList.get(i) != intList.get(i+2)) {
                count++;
            }
        }
        
        System.out.print(count);
    }

}



Compiler output:
Main.java:10: error: unexpected type
        List<int> intlist = new List<int>();
             ^
  required: reference
  found:    int
Main.java:10: error: unexpected type
        List<int> intlist = new List<int>();
                                     ^
  required: reference
  found:    int
Main.java:10: error: List is abstract; cannot be instantiated
        List<int> intlist = new List<int>();
                            ^
Main.java:13: error: cannot find symbol
            intList.add(sc.nextInt());
            ^
  symbol:   variable intList
  location: class Main
Main.java:17: error: cannot find symbol
            if(intList.get(i) != intList.get(i+2)) {
               ^
  symbol:   variable intList
  location: class Main
Main.java:17: error: cannot find symbol
            if(intList.get(i) != intList.get(i+2)) {
                                 ^
  symbol:   variable intList
  location: class Main
6 errors
Language: Java

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.SplittableRandom;

public class Main {

    public static void main(String[] args) {
        int N = sc.nextInt();
        int count = 0;
        
        List<int> intlist = new List<int>();
        
        for(int i = 0; i < N; i++) {
            intList.add(sc.nextInt());
        }
        
        for(int i = 0; i < N; i++) {
            if(intList.get(i) != intList.get(i+2)) {
                count++;
            }
        }
        
        System.out.print(count);
    }

}


Compiler output:
Main.java:9: error: cannot find symbol
        int N = sc.nextInt();
                ^
  symbol:   variable sc
  location: class Main
Main.java:12: error: cannot find symbol
        List<int> intlist = new List<int>();
        ^
  symbol:   class List
  location: class Main
Main.java:12: error: unexpected type
        List<int> intlist = new List<int>();
             ^
  required: reference
  found:    int
Main.java:12: error: cannot find symbol
        List<int> intlist = new List<int>();
                                ^
  symbol:   class List
  location: class Main
Main.java:12: error: unexpected type
        List<int> intlist = new List<int>();
                                     ^
  required: reference
  found:    int
Main.java:15: error: cannot find symbol
            intList.add(sc.nextInt());
            ^
  symbol:   variable intList
  location: class Main
Main.java:15: error: cannot find symbol
            intList.add(sc.nextInt());
                        ^
  symbol:   variable sc
  location: class Main
Main.java:19: error: cannot find symbol
            if(intList.get(i) != intList.get(i+2)) {
               ^
  symbol:   variable intList
  location: class Main
Main.java:19: error: cannot find symbol
            if(intList.get(i) != intList.get(i+2)) {
                                 ^
  symbol:   variable intList
  location: class Main
9 errors
Language: C++

#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
#define Maxn 100005
int n,id[Maxn],par[Maxn],sz[Maxn];
long long a[Maxn];
map <long long,int> mp;
int main()	
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		mp[a[i]]=i;
		id[i]=i;
		sz[i]=1;
	}
	sort(id+1,id+n+1,[&](const int &a,const int &b)->bool{return a[x]>a[y];});
	for (int i=1;i<n;++i)
	{
		int x=id[i];
		par[x]=mp[a[x]-n+2*sz[x]];
		if (!par[x]) return (int)puts("-1")*0;
		sz[par[x]]+=sz[x];
	}
	for (int i=1;i<n;++i) a[id[n]]-=sz[id[i]];
	if (a[id[n]]) return (int)puts("-1")*0;
	for (int i=1;i<n;++i) printf("%d %d\n",id[i],par[id[i]]);
	return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:19:72: error: 'x' was not declared in this scope
   19 |         sort(id+1,id+n+1,[&](const int &a,const int &b)->bool{return a[x]>a[y];});
      |                                                                        ^
a.cc:19:77: error: 'y' was not declared in this scope
   19 |         sort(id+1,id+n+1,[&](const int &a,const int &b)->bool{return a[x]>a[y];});
      |                                                                             ^
Language: C++

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

int main ()
{
    int n;
    cin >> n;
    vector<int> v(n/2);
    vector<int> w(n/2);
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            cin >> v[i / 2];
        }
        if (i % 2 == 1) {
            cin >> w[i / 2];
        }
    }
    sort(v.begin(),v.end());
    sort(w.begin(),w.end());
    v.push_back(-1);
    w.push_back(-1);
    int counteven = 0;
    int maxcounteven = 0;
    int beforeeven = -1;
    int secondcounteven = 0;
    int maxcountevenelement = -1;
    for (int i = 0; i < v.size(); ++i) {
        if (beforeeven != v[i]) {
            if (counteven > maxcounteven) {
                secondcounteven = maxcounteven;
                maxcounteven = counteven;
                maxcountevenelement = beforeeven;
            }
            counteven = 1;
        }
        else {
            counteven++;
        }
        beforeeven = v[i];
    }
    int countodd = 0;
    int maxcountodd = 0;
    int beforeodd = -1;
    int secondcountodd = 0;
    int maxcountoddelement = -1;
    for (int i = 0; i < w.size(); ++i) {
        if (beforeodd != w[i]) {
            if (countodd > maxcountodd) {
                secondcountodd = maxcountodd;
                maxcountodd = countodd;
                maxcountoddelement = beforeodd;
            }
            countodd = 1;
        }
        else {
            countodd++;
        }
        beforeodd = w[i];
    }
    int ans = -1;
    if (n == 2) {
        cout << 0;
        return;
    }
    if (maxcountoddelement != maxcountevenelement) {
        ans = n - maxcountodd - maxcounteven;
    }
    else {
        ans = min(n - maxcountodd - secondcounteven, n - maxcounteven -secondcountodd);
    }
    cout << ans;
    /*

    //<<codes for debug>>
    
    cout << endl << "maxcountodd:";
    cout << endl << maxcountodd;
    cout << endl << "maxcounteven:";
    cout << endl << maxcounteven << endl;
    cout << "maxcountevenelement:" << endl;
    cout << maxcountevenelement << endl;
    cout << "maxcountoddelement:" << endl;
    cout << maxcountoddelement << endl;
    cout << "v" << endl;
    for (int i = 0; i < v.size(); ++i) {
        cout << v[i] << endl;
    }
    cout << "w" << endl;
    for (int i = 0; i < w.size(); ++i) {
        cout << w[i] << endl;
    }
    */
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   67 |         return;
      |         ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m[N],ans=1e9,f1[N],f[N];
set<int>st;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>m[i];
		st.insert(m[i]);
		if(i%2==0)f1[m[i]]++;
		else f[m[i]]++;
	}
	if(st.size()==1)
	{
		cout<<n/2;
		return 0;
	}
	sort(f1,f1+N);
	sort(f,f+N);
	if(f1[N-1]==f[N-1])ans=min(n-f1[N-2]-f[N-1],n-f1[N-1]-f[N-2]);
	else ans=n-f1[N-1]-f2[N-1];
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:28: error: 'f2' was not declared in this scope; did you mean 'f1'?
   24 |         else ans=n-f1[N-1]-f2[N-1];
      |                            ^~
      |                            f1
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int cont;
  int arreglo[];  
  for(int i=0; i<n; i++){
    int temp;
    cin>>temp;
    arreglo[i]=temp;
  }
  for(int r=0; r<n/2; r++){
    if(r%2=0){
      if(arreglo[r]!=arreglo[r+2]){
        cont++;
      }
    }
    else{
      if(arreglo[r]!=arreglo[r+2]){
        cont++;
      }
    }
  }
  cout<<cont;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:7: error: storage size of 'arreglo' isn't known
    7 |   int arreglo[];
      |       ^~~~~~~
a.cc:14:9: error: lvalue required as left operand of assignment
   14 |     if(r%2=0){
      |        ~^~
Language: Java

class Main{
public static void main(String[] args){
int n;
  int[] v1,v2;
  {
    Scanner s=new Scanner(System.in);
    n=s.nextInt();
    v1=new int[n];
    v2=new int[n];
    for(int i=0;i<n/2;i++){
    v1[s.nextInt()]++;
    v2[s.nextInt()]++;
    }
  }
  
  System.out.println(n-v1[max(v1)]-v2[max(v2)]);
}
  static int max(int[] v){
  int ans=0;
    for(int i=1;i<v.length;i++){
    if(v[i]>v[ans]){
    ans=i;
    }
    }
    return ans;
  }
}

Compiler output:
Main.java:6: error: cannot find symbol
    Scanner s=new Scanner(System.in);
    ^
  symbol:   class Scanner
  location: class Main
Main.java:6: error: cannot find symbol
    Scanner s=new Scanner(System.in);
                  ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java



import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class question01 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        Map<Integer, Integer> map1 = new HashMap<>();
        Map<Integer, Integer> map2 = new HashMap<>();
        for( int i=1; i<= num; i++ ) {
            int val = Integer.valueOf(sc.nextInt());
            if( i%2 == 0 ) {
                map2.put( val, map2.getOrDefault( val, 0 ) + 1 );
                continue;
            }
            map1.put( val, map1.getOrDefault( val, 0 ) + 1 );
        }
        Stream<Map.Entry<Integer, Integer>> s1 = map1.entrySet().stream().sorted((o1, o2) -> Integer.compare(o2.getValue(), o1.getValue()));
        int aNum = s1.map(Map.Entry::getValue).collect(Collectors.toList()).get(0);
        s1 = map1.entrySet().stream().sorted((o1, o2) -> Integer.compare(o2.getValue(), o1.getValue()));
        int aKey = s1.map(Map.Entry::getKey).collect(Collectors.toList()).get(0);

        Stream<Map.Entry<Integer, Integer>> s2 = map2.entrySet().stream().sorted((o1, o2) -> Integer.compare(o2.getValue(), o1.getValue()));
        int bNum = s2.map(Map.Entry::getValue).collect(Collectors.toList()).get(0);
        s2 = map2.entrySet().stream().sorted((o1, o2) -> Integer.compare(o2.getValue(), o1.getValue()));
        int bKey = s2.map(Map.Entry::getKey).collect(Collectors.toList()).get(0);

        aNum = (num%2 == aNum) ? 0 : Math.abs( (num%2) - aNum );
        bNum = (num%2 == bNum) ? 0 : Math.abs( (num%2) - bNum );

        if( aKey == bKey ) {
            aNum = num%2;
            bNum = 0;
        }
        System.out.println( aNum + bNum );
    }
}

Compiler output:
Main.java:7: error: class question01 is public, should be declared in a file named question01.java
public class question01 {
       ^
1 error
Language: C

#include<set>
#include<map>
#include<list>
#include<queue>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define qread(x) x=read()
#define mes(x,y) memset(x,y,sizeof(x))
#define mpy(x,y) memcpy(x,y,sizeof(x))
#define Maxn 100000 
#define INF 1073741823
inline int read(){
	int f=1,x=0;char ch;
	while(!(ch>='0'&&ch<='9')){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int n,x,ans,max[2][2],num[2][2],a[2][Maxn+1];
int main(){
    qread(n);
    mes(a,0);
	for(int i=0;i<n;i++){
		qread(x);
		a[(i%2)][x]++;
	}
	mes(max,0);mes(num,0);
	for(int i=1;i<=100000;i++){
		if(max[0][0]<=a[0][i]){
			max[1][0]=max[0][0];
			num[1][0]=num[0][0];
			max[0][0]=a[0][i];
			num[0][0]=i; 
		} 
		if(max[0][1]<=a[1][i]){
			max[1][1]=max[0][1];
			num[1][1]=num[0][1];
			max[0][1]=a[1][i];
			num[0][1]=i; 
		} 
	}
	ans=0;
	for(int i=0;i<=1;i++){
		for(int j=0;j<=1;j++){
			if(num[i][0]!=num[j][1])ans=std::max(ans,max[i][0]+max[j][1]);
			else ans=std::max(ans,std::max(max[1-i][0]+max[j][1],max[i][0]+max[1-j][1]));
		}
	}
	printf("%d\n",n-ans);
}

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

import collections
n=int(input())
v = list(map(int,input().split()))
od=[]
ev=[]
k=n/2
cev=0
cod=0

for i in range(0,n,2):
  ev.append(v[i])
  od.append(v[i+1])

ev.sort()
od.sort()

c=collections.Counter(ev)
d=collections.Counter(od)
e=c.most_common()[0][1]
f=d.most_common()[0][1]

if c.most_common()[0][0]==d.most_common()[0][0]:
  e=int(k)
  f=0

print(n-e-f)
    


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: Java



import java.util.*;

public class question01 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        AbstractMap.SimpleEntry<Integer, Integer> a1 = new AbstractMap.SimpleEntry<>(0, 0);
        AbstractMap.SimpleEntry<Integer, Integer> b1 = new AbstractMap.SimpleEntry<>(0, 0);
        AbstractMap.SimpleEntry<Integer, Integer> a2 = new AbstractMap.SimpleEntry<>(0, 0);
        AbstractMap.SimpleEntry<Integer, Integer> b2 = new AbstractMap.SimpleEntry<>(0, 0);
        for( int i=1; i<= num; i++ ) {
            int val = sc.nextInt();
            if( i%4 == 0 ) {
                if( b1.getKey() == val ) {
                    b1 = new AbstractMap.SimpleEntry<>(val, b1.getValue()+1);
                } else {
                    b2 = new AbstractMap.SimpleEntry<>(val, 1);
                }
                continue;
            }
            if( i%3 == 0 && i%6 != 0 ) {
                if( a1.getKey() == val ) {
                    a1 = new AbstractMap.SimpleEntry<>(val, a1.getValue()+1);
                } else {
                    a2 = new AbstractMap.SimpleEntry<>(val, 1);
                }
                continue;
            }
            if( i%2 == 0 ) {
                if( b2.getKey() == val ) {
                    b2 = new AbstractMap.SimpleEntry<>(val, b2.getValue()+1);
                } else {
                    b1 = new AbstractMap.SimpleEntry<>(val, 1);
                }
                continue;
            }
            if( i%1 == 0 ) {
                if( a2.getKey() == val ) {
                    a2 = new AbstractMap.SimpleEntry<>(val, a2.getValue()+1);
                } else {
                    a1 = new AbstractMap.SimpleEntry<>(val, 1);
                }
                continue;
            }
        }
        int a = 0, b = 0;
        if( a2.getValue() != 0 ) {
            a = (a1.getValue() > a2.getValue()) ? a1.getValue() : a2.getValue();
            if( a< 0 ) a *= -1;
            a = (num / 2) - a;
        }
        if( b2.getValue() != 0 ) {
            b = (b1.getValue() > b2.getValue()) ? b1.getValue() : b2.getValue();
            if( b< 0 ) b *= -1;
            b = (num / 2) - b;
        }
        int result = a + b;
        if( result == 0 && a1.getKey() == b1.getKey() ) result = num / 2;

        System.out.println( result );
    }
}

Compiler output:
Main.java:5: error: class question01 is public, should be declared in a file named question01.java
public class question01 {
       ^
1 error
Language: Java

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();

		int[] KISU=new int[100001];
		int[] GUSU=new int[100001];

		for(int i=0; i<=100000; i++) {
			KISU[i]=0;
			GUSU[i]=0;
		}

		for(int i=0; i<N; i++) {
			if(i%2==0) {
				KISU[sc.nextInt()]++;
			}
			else if(i%2==1) {
				GUSU[sc.nextInt()]++;
			}
		}

		int K_MAX=0;
		int G_MAX=0;
		int K_NUM=0;
		int G_NUM=0;
		int K_2nd=0;
		int G_2nd=0;
		int K_2nu=0;
		int G_2nu=0;

		for(int i=0; i<=100000; i++) {
			if(K_MAX<KISU[i]) {
				K_MAX=KISU[i];
				K_NUM=i;
			}

			if(G_MAX<GUSU[i]) {
				G_MAX=GUSU[i];
				G_NUM=i;
			}
		}
/*
		for(int i=0; i<=100000; i++) {
			if(K_2nd<KISU[i] && KISU[i]<K_MAX) {
				K_2nd=KISU[i];
			}

			if(G_2nd<GUSU[i] && GUSU[i]<G_MAX) {
				G_2nd=GUSU[i];
			}
		}*/

		Arrays.sort(KISU);
		Arrays.sort(GUSU);
		K_2nd=KISU[99998];
		G_2nd=GUSU[99998];

		if(K_NUM!=G_NUM) {
			System.out.println(N-K_MAX-G_MAX);
		}
		else if(K_NUM==G_NUM) {
			int[][] mat=new int[2][2];
			mat[0][0]=K_MAX;
			mat[0][1]=K_2nd;
			mat[1][0]=G_MAX;
			mat[1][1]=G_2nd;

			System.out.println(Math.min(N-mat[0][0]-mat[1][1], N-mat[0][1]-mat[1][0]));
		}
	}
}


Compiler output:
Main.java:56: error: cannot find symbol
		Arrays.sort(KISU);
		^
  symbol:   variable Arrays
  location: class Main
Main.java:57: error: cannot find symbol
		Arrays.sort(GUSU);
		^
  symbol:   variable Arrays
  location: class Main
2 errors
Language: Java

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();

		int[] KISU=new int[100001];
		int[] GUSU=new int[100001];

		for(int i=0; i<=100000; i++) {
			KISU[i]=0;
			GUSU[i]=0;
		}

		for(int i=0; i<N; i++) {
			if(i%2==0) {
				KISU[sc.nextInt()]++;
			}
			else if(i%2==1) {
				GUSU[sc.nextInt()]++;
			}
		}

		int K_MAX=0;
		int G_MAX=0;
		int K_NUM=0;
		int G_NUM=0;
		int K_2nd=0;
		int G_2nd=0;
		int K_2nu=0;
		int G_2nu=0;

		for(int i=0; i<=100000; i++) {
			if(K_MAX<KISU[i]) {
				K_MAX=KISU[i];
				K_NUM=i;
			}

			if(G_MAX<GUSU[i]) {
				G_MAX=GUSU[i];
				G_NUM=i;
			}
		}
/*
		for(int i=0; i<=100000; i++) {
			if(K_2nd<KISU[i] && KISU[i]<K_MAX) {
				K_2nd=KISU[i];
			}

			if(G_2nd<GUSU[i] && GUSU[i]<G_MAX) {
				G_2nd=GUSU[i];
			}
		}*/

		Arrays.sort(KISU);
		Arrays.sort(GUSU);
		K_2nd=KISU[99999];
		G_2nd=GUSU[99999];

		if(K_NUM!=G_NUM) {
			System.out.println(N-K_MAX-G_MAX);
		}
		else if(K_NUM==G_NUM) {
			int[][] mat=new int[2][2];
			mat[0][0]=K_MAX;
			mat[0][1]=K_2nd;
			mat[1][0]=G_MAX;
			mat[1][1]=G_2nd;

			System.out.println(Math.min(N-mat[0][0]-mat[1][1], N-mat[0][1]-mat[1][0]));
		}
	}
}


Compiler output:
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
Main.java:54: error: cannot find symbol
		Arrays.sort(KISU);
		^
  symbol:   variable Arrays
  location: class Main
Main.java:55: error: cannot find symbol
		Arrays.sort(GUSU);
		^
  symbol:   variable Arrays
  location: class Main
4 errors
Language: C++

#include<cstdio>
using namespace std;
struct wave{
	int num1,num2
	long long total;
};
int main(){
	int i,n,max=0;
	struct wave a[50005];
	scanf("%d",&n);
	for(i=1;i<=n/2;i++) {
		scanf("%d%d",&a[i].num1,&a[i].num2);
		a[i].total=11111*a[i].num1+a[i].num2;
	}
	for(i=1;i<=n/2;i++)
	{
		int sum=0;
		if(a[i].num1!=a[i].num2)
		do{
			sum++;
			i++;
		}while(a[i].total==a[i-1].total && i<=n/2);
		if(sum>max) max=sum;
	}
	int ans=n/2-max;
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc:4:18: error: expected ';' at end of member declaration
    4 |         int num1,num2
      |                  ^~~~
      |                      ;
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define mod 998244353
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;

typedef pair<int, int> P;

#define dfor(i,a,b) for(int i=(a);i<(b);++i)
#define drfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define drep(i,n) dfor(i,0,n)
#define drrep(i,n) drfor (i,n,0)
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
	void reset(void) {
		drep(i, data.size()) data[i] = -1;
	}
};

int v[2][100001];

int main(void) {
	int n,j,m=0,mm=0,r=0,rr=0,k,l;
	scanf("%d", &n);
	drep(i, 100001) {
		v[0][i] = 0;
		v[1][i] = 0;
	}
	drep(i, n) {
		scanf("%d", &j);
		v[i%2][j]++;
	}
	drep(i, 100001) {
		if (v[0][i] > m) {
			r = m;
			m = v[0][i];
			k = i;
		}
		else if (v[0][i] > r) {
			r = v[0][i];
		}
		if (v[1][i] > mm) {
			rr = mm;
			mm = v[1][i];
			l = i;
		}
		else if (v[1][i] > rr) {
			rr = v[1][i];
		}
	}
	int res;
	if (k == l) {
		res = max(m + rr, mm + r);
	}
	else {
		res = m + mm;
	}
	else {
		printf("%d", n-res);
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:92:9: error: 'else' without a previous 'if'
   92 |         else {
      |         ^~~~
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];
    }
    map<int,int> a;
    map<int,int> b;
    for (int i = 0; i < n-1; i+=2) {
        a[v[i]]+=1;
    }
    for (int i = 1; i < n; i+=2) {
        b[v[i]]+=1;
    }
    priority_queue<pair<int,int>> aq,bq;
    for(auto i:a){
        aq.emplace(i.second,i.first);
    }
    for(auto i:b){
        bq.(i.second,i.first);
    }
    int ans=0;
    if(aq.top().first!=bq.top().first){
        ans+=n/2-aq.top().second;
        ans+=n/2-bq.top().second;
        cout<<ans<<endl;
        return 0;
    }
    else {
        if(aq.top().second>bq.top().second){
            bq.pop();
            ans+=n/2-aq.top().second;
            if(bq.empty())ans+=n/2;
            else ans+=n/2-bq.top().second;
            cout<<ans<<endl;
            return 0;
        }
        else {
            aq.pop();
            if(aq.empty())ans+=n/2;
            else ans+=n/2-aq.top().second;
            ans+=n/2-bq.top().second;
            cout<<ans<<endl;
            return 0;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:12: error: expected unqualified-id before '(' token
   24 |         bq.(i.second,i.first);
      |            ^
Language: C++

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

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int v[100005];
pii o[100005];
pii e[100005];

int main()
{
	int n;
	cin >> n;
	REP(i, n)
	{
		cin >> v[i];
	}

	REP(i, n)
	{
		if (i % 2 == 0)
		{
			e[v[i]].first++;
			e[v[i]].second = v[i];
		}
		else
		{
			o[v[i]].first++;
			o[v[i]].second = v[i];
		}
	}
	sort(e, e + 100005, [](pii a, pii b) {return a.first > b.first; });
	sort(o, o + 100005, [](pii a, pii b) {return a.first > b.first; });
	
	int sum = 0;
	if (e[0].second != o[0].second)
	{
		FOR(i, 100005, 1)
		{
			sum += e[i].first;
			sum += o[i].first;
		}
	}
	else
	{
		//REP(j, 100005)
		{
			//if (e[j].first == o[j].first)continue;
			if (e[0].first < o[0].first)
			{
				sum += e[0].first;
				FOR(i, 100005, 1)
				{
					sum += o[i].first;
				}
				FOR(i, 100005, 2)
				{
					sum += e[i].first;
				}
			}
			else
			{
				sum += o[0].first;
				FOR(i, 100005, 1)
				{
					sum += e[i].first;
				}
				FOR(i, 100005, 2)
				{
					sum += o[i].first;
				}
			}
			break;
		}

	}
	cout << sum << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:95:25: error: break statement not within loop or switch
   95 |                         break;
      |                         ^~~~~
Language: C++

/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;
map < int , int > mp1, mp2 ;
int main ( ){
  scanf("%d",&n);
  for ( int i = 1; i <= n; i++ ) {
    int x ; scanf("%d",&x);
    if ( i &1 ) {
        mp1[x]++;
    }else {
    mp2[x]++;
    }
  }
  int mn = inf ;
   int mx1 = 0 , ixd = -1  , cnt = 0  ;
   for ( auto x : mp1 ) {

    if ( mx1  < x.S ){

       cnt = 1 ;
       ixd = x.F ;
       mx1 = x.S ;
    } else if ( mx1 == x.S){
      cnt++;
    }
   }
   int mx2 = 0 ;
   for ( auto x : mp2 ) {
    if ( mx2 < x.S ){
        if ( ixd == x.F && cnt == 1 ) continue;
        mx2 = x.S ;
    }

   }
     mx1 = (n/2) - mx1 ;
   mx2 = (n/2) - mx2 ;
   mn = min ( mn , mx1+mx2 );
   mx2 = 0 , ixd = -1  , cnt = 0  ;
   for ( auto x : mp2 ) {

    if ( mx2  < x.S ){

       cnt = 1 ;
       ixd = x.F ;
       mx2 = x.S ;
    } else if ( mx2 == x.S){
      cnt++;
    }
   }
   int mx1 = 0 ;
   for ( auto x : mp1 ) {
    if ( mx1 < x.S ){
        if ( ixd == x.F && cnt == 1 ) continue;
        mx1 = x.S ;
    }

   }
   mx1 = (n/2) - mx1 ;
   mx2 = (n/2) - mx2 ;
   mn = min ( mn , mx1+mx2 );
   printf("%d",mn);
 return 0 ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:8: error: redeclaration of 'int mx1'
   65 |    int mx1 = 0 ;
      |        ^~~
a.cc:30:8: note: 'int mx1' previously declared here
   30 |    int mx1 = 0 , ixd = -1  , cnt = 0  ;
      |        ^~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define fs first 
#define sc second 
#define mod 1000000007
#define eps 10e-6
#define ll long long
#define pb push_back
#define lsb(x) (x&(-x))
using namespace std;
int main()
{
    int n,even[100005],odd[100005],x;
    vector<pair<int,int> ev,od;
    memset(odd,0,sizeof(odd));
    memset(even,0,sizeof(even));
    cin>>n;
    rep(i,n)
    {
        cin>>x;
        if(i%2==0)
        {
            even[x]++;
        }
        else
        {
            odd[x]++;
        }
    }
    rep(i,100005)
    {
        ev.pb({even[i],i});
        od.pb({odd[i],i});
    }
    sort(ev.begin(),ev.end());
    sort(od.begin(),od.end());
    reverse(ev.begin(),ev.end());
    reverse(od.begin(),od.end());
    if(ev[0].sc!=od[0].sc)
    {
        cout<<n-ev[0].fs-od[0].fs<<endl;
    }
    else
    {
        cout<<n-max(ev[0].fs+od[1].fs,ev[1].fs+od[0].fs)<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:29: error: template argument 1 is invalid
   14 |     vector<pair<int,int> ev,od;
      |                             ^~
a.cc:14:29: error: template argument 2 is invalid
a.cc:32:9: error: 'ev' was not declared in this scope
   32 |         ev.pb({even[i],i});
      |         ^~
a.cc:33:9: error: 'od' was not declared in this scope; did you mean 'odd'?
   33 |         od.pb({odd[i],i});
      |         ^~
      |         odd
a.cc:35:10: error: 'ev' was not declared in this scope
   35 |     sort(ev.begin(),ev.end());
      |          ^~
a.cc:36:10: error: 'od' was not declared in this scope; did you mean 'odd'?
   36 |     sort(od.begin(),od.end());
      |          ^~
      |          odd
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef  long long ll;
int gcd(int f , int s){if(s==0)return f;else return gcd(s,f%s);}
int const N = 1000006;
ll const M = 1020;
long double const ep = .000000000000000001;
int frq[N] , frq1[N];
int main() {
	#ifndef ONLINE_JUDGE
	
	int a;cin >> a;
	int mx = 0 , tot = 0 , mx1 = 0 , tot1 = 0;
	for(int i = 0 ; i < a ; i++){
		int t;cin >> t;
		if(i%2==0){
			frq[t]++;
			tot++;
		}
		else{
			frq1[t]++;
			tot1++;
		}
	}
	vector<pair<int , int> > v , v1;
	v.pb(mp(0,0));
	v1.pb(mp(0,0));
	for(int i = 0 ; i < 100001; i++){
		if(frq[i]!=0)v.pb(mp(frq[i] , i));
		if(frq1[i]!=0)v1.pb(mp(frq1[i] , i));
	}
	sort(v.rbegin() , v.rend());
	sort(v1.rbegin() , v1.rend());

	mx = v[0].first ;
	mx1 = v1[0].first;
	int lol = mx + mx1;
	if(v[0].second == v1[0].second){
		lol = max(mx + v1[1].first , mx1 + v[1].first);
	}
	cout << tot + tot1 - lol; 
	return 0;
}

Compiler output:
a.cc:12: error: unterminated #ifndef
   12 |         #ifndef ONLINE_JUDGE
Language: C++

#include<iostream>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;

const int maxn = 1100;
ll X[maxn]; ll Y[maxn]; int N;
ll ABS(ll x) { return (x >= 0) ? x : -x; }
ll d[50];

void solve(int k,int pos)
{
	ll XX = X[k]; ll YY = Y[k];
	ll x = 0; ll y = 0;
	for (int i = pos - 1; i >= 0; i--)
	{
		if (ABS(XX - x) > ABS(YY - y))
		{
			if (XX > x) { cout << 'R'; x += d[i]; }
			else if (XX < x) { cout << 'L'; x -= d[i]; }
		}
		else if(ABS(XX-x)<ABS(YY-y))
		{
			if (YY > y) { cout << 'U'; y += d[i]; }
			else if (YY < y) { cout << 'D'; y -= d[i]; }
		}
		else
		{
			if (XX >= x) { cout << 'R'; x += d[i]; }
			else if (XX < x) { cout << 'L'; x -= d[i]; }
		}
	}
	cout << endl;
}

int main()
{
	cin >> N;
	int flag0 = 0; int flag1 = 0; ll pmax = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> X[i] >> Y[i];
		if ((X[i] + Y[i]) % 2 == 0)flag0 = 1;
		else flag1 = 1;
		pmax = max(pmax, ABS(X[i]) + ABS(Y[i]));
	}
	if (flag0 == 1 && flag1 == 1)
	{
		cout << -1 << endl;
		return 0;
	}
	ll sum = 0; int pos = 0;
	if (flag0 == 1) { d[pos++] = 1; sum += 1; }
	for (ll k = 0; k < 50; k++)
	{
		sum += (ll(1) << k);
		d[pos++] = (ll(1) << k);
		if (sum >= pmax)break;
	}
	cout << pos << endl;
	for (int i = pos - 1; i >= 0; i--)
		cout << d[i] << ' ';
	cout << endl;
	
	for (int i = 1; i <= N; i++)
		solve(i, pos);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:12: error: expected primary-expression before 'long'
    4 | #define ll long long
      |            ^~~~
a.cc:57:25: note: in expansion of macro 'll'
   57 |                 sum += (ll(1) << k);
      |                         ^~
a.cc:57:25: error: expected ')' before 'long'
   57 |                 sum += (ll(1) << k);
      |                        ~^
      |                         )
a.cc:4:12: error: expected primary-expression before 'long'
    4 | #define ll long long
      |            ^~~~
a.cc:58:29: note: in expansion of macro 'll'
   58 |                 d[pos++] = (ll(1) << k);
      |                             ^~
a.cc:58:29: error: expected ')' before 'long'
   58 |                 d[pos++] = (ll(1) << k);
      |                            ~^
      |                             )