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

#include <iostream>
using namespace std;
void merge(int* a, int low, int mid, int high, int& cmpr) {
   int lSize = mid - low;
   int rSize = high - mid;
   int lIndex = 0;
   int rIndex = 0;
   int b[lSize + rSize];
   int cur = 0;
   while(lIndex < lSize && rIndex < rSize) {
       cmpr++;
       if (a[lIndex] <= a[rIndex]) {
          b[cur++] = a[lIndex++];
       }
       else {
          b[cur++] = a[rIndex++];
       }
   }
   while(lIndex < lSize) {
       b[cur++] = a[lIndex++];
   }
   while(rIndex < rSize) {
       b[cur++] = a[rIndex++];
   }
   for (int i = low; i < high; i ++) {
       a[i] = b[i - low];
   }
     
}
void mergeSort(int*a, int low, int high, int& cmpr) {
   if (low + 1 >= high) {
      return;
   }
   int mid = (low + high) / 2;
   mergeSort(a, low, mid, cmpr);
   mergeSort(a, mid, high, cmpr);
   merge(a, low, mid, high, cmpr);
}
int main() {
   int n;
   cin >> n;
   int a[n];
   for (int i = 0; i < n; i ++) {
       cin >> a[i];
   }
   int cmpr = 0;
   mergetSort(a, 0, n, cmpr);
   for (int i = 0; i < n; i ++) {
       cout << a[i] << " ";
   }
   cout << endl;
   cout << cmpr;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:4: error: 'mergetSort' was not declared in this scope; did you mean 'mergeSort'?
   47 |    mergetSort(a, 0, n, cmpr);
      |    ^~~~~~~~~~
      |    mergeSort
Language: C++

//#include <string>
#include <stdio.h>
//#include <math.h>
//#include <stack>
//#include <queue>
//#include <list>
#include <vector>
#include <iostream>
using namespace std;
#define MAX 100
int cou = 0;
void merge(int A[], int left, int mid, int right)
{
	int i = 0, j = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L, R;
	for (i = 0; i < n1; i++) { L.push_back(A[left + i]); }
	for (i = 0; i < n2; i++) { R.push_back(A[mid + i]); }
	L.push_back(MAX); R.push_back(MAX);
	i = 0;
	j = 0;
	for (int k = left; k < right; k++) {
		if (L.at(i) <= R.at(j)) {
			A[k] = L.at(i); i++;
		}
		else {
			A[k] = R.at(j); j++; 
		}
		cou++;
	}
}
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(void)
{
	int n, S[500];
	scanf_s("%d", &n);
	for (int i = 0; i < n; i++) { scanf_s("%d", &S[i]); }
	mergeSort(S, 0, n);
	for (int i = 0; i < n; i++) { 
		if (i != 0) { printf(" "); }
		printf("%d", S[i]);
	}
	printf("\n%d\n", cou);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   45 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int cntt;

const int INFTY = INT_MAX/2;
void merge(vector<int> &A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L, R;
    REP(i,n1) L.push_back(A[left + i]);
    REP(i,n2) R.push_back(A[mid + i]);
    L.push_back(INFTY);
    R.push_back(INFTY);
    int i = 0;
    int j = 0;
    FOR(k, left, right) {
        cntt++;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i = i + 1;
        }else {
            A[k] = R[j];
            j = j + 1;
        }
    }
}

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

void printvec(vector<int> A) {
    REP(i,A.size()-1) cout << A[i] << " ";
    cout << A[A.size()-1] << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> v;
    PUSH(n,v);
    mergeSort(v, 0, v.size());
    printvec(v);
    cout << cntt << endl;
    return 0;
}

Compiler output:
a.cc:18:19: error: 'INT_MAX' was not declared in this scope
   18 | const int INFTY = INT_MAX/2;
      |                   ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <set>
  +++ |+#include <climits>
    9 | using namespace std;
Language: C++

import std.stdio, std.algorithm, std.range, std.conv, std.string;

int exchange = 0;

void main()
{
    int n = readln.chomp.to!int;
    auto s = readln.chomp.split.map!(to!int).array;
    mergeSort(s).map!(to!string).join(" ").writeln;
    exchange.writeln;
}

int[] merge(int[] left, int[] right)
{
    int[] result;

    while (true) {
        if (left.empty) {
            result ~= right;
            exchange += right.length;
            break;
        } else if (right.empty) {
            result ~= left;
            exchange += left.length;
            break;
        } else {
            if (left[0] <= right[0]) {
                result ~= left[0];
                left = left[1..$];
            } else {
                result ~= right[0];
                right = right[1..$];
            }

            exchange++;
        }
    }

    return result;
}

int[] mergeSort(int[] a)
{
    if (a.length < 2)
        return a;

    auto mid = a.length / 2;
    int[] left = a[0..mid];
    int[] right = a[mid..$];
    return merge(mergeSort(left),  mergeSort(right));
}

Compiler output:
a.cc:29:29: error: too many decimal points in number
   29 |                 left = left[1..$];
      |                             ^~~~
a.cc:32:31: error: too many decimal points in number
   32 |                 right = right[1..$];
      |                               ^~~~
a.cc:48:20: error: too many decimal points in number
   48 |     int[] left = a[0..mid];
      |                    ^~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import std.stdio, std.algorithm, std.range, std.conv, std.string;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: '::main' must return 'int'
    5 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:7:13: error: 'readln' was not declared in this scope
    7 |     int n = readln.chomp.to!int;
      |             ^~~~~~
a.cc:9:5: error: 'mergeSort' was not declared in this scope
    9 |     mergeSort(s).map!(to!string).join(" ").writeln;
      |     ^~~~~~~~~
a.cc:10:14: error: request for member 'writeln' in 'exchange', which is of non-class type 'int'
   10 |     exchange.writeln;
      |              ^~~~~~~
a.cc: At global scope:
a.cc:13:4: error: structured binding declaration cannot have type 'int'
   13 | int[] merge(int[] left, int[] right)
      |    ^~
a.cc:13:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:13:4: error: empty structured binding declaration
a.cc:13:7: error: expected initializer before 'merge'
   13 | int[] merge(int[] left, int[] right)
      |       ^~~~~
a.cc:42:4: error: structured binding declaration cannot have type 'int'
   42 | int[] mergeSort(int[] a)
      |    ^~
a.cc:42:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:42:4: error: empty structured binding declaration
a.cc:42:7: error: expected initializer before 'mergeSort'
   42 | int[] mergeSort(int[] a)
      |       ^~~~~~~~~
Language: C++

let cnt = ref 0

let merge a l m r =
  let ni = m - l in
  let nj = r - m in
  let init_ary n p =
    Array.init (n + 1) (fun i -> if i = n then max_int else a.(p + i))
  in
  let ai = init_ary ni l in
  let aj = init_ary nj m in
  let rec doit i j k =
    if k < r then begin
      incr cnt;
      if ai.(i) <= aj.(j) then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
      else (a.(k) <- aj.(j); doit i (j + 1) (k + 1))
    end
  in
  doit 0 0 l

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in 
  merge_sort a 0 n;
  Array.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e) a;
  print_newline ();
  Printf.printf "%d\n" !cnt

Compiler output:
a.cc:1:1: error: 'let' does not name a type
    1 | let cnt = ref 0
      | ^~~
a.cc:14:7: error: expected unqualified-id before 'if'
   14 |       if ai.(i) <= aj.(j) then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
      |       ^~
a.cc:14:55: error: expected constructor, destructor, or type conversion before '(' token
   14 |       if ai.(i) <= aj.(j) then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
      |                                                       ^
a.cc:15:30: error: 'doit' does not name a type
   15 |       else (a.(k) <- aj.(j); doit i (j + 1) (k + 1))
      |                              ^~~~
a.cc:24:5: error: 'merge_sort' does not name a type
   24 |     merge_sort a m r;
      |     ^~~~~~~~~~
a.cc:25:5: error: 'merge' does not name a type
   25 |     merge a l m r
      |     ^~~~~
a.cc:32:3: error: 'Array' does not name a type
   32 |   Array.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e) a;
      |   ^~~~~
a.cc:33:19: error: expected constructor, destructor, or type conversion before ';' token
   33 |   print_newline ();
      |                   ^
a.cc:34:3: error: 'Printf' does not name a type
   34 |   Printf.printf "%d\n" !cnt
      |   ^~~~~~
Language: C++

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] = 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 'int main()':
a.cc:37:9: error: 'cin' was not declared in this scope
   37 |         cin >> n;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:41:22: error: 'cout' was not declared in this scope
   41 |                 if(i)cout << " ";
      |                      ^~~~
a.cc:41:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:42:17: error: 'cout' was not declared in this scope
   42 |                 cout << A[i];
      |                 ^~~~
a.cc:42:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:9: error: 'cout' was not declared in this scope
   44 |         cout << endl;
      |         ^~~~
a.cc:44:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:17: error: 'endl' was not declared in this scope
   44 |         cout << endl;
      |                 ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

include <bits/stdc++.h>
#define INF 1000000001
#define MAX 500000
using namespace std;
int N, S[MAX], res;

void Out() {
	cout << S[0];
	for (int i = 1; i < N; i++)
		cout << ' ' << S[i];
	cout << endl;
}

void Merge(int left, int mid, int right) {
	int n1 = mid - left, n2 = right - mid;
	vector<int> L(n1 + 1, INF), R(n2 + 1, INF);
	for (int i = 0; i < n1; i++)
		L[i] = S[left + i];
	for (int i = 0; i < n2; i++)
		R[i] = S[mid + i];
	for (int i = 0, j = 0, k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			S[k] = L[i];
			i++;
		}
		else {
			S[k] = R[j];
			j++;
		}
		res++;
	}
}

void MergeSort(int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		MergeSort(left, mid);
		MergeSort(mid, right);
		Merge(left, mid, right);
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> S[i];
	MergeSort(0, N);
	Out();
	cout << res << endl;
	return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'void Out()':
a.cc:8:9: error: 'cout' was not declared in this scope
    8 |         cout << S[0];
      |         ^~~~
a.cc:11:17: error: 'endl' was not declared in this scope
   11 |         cout << endl;
      |                 ^~~~
a.cc: In function 'void Merge(int, int, int)':
a.cc:16:9: error: 'vector' was not declared in this scope
   16 |         vector<int> L(n1 + 1, INF), R(n2 + 1, INF);
      |         ^~~~~~
a.cc:16:16: error: expected primary-expression before 'int'
   16 |         vector<int> L(n1 + 1, INF), R(n2 + 1, INF);
      |                ^~~
a.cc:18:17: error: 'L' was not declared in this scope
   18 |                 L[i] = S[left + i];
      |                 ^
a.cc:20:17: error: 'R' was not declared in this scope
   20 |                 R[i] = S[mid + i];
      |                 ^
a.cc:22:21: error: 'L' was not declared in this scope
   22 |                 if (L[i] <= R[j]) {
      |                     ^
a.cc:22:29: error: 'R' was not declared in this scope
   22 |                 if (L[i] <= R[j]) {
      |                             ^
a.cc: In function 'int main()':
a.cc:45:9: error: 'cin' was not declared in this scope
   45 |         cin >> N;
      |         ^~~
a.cc:50:9: error: 'cout' was not declared in this scope
   50 |         cout << res << endl;
      |         ^~~~
a.cc:50:24: error: 'endl' was not declared in this scope
   50 |         cout << res << endl;
      |                        ^~~~
Language: C++



#define MAXN (500000+50)

#include<iostream>
#include<cstdlib>

using namespace std;

int arr[MAXN];
int exc[MAXN];

int N;
int time(0);

void msort(int l,int r)
{
	int mid((l+r)>>1);
	if(r-l<=1)
	{
		return;
	}
	msort(l,mid);
	msort(mid,r);
	int p1(mid-1),p2(r-1);
	for(int i=r-1;i>=l;--i)
	{++time;
		if(p1<l)
		{
			exc[i]=arr[p2--];
			continue;
		}
		if(p2<mid)
		{
			exc[i]=arr[p1--];
			continue;
		}
		if(arr[p1]<arr[p2])
			exc[i]=arr[p1--];
		else
			exc[i]=arr[p2--];
	}
	for(int i=l;i<r;++i)
		arr[i]=exc[i];
}
int main()
{
	cin>>N;
	for(int i=0;i<N;++i)
		cin>>arr[i];
	msort(0,N);
	for(int i=N-1;i>0;--i)
		cout<<arr[i]<<' ';cout<<arr[0]<<endl;
	cout<<time<<endl;
	return 0;
}

Compiler output:
a.cc:14:9: error: 'int time' redeclared as different kind of entity
   14 | 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:5:
/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 msort(int, int)':
a.cc:27:12: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
   27 |         {++time;
      |            ^~~~
a.cc:27:12: error: lvalue required as increment operand
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

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

int merge_sort(vector<int> &A, int left, int right){
	int sum = 0;
	if (left + 1 < right){
		int mid = (left + right) / 2;
		sum = merge_sort(A, left, mid) + merge_sort(A, mid, right);
		sum += merge(A, left, mid, right);
	}
	return sum;
}

void solve(){
	int n, sum;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	sum = merge_sort(A, 0, n);
	for (int i = 0; i < n; i++){
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl << sum << endl;
}

signed main(){
	solve();
}

Compiler output:
a.cc: In function 'int merge(std::vector<int>&, int, int, int)':
a.cc:15:25: error: 'INT_MAX' was not declared in this scope
   15 |         L[n1] = R[n2] = INT_MAX;
      |                         ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <map>
  +++ |+#include <climits>
    5 | #include <string>
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
using namespace std;
const int num = 500005, INF = 2000000000;
int A[num], l[num/2 + 1], r[num/2 + 1], cnt = 0;
void merge(int a[], int left, int mid, int right) {
	int num1 = mid - left;
	int num2 = right - mid;
	for (int i = 0; i < num1; i++) {
		l[i] = a[left + i];
	}
	for (int i = 0; i < num2; i++) {
		r[i] = a[mid + i];
	}
	int t = 0, u = 0;
	l[num1] = INF;
	r[num2] = INF;
	for (int s = left; s < right; s++) {
		cnt++;
		if (l[t] <= r[u]) {
			a[s] = l[t];
			t++;
		}
		else {
			a[s] = r[u];
			u++;
		}
	}
}
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;
	scanf("%d", &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]);
		if(i -1 != n)cout << " ";
	}
	printf("\n");
	printf("%d\n", cnt);
	return 0;
}
		else {
			a[s] = r[u];
			u++;
		}
	}
}
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;
	scanf("%d", &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]);
		if(i -1 != n)cout << " ";
	}
	return 0;
}

Compiler output:
a.cc:54:17: error: expected unqualified-id before 'else'
   54 |                 else {
      |                 ^~~~
a.cc:58:9: error: expected declaration before '}' token
   58 |         }
      |         ^
a.cc:59:1: error: expected declaration before '}' token
   59 | }
      | ^
a.cc:60:6: error: redefinition of 'void mergeSort(int*, int, int)'
   60 | void mergeSort(int a[], int left, int right) {
      |      ^~~~~~~~~
a.cc:32:6: note: 'void mergeSort(int*, int, int)' previously defined here
   32 | void mergeSort(int a[], int left, int right) {
      |      ^~~~~~~~~
a.cc:68:5: error: redefinition of 'int main()'
   68 | int main() {
      |     ^~~~
a.cc:40:5: note: 'int main()' previously defined here
   40 | int main() {
      |     ^~~~
Language: C++

#include <iostream>
using namespace std;

int cnt = 0, s[500000];

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] = 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++;
		}
		else {
			A[k] = R[j];
			j++;
		}
		cnt++;
	}

	delete[] R;
	delete[] L;

}

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

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

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

	MergeSort(s, 0, n);

	for (int i = 0; i < n; i++) 
	{
		if (i != 0) {
			putchar(' ');
		}
		cout << s[i];
	}

	cout << endl << cnt << endl;
}

Compiler output:
a.cc: In function 'void Merge(int*, int, int, int)':
a.cc:23:25: error: 'INT_MAX' was not declared in this scope
   23 |         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 | using namespace std;
Language: C++

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

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

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

int main()
{
	int C[MAX], n, i;
	cnt = 0;
	cin >> n;
	for (i = 0; i < n, i++) cin >> C[i];

	mergesort(C, n, 0, n);

	for (i = 0; i < n; i++) {
		if (i)cout << " ";
		cout << C[i];
	}
	cout << endl;
	cout << cnt << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:31: error: expected ';' before ')' token
   46 |         for (i = 0; i < n, i++) cin >> C[i];
      |                               ^
      |                               ;
Language: C++

#include <iostream>

using namespace std;

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

// Merge
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] = 200000;
	R[n2] = 200000;

	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:6:7: error: 'MAX' was not declared in this scope
    6 | int L[MAX/2 + 2];
      |       ^~~
a.cc:7:7: error: 'MAX' was not declared in this scope
    7 | int R[MAX/2 + 2];
      |       ^~~
a.cc: In function 'void Merge(int*, int, int, int)':
a.cc:16:17: error: 'L' was not declared in this scope
   16 |                 L[i] = A[left + i];
      |                 ^
a.cc:18:17: error: 'R' was not declared in this scope
   18 |                 R[i] = A[mid + i];
      |                 ^
a.cc:19:9: error: 'L' was not declared in this scope
   19 |         L[n1] = 200000;
      |         ^
a.cc:20:9: error: 'R' was not declared in this scope
   20 |         R[n2] = 200000;
      |         ^
Language: C++

#include <iostream>

using namespace std;

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


// Merge
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] = 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:13:1: error: expected ',' or ';' before 'void'
   13 | void Merge(int A[], int left, int mid, int right)
      | ^~~~
a.cc: In function 'void Mergesort(int*, int, int)':
a.cc:46:17: error: 'Merge' was not declared in this scope
   46 |                 Merge(A, left, mid, right);
      |                 ^~~~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF 999999999
using namespace std;
int cnt=0;
void merge(int A[],int left,int mid,int right);
void mergeSort(int A[],int left,int right);

int main()
{
    int n;
    cin >> n;
    int S[n];
    REP(i, n) cin >> S[i];
    mergeSort(S, 0, n);
    REP(i,n)
        cout << S[i];
        if (i < n-1) cout << " ";
    cout << endl << cnt << endl;;
    return 0;
}

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

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);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:13: error: 'i' was not declared in this scope
   20 |         if (i < n-1) cout << " ";
      |             ^
Language: C++


#include<iostream>
const int STN = INT_MAX;
const int MAX = 520000;
using namespace std;
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, 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] = STN;
	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 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];
	cnt =  0;
	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) 
			cout << " ";
		 cout <<A[i];
		 }
 	cout <<endl;
 	cout << cnt <<endl;
}

Compiler output:
a.cc:3:17: error: 'INT_MAX' was not declared in this scope
    3 | const int STN = 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 | const int STN = INT_MAX;
Language: C++

def merge(A, left, mid, right):
    n1 = mid-left
    n2 = right-mid
    L = [0 for i in range(n1)]
    R = [0 for i in range(n2)]
    for i in range(n1):
        L[i] = A[left+i]
    for i in range(n2):
        R[i] = A[mid+i]
    L[n1] = inf
    R[n2] = inf
    i = 0
    j = 0
    for k in range(left, right)
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
        else:
            A[k] = R[j]
            j = j+1
    global cnt
    cnt += 1

 def mergeSort(A, left, right):
     if left+1 < right:
         mid = (left+right) / 2
         mergeSort(A, left, mid)
         mergeSort(A, mid, right)
         merge(A, left, mid, right)

n = input()
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, len(A))
print(*A)
print(str(cnt))

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def merge(A, left, mid, right):
      | ^~~
Language: C++

def merge(A, left, mid, right):
    n1 = mid-left
    n2 = right-mid
    L = [0 for i in range(n1)]
    R = [0 for i in range(n2)]
    for i in range(n1):
        L[i] = A[left+i]
    for i in range(n2):
        R[i] = A[mid+i]
    L[n1] = inf
    R[n2] = inf
    i = 0
    j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
        else:
            A[k] = R[j]
            j = j+1
    global cnt
    cnt += 1
def mergeSort(A, left, right):
     if left+1 < right:
         mid = (left+right) / 2
         mergeSort(A, left, mid)
         mergeSort(A, mid, right)
         merge(A, left, mid, right)

n = input()
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, len(A))
print(*A)
print(str(cnt))

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def merge(A, left, mid, right):
      | ^~~
Language: C++

def merge(A, left, mid, right):
    global cnt
    inf = 50000001
    n1, n2 = mid - left, right - mid
    L, R = A[left:left+n1]+[inf], A[mid:mid+n2]+[inf]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
        cnt += 1

def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

cnt = 0
n = int(input())
A = list(map(int, input().split()))
mergeSort(A, 0, n)
print(*A)
print(cnt)

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def merge(A, left, mid, right):
      | ^~~
Language: C++

#include<iostream>
#include<limits>
using namespace std;
int conpareCount = 0;
void merge(int* A, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	//int L[n1 + 1], R[n2 + 1];
	int L = new int[550000], R = new int[550000];
	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] = numeric_limits<int>::infinity();
	R[n2] = numeric_limits<int>::infinity();*/
	L[n1] = 100000;
	R[n2] = 100000;
	int i = 0; 
	int j = 0;
	for(int k = left; k < right; k++){
		conpareCount++;
		if(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;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){
	int n = 0;
	cin >> n;
	//int A[n];
	int A[3000000];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	mergeSort(A, 0, n);
	cout << A[0];
	for(int i = 1; i < n; i++){
		cout << ' ' << A[i];
	}
	cout << '\n';
	cout << conpareCount << '\n';
	cin >> n;
	return 0;
}

Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:9:31: error: invalid conversion from 'int*' to 'int' [-fpermissive]
    9 |         int L = new int[550000], R = new int[550000];
      |                               ^
      |                               |
      |                               int*
a.cc:9:52: error: invalid conversion from 'int*' to 'int' [-fpermissive]
    9 |         int L = new int[550000], R = new int[550000];
      |                                                    ^
      |                                                    |
      |                                                    int*
a.cc:11:18: error: invalid types 'int[int]' for array subscript
   11 |                 L[i] = A[left + i];
      |                  ^
a.cc:14:18: error: invalid types 'int[int]' for array subscript
   14 |                 R[i] = A[mid + i];
      |                  ^
a.cc:18:10: error: invalid types 'int[int]' for array subscript
   18 |         L[n1] = 100000;
      |          ^
a.cc:19:10: error: invalid types 'int[int]' for array subscript
   19 |         R[n2] = 100000;
      |          ^
a.cc:24:21: error: invalid types 'int[int]' for array subscript
   24 |                 if(L[i] <= R[j]){
      |                     ^
a.cc:24:29: error: invalid types 'int[int]' for array subscript
   24 |                 if(L[i] <= R[j]){
      |                             ^
a.cc:25:33: error: invalid types 'int[int]' for array subscript
   25 |                         A[k] = L[i];
      |                                 ^
a.cc:28:33: error: invalid types 'int[int]' for array subscript
   28 |                         A[k] = R[j];
      |                                 ^
a.cc:32:9: error: type 'int' argument given to 'delete', expected pointer
   32 | delete[]L;
      |         ^
a.cc:33:9: error: type 'int' argument given to 'delete', expected pointer
   33 | delete[]R;
      |         ^
Language: C++

#include<iostream>
#include<limits>
using namespace std;
int conpareCount = 0;
void merge(int* A, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	//int L[n1 + 1], R[n2 + 1];
	int* L = new int[550000], R = new int[550000];
	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] = numeric_limits<int>::infinity();
	R[n2] = numeric_limits<int>::infinity();*/
	L[n1] = 100000;
	R[n2] = 100000;
	int i = 0; 
	int j = 0;
	for(int k = left; k < right; k++){
		conpareCount++;
		if(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;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){
	int n = 0;
	cin >> n;
	//int A[n];
	int A[3000000];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	mergeSort(A, 0, n);
	cout << A[0];
	for(int i = 1; i < n; i++){
		cout << ' ' << A[i];
	}
	cout << '\n';
	cout << conpareCount << '\n';
	cin >> n;
	return 0;
}

Compiler output:
a.cc: In function 'void merge(int*, int, int, int)':
a.cc:9:53: error: invalid conversion from 'int*' to 'int' [-fpermissive]
    9 |         int* L = new int[550000], R = new int[550000];
      |                                                     ^
      |                                                     |
      |                                                     int*
a.cc:14:18: error: invalid types 'int[int]' for array subscript
   14 |                 R[i] = A[mid + i];
      |                  ^
a.cc:19:10: error: invalid types 'int[int]' for array subscript
   19 |         R[n2] = 100000;
      |          ^
a.cc:24:29: error: invalid types 'int[int]' for array subscript
   24 |                 if(L[i] <= R[j]){
      |                             ^
a.cc:28:33: error: invalid types 'int[int]' for array subscript
   28 |                         A[k] = R[j];
      |                                 ^
a.cc:33:9: error: type 'int' argument given to 'delete', expected pointer
   33 | delete[]R;
      |         ^
Language: C++

#include<iostream>
#include<limits>
using namespace std;
int conpareCount = 0;
void merge(int* A, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	//int L[n1 + 1], R[n2 + 1];
	int *L = new int[50000000], *R = new int[50000000];
	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] = numeric_limits<int>::infinity();
	R[n2] = numeric_limits<int>::infinity();*/
	L[n1] = 100000;
	R[n2] = 100000;
	int i = 0; 
	int j = 0;
	for(int k = left; k < right; k++){
		conpareCount++;
		if(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;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(){
	int n = 0;
	cin >> n;
	//int A[n];
	int A = int[n];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	mergeSort(A, 0, n);
	cout << A[0];
	for(int i = 1; i < n; i++){
		cout << ' ' << A[i];
	}
	cout << '\n';
	cout << conpareCount << '\n';
	cin >> n;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:17: error: expected primary-expression before 'int'
   49 |         int A = int[n];
      |                 ^~~
a.cc:51:25: error: invalid types 'int[int]' for array subscript
   51 |                 cin >> A[i];
      |                         ^
a.cc:53:19: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   53 |         mergeSort(A, 0, n);
      |                   ^
      |                   |
      |                   int
a.cc:36:21: note:   initializing argument 1 of 'void mergeSort(int*, int, int)'
   36 | void mergeSort(int* A, int left, int right){
      |                ~~~~~^
a.cc:54:18: error: invalid types 'int[int]' for array subscript
   54 |         cout << A[0];
      |                  ^
a.cc:56:33: error: invalid types 'int[int]' for array subscript
   56 |                 cout << ' ' << A[i];
      |                                 ^
Language: C++

#include <iostream>
#include<stack>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int merges(int start,int end) {
	int middle;
	if (start >= end) {
		return 0;
	}
	middle = (start + end) / 2;
	return (merges( start, middle)+merges(middle+1,end)+right-left);
}

int main()
{
	int n, dat[50000]; cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> dat[i];
	}
	sort(dat, dat + n);
	for (int i = 0; i <n; i++)
	{
		if (i != 0) {
			cout << " ";
		}
		cout << dat[i];
	}
	
	cout << endl << merges(0, n) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int merges(int, int)':
a.cc:13:60: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |         return (merges( start, middle)+merges(middle+1,end)+right-left);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
a.cc:13:66: error: ISO C++ forbids using pointer to a function in subtraction [-fpermissive]
   13 |         return (merges( start, middle)+merges(middle+1,end)+right-left);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
const int INF=10000000;
int x;


void merge(int *A,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	int* L=new int[n1];
	int* R=new int[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]=INF;
	R[n2]=INF;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		x++;
		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);
	
	}
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
const int INF=10000000;
int x;
int a*;

void merge(int *A,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	int* L=new int[n1];
	int* R=new int[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]=INF;
	R[n2]=INF;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		x++;
		if(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;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	
	}
}




int main(){
	a=new int[500000];
	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!=n-1)cout<<a[i]<<" ";
		else cout<<a[i]<<endl;
	}
	cout<<x<<endl;
	return 0;
}

Compiler output:
a.cc:6:6: error: expected initializer before '*' token
    6 | int a*;
      |      ^
a.cc: In function 'int main()':
a.cc:55:9: error: 'a' was not declared in this scope
   55 |         a=new int[500000];
      |         ^
Language: C++

#include <iostream>
using namespace std;

const int INFTY=1000000001;
int Count;

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;

	for(int i=0,j=0,k=left;k<right;k++){
		if(Count++,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)
		return;

	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[100000];
	for(int i=0;i<n;i++){
		cin>>S[i];
	}

	Count=0;

	mergesort(S,S[0],S[n]);

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


		if(i<n-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
	cout<<Count<<endl;
	return 0;
}

Compiler output:
a.cc:7:28: error: expected ')' before ';' token
    7 | void Merge(int A[],int left;int mid,int right){
      |           ~                ^
      |                            )
a.cc:7:37: error: expected unqualified-id before 'int'
    7 | void Merge(int A[],int left;int mid,int right){
      |                                     ^~~
a.cc: In function 'void mergesort(int*, int, int)':
a.cc:46:14: error: too many arguments to function 'void Merge(int*, int)'
   46 |         Merge(A,left,mid,right);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
a.cc:7:6: note: declared here
    7 | void Merge(int A[],int left;int mid,int right){
      |      ^~~~~
Language: C++

#include<iostream>
#include<algorithm>
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;
	for(int i=0,j=0,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) {
		return;
	}
		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[500000];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	C = 0;
	mergeSort(A, A[0],A[N]);

	for (int i = 0; i < N; i++) {
		cout << A[i];
		if (i < N - 1) {
			cout << ' ';
		}
		else {
			cout << endl;
		}
	}
	cout << C << endl;
	return 0;
}

Compiler output:
a.cc: In function 'void Merge(int*, int, int, int)':
a.cc:24:27: error: expected ']' before '}' token
   24 |                 if(C++,L[i}<=R[j]){
      |                           ^
      |                           ]
a.cc:24:27: error: expected ')' before '}' token
   24 |                 if(C++,L[i}<=R[j]){
      |                   ~       ^
      |                           )
a.cc:24:27: error: expected primary-expression before '}' token
a.cc:24:28: error: expected primary-expression before '<=' token
   24 |                 if(C++,L[i}<=R[j]){
      |                            ^~
a.cc:24:32: error: 'j' was not declared in this scope
   24 |                 if(C++,L[i}<=R[j]){
      |                                ^
a.cc:27:18: error: 'else' without a previous 'if'
   27 |                 }else{
      |                  ^~~~
a.cc:28:27: error: 'k' was not declared in this scope
   28 |                         A[k]=R[j];
      |                           ^
a.cc: At global scope:
a.cc:32:9: error: expected unqualified-id before 'delete'
   32 |         delete[] L;
      |         ^~~~~~
a.cc:33:9: error: expected unqualified-id before 'delete'
   33 |         delete[] R;
      |         ^~~~~~
a.cc:34:1: error: expected declaration before '}' token
   34 | }
      | ^
Language: C++

#include<iostream>
#include"stdio.h"
#define MAX 500000
#define N 1000000000
using namespace std;

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

void merge(int a[], int left,int middle, int right)
{
	int n1 = middle - left;
	int n2 = right - middle;
	for (int i = 0; i < n1; i++)L[i] = a[left+i];
	L[n1] = N;
	for (int i = 0; i < n2; i++)R[i] = a[middle+i];
	R[n2] = N;
	int l = 0;
	int r = 0;
	for (int i = left; i < right; i++)
	{
		c++;
		if (L[l] > R[r])
		{
			a[i] = R[r];
			r++;
		}
		else
		{
			a[i] = L[l];
			l++;
		}
	}
}
void mergesort(int a[],int left,int right)
{
	if (left + 1 < right)
	{
		int middle = (left + right) / 2;
		mergesort(a, left, middle);
		mergesort(a, middle, right);
		merge(a, left, middle, right);
	}

}


int main()
{
	int n;
	scanf_s("%d", &n);
	for (int i = 0; i < n; i++)scanf_s("%d", &arr[i]);
	mergesort(arr, 0, n);
	for (int i = 0; i < n; i++)printf("%d ", arr[i]);
	printf("\n");
	printf("%d\n", c);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   52 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf
Language: C++

#include<iostream>
#include"stdio.h"
#define MAX 500000
#define N 1000000000
using namespace std;

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

void merge(int a[], int left,int middle, int right)
{
	int n1 = middle - left;
	int n2 = right - middle;
	for (int i = 0; i < n1; i++)L[i] = a[left+i];
	L[n1] = N;
	for (int i = 0; i < n2; i++)R[i] = a[middle+i];
	R[n2] = N;
	int l = 0;
	int r = 0;
	for (int i = left; i < right; i++)
	{
		c++;
		if (L[l] > R[r])
		{
			a[i] = R[r];
			r++;
		}
		else
		{
			a[i] = L[l];
			l++;
		}
	}
}
void mergesort(int a[],int left,int right)
{
	if (left + 1 < right)
	{
		int middle = (left + right) / 2;
		mergesort(a, left, middle);
		mergesort(a, middle, right);
		merge(a, left, middle, right);
	}

}


int main()
{
	int n;
	scanf_s("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", &arr[i]);
	mergesort(arr, 0, n);
	for (int i = 0; i < n; i++)printf("%d ", arr[i]);
	printf("\n");
	printf("%d\n", c);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   52 |         scanf_s("%d", &n);
      |         ^~~~~~~
      |         scanf