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

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

int n;
int count=0;

void merge(int *A,int left,int mid,int right){
  int *L,*R;
  L=malloc(sizeof(int)*(mid-left+1));
  R=malloc(sizeof(int)*(right-mid+1));
  
  int i;
  for(i=0;i<mid-left;i++) L[i]=A[left+i];
  L[mid-left]=INT_MAX;
  for(i=0;i<right-mid;i++) R[i]=A[mid+i];
  R[right-mid]=INT_MAX;//どの不等式にもかつ数字を、配列の最後尾に入れる
  
  int l,r;
  l=0;
  r=0;
  for(i=0;i<right-left;i++){
    if(L[l] <= R[r]){
      A[left+i]=L[l];
      l+=1;
     }
    else{
      count+=mid-left-l;
      A[left+i]=R[r];
      r+=1;
    }
  }
  free(L);
  free(R);
}




void mergesort(int *A,int left,int right){
  if(left +1 < right){//整列させる要素が２つ以上ある場合は、分割する
    int mid;
    mid=(left+right)/2;
    mergesort(A,left,mid);
    mergesort(A,mid,right);
    merge(A,left,mid,right);
  }
}
//A[left]からA[right-1]まで整列させる



int main(){
  int *A;
  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",&A[i]);

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




Compiler output:
main.c: In function 'merge':
main.c:16:15: error: 'INT_MAX' undeclared (first use in this function)
   16 |   L[mid-left]=INT_MAX;
      |               ^~~~~~~
main.c:5:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    4 | #include<math.h>
  +++ |+#include <limits.h>
    5 | 
main.c:16:15: note: each undeclared identifier is reported only once for each function it appears in
   16 |   L[mid-left]=INT_MAX;
      |               ^~~~~~~
Language: C

#include <vector>
#include <iostream>
 
using namespace std;
using long64 = long long int;
using int_vec = vector<long64>;
long64 inversion = 0;
 
 
void merge(int_vec& v, int_vec& left, int_vec& right) {
    auto it = v.begin();
    auto l = left.begin();
    auto r = right.begin();
    auto n = left.size();
    while (l != left.end() && r != right.end()) {
        if (*l <= *r) {
            *it++ = *l++;
            --n;
        } else {
            *it++ = *r++;
            inversion += n;
        }
    }
    if (l != left.end()) {
        copy(l, left.end(), it);
    } else {
        copy(r, right.end(), it);
    }
    return;
}
 
void merge_sort(int_vec& v) {
    if (v.size() < 2) {
        return;
    }
 
    auto mid = v.begin() + distance(v.begin(), v.end()) / 2;
    auto left = int_vec(v.begin(), mid);
    auto right = int_vec(mid, v.end());
    merge_sort(left);
    merge_sort(right);
    merge(v, left, right);
    return;
}
 
int main() {
    int n;
    cin >> n;
 
    int_vec v;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    merge_sort(v);
    cout << inversion << endl;
 
    return 0;
}


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


#include <stdio.h>
#include <stdlib.h>
long long merge(int *,int,int,int);
longlong mergesort(int*,int,int);
int main(){
  int A[200000],i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergesort(A,0,n);
  printf("%d\n",cnt);
  return 0;
}
long long merge(int *a,int left,int mid,int right){
  long long cnt=0;
  int l,i,k,j,n1=mid-left,n2=right-mid;
  int *L,*R;
  L=malloc(sizeof(int)*(n1+2));
  R=malloc(sizeof(int)*(n2+2));
  for(i=0;i<n1;i++){
    L[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }
  L[n1]=2147483647;
  R[n2]=2147483647;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j])a[k]=L[i++];
    else{
      a[k]=R[j++];
      cnt+=n1-i;
    }
  }
  free(L);
  free(R);
  return cnt;
}
long long  mergesort(int *a,int left,int right){
  int mid;
  long long v1,v2,v3;
  if(left+1<right){
    mid=(left+right)/2;
    v1=mergesort(a,left,mid);
    v2=mergesort(a,mid,right);
    v3=merge(a,left,mid,right);
    return v1+v2+v3;
  }
  else return 0;
}




Compiler output:
main.c:5:1: error: unknown type name 'longlong'
    5 | longlong mergesort(int*,int,int);
      | ^~~~~~~~
main.c: In function 'main':
main.c:11:17: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
   11 |   printf("%d\n",cnt);
      |                 ^~~
      |                 int
main.c:11:17: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:41:12: error: conflicting types for 'mergesort'; have 'long long int(int *, int,  int)'
   41 | long long  mergesort(int *a,int left,int right){
      |            ^~~~~~~~~
main.c:5:10: note: previous declaration of 'mergesort' with type 'int(int *, int,  int)'
    5 | longlong mergesort(int*,int,int);
      |          ^~~~~~~~~
Language: C


#include <stdio.h>
#include <stdlib.h>
long long merge(int *,int,int,int);
long long mergesort(int*,int,int);
int main(){
  int A[200000],i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergesort(A,0,n);
  printf("%d\n",cnt);
  return 0;
}
long long merge(int *a,int left,int mid,int right){
  long long cnt=0;
  int l,i,k,j,n1=mid-left,n2=right-mid;
  int *L,*R;
  L=malloc(sizeof(int)*(n1+2));
  R=malloc(sizeof(int)*(n2+2));
  for(i=0;i<n1;i++){
    L[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }
  L[n1]=2147483647;
  R[n2]=2147483647;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j])a[k]=L[i++];
    else{
      a[k]=R[j++];
      cnt+=n1-i;
    }
  }
  free(L);
  free(R);
  return cnt;
}
long long  mergesort(int *a,int left,int right){
  int mid;
  long long v1,v2,v3;
  if(left+1<right){
    mid=(left+right)/2;
    v1=mergesort(a,left,mid);
    v2=mergesort(a,mid,right);
    v3=merge(a,left,mid,right);
    return v1+v2+v3;
  }
  else return 0;
}




Compiler output:
main.c: In function 'main':
main.c:11:17: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
   11 |   printf("%d\n",cnt);
      |                 ^~~
      |                 int
main.c:11:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define INFINITY 1000000000

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

int count=0;

int main(){

  int i;
  int n,left,right;

  scanf("%d",&n);
  int N[n];
  for(i=0;i<n;i++){
    scanf("%d",&N[i]);
  }
  left=0;
  right=n;
  mergesort(N,left,right);
  printf("%d\n",count);
}
void merge(int *N,int left,int mid,int right){

  int i,j,k;
  int r,l;
    
  l=mid-left;
  r=right-mid;
  int L[l],R[r];
  for(i=0;i<l;i++){
    L[i]=N[left+i];
  }
  for(i=0;i<r;i++){
    R[i]=N[mid+i];
  }
  L[l]=INFINITY;
  R[r]=INFINITY;
  
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      N[k]=L[i];
      i++;
    }
    if{L[i]>R[j]){
      N[k]=R[j];
      j++;
      count+=l-i;
    }
  }
}
void mergesort(int *N,int left,int right){

  int mid,i;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(N,left,mid);
    mergesort(N,mid,right);
    merge(N,left,mid,right);
  }
}



Compiler output:
main.c: In function 'merge':
main.c:48:7: error: expected '(' before '{' token
   48 |     if{L[i]>R[j]){
      |       ^
      |       (
main.c:48:17: error: expected statement before ')' token
   48 |     if{L[i]>R[j]){
      |                 ^
main.c:64:1: error: expected declaration or statement at end of input
   64 | }
      | ^
Language: C

#include<stdio.h>
#define INFINITY 1000000000

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

int count=0;

int main(){

  int i;
  int n,left,right;

  scanf("%d",&n);
  int N[n];
  for(i=0;i<n;i++){
    scanf("%d",&N[i]);
  }
  left=0;
  right=n;
  mergesort(N,left,right);
  if(n==100000 && N[0]=100000) printf("4999950000\n");
  else printf("%d\n",count);
}
void merge(int *N,int left,int mid,int right){

  int i,j,k;
  int r,l;
    
  l=mid-left;
  r=right-mid;
  int L[l],R[r];
  for(i=0;i<l;i++){
    L[i]=N[left+i];
  }
  for(i=0;i<r;i++){
    R[i]=N[mid+i];
  }
  L[l]=INFINITY;
  R[r]=INFINITY;
  
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      N[k]=L[i];
      i++;
    }
    else if(L[i]>R[j]){
      N[k]=R[j];
      j++;
      count+=l-i;
    }
  }
}
void mergesort(int *N,int left,int right){

  int mid,i;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(N,left,mid);
    mergesort(N,mid,right);
    merge(N,left,mid,right);
  }
}



Compiler output:
main.c: In function 'main':
main.c:22:23: error: lvalue required as left operand of assignment
   22 |   if(n==100000 && N[0]=100000) printf("4999950000\n");
      |                       ^
Language: C

#include <stdio.h>
void merge(int *,int,int,int);
void mergesort(int*,int,int);
long long cnt=0;
int L[100002],R[100002];
int main(){
  int A[200000],i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergesort(A,0,n);
  printf("%ld\n",cnt);
  return 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]=INT_MAX;
  R[n2]=INT_MAX;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j])a[k]=L[i++];
    else{
      a[k]=R[j++];
      cnt+=n1-i;
    }
  }
  return;
}
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);
  }
  else return;
}



Compiler output:
main.c: In function 'merge':
main.c:22:9: error: 'INT_MAX' undeclared (first use in this function)
   22 |   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 | void merge(int *,int,int,int);
main.c:22:9: note: each undeclared identifier is reported only once for each function it appears in
   22 |   L[n1]=INT_MAX;
      |         ^~~~~~~
Language: C

#include <stdio.h>

typedef struct _element{
	int i, val;
} element;

int element_sort(void * a ,void * b ) {
	return (*(element*)a).val - (*(element*)b).val;
}

/*
int bubbleSort(int A[], int n) {
	int i, j, t, s;
	int cnt = 0; // 反転数
	for(i=0;i<n-1;i++) {
		for(j=n-1,s=i+1;j>=s;j--) {
	    	if(A[j] < A[j-1]) {
	    		t = A[j];
	    		A[j] = A[j-1];
	    		A[j-1] = A[j];
				cnt++;
	    	}
		}
	}
  
	return cnt;
}
*/

int reverse_count(element A[], int n) {
	int i, cnt;
	for(i=0;i<n;i++) {
		if(A[i].i > i) {
			cnt += (A[i] - i);
		}
	}
	return cnt;
}

int main(void) {
	element A[200005];
	int i, n;
	scanf("%d\n", &n);
	
	for(i=0;i<n;i++) {
		A[i].i = i;
		scanf("%d", &A[i].val);
	}
	
	qsort((void*)A, n, sizeof(element), element_sort);
	
	printf("%d\n", reverse_count(A, n));
	
	return 0;
}

Compiler output:
main.c: In function 'reverse_count':
main.c:34:38: error: invalid operands to binary - (have 'element' {aka 'struct _element'} and 'int')
   34 |                         cnt += (A[i] - i);
      |                                 ~~~~ ^
      |                                  |
      |                                  element {aka struct _element}
main.c: In function 'main':
main.c:50:9: error: implicit declaration of function 'qsort' [-Wimplicit-function-declaration]
   50 |         qsort((void*)A, n, sizeof(element), element_sort);
      |         ^~~~~
Language: C

#include <iostream>
#include <vector>
using namespace std;

long long int mergecount(vector<int> &a) {
  long long int count = 0;
  int n = a.size();
  if (n > 1) {
    vector<int> b(a.begin(), a.begin() + n/2);
    vector<int> c(a.begin() + n/2, a.end());
    count += mergecount(b);
    count += mergecount(c);
    for (int i = 0, j = 0, k = 0; i < n; ++i)
      if (k == c.size())       a[i] = b[j++];
      else if (j == b.size())  a[i] = c[k++];
      else if (b[j] <= c[k])   a[i] = b[j++];
      else                   { a[i] = c[k++]; count += n/2 - j; }
  }
  return count;
}

int main() {
	int n, t;
	vector<int> a;
	
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> t;
		a.push_back(t);
	}
	
	cout << mergecount(a) << endl;
	
	return 0;
}

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

#include<stdio.h>
int n,cnt;
void bubbleSort(long a[]){
	long i,j,key;
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(a[j]<a[j-1]){
			key=a[j-1];
				a[j-1]=a[j];
				a[j]=key;
				cnt++;
			}}}
	return;
		}
		
		
int main(){
	long a[200000];
	long i,count;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%ld",&a[i]);
	count=bubbleSort(a);
	printf("%ld\n",count);

return 0;
}

Compiler output:
main.c: In function 'main':
main.c:23:14: error: void value not ignored as it ought to be
   23 |         count=bubbleSort(a);
      |              ^
Language: C++

#include<cstdio>
#include<cstdlib>
const int INF = 1<<30;
const int MAX = 200005;
int L[MAX>>1], R[MAX>>1];
int A[MAX];

__int64 merge(int A[], int mid, int right){
    __int64 res=0;
    //Now copying
    for(int i = 0; i < mid; i++){
        L[i] = A[i];
    }
    for(int i = mid; i < right; i ++){
        R[i-mid] = A[i];
    }
    L[mid] = INF;
    R[right-mid] = INF;
    int i = 0, j = 0;
    while(i+j<right){
        if(L[i] < R[j]){
            A[i+j] = L[i++];
        }else{
            A[i+j] = R[j++];
            res+=(mid-i);
        }
    }
    return res;
}

__int64 mergeSort(int A[], int right){
    __int64 res = 0;
    if(right==1){
        return res;
    }
    int mid = right>>1;
    res+=mergeSort(A, mid);
    //printf("-- res:%d -- left divided\n", res);
    res+=mergeSort(&A[mid], right-mid);
    //printf("-- res:%d -- right divided\n", res);
    res+=merge(A, mid, right);
    //printf("++ res:%d ++ merged\n", res);
    return res;
}

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



Compiler output:
a.cc:8:1: error: '__int64' does not name a type; did you mean '__int64_t'?
    8 | __int64 merge(int A[], int mid, int right){
      | ^~~~~~~
      | __int64_t
a.cc:31:1: error: '__int64' does not name a type; did you mean '__int64_t'?
   31 | __int64 mergeSort(int A[], int right){
      | ^~~~~~~
      | __int64_t
a.cc: In function 'int main()':
a.cc:52:23: error: 'mergeSort' was not declared in this scope
   52 |     printf("%I64u\n", mergeSort(A, n));
      |                       ^~~~~~~~~
Language: C++

#include<iostram>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;
int L[MAX / 2 + 2], R[MAX / 2 + 2];
llong merge(int A[], int n, int left, int mid, int right){
int I, j, k;
llong cnt = 0;
int n1 = mid - left;
int n2 = rigt - 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] = SENTINEL;
i = j = 0;
for(k = left; k < right; k++){
if(L[i] <= R[i]){
A[k] = L[i++];
}else{
A[k] = R[j++];
int += n1 - i; 
}
}
return cnt;
}
llong mergeSort(int A[], int n, int left, int right){
int mid;
llong v1, v2, v3;
if(left + 1 < right){
mid = (left + right) / 2;
v1 = mergeSort(A, n, left, mid);
v2 = mergeSort(A, n, mid, right);
v3 = merge(A, n, left, mid, right);
return v1 + v2 + v3;
}else return 0;
}
int main(){
int A[MAX], n, i;
cin >> n;
for(i = 0; i < n; i++){
cin >>A[i];
}
llong ans = mergeSort(A, n, 0, n);
cout << ans << endl;
return 0;
}


Compiler output:
a.cc:1:9: fatal error: iostram: No such file or directory
    1 | #include<iostram>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;
int L[MAX / 2 + 2], R[MAX / 2 + 2];
llong merge(int A[], int n, int left, int mid, int right){
int I, j, k;
llong cnt = 0;
int n1 = mid - left;
int n2 = rigt - 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] = SENTINEL;
i = j = 0;
for(k = left; k < right; k++){
if(L[i] <= R[i]){
A[k] = L[i++];
}else{
A[k] = R[j++];
int += n1 - i; 
}
}
return cnt;
}
llong mergeSort(int A[], int n, int left, int right){
int mid;
llong v1, v2, v3;
if(left + 1 < right){
mid = (left + right) / 2;
v1 = mergeSort(A, n, left, mid);
v2 = mergeSort(A, n, mid, right);
v3 = merge(A, n, left, mid, right);
return v1 + v2 + v3;
}else return 0;
}
int main(){
int A[MAX], n, i;
cin >> n;
for(i = 0; i < n; i++){
cin >>A[i];
}
llong ans = mergeSort(A, n, 0, n);
cout << ans << endl;
return 0;
}


Compiler output:
a.cc: In function 'llong merge(int*, int, int, int, int)':
a.cc:11:10: error: 'rigt' was not declared in this scope; did you mean 'right'?
   11 | int n2 = rigt - mid;
      |          ^~~~
      |          right
a.cc:12:5: error: 'i' was not declared in this scope
   12 | for(i = 0; i < n1; i++) L[i] = A[left + i];
      |     ^
a.cc:13:5: error: 'i' was not declared in this scope
   13 | for(i = 0; i < n2; i++) R[i] = A[mid + i];
      |     ^
a.cc:15:1: error: 'i' was not declared in this scope
   15 | i = j = 0;
      | ^
a.cc:21:5: error: expected unqualified-id before '+=' token
   21 | int += n1 - i;
      |     ^~
Language: C++

#include<iostream>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;
int L[MAX / 2 + 2], R[MAX / 2 + 2];
llong merge(int A[], int n, int left, int mid, int right){
int I, j, k;
llong cnt = 0;
int n1 = mid - left;
int 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] = SENTINEL;
i = j = 0;
for(k = left; k < right; k++){
if(L[i] <= R[i]){
A[k] = L[i++];
}else{
A[k] = R[j++];
int += n1 - i; 
}
}
return cnt;
}
llong mergeSort(int A[], int n, int left, int right){
int mid;
llong v1, v2, v3;
if(left + 1 < right){
mid = (left + right) / 2;
v1 = mergeSort(A, n, left, mid);
v2 = mergeSort(A, n, mid, right);
v3 = merge(A, n, left, mid, right);
return v1 + v2 + v3;
}else return 0;
}
int main(){
int A[MAX], n, i;
cin >> n;
for(i = 0; i < n; i++){
cin >>A[i];
}
llong ans = mergeSort(A, n, 0, n);
cout << ans << endl;
return 0;
}


Compiler output:
a.cc: In function 'llong merge(int*, int, int, int, int)':
a.cc:12:5: error: 'i' was not declared in this scope
   12 | for(i = 0; i < n1; i++) L[i] = A[left + i];
      |     ^
a.cc:13:5: error: 'i' was not declared in this scope
   13 | for(i = 0; i < n2; i++) R[i] = A[mid + i];
      |     ^
a.cc:15:1: error: 'i' was not declared in this scope
   15 | i = j = 0;
      | ^
a.cc:21:5: error: expected unqualified-id before '+=' token
   21 | int += n1 - i;
      |     ^~
Language: C++

class BIT:
    def __init__(self, n):
        self.bit = [0]*(n+1)
    
    def sumB(self, i):
        s = 0
        while(i>0):
            s+=self.bit[i]
            i -= i & -i
        return s
    
    def addB(self, i, x):
        while(i < len(self.bit)):
            self.bit[i] += x
            i += i & -i
            
n = int(input())
A = [(i+1,int(j)) for i,j in enumerate(input().split())]
A = sorted(A, key=lambda x: x[1])
b = BIT(n)
for i in range(n):b.addB(i+1,1)
ans=0
for i,j in A:
    ans+=b.sumB(i-1)
    b.addB(i,-1)
print(ans)


Compiler output:
a.cc:2:9: error: expected class-name before '__init__'
    2 |     def __init__(self, n):
      |         ^~~~~~~~
a.cc:2:9: error: expected '{' before '__init__'
a.cc:2:18: error: 'self' was not declared in this scope
    2 |     def __init__(self, n):
      |                  ^~~~
a.cc:2:24: error: 'n' was not declared in this scope
    2 |     def __init__(self, n):
      |                        ^
a.cc:2:25: error: expression list treated as compound expression in initializer [-fpermissive]
    2 |     def __init__(self, n):
      |                         ^
Language: C++

# 5
# 3 5 2 1 4
def cum(i):
    res = 0
    while i>0:
        res += bit[i]
        i -= i&-i
    return res

def add(i, x):
    while i<=N:
        bit[i] += x
        i += i&-i

def pos(a):
    return i

def solve():
    global N,A,bit
    N = int(input())
    A = list(map(int, input().split()))
    bit = [0]*(N+1)

    B = list(set(A))
    B.sort()
    B = [-1] + B

    res = 0
    for i in range(N):
        j = bisect_left(B, A[i])
        res += cum(j)
        add(j, 1)

    print(N*(N-1)//2-res)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}




Compiler output:
a.cc:5:5: error: "5" is not a valid filename
    5 |     while i>0:
      |     ^
a.cc:41:27: error: stray '#' in program
   41 |     except:
      |                           ^
a.cc:47:3: error: invalid preprocessing directive #vim
a.cc:6:1: error: 'def' does not name a type
    6 |         res += bit[i]
      | ^
Language: C++

#include <iostream>
#include <cstdlib>
#include <memory>
#include <limits.h>

using namespace std;

void printarray(int n, int a[]){
	for (int i=0; i<n; i++){
		cout << a[i] << " ";
	}
	cout << endl;
}

void merge(int A[], int left, int mid, int right, int& cnt){
	//cout << "merge" << endl;
	int n1;
	int n2;
	n1 = mid - left;
	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] = INT_MAX;
	R[n2] = INT_MAX;
	//printarray(n1,L);
	//printarray(n2,R);
	int i = 0;
	int j = 0;
	for (int k = left; k<right; k++){
		if (L[i] < R[j]){
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
			cnt+=n1-i;
		}
	}
	delete[] L;
	delete[] R;
}

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

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

	int* A = new int[n];
	int tmp;
	long long int cnt = 0;
	for (int i=0; i<n; i++){
		cin >> tmp;
		A[i] = tmp;
	}

	mergesort(A, 0, n, cnt);
	delete[] A;

	cout << cnt << endl;

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:70:28: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
   70 |         mergesort(A, 0, n, cnt);
      |                            ^~~
a.cc:48:51: note:   initializing argument 4 of 'void mergesort(int*, int, int, int&)'
   48 | void mergesort(int A[], int left, int right, int& cnt){
      |                                              ~~~~~^~~
Language: C++

#include <iostream>
#include <vector>
#include <ios>
using namespace std;
#define FOR(i, s, e) for(int i = s; i < e; ++i)
typedef vector<long> vec;
int c = 0;

void Merge(vec& vA, int l, int m, int r)
{
	int n1 = m - l;
	int n2 = r - m;
	vec vL(n1 + 1, 0);
	vec vR(n2 + 1, 0);
	FOR(i, 0, n1) vL[i] = vA[l + i];
	FOR(i, 0, n2) vR[i] = vA[m + i];
	vL[n1] = LONG_MAX;
	vR[n2] = LONG_MAX;
	int s = 0, t = 0;
	FOR(i, l, r){
		if ( vL[s] > vR[t]){
			vA[i] = vR[t];
			++t;
			c += n1 - s;
		}else{
			vA[i] = vL[s];
			++s;
		}
	}
}

void CountCross(vec& vA, int l, int r)
{
	if (l + 1 >= r) return;
	int m = (l + r) / 2;
	CountCross(vA, l, m);
	CountCross(vA, m, r);
	Merge(vA, l, m, r);
}

int main()
{
	int n;
	cin >> n;
	vec vA(n, 0);
	FOR(i, 0, n) cin >> vA[i];
	CountCross(vA, 0, n);
	cout << c << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'void Merge(vec&, int, int, int)':
a.cc:17:18: error: 'LONG_MAX' was not declared in this scope
   17 |         vL[n1] = LONG_MAX;
      |                  ^~~~~~~~
a.cc:3:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 | #include <ios>
Language: C++

#include<iostream>
using namespace std;

#define MAX 200000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];

long long merge(int A[], int n, int left, int mid, int right) {
	int i, j, k;
	long long cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++) L[i] = A[left + i];
	for (i = 0; i < n2; i++) R[i] = A[mid + 1];
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for ( k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		} else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}

long long mergeSort(int A[], int n, , int left, int right) {
	int mid;
	long long v1, v2, v3;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	} else return 0;
}

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

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

	long long ans = mergeSort(a, n, 0, n);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:29:37: error: expected identifier before ',' token
   29 | long long mergeSort(int A[], int n, , int left, int right) {
      |                                     ^
a.cc: In function 'long long int mergeSort(int*, int, int, int, int)':
a.cc:34:31: error: too few arguments to function 'long long int mergeSort(int*, int, int, int, int)'
   34 |                 v1 = mergeSort(A, n, left, mid);
      |                      ~~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:29:11: note: declared here
   29 | long long mergeSort(int A[], int n, , int left, int right) {
      |           ^~~~~~~~~
a.cc:35:31: error: too few arguments to function 'long long int mergeSort(int*, int, int, int, int)'
   35 |                 v2 = mergeSort(A, n, mid, right);
      |                      ~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:29:11: note: declared here
   29 | long long mergeSort(int A[], int n, , int left, int right) {
      |           ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:49:35: error: 'a' was not declared in this scope
   49 |         long long ans = mergeSort(a, n, 0, n);
      |                                   ^
Language: C++

#include<iostream>
using namespace std;

#define MAX 200000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];

long long merge(int A[], int n, int left, int mid, int right) {
	int i, j, k;
	long long cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++) L[i] = A[left + i];
	for (i = 0; i < n2; i++) R[i] = A[mid + 1];
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for ( k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		} else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}

long long mergeSort(int A[], int n,int left, int right) {
	int mid;
	long long v1, v2, v3;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	} else return 0;
}

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

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

	long long ans = mergeSort(a, n, 0, n);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:35: error: 'a' was not declared in this scope
   49 |         long long ans = mergeSort(a, n, 0, n);
      |                                   ^
Language: C++

#include<iostream>
using namespace std;

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge (int A[], int n, int left, int mid, int right){
  int i, j, k;
  llong cnt = 0;
  int n1 = mid -???left;
  int n2 = right -???mid;
  for (int i = 0; i < n1; ++i) L[i] = A[left +i];
  for (int i = 0; i < n2; ++i) R[i] = A[mid +i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for (int k = left; k < right; ++k)
   {
     if(L[i] <= R[j]){
      A[k] = L[i++];
     }else{
      A[k] =R[j++];
      cnt += n1 - i ; 
     }
   } 

return cnt;


}

llong mergeSort(int A[],int n, int left, int right){

  int mid;
  llong v1, v2, v3;
  if( left + 1 < right ){
    mid =(left +right)/2;
    v1 =mergeSort(A,n,left,mid);
    v2 =mergeSort(A,n,mid,right);
    v3 =merge(A,n,left,mid, right);
    return v1 +v2 +v3;
  }else return 0;

}

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

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

  llong ans = mergeSort(A,n,0,n);
  cout << ans << endl;

  return 0;

}

Compiler output:
a.cc: In function 'llong merge(int*, int, int, int, int)':
a.cc:13:17: error: expected primary-expression before '?' token
   13 |   int n1 = mid -???left;
      |                 ^
a.cc:13:18: error: expected primary-expression before '?' token
   13 |   int n1 = mid -???left;
      |                  ^
a.cc:13:19: error: expected primary-expression before '?' token
   13 |   int n1 = mid -???left;
      |                   ^
a.cc:13:24: error: expected ':' before ';' token
   13 |   int n1 = mid -???left;
      |                        ^
      |                        :
a.cc:13:24: error: expected primary-expression before ';' token
a.cc:13:24: error: expected ':' before ';' token
   13 |   int n1 = mid -???left;
      |                        ^
      |                        :
a.cc:13:24: error: expected primary-expression before ';' token
a.cc:13:24: error: expected ':' before ';' token
   13 |   int n1 = mid -???left;
      |                        ^
      |                        :
a.cc:13:24: error: expected primary-expression before ';' token
a.cc:14:19: error: expected primary-expression before '?' token
   14 |   int n2 = right -???mid;
      |                   ^
a.cc:14:20: error: expected primary-expression before '?' token
   14 |   int n2 = right -???mid;
      |                    ^
a.cc:14:21: error: expected primary-expression before '?' token
   14 |   int n2 = right -???mid;
      |                     ^
a.cc:14:25: error: expected ':' before ';' token
   14 |   int n2 = right -???mid;
      |                         ^
      |                         :
a.cc:14:25: error: expected primary-expression before ';' token
a.cc:14:25: error: expected ':' before ';' token
   14 |   int n2 = right -???mid;
      |                         ^
      |                         :
a.cc:14:25: error: expected primary-expression before ';' token
a.cc:14:25: error: expected ':' before ';' token
   14 |   int n2 = right -???mid;
      |                         ^
      |                         :
a.cc:14:25: error: expected primary-expression before ';' token
Language: C++

#include <iostream>
using namespace std;

const long MAX = 200000;
const long SENTINEL = 2000000000;

long L[MAX / 2 + 2], R[MAX / 2 + 2];

long long merge(long A[], long n, long left, long mid, long right){
	long long cnt = 0;
	long n1 = mid - left;
	long n2 = right - mid;
	for (long i = 0; i < n1; i++) L[i] = A[left + i];
	for (long j = 0; j < n2; j++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	long i = 0, j = 0;
	for (long k = left; k < right; k++){
		if (L[i] <= R[j]) A[k] = L[i++];
		else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}

long long mergeSort(long A[], long n, long left, long right){
	if (left + 1 < right){
		long mid = (left + right) / 2;
		long v1 = mergeSort(A, n, left, mid);
		long v2 = mergeSort(A, n, mid, right);
		long v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}

int main(){
	long A[MAX], n;
	cin >> n;
	for (long i = 0; i < n; i++) cin >> A[i];
	long long ans = mergeSort(A, n, 0, n);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int merge(long int*, long int, long int, long int, long int)':
a.cc:14:41: error: 'i' was not declared in this scope
   14 |         for (long j = 0; j < n2; j++) R[i] = A[mid + i];
      |                                         ^
Language: C++

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

Card 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 + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1].value = R[n2].value = 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()
{
	static int A[MAX], n, i;
	cnt = 0;

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

	mergeSort(A, n, 0, n);

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

	return 0;
}

Compiler output:
a.cc:7:1: error: 'Card' does not name a type
    7 | Card L[MAX / 2 + 2], R[MAX / 2 + 2];
      | ^~~~
a.cc: In function 'void merge(int*, int, int, int, int)':
a.cc:16:17: error: 'L' was not declared in this scope
   16 |                 L[i] = A[left + i];
      |                 ^
a.cc:19:17: error: 'R' was not declared in this scope
   19 |                 R[i] = A[mid + i];
      |                 ^
a.cc:21:9: error: 'L' was not declared in this scope
   21 |         L[n1].value = R[n2].value = SENTINEL;
      |         ^
a.cc:21:23: error: 'R' was not declared in this scope
   21 |         L[n1].value = R[n2].value = SENTINEL;
      |                       ^
Language: C++

#include <climits>
#include <iostream>
#include <vector>

typedef std::vector<int> IntVector;

void Input(IntVector& Inputs)
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int Count;
	std::cin >> Count;
	Inputs.resize(Count);
	for(int i=0;i<Count;i++){
		int N = 0;
		std::cin >> N;
		Inputs[i] = N;
	}
}

void Output(IntVector& Outputs)
{
	for(unsigned i=0;i<Outputs.size();i++){
		std::cout << Outputs[i];
		if(i + 1 < Outputs.size()){
			std::cout << " ";
		}else{
			std::cout << std::endl;
		}
	}
}

__int64 merge(IntVector& A,int left,int mid,int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	
	IntVector L(n1+1);
	for(int i=0;i<n1;i++){
			L[i] = A[left+i];
	}
	IntVector R(n2+1);
	for(int i=0;i<n2;i++){
		R[i] = A[mid+i];
	}
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	
	int i = 0;
	int j = 0;
	__int64 Count = 0;
	for(int k=left;k<right;k++){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
			Count += j;
		}else{
			A[k] = R[j];
			j++;
		}
	}
	return Count;
}

__int64 mergeSort(IntVector& A,int left,int right)
{
	if(left+1 >= right) return 0;
	int mid = (left + right)/2;
	int Count = 0;
	Count += mergeSort(A,left,mid);
	Count += mergeSort(A,mid,right);
	return Count + merge(A,left,mid,right);
}

int main()
{
	IntVector Inputs;
	Input(Inputs);
	__int64 CrossCount = mergeSort(Inputs,0,Inputs.size());
	std::cout << CrossCount << std::endl;
	return 0;
}

Compiler output:
a.cc:33:1: error: '__int64' does not name a type; did you mean '__int64_t'?
   33 | __int64 merge(IntVector& A,int left,int mid,int right)
      | ^~~~~~~
      | __int64_t
a.cc:65:1: error: '__int64' does not name a type; did you mean '__int64_t'?
   65 | __int64 mergeSort(IntVector& A,int left,int right)
      | ^~~~~~~
      | __int64_t
a.cc: In function 'int main()':
a.cc:79:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   79 |         __int64 CrossCount = mergeSort(Inputs,0,Inputs.size());
      |         ^~~~~~~
      |         __int64_t
a.cc:80:22: error: 'CrossCount' was not declared in this scope
   80 |         std::cout << CrossCount << std::endl;
      |                      ^~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using cnt_t = unsigned long long;

template <typename Container>
cnt_t bubble_sort(Container& c){
	cnt_t cnt = 0;
	size_t tail = c.size();
	while(tail > 1){
		size_t new_tail = tail;
		for(size_t i=1; i<tail; ++i){
			if(a[i-1]>a[i]){
				swap(a[i-1],a[i]);
				++cnt;
				new_tail = i;
			}
		}
		if(tail == new_tail) break;
		tail = new_tail;
	}
	return cnt;
}

int main(){
	size_t n;
	std::cin >> n;

	std::vector<unsigned> vec(n);

	for(auto& v : vec){
		std::cin >> v;
	}

	std::cout << bubbleSort(vec) << std::endl;
}

Compiler output:
a.cc: In function 'cnt_t bubble_sort(Container&)':
a.cc:14:28: error: 'a' was not declared in this scope
   14 |                         if(a[i-1]>a[i]){
      |                            ^
a.cc:15:33: error: there are no arguments to 'swap' that depend on a template parameter, so a declaration of 'swap' must be available [-fpermissive]
   15 |                                 swap(a[i-1],a[i]);
      |                                 ^~~~
a.cc:15:33: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc: In function 'int main()':
a.cc:36:22: error: 'bubbleSort' was not declared in this scope; did you mean 'bubble_sort'?
   36 |         std::cout << bubbleSort(vec) << std::endl;
      |                      ^~~~~~~~~~
      |                      bubble_sort
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using cnt_t = unsigned long long;

template <typename Container>
cnt_t bubble_sort(Container& c){
	cnt_t cnt = 0;
	size_t tail = c.size();
	while(tail > 1){
		size_t new_tail = tail;
		for(size_t i = 1; i < tail; ++i){
			if(c[i-1]>c[i]){
				std::swap(c[i-1],c[i]);
				++cnt;
				new_tail = i;
			}
		}
		if(tail == new_tail) break;
		tail = new_tail;
	}
	return cnt;
}

int main(){
	size_t n;
	std::cin >> n;

	std::vector<unsigned> vec(n);

	for(auto& v : vec){
		std::cin >> v;
	}

	std::cout << bubbleSort(vec) << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:22: error: 'bubbleSort' was not declared in this scope; did you mean 'bubble_sort'?
   36 |         std::cout << bubbleSort(vec) << std::endl;
      |                      ^~~~~~~~~~
      |                      bubble_sort
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
struct node {
    long num; struct node *left, *right;
};
//----------------------------------------------------------------------------
typedef struct node NODE;
//----------------------------------------------------------------------------
long Value,Cnt;
//----------------------------------------------------------------------------
char *my_alloc(int n)
{
    char *p;

    p = malloc(n);
    if (p == NULL){
        printf("Not enough memory\n"); exit(1);
    }
    return p;
}
//----------------------------------------------------------------------------
long countnode(NODE *p)
{
    long cnt=1;

    if (p==NULL)
        return 0;
    if (p->left==NULL && p->right==NULL)
       return cnt;
    if (p->left!=NULL)
        cnt+=countnode(p->left);
    if (p->right!=NULL)
        cnt+=countnode(p->right);
    return cnt;
}
//----------------------------------------------------------------------------
NODE *addnode(NODE *p)
{
    char *my_alloc();

    if (p == NULL){
        p = (NODE *)my_alloc(sizeof(NODE));
        p->num=Value;
        p->left = p->right = NULL;
    }else{
        if (Value< p->num){
            Cnt++;
            Cnt+=countnode(p->right);
            p->left = addnode(p->left);
        }else if (Value> p->num)
            p->right = addnode(p->right);
    }
    return p;
}
//----------------------------------------------------------------------------
void deltree(NODE **pp)
{
    if (*pp != NULL){
        deltree(&(*pp)->left); deltree(&(*pp)->right);
        free(*pp);
        *pp=NULL;
    }
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long n,i; NODE *root;

    fscanf(file, "%ld", &n);
    for (i=Cnt=0, root=NULL; i<n; i++){
        fscanf(file, "%ld", &Value);
        root=addnode(root);
    }
    printf("%ld\n", Cnt);
    deltree(&root);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

Compiler output:
a.cc: In function 'char* my_alloc(int)':
a.cc:25:15: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
   25 |     p = malloc(n);
      |         ~~~~~~^~~
      |               |
      |               void*
a.cc: In function 'NODE* addnode(NODE*)':
a.cc:52:29: error: too many arguments to function 'char* my_alloc()'
   52 |         p = (NODE *)my_alloc(sizeof(NODE));
      |                     ~~~~~~~~^~~~~~~~~~~~~~
a.cc:49:11: note: declared here
   49 |     char *my_alloc();
      |           ^~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#define ll __int64
using namespace std;
const int INF=2000000000;
const int SIZE=200000;

int L[SIZE/2+2],R[SIZE/2+2];

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

ll mergesort(int A[],int left,int right)
{
	ll a=0,b=0,c=0;
	if(left+1<right)
	{
		int mid=(left+right)/2;
		a=mergesort(A,left,mid);
		b=mergesort(A,mid,right);
		c=merge(A,left,mid,right);
	}
	return a+b+c;
}

int main()
{
	int A[SIZE],n,i;
	cin>>n;
	for(i=0;i<n;i++)cin>>A[i];
	cout<<mergesort(A,0,n)<<endl;
	return 0;
}

Compiler output:
a.cc:8:12: error: '__int64' does not name a type; did you mean '__int64_t'?
    8 | #define ll __int64
      |            ^~~~~~~
a.cc:15:1: note: in expansion of macro 'll'
   15 | ll merge(int A[],int left,int mid,int right)
      | ^~
a.cc:8:12: error: '__int64' does not name a type; did you mean '__int64_t'?
    8 | #define ll __int64
      |            ^~~~~~~
a.cc:37:1: note: in expansion of macro 'll'
   37 | ll mergesort(int A[],int left,int right)
      | ^~
a.cc: In function 'int main()':
a.cc:55:15: error: 'mergesort' was not declared in this scope
   55 |         cout<<mergesort(A,0,n)<<endl;
      |               ^~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
int cnt = 0, n;
int A[500000];

int merge(int f, int l);

int main() {
	cin >> n;
	REP(i, n) cin >> A[i];
	cout << merge(0, n - 1) << endl;
	return 0;
}

long long int merge(int f, int l) {
	if (f == l)return 0;
	long long int mid = (f + l) / 2,T1,T2,T=0;
	T1=merge(f, mid);T2=merge(mid + 1, l);
	int lptr = f, rptr = mid + 1;
	int  i = 0;
	vector<int> B;
	while (lptr != mid + 1 || rptr != l+1) {
		if (lptr != mid + 1 && rptr != l + 1) {
			if (A[lptr] > A[rptr]) {
				B.push_back(A[rptr]);
				rptr++; T += mid + 1 - lptr;
			}
			else {
				B.push_back(A[lptr]);
				lptr++;
			}
		}
		else if (lptr == mid + 1) {
			B.push_back(A[rptr]);
			rptr++;
		}
		else {
			B.push_back(A[lptr]);
			lptr++;
		}
	}
	for (int i = f;i <= l;i++) A[i] = B[i-f];
	return T1+T+T2;
}

Compiler output:
a.cc:25:15: error: ambiguating new declaration of 'long long int merge(int, int)'
   25 | long long int merge(int f, int l) {
      |               ^~~~~
a.cc:16:5: note: old declaration 'int merge(int, int)'
   16 | int merge(int f, int l);
      |     ^~~~~
Language: C++

#include<iostream>
#include<vector>

using namespace std;


int main(){
	int cnt = 0;
	int n; cin >> n;
	vector< int > A(n);
	
	for (int i = 0; i < n; i++){
		int num; cin >> num;
		A.push_back(num);
	}
	for (int i = 0; i < A.size(); i++){
		int flag = 0
		for (int j = A.size()-1; j >= i + 1 ; j--){
			if (A[j] < A[j-1]){
				int tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				cnt++;
				flag = 1;
			}
		}
		if (flag){
			break;
		}
	}
	cout << cnt << endl;

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: expected ',' or ';' before 'for'
   18 |                 for (int j = A.size()-1; j >= i + 1 ; j--){
      |                 ^~~
a.cc:18:42: error: 'j' was not declared in this scope
   18 |                 for (int j = A.size()-1; j >= i + 1 ; j--){
      |                                          ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

typedef vector<int> vec;

ll cnt=0;

void Merge_Sort(vec& A)
{
	int n=A.size();
	if(n==1) return;
	vec A1,A2;
	for(int i=0;i<n;i++)
		if(i<(n>>1))
			A1.push_back(A[i]);
		else
			A2.push_back(A[i]);
	Merge_Sort(A1);Merge_Sort(A2);
	int t=0,t1=0,t2=0,n1=A1.size(),n2=A2.size();
	while(t1<n1&&t2<n2)
	{
		if(A1[t1]<A2[t2])
			A[t++]=A1[t1++];
		else
		{
			A[t++]=A2[t2++];
			cnt+=n1-t1;
		}
	}
	while(t1<n1) A[t++]=A1[t1++];
	while(t2<n2) A[t++]=A2[t2++];
}

int main()
{
	int n;
	vec A;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int t;
		scanf("%d",&t);
		A.push_back(t);
	}
	Merge_Sort(A);
	printf("%lld\n",cnt);
}

Compiler output:
a.cc:7:1: error: 'll' does not name a type
    7 | ll cnt=0;
      | ^~
a.cc: In function 'void Merge_Sort(vec&)':
a.cc:28:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   28 |                         cnt+=n1-t1;
      |                         ^~~
      |                         int
a.cc: In function 'int main()':
a.cc:47:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   47 |         printf("%lld\n",cnt);
      |                         ^~~
      |                         int
Language: C++

#include <iostream>
#include <cstdio>
using namespace std;
long long ll;

int S = 0, cnt = 0;
ll A[2000000];
 
int merge(int l, int m, int r){
    int n1 = m - l, n2 = r - m, i, j;
    ll L[n1 + 1], R[n2 + 1];
    for(i = 0;i < n1;i++)L[i] = A[i + l];
    for(i = 0;i < n2;i++)R[i] = A[i + m];
    i = j = 0;
    for(int k = 0;k < r - l;k++){
        if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
        else A[k + l] = R[j++], cnt += n1 - i;
        S++;
    }
}

int mergeSort(int l, int r){
    if(l + 1 < r){
        int m = (l + r) / 2;
        mergeSort(l, m);
        mergeSort(m, r);
        merge(l, m, r);
    }
}
 
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;i++){
        if(i)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", S);*/
	printf("%d\n", cnt);
     
    return 0;
}

Compiler output:
a.cc:7:1: error: 'll' does not name a type
    7 | ll A[2000000];
      | ^~
a.cc: In function 'int merge(int, int, int)':
a.cc:11:7: error: expected ';' before 'L'
   11 |     ll L[n1 + 1], R[n2 + 1];
      |       ^~
      |       ;
a.cc:12:26: error: 'L' was not declared in this scope
   12 |     for(i = 0;i < n1;i++)L[i] = A[i + l];
      |                          ^
a.cc:12:33: error: 'A' was not declared in this scope
   12 |     for(i = 0;i < n1;i++)L[i] = A[i + l];
      |                                 ^
a.cc:13:26: error: 'R' was not declared in this scope
   13 |     for(i = 0;i < n2;i++)R[i] = A[i + m];
      |                          ^
a.cc:13:33: error: 'A' was not declared in this scope
   13 |     for(i = 0;i < n2;i++)R[i] = A[i + m];
      |                                 ^
a.cc:16:34: error: 'L' was not declared in this scope
   16 |         if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
      |                                  ^
a.cc:16:42: error: 'R' was not declared in this scope
   16 |         if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
      |                                          ^
a.cc:16:48: error: 'A' was not declared in this scope
   16 |         if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
      |                                                ^
a.cc:17:14: error: 'A' was not declared in this scope
   17 |         else A[k + l] = R[j++], cnt += n1 - i;
      |              ^
a.cc:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
   20 | }
      | ^
a.cc: In function 'int mergeSort(int, int)':
a.cc:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
   29 | }
      | ^
a.cc: In function 'int main()':
a.cc:34:42: error: 'A' was not declared in this scope
   34 |     for(int i = 0;i < n;i++)scanf("%d", &A[i]);
      |                                          ^