Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;
#define MAX 500000
#define SENTINEL 200000000000

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

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++) {
    count++;
    if(L[i]<=R[i]){
      A[k]=L[i++];
    }else{
      A[k]=R[i++];
    }
  }
}

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

int main (){
  cin >> n;
  int A[500002];
  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 << count << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:16:18: warning: overflow in conversion from 'long int' to 'int' changes value from '200000000000' to '-1863462912' [-Woverflow]
   16 | #define SENTINEL 200000000000
      |                  ^~~~~~~~~~~~
a.cc:27:15: note: in expansion of macro 'SENTINEL'
   27 |   L[n1]=R[n2]=SENTINEL;
      |               ^~~~~~~~
a.cc:30:5: error: reference to 'count' is ambiguous
   30 |     count++;
      |     ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/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:19:5: note:                 'int count'
   19 | int count=0;
      |     ^~~~~
a.cc: In function 'void mergeSort(int*, int, int)':
a.cc:40:16: error: 'rihgt' was not declared in this scope; did you mean 'right'?
   40 |   if(left +1 < rihgt ) {
      |                ^~~~~
      |                right
a.cc: In function 'int main()':
a.cc:55:12: error: too many arguments to function 'void mergeSort(int*, int, int)'
   55 |   mergeSort(A,n,0,n);
      |   ~~~~~~~~~^~~~~~~~~
a.cc:39:7: note: declared here
   39 | void  mergeSort(int A[], int left, int right){
      |       ^~~~~~~~~
a.cc:62:11: error: reference to 'count' is ambiguous
   62 |   cout << count << endl;
      |           ^~~~~
/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:19:5: note:                 'int count'
   19 | int count=0;
      |     ^~~~~