Language: C

#include<stdio.h>
#define N 300000

void merge(int [],int,int,int);
void mergeSort(int [],int,int);

int L[N/2],R[N/2];
int count=0;


void merge(int A[],int left,int mid,int right){
  int n1;
  int n2;
  int i,j,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]=R[n2]=N;
  i=0;
  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++;
    }
  }#include<stdio.h>
#define N 500000

void merge(int [],int,int,int);
void mergeSort(int [],int,int);

int L[N/2],R[N/2];
int count=0;


void merge(int A[],int left,int mid,int right){
  int n1;
  int n2;
  int i,j,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]=R[n2]=N;
  i=0;
  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);
#include<stdio.h>
#define N 500000

void merge(int [],int,int,int);
void mergeSort(int [],int,int);

int L[N/2],R[N/2];
int count=0;


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

  }
}

main(){

  int A[N],n,i;

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

  mergeSort(A,0,n);

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

  }
}

main(){

  int A[N],n,i;

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

  mergeSort(A,0,n);

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

}

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

  }
}

main(){

  int A[N],n,i;

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

  mergeSort(A,0,n);

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

Compiler output:
main.c: In function 'merge':
main.c:35:4: error: stray '#' in program
   35 |   }#include<stdio.h>
      |    ^
main.c:35:5: error: 'include' undeclared (first use in this function)
   35 |   }#include<stdio.h>
      |     ^~~~~~~
main.c:35:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:35:13: error: 'stdio' undeclared (first use in this function); did you mean 'stdin'?
   35 |   }#include<stdio.h>
      |             ^~~~~
      |             stdin
main.c:36:9: warning: "N" redefined
   36 | #define N 500000
      |         ^
main.c:2:9: note: this is the location of the previous definition
    2 | #define N 300000
      |         ^
main.c:38:1: error: expected expression before 'void'
   38 | void merge(int [],int,int,int);
      | ^~~~
main.c:72:6: error: static declaration of 'mergeSort' follows non-static declaration
   72 | void mergeSort(int A[],int left,int right){
      |      ^~~~~~~~~
main.c:39:6: note: previous declaration of 'mergeSort' with type 'void(int *, int,  int)'
   39 | void mergeSort(int [],int,int);
      |      ^~~~~~~~~
main.c: In function 'mergeSort':
main.c:89:6: error: redefinition of 'merge'
   89 | void merge(int A[],int left,int mid,int right){
      |      ^~~~~
main.c:11:6: note: previous definition of 'merge' with type 'void(int *, int,  int,  int)'
   11 | void merge(int A[],int left,int mid,int right){
      |      ^~~~~
main.c:116:6: error: static declaration of 'mergeSort' follows non-static declaration
  116 | void mergeSort(int A[],int left,int right){
      |      ^~~~~~~~~
main.c:83:6: note: previous declaration of 'mergeSort' with type 'void(int *, int,  int)'
   83 | void mergeSort(int [],int,int);
      |      ^~~~~~~~~
main.c:127:1: error: implicit declaration of function 'main' [-Wimplicit-function-declaration]
  127 | main(){
      | ^~~~
main.c:127:7: error: expected ';' before '{' token
  127 | main(){
      |       ^
      |       ;
main.c: In function 'merge':
main.c:149:7: error: expected ';' before '{' token
  149 | main(){
      |       ^
      |       ;
main.c: At top level:
main.c:181:1: error: return type defaults to 'int' [-Wimplicit-int]
  181 | main(){
      | ^~~~