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

#include <stdio.h>
#include <stdlib.h>

#define MAX_DATA_NUM      500000
#define HALF_MAX_DATA_NUM (MAX_DATA_NUM/2)

static void Merge_Void(int *pSortBuff, int LeftNum, int RightNum );

int main(void)
{
    int data_num;			/* Data Num */
	int dn;					/* Data Block */
	int cn = 2;				/* Compare Num */
	int mn = 0;				/* merge num */
	int half = 1;			/* Compare Half Num */
    int *pSortBuff;
	int remainder;          /* amari */
	int position;
	int loop;
    
    pSortBuff = (int *)malloc(sizeof(int) * MAX_DATA_NUM);
    /* get "Data Block Num" */
    scanf("%d", &db);
     
    /* get Name & time */
    while((scanf("%d", &(pSortBuff[data_num])) != EOF) && data_num < MAX_DATA_NUM)
    {
        data_num++;
    }
    
	
    /* get Data Num equal process num */
    if( data_num == db )
    {
         while(db > 1)
        {
        	position = 0;
    		db /= cn;
		   	remainder = data_num % cn;
        	
        	for(loop=0; loop<dn; loop++)
        	{
        		Merge_Void(&(pSortBuff[position]), half, half);
        		position += cn;
        		mn++;
        	}
        	
        	if(remainder > half)
        	{
        		Merge_Void(&(pSortBuff[position]), half, (remainder - half));
        		mn++;
        	}
        	
        	half = cn;
        	cn *= 2; /* double compare num */
        }
    	
    	remainder = data_num - half;
    	if(remainder > 0)
    	{
    		Merge_Void(&(pSortBuff[0]), half, remainder);
        	mn++;
    	}
    	else
    	{
    		/* Nothing */
    	}
    }
    else
    {
        /* error input */
    }
	
	for(loop=0; loop<data_num-1; loop++)
	{
		printf("%d ", pSortBuff[loop]);
	}
	printf("%d\n%d", pSortBuff[data_num-1], mn);
	
	free(pSortBuff);
    return 0;
}

void Merge_Void(int *pSortBuff, int LeftNum, int RightNum )
{
    int *pLeftBuff;
    int *pRightBuff;
	int loop;
	int ln = 0;
	int rn = 0;
	
	
    pLeftBuff = (int *)malloc(sizeof(int) * LeftNum);
    pRightBuff = (int *)malloc(sizeof(int) * RightNum);
	
	/* Input Left Buffer */
	for( loop=0; loop<LeftNum; loop++ )
	{
		pLeftBuff[loop] = pSortBuff[loop];
	}
	
	/* Input Right Buffer */
	for( loop=0; loop<RightNum; loop++ )
	{
		pRightBuff[loop] = pSortBuff[LeftNum + loop];
	}
	
	/* merge */
	for( loop=0; loop<(LeftNum + RightNum); loop++ )
	{
		if(ln == LeftNum)
		{
			pSortBuff[loop] = pRightBuff[rn];
			rn++;
		}
		else if(rn == RightNum)
		{
			pSortBuff[loop] = pLeftBuff[rn];
			ln++;
		}
		else if(pRightBuff[rn] > pLeftBuff[rn])
		{
			pSortBuff[loop] = pRightBuff[rn];
			rn++;
		}
		else
		{
			pSortBuff[loop] = pLeftBuff[rn];
			ln++;
		}
	}
	
	free(pLeftBuff);
	free(pRightBuff);
}

Compiler output:
main.c: In function 'main':
main.c:23:18: error: 'db' undeclared (first use in this function); did you mean 'dn'?
   23 |     scanf("%d", &db);
      |                  ^~
      |                  dn
main.c:23:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <cstdio>
#define M 500010
#define SENTINEL 2000000000
int a[M];
int count=0;
void merge(int,int,int);
void mergeSort(int,int);
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	mergeSort(0,n);
	for(int i=0;i<n-1;i++)
		printf("%d ",a[i]);
	printf("%d\n%d\n",a[n-1],count);
	return 0;
}
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);
	}
}
void merge(int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	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] = SENTINEL;
	R[n2] = SENTINEL;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		count++;
		if(L[i]<=R[j]){
			a[k]=L[i];
			i++;
		}else{
			a[k]=R[j];
			j++;
		}
	}
}

Compiler output:
main.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int N = 500010;
int n,cnt;
int a[N]; int L[N>>1]; int R[N>>1];
void merge(int left,int mid,int right)
{
	int x=mid-left;
	int y=right-mid;
	for(int i=0;i<x;i++)
	L[i]=a[i+left];
	for(int i=0;i<y;i++)
	R[i]=a[mid+i];
	L[x]=R[y]=INF;
	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 sort(int left ,int right)
{
	if(left<right-1) 
	{
		int mid=(left+right)>>1;
		sort(left,mid);
		sort(mid,right);
		merge(left,mid,right);
	}	
}
void print()
{
    for(int i = 0; i < n; i ++)
    {
        if(i == n-1) printf("%d\n",a[i]);
        else printf("%d ",a[i]);
    }
    printf("%d\n",cnt);
    return ;
}
int main()
{
    cnt = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i ++)
        scanf("%d",&a[i]);
    sort(0,n);
    print();
    return 0;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>
#include <stdlib.h>

static void Merge_Void(int *pSortBuff, int LeftNum, int RightNum );

int main(void)
{
    int data_num;			/* Data Num */
	int db;					/* Data Block */
	int cn = 2;				/* Compare Num */
	int mn = 0;				/* merge num */
	int half = 1;			/* Compare Half Num */
//	int pSortBuff[10] = {0, 3, 3, 2, 9, 0, 8, 2, 6, 6};
	int remainder;          /* amari */
	int section = 1;
	int position;
	int loop;
	int i;
    
    /* get "Data Block Num" */
    scanf("%d", &db);
    pSortBuff = (int *)malloc(sizeof(int) * db);
     
    /* get Name & time */
    while((scanf("%d", &(pSortBuff[data_num])) != EOF) && data_num < db)
    {
        data_num++;
    }
//    data_num = 10;
//	db = 10;
	
    /* get Data Num equal process num */
    if( data_num == db )
    {
         while(section > 1)
        {
        	position = 0;
    		section = db / cn;
		   	remainder = data_num % cn;
        	
        	for(loop=0; loop<section; loop++)
        	{
        		Merge_Void(&(pSortBuff[position]), half, half);
        		position += cn;
        		mn += cn;
        	}
        	if(remainder > half)
        	{
        		Merge_Void(&(pSortBuff[position]), half, (remainder - half));
        		mn += remainder;
        	}
        	
        	half = cn;
        	cn *= 2; /* double compare num */
        }
    	
    	if(remainder > 0)
    	{
    		Merge_Void(&(pSortBuff[0]), half, remainder);
    		mn += half;
    	}
    }
    else
    {
        /* error input */
    }
	
	for(loop=0; loop<data_num-1; loop++)
	{
		printf("%d ", pSortBuff[loop]);
	}
	printf("%d\n%d\n", pSortBuff[data_num-1], mn);
	
	free(pSortBuff);
    return 0;
}

void Merge_Void(int *pSortBuff, int LeftNum, int RightNum )
{
	int loop;
	int ln = 0;
	int rn = 0;
    int *pLeftBuff;
    int *pRightBuff;
	
	
    pLeftBuff = (int *)malloc(sizeof(int) * LeftNum);
    pRightBuff = (int *)malloc(sizeof(int) * RightNum);
	
	/* Input Left Buffer */
	for( loop=0; loop<LeftNum; loop++ )
	{
		pLeftBuff[loop] = pSortBuff[loop];
	}
	
	/* Input Right Buffer */
	for( loop=0; loop<RightNum; loop++ )
	{
		pRightBuff[loop] = pSortBuff[LeftNum + loop];
	}
	
	/* merge */
	for( loop=0; loop<(LeftNum + RightNum); loop++ )
	{
		if(ln == LeftNum)
		{
			pSortBuff[loop] = pRightBuff[rn];
			rn++;
		}
		else if(rn == RightNum)
		{
			pSortBuff[loop] = pLeftBuff[ln];
			ln++;
		}
		else if(pRightBuff[rn] < pLeftBuff[ln])
		{
			pSortBuff[loop] = pRightBuff[rn];
			rn++;
		}
		else
		{
			pSortBuff[loop] = pLeftBuff[ln];
			ln++;
		}
	}
	
	free(pLeftBuff);
	free(pRightBuff);
}

Compiler output:
main.c: In function 'main':
main.c:22:5: error: 'pSortBuff' undeclared (first use in this function)
   22 |     pSortBuff = (int *)malloc(sizeof(int) * db);
      |     ^~~~~~~~~
main.c:22:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <stdlib.h>

static void Merge_Void(int *pSortBuff, int LeftNum, int RightNum );

int main(void)
{
    int data_num;			/* Data Num */
	int db;					/* Data Block */
	int cn = 2;				/* Compare Num */
	int mn = 0;				/* merge num */
	int half = 1;			/* Compare Half Num */
//	int pSortBuff[10] = {0, 3, 3, 2, 9, 0, 8, 2, 6, 6};
	int *pSortBuff
	int remainder;          /* amari */
	int section = 1;
	int position;
	int loop;
	int i;
    
    /* get "Data Block Num" */
    scanf("%d", &db);
    pSortBuff = (int *)malloc(sizeof(int) * db);
     
    /* get Name & time */
    while((scanf("%d", &(pSortBuff[data_num])) != EOF) && data_num < db)
    {
        data_num++;
    }
//    data_num = 10;
//	db = 10;
	
    /* get Data Num equal process num */
    if( data_num == db )
    {
         while(section > 1)
        {
        	position = 0;
    		section = db / cn;
		   	remainder = data_num % cn;
        	
        	for(loop=0; loop<section; loop++)
        	{
        		Merge_Void(&(pSortBuff[position]), half, half);
        		position += cn;
        		mn += cn;
        	}
        	if(remainder > half)
        	{
        		Merge_Void(&(pSortBuff[position]), half, (remainder - half));
        		mn += remainder;
        	}
        	
        	half = cn;
        	cn *= 2; /* double compare num */
        }
    	
    	if(remainder > 0)
    	{
    		Merge_Void(&(pSortBuff[0]), half, remainder);
    		mn += half;
    	}
    }
    else
    {
        /* error input */
    }
	
	for(loop=0; loop<data_num-1; loop++)
	{
		printf("%d ", pSortBuff[loop]);
	}
	printf("%d\n%d\n", pSortBuff[data_num-1], mn);
	
	free(pSortBuff);
    return 0;
}

void Merge_Void(int *pSortBuff, int LeftNum, int RightNum )
{
	int loop;
	int ln = 0;
	int rn = 0;
    int *pLeftBuff;
    int *pRightBuff;
	
	
    pLeftBuff = (int *)malloc(sizeof(int) * LeftNum);
    pRightBuff = (int *)malloc(sizeof(int) * RightNum);
	
	/* Input Left Buffer */
	for( loop=0; loop<LeftNum; loop++ )
	{
		pLeftBuff[loop] = pSortBuff[loop];
	}
	
	/* Input Right Buffer */
	for( loop=0; loop<RightNum; loop++ )
	{
		pRightBuff[loop] = pSortBuff[LeftNum + loop];
	}
	
	/* merge */
	for( loop=0; loop<(LeftNum + RightNum); loop++ )
	{
		if(ln == LeftNum)
		{
			pSortBuff[loop] = pRightBuff[rn];
			rn++;
		}
		else if(rn == RightNum)
		{
			pSortBuff[loop] = pLeftBuff[ln];
			ln++;
		}
		else if(pRightBuff[rn] < pLeftBuff[ln])
		{
			pSortBuff[loop] = pRightBuff[rn];
			rn++;
		}
		else
		{
			pSortBuff[loop] = pLeftBuff[ln];
			ln++;
		}
	}
	
	free(pLeftBuff);
	free(pRightBuff);
}

Compiler output:
main.c: In function 'main':
main.c:14:23: error: expected ';' before 'int'
   14 |         int *pSortBuff
      |                       ^
      |                       ;
   15 |         int remainder;          /* amari */
      |         ~~~            
main.c:23:5: error: 'pSortBuff' undeclared (first use in this function)
   23 |     pSortBuff = (int *)malloc(sizeof(int) * db);
      |     ^~~~~~~~~
main.c:23:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <stdlib.h>

#define MAX_DATA 500000
static void Merge_Void(int *pSortBuff, int LeftNum, int RightNum );

int main(void)
{
    int data_num = 0;		/* Data Num */
	int db;					/* Data Block */
	int cn = 2;				/* Compare Num */
	int mn = 0;				/* merge num */
	int half = 1;			/* Compare Half Num */
//	int pSortBuff[10] = {0, 3, 3, 2, 9, 0, 8, 2, 6, 6};
//	int *pSortBuff;
	int pSortBuff[MAX_DATA];
	int remainder;          /* amari */
	int section = 1;
	int position;
	int loop;
	int i;
    
    /* get "Data Block Num" */
    scanf("%d", &db);
    pSortBuff = (int *)malloc(sizeof(int) * db);
     
    /* get Name & time */
    while((scanf("%d", &(pSortBuff[data_num])) != EOF) && data_num < db)
    {
        data_num++;
    }
//    data_num = 10;
//	db = 10;
	
    /* get Data Num equal process num */
    if( data_num == db )
    {
         while(section > 1)
        {
        	position = 0;
    		section = db / cn;
		   	remainder = data_num % cn;
        	
        	for(loop=0; loop<section; loop++)
        	{
        		Merge_Void(&(pSortBuff[position]), half, half);
        		position += cn;
        		mn += cn;
        	}
        	if(remainder > half)
        	{
        		Merge_Void(&(pSortBuff[position]), half, (remainder - half));
        		mn += remainder;
        	}
        	
        	half = cn;
        	cn *= 2; /* double compare num */
        }
    	
    	if(remainder > 0)
    	{
    		Merge_Void(&(pSortBuff[0]), half, remainder);
    		mn += half;
    	}
    }
    else
    {
        /* error input */
    }
	
	for(loop=0; loop<data_num-1; loop++)
	{
		printf("%d ", pSortBuff[loop]);
	}
	printf("%d\n%d\n", pSortBuff[data_num-1], mn);
	
//	free(pSortBuff);
    return 0;
}

void Merge_Void(int *pSortBuff, int LeftNum, int RightNum )
{
	int loop;
	int ln = 0;
	int rn = 0;
    int *pLeftBuff;
    int *pRightBuff;
	
	
    pLeftBuff = (int *)malloc(sizeof(int) * LeftNum);
    pRightBuff = (int *)malloc(sizeof(int) * RightNum);
	
	/* Input Left Buffer */
	for( loop=0; loop<LeftNum; loop++ )
	{
		pLeftBuff[loop] = pSortBuff[loop];
	}
	
	/* Input Right Buffer */
	for( loop=0; loop<RightNum; loop++ )
	{
		pRightBuff[loop] = pSortBuff[LeftNum + loop];
	}
	
	/* merge */
	for( loop=0; loop<(LeftNum + RightNum); loop++ )
	{
		if(ln == LeftNum)
		{
			pSortBuff[loop] = pRightBuff[rn];
			rn++;
		}
		else if(rn == RightNum)
		{
			pSortBuff[loop] = pLeftBuff[ln];
			ln++;
		}
		else if(pRightBuff[rn] < pLeftBuff[ln])
		{
			pSortBuff[loop] = pRightBuff[rn];
			rn++;
		}
		else
		{
			pSortBuff[loop] = pLeftBuff[ln];
			ln++;
		}
	}
	
	free(pLeftBuff);
	free(pRightBuff);
}

Compiler output:
main.c: In function 'main':
main.c:25:15: error: assignment to expression with array type
   25 |     pSortBuff = (int *)malloc(sizeof(int) * db);
      |               ^
Language: C

#include<stdio.h>
#define MAX 500001
#define INF 1000000

void merge(int A[],int left,int mid,int right,int *cnt){
int i,j,n1,n2;
int L[MAX];
int R[MAX];
int 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]=INT_MAX;
R[n2]=INT_MAX;

i=0;
j=0;

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


return;
}



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

return;
}



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

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

mergesort(A,0,n,&cnt);

for(i=0;i<n-1;i++)printf("%d ",A[i]);
printf("%d\n",A[n-1]);

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

return 0;
}


Compiler output:
main.c: In function 'merge':
main.c:16:7: error: 'INT_MAX' undeclared (first use in this function)
   16 | L[n1]=INT_MAX;
      |       ^~~~~~~
main.c:2:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    1 | #include<stdio.h>
  +++ |+#include <limits.h>
    2 | #define MAX 500001
main.c:16:7: note: each undeclared identifier is reported only once for each function it appears in
   16 | L[n1]=INT_MAX;
      |       ^~~~~~~
Language: C

#include<stdio.h>
#define MAX 500001
#define INF 100000

void merge(int A[],int left,int mid,int right,int *cnt){
int i,j,n1,n2;
int L[MAX];
int R[MAX];
int 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]=INT_MAX;
R[n2]=INT_MAX;

i=0;
j=0;

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


return;
}



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

return;
}



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

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

mergesort(A,0,n,&cnt);

for(i=0;i<n-1;i++)printf("%d ",A[i]);
printf("%d\n",A[n-1]);

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

return 0;
}


Compiler output:
main.c: In function 'merge':
main.c:16:7: error: 'INT_MAX' undeclared (first use in this function)
   16 | L[n1]=INT_MAX;
      |       ^~~~~~~
main.c:2:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    1 | #include<stdio.h>
  +++ |+#include <limits.h>
    2 | #define MAX 500001
main.c:16:7: note: each undeclared identifier is reported only once for each function it appears in
   16 | L[n1]=INT_MAX;
      |       ^~~~~~~
Language: C

#include<stdio.h>

#define INFTY 1 << 30;



int Merge(int A[],int left,int mid,int right){

  int k;
  int n1 = mid-left;
  int n2 = right-mid;

  int L[n1+1];
  int R[n2+1];

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

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

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

  int i=0;
  int j=0;

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

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

int main(){
  int n,m;
  scanf("%d",&n);

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

  m = MergeSort(S,0,n);

  for(int i=0;i<n-1;i++){
    printf("%d ",S[i];
  }
  printf("%d\n%d\n",S[n],m);

  return 0;
}



Compiler output:
main.c: In function 'main':
main.c:65:22: error: expected ')' before ';' token
   65 |     printf("%d ",S[i];
      |           ~          ^
      |                      )
main.c:65:23: error: expected ';' before '}' token
   65 |     printf("%d ",S[i];
      |                       ^
      |                       ;
   66 |   }
      |   ~
Language: C

#include<stdio.h>
#define MAX 500000

int a[N];
int cnt = 0;

void merge(int left,int mid,int right){
  int L[N/2};
  int R[N/2];
  int i,j,idx;

  for(i = mid+1; i<=right;i++) R[i-mid-1]=a[i];

  i=0;j=0;idx=left;

  while(i<=(mid-left) && j<=(right-mid-1)){
    if(L[i] <R[j]) a[idx++]=L[i++];
    else a[idx++]=R[j++];
    ent++;
  }
  while(i<=(mid-left)){
    a[idx]=L[i++];
    cnt++;
  }
  while(j<=(right-mid-1)){
    a[idx++]R[j++];
    cnt++;
  }
  return;
}

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

int main(){
  int n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  mergeSort(0,n-1);

  for(i = 0; i < n; i++){
    if(1){ printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}



Compiler output:
main.c:4:7: error: 'N' undeclared here (not in a function)
    4 | int a[N];
      |       ^
main.c: In function 'merge':
main.c:8:12: error: expected ']' before '}' token
    8 |   int L[N/2};
      |            ^
      |            ]
main.c:17:8: error: 'L' undeclared (first use in this function)
   17 |     if(L[i] <R[j]) a[idx++]=L[i++];
      |        ^
main.c:17:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:19:5: error: 'ent' undeclared (first use in this function); did you mean 'cnt'?
   19 |     ent++;
      |     ^~~
      |     cnt
main.c:26:13: error: expected ';' before 'R'
   26 |     a[idx++]R[j++];
      |             ^
      |             ;
main.c: In function 'main':
main.c:52:17: error: 'A' undeclared (first use in this function)
   52 |     printf("%d",A[i]);
      |                 ^
main.c:57:1: error: expected declaration or statement at end of input
   57 | }
      | ^
Language: C

#include<stdio.h>
#include<stdlib.h>
void merge(int*,int,int,int);
void mergeSort(int*,int,int);
int cnt=0;
void merge(int A[],int l,int m,int r){
  int n1=m-l;
  int n2=r-m;
  int L[n1]=2000000000;
  int R[n2]=2000000000;
  int i;
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  i=0;
  int j=0;
  for(int k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i+=1;
      cnt++;
    }
    else {
      A[k]=R[j];
      j+=1;
      cnt++;
    }
  }
  
  return 0;
}
void mergeSort(int A[],int l,int r){
  if(l+1<r){
    int m=(l+r)/2;
    mergeSort(A,l,m);
    mergeSort(A,m,r);
    merge(A,l,m,r);
  }
  
  return 0;
}

int main(){
  int l,m,r,n,i;
  int *A;
  scanf("%d",&n);
  A=(int *)malloc(n *sizeof(int));
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  l=0;
  r=n;
  mergeSort(A,l,r);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",cnt);
  free(A);
  return 0;
}



Compiler output:
main.c: In function 'merge':
main.c:9:13: error: variable-sized object may not be initialized except with an empty initializer
    9 |   int L[n1]=2000000000;
      |             ^~~~~~~~~~
main.c:10:13: error: variable-sized object may not be initialized except with an empty initializer
   10 |   int R[n2]=2000000000;
      |             ^~~~~~~~~~
main.c:29:10: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   29 |   return 0;
      |          ^
main.c:6:6: note: declared here
    6 | void merge(int A[],int l,int m,int r){
      |      ^~~~~
main.c: In function 'mergeSort':
main.c:39:10: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   39 |   return 0;
      |          ^
main.c:31:6: note: declared here
   31 | void mergeSort(int A[],int l,int r){
      |      ^~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
void merge(int*,int,int,int);
void mergeSort(int*,int,int);
int cnt=0;
int main(){
  int l,m,r,n,i;
  int *A;
  scanf("%d",&n);
  A=(int *)malloc(n *sizeof(int));
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  l=0;
  r=n;
  mergeSort(A,l,r);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d",A[i]);
    else printf("%d ",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  free(A);
  return 0;
}
void merge(int A[],int l,int m,int r){
  int n1=m-l;
  int n2=r-m;
  int L[n1]=2000000000;
  int R[n2]=2000000000;
  int i;
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  i=0;
  int j=0;
  for(int k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i+=1;
      cnt++;
    }
    else {
      A[k]=R[j];
      j+=1;
      cnt++;
    }
  }
}
void mergeSort(int A[],int l,int r){
  if(l+1<r){
    int m=(l+r)/2;
    mergeSort(A,l,m);
    mergeSort(A,m,r);
    merge(A,l,m,r);
  }
}



Compiler output:
main.c: In function 'merge':
main.c:27:13: error: variable-sized object may not be initialized except with an empty initializer
   27 |   int L[n1]=2000000000;
      |             ^~~~~~~~~~
main.c:28:13: error: variable-sized object may not be initialized except with an empty initializer
   28 |   int R[n2]=2000000000;
      |             ^~~~~~~~~~
Language: C

#include <stdio.h>
#define MAX 1000000001
void mergesort(int *,int ,int );
void merge(int *,int ,int ,int );
int count=0,n,Left[250001],Right[250001],i,j,kn1,n2;

int main(void){
  int S[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  mergesort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}
void mergesort(int *S,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(S,left,mid);
    mergesort(S,mid,right);
    merge(S,left,mid,right);
  }
}
void merge(int *S,int left,int mid,int right){
  n1=mid-left;n2=right-mid;
  for(i=0;i<n1;i++)
    Left[i]=S[left+i];//not include mid
  for(i=0;i<n2;i++)
    Right[i]=S[mid+i];//include mid
  Left[n1]=MAX;
  Right[n2]=MAX;
  for(i=0,j=0,k=left;k<right;k++){
    if(Left[j]>Right[i])S[k]=Right[i++];
    else S[k]=Left[j++];
  }
 


Compiler output:
main.c: In function 'merge':
main.c:31:3: error: 'n1' undeclared (first use in this function); did you mean 'n2'?
   31 |   n1=mid-left;n2=right-mid;
      |   ^~
      |   n2
main.c:31:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:38:15: error: 'k' undeclared (first use in this function)
   38 |   for(i=0,j=0,k=left;k<right;k++){
      |               ^
main.c:41:3: error: expected declaration or statement at end of input
   41 |   }
      |   ^
Language: C

#include <stdio.h>
#define MAX 1000000001
void mergesort(int *,int ,int );
void merge(int *,int ,int ,int );
int count=0,n,Left[250001],Right[250001],i,j,kn1,n2;

int main(void){
  int S[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  mergesort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}
void mergesort(int *S,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(S,left,mid);
    mergesort(S,mid,right);
    merge(S,left,mid,right);
  }
}
void merge(int *S,int left,int mid,int right){
  n1=mid-left;n2=right-mid;
  for(i=0;i<n1;i++)
    Left[i]=S[left+i];//not include mid
  for(i=0;i<n2;i++)
    Right[i]=S[mid+i];//include mid
  Left[n1]=MAX;
  Right[n2]=MAX;
  for(i=0,j=0,k=left;k<right;k++){
    if(Left[j]>Right[i])S[k]=Right[i++];
    else S[k]=Left[j++];
  }
count+=left-right;
}
 


Compiler output:
main.c: In function 'merge':
main.c:31:3: error: 'n1' undeclared (first use in this function); did you mean 'n2'?
   31 |   n1=mid-left;n2=right-mid;
      |   ^~
      |   n2
main.c:31:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:38:15: error: 'k' undeclared (first use in this function)
   38 |   for(i=0,j=0,k=left;k<right;k++){
      |               ^
Language: C

#include <stdio.h>
#define MAX 1000000001
void mergesort(int *,int ,int );
void merge(int *,int ,int ,int );
int count=0,n,Left[250001],Right[250001],i,j,kn1,n2;

int main(void){
  int S[500000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  mergesort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}
void mergesort(int *S,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(S,left,mid);
    mergesort(S,mid,right);
    merge(S,left,mid,right);
  }
}
void merge(int *S,int left,int mid,int right){
  n1=mid-left;n2=right-mid;
  for(i=0;i<n1;i++)
    Left[i]=S[left+i];//not include mid
  for(i=0;i<n2;i++)
    Right[i]=S[mid+i];//include mid
  Left[n1]=MAX;
  Right[n2]=MAX;
  for(i=0,j=0,k=left;k<right;k++){
    if(Left[j]>Right[i])S[k]=Right[i++];
    else S[k]=Left[j++];
  }
count+=right-left;
}
 


Compiler output:
main.c: In function 'merge':
main.c:31:3: error: 'n1' undeclared (first use in this function); did you mean 'n2'?
   31 |   n1=mid-left;n2=right-mid;
      |   ^~
      |   n2
main.c:31:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:38:15: error: 'k' undeclared (first use in this function)
   38 |   for(i=0,j=0,k=left;k<right;k++){
      |               ^
Language: C

#include<stdio.h>
#define inf 2000000000

int count=0;

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

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


int main(){
    int num;
    scanf("%d",&n);
    int A[num];
    int i;
    for(i=0;i<=num-1;i++)scanf("%d",&A[i]);
    
    mergeSort(A,0,num);
    
    for(i=0;i<=num-2;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[n-1]);
    printf("%d\n",count);
    
    return 0;
}



Compiler output:
main.c: In function 'main':
main.c:47:17: error: 'n' undeclared (first use in this function)
   47 |     scanf("%d",&n);
      |                 ^
main.c:47:17: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'merge':
main.c:61:1: error: expected declaration or statement at end of input
   61 | }
      | ^
main.c:61:1: error: expected declaration or statement at end of input
Language: C

#include<stdio.h>
#define inf 2000000000

int count=0;

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

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


int main(){
    int num;
    scanf("%d",&num);
    int A[num];
    int i;
    for(i=0;i<=num-1;i++)scanf("%d",&A[i]);
    
    mergeSort(A,0,num);
    
    for(i=0;i<=num-2;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[n-1]);
    printf("%d\n",count);
    
    return 0;
}



Compiler output:
main.c: In function 'main':
main.c:57:21: error: 'n' undeclared (first use in this function)
   57 |     printf("%d\n",A[n-1]);
      |                     ^
main.c:57:21: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'merge':
main.c:61:1: error: expected declaration or statement at end of input
   61 | }
      | ^
main.c:61:1: error: expected declaration or statement at end of input
Language: C

#include<stdio.h>
#define INFINITY 1000000000
int L[INFINITY],R[INFINITY];
int A[500000];
int num=0;
void merge(int A[],int left,int mid,int right){
  int i,k,j,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]=INFINITY;
  R[n2]=INFINITY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
num++;
    }
   else{
     num++;
  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);
  }
}
int main(){
  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==n-1){
printf("%d\n",A[i]);
break;
}
printf("%d ",A[i]);
}
printf("%d\n",num);
return 0;
}



Compiler output:
/tmp/ccfKYHT8.o: in function `merge':
main.c:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0xde): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0x129): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0x167): relocation truncated to fit: R_X86_64_PC32 against symbol `num' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0x170): relocation truncated to fit: R_X86_64_PC32 against symbol `num' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0x178): relocation truncated to fit: R_X86_64_PC32 against symbol `num' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0x181): relocation truncated to fit: R_X86_64_PC32 against symbol `num' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0x1a9): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccfKYHT8.o
/tmp/ccfKYHT8.o: in function `main':
main.c:(.text+0x277): relocation truncated to fit: R_X86_64_PC32 against symbol `A' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0x2ae): relocation truncated to fit: R_X86_64_PC32 against symbol `A' defined in .bss section in /tmp/ccfKYHT8.o
main.c:(.text+0x2de): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
#define DEF 1000000
int count=0;

int L[10000];
int R[10000];



void sort(int A[],int n,int lift,int right);
void merge(int A[],int n,int left,int mid,int right);

int main(){
int number;
scanf("%d",&number);

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

merge(A,number,0,number);

for(i=0;i<number;i++){
    if(i==number-1){printf("%d",A[i]);}
    else {printf("%d ",A[i]);}
    
}

    printf("\n");
    printf("%d\n",count);
    
    
    
    return 0;
}


void merge(int A[],int n,int left,int mid,int right){
    int a1=mid-left;
    int a2=right-mid;
    
    int i;
    for(i=0;i<a1;i++){L[i]=A[left+1];}
    for(i=0;i<a2;i++){R[i]=A[mid+1];}
    
    L[a1]=R[a2]=DEF;
    
    i=0;    
    int j=0;
    int k;


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

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



Compiler output:
main.c: In function 'main':
main.c:23:1: error: too few arguments to function 'merge'
   23 | merge(A,number,0,number);
      | ^~~~~
main.c:11:6: note: declared here
   11 | void merge(int A[],int n,int left,int mid,int right);
      |      ^~~~~
main.c: At top level:
main.c:69:5: error: expected identifier or '(' before '}' token
   69 |     }
      |     ^
main.c:70:1: error: expected identifier or '(' before '}' token
   70 | }
      | ^
Language: C

#include<stdio.h>
#define DEF 1000000
int count=0;

int L[10000];
int R[10000];



void sort(int A[],int n,int lift,int right);
void merge(int A[],int n,int left,int mid,int right);

int main(){
int number;
scanf("%d",&number);

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

sort(A,number,0,number);

for(i=0;i<number;i++){
    if(i==number-1){printf("%d",A[i]);}
    else {printf("%d ",A[i]);}
    
}

    printf("\n");
    printf("%d\n",count);
    
    
    
    return 0;
}


void merge(int A[],int n,int left,int mid,int right){
    int a1=mid-left;
    int a2=right-mid;
    
    int i;
    for(i=0;i<a1;i++){L[i]=A[left+1];}
    for(i=0;i<a2;i++){R[i]=A[mid+1];}
    
    L[a1]=R[a2]=DEF;
    
    i=0;    
    int j=0;
    int k;


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

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




Compiler output:
main.c:69:5: error: expected identifier or '(' before '}' token
   69 |     }
      |     ^
main.c:70:1: error: expected identifier or '(' before '}' token
   70 | }
      | ^
Language: C

#include<stdio.h>
#define DEF 1000000
int count=0;

int L[10000];
int R[10000];



void sort(int A[],int n,int lift,int right);
void merge(int A[],int n,int left,int mid,int right);

int main(){
int number;
scanf("%d",&number);

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

sort(A,number,0,number);

for(i=0;i<number;i++){
    if(i==number-1){printf("%d",A[i]);}
    else {printf("%d ",A[i]);}
    
}

    printf("\n");
    printf("%d\n",count);
    
    
    
    return 0;
}


void merge(int A[],int n,int left,int mid,int right){
    int a1=mid-left;
    int a2=right-mid;
    
    int i;
    for(i=0;i<a1;i++){L[i]=A[left+1];}
    for(i=0;i<a2;i++){R[i]=A[mid+1];}
    
    L[a1]=R[a2]=DEF;
    
    i=0;    
    int j=0;
    int k;


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

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




Compiler output:
main.c:70:1: error: expected identifier or '(' before '}' token
   70 | }
      | ^
Language: C

#include<stdio.h>

void mergeSort(int,int,int*);
void merge(int,int,int,int*);
int count=0;
int ans[500000];

int main(void){
  int data;
  int i;

  scanf("%d",&data);

  for(i = 0;i < data;i++){
    scanf("%d",&ans[i]);
  }
    mergeSort(0,data,ans);
  for(i = 0;i < data;i++){
if(i==data-1){printf("%d",ans[i])
break;
}
      printf("%d ",ans[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

void merge(int left,int mid,int right,int ans[]){
  int i;
  int j = 0;
  int k;

  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1];
  int R[n2];

  for(i = 0;i < n1;i++){
    L[i] = ans[left + i];
  }
  for(i = 0;i < n2;i++){
    R[i] = ans[mid + i];
  }
  L[n1] = R[n2] = 1000000000;
  i = 0;
  j = 0;
  for(k = left;k < right;k++){
    count++;
    if(L[i] <= R[j]){
      ans[k] = L[i];
      i = i + 1;
    }
    else{
      ans[k] = R[j];
      j = j + 1;
    }
  }
}

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



Compiler output:
main.c: In function 'main':
main.c:19:34: error: expected ';' before 'break'
   19 | if(i==data-1){printf("%d",ans[i])
      |                                  ^
      |                                  ;
   20 | break;
      | ~~~~~
Language: C

#include<stdio.h>

#define SENTINEL INT_MAX
#define MAX 500000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

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

int main()
{
    int i,n;
    int S[MAX];

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

    for(i=0;i<n;i++)
    {
        if(i>0)printf(" ");
        printf("%d",S[i]);
    }
    printf("\n");
    printf("%d\n",count);
    return 0;
}

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

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

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


Compiler output:
main.c: In function 'merge':
main.c:3:18: error: 'INT_MAX' undeclared (first use in this function)
    3 | #define SENTINEL INT_MAX
      |                  ^~~~~~~
main.c:60:13: note: in expansion of macro 'SENTINEL'
   60 |     L[n1] = SENTINEL;
      |             ^~~~~~~~
main.c:2:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    1 | #include<stdio.h>
  +++ |+#include <limits.h>
    2 | 
main.c:3:18: note: each undeclared identifier is reported only once for each function it appears in
    3 | #define SENTINEL INT_MAX
      |                  ^~~~~~~
main.c:60:13: note: in expansion of macro 'SENTINEL'
   60 |     L[n1] = SENTINEL;
      |             ^~~~~~~~
Language: C

#include<iostream>
#include<limits>
#define INFINITY 0x7FFFFFFF
void mergeSort(int* A, int left, int right);
using namespace std;
int ct = 0;
int main() {
	int* S;
	int n;
	cin >> n;
	S = new int[n];
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
	}
	/*for (int i = 0; i < n; ++i) {
	cout << S[i];
	cout << " ";
	}
	cout << endl;
	*/
	mergeSort(S, 0, n);

	for (int i = 0; i < n - 1; ++i) {
		cout << S[i];
		cout << " ";
	}
	cout << S[n - 1] << endl;
	cout << ct << endl;

	return 0;

}

void merge(int* A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int* L;
	int* R;
	L = new int[n1 + 1];
	R = new int[n2 + 1];
	for (int i = 0; i < n1; ++i) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; ++i) {
		R[i] = A[mid + i];
	}
	L[n1] = (int)INFINITY;
	R[n2] = (int)INFINITY;
	int i = 0;
	int j = 0;

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


Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>
#define N 500000

int tmp[N], cnt;

void MergeSort(int data[], int left, int right){
  int mid, i, j, k;

  if(left >= right) return;
  mid = (left + right) / 2;
  MergeSort(data, left, mid);
  MergeSort(data, mid+1, right);
  for(i=left;i<=mid;i++) tmp[i] = data[i];
  for(i=mid+1,j=right;i<=right;i++,j--) tmp[i] = data[j];
  i = left;
  j = right;
  for(k=left;k<=right;k++){
    if(tmp[i] <= tmp[j]) data[k] = tmp[i++];
    else data[k] = tmp[j--];
    c++;
  }
}

main(){
  int n, data[N], i;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &data[i]);
  MergeSort(data, 0, n-1);
  for(i=0;i<n;i++) printf("%d ", data[i]);
  printf("%d\n%d\n", data[n-1], cnt);
  return 0;
}

Compiler output:
main.c: In function 'MergeSort':
main.c:20:5: error: 'c' undeclared (first use in this function)
   20 |     c++;
      |     ^
main.c:20:5: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:24:1: error: return type defaults to 'int' [-Wimplicit-int]
   24 | main(){
      | ^~~~
Language: C

#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

Compiler output:
main.c:1:9: fatal error: map: No such file or directory
    1 | #include<map>
      |         ^~~~~
compilation terminated.
Language: C

#include <stdio.h>
#include <stdlib.h>

#define SENTINEL (1000000001)

register int count = 0;
int S[500000];
int L[500000];
int R[500000];

static void Merge(int A[], int left, int mid, int right);
static void MergeSort(int A[], int left, int right);

int main(void) {
	int i;
	int n;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d", &S[i]);
	}
	
	MergeSort(S, 0, n);
	
	for (i = 0; i < n; ++i) {
		if (i > 0) {
			putchar(' ');
		}
		printf("%d", S[i]);
	}
	putchar('\n');
	
	printf("%d\n", count);

	return 0;
}

void Merge(int A[], int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	memcpy(L, A + left, n1 * sizeof(int));
	memcpy(R, A + mid, n2 * sizeof(int));
	L[n1] = R[n2] = SENTINEL;
	i = 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 mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

Compiler output:
main.c: In function 'Merge':
main.c:42:9: error: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration]
   42 |         memcpy(L, A + left, n1 * sizeof(int));
      |         ^~~~~~
main.c:3:1: note: include '<string.h>' or provide a declaration of 'memcpy'
    2 | #include <stdlib.h>
  +++ |+#include <string.h>
    3 | 
main.c:42:9: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch]
   42 |         memcpy(L, A + left, n1 * sizeof(int));
      |         ^~~~~~
main.c:42:9: note: include '<string.h>' or provide a declaration of 'memcpy'
Language: C

#include<stdio.h>

#define SENTINEL 1000000000

void Merge(int A[],int left,int mid,int right){
  int n1 = mid - left, 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] = SENTINEL;
  R[n2] = SENTINEL;

  i = 0;
  j = 0;

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

MergeSort(int A[], int left, int right){
  int mid;

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

int main(){
  int n,i;
  int A[500000];

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

  MergeSort(A,0,n);

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

Compiler output:
main.c: In function 'Merge':
main.c:24:1: error: 'count' undeclared (first use in this function)
   24 | count++;
      | ^~~~~
main.c:24:1: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:35:1: error: return type defaults to 'int' [-Wimplicit-int]
   35 | MergeSort(int A[], int left, int right){
      | ^~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#define SENTINEL 100000
int Merge(int,int,int);
int Merge_Sort(int,int);
 int S[SENTINEL];
int A[SENTINEL];
int L[SENTINEL];
int R[SENTINEL];
int n,count = 0;

main(){
  int left,right,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  left = 0;
  right = n;
 
  Merge_Sort(left,right);

for(i=0;i<n-1;i++){
  printf("%d ",S[i]);
 }
 printf("%d",S[n-1]); 
 printf("\n");
 printf("%d\n",count);
 return 0;
}
int Merge(int left,int mid,int right){
  int n1,n2,i,j,k;

Compiler output:
main.c:12:1: error: return type defaults to 'int' [-Wimplicit-int]
   12 | main(){
      | ^~~~
main.c: In function 'Merge':
main.c:32:3: error: expected declaration or statement at end of input
   32 |   int n1,n2,i,j,k;
      |   ^~~