criyle/codenet-compile-errors huggingface dataset:
Language: Java

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int n=N/2;
				
		int	SetO[]=new int [n];
		int SetE[]=new int [n];
				
		for(int i=0;i<n;i++) {
			SetO[i]=sc.nextInt();
			SetE[i]=sc.nextInt();
		}
				
		int [] maxO=new int[4];
		maxO=max(SetO,n);
		int [] maxE=new int[4];
		maxE=max(SetE,n);
				
		if(maxO[0]==maxE[0]) {
			if((n - maxO[1] + n - maxE[3]) < (n - maxE[1] + n - maxO[3])) // 條件是這樣
				System.out.println(n - maxO[1] + n - maxE[3]);
			else
				System.out.println(n - maxO[3] + n - maxE[1]);
		}
		else
			System.out.println(n - maxO[1] + n - maxE[1]);
					
	}
			
			
	public static int[] max (int [] set,int n) {
		int max=0;
		int maxv=0;
		int maxS=0;
		int maxSv=0;		
		int [] re=new int[4];
				
		int count[]=new int [100001];
		/* JAVA 裡陣列初始值已經是 0
		for(int i=0;i<100001;i++) {
			count[i]=0;
		}
		*/

		for(int j=0;j<n;j++) {
			/*
			for(int f=1;f<10001;f++) {
				if(set[j]==f)
					count[f]++;
			}
			*/
			//等同於直接這樣寫
			count[set[j]]++;
		}
			
		//直接找最多次的值
		for(int i=0;i<=100000;i++) {
			if(count[i]>count[maxv])
				maxv=i;
		}
		//選出出現最多次的值
		/*
			for(int f=0;f<100000;f++) {
				if(count[f]==max)
					maxv=f;
			}
		*/
			
		//直接找次多的值
		for(int i=0;i<=100000;i++) {
			if(count[i]>count[maxSv] && i != maxv)
				maxSv=i;
		}
				
		//選出次數第二多的值
		/*
		for(int i=0;i<100000;i++) {
			if(count[i]==maxS)
				maxSv=i;
		}
		*/
		re[0]=maxv;
		re[1]=count[maxv];
		re[2]=maxSv;
		re[3]=count[maxSv];
		return re;
	}	
}




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

import java.util.Scanner;

class Main{

	static long ans = 0;
	static int N;
	static long M;

	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int[] v = new int[n];
		int[] odd= new int[n/2];
		int[] even= new int[n/2];


		int j = 0;
		for(int i=0;i < n;i++){
			if(i%2==1){
				odd[j] = sc.nextInt();
				j++;
			}else{
				even[j] = sc.nextInt();;
			}
		}


		boolean flag = false;				//全部一緒か見る


		for(int i=0;i < n/2-1;i++){
			if(odd[0] != even[0] || odd[i] != odd[i+1] || even[i] != even[i+1]){
				flag = true;
			}
		}
		if(!flag){
			System.out.println(odd.length);
			return;
		}
		j=0;


		//
		//		for(int i= 0;i < n/2;i++){
		//			System.out.println(odd[i]);
		//		}

		int[] odddata = new int[100001];
		for(int i = 0;i < n/2;i++){			//各数をカウント
			odddata[odd[i]]++;
		}
		int maxodd = 0;
		int firstodd = 0;
		int secondodd = odd[0];

		for(int i = 1;i < 100001;i++){			//最頻数の数値をえる
			if(maxodd<=odddata[i]){
				secondodd = firstodd;
				firstodd = i;
				maxodd = odddata[i];
			}
		}



		int[] evendata = new int[100001];
		for(int i = 0;i < n/2;i++){
			evendata[even[i]]++;
		}
		int maxeven= 0;
		int firsteven = 0;
		int secondeven = even[0];

		for(int i = 1;i < 100001;i++){
			if(maxeven<=evendata[i]){
				secondeven = firsteven;
				firsteven = i;
				maxeven = evendata[i];
			}
		}
		//	System.out.println("firsteven "+firsteven);

		if(firsteven !=firstodd){
			int ans =0 ;
			j = 0;
			for(int i= 0;i < n;i++){
				if(i%2==1){
					if(odd[j] != firstodd){
						ans++;
					}
					j++;
				}else{
					if(even[j] != firsteven){
						ans++;
					}

				}
			}
			System.out.println(ans);
			return;
		}


		j = 0;
		int count = 0;
		for(int i= 0;i < n;i++){
			if(i%2==1){
				if(odd[j] != firstodd){
					count++;
				}
				j++;
			}else{
				if(even[j] != secondeven){
					count++;
				}

			}
		}

		j = 0;
		int subcount = 0;
		for(int i= 0;i < n;i++){
			if(i%2==1){
				if(odd[j] != secondodd){
					subcount++;
				}
				j++;
			}else{
				if(even[j] != firsteven){
					subcount++;
				}

			}
		}

		System.out.println(Math.min(count, subcount)));








	}


}





Compiler output:
Main.java:140: error: ';' expected
		System.out.println(Math.min(count, subcount)));
		                                             ^
1 error
Language: C++

#include <iostream>
#include <utility>
#include <set>
using namespace std;

int main() {
    int n; cin >> n;
    int v[n];
    set <int> s;
    pair <int,int> odd[n/2],even[n/2];
    for (int i=0; i<n; i++){
        cin >> v[i];
        s.insert(v[i]);
    }
    
    for (int i=0; i<n; i=i+2){
        int p; p=v[i];
        int q=0;
        for (int j=0; j<n; j=j+2){
            if (v[j] == p) q++;
        }
        odd[i/2] = make_pair(q,p);
    }
    for (int i=1; i<n; i=i+2){
        int p; p=v[i];
        int q=0;
        for (int j=1; j<n; j=j+2){
            if (v[j] == p) q++;
        }
        even[(i-1)/2] = make_pair(q,p);
    }
    sort(odd,odd+n/2);
    sort(even,even+n/2);
    for (int i=0; i<n/2; i++){
        cout << odd[i].first << " " << odd[i].second << endl;
    }
    for (int i=0; i<n/2; i++){
        cout << even[i].first << " " << even[i].second << endl;
    }
    if (s.size() == 1) cout << n/2 << endl;
    
    else if (odd[n/2 -1].second != even[n/2 - 1].second)
        cout << n - odd[n/2 -1].first-even[n/2 -1].first;
    else if(odd[n/2 -1].first >= even[n/2 -1].first){
        cout << n - odd[n/2 -1].first - even[n/2 -1-even[n/2 -1].first].first << endl;
    }
    else{
        cout << n - even[n/2 -1].first - odd[n/2 -1-odd[n/2 -1].first].first << endl;
        
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   32 |     sort(odd,odd+n/2);
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
using namespace std;



int main()
{
	int n;
	cin >> n;
	int arr[10005];
	vector<pair<int, int>> hold;
	bool check = true;
	for (int i = 1; i <= n; i++) {
		if (i >= 2 && arr[i - 1] != arr[i]) {
			check = false;
		}
		cin >> arr[i];
	}

	if (check) {
		cout << n / 2 << endl;
		return 0;
	}

	hold.push_back(make_pair(arr[1], 1));
	int maxNum = 1;
	int index =0;
	int ans = 0;
	
	for (int i = 3; i <= n; i += 2) {
		bool found = false;
		for (int j = 0; j < hold.size(); j++) {
			if (arr[i] == hold[i].first) {
				hold[i].second++;
				found = false;
			}
			if (hold[i].second > maxNum) {
				maxNum = hold[i].second;
				index = i;
			}
		}
		if (!found) {
			hold.push_back(make_pair(arr[i], 1));
		}
	}

	for (int i = 0; i < hold.size(); i++) {
		if (i != index) {
			ans += hold[i].second;
		}
	}
	

	hold.clear();
	hold.push_back(make_pair(arr[2], 1));
	int maxNum = 1;
	int index = 0;
	for (int i = 4; i <= n; i += 2) {
		bool found = false;
		for (int j = 0; j < hold.size(); j++) {
			if (arr[i] == hold[i].first) {
				hold[i].second++;
				found = false;
			}
			if (hold[i].second > maxNum) {
				maxNum = hold[i].second;
				index = i;
			}
		}
		if (!found) {
			hold.push_back(make_pair(arr[i], 1));
		}
	}

	for (int i = 0; i < hold.size(); i++) {
		if (i != index) {
			ans += hold[i].second;
		}
	}
	

	

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:13: error: redeclaration of 'int maxNum'
   61 |         int maxNum = 1;
      |             ^~~~~~
a.cc:31:13: note: 'int maxNum' previously declared here
   31 |         int maxNum = 1;
      |             ^~~~~~
a.cc:62:13: error: redeclaration of 'int index'
   62 |         int index = 0;
      |             ^~~~~
a.cc:32:13: note: 'int index' previously declared here
   32 |         int index =0;
      |             ^~~~~
Language: C++

int main(){
  int n,evenMax=0,oddMax=0,same=0;
  cin>>n;
  const int SIZE=n+1;
  
  int v[SIZE], count[SIZE]={};
  
  for(int i=1; i<SIZE; i++) 
    cin>>v[i];

  for(int i=1; i<SIZE; i++){
    if(v[1]=v[i]) same+=1;
    for(int j=i; j<SIZE; j+=2)
      if(v[i]==v[j]) count[i]+=1;
  }
  for(int i=1; i<SIZE; i++){
    if(i%2!=0&&count[i]>=oddMax) oddMax=count[i];
    else if(i%2==0&&count[i]>=evenMax) evenMax=count[i];
    }
    
  if(oddMax==0) oddMax=1;
  if(evenMax==0) evenMax=1;
  if(same==n) oddMax=0;
  n-=(oddMax+evenMax);
  
  cout<<n<<endl;
  return 0;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin>>n;
      |   ^~~
a.cc:26:3: error: 'cout' was not declared in this scope; did you mean 'count'?
   26 |   cout<<n<<endl;
      |   ^~~~
      |   count
a.cc:26:12: error: 'endl' was not declared in this scope
   26 |   cout<<n<<endl;
      |            ^~~~
Language: Java


 
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n/2];
        int[] b = new int[n/2];
 
        for(int i = 0; i < n/2; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
 
        int ans_a1 = 1;
        int ans_a2 = 1;
        int ans_b1 = 1;
        int ans_b2 = 1;
        
        Arrays.sort(a);
        Arrays.sort(b);
 
        int k = 1; 
        int l = 1;
        int x1 = a[0];
        int y1 = b[0];
 
        for(int i = 1; i < n/2; i++){
            if(a[i] == a[i-1]){
                k++;
                if(ans_a1 <= k){
                    ans_a2 = ans_a1;
                    ans_a1 = k;
                    x1 = a[i-1];
                }
                else if(ans_a2 <= k){
                    ans_a2 = k;
                }
            }
            else{
                k = 1;
            }
        }
 
 
        for(int i = 1; i < n/2; i++){
            if(b[i] == b[i-1]){
                l++;
                if(ans_b1 <= l){
                    ans_b2 = ans_b1;
                    ans_b1 = l;
                    y1 = b[i-1];
                }
                else if(ans_b2 <= l){
                    ans_b2 = l;
                }
            }
            else{
                l = 1;
            }
        }
        int ans = n - (ans_a1 + ans_b1);
 
        if(ans_a1 == n/2) ans_a2 = 0;
        if(ans_b1 == n/2) ans_b2 = 0;
        if(x1 == y1){
            if(ans_a1 > ans_b1)
                ans = Math.min(n - (ans_a1 + ans_b2), n - (ans_b1 + ans_a2));
        }
        System.out.println(ans);
    }
} 

Compiler output:
Main.java:7: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:7: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
Main.java:22: error: cannot find symbol
        Arrays.sort(a);
        ^
  symbol:   variable Arrays
  location: class Main
Main.java:23: error: cannot find symbol
        Arrays.sort(b);
        ^
  symbol:   variable Arrays
  location: class Main
4 errors
Language: C++

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

int main() {
  int N;
  cin>>N;
  
  vector<int> v(N);
  for(int i=0;i<N;++i){
    cin>>v[i];
  }
  
  // バケット法
  int b_odd[100000]={0};
  int b_even[100000]={0};
  
  for(int i=0;i<N;i=i+2){
    ++b_odd[v[i]];
  }
  
  for(int i=1;i<N;i=i+2){
    ++b_even[v[i]];
  }
  
  // 奇数列の最大と２番目を探索
  int odd1=0, odd2=0;  // インデックス
  int odd_max=0, odd_second=0;  // 個数
  
  for(int i=1;i<=100000;++i){
    if(odd_second<b_odd[i]){
      if(odd_max<b_odd[i]){
        odd2=odd1;
        odd1=i
        odd_second=odd_max;
        odd_max=b_odd[i];
      }
      else{
        odd2=i;
        odd_second=b_odd[i];
      }
    }
  }
  
  // 偶数列の最大と２番目を探索
  int even1=0, even2=0;
  int even_max=0, even_second=0;
  
  for(int i=1;i<=100000;++i){
    if(even_second<b_even[i]){
      if(even_max<b_even[i]){
        even2=even1;
        even1=i
        even_second=even_max;
        even_max=b_even[i];
      }
      else{
        even2=i;
        even_second=b_even[i];
      }
    }
  }
   
  if(odd1!=even1){
    cout<<N-odd_max-even_max;
  }
  else if(odd1==even1){
    
    
  }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:15: error: expected ';' before 'odd_second'
   36 |         odd1=i
      |               ^
      |               ;
   37 |         odd_second=odd_max;
      |         ~~~~~~~~~~
a.cc:55:16: error: expected ';' before 'even_second'
   55 |         even1=i
      |                ^
      |                ;
   56 |         even_second=even_max;
      |         ~~~~~~~~~~~
Language: C++

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

int main() {
  int N;
  cin>>N;
  
  vector<int> v(N);
  for(int i=0;i<N;++i){
    cin>>v[i];
  }
  
  int b_odd[100000]={0};
  int b_even[100000]={0};
  
  for(int i=0;i<N;i=i+2){
    ++b_odd[v[i]];
  }
  
  for(int i=1;i<N;i=i+2){
    ++b_even[v[i]];
  }
  
  int max_odd=0;
  int max_even=0;
  int odd_num=0;
  int even_num=0;
  
  int max_odd_second=0;
  int odd_num_second=0;
  int max_even_second=0;
  int even_num_second=0;
  
  for(int i=1;i<=100000;++i){
    if(max_odd<b_odd[i]){
      max_odd=b_odd[i];
      odd_num=i;
    }
    if(max_even<b_even[i]){
      max_even=b_even[i];
      even_num=i;
    }
  }
  
  // ２番目に多く出る奇数を探索
  for(int i=1;i<=100000 && i!=odd_num;++i){
    if(max_odd_second<b_odd[i]){
      max_odd_second=b_odd[i];
      odd_num_second=i;
    }
  }
  
  // ２番目に多く出る偶数を探索
  for(int i=1;i<=100000 && i!=even_num;++i){
    if(max_even_second<b_even[i]){
      max_even_second=b_even[i];
      even_num_second=i;
    }
  }
  
  int count_odd=(N+1)/2-max_odd;
  int count_even=N/2-max_even;
  
  if(odd_num!=even_num){
    int ans=count_odd+count_even;
    cout<<ans<<endl;
  }
  else　if(odd_num==even_num){
    int count_odd_second=(N+1)/2-max_odd_second;
    int count_even_second=N/2-max_even_second;
    
    if(count_odd==0 && count_even==0)
      cout<<N/2<<endl;
    else{
      if(count_odd_second>count_even_second){
      cout<<count_odd+count_even_second<<endl;
      }
      else{
      cout<<count_odd_second+count_even<<endl;
      }
    }
    
  }
  
}


Compiler output:
a.cc:71:3: error: extended character 　 is not valid in an identifier
   71 |   else　if(odd_num==even_num){
      |   ^
a.cc: In function 'int main()':
a.cc:71:3: error: 'else\U00003000if' was not declared in this scope
   71 |   else　if(odd_num==even_num){
      |   ^~~~~~~~
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[] v=new int[n];
        int t=0;
        for(int i=0;i<n;i++){
            v[i]=sc.nextInt();
        }
        for(int i=0;i<n/2;i++){
            if(i%2==0){
                if(v[i]!=v[i*2]){
                    System.out.println(v[i]);
                    t=1;
                    break;
                }
            }else{
                if(v[i]!=v[i*2+1]){
                    System.out.println(v[i]);
                    t=1;
                    break;
                }
            }
            for(int j=0;j<n;j++){
                if(v[i]==v[j]){
                    t=1;
                    System.out.println(n/2);
                    break;
                }
                
            }
        }
        if(t==0){
            System.out.println(0);
        }
        
     }
}

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

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

int main() {
  int N;
  cin>>N;
  
  int v[N];
  for(int i=0;i<N;++i){
    cin>>v[i];
  }
  
  int b_odd[100000]={0};
  int b_even[100000]={0};
  
  for(int i=0;i<N;i=i+2){
    ++b_odd[v[i]];
  }
  
  for(int i=1;i<N;i=i+2){
    ++b_even[v[i]];
  }
  
  int max_odd=0;
  int max_even=0;
  
  for(int i=0;i<100000;++i){
    max_odd=max(max_odd,b_odd[i]);
    max_even=max(max_even,b_even[i]);
  }
  
  count_odd=(N+1)/2-max_odd;
  count_even=N/2-max_even;
  
  int ans=count_odd+count_even;
  if(count_odd==0 && count_even==0)
    cout<<N/2<<endl;
  else
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:3: error: 'count_odd' was not declared in this scope
   34 |   count_odd=(N+1)/2-max_odd;
      |   ^~~~~~~~~
a.cc:35:3: error: 'count_even' was not declared in this scope
   35 |   count_even=N/2-max_even;
      |   ^~~~~~~~~~
Language: C++

#include <iostream>
#include <set>
#include <vector>

const int maxn = 1e5+7;
std::set<int> a, b;
std::multiset<int> odd, even;
std::vector<std::pair<int, int>> o, e;

int main(int argc, char *argv[]) {  
	int n, v[maxn];
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> v[i];
		if (i%2==1) {
			a.insert(v[i]);
			odd.insert(v[i]);
		} else {
			b.insert(v[i]);
			even.insert(v[i]);
		}
	}
	for (auto it: a) {
		o.push_back(std::make_pair(odd.count(it), it));
	}
	o.push_back(std::make_pair(0, 0));
	for (auto it: b) {
		e.push_back(std::make_pair(even.count(it), it));
	}
	e.push_back(std::make_pair(0, 0));
	std::sort(o.begin(), o.end());
	std::sort(e.begin(), e.end());
	std::reverse(o.begin(), o.end());
	std::reverse(e.begin(), e.end());
	int ans = 0;
	if (o[0].second != e[0].second) {
		ans = n-o[0].first-e[0].first;
	} else {
		ans = n-std::min(o[1].first+e[0].first, o[0].first+e[1].first);
	}
	std::cout << ans << '\n';
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:31:14: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   31 |         std::sort(o.begin(), o.end());
      |              ^~~~
      |              qsort
a.cc:32:14: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   32 |         std::sort(e.begin(), e.end());
      |              ^~~~
      |              qsort
a.cc:33:14: error: 'reverse' is not a member of 'std'
   33 |         std::reverse(o.begin(), o.end());
      |              ^~~~~~~
a.cc:34:14: error: 'reverse' is not a member of 'std'
   34 |         std::reverse(e.begin(), e.end());
      |              ^~~~~~~
Language: Java

import java.util.*;
class Main
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n/2];
        int[] b = new int[n/2];
        Map<Integer, Integer> ma = new HashMap<>();
        Map<Integer, Integer> mb = new HashMap<>();  
        for(int i = 0; i < n/2; i++){
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }
        int[] aa = new int[100002];
        int[] bb = new int[100002];
        for(int i = 0; i < n/2; i++){
            aa[a[i]]--; bb[b[i]]--;
            ma.put(aa[a[i]], a[i]);
            mb.put(bb[b[i]], b[i]);
        }
        Arrays.sort(aa);
        Arrays.sort(bb);
        int ans = aa[0] + bb[0];
        if(ma.get(aa[0]) == mb.get(bb[0])){
            if(aa[1] < bb[0]) ans = aa[1] + bb[0];
            else ans = aa[0] + bb[1];
        }
        ans += n;
        System.out.println(ans);
    }
 }



Compiler output:
Main.java:2: error: '{' expected
class Main
          ^
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
    public static void main (String[] args)
                  ^
  (use --enable-preview to enable unnamed classes)
Main.java:32: error: class, interface, enum, or record expected
 }
 ^
3 errors
Language: Java

import java.util.*;
class Main
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n/2];
        int[] b = new int[n/2];
        Map<Integer, Integer> ma = new HashMap<>();
        Map<Integer, Integer> mb = new HashMap<>();  
        for(int i = 0; i < n/2; i++){
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }
        int[] aa = new int[100002];
        int[] bb = new int[100002];
        for(int i = 0; i < n/2; i++){
            aa[a[i]]--; bb[b[i]]--;
            ma.put(aa[a[i]], a[i]);
            mb.put(bb[b[i]], b[i]);
        }
        Arrays.sort(aa);
        Arrays.sort(bb);
        int ans = aa[0] + bb[0];
        if(ma.get(aa[0]) == mb.get(bb[0])){
            if(aa[1] < bb[0]) ans = aa[1] + bb[0];
            else ans = aa[0] + bb[1];
        }
        ans += ans;
        System.out.println(ans);
    }
 }



Compiler output:
Main.java:2: error: '{' expected
class Main
          ^
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
    public static void main (String[] args)
                  ^
  (use --enable-preview to enable unnamed classes)
Main.java:32: error: class, interface, enum, or record expected
 }
 ^
3 errors
Language: Java

import java.util.Scanner;
import java.util.*;
import java.util.Map.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Long> guu = new HashMap<>();
        Map<Integer, Long> kisu = new HashMap<>();
        guu.put(-1,0L);
        kisu.put(-1,0L);
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (i % 2 == 0) {
                if (guu.containsKey(x)) {
                    guu.put(x, guu.get(x) + 1L);
                    continue;
                }
                guu.put(x, 1L);
                continue;
            }
            if (kisu.containsKey(x)) {
                kisu.put(x, kisu.get(x) + 1L);
                continue;
            }
            kisu.put(x, 1L);
        }
        List<Entry<Integer, Long>> list_guu = createList(guu);
        List<Entry<Integer, Long>> list_kisu = createList(kisu);

        long ans1 = list_guu.get(0).getValue();
        if (list_guu.get(0).getKey() == list_kisu.get(0).getKey()) {
            ans1 += list_kisu.get(1).getValue();
        } else {
            ans1 += list_kisu.get(0).getValue();
        }

        long ans2 = list_kisu.get(0).getValue();
        if (list_guu.get(0).getKey() == list_kisu.get(0).getKey()) {
            ans2 += list_guu.get(1).getValue();
        } else {
            ans2 += list_guu.get(0).getValue();
        }

        long cnt = n - Math.max(ans1, ans2);
        System.out.println(cnt);

        list_guu.get(0).getValue() + list_kisu.get(0).getValue()
    }
    public static List<Entry<Integer, Long>> createList(Map<Integer, Long> map) {
        List<Entry<Integer, Long>> list_entries =
            new ArrayList<Entry<Integer, Long>>(map.entrySet());
        Collections.sort(list_entries, new Comparator<Entry<Integer, Long>>() {
            public int compare(Entry<Integer, Long> obj1, Entry<Integer, Long> obj2) {
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });
        return list_entries;
    }
}


Compiler output:
Main.java:48: error: not a statement
        list_guu.get(0).getValue() + list_kisu.get(0).getValue()
                                   ^
Main.java:48: error: ';' expected
        list_guu.get(0).getValue() + list_kisu.get(0).getValue()
                                                                ^
2 errors
Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int v[100001], w[100001];

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    if(i%2==0)v[tmp]++;
    else w[tmp]++;
  }
  int vmax=0, vid=0, wmax=0, wid=0;
  for(int i=0;i<=100000;i++){
    if(vmax<v[i]){
      vid=i;
      vmax=v[i];
    }
    if(wmax<w[i]){
      wid=i;
      wmax=w[i];
    }
  }
  if(vid==wid){
      if(vmax<wmax){
        int vvmax=0, vvid=0;
        for(int i=0;i<=100000;i++){
          if(vid!=i&&vvmax<v[i]){
            vvid=i;
            vvmax=v[i];
          }
        }
        vmax=vvmax;
      }
      else if(vmax>wmax){
        int wwmax=0, wwid=0;
        for(int i=0;i<=100000;i++){
          if(wid!=i&&wwmax<w[i]){
            wwid=i;
            wwmax=w[i];
          }
        }
        wmax=wwmax;
      }
      else{
        int wwmax=0, wwid=0;
        for(int i=0;i<=100000;i++){
          if(wid!=i&&wwmax<w[i]){
            wwid=i;
            wwmax=w[i];
          }
        }
        int wwmax=0, wwid=0;
        for(int i=0;i<=100000;i++){
          if(wid!=i&&wwmax<w[i]){
            wwid=i;
            wwmax=w[i];
          }
        }
        if(wwmax<=vvmax)vmax=vvmax;
        else wmax=wwmax;              
      }
  }
  cout << n-wmax-vmax << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:73:13: error: redeclaration of 'int wwmax'
   73 |         int wwmax=0, wwid=0;
      |             ^~~~~
a.cc:66:13: note: 'int wwmax' previously declared here
   66 |         int wwmax=0, wwid=0;
      |             ^~~~~
a.cc:73:22: error: redeclaration of 'int wwid'
   73 |         int wwmax=0, wwid=0;
      |                      ^~~~
a.cc:66:22: note: 'int wwid' previously declared here
   66 |         int wwmax=0, wwid=0;
      |                      ^~~~
a.cc:80:19: error: 'vvmax' was not declared in this scope; did you mean 'vmax'?
   80 |         if(wwmax<=vvmax)vmax=vvmax;
      |                   ^~~~~
      |                   vmax
Language: C++

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int n;
  vector<int> v(n+1);
  
  cin>>n;
  FORQ(i,1,n){
    cin>>v[i];
  }

  int count_1=0, count_2=0;
  set<int> oddx;
  set<int> evenx;
  
  for(int i=1;i<=n;i=i+2){
    oddx.insert(v[i]);
  }

  for(int i=2;i<=n;i=i+2){
    evenx.insert(v[i]);
  }
  if(oddx.size()==1&&evenx.size()==1&&oddx[1]==evenx[1]){
    cout<<2;
  }else{
    cout<<oddx.size()+evenx.size()-2<<endl;
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:62:43: error: no match for 'operator[]' (operand types are 'std::set<int>' and 'int')
   62 |   if(oddx.size()==1&&evenx.size()==1&&oddx[1]==evenx[1]){
      |                                           ^
a.cc:62:53: error: no match for 'operator[]' (operand types are 'std::set<int>' and 'int')
   62 |   if(oddx.size()==1&&evenx.size()==1&&oddx[1]==evenx[1]){
      |                                                     ^
Language: C++

#include <iostream>
#include <algorithm>
#include <climits>
#include <unistd.h>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    int fo[(int)1e5+5];
    int fe[(int)1e5+5];
    memset(fe, 0, sizeof(fe));
    memset(fo, 0, sizeof(fo));
    int mo1= INT_MIN, mo2= INT_MIN, me1= INT_MIN, me2 = INT_MIN;
    int vo1, vo2, ve1, ve2;
    for (int i = 0; i < n; ++i){
        int x;
        scanf("%d", &x);
        if (i % 2 == 0)
            fe[x]++;
        else
            fo[x]++;
    }
    for (int x = 0; x < (int)1e5+5; ++x){
        if (fe[x] >= me1){
            me2 = me1;
            ve2 = ve1;
            me1 = fe[x];
            ve1 = x;
        }
        else if (fe[x] > me2)
            me2 = fe[x], ve2 = x;
        if (fo[x] >= mo1){
            mo2 = mo1;
            vo2 = vo1;
            mo1 = fo[x];
            vo1 = x;
        }
        else if (fo[x] > mo2)
            mo2 = fo[x], vo2 = x;
    }
    int ans = INT_MAX;
    if (mo2 != INT_MIN){
        if (vo2 != ve2 && me2 != INT_MIN)
            ans = min(ans, n-mo2-me2);
        if (vo2 != ve1 && me1 != INT_MIN)
            ans = min(ans, n-mo2-me1);
    }
    if (mo1 != INT_MIN){
        if (vo1 != ve2 && me2 != INT_MIN)
            ans = min(ans, n-mo1-me2);
        if (vo1 != ve1 && me1 != INT_MIN)
            ans = min(ans, n-mo1-me1);
    }
    cout << ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'memset' was not declared in this scope
   12 |     memset(fe, 0, sizeof(fe));
      |     ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <cmath>
  +++ |+#include <cstring>
    6 | using namespace std;
Language: C++

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

int e[100010];
int o[100010];
int ev[100010];
int ov[100010];

bool same(int *a, int len) {
    for (int i = 1; i < len; i++)
        if (a[i] != a[i+1]) return false;
    return true;
}

bool cmp(int x, int y) {
    return x > y;
}

int main() {
    int n;
    int maxo, maxe, counte = 0, counto = 0;
    
    scanf("%d", &n);
    for (int i = 1; i <= n/2; i++) {
        scanf("%d", &o[i]);
        ov[o[i]]++;

        scanf("%d", &e[i]);
        ev[e[i]]++;
    }
    
    for (int i = 1; i <= n/2; i++) {
        if (ov[o[i]] > counto) {
            counto = ov[o[i]];
            maxo = o[i];
        }
        if (ev[e[i]] > counte) {
            counte = ev[e[i]];
            maxe = e[i];
        }
    }
    sort(ev+1, ev+100010, cmp);
    sort(ov+1, ov+100010, cmp);

    if (maxo != maxe)
        cout << n - (ev[1] + ov[1]) << endl;
    else if (same(v, n))
        cout << n / 2 << endl;
    else
        cout << min(n - (ev[1] + ov[2]), n-(ev[2] + ov[1])) << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:19: error: 'v' was not declared in this scope
   47 |     else if (same(v, n))
      |                   ^
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	
	int n,v[111111],num=0,num2=0;
	cin>>n;
	rep(i,n)cin>>v[i];
	sort(v,v+n);
	int co=0;
	rep(i,n-1){
		if(v[i]==v[i+1])co++;
		else{
			co++;
			num2=num;
			num=max(num,co);
			co=0;
		}
	}
	
	if(co!=0){
		co++;
		num2=num;
		num=max(num,co);
	}
	ans=n-num-num2;
	if(co==n){
		ans=0;
		ans+=n/2;
	}
	
	cout<<ans<<endl;
	
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |         ans=n-num-num2;
      |         ^~~
      |         abs
Language: C++

#include<iostream>

using namespace std;
int main()
{
	int N,i,v[50010],w[50010],cnt_even[100010],cnt_odd[100010];
	int max_even=-1,max_odd=-1,tmp_even,tmp_odd,emx=-1,omx=-1;
	cin >> N;
	for(i=0; i<=100000; i++){
		cnt_even[i] = 0;
		cnt_odd[i] = 0;
	}
	for(i=0; i<N/2; i++){
		cin >> v[i] >> w[i];
		cnt_even[v[i]]++;
		cnt_odd[w[i]]++;
	}
	for(i=0; i<=100000; i++){
		if(max_even == cnt_even){
			tmp_even = -2;
		}else if(max_even < cnt_even[i]){
			max_even = cnt_even[i];
			tmp_even = i;
		}else if(emx <= cnt_even[i]){
			emx = cnt_even[i];
		}
		if(max_odd == cnt_odd){
			tmp_odd = -1;
		}else if(max_odd < cnt_odd[i]){
			max_odd = cnt_odd[i];
			tmp_odd = i;
		}else if(omx < cnt_odd[i]){
			omx = cnt_odd[i];
		}
			
	}
	if(tmp_even != tmp_odd){
		cout << N - max_even - max_odd << endl;
	}else{
		if(max_even + omx <= max_odd + emx){
			cout << N - max_odd - emx << endl;
		}else{
			cout << N - max_even - omx << endl;
		}
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   19 |                 if(max_even == cnt_even){
      |                    ~~~~~~~~~^~~~~~~~~~~
a.cc:27:28: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |                 if(max_odd == cnt_odd){
      |                    ~~~~~~~~^~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;

int main()
{
    int n;
    int a[100000],b[100000];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));

    cin >> n;

    int m = n/2;

    for(int i = 0;i < m;i++)
    {
        int s,t;
        cin >> s >> t;
        a[s-1]++;
        b[t-1]++;
    }

    int im = 1, km = 1, am, bm;

    for(int i = 0;i < 100000;i++)
    {
        if(im < a[i])
        {
            im = a[i];
            am = i;
        }
        if(km < b[i])
        {
            km = b[i];
            bm = i;
        }
    }

    if(am == bm)
    {
        int as = 0, bs = 0;
        for(int i = 0; i < 100000; i++)
        {
            if(i != am && as < a[i])
                as = a[i];
            if(i != am && bs < b[i])
                bs = b[i];
        }
        cout << n -max(im + bs, km + as) << endl;
    }
    else
            cout << n-(im + km) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'memset' was not declared in this scope
    8 |     memset(a,0,sizeof(a));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include<iostearm>
using namespace std;

int main()
{
    int n;
    int a[100000],b[100000];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));

    cin >> n;

    int m = n/2;

    for(int i = 0;i < m;i++)
    {
        int s,t;
        cin >> s >> t;
        a[s-1]++;
        b[t-1]++;
    }

    int im = 1, km = 1, am, bm;

    for(int i = 0;i < 100000;i++)
    {
        if(im < a[i])
        {
            im = a[i];
            am = i;
        }
        if(km < b[i])
        {
            km = b[i];
            bm = i;
        }
    }

    if(am == bm)
    {
        int as = 0, bs = 0;
        for(int i = 0; i < 100000; i++)
        {
            if(i != am && as < a[i])
                as = a[i];
            if(i != am && bs < b[i])
                bs = b[i];
        }
        cout << n -max(im + bs, km + as) << endl;
    }
    else
            cout << n-(im + km) << endl;

    return 0;
}

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

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int ques[2][100007];
int max1=0,max2=0;
int main(){
  for(int i=0;i<2;i++){
  for(int j=0;j<100007;j++){ques[i][j]=0;}
  }
int a;
  cin>>a;
  for(int i=0;i<a;i++){
int inp=0;
    cin>>inp;
    if(a%2==0){
 　 ques[0][inp]++;
	if(ques[0][inp]>max1){max1=ques[0][inp];}
    }
  	else{
    ques[1][inp]++;
    if(ques[1][inp]>max2){max2=ques[1][inp];}
    }
  }
cout<<a-max1-max2<<endl;
}


Compiler output:
a.cc:17:2: error: extended character 　 is not valid in an identifier
   17 |  　 ques[0][inp]++;
      |  ^
a.cc: In function 'int main()':
a.cc:17:2: error: '\U00003000' was not declared in this scope
   17 |  　 ques[0][inp]++;
      |  ^~
Language: C++

#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int ques[2][100007];
int max1=0,max2=0;
int main(){
int a;
  cin>>a;
  for(int i=0;i<a;i++){
int inp=0;
    cin>>inp;
    if(a%2==0){
 　 ques[0][inp]++;
	if(ques[0][inp]>max1){max1=ques[0][inp];}
    }
  	else{
    ques[1][inp]++;
    if(ques[1][inp]>max2){max2=ques[1][inp];}
    }
  }
cout<<a-max1-max2<<endl;
}


Compiler output:
a.cc:14:2: error: extended character 　 is not valid in an identifier
   14 |  　 ques[0][inp]++;
      |  ^
a.cc: In function 'int main()':
a.cc:14:2: error: '\U00003000' was not declared in this scope
   14 |  　 ques[0][inp]++;
      |  ^~
Language: C++

#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v.at(i);
  }

  vector<int> odd(100010, 0);
  vector<int> even(100010, 0);

  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      even.at(v.at(i))++;
    } else {
      odd.at(v.at(i))++;
    }
  }

  int max_e = 0, num_e = 0;
  for (int i = 0; i < even.size(); ++i) {
    if (even.at(i) > max_e) {
      max_e = even.at(i);
      num_e = i;
    }
  }

  int max_o = 0, num_o = 0;
  for (int i = 0; i < odd.size(); ++i) {
    if (odd.at(i) > max_o) {
      max_o = odd.at(i);
      num_o = i;
    }
  }

  sort(odd.begin(), odd.end(), greater<int>);
  sort(even.begin(), even.end(), greater<int>);

  if (num_e != num_o) {
    cout << n - max_e - max_o << endl;
  } else {
    int res = min(n - max_e - odd.at(1), n - max_o - even.at(1));
    cout << res << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:44: error: expected primary-expression before ')' token
   41 |   sort(odd.begin(), odd.end(), greater<int>);
      |                                            ^
a.cc:42:46: error: expected primary-expression before ')' token
   42 |   sort(even.begin(), even.end(), greater<int>);
      |                                              ^
Language: C++

#include <stdio.h>
 
int main(){
        int i,n,maxxx;
	scanf("%d",&n);
	int z[n];
	int count[100000];
	int countt[100000];
	int eq;
	for(i = 0;i < 100000;i++){
	count[i] = 0;//==
	countt[i] = 0;//==
	}
	int max,maxx;
	int maxn = 0;
	int maxnn = 0;
	int maxcloud = 0;
	int maxcloudd = 0;
	for(i = 0;i < n;i++){
	scanf("%d",&z[i]);//n
	if(i % 2 == 0)
		count[z[i]] += 1;//n
	else
		countt[z[i]] += 1;//n
	}
	for(i = 0;i < 100000;i++){
	if(maxn <= count[i]){
		max = i;
		maxcloud = maxn;
		maxn = count[i];}
	if(maxnn <= countt[i]){
                maxxx = maxx;
		maxx = i;
		maxcloudd = maxnn;
		maxnn = countt[i];}
        else if(maxcloud == 0 && maxn > count[i])
                maxcloud == count[i];
         else if(maxcloudd == 0 && maxnn > countt[i])
                maxcloudd == countt[i];

	}
        if(maxcloud + maxnn < maxcloudd + maxn)
                         eq = maxcloudd + maxn;
        else
                         eq = maxcloud + maxnn;
        if(max != maxx && max != maxxx)
  	printf("%d,n - maxnn - maxn);
        else
        printf("%d",n - eq);
        return 0;
}

Compiler output:
a.cc:47:16: warning: missing terminating " character
   47 |         printf("%d,n - maxnn - maxn);
      |                ^
a.cc:47:16: error: missing terminating " character
   47 |         printf("%d,n - maxnn - maxn);
      |                ^~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:48:9: error: expected primary-expression before 'else'
   48 |         else
      |         ^~~~
Language: C++

//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
int n, a[N], mx[N];
struct node{
    int x, y;
    friend bool operator < (node a, node b){
        return a.x > b.x;
    }
}b[2][N];
int main()
{
//    freopen("/Users/wangjiaolv/Desktop/test/in.txt", "r", stdin);
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    for(int j=0;j<2;j++){
        for(int i=1+j;i<=n;i+=2) {
            b[j][a[i]].x ++;
            b[j][a[i]].y = a[i];
        }
    }
    sort(b[0]+1, b[0]+1+N-10);
    sort(b[1]+1, b[1]+1+N-10);
    int ans = n;
    for(int i=1; i<=2; i++){
        for (int j=1; j<=2; j++) {
            if(b[0][i].y != b[1][j].y) ans = min(ans, n - b[0][i].x - b[1][j].x);
        }
    }
    printf("%d\n", ans);
    
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   28 |     sort(b[0]+1, b[0]+1+N-10);
      |     ^~~~
      |     sqrt
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Seq2digit06 {

  public static void main(String[] args) {
    new Seq2digit06().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int nHalf = n >> 1;

      Integer num;
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();;
      int offset=0,next=0;
      char regx = ' ';

      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = new Integer(line.substring(offset, next));
        offset = ++next;

        if((i&1) == 0)
          mapA.merge(num, 1, Integer::sum);
        else
          mapB.merge(num, 1, Integer::sum);
      }

      int[] vm1 = {0,0};
      int[] vm2 = {0,0};
      int[] x   = {0,0};

      for (Map.Entry<Integer,Integer> m : mapA.entrySet()) {
        int val = m.getValue();
        if(vm1[0] <val) {
          vm2[0] = vm1[0];
          vm1[0] = val;
          x[0]  = m.getKey();
        } else if(vm2[0] < val) {
          vm2[0] = val;
        }
      }
      for (Map.Entry<Integer,Integer> m : mapB.entrySet()) {
        int val = m.getValue();
        if(vm1[1] <val) {
          vm2[1] = vm1[1];
          vm1[1] = val;
          x[1]  = m.getKey();
        } else if(vm2[1] < val) {
          vm2[1] = val;
        }
      }

      int ans = 0;
      int cca1 = nHalf - vm1[0];
      int ccb1 = nHalf - vm1[1];
      int cca2 = nHalf - vm2[0];
      int ccb2 = nHalf - vm2[1];

      if(x[0] == x[1])
        ans = cca2 > ccb2 ? cca1 + ccb2 : cca2 + ccb1;
      else
        ans = cca1 + ccb1;

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Compiler output:
Main.java:7: error: class Seq2digit06 is public, should be declared in a file named Seq2digit06.java
public class Seq2digit06 {
       ^
Main.java:30: warning: [removal] Integer(String) in Integer has been deprecated and marked for removal
        num = new Integer(line.substring(offset, next));
              ^
1 error
1 warning
Language: C++

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] odd = new int[100001]; // iが奇数であるviからなる数列Oについて、1-100000までのそれぞれの数が存在する個数
		int[] even = new int[100001];
		Arrays.fill(odd, 0);
		Arrays.fill(even, 0);
		for (int i = 1; i <= n; i++) {
			int v = sc.nextInt();
			if (i%2 != 0) {
				odd[v]++;
			} else {
				even[v]++;
			}
		}

		int odd_max1 = 0;
		int odd_max2 = 0;
		for (int i = 1; i < 100000; i++) {
			if (odd[i] > odd[odd_max1]) {
				odd_max2 = odd_max1;
				odd_max1 = i;
			} else if (odd[i] > odd[odd_max2]) {
				odd_max2 = i;
			}
		}
		int even_max1 = 0;
		int even_max2 = 0;
		for (int i = 2; i < 100001; i++) {
			if (even[i] > even[even_max1]) {
				even_max2 = even_max1;
				even_max1 = i;
			} else if (even[i] > even[even_max2]) {
				even_max2 = i;
			}
		}
		int not_rewrited = 0;
		if (odd_max1 == even_max1) {
			not_rewrited = Math.max(odd[odd_max1] + even[even_max2], odd[odd_max2] + even[even_max1]);
		} else {
			not_rewrited = odd[odd_max1] + even[even_max1];
		}
		System.out.println(n - not_rewrited);
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Arrays;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 	int s[101]
 	int n,sum=0;
 	ll i,j;
 	cin>>n;
 	for(i=0;i<n;i++) cin>>s[i];
 	for(i=0;i<n;i+=2)
 	{
 		for(j=2;j<n;j+=2) if(s[i]!=s[j]) sum++;
	}
	for(i=1;i<n;i+=2)
 	{
 		for(j=3;j<n;j+=2) if(s[i]!=s[j]) sum++;
	}
	cout<<sum;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: expected initializer before 'int'
    7 |         int n,sum=0;
      |         ^~~
a.cc:9:14: error: 'n' was not declared in this scope
    9 |         cin>>n;
      |              ^
a.cc:10:31: error: 's' was not declared in this scope
   10 |         for(i=0;i<n;i++) cin>>s[i];
      |                               ^
a.cc:13:38: error: 's' was not declared in this scope
   13 |                 for(j=2;j<n;j+=2) if(s[i]!=s[j]) sum++;
      |                                      ^
a.cc:13:50: error: 'sum' was not declared in this scope
   13 |                 for(j=2;j<n;j+=2) if(s[i]!=s[j]) sum++;
      |                                                  ^~~
a.cc:17:38: error: 's' was not declared in this scope
   17 |                 for(j=3;j<n;j+=2) if(s[i]!=s[j]) sum++;
      |                                      ^
a.cc:17:50: error: 'sum' was not declared in this scope
   17 |                 for(j=3;j<n;j+=2) if(s[i]!=s[j]) sum++;
      |                                                  ^~~
a.cc:19:15: error: 'sum' was not declared in this scope
   19 |         cout<<sum;
      |               ^~~
Language: C

#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
	int n;
 
 	scanf("%d", &n);
 
	int guu[n];
	int ki[n];

	int gucount = 0;
	int baka = 0;
	int bakavalue = 0;
	int guuindex = 0;

	int kicount = 0;
	int aho = 0;
	int ahovalue = 0;
	int kiindex = 0;
	int input;

	int output = 0;

	if(n < 2 || n > 100000 || n % 2 != 0) {
		exit(0);
	}

	if(n == 2) {
        printf("0");
        return 0;
    }

    for(int i= 0; i < n; i++) {
        guu[i] = 0;
        ki[i] = 0;
    }

    for(int i = 0; i < n; i++) {
        scanf("%d", &input);
        num = i % 2;
        if(num == 0) {
            guu[input]++;
        } else {
            ki[input]++;
        }
    }

    for(int i = 0; i < n; i++) {
        if(guu[i] != 0) {
            if(gucount < guu[i]) {
            	// 2番目のcount(偶数)
                baka = gucount;
                // 2番目のindex(偶数)
                bakavalue = guuindex;
                // 1番目のcount(偶数)
                gucount = guu[i];
                // 1番目のindex(偶数)
                guuindex = i;
            } else if(baka < guu[i]) {
            	// 2番目のcount(偶数)
                baka = guu[i];
                // 2番目のindex(偶数)
                bakavalue = i;
            }
        }
        
        if(ki[i] != 0) {
            if(kicount < ki[i]) {
                aho = kicount;
                ahovalue = kiindex;
                kicount = ki[i];
                kiindex = i;
            } else if(aho < ki[i]) {
                aho = ki[i];
                ahovalue = i;
            }
        }
    }

    if(bakavalue == ahovalue) {
    	if(gucount >= kicount) {
    		output = (n / 2 - gucount) + (n / 2 - aho);
    	} else {
    		output = (n / 2 - baka) + (n / 2 - kicount);
    	}
    } else {
    	output = (n / 2 - gucount) + (n / 2 - kicount);
    }

	printf("%d\n", output);
}

Compiler output:
main.c: In function 'main':
main.c:41:9: error: 'num' undeclared (first use in this function)
   41 |         num = i % 2;
      |         ^~~
main.c:41:9: note: each undeclared identifier is reported only once for each function it appears in