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

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

public class Main{
	static int num = 0;
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] a = new int[Integer.parseInt(scanner.nextLine())];
		String[] strings = scanner.nextLine().split(" ");
		
		for(int i = 0; i < strings.length; i++) {
			a[i] = Integer.parseInt(strings[i]);
		}
		
		int[] b = sortlist(a);
		for(int i = 0; i < a.length - 1; i++) {
			System.out.print(b[i]+"　");
		}
		System.out.println(b[a.length - 1] + " ");
		System.out.println(num);
		scanner.close();
	}
	
	private static int[] sortlist(int[] i) {
		if(i.length == 1) {
			return i;
		}else {
			
			int[] a = sortlist(Arrays.copyOfRange(i,0,i.length/2));
			int[] b = sortlist(Arrays.copyOfRange(i, i.length/2, i.length));
			int j = 0, k = 0;
			while(j < a.length && k < b.length) {
				num += 1;
				if(a[j] > b[k]) {
					i[j+k] = b[k];
					k++;
				}else {
					i[j+k] = a[j];
					j++;
				}
			}
			if(j == a.length) {
				while(k < b.length) {
					num += 1;
					i[j+k] = b[k];
					k++;
				}
			}else {
				while(j < a.length) {
					num+= 1;
					i[j+k] = a[j];
					j++;
				}
			}
			return i;
		}
	}
}


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<iostream>
using namespace std;
#define INF 2<<15;
int S[500000];
int merge(int left, int mid, int right) {
	int count = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1], R[n2];
	for (int i = 0; i < n1; i++) {
		L[i] = S[left + 1];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = S[mid + 1];
	}
	L[n1] = INF;
	R[n2] = INF;
	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		count++;
		if (L[i] <= R[j]) {
			S[k] = L[i];
			i++;
		}else {
			S[k] = R[j];
			j++;
		}
	}
	return count;
}
int mergeSort(int left,int right) {
	int count = 0;
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(left, mid);
		mergeSort(left, mid);
		count += merge(left, mid, right);
	}
	return count;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	mergesort(0, n - 1);
	for (int i = 0; i < n-1; i++) {
		cout << S[i] << " ";
	}
	cout << S[n - 1] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:9: error: 'mergesort' was not declared in this scope; did you mean 'mergeSort'?
   49 |         mergesort(0, n - 1);
      |         ^~~~~~~~~
      |         mergeSort
Language: C++

#include<iostream>
using namespace std;

const int INFTY = 1000000001;

int C;

void merge(int A[],int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;

  int* L = new int[n1+1];
  int* R = new int[n2+1];

  for(int i=0;i<n1;i++){
    L[i] = A[left+i];
  }

  for(int i=0;i<n2;i++){
    R[i] = A[mid+i];
  }

  L[n1] = INFTY;
  R[n2] = INFTY;

  int i=0;
  int j=0;

  for(int k=left;k<right;k++){
    if(C++;L[i]<=R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
  delete[] L;
  delete[] R;
}

void mergeSort(int A[],int left,int right){
  if(left+1<right){
    int mid = (left+right)/2;
    return;
  }

  mergeSort(A,left,mid);
  mergeSort(A,mid,left);
  merge(A,left,mid,right);
}

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

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

  mergeSort(S,S,S[n]);

  for(int i=0;i<n;i++){
    cout << S[i] << ' ';
  }

  cout << C << endl;

  return 0;
}



Compiler output:
a.cc: In function 'void mergeSort(int*, int, int)':
a.cc:48:20: error: 'mid' was not declared in this scope
   48 |   mergeSort(A,left,mid);
      |                    ^~~
a.cc: In function 'int main()':
a.cc:62:15: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   62 |   mergeSort(S,S,S[n]);
      |               ^
      |               |
      |               int*
a.cc:42:28: note:   initializing argument 2 of 'void mergeSort(int*, int, int)'
   42 | void mergeSort(int A[],int left,int right){
      |                        ~~~~^~~~
Language: C++

#include <iostream>

using namespace std;

int num_comp = 0;
//const int MAX = 500000;
//int R[MAX/2 + 2];
const int SENTINEL = 2000000000;


// Merge
void Merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;

  int L[n1+1];
  int R[n2+1];
  
	for (int i = 0; i < n1; i++)
		L[i] = A[left + i];
	for (int i = 0; i < n2; i++)
		R[i] = A[mid + i];
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;

	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		num_comp++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}

// Merge sort
void Mergesort(int A[], int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		Mergesort(A, left, mid);
		Mergesort(A, mid, right);
		Merge(A, left, mid, right);
	}

}

// MAIN FUNCTION
int main(int argc, char** argv)
{
	// Input
	int A[MAX];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];

	// Merge sort
	Mergesort(A, 0, n);

	// Print all elements
	for (int i = 0; i < n; i++) {
		if (i)
			cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << num_comp << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:58:15: error: 'MAX' was not declared in this scope
   58 |         int A[MAX];
      |               ^~~
a.cc:62:24: error: 'A' was not declared in this scope
   62 |                 cin >> A[i];
      |                        ^
a.cc:65:19: error: 'A' was not declared in this scope
   65 |         Mergesort(A, 0, n);
      |                   ^
Language: C++

#include<iostream>
using namespace std;
#define INFTY 2000000000
int count=0;
void merge(int A[],int left,int mid,int right){
  n1=mid-left;
  nw=right-mid;
  L=new int[n1+1];
  R=new int[n2+1];
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  int i=0;
  int j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[i]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[i];
      j++;
    }
    count++;
  }
}
void mergeSort(int A[],int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right)
  }
}

int main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  mergeSort(A,0,n);
  for(int i=0;i<n-1;i++){
    cout<<A[i]<<' ';
  }
  cout<<A[n-1]<<endl;
  cout<<count<<endl;
}



Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:6:3: error: 'n1' was not declared in this scope
    6 |   n1=mid-left;
      |   ^~
a.cc:7:3: error: 'nw' was not declared in this scope
    7 |   nw=right-mid;
      |   ^~
a.cc:8:3: error: 'L' was not declared in this scope
    8 |   L=new int[n1+1];
      |   ^
a.cc:9:3: error: 'R' was not declared in this scope
    9 |   R=new int[n2+1];
      |   ^
a.cc:9:13: error: 'n2' was not declared in this scope
    9 |   R=new int[n2+1];
      |             ^~
a.cc:20:7: error: 'k' was not declared in this scope
   20 |   for(k=left;k<right;k++){
      |       ^
a.cc: In function 'void mergeSort(int*, int, int)':
a.cc:36:28: error: expected ';' before '}' token
   36 |     merge(A,left,mid,right)
      |                            ^
      |                            ;
   37 |   }
      |   ~
Language: C++

#include<iostream>
using namespace std;
 
#define INFTY 1 << 16;
 

 
void Merge(int A[],int left,int mid,int right){
  int n1 = mid-left;
  int n2 = right-mid;
 
  int L[n1+1];
  int R[n2+1];
 
  for(int i=0;i<n1;i++){
    L[i] = A[left+i];
  }
 
  for(int i=0;i<n2;i++){
    R[i] = A[mid+i];
  }
 
  L[n1] = INFTY;
  R[n2] = INFTY;
 
  int i=0;
  int j=0;
 
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}
 
int MergeSort(int A[],int left,int right){
  int count = 0;
  if(left+1 < right){
    int mid = (left+right)/2;
    counter += MergeSort(A,left,mid);
    counter += MergeSort(A,mid,right);
    Merge(A,left,mid,right);
    counter++;
  }
  return counter;
}
 
int main(){
  int n;
  cin >> n;
 
  int S[500000];
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
 
  MergeSort(S,0,n);
 
  for(int i=0;i<n-1;i++){     
    cout << S[i];
    cout << " ";
  }
  cout << S[n-1];
  cout << endl;
 
  cout << C << endl;
 
  return 0;
}


Compiler output:
a.cc: In function 'int MergeSort(int*, int, int)':
a.cc:44:5: error: 'counter' was not declared in this scope; did you mean 'count'?
   44 |     counter += MergeSort(A,left,mid);
      |     ^~~~~~~
      |     count
a.cc:49:10: error: 'counter' was not declared in this scope; did you mean 'count'?
   49 |   return counter;
      |          ^~~~~~~
      |          count
a.cc: In function 'int main()':
a.cc:70:11: error: 'C' was not declared in this scope
   70 |   cout << C << endl;
      |           ^
Language: C++

#include<iostream>
using namespace std;
 
#define INFTY 1 << 16;
 

 
void Merge(int A[],int left,int mid,int right){
  int n1 = mid-left;
  int n2 = right-mid;
 
  int L[n1+1];
  int R[n2+1];
 
  for(int i=0;i<n1;i++){
    L[i] = A[left+i];
  }
 
  for(int i=0;i<n2;i++){
    R[i] = A[mid+i];
  }
 
  L[n1] = INFTY;
  R[n2] = INFTY;
 
  int i=0;
  int j=0;
 
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}
 
int MergeSort(int A[],int left,int right){
  int count = 0;
  if(left+1 < right){
    int mid = (left+right)/2;
    counter += MergeSort(A,left,mid);
    counter += MergeSort(A,mid,right);
    Merge(A,left,mid,right);
    counter++;
  }
  return count;
}
 
int main(){
  int n,m;
  cin >> n;
 
  int S[500000];
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
 
  m = MergeSort(S,0,n);
 
  for(int i=0;i<n-1;i++){     
    cout << S[i];
    cout << " ";
  }
  cout << S[n-1];
  cout << endl;
 
  cout << m << endl;
 
  return 0;
}


Compiler output:
a.cc: In function 'int MergeSort(int*, int, int)':
a.cc:44:5: error: 'counter' was not declared in this scope; did you mean 'count'?
   44 |     counter += MergeSort(A,left,mid);
      |     ^~~~~~~
      |     count
Language: C++

#include<iostream>
using namespace std;
 
#define INFTY 1 << 16;
 

 
void Merge(int A[],int left,int mid,int right){
  int n1 = mid-left;
  int n2 = right-mid;
 
  int L[n1+1];
  int R[n2+1];
 
  for(int i=0;i<n1;i++){
    L[i] = A[left+i];
  }
 
  for(int i=0;i<n2;i++){
    R[i] = A[mid+i];
  }
 
  L[n1] = INFTY;
  R[n2] = INFTY;
 
  int i=0;
  int j=0;
 
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}
 
int MergeSort(int A[],int left,int right){
  int count = 0;
  if(left+1 < right){
    int mid = (left+right)/2;
    count += MergeSort(A,left,mid);
    count += MergeSort(A,mid,right);
    Merge(A,left,mid,right);
    counter++;
  }
  return count;
}
 
int main(){
  int n,m;
  cin >> n;
 
  int S[500000];
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
 
  m = MergeSort(S,0,n);
 
  for(int i=0;i<n-1;i++){     
    cout << S[i];
    cout << " ";
  }
  cout << S[n-1];
  cout << endl;
 
  cout << m << endl;
 
  return 0;
}


Compiler output:
a.cc: In function 'int MergeSort(int*, int, int)':
a.cc:47:5: error: 'counter' was not declared in this scope; did you mean 'count'?
   47 |     counter++;
      |     ^~~~~~~
      |     count
Language: C++

#include <iostream>

using namespace std;

#define MAX 500000
#define INFTY 2000000000

int cnt;
int L[MAX/2+1],R[MAX/2+1];

void merge(int a[] , int left , int mid , int right){
    int n1 = mid-left;
    int n2 = right-mid;
    for(int i = 0 ; i<n1 ; i++){
        L[i] = a[left+i];
    }
    for(int i = 0 ; i<n2 ; i++){
        R[i] = a[mid+i];
    }
    L[n1] = R[n2] = INFTY;

    int i = j = 0;
    for(int k = left ; k<right ; k++){
        cnt++;
        if(L[i]<=R[j]){
            a[k] = L[i++];
        }
        else{
            a[k] = R[j++];
        }
    }
}

void mergeSort(int a[] , int left , int right){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int main(){
    int a[MAX+2];
    int n;  cin>>n;
    for(int i = 0 ; i<n ; i++){
        cin>>a[i];
    }

    mergeSort(a,0,n);


    for(int i = 0 ; i<n ; i++){
        if(i!=0)
					cout << ' ';
        cout << a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:22:13: error: 'j' was not declared in this scope
   22 |     int i = j = 0;
      |             ^
Language: C++

#include <iostream>

using namespace std;

#define MAX 500000
#define INFTY 2000000000

int cnt;
int L[MAX/2+1],R[MAX/2+1];

void merge(int a[] , int left , int mid , int right){
    int n1 = mid-left;
    int n2 = right-mid;
    for(int i = 0 ; i<n1 ; i++){
        L[i] = a[left+i];
    }
    for(int i = 0 ; i<n2 ; i++){
        R[i] = a[mid+i];
    }
    L[n1] = R[n2] = INFTY;

    int i = 0
		int j = 0;
    for(int k = left ; k<right ; k++){
        cnt++;
        if(L[i]<=R[j]){
            a[k] = L[i++];
        }
        else{
            a[k] = R[j++];
        }
    }
}

void mergeSort(int a[] , int left , int right){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(a,left,mid);
        mergeSort(a,mid,right);
        merge(a,left,mid,right);
    }
}

int main(){
    int a[MAX+2];
    int n;  cin>>n;
    for(int i = 0 ; i<n ; i++){
        cin>>a[i];
    }

    mergeSort(a,0,n);


    for(int i = 0 ; i<n ; i++){
        if(i!=0)
					cout << ' ';
        cout << a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:23:17: error: expected ',' or ';' before 'int'
   23 |                 int j = 0;
      |                 ^~~
a.cc:26:20: error: 'j' was not declared in this scope
   26 |         if(L[i]<=R[j]){
      |                    ^
Language: C++

#include <iostream>
#include <sstream>
void merge(int A[],int left,int mid,int right){
  int n1,n2;
  n1=mid-left;
  n2=right-mid;
  int L[n1]={0};
  int R[n2]={0};
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  i=0; j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(int)(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int n;
  std::cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    std::cin>>A[i];
  }
  int left=0;
  int right=n-1;
  mergrSort(A,left,right);
}


Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:15:3: error: 'i' was not declared in this scope
   15 |   i=0; j=0;
      |   ^
a.cc:15:8: error: 'j' was not declared in this scope
   15 |   i=0; j=0;
      |        ^
a.cc: In function 'int main()':
a.cc:46:3: error: 'mergrSort' was not declared in this scope; did you mean 'mergeSort'?
   46 |   mergrSort(A,left,right);
      |   ^~~~~~~~~
      |   mergeSort
Language: C++

#include <iostream>
#include <sstream>
void merge(int A[],int left,int mid,int right){
  int n1,n2;
  n1=mid-left;
  n2=right-mid;
  int L[n1]={0};
  int R[n2]={0};
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  i=0; j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid=(int)(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int n;
  std::cin>>n;
  int A[n];
  for(int i=0;i<n;i++){
    std::cin>>A[i];
  }
  int left=0;
  int right=n-1;
  mergeSort(A,left,right);
}


Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:15:3: error: 'i' was not declared in this scope
   15 |   i=0; j=0;
      |   ^
a.cc:15:8: error: 'j' was not declared in this scope
   15 |   i=0; j=0;
      |        ^
Language: C++

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

void print(vector<int> array)
{
  for(int x:array){
    cout<<x<<" ";
  }
  cout<<endl;
}
void swap(int& a,int& b)
{
  if(a>=b){
    int tmp=a;
    a=b;
    b=tmp;
  }
}

vector<int> marge(vector<int>& list,int& count)
{
  int n=list.size();
  if(n==1){
    return list;
  }else if(n==2){
    swap(list[0],list[1]);
    count+=2;
    return list;
  }else{
    int half=n/2;
    vector<int> left(0);
    vector<int> right(0);

    for(int i=0;i<half;i++){
      left.push_back(list[i]);
    }

    for(int i=half;i<n;i++){
      right.push_back(list[i]);
    }

    left=marge(left,count);
    right=marge(right,count);
    vector<int> result(0);
    int i=0,j=0;
    while(result.size()<n){
      if(i==left.size()){
	while(j<right.size()){
	  result.push_back(right[j]);
	  j++;
	  count++;
	}
	break;
      }else if(j==right.size()){
	while(i<left.size()){
	  result.push_back(left[i]);
	  i++;
	  count++;
	}
	break;
      }
      if(left[i]<=right[j]){
	result.push_back(left[i]);
	i++;
	count++;
      }else{
	result.push_back(right[j]);
	j++;
	count++;
      }
    }
  }
  return result;
}

int main()
{
  int n,count=0;
  cin>>n;
  vector<int> list(n);
  for(int i=0;i<n;i++){
    cin>>list[i];
  }
  list=marge(list,count);
  print(list);
  cout<<count<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'std::vector<int> marge(std::vector<int>&, int&)':
a.cc:75:10: error: 'result' was not declared in this scope
   75 |   return result;
      |          ^~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int comparisonCount = 0;

void merge(vector<int>& A, int left, int mid, int right) {
  vector<int> L(A.begin() + left, A.begin() + mid);
  vector<int> R(A.begin() + mid, A.begin() + right);
  int i = 0;
  int j = 0;
  L.push_back(INT_MAX);
  R.push_back(INT_MAX);
  for (int k = left; k < right; ++k) {
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
    ++comparisonCount;
  }
}

void mergeSort(vector<int>& A, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> S(n);
  for (int i = 0; i < n; ++i) {
    cin >> S[i];
  }

  mergeSort(S, 0, S.size());

  for (int i = 0; i < n; ++i) {
    if (i != 0) {
      cout << " ";
    }
    cout << S[i];
  }
  cout << endl;
  cout << comparisonCount << endl;
}



Compiler output:
a.cc: In function 'void merge(std::vector<int>&, int, int, int)':
a.cc:13:15: error: 'INT_MAX' was not declared in this scope
   13 |   L.push_back(INT_MAX);
      |               ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 |
Language: C++

def merge(a,n)#配列,配列数
  x=0
  left=Array.new
  right=Array.new 
  l=(n/2).to_i
  r=n-l
  l.times do |i|
    left<<a[i]
  end
  r.times do |i|
    right<<a[i+l]
  end
  left<<10**9+1
  right<<10**9+1
  if l>1 then
    x+=merge(left,l)
  end
  if r>1 then
    x+=merge(right,r)
  end
  i=0
  j=0
  n.times do |k|
    if left[i]<right[j] then
      a[k]=left[i]
      i+=1
    else
      a[k]=right[j]
      j+=1
    end
  end
  return i+j+x
end

n=gets.to_i
a=gets.split.map!{|i|i.to_i}
a.slice!(n..-1)
x=merge(a,n)
print a


Compiler output:
a.cc:1:15: error: stray '#' in program
    1 | def merge(a,n)#配列,配列数
      |               ^
a.cc:1:1: error: 'def' does not name a type
    1 | def merge(a,n)#配列,配列数
      | ^~~
a.cc:37:1: error: 'a' does not name a type
   37 | a.slice!(n..-1)
      | ^
Language: C++

def merge(a,n)#配列,配列数
  x=0
  left=Array.new
  right=Array.new 
  l=(n/2).to_i
  r=n-l
  l.times do |i|
    left<<a[i]
  end
  r.times do |i|
    right<<a[i+l]
  end
  left<<10**9+1
  right<<10**9+1
  if l>1 then
    x+=merge(left,l)
  end
  if r>1 then
    x+=merge(right,r)
  end
  i=0
  j=0
  n.times do |k|
    if left[i]<right[j] then
      a[k]=left[i]
      i+=1
    else
      a[k]=right[j]
      j+=1
    end
  end
  return i+j+x
end

n=gets.to_i
a=gets.split.map!{|i|i.to_i}
a.slice!(n..-1)
x=merge(a,n)
print a
print "\n",x


Compiler output:
a.cc:1:15: error: stray '#' in program
    1 | def merge(a,n)#配列,配列数
      |               ^
a.cc:1:1: error: 'def' does not name a type
    1 | def merge(a,n)#配列,配列数
      | ^~~
a.cc:37:1: error: 'a' does not name a type
   37 | a.slice!(n..-1)
      | ^
Language: C++

#include<iostream>
using namespace std;

int merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1],R[n2];

  for(int i=0;i<=n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<=n2;i++){
    R[i]=A[mid+i];
}

  L[n1]=R[n2]=INFTY;

  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i++];
      c++;
    }else{
      A[k]=R[j++];
      c++;
    }
  }

}

int mergesort(int A[],int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int n;
  cin>>n;
  int S[n];

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

  mergesort(S,0,n);
for(int i=0;i<n;i++){
  cout<<S[i];
  }
 cout<<endl;
 cout<<c<<endl;

 return 0;
}



Compiler output:
a.cc: In function 'int merge(int*, int, int, int)':
a.cc:16:15: error: 'INFTY' was not declared in this scope
   16 |   L[n1]=R[n2]=INFTY;
      |               ^~~~~
a.cc:22:7: error: 'c' was not declared in this scope
   22 |       c++;
      |       ^
a.cc:25:7: error: 'c' was not declared in this scope
   25 |       c++;
      |       ^
a.cc:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
   29 | }
      | ^
a.cc: In function 'int mergesort(int*, int, int)':
a.cc:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
a.cc: In function 'int main()':
a.cc:54:8: error: 'c' was not declared in this scope
   54 |  cout<<c<<endl;
      |        ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2+2];
int cnt;

void merge(int A[], int left, int mid, int right) {
  n1 = mid - left;
  n2 = right - mid;
  int L[n1], R[n2];

  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSorf(int A[], int n, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2.0;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for ( int i = 0; i < n; i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  
  for ( int i = 0; i < n; i++) {
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:10:3: error: 'n1' was not declared in this scope
   10 |   n1 = mid - left;
      |   ^~
a.cc:11:3: error: 'n2' was not declared in this scope
   11 |   n2 = right - mid;
      |   ^~
a.cc:14:9: error: 'i' was not declared in this scope
   14 |   for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
      |         ^
a.cc:15:9: error: 'i' was not declared in this scope
   15 |   for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
      |         ^
a.cc: In function 'void mergeSorf(int*, int, int, int)':
a.cc:31:5: error: 'mergeSort' was not declared in this scope; did you mean 'mergeSorf'?
   31 |     mergeSort(A, n, left, mid);
      |     ^~~~~~~~~
      |     mergeSorf
a.cc:33:10: error: too many arguments to function 'void merge(int*, int, int, int)'
   33 |     merge(A, n, left, mid, right);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:9:6: note: declared here
    9 | void merge(int A[], int left, int mid, int right) {
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:44:3: error: 'mergeSort' was not declared in this scope; did you mean 'mergeSorf'?
   44 |   mergeSort(A, n, 0, n);
      |   ^~~~~~~~~
      |   mergeSorf
Language: C++

#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2+2];
int cnt;

void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2];

  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSorf(int A[], int n, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2.0;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for ( int i = 0; i < n; i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  
  for ( int i = 0; i < n; i++) {
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:14:9: error: 'i' was not declared in this scope
   14 |   for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
      |         ^
a.cc:15:9: error: 'i' was not declared in this scope
   15 |   for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
      |         ^
a.cc: In function 'void mergeSorf(int*, int, int, int)':
a.cc:31:5: error: 'mergeSort' was not declared in this scope; did you mean 'mergeSorf'?
   31 |     mergeSort(A, n, left, mid);
      |     ^~~~~~~~~
      |     mergeSorf
a.cc:33:10: error: too many arguments to function 'void merge(int*, int, int, int)'
   33 |     merge(A, n, left, mid, right);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:9:6: note: declared here
    9 | void merge(int A[], int left, int mid, int right) {
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:44:3: error: 'mergeSort' was not declared in this scope; did you mean 'mergeSorf'?
   44 |   mergeSort(A, n, 0, n);
      |   ^~~~~~~~~
      |   mergeSorf
Language: C++

#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2+2];
int cnt;

void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2];

  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSorf(int A[], int n, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2.0;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for ( int i = 0; i < n; i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  
  for ( int i = 0; i < n; i++) {
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


Compiler output:
a.cc: In function 'void mergeSorf(int*, int, int, int)':
a.cc:31:5: error: 'mergeSort' was not declared in this scope; did you mean 'mergeSorf'?
   31 |     mergeSort(A, n, left, mid);
      |     ^~~~~~~~~
      |     mergeSorf
a.cc:33:10: error: too many arguments to function 'void merge(int*, int, int, int)'
   33 |     merge(A, n, left, mid, right);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:9:6: note: declared here
    9 | void merge(int A[], int left, int mid, int right) {
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:44:3: error: 'mergeSort' was not declared in this scope; did you mean 'mergeSorf'?
   44 |   mergeSort(A, n, 0, n);
      |   ^~~~~~~~~
      |   mergeSorf
Language: C++

#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2+2];
int cnt;

void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2];

  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2.0;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for ( int i = 0; i < n; i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  
  for ( int i = 0; i < n; i++) {
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


Compiler output:
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:33:10: error: too many arguments to function 'void merge(int*, int, int, int)'
   33 |     merge(A, n, left, mid, right);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:9:6: note: declared here
    9 | void merge(int A[], int left, int mid, int right) {
      |      ^~~~~
Language: C++

#include<iostream>
using namespace std;
int merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1+1];
  int R[n2+1];
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];    
  }
  L[n1]=10000000;
  R[n2]=10000000;       
  i=0,j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
  }
  return right-left;
}
int Merge_Sort(int A[],int left,int right){
  int mid,res=0;
  if(left+1<right){
    mid=(left+right)/2;
   
    res+=Merge_Sort(A,left,mid);
    res+=Merge_Sort(A,mid,right);
    res+=Merge(A,left,mid,right);
       
  }
  return res;
}
   
int main(){
  int i,x,n,S[500000]; 
  cin>>n;
  for(i=0;i<n;i++)    cin>>S[i];
  x=Merge_Sort(S,0,n);
     
  for(i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<S[i];
  }
  cout<<endl;
  cout<<x<<endl;
  return 0;
}



Compiler output:
a.cc: In function 'int merge(int*, int, int, int)':
a.cc:16:3: error: 'i' was not declared in this scope
   16 |   i=0,j=0;
      |   ^
a.cc:16:7: error: 'j' was not declared in this scope
   16 |   i=0,j=0;
      |       ^
a.cc:17:7: error: 'k' was not declared in this scope
   17 |   for(k=left;k<right;k++){
      |       ^
a.cc: In function 'int Merge_Sort(int*, int, int)':
a.cc:35:10: error: 'Merge' was not declared in this scope; did you mean 'merge'?
   35 |     res+=Merge(A,left,mid,right);
      |          ^~~~~
      |          merge
Language: C++

#include<iostream>

int n;
int S[500000]={};
int cnt=0;

void merge(int A,int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	int L[100000];
	int R[100000];
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=R[n2]=INFTY;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
			cnt++;
		}else{
			A[k]=R[j];
			j++;
			cnt++;
		}
	}
}

void mergeSort(int A,int left,int right){
	if(left+1<right){
		mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(a,mid,right);
		merge(A,left,mid,right);
	}
}
int main()
{
	
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>S[i];
	}
	mergeSort(S,0,n);
	for(int i=0;i<n-1;i++){
		std::cout<<S[i]<<" ";
	}
	std::cout<<S[n-1]<<'\n';
	std::cout<<cnt<<'\n';
	return 0;
}


Compiler output:
a.cc: In function 'void merge(int, int, int, int)':
a.cc:14:23: error: invalid types 'int[int]' for array subscript
   14 |                 L[i]=A[left+i];
      |                       ^
a.cc:17:23: error: invalid types 'int[int]' for array subscript
   17 |                 R[i]=A[mid+i];
      |                       ^
a.cc:19:21: error: 'INFTY' was not declared in this scope
   19 |         L[n1]=R[n2]=INFTY;
      |                     ^~~~~
a.cc:24:26: error: invalid types 'int[int]' for array subscript
   24 |                         A[k]=L[i];
      |                          ^
a.cc:28:26: error: invalid types 'int[int]' for array subscript
   28 |                         A[k]=R[j];
      |                          ^
a.cc: In function 'void mergeSort(int, int, int)':
a.cc:37:17: error: 'mid' was not declared in this scope
   37 |                 mid=(left+right)/2;
      |                 ^~~
a.cc:39:27: error: 'a' was not declared in this scope
   39 |                 mergeSort(a,mid,right);
      |                           ^
a.cc: In function 'int main()':
a.cc:50:19: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   50 |         mergeSort(S,0,n);
      |                   ^
      |                   |
      |                   int*
a.cc:35:20: note:   initializing argument 1 of 'void mergeSort(int, int, int)'
   35 | void mergeSort(int A,int left,int right){
      |                ~~~~^
Language: C++

#include<iostream>
#define 100000000000;

int n;
int S[500000]={};
int cnt=0;

void merge(int A,int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	int L[100000];
	int R[100000];
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=R[n2]=INFTY;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
			cnt++;
		}else{
			A[k]=R[j];
			j++;
			cnt++;
		}
	}
}

void mergeSort(int A,int left,int right){
	if(left+1<right){
		mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(a,mid,right);
		merge(A,left,mid,right);
	}
}
int main()
{
	
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>S[i];
	}
	mergeSort(S,0,n);
	for(int i=0;i<n-1;i++){
		std::cout<<S[i]<<" ";
	}
	std::cout<<S[n-1]<<'\n';
	std::cout<<cnt<<'\n';
	return 0;
}


Compiler output:
a.cc:2:9: error: macro names must be identifiers
    2 | #define 100000000000;
      |         ^~~~~~~~~~~~
a.cc: In function 'void merge(int, int, int, int)':
a.cc:15:23: error: invalid types 'int[int]' for array subscript
   15 |                 L[i]=A[left+i];
      |                       ^
a.cc:18:23: error: invalid types 'int[int]' for array subscript
   18 |                 R[i]=A[mid+i];
      |                       ^
a.cc:20:21: error: 'INFTY' was not declared in this scope
   20 |         L[n1]=R[n2]=INFTY;
      |                     ^~~~~
a.cc:25:26: error: invalid types 'int[int]' for array subscript
   25 |                         A[k]=L[i];
      |                          ^
a.cc:29:26: error: invalid types 'int[int]' for array subscript
   29 |                         A[k]=R[j];
      |                          ^
a.cc: In function 'void mergeSort(int, int, int)':
a.cc:38:17: error: 'mid' was not declared in this scope
   38 |                 mid=(left+right)/2;
      |                 ^~~
a.cc:40:27: error: 'a' was not declared in this scope
   40 |                 mergeSort(a,mid,right);
      |                           ^
a.cc: In function 'int main()':
a.cc:51:19: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   51 |         mergeSort(S,0,n);
      |                   ^
      |                   |
      |                   int*
a.cc:36:20: note:   initializing argument 1 of 'void mergeSort(int, int, int)'
   36 | void mergeSort(int A,int left,int right){
      |                ~~~~^
Language: C++

#include<iostream>
#define INFTY=10000000;

int n;
int S[500000]={};
int cnt=0;

void merge(int A,int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	int L[100000];
	int R[100000];
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=R[n2]=INFTY;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
			cnt++;
		}else{
			A[k]=R[j];
			j++;
			cnt++;
		}
	}
}

void mergeSort(int A,int left,int right){
	if(left+1<right){
		mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(a,mid,right);
		merge(A,left,mid,right);
	}
}
int main()
{
	
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>S[i];
	}
	mergeSort(S,0,n);
	for(int i=0;i<n-1;i++){
		std::cout<<S[i]<<" ";
	}
	std::cout<<S[n-1]<<'\n';
	std::cout<<cnt<<'\n';
	return 0;
}


Compiler output:
a.cc:2:9: warning: ISO C++11 requires whitespace after the macro name
    2 | #define INFTY=10000000;
      |         ^~~~~
a.cc: In function 'void merge(int, int, int, int)':
a.cc:15:23: error: invalid types 'int[int]' for array subscript
   15 |                 L[i]=A[left+i];
      |                       ^
a.cc:18:23: error: invalid types 'int[int]' for array subscript
   18 |                 R[i]=A[mid+i];
      |                       ^
a.cc:2:14: error: expected primary-expression before '=' token
    2 | #define INFTY=10000000;
      |              ^
a.cc:20:21: note: in expansion of macro 'INFTY'
   20 |         L[n1]=R[n2]=INFTY;
      |                     ^~~~~
a.cc:25:26: error: invalid types 'int[int]' for array subscript
   25 |                         A[k]=L[i];
      |                          ^
a.cc:29:26: error: invalid types 'int[int]' for array subscript
   29 |                         A[k]=R[j];
      |                          ^
a.cc: In function 'void mergeSort(int, int, int)':
a.cc:38:17: error: 'mid' was not declared in this scope
   38 |                 mid=(left+right)/2;
      |                 ^~~
a.cc:40:27: error: 'a' was not declared in this scope
   40 |                 mergeSort(a,mid,right);
      |                           ^
a.cc: In function 'int main()':
a.cc:51:19: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   51 |         mergeSort(S,0,n);
      |                   ^
      |                   |
      |                   int*
a.cc:36:20: note:   initializing argument 1 of 'void mergeSort(int, int, int)'
   36 | void mergeSort(int A,int left,int right){
      |                ~~~~^
Language: C++

#include<iostream>
#define INFTY 100000000;

int n;
int S[100000000]={};
int cnt=0;

void merge(int A[],int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	int L[n1+1];
	int R[n2+1];
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=R[n2]=INT_MAX;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++){
		if(L[i]<=R[j]){
			A[k]=L[i];
			i++;
			cnt++;
		}else{
			A[k]=R[j];
			j++;
			cnt++;
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}
int main()
{
	
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>S[i];
	}
	mergeSort(S,0,n);
	for(int i=0;i<n-1;i++){
		std::cout<<S[i]<<" ";
	}
	std::cout<<S[n-1]<<'\n';
	std::cout<<cnt<<'\n';
	return 0;
}


Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:20:21: error: 'INT_MAX' was not declared in this scope
   20 |         L[n1]=R[n2]=INT_MAX;
      |                     ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | #define INFTY 100000000;
Language: C++

#include<iostream>

#define MAX 100000
using namespace std;

int cnt_sum;

void merge(int a[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;

	int l1 = n1 + 1;
	int r1 = n2 + 1;

	int l[l1], r[r1];
	for (int i = 0; i < n1; i++) {
		l[i] = a[left + i];
	}
	l[n1] = MAX;
	for (int i = 0; i < n2; i++) {
		r[i] = a[mid + i];
	}
	r[n2] = MAX;

	int p = 0, q = 0;
	for (int i = left; i < right; i++) {
		cnt_sum++;
		if (l[p] < r[q]) {
			a[i] = l[p++];
		}
		else {
			a[i] = r[q++];
		}
	}
}
void mergeSort(int a[], int left, int right) {
	if (left + 1 == right) return;
	int mid = (left + right) / 2;
	mergeSort(a, left, mid);
	mergeSort(a, mid, right);
	merge(a, left, mid, right);
}


int main(void) {
	
	int n;
	int s[MAX];

	cin >> n;

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

	mergeSort(s, n, 0);

	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	cout << cnt_sum << endl;

	return 0;





Compiler output:
a.cc: In function 'int main()':
a.cc:64:18: error: expected '}' at end of input
   64 |         return 0;
      |                  ^
a.cc:45:16: note: to match this '{'
   45 | int main(void) {
      |                ^
Language: C++

#include<iostream>

using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

int merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    cnt++
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
   
int Merge_Sort(int A[], int left, int right){
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
   
int main() {
  int A{MAX}, N;

  cnt = 0;

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  mergeSort(A, 0, N);

  for (int i = 0; i < N; i++) {
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}



Compiler output:
a.cc: In function 'int merge(int*, int, int, int)':
a.cc:24:10: error: expected ';' before 'if'
   24 |     cnt++
      |          ^
      |          ;
   25 |     if (L[i] <= R[j]) {
      |     ~~    
a.cc:27:7: error: 'else' without a previous 'if'
   27 |     } else {
      |       ^~~~
a.cc:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^
a.cc: In function 'int Merge_Sort(int*, int, int)':
a.cc:36:5: error: 'mergeSort' was not declared in this scope; did you mean 'Merge_Sort'?
   36 |     mergeSort(A, left, mid);
      |     ^~~~~~~~~
      |     Merge_Sort
a.cc:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
a.cc: In function 'int main()':
a.cc:49:13: error: invalid types 'int[int]' for array subscript
   49 |     cin >> A[i];
      |             ^
a.cc:52:3: error: 'mergeSort' was not declared in this scope; did you mean 'Merge_Sort'?
   52 |   mergeSort(A, 0, N);
      |   ^~~~~~~~~
      |   Merge_Sort
a.cc:58:14: error: invalid types 'int[int]' for array subscript
   58 |     cout << A[i];
      |              ^
Language: C++

#include<iostream>

using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

int merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
   
int Merge_Sort(int A[], int left, int right){
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
   
int main() {
  int A{MAX}, N;

  cnt = 0;

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  mergeSort(A, 0, N);

  for (int i = 0; i < N; i++) {
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}



Compiler output:
a.cc: In function 'int merge(int*, int, int, int)':
a.cc:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^
a.cc: In function 'int Merge_Sort(int*, int, int)':
a.cc:36:5: error: 'mergeSort' was not declared in this scope; did you mean 'Merge_Sort'?
   36 |     mergeSort(A, left, mid);
      |     ^~~~~~~~~
      |     Merge_Sort
a.cc:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
a.cc: In function 'int main()':
a.cc:49:13: error: invalid types 'int[int]' for array subscript
   49 |     cin >> A[i];
      |             ^
a.cc:52:3: error: 'mergeSort' was not declared in this scope; did you mean 'Merge_Sort'?
   52 |   mergeSort(A, 0, N);
      |   ^~~~~~~~~
      |   Merge_Sort
a.cc:58:14: error: invalid types 'int[int]' for array subscript
   58 |     cout << A[i];
      |              ^
Language: C++

#include<iostream>

using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

int merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
   
int mergeSort(int A[], int left, int right){
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
   
int main() {
  int A{MAX}, N;

  cnt = 0;

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  mergeSort(A, 0, N);

  for (int i = 0; i < N; i++) {
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int merge(int*, int, int, int)':
a.cc:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^
a.cc: In function 'int mergeSort(int*, int, int)':
a.cc:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
a.cc: In function 'int main()':
a.cc:49:13: error: invalid types 'int[int]' for array subscript
   49 |     cin >> A[i];
      |             ^
a.cc:52:13: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   52 |   mergeSort(A, 0, N);
      |             ^
      |             |
      |             int
a.cc:33:19: note:   initializing argument 1 of 'int mergeSort(int*, int, int)'
   33 | int mergeSort(int A[], int left, int right){
      |               ~~~~^~~
a.cc:58:14: error: invalid types 'int[int]' for array subscript
   58 |     cout << A[i];
      |              ^