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

//
//  main.cpp
//  merge_sort
//
//  Created by ???????????? on 2017/10/08.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

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

using namespace std;

int ct = 0;

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

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


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


int main(int argc, const char * argv[]) {
    int n, i;
    scanf("%d", &n);
    int S[n];
    for (i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    merge_sort(S, 0, n);
    for (i = 0; i < n; i++){
        if(i)cout << " ";
        cout<<S[i];
    }
    cout << endl;
    cout << ct << endl;
    

    return 0;
}

Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:29:13: error: 'INT_MAX' was not declared in this scope
   29 |     L[n1] = INT_MAX;
      |             ^~~~~~~
a.cc:13:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <math.h>
  +++ |+#include <climits>
   13 |
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 n, 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, j = 0;
    for ( int k = keft; 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 ) {
        mid = (left + right ) / 2;
        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 ( 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, int)':
a.cc:16:19: error: 'keft' was not declared in this scope; did you mean 'left'?
   16 |     for ( int k = keft; k < right; k++) {
      |                   ^~~~
      |                   left
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:29:9: error: 'mid' was not declared in this scope
   29 |         mid = (left + right ) / 2;
      |         ^~~
Language: C++

#include <iostream>

using namespace std;

#define INFY 200000000;

static int cnt = 0;

void merging (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] = INFY;

  int j = 0, i = 0;

  for (int k = left; k < right; k++) {
    cnt++
    if (L[i] < R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      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);
    merging(A, left, mid, right);
  }

}

int main () {

  int n;

  scanf("%d", &n);

  int A[n];

  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  mergeSort(A, 0, n);

  for(int i = 0; i < n; i++) {
    printf("%d ", A[i]);
  }

  printf("\n%d\n", cnt);

}

Compiler output:
a.cc: In function 'void merging(int*, int, int, int)':
a.cc:25:10: error: expected ';' before 'if'
   25 |     cnt++
      |          ^
      |          ;
   26 |     if (L[i] < R[j]) {
      |     ~~    
a.cc:29:7: error: 'else' without a previous 'if'
   29 |     } else {
      |       ^~~~
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;
  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) {


int main(void) {
  return 0;
}

Compiler output:
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:29:16: error: a function-definition is not allowed here before '{' token
   29 | int main(void) {
      |                ^
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:26:53: note: to match this '{'
   26 | void mergeSort(int A[], int n, int left, int right) {
      |                                                     ^
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 n,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, 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;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}
 
int main(void) {
  int A[MAX], n, i;
  cnt = 0;
 
  cin >> n;
  for(i=0;i<n;i++) cin >> A[i];
 
  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
    cout << A[i];
  }
  cout << endl;
 
  cout << cnt << endl;
 
  return 0;
}


void mergeSort(int A[], int n, int left, int right) {


int main(void) {
  return 0;
}

Compiler output:
a.cc:56:6: error: redefinition of 'void mergeSort(int*, int, int, int)'
   56 | void mergeSort(int A[], int n, int left, int right) {
      |      ^~~~~~~~~
a.cc:27:6: note: 'void mergeSort(int*, int, int, int)' previously defined here
   27 | void mergeSort(int A[],int n,int left,int right) {
      |      ^~~~~~~~~
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:59:16: error: a function-definition is not allowed here before '{' token
   59 | int main(void) {
      |                ^
a.cc:61:2: error: expected '}' at end of input
   61 | }
      |  ^
a.cc:56:53: note: to match this '{'
   56 | void mergeSort(int A[], int n, int left, int right) {
      |                                                     ^
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 n,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, 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;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

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

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

  mergeSort(A, n, 0, n);
  for(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 main()':
a.cc:56:12: error: expected '}' at end of input
   56 |   return 0;
      |            ^
a.cc:40:16: note: to match this '{'
   40 | int main(void) {
      |                ^
Language: C++

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

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

void marge(int A[],int n,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,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}else {
			A[k]=R[j++];
		}
	}
}

voidmergeSort(int A[],int n,int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		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(i=0;i,n;i++)cin>>A[i];
	
	mergeSort(A,n,0,n);
	
	for(i=0;i<n;i++){
		if(i)cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	
	cout,,cnt<<endl;
	
	return 0;
}

Compiler output:
a.cc:1:9: fatal error: iostoream: No such file or directory
    1 | #include<iostoream>
      |         ^~~~~~~~~~~
compilation terminated.
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 n,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 + 1];
	for(int i = 0; i < n2; i++) R[i] = A[mid + 1];
	L[n1] = R[n2] = SENTIMNEL;
	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;
		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(i = 0; i < n; i++) cin >> A[i];
	
	for(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, int)':
a.cc:15:25: error: 'SENTIMNEL' was not declared in this scope; did you mean 'SENTINEL'?
   15 |         L[n1] = R[n2] = SENTIMNEL;
      |                         ^~~~~~~~~
      |                         SENTINEL
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 n, 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, 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 mid, int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, right);
	}
}

int main(){`
	int A[MAX], n, i;
	cnt = 0;
	
	cin >> n;
	for(i=0;i<n;i++) cin >> A[i];
	
	mergeSort(A, n, 0, n);
	
	for(i=0;i<n;i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	
	cout << cnt << endl;
	
	
	return 0;
}

Compiler output:
a.cc:38:12: error: stray '`' in program
   38 | int main(){`
      |            ^
a.cc: In function 'void mergeSort(int*, int, int, int, int)':
a.cc:32:26: error: too few arguments to function 'void mergeSort(int*, int, int, int, int)'
   32 |                 mergeSort(A, n, left, mid);
      |                 ~~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:29:6: note: declared here
   29 | void mergeSort(int A[], int n, int left, int mid, int right){
      |      ^~~~~~~~~
a.cc:33:26: error: too few arguments to function 'void mergeSort(int*, int, int, int, int)'
   33 |                 mergeSort(A, n, mid, right);
      |                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:29:6: note: declared here
   29 | void mergeSort(int A[], int n, int left, int mid, int right){
      |      ^~~~~~~~~
a.cc:34:22: error: too few arguments to function 'void merge(int*, int, int, int, int)'
   34 |                 merge(A, n, left, right);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:11:6: note: declared here
   11 | void merge(int A[], int n, int left, int mid, int right){
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:45:18: error: too few arguments to function 'void mergeSort(int*, int, int, int, int)'
   45 |         mergeSort(A, n, 0, n);
      |         ~~~~~~~~~^~~~~~~~~~~~
a.cc:29:6: note: declared here
   29 | void mergeSort(int A[], int n, int left, int mid, int right){
      |      ^~~~~~~~~
Language: C++

#include<iostream>

using namespace std;

#define MAX 500000
#define INFTY 2000000000

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

void marge (int A[], int n, int left, int mid, int right) {

    int n1 = mid -left, n2 = right - mid;
    int i, j, k;

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

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

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

    i = 0;
    j = 0;

    for (k = left; k < right; k++) {

        count++;

        if (L[i] <= R[j]) {

            A[k] = L[i];
            i++;

        } else {

            A[k] = R[j];
            j++;

        }

    }

}

void margeSort (int A[], int n, int left, int right) {

    int mid;

    if (left + 1 < right) {

        mid (left + right) / 2;

        margeSort (A, n, left, mid);
        margeSort (A, n, mid, right);

        marge (A, n, left, mid, right);

    }

}

int main () {

    int A[MAX], n, i;
    count = 0;

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

    margeSort (A, n, 0, n);

    for (i = 0; i < n; i++) {

        if (i) {
            cout << " ";
        }

        cout << A[i];

    }

    cout << endl;

    cout << count << endl;

    return 0;

}

Compiler output:
a.cc: In function 'void margeSort(int*, int, int, int)':
a.cc:55:13: error: 'mid' cannot be used as a function
   55 |         mid (left + right) / 2;
      |         ~~~~^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:72:27: error: expected primary-expression before ')' token
   72 |     for (i = 0; i < n; ++ ) {
      |                           ^
Language: C++


#include<iostream>

#define MAX 500001
using namespace std;

int cnt = 0;

void merge(int *A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int L[MAX], R[MAX];
		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] = INT_MAX;
	R[n2] = INT_MAX;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			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 n, A[MAX];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
		mergeSort(A, 0, n);
	for (int i = 0; i < n; i++) {
		cout << A[i];
		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	cout << cnt << endl;
}

Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:19:25: error: 'INT_MAX' was not declared in this scope
   19 |                 L[n1] = INT_MAX;
      |                         ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<iostream>
  +++ |+#include <climits>
    3 |
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 n,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, 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;
 mergrSort(A,n,left,mid);
 mergrSort(A,n,,mid,right);
 mergrSort(A,n,left,mid,right);
 }
}
  
 int main(){
  int A[MAX],n,i;
  cnt = 0;

  cin >> n;
  for(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, int)':
a.cc:18:31: error: 'K' was not declared in this scope
   18 |  for (int k = left; k <right; K++){
      |                               ^
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:30:2: error: 'mergrSort' was not declared in this scope; did you mean 'mergeSort'?
   30 |  mergrSort(A,n,left,mid);
      |  ^~~~~~~~~
      |  mergeSort
a.cc:31:16: error: expected primary-expression before ',' token
   31 |  mergrSort(A,n,,mid,right);
      |                ^
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 n,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, 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;
 mergeSort(A,n,left,mid);
 mergeSort(A,n,,mid,right);
 mergeSort(A,n,left,mid,right);
 }
}
  
 int main(){
  int A[MAX],n,i;
  cnt = 0;

  cin >> n;
  for(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, int)':
a.cc:18:31: error: 'K' was not declared in this scope
   18 |  for (int k = left; k <right; K++){
      |                               ^
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:31:16: error: expected primary-expression before ',' token
   31 |  mergeSort(A,n,,mid,right);
      |                ^
a.cc:32:11: error: too many arguments to function 'void mergeSort(int*, int, int, int)'
   32 |  mergeSort(A,n,left,mid,right);
      |  ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:27:7: note: declared here
   27 |  void mergeSort(int A[],int n,int left,int right){
      |       ^~~~~~~~~
Language: C++

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

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

void merge(int A[],int n,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, 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;
 mergeSort(A,n,left,mid);
 mergeSort(A,n,,mid,right);
 mergeSort(A,n,left,mid,right);
 }
}
  
 int main(){
  int A[MAX],n,i;
  cnt = 0;

  cin >> n;
  for(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, int)':
a.cc:18:31: error: 'K' was not declared in this scope
   18 |  for (int k = left; k <right; K++){
      |                               ^
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:31:16: error: expected primary-expression before ',' token
   31 |  mergeSort(A,n,,mid,right);
      |                ^
a.cc:32:11: error: too many arguments to function 'void mergeSort(int*, int, int, int)'
   32 |  mergeSort(A,n,left,mid,right);
      |  ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:27:7: note: declared here
   27 |  void mergeSort(int A[],int n,int left,int right){
      |       ^~~~~~~~~
Language: C++

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

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

void merge(int A[],int n,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, 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;
 mergeSort(A,n,left,mid);
 mergeSort(A,n,,mid,right);
 mergeSort(A,n,left,mid,right);
 }
}
  
 int main(){
  int A[MAX],n,i;
  cnt = 0;

  cin >> n;
  for(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:31:16: error: expected primary-expression before ',' token
   31 |  mergeSort(A,n,,mid,right);
      |                ^
a.cc:32:11: error: too many arguments to function 'void mergeSort(int*, int, int, int)'
   32 |  mergeSort(A,n,left,mid,right);
      |  ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:27:7: note: declared here
   27 |  void mergeSort(int A[],int n,int left,int right){
      |       ^~~~~~~~~
Language: C++

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

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

void merge(int A[],int n,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, 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;
 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(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:31:16: error: expected primary-expression before ',' token
   31 |  mergeSort(A,n,,mid,right);
      |                ^
Language: C++

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

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

void merge(int A[],int n,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, 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;
 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(i = 0; i < n; i++)
  cin >> A[i];
  
  mergeSort(A,n,0,n);

  for(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:31:16: error: expected primary-expression before ',' token
   31 |  mergeSort(A,n,,mid,right);
      |                ^
Language: C++

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

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

void merge(int A[],int n,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, 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;
 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(i = 0; i < n; i++)
  cin >> A[i];
  
  mergeSort(A,n,0,n);

  for(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:31:16: error: expected primary-expression before ',' token
   31 |  mergeSort(A,n,,mid,right);
      |                ^
Language: C++

#include<iostream>
using namespace std;
#define MAX 500000
#define S 2000000

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


void merge(int a[], int n, 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] = S;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		c++;
		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;
		mergeSort(a,n,left,mid);
		mergeSort(a, n, mid,right);
		merge(a, n, left, mid,right);
	}
}

int main() {
	int a[MAX], n, i;
	c = 0;

	cin >> n;
	for (i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << a[i];
	}
	cout <<endl;
	cout << c << endl;

	return 0;
}

Compiler output:
a.cc: In function 'void merge(int*, int, int, int, int)':
a.cc:12:16: error: expected initializer before 'right'
   12 |         int n2 right - mid;
      |                ^~~~~
a.cc:16:29: error: 'n2' was not declared in this scope; did you mean 'n1'?
   16 |         for (int i = 0; i < n2; i++) {
      |                             ^~
      |                             n1
a.cc:19:19: error: 'n2' was not declared in this scope; did you mean 'n1'?
   19 |         L[n1] = R[n2] = S;
      |                   ^~
      |                   n1
Language: C++

#include<stdio.h>
??
int count;
??
void merge(int A[], int left, int mid, int right, int n){
??
int n1, n2, L[250001], R[250001], i, j, k;
 n1 = mid - left;
 n2 = right - mid;
  for(i = 0; i < n1; i++){
  L[i] = A[left + i];
  }
 for(i = 0; i < n2; i++){
  R[i] = A[mid + i];
 }
 L[n1] = 2000000000;
 R[n2] = 2000000000;
 i = 0;
j = 0;
for(k = left; k < right; k++){
count++;
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 n){
??
int mid;
if(left + 1 < right){
mid = (left + right) / 2;
mergeSort(A, left, mid, n);
mergeSort(A, mid, right, n);
merge(A, left, mid, right, n);
}
??
}
??
??
??
int main(void){
??
int A[500000], n, i;
count = 0;
??
scanf("%d",&n);
for(i = 0; i < n; i++){
scanf("%d",&A[i]);
}
??
mergeSort(A, 0, n, n);
??
for(i = 0; i < n; i++){
if(i != 0) printf(" ");
printf("%d", A[i]);
}
??
printf("\n");
printf("%d\n",count);
??
return 0;
}

Compiler output:
a.cc:2:1: error: expected unqualified-id before '?' token
    2 | ??
      | ^
a.cc:4:1: error: expected unqualified-id before '?' token
    4 | ??
      | ^
a.cc:34:1: error: expected unqualified-id before '?' token
   34 | ??
      | ^
a.cc:48:1: error: expected unqualified-id before '?' token
   48 | ??
      | ^
Language: C++

#include<stdio.h>
#include<limit.h>

#define rep(i,n) for(i=0;i<(n);i++)
#define For(i,a,b) for(i=(a);i<(b);i++)
#define size 500000

int count=0;

void merge(int a[],int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  int l[n1+1],r[n2+1];
  int i,j,k;
  rep(i,n1)
    l[i]=a[left+i];
  rep(i,n2)
    r[i]=a[mid+i];
  l[n1]=INT_MAX;
  r[n2]=INT_MAX;
  i=0;j=0;
  For(k,left,right){
    if(l[i]<=r[j]){
      a[k]=l[i];
      //printf("%d\n",a[k]);
      i++;
    }else{
      a[k]=r[j];
      //printf("%d\n",a[k]);
      j++;
    }
    count++;
  }  
}

void mergesort(int a[],int l,int r){
  int m;
  if(l+1<r){
    m=(l+r)/2;
    mergesort(a,l,m);
    mergesort(a,m,r);
    merge(a,l,m,r);
  }
}

int main(){
  int n,s[size];
  int i,j,k,l;

  scanf("%d",&n);
  rep(i,n)
    scanf("%d",&s[i]);

  mergesort(s,0,n);
  rep(i,n){
    printf("%d",s[i]);
    if(i==n-1){
      printf("\n");
    }else{
      printf(" ");
    }
  }
  printf("%d\n",count);

  return 0;

}

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

#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int INF = 2e9;
const int MaxSize = 5e5 + 5;
int A[MaxSize], L[MaxSize], R[MaxSize];
int count;
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[n1] = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		count++;
		if (L[i] <= R[j])A[k]=L[i++];
		else A[k]=R[j++];
	}
}
void Merge_sort(int A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (right + left) / 2;
		Merge_sort(A, left, mid);
		Merge_sort(A, mid, right);
		Merge(A, left, mid, right);
	}
}
int main() {
	int n = 0;
	scanf("%d", &n);
	count = 0;
	for (int i = 0; i < n; i++)scanf("%d", &A[i]);
	
	for (int i = 0; i < n - 1; i++)printf("%d ", A[i]);
	printf("%d\n", A[n - 1]);
	return 0;
}

Compiler output:
a.cc: In function 'void Merge(int*, int, int, int)':
a.cc:17:17: error: reference to 'count' is ambiguous
   17 |                 count++;
      |                 ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:8:5: note:                 'int count'
    8 | int count;
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:33:9: error: reference to 'count' is ambiguous
   33 |         count = 0;
      |         ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:8:5: note:                 'int count'
    8 | int count;
      |     ^~~~~
Language: C++

#include <iostream>  
#include <cstdio>  
#include <algorithm>
#define N 1000  
using namespace std;
int time=0; 
void m(int a[],int l,int m,int r){
	int n=m-l;
	int c=r-m;
	int li[N];
	int ri[N];
	for(int i=0;i<n;i++)li[i]=a[i+l];
	for(int i=0;i<c;i++)ri[i]=a[i+m]; 
	li[n]=1000000;
	ri[c]=1000000;
	int i=0,j=0;
	for(int k=l;k<r;k++){
		time++;
		if(li[i]<=ri[j]){
			a[k]=li[i];
			i++;
		}else{
			a[k]=ri[j];
			j++;
		}
		//cout<<a[k]<<li[i]<<ri[j]<<"\n";
 }
	return;
}
void msort(int a[],int l,int r){
	if(l+1<r){
		int mid=l+r;
		mid/=2;
		msort(a,l,mid);
		msort(a,mid,r);
		m(a,l,mid,r);
	} 
	return;
}
int main() { 
	int n;
	cin>>n;
	int a[N];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	msort(a,0,n);
	for(int i=0;i<n-1;i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[n-1]);
	cout<<time<<endl;
    return 0;  
} 

Compiler output:
a.cc:6:5: error: 'int time' redeclared as different kind of entity
    6 | int time=0;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'void m(int*, int, int, int)':
a.cc:18:17: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
   18 |                 time++;
      |                 ^~~~
a.cc:18:21: error: lvalue required as increment operand
   18 |                 time++;
      |                     ^~
Language: C++

#include <iostream>

using namespace std;

#define MAX 500000
#define INF 2000000000

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

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] = INF;
	R[n2] = INF;
	int i = 0;
	int j = 0;
	for(int k = left; k < right; k++)
	{
		if(L[i] < R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[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()
{
	int A[MAX];
	int n, i;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d", A + i);
	}
	mergesort(A,0,n);
	for(i = 0; i < n; i++)
	{
		if(i)a
		{
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n%d\n", cnt);
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:22: error: 'a' was not declared in this scope
   64 |                 if(i)a
      |                      ^
Language: C++

#include <iostream>
#include <cstdio>

using namespace std;

int A[500000+10],n,sum=0,i,j;

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

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


int main()
{
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    Merge_sort(A,0,n);
    for(i=0;i<n;i++)
    {
      printf("%d%c", A[i], i == n - 1 ? '\n' : ' ');
    }
    printf("%d\n", sum);
    return 0;
}



Compiler output:
a.cc: In function 'int Merge(int*, int, int, int)':
a.cc:13:11: error: 'INT_MAX' was not declared in this scope
   13 |     L[n1]=INT_MAX;
      |           ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <cstdio>
  +++ |+#include <climits>
    3 | 
a.cc:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
   33 | }
      | ^
a.cc: In function 'int Merge_sort(int*, int, int)':
a.cc:44:1: warning: no return statement in function returning non-void [-Wreturn-type]
   44 | }
      | ^
Language: C++

#include <iostream>
#include <cstdio>

using namespace std;

int A[500000+10];
int n,i,j,sum=0;

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

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


int main()
{
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    Merge_sort(A,0,n);
    for(i=0;i<n;i++)
    {
      printf("%d%c", A[i], i == n - 1 ? '\n' : ' ');
    }
    printf("%d\n", sum);
    return 0;
}



Compiler output:
a.cc: In function 'int Merge(int*, int, int, int)':
a.cc:14:11: error: 'INT_MAX' was not declared in this scope
   14 |     L[n1]=INT_MAX;
      |           ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <cstdio>
  +++ |+#include <climits>
    3 | 
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
a.cc: In function 'int Merge_sort(int*, int, int)':
a.cc:45:1: warning: no return statement in function returning non-void [-Wreturn-type]
   45 | }
      | ^
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 n, 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++ ) {
    cnd++;
    if ( L[i] <= R[j] )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(int A[], int, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2;
    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 ( i = 0; i < n; i++ ) cin >> A[i];

  mergeSort(A, n, 0, n);

  for ( 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, int)':
a.cc:17:5: error: 'cnd' was not declared in this scope; did you mean 'cnt'?
   17 |     cnd++;
      |     ^~~
      |     cnt
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:28:18: error: 'n' was not declared in this scope
   28 |     mergeSort(A, n, left, mid);
      |                  ^
Language: C++

#include<iostream>
#include<limits.h>
#define SENTINEL INT_MAX
using namespace std;
typedef long long ll;
ll counter=0;
void Merge(long long S[],int left,int mid,int right){
  int n2 = right-mid;
  ll L[n1+1];
  ll R[n2+1];
  
  for(int i=0;i<n1;i++){
    L[i] = S[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=S[mid+i];
  }
  L[n1]=R[n2]=SENTINEL;
  int i=0;
  int j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      S[k]=L[i];
      i=i+1;
      counter++;
    }
    else{
      S[k]=R[j];
      j=j+1;
      counter++;
    }
  }
}
 
void Merge_Sort(long long S[],int left,int right){
   
  if(left+1<right){
    int mid = (left+right)/2;
    Merge_Sort(S,left,mid);
    Merge_Sort(S,mid,right);
    Merge(S,left,mid,right);
  }
}
int main(){
  int n;
  ll S[600000];
  
  cin >> n;
	
    for(int i=0;i<n;i++){
    	
      cin >> S[i];
    }
  
    Merge_Sort(S,0,n);
  
    for(int i=0;i<n;i++){
      cout << S[i];
    	
      if(i != n-1)cout << " ";
    }
    cout << endl;
    cout << counter << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'void Merge(long long int*, int, int, int)':
a.cc:9:8: error: 'n1' was not declared in this scope; did you mean 'n2'?
    9 |   ll L[n1+1];
      |        ^~
      |        n2
a.cc:13:5: error: 'L' was not declared in this scope
   13 |     L[i] = S[left+i];
      |     ^
a.cc:18:3: error: 'L' was not declared in this scope
   18 |   L[n1]=R[n2]=SENTINEL;
      |   ^
Language: C++

#include<iostream>
#include <vector>
using namespace std;
   
int Merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  int L[n1+1],R[n2+1];
     
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1000000000;
  R[n2]=1000000000;
     
  i=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;
}

void HeapBuild(vector<int> &vec, int root, int len) {
    int lchild = root * 2 + 1;
    if (lchild < len) {
        int flag = lchild;  // 保存左右孩子节点中的最大值下标
        int rchild = lchild + 1;
        if (rchild < len) {
            if (vec[rchild] > vec[flag]) {
                flag = rchild;
            }
        }
 
        if (vec[root] < vec[flag]) {
            std::swap(vec[root], vec[flag]);
            HeapBuild(vec, flag, len);
        }
    }
}
 
void HeapSort(vector<int> &vec) {
    for (int i = vec.size() / 2; i >= 0; --i) {
        HeapBuild(vec, i, vec.size());
    }
 
    for (int j = vec.size() - 1; j > 0; --j) {
        std::swap(vec[0], vec[j]);
        HeapBuild(vec, 0, j);
    }
}

int main(){
  int i,x,n,S[500000]; 
  cin>>n;
  for(i=0;i<n;i++)cin>>S[i];

  vector<int> vec(s,s + n);
  HeapSort(vec);
   
  x=Merge_Sort(S,0,n);
     
  for(i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<vec[i];
  }
  cout<<endl;
  cout<<x<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:76:19: error: 's' was not declared in this scope
   76 |   vector<int> vec(s,s + n);
      |                   ^
Language: C++

#include<iostream>
#include <vector>
using namespace std;
    
int Merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  int L[n1+1],R[n2+1];
      
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1000000000;
  R[n2]=1000000000;
      
  i=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 merge(vector<int> &vec, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
 
    vector<int> l(n1);
    for (int i = 0; i < n1; ++i) l[i] = vec[left + i];
 
    vector<int> r(n2);
    for (int i = 0; i < n2; ++i) r[i] = vec[mid + i];
 
    int i = 0, j = 0, k = left;
    while (i < n1 && j < n2) {
        if (l[i] <= r[j]) vec[k++] = l[i++];
        else              vec[k++] = r[j++];
    }
    while (i < n1) vec[k++] = l[i++];
    while (j < n2) vec[k++] = r[j++];
 
    return right - left;
}
 
int MergeSort(vector<int> &vec, int left, int right) {
    int res = 0;
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        res += MergeSort(vec, left, mid);
        res += MergeSort(vec, mid, right);
        res += merge(vec, left, mid, right);
        Print(vec);
    }
 
    return res;
}
 
int main(){
  int i,x,n,S[500000]; 
  cin>>n;
  for(i=0;i<n;i++)cin>>S[i];
 
  vector<int> vec(S,S + n);
  MergeSort(vec, 0, vec.size());
    
  x=Merge_Sort(S,0,n);
      
  for(i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<vec[i];
  }
  cout<<endl;
  cout<<x<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int MergeSort(std::vector<int>&, int, int)':
a.cc:70:9: error: 'Print' was not declared in this scope; did you mean 'printf'?
   70 |         Print(vec);
      |         ^~~~~
      |         printf
Language: C++

#include<iostream>
#include <vector>
using namespace std;
    
int Merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  int L[n1+1],R[n2+1];
      
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1000000000;
  R[n2]=1000000000;
      
  i=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 merge(vector<int> &vec, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
 
    vector<int> l(n1);
    for (int i = 0; i < n1; ++i) l[i] = vec[left + i];
 
    vector<int> r(n2);
    for (int i = 0; i < n2; ++i) r[i] = vec[mid + i];
 
    int i = 0, j = 0, k = left;
    while (i < n1 && j < n2) {
        if (l[i] <= r[j]) vec[k++] = l[i++];
        else              vec[k++] = r[j++];
    }
    while (i < n1) vec[k++] = l[i++];
    while (j < n2) vec[k++] = r[j++];
 
    return right - left;
}

int MergeSort(vector<int> &vec, int left, int right) {
    int res = 0;
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        res += MergeSort(vec, left, mid);
        res += MergeSort(vec, mid, right);
        res += Merge(vec, left, mid, right);
    }
 
    return res;
}

int main(){
  int i,x,n,S[500000]; 
  cin>>n;
  for(i=0;i<n;i++)cin>>S[i];
 
  vector<int> vec(S,S + n);
  MergeSort(vec, 0, vec.size());
    
  x=Merge_Sort(S,0,n);
      
  for(i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<vec[i];
  }
  cout<<endl;
  cout<<x<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int MergeSort(std::vector<int>&, int, int)':
a.cc:69:22: error: cannot convert 'std::vector<int>' to 'int*'
   69 |         res += Merge(vec, left, mid, right);
      |                      ^~~
      |                      |
      |                      std::vector<int>
a.cc:5:15: note:   initializing argument 1 of 'int Merge(int*, int, int, int)'
    5 | int Merge(int A[],int left,int mid,int right){
      |           ~~~~^~~