Language: C++

#include<iostream>
using namespace std;
#define Ma 500000
#define SENTINEL 200000000000

int L[Max/2+2], M[Max/2+2];
int cnt;

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

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(){
    nit 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<<end1;
    return 0;
}


Compiler output:
a.cc:6:7: error: 'Max' was not declared in this scope; did you mean 'Ma'?
    6 | int L[Max/2+2], M[Max/2+2];
      |       ^~~
      |       Ma
a.cc:6:19: error: 'Max' was not declared in this scope; did you mean 'Ma'?
    6 | int L[Max/2+2], M[Max/2+2];
      |                   ^~~
      |                   Ma
a.cc: In function 'int merge(int, int, int, int)':
a.cc:13:5: error: 'L' was not declared in this scope
   13 |     L[i]=A[left+i];
      |     ^
a.cc:13:11: error: invalid types 'int[int]' for array subscript
   13 |     L[i]=A[left+i];
      |           ^
a.cc:15:5: error: 'R' was not declared in this scope
   15 |     R[i]=A[mid+i];
      |     ^
a.cc:15:11: error: invalid types 'int[int]' for array subscript
   15 |     R[i]=A[mid+i];
      |           ^
a.cc:16:3: error: 'L' was not declared in this scope
   16 |   L[n1]=R[n2]=SENTINEL;
      |   ^
a.cc:16:9: error: 'R' was not declared in this scope
   16 |   L[n1]=R[n2]=SENTINEL;
      |         ^
a.cc:21:11: error: invalid types 'int[int]' for array subscript
   21 |          A[k]=L[i++];
      |           ^
a.cc:24:9: error: invalid types 'int[int]' for array subscript
   24 |        A[k]=R[i];
      |         ^
a.cc:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
   27 | }
      | ^
a.cc: In function 'void mergeSort(int*, int, int, int)':
a.cc:34:15: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   34 |         merge(A,n,left,mid,right);
      |               ^
      |               |
      |               int*
a.cc:34:14: error: too many arguments to function 'int merge(int, int, int, int)'
   34 |         merge(A,n,left,mid,right);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:9:5: note: declared here
    9 | int merge(int A,int left,int mid,int right){
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:39:5: error: 'nit' was not declared in this scope; did you mean 'int'?
   39 |     nit A[MAX],n,i;
      |     ^~~
      |     int
a.cc:42:10: error: 'n' was not declared in this scope
   42 |     cin>>n;
      |          ^
a.cc:43:9: error: 'i' was not declared in this scope
   43 |     for(i=0;i<n;i++)
      |         ^
a.cc:44:13: error: 'a' was not declared in this scope; did you mean 'Ma'?
   44 |        cin>>a[i];
      |             ^
      |             Ma
a.cc:46:15: error: 'A' was not declared in this scope
   46 |     mergeSort(A,n,0,n);
      |               ^
a.cc:48:9: error: 'i' was not declared in this scope
   48 |     for(i=0;i<n;i++){
      |         ^
a.cc:53:16: error: 'end1' was not declared in this scope
   53 |     cout<<cnt<<end1;
      |                ^~~~