Language: C

include<stdio.h>
#define INFTY 500000
int R[10000],L[10000],C=0;
void merge(int *,int, int,int );
void mergeSort(int *,int,int);

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

  mergeSort(S,left,right);

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

  return 0;
}
void merge(int A[],int left,int mid,int right)
{
  int n1,n2,i,j,k,l=0,r=0;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<=n1-1;i++)
    {
      L[i]=A[left+i];
      l++;
    }

      l++;
    }

  for(i=0;i<=n2-1;i++)
    {
      R[i]=A[mid+i];
      r++;
    }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++)
    {
      C++;
      if(L[i]<=R[j])
        {
          if(l>0)
            {
              A[k]=L[i];
              i=i+1;
              l--;
            }
          else
            {
            A[k]=R[j];
            j=j+1;
            r--;
        }
        }
      else
        {
          if(r>0)
            {
          A[k]=R[j];
          j=j+1;
          r--;
            }
          else
            {
              A[k]=L[i];
          i=i+1;
          if(r>0)
                    l--;
            }
        }
    }
}

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:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
main.c: In function 'main':
main.c:10:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   10 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | include<stdio.h>
main.c:10:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   10 |   scanf("%d",&n);
      |   ^~~~~
main.c:10:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:25:8: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   25 |        printf("%d",S[i]);
      |        ^~~~~~
main.c:25:8: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:25:8: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:25:8: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:35:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   35 |   printf("%d\n",C);
      |   ^~~~~~
main.c:35:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:35:17: error: 'C' undeclared (first use in this function)
   35 |   printf("%d\n",C);
      |                 ^
main.c:35:17: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'merge':
main.c:46:7: error: 'L' undeclared (first use in this function)
   46 |       L[i]=A[left+i];
      |       ^
main.c: At top level:
main.c:53:3: error: expected identifier or '(' before 'for'
   53 |   for(i=0;i<=n2-1;i++)
      |   ^~~
main.c:53:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token
   53 |   for(i=0;i<=n2-1;i++)
      |            ^~
main.c:53:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   53 |   for(i=0;i<=n2-1;i++)
      |                    ^~
main.c:58:5: error: 'n1' undeclared here (not in a function)
   58 |   L[n1]=INFTY;
      |     ^~
main.c:58:3: warning: data definition has no type or storage class
   58 |   L[n1]=INFTY;
      |   ^
main.c:58:3: error: type defaults to 'int' in declaration of 'L' [-Wimplicit-int]
main.c:59:5: error: 'n2' undeclared here (not in a function)
   59 |   R[n2]=INFTY;
      |     ^~
main.c:59:3: warning: data definition has no type or storage class
   59 |   R[n2]=INFTY;
      |   ^
main.c:59:3: error: type defaults to 'int' in declaration of 'R' [-Wimplicit-int]
main.c:60:3: warning: data definition has no type or storage class
   60 |   i=0;
      |   ^
main.c:60:3: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
main.c:61:3: warning: data definition has no type or storage class
   61 |   j=0;
      |   ^
main.c:61:3: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
main.c:62:3: error: expected identifier or '(' before 'for'
   62 |   for(k=left;k<=right-1;k++)
      |   ^~~
main.c:62:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token
   62 |   for(k=left;k<=right-1;k++)
      |               ^~
main.c:62:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   62 |   for(k=left;k<=right-1;k++)
      |                          ^~
main.c:97:1: error: expected identifier or '(' before '}' token
   97 | }
      | ^