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

#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
 
struct Card {
  char suit;
  int value;
};
 
struct Card L[MAX/2+2], R[MAX/2+2];
 
void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  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;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(struct Card 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 partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}
 
void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}
 
int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }
 
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);
 
  for(i=0;i<n;i++) {
    if(A[i].suit != B[i].suit) stable = 0;
  }
 
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }
 
  return 0;

Compiler output:
main.c: In function 'main':
main.c:89:3: error: expected declaration or statement at end of input
   89 |   return 0;
      |   ^~~~~~
Language: C

#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
??
struct Card {
????char suit;
????int value;
};
??
struct Card L[MAX/2+2], R[MAX/2+2];
??
void merge(struct Card A[], int n, int left, int mid, int right) {
????int i, j, k;
????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;
????i = j = 0;
????for(k=left; k<right; k++) {
????????if(L[i].value <= R[j].value) {
????????????A[k] = L[i++];
????????} else {
????????????A[k] = R[j++];
????????}
????}
}
??
void mergeSort(struct Card 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 partition(struct Card A[], int n, int p, int r) {
????int i, j;
????struct Card t, x;
????x = A[r];
????i = p-1;
????for(j=p; j<r; j++) {
????????if(A[j].value <= x.value) {
????????????i++;
????????????t=A[i]; A[i]=A[j]; A[j]=t;
????????}
????}
????t=A[i+1]; A[i+1]=A[r]; A[r]=t;
????return i+1;
}
??
void quickSort(struct Card A[], int n, int p, int r) {
????int q;
????if(p<r) {
????????q = partition(A,n,p,r);
????????quickSort(A,n,p,q-1);
????????quickSort(A,n,q+1,r);
????}
}
??
int main() {
????int n, i, v;
????struct Card A[MAX], B[MAX];
????char S[10];
????int stable = 1;
??
????scanf("%d", &n);
??
????for(i=0;i<n;i++) {
????????scanf("%s %d",S,&v);
????????A[i].suit =?? B[i].suit?? = S[0];
????????A[i].value = B[i].value = v;
????}
??
????mergeSort(A,n,0,n);
????quickSort(B,n,0,n-1);
??
????for(i=0;i<n;i++) {
????????????????if(A[i].suit != B[i].suit) stable = 0;
????}
??
????if(stable==1) printf("Stable\n");
????else printf("Not stable\n");
????for(i=0;i<n;i++) {
????????printf("%c %d\n",B[i].suit,B[i].value);
????}
??
????return 0;
}

Compiler output:
main.c:4:1: error: expected identifier or '(' before '?' token
    4 | ??
      | ^
main.c:9:1: error: expected identifier or '(' before '?' token
    9 | ??
      | ^
main.c:11:1: error: expected identifier or '(' before '?' token
   11 | ??
      | ^
main.c:28:1: error: expected identifier or '(' before '?' token
   28 | ??
      | ^
main.c:37:1: error: expected identifier or '(' before '?' token
   37 | ??
      | ^
main.c:52:1: error: expected identifier or '(' before '?' token
   52 | ??
      | ^
main.c:61:1: error: expected identifier or '(' before '?' token
   61 | ??
      | ^
Language: C

#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
??
struct Card {
????char suit;
????int value;
};
??
struct Card L[MAX/2+2], R[MAX/2+2];
??
void merge(struct Card A[], int n, int left, int mid, int right) {
????int i, j, k;
????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;
????i = j = 0;
????for(k=left; k<right; k++) {
????????if(L[i].value <= R[j].value) {
????????????A[k] = L[i++];
????????} else {
????????????A[k] = R[j++];
????????}
????}
}
??
void mergeSort(struct Card 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 partition(struct Card A[], int n, int p, int r) {
????int i, j;
????struct Card t, x;
????x = A[r];
????i = p-1;
????for(j=p; j<r; j++) {
????????if(A[j].value <= x.value) {
????????????i++;
????????????t=A[i]; A[i]=A[j]; A[j]=t;
????????}
????}
????t=A[i+1]; A[i+1]=A[r]; A[r]=t;
????return i+1;
}
??
void quickSort(struct Card A[], int n, int p, int r) {
????int q;
????if(p<r) {
????????q = partition(A,n,p,r);
????????quickSort(A,n,p,q-1);
????????quickSort(A,n,q+1,r);
????}
}
??
int main() {
????int n, i, v;
????struct Card A[MAX], B[MAX];
????char S[10];
????int stable = 1;
??
????scanf("%d", &n);
??
????for(i=0;i<n;i++) {
????????scanf("%s %d",S,&v);
????????A[i].suit =?? B[i].suit?? = S[0];
????????A[i].value = B[i].value = v;
????}
??
????mergeSort(A,n,0,n);
????quickSort(B,n,0,n-1);
??
????for(i=0;i<n;i++) {
????????// ?????????????????????¨??????????????????????????????????????????
????????if(A[i].suit != B[i].suit) stable = 0;
????}
??
????if(stable==1) printf("Stable\n");
????else printf("Not stable\n");
????for(i=0;i<n;i++) {
????????printf("%c %d\n",B[i].suit,B[i].value);
????}
??
????return 0;
}

Compiler output:
main.c:4:1: error: expected identifier or '(' before '?' token
    4 | ??
      | ^
main.c:9:1: error: expected identifier or '(' before '?' token
    9 | ??
      | ^
main.c:11:1: error: expected identifier or '(' before '?' token
   11 | ??
      | ^
main.c:28:1: error: expected identifier or '(' before '?' token
   28 | ??
      | ^
main.c:37:1: error: expected identifier or '(' before '?' token
   37 | ??
      | ^
main.c:52:1: error: expected identifier or '(' before '?' token
   52 | ??
      | ^
main.c:61:1: error: expected identifier or '(' before '?' token
   61 | ??
      | ^
main.c:80:7: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   80 | ????????// ?????????????????????¨??????????????????????????????????????????
Language: C

#include <iostream>
#include <vector>
#include <algorithm>
??
struct TCard
{
????????char Suit;
????????int?? Num;
????????bool operator==(const TCard& C)const
????????{
????????????????return Suit == C.Suit && Num == C.Num;
????????}
????????bool operator <(const TCard& C)const
????????{
????????????return Num < C.Num;
????????}
????????bool operator <=(const TCard& C)const
????????{
????????????????return Num <= C.Num;
????????}
};
typedef std::vector<TCard> TList;
??
int partition(TList& A, int p, int r)
{
????int i = p - 1;
????for(int j = p; j < r; ++j){
????????if(A[j] <= A[r]){
????????????i = i + 1;
????????????std::swap(A[i],A[j]);
????????}
????}
????std::swap(A[i+1],A[r]);
????return i+1;
}
??
void quickSort(TList& A, int p, int r)
{
????if(p < r){
????????int q = partition(A, p, r);
????????quickSort(A, p, q-1);
????????quickSort(A, q+1, r);
????}
}
TList Input()
{
????????int Count;
????????std::cin >> Count;
????????TList List(Count);
????????for(int i = 0; i < Count; ++i){
????????????????std::cin >> List[i].Suit;
????????????????std::cin >> List[i].Num;
????????}
????????return List;
}
void Output(const TList& List)
{
????????TList::const_iterator It = List.begin();
????????std::cout << It->Suit << " " << It->Num;
????????for(++It; It != List.end(); ++It){
????????????????std::cout << "\n" << It->Suit << " " << It->Num;
????????}
????????std::cout << std::endl;
}
void Check(const TList& List, const TList& Stable)
{
????????if(std::equal(List.begin(), List.end(), Stable.begin())){
????????????????std::cout << "Stable" << std::endl;
????????}else{
????????????????std::cout << "Not stable" << std::endl;
????????}
}
??
int main()
{
????????std::cin.tie(0);
????????std::ios::sync_with_stdio(false);
????????const TList List = Input();
????????TList StableList = List;
????????std::stable_sort(StableList.begin(), StableList.end());
??
????????TList QuickList = List;
????????quickSort(QuickList, 0, QuickList.size() - 1);
????????Check(QuickList, StableList);
????????Output(QuickList);
????????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>

struct fun{
	char c;
	int b;
}f[100010],f1[100010],t,h;

int Partition(fun a[],int p,int r){
   a[0]=a[p];
   int k=a[0].b;
   while(p<r){
   	while(p<r&&a[r].b>=k)  r--;
   	  a[p]=a[r];
   	while(p<r&&a[p].b<=k)  p++;
   	  a[r]=a[p];
   }
   a[p]=a[0];
   return p;
}
void Quicksort(fun a[],int p,int r){
	if(p<r){
     int q = Partition(a, p, r);
      Quicksort(a, p, q-1);
      Quicksort(a, q+1, r);
   }
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf(" %c %d",&f[i].c,&f[i].b);
		f1[i].c=f[i].c;
		f1[i].b=f[i].b;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=n-i;j++){
			if(f1[j].b>f1[j+1].b){
				h=f1[j];
				f1[j]=f1[j+1];
				f1[j+1]=h;
			}
		} 
	}
	Quicksort(f,1,n);
	int leap;
	 for(int i=1;i<=n;i++){
		if(f[i].c!=f1[i].c){
			leap=1;
			break;
		}
		  else
		  leap=0;
		}
	if(leap==1)
	  printf("Not stable\n");
	if(leap==0)
	  printf("Stable\n");
    for(int i=1;i<=n;i++){
		printf("%c %d\n",f[i].c,f[i].b);
	}
	return 0;
}

Compiler output:
main.c:8:15: error: unknown type name 'fun'
    8 | int Partition(fun a[],int p,int r){
      |               ^~~
main.c:20:16: error: unknown type name 'fun'
   20 | void Quicksort(fun a[],int p,int r){
      |                ^~~
main.c: In function 'main':
main.c:45:9: error: implicit declaration of function 'Quicksort' [-Wimplicit-function-declaration]
   45 |         Quicksort(f,1,n);
      |         ^~~~~~~~~
Language: C

#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct Kp{
     char c;
     int n,k;
}card[100000];
bool cmp(Kp x,Kp y){
    return x.n<y.n;
}
int main(){
   int N,i;
   bool flag;
   while(~scanf("%d",&N)){
        flag=false;
        getchar();
    for(i=0;i<N;i++){
        scanf("%c %d",&card[i].c,&card[i].n);
        getchar();
        card[i].k=i;
    }
   sort(card,card+N,cmp);
   for(i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(card[i].c==card[j].c)
                if(card[i].k>card[j].k)
                  flag=true;
        }
   }
   if(flag)
     printf("Not stable\n");
   else
     printf("Stable\n");
   for(i=0;i<N;i++){
        printf("%c %d\n",card[i].c,card[i].n);
   }

  }
}

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

#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
}

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, 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] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

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

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ )
    if ( A[j].value <= x.vaule ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n - 1);

  for ( i = 0; i < n; i++ ) {
    // マージソートとクイックソートの結果を比べる
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ )
    printf("%c %d\n", B[i].suit, B[i].value);

  return 0;
}


Compiler output:
main.c:10:1: error: expected ';', identifier or '(' before 'struct'
   10 | struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];
      | ^~~~~~
main.c: In function 'partition':
main.c:44:26: error: 'struct Card' has no member named 'vaule'; did you mean 'value'?
   44 |     if ( A[j].value <= x.vaule ) {
      |                          ^~~~~
      |                          value
Language: C

#include<stdio.h>
#define MAX 100000
typedef struct{
  char design;
  int value;
}card;
int Partition(card A[],int,int,int);
void quickSort(card A[],int,int,int);
void mergeSort(card A[],int ,int );
void merge(card A[],int ,int ,int );
int Partition(card A[],int n,int p,int r){
  int x=A[r].value;
  int i=p-1,j;
  card k;
  for(j=p;j<r;j++){
    if(A[j].value<=x){
      i++;
      k=A[i];
      A[i]=A[j];
      A[j]=k;

    }
  }
  k=A[i+1];
  A[i+1]=A[r];
  A[r]=k;
return  i+1;
}
void quickSort(card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=Partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}
void mergeSort(card 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);

}
}
void merge(card A[],int Left,int Mid,int Right){
  int i,j,l1,l2,k;
l1=Mid-Left;
  l2=Right-Mid;

  for(i=0;i<l1;i++){
    L[i]=A[Left+i];
  }
  for(j=0;j<l2;j++){
    R[j]=A[Mid+j];
  }
  L[l1]=1000000000;
  R[l2]=1000000000;
  i=0;
  j=0;
  for(k=Left;k<Right;k++)
  if(L[i]<=R[j]){
    A[k]=L[i];
    i++;
    c++;

  }
  else{
    A[k]=R[j];
    j++;
    c++;

  }
}
int main(){
int i,n;
char s[5];
card A[MAX],B[MAX];
scanf("%d",&n);
for (i=0;i<n;i++) {
  scanf("%s %d",s,&A[i].value);
  A[i].design=s[0];
  B[i]=A[i];
  }
  quickSort(A,n,0,n-1);
  mergeSort(B,0,n);
  printf("Not stable\n");
  for(i=0;i<n;i++){


  printf("%c %d\n",A[i].design,A[i].value);
}
printf("\n");
return 0;
}



Compiler output:
main.c: In function 'merge':
main.c:53:5: error: 'L' undeclared (first use in this function)
   53 |     L[i]=A[Left+i];
      |     ^
main.c:53:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:56:5: error: 'R' undeclared (first use in this function)
   56 |     R[j]=A[Mid+j];
      |     ^
main.c:66:5: error: 'c' undeclared (first use in this function)
   66 |     c++;
      |     ^
Language: C

#include <stdio.h>
#include <stdlib.h>
struct card{
  char handle;
  int num;
};
card L[50002],R[50002];
void quicksort(int,int);
int partition(int,int);
void merge(struct card *,int,int,int);
void mergesort(struct card *,int,int);
struct card A[100000];
int main(){
  int n,i;
  char dummy;
  struct card c[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%c %c",&dummy,&A[i].handle);
    scanf("%d",&A[i].num);
    c[i]=A[i];
  }
  printf("\n");
  mergesort(A,0,n);
  quicksort(0,n);
  int cnt=0;
  for(i=0;i<n;i++){
    if(A[i].handle!=c[i].handle){
      printf("Not stable\n");
      cnt++;
      break;
    }
  }
  if(cnt==0)printf("Stable\n");
  for(i=0;i<n;i++)printf("%c %d\n",A[i].handle,A[i].num);
  printf("\n");
  return 0;
}
void quicksort(int p,int r){
  int q;
  if(p<r){
    q=partition(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }
}
int partition(int p,int r){
  int i,q,cnt=p-1;
  q=A[r-1].num;
  struct card j;
  for(i=p;i<r;i++){
    if(A[i].num<=q){
      cnt++;
      j=A[i];
      A[i]=A[cnt];
      A[cnt]=j;
    }
  }
}
void mergesort(struct card *c,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergesort(c,left,mid);
    mergesort(c,mid,right);
    merge(c,left,mid,right);
  }
}
void merge(struct card *c,int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  int i;
  for(i=0;i<n1;i++)L[i]=c[i+left];
  for(i=0;i<n2;i++)R[i]=c[i+mid];
  L[n1].num=R[n2].num=2000000000;
  int j=0,k;
  i=0;
  for(k=left;k<right;k++){
    if(L[i].num<=R[j].num)c[k]=L[i++];
    else c[k]=R[j++];
  }
}



Compiler output:
main.c:7:1: error: unknown type name 'card'; use 'struct' keyword to refer to the type
    7 | card L[50002],R[50002];
      | ^~~~
      | struct 
main.c: In function 'merge':
main.c:71:25: error: incompatible types when assigning to type 'int' from type 'struct card'
   71 |   for(i=0;i<n1;i++)L[i]=c[i+left];
      |                         ^
main.c:72:25: error: incompatible types when assigning to type 'int' from type 'struct card'
   72 |   for(i=0;i<n2;i++)R[i]=c[i+mid];
      |                         ^
main.c:73:8: error: request for member 'num' in something not a structure or union
   73 |   L[n1].num=R[n2].num=2000000000;
      |        ^
main.c:73:18: error: request for member 'num' in something not a structure or union
   73 |   L[n1].num=R[n2].num=2000000000;
      |                  ^
main.c:77:12: error: request for member 'num' in something not a structure or union
   77 |     if(L[i].num<=R[j].num)c[k]=L[i++];
      |            ^
main.c:77:22: error: request for member 'num' in something not a structure or union
   77 |     if(L[i].num<=R[j].num)c[k]=L[i++];
      |                      ^
main.c:77:32: error: incompatible types when assigning to type 'struct card' from type 'int'
   77 |     if(L[i].num<=R[j].num)c[k]=L[i++];
      |                                ^
main.c:78:15: error: incompatible types when assigning to type 'struct card' from type 'int'
   78 |     else c[k]=R[j++];
      |               ^
Language: C

#include <stdio.h>
#include <stdlib.h>
struct card{
  char handle;
  int num;
};
void quicksort(struct card *,int,int);
int partition(struct card *,int,int);
void merge(struct card *,int,int,int);
void mergesort(struct card *,int,int);
int main(){
  int n,i;
  char dummy[10];
  struct card A[100000],c[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",dummy,&A[i].num);
    A[i].handle=dummy[0];
    c[i]=A[i];
  }
  mergesort(A,0,n);
  quicksort(c,0,n-1);
  int cnt=0;
  for(i=0;i<n;i++){
    if(A[i].handle!=c[i].handle){
      printf("Not stable\n");
      cnt++;
      break;
    }
  }
  if(cnt==0)printf("Stable\n");
  for(i=0;i<n;i++){
      printf("%c %d\n",c[i].handle,c[i].num);
      if(i!=n-1)printf(" ");
  printf("\n");
  return 0;
}
void quicksort(struct card *A,int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}
int partition(struct card *A,int p,int r){
  int i,cnt=p-1,q;
  q=A[r].num;
  struct card j;
  for(i=p;i<r;i++){
    if(A[i].num<=q){
      cnt++;
      j=A[i];
      A[i]=A[cnt];
      A[cnt]=j;
    }
  }
  j=A[cnt+1];
  A[cnt+1]=A[r];
  A[r]=j;
  return cnt+1;
}
void mergesort(struct card *c,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(c,left,mid);
    mergesort(c,mid,right);
    merge(c,left,mid,right);
  }
}
void merge(struct card *c,int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  struct card *L,*R;
  L=malloc(sizeof(struct card)*(n1+2));
  R=malloc(sizeof(struct card)*(n2+2));
  int i;
  for(i=0;i<n1;i++)L[i]=c[i+left];
  for(i=0;i<n2;i++)R[i]=c[i+mid];
  L[n1].num=R[n2].num=2000000000;
  int j=0,k;
  i=0;
  for(k=left;k<right;k++){
    if(L[i].num<=R[j].num)c[k]=L[i++];
    else c[k]=R[j++];
  }
  free(L);
  free(R);
}




Compiler output:
main.c: In function 'main':
main.c:89:1: error: expected declaration or statement at end of input
   89 | }
      | ^
Language: C

#include<iostream>

using namespace std;

#define N 100001

#define SENTINEL 999999998

//Merge function
void Merge(int a[],char c[],int left,int mid,int right){
  
  int n1,n2,i,j;
  int L[N],R[N];
  char Lc[N],Rc[N];
  n1=mid-left;
  n2=right-mid;

  for(i=0;i<n1;i++){
    L[i]=a[left+i];
    Lc[i]=c[left+i];
  }

  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
    Rc[i]=c[mid+i];
  }

  //L[n1]=SENTINEL,R[n2]=SENTINEL
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;

  i=0;
  j=0;
  for(int k=left;k<right;k++){

    if(L[i]<=R[j]){
      a[k]=L[i];
      c[k]=L[i];
      i++;
    }
    else{
      a[k]=R[j];
      c[k]=Rc[j];
      j++;
    }
  }

}

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

}


int Partition(int a[],char c[],int p,int r){
  int x,i,j,st;
  char stc;

  x=a[r];
  i=p-1;

  for(j=p;j<=r-1;j++){
    if(a[j]<=x){
      i++;

      //exchange a[i] and a[j]
      st=a[i];
      a[i]=a[j];
      a[j]=st;

      stc=c[i];
      c[i]=c[j];
      c[j]=stc;

    }
  }

  //exchange a[i] and a[j]
    st=a[i+1];
    a[i+1]=a[r];
    a[r]=st;

    stc=c[i+1];
    c[i+1]=c[r];
    c[r]=stc;

    return i+1;

}


void QuickSort(int a[],char c[],int p,int r){
  int q;
  if(p<r){
    q=Partition(a,c,p,r);
    QuickSort(a,c,p,q-1);
    QuickSort(a,c,q+1,r);
  }
}

int main(){
 
  int n,i,a1[N],a2[N];
  char c1[N],c2[N];
  bool flag=true;
  cin >>n;

  for(i=0;i<n;i++){
    cin >>c1[i]>>a1[i];
    a2[i]=a1[i];
    c2[i]=c1[i];
  }


  QuickSort(a1,c1,0,n-1);
  MergeSort(a2,c2,0,n-1);

  for(i=0;i<n;i++){
    if(c1[i]!=c2[i]){
      cout <<"Not stable"<<endl;
      flag=false;
      break;
    }
  }

  if(flag==true) cout <<"Stable"<<endl;

  for(i=0;i<n;i++){
    cout <<c1[i]<<" "<<a1[i]<<endl;;
  }

  /*  cout <<endl;
  for(i=0;i<n;i++){
    cout <<c2[i]<<" "<<a2[i]<<endl;;
  }*/
  return 0;
}

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 100000

typedef struct C{
    char pic;
    int num;
    int id;
}card;
 
int part(card arr[], int p, int r){
    int x, i, j;
    card tmp;
    x = arr[r].num;
    i = p-1;
     
    for(j = p; j < r; j++) {
        if(arr[j].num <= x) {
            i++;
            tmp = arr[i];
	    arr[i] = arr[j];
	    arr[j] = tmp;
        } 
    }
    t = arr[i+1];
    arr[i+1] = arr[r];
    arr[r] = t;
    return i + 1;
}
 
void quick(card arr[], int P, int R){
    int Q;
    if(P < R) {
        Q = part(arr, P, R);
        quick(arr, P, Q - 1);
        quick(arr, Q + 1, R);
    }
}
 
int isSta(card arr[], int n){
    int i;
    for(i=1; i<n; i++) {
        if(arr[i-1].num == arr[i].num) {
            if(arr[i - 1].id > arr[i].id) return 0;
        }
    }
    return 1;
}
 
int main(int argc,char *argv[]){
    int i, n;
    card arr[N];
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf(" %c %d", &arr[i].pic, &arr[i].num);
        arr[i].id=i;
    }
    quick(arr, 0, n-1);
 
    if(isSta(arr, n)) printf("Stable\n");
    else printf("Not stable\n");
    for(i=0; i<n; i++) {
        printf("%c %d\n", arr[i].pic, arr[i].num);
    }
    return 0;
}

Compiler output:
main.c:3:1: error: unknown type name 'define'
    3 | define N 100000
      | ^~~~~~
main.c:3:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
    3 | define N 100000
      |          ^~~~~~
main.c:9:2: warning: data definition has no type or storage class
    9 | }card;
      |  ^~~~
main.c:9:2: error: type defaults to 'int' in declaration of 'card' [-Wimplicit-int]
main.c:11:10: error: expected declaration specifiers or '...' before 'card'
   11 | int part(card arr[], int p, int r){
      |          ^~~~
main.c:31:12: error: expected declaration specifiers or '...' before 'card'
   31 | void quick(card arr[], int P, int R){
      |            ^~~~
main.c:40:11: error: expected declaration specifiers or '...' before 'card'
   40 | int isSta(card arr[], int n){
      |           ^~~~
main.c: In function 'main':
main.c:52:9: error: expected ';' before 'arr'
   52 |     card arr[N];
      |         ^~~~
      |         ;
main.c:55:26: error: 'arr' undeclared (first use in this function)
   55 |         scanf(" %c %d", &arr[i].pic, &arr[i].num);
      |                          ^~~
main.c:55:26: note: each undeclared identifier is reported only once for each function it appears in
main.c:58:5: error: implicit declaration of function 'quick' [-Wimplicit-function-declaration]
   58 |     quick(arr, 0, n-1);
      |     ^~~~~
main.c:60:8: error: implicit declaration of function 'isSta' [-Wimplicit-function-declaration]
   60 |     if(isSta(arr, n)) printf("Stable\n");
      |        ^~~~~
Language: C

#include <stdio.h>
#define N 100000

int A[N];
char C[N];

int Partition(int p,int r){
    int x,i,j;
    int tmp,tmpc;
    
    x=A[r];
    i = p-1;
    
    for(j=p;j<r;j++){
        if (A[j] <= x){
            i=i+1;
            tmp=A[j];
            tmpc=C[j];
            A[j]=A[i];
            C[j]=C[i];
            A[i]=tmp;
            C[j]=tmpc;
        }
    }
    
    tmp=A[i+1];
    tmpc=C[i+1];
    A[i+1]=A[r];
    C[i+1]=C[r];
    A[r]=tmp;
    C[r]=tmpc;
    
    
    return i+1;
}

void Quicksort(p,r){
    int q;
    if(p<r){
        q=Partition(p,r);
        Quicksort(p,q-1);
        Quicksort(q+1,r);
    }
}



int main(int argc, char *argv[]){
    
    char C1[N];
    int A1[n];
    int n,i,x,j,k=0;
    char null;
    int tmp;
    char tmpc;
    
    scanf("%d%c",&n,&null);
    if(1>n || n>100000)return 0;
    
    for(i=0;i<n;i++){
        scanf("%c%d%c",&C[i],&A[i],&null);
        C1[i]=C[i];
        A1[i]=A[i];
    }
    
    
    Quicksort(0,n-1);
    
    
    
    
    
    for(i=0;i<n;i++){
        for(j=1;j<n;j++){
            
            if(A1[j]<A1[j-1]){
                tmp=A1[j];
                tmpc=C1[j];
                A1[j]=A1[j-1];
                C1[j]=C1[j-1];
                A1[j-1]=tmp;
                C1[j-1]=tmpc;
            }
        }
    }
    
    
    for(i=0;i<n;i++){
        if(C1[i]!=C[i]){
        k=1;
    }
    }
    
    
    
    
    if(k==1)printf("Not stable\n");
    else printf("Stable\n");
    
    
    for(i=0;i<n-1;i++){
        printf("%c %d\n",C[i],A[i]);
    }

    printf("%c %d\n",C[n-1],A[n-1]);
    
    
    
    
    return 0;
}

Compiler output:
main.c: In function 'Quicksort':
main.c:37:6: error: type of 'p' defaults to 'int' [-Wimplicit-int]
   37 | void Quicksort(p,r){
      |      ^~~~~~~~~
main.c:37:6: error: type of 'r' defaults to 'int' [-Wimplicit-int]
main.c: In function 'main':
main.c:51:12: error: 'n' undeclared (first use in this function)
   51 |     int A1[n];
      |            ^
main.c:51:12: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define N 100000

int A[N];
char C[N];
char C1[N];
int A1[N];

int Partition(int p,int r){
    int x,i,j;
    int tmp,tmpc;
    
    x=A[r];
    i = p-1;
    
    for(j=p;j<r;j++){
        if (A[j] <= x){
            i=i+1;
            tmp=A[j];
            tmpc=C[j];
            A[j]=A[i];
            C[j]=C[i];
            A[i]=tmp;
            C[i]=tmpc;
        }
    }
    
    tmp=A[i+1];
    tmpc=C[i+1];
    A[i+1]=A[r];
    C[i+1]=C[r];
    A[r]=tmp;
    C[r]=tmpc;
    
    
    return i+1;
}

void Quicksort(p,r){
    int q;
    if(p<r){
        q=Partition(p,r);
        Quicksort(p,q-1);
        Quicksort(q+1,r);
    }
}

/* Merge */
void Merge(int l,int m,int r){
    int n1,n2;
    int i,j,k;
    int L[N],R[N];
    char LC[N],RC[N];
    
    n1=m-l;
    n2=r-m;
    
    for(i=0;i<n1;i++){
        L[i]=A1[l+i];
        LC[i]=C1[l+i];
    }
    for(j=0;j<n2;j++){
        R[j]=A1[m+j];
        LC[j]=C1[m+j];
    }
    
    L[n1] = 2147483647;
    R[n2] = 2147483647;
    
    i=0;
    j=0;
    
    for(k=l;k<r;k++){
        if(L[i]<=R[j]){
            A1[k]=L[i];
            C1[k]=L[i];
            i++;
        }else{
            A1[k]=R[j];
            C1[k]=R[j];
            j++;
        }
    }
    
}
/* Merge Sort */
void Merge_Sort(int left,int right){
    int mid;
    if(left+1<right){
        mid = (left + right)/2;
        Merge_Sort(left,mid);
        Merge_Sort(mid,right);
        Merge(left,mid,right);
    }
}// End Merge-Sort



int main(int argc, char *argv[]){
    

    int n,i,x,j,k=0;
    char null;
    int tmp;
    char tmpc;
    
    scanf("%d%c",&n,&null);
    if(1>n || n>100000)return 0;
    
    for(i=0;i<n;i++){
        scanf("%c%d%c",&C[i],&A[i],&null);
        C1[i]=C[i];
        A1[i]=A[i];
    }
    
    
    Quicksort(0,n-1);
    
    
    Merge_Sort(0,n);
    
    
/*    for(i=0;i<n;i++){
        for(j=1;j<n;j++){
            
            if(A1[j]<A1[j-1]){
                tmp=A1[j];
                tmpc=C1[j];
                A1[j]=A1[j-1];
                C1[j]=C1[j-1];
                A1[j-1]=tmp;
                C1[j-1]=tmpc;
            }
        }
    }
    
  */
    for(i=0;i<n;i++){
        if(C1[i]!=C[i]){
        k=1;
    }
    }
    

Compiler output:
main.c: In function 'Quicksort':
main.c:39:6: error: type of 'p' defaults to 'int' [-Wimplicit-int]
   39 | void Quicksort(p,r){
      |      ^~~~~~~~~
main.c:39:6: error: type of 'r' defaults to 'int' [-Wimplicit-int]
main.c: In function 'main':
main.c:142:5: error: expected declaration or statement at end of input
  142 |     }
      |     ^
Language: C

#include <stdio.h>

struct s{
  int num;
  char moji;
  int key;
};

struct s A[100001]; 

int Partition(int,int); 
void Quicksort(int,int);

main(){
  char c1,c2,c3;
  int n;
  int i,a,b;
  scanf("%d%c",&n,&c1);
  for(i=0;i<n;i++){
    scanf("%c%c%d%c",&A[i].moji,&c2,&A[i].num,&c3);
    A[i].key=i;
  }
  a = Partition(0,n-1);
  Quicksort(0,n-1);
  for(i=0;i<n-1;i++){
    if(A[i].key>A[i+1].key && A[i].num==A[i+1].num){
      b=1;
      break;
    }
  }
  if(b!=1)
    printf("Stable\n");
  if(b==1)
    printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].moji,A[i].num);
  }
  return 0;
}

int Partition(int p,int r){
  int i,j;
  struct s x,tmp;
  x.num=A[r].num;
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].num<=x.num){
      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}

Compiler output:
main.c:14:1: error: return type defaults to 'int' [-Wimplicit-int]
   14 | main(){
      | ^~~~
Language: C

#include<stdio.h>
#define N 100000

int patition(int [],int,int);
void quickSort(int[],int,int);
void bubble(int);
void isStable(int);

int A[N];
int A_1[N];
char B[N];
char B_1[N];
int main(){

  scanf("%d",&right);
  for(i=0;i<right;i++){
	scanf("%s%d",&B[i],&A[i]);
	A_1[i]=A[i];
	B_1[i]=B[i];
  }

  quickSort(A,left,right);
  bubble(right);
  isStable(right);
 
  for(i=0;i<right;i++){
	printf("%c %d\n",B[i],A[i]);
  }
  return 0;
}

int partition(int A[],int left,int right){

  int i,j,x=0,s=0;
  char c;
  x=A[right-1];
  i=left-1;

  for(j=left;j<right;j++){
	if(A[j]<=x){
   		s=A[i];
  		A[i]=A[j];
  		A[j]=s;

   		c=B[i];
  		B[i]=B[j];
  		B[j]=c;
  		
		i++;
	}
  }

  s=A[i];
  A[i]=A[right-1];
  A[right-1]=s;
  	 
  c=B[i];
  B[i]=B[right-1];
  B[right-1]=c;
  
  return i+1;
 
}

void quickSort(int A[],int left,int right){
 
  int q=0;
 
  if(left < right){
	q = partition(A,left,right);
	quickSort(A,left,q-1);
	quickSort(A,q+1,right);   
    
  }
 
 
}

void bubble(int right){
  int i,j,a=0;
  char c;
  for(i=0;i<right;i++){
	for(j=right-1;j>i;j--){
  	if( A_1[j] < A_1[j-1]){
    a=A_1[j-1];
    A_1[j-1]=A_1[j];
    A_1[j]=a;

    c=B_1[j-1];
    B_1[j-1]=B_1[j];
    B_1[j]=c;

  	}	 
	}
  }

}
void isStable(int right){
  int i,m=0;

  for(i=0;i<right;i++){
	if(B[i]==B_1[i]){
  	m++;
	} else {
  	break;
	}
  }
  if(m==right){
	printf("Stable\n");
  } else {
	printf("Not stable\n");
  }
}

Compiler output:
main.c: In function 'main':
main.c:15:15: error: 'right' undeclared (first use in this function)
   15 |   scanf("%d",&right);
      |               ^~~~~
main.c:15:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:16:7: error: 'i' undeclared (first use in this function)
   16 |   for(i=0;i<right;i++){
      |       ^
main.c:22:15: error: 'left' undeclared (first use in this function)
   22 |   quickSort(A,left,right);
      |               ^~~~
Language: C++

#include <iostream>
#define maxn 100000
#define INFTY 2000000000
using namespace std;

struct Card {
  char suit;
  int value;
};

struct Card L[maxn/2+2],R[maxn/2+2];

void merge(struct Card *Array,int left,int mid,int right) {
  int n1=mid-left;
  int n2=right-mid;
  for (int i=0; i<n1; i++) {
    L[i]=Array[left+i];
  }
  for (int i=0; i<n2; i++) {
    R[i]=Array[mid+i];
  }
  L[n1].value=R[n2].value=INFTY;
  int i=0,j=0;
  for (int k=left; k<right; k++) {
    if (L[i].value<=R[j].value) {
      Array[k]=L[i++];
    }
    else {
      Array[k]=R[j++];
    }
  }
}
void mergeSort(struct Card *Array,int left,int right) {
  if (left+1<right) {
    int mid=(left+right)/2;
    mergeSort(Array,left,mid);
    mergeSort(Array,mid,right);
    merge(Array,left,mid,right);
  }
}
int partition(struct Card *Array,int index,int p,int r) {
  int i,j;
  struct Card x=Array[r];
  i=p-1;
  for (j=p; j<r; j++) {
    if (Array[j].value<=x.value) {
      i++;
      swap(Array[i],Array[j]);
    }
  }
  swap(Array[i+1],Array[r]);
  return i+1;
}
void quickSort(struct Card *Array,int index,int p,int r) {
  int p;
  if (p<r) {
    q=partition(Array,index,p,r);
    quickSort(Array,index,p,q-1);
    quickSort(Array,index,q+1,r);
  }
}
int main() {
  int n,i,v;
  struct Card A[maxn],B[maxn];
  char S[10];
  bool stable=true;
  cin>>n;
  for (i=0; i<n; i++) {
    cin>>S>>v;
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,0,n);
  quickSort(B,n,0,n-1);
  for (i=0; i<n; i++) {
    if (A[i].suit!=B[i].suit) 
      stable=false;
    
  }
  if (stable) 
    cout<<"Stable"<<endl;
 else 
    cout<<"Not stable"<<endl;
  
  for (i=0; i<n; i++)  cout<<B[i].suit<<" "<<B[i].value<<endl;
  return 0;
}



Compiler output:
a.cc: In function 'void quickSort(Card*, int, int, int)':
a.cc:55:7: error: declaration of 'int p' shadows a parameter
   55 |   int p;
      |       ^
a.cc:54:49: note: 'int p' previously declared here
   54 | void quickSort(struct Card *Array,int index,int p,int r) {
      |                                             ~~~~^
a.cc:57:5: error: 'q' was not declared in this scope
   57 |     q=partition(Array,index,p,r);
      |     ^
Language: C++

#include <iostream>
using namespace std;

struct card{
   char suit;
   int value;
};

const int SENTINEL=2000000000;
int cnt=0;
void merge(card A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	card *L=new card[n1+1];
	card *R=new card[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].value=R[n2].value=SENTINEL;
    int i=0,j=0;
    for(int k=left;k<right;k++){
    	cnt++;
    	if(L[i].value<=R[j].value)A[k]=L[i++];
    	else A[k]=R[j++];
    }
    delete L;
    delete R;

}
void mergeSort(card 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  partition(card A[],int n,int p,int r){
	int i=p;
	card x=A[r];
	for(int j=p;j<r;j++){
		if(A[j].value<=x.value){
			
			card t=A[j];
			A[j]=A[i];
			A[i]=t;
			++i;
		}
	}
	A[r]=A[i];
	A[i]=x;

	return i;
}
quickSort(card A[],int n,int p,int r){
	if(p<r){
		int q=partition(A,n,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}

int main(){
	int n;
	cin>>n;
	card *A=new card[n];
	card *B=new card[n];

	for(int i=0;i<n;i++){
		cin>>A[i].suit>>A[i].value;
		B[i]=A[i];
    }
    
    quickSort(A,n,0,n-1);
    mergeSort(B,n,0,n);
    int stable=1;
    for(int i=0;i<n;i++){
    	if(A[i].suit != B[i].suit ) {
    		stable=0;break;
    	}
    }
    if(stable==1)cout<<"Stable"<<endl;
    else cout<<"No stable"<<endl;
    for(int i=0;i<n;i++){
       	cout<<A[i].suit<<' '<<A[i].value<<endl;
    }

    cout<<endl;

    return 0;
}


Compiler output:
a.cc:55:1: error: ISO C++ forbids declaration of 'quickSort' with no type [-fpermissive]
   55 | quickSort(card A[],int n,int p,int r){
      | ^~~~~~~~~
a.cc: In function 'int quickSort(card*, int, int, int)':
a.cc:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
   61 | }
      | ^
Language: C++

import copy

def partition(p, r):
    i = p
    for j in range(p, r):
        if A[r][1] >= A[j][1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[r], A[i] = A[i], A[r]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def correct_same_num_suits(l, num):
    suits = []
    for card in l:
        if num == card[1]:
            suits.append(card[0])
    return suits

def is_stable():
    idx = 0
    while idx < N-1:
        idx_incr_flg = True
        if A[idx][1] == A[idx+1][1]:
            num = A[idx][1]
            sorted_suits = correct_same_num_suits(A, num)
            orig_suits = correct_same_num_suits(orig_list, num)
            if sorted_suits != orig_suits:
                return False
            idx += len(sorted_suits)
            idx_incr_flg = False
        if idx_incr_flg:
            idx += 1
    return True


N = int(input())
A = []
for _ in range(N):
    suit, num = input().split()
    num = int(num)
    A.append([suit, num])
orig_list = copy.deepcopy(A)

quick_sort(0, N-1)

is_stable = is_stable()
if is_stable:
    print("Stable")
else:
    print("Not stable")

for card in A:
    print("%s %d" % (card[0], card[1]))


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import copy
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

import copy

def partition(p, r):
    i = p
    for j in range(p, r):
        if A[r][1] >= A[j][1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[r], A[i] = A[i], A[r]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def correct_same_num_suits(l, num, first):
    suits = []
    for i in range(first, N):
        if num == l[i][1]:
            suits.append(l[i][0])
    return suits

def is_stable():
    idx = 0
    while idx < N-1:
        idx_incr_flg = True
        if A[idx][1] == A[idx+1][1]:
            num = A[idx][1]
            sorted_suits = correct_same_num_suits(A, num, idx)
            orig_suits = correct_same_num_suits(orig_list, num, 0)
            if sorted_suits != orig_suits:
                return False
            idx += len(sorted_suits)
            idx_incr_flg = False
        if idx_incr_flg:
            idx += 1
    return True


N = int(input())
A = []
for _ in range(N):
    suit, num = input().split()
    num = int(num)
    A.append([suit, num])
orig_list = copy.deepcopy(A)

quick_sort(0, N-1)

is_stable = is_stable()
if is_stable:
    print("Stable")
else:
    print("Not stable")

for card in A:
    print("%s %d" % (card[0], card[1]))


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import copy
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

import copy

def partition(p, r):
    i = p
    for j in range(p, r):
        if A[r][1] >= A[j][1]:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[r], A[i] = A[i], A[r]
    return i

def quick_sort(p, r):
    if p < r:
        q = partition(p, r)
        quick_sort(p, q-1)
        quick_sort(q+1, r)

def correct_same_num_suits(l, num, first, ele_cnt):
    suits = []
    for i in range(first, N):
        if num == l[i][1]:
            suits.append(l[i][0])
        if ele_cnt == len(suits):
            break
    return suits

def is_stable():
    idx = 0
    while idx < N-1:
        idx_incr_flg = True
        if A[idx][1] == A[idx+1][1]:
            num = A[idx][1]
            j = idx
            ele_cnt = 0
            while j < N and num == A[j][1]:
                ele_cnt += 1
                j += 1
            sorted_suits = correct_same_num_suits(A, num, idx, ele_cnt)
            orig_suits = correct_same_num_suits(orig_list, num, 0, ele_cnt)
            if sorted_suits != orig_suits:
                return False
            idx += len(sorted_suits)
            idx_incr_flg = False
        if idx_incr_flg:
            idx += 1
    return True


N = int(input())
A = []
for _ in range(N):
    suit, num = input().split()
    num = int(num)
    A.append([suit, num])
orig_list = copy.deepcopy(A)

quick_sort(0, N-1)

is_stable = is_stable()
if is_stable:
    print("Stable")
else:
    print("Not stable")

for card in A:
    print("%s %d" % (card[0], card[1]))


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import copy
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

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

struct Card{
    char suit;
    int val;
};

const int MAX = 100000, SENTINEL = 2100000000;
Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(Card 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].val = R[n2].val = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].val <= R[j].val) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergesort(Card 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 partition(Card A[], int p, int r) {
    Card x = A[r];
    int i = p - 1;
    for (int j  = p; j < r; j++) {
        if (A[j].val <= x.val) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void qsort(Card A[], int n, int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        qsort(A, n, p, q - 1);
        qsort(A, n, q + 1, r);
    }
}

int main(void) {
    int n;
    Card A[MAX], B[MAX];
    cin >> n;
    string s;
    int v;
    for (int i = 0; i < n; i++) {
        cin >> s >> v;
        A[i].suit = B[i].suit = s[0];
        A[i].val = B[i].val = v;
    }

    msort(A, n, 0, n);
    qsort(B, n, 0, n - 1);

    int stable = 1;
    for (int i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit) stable = 0;
    }

    cout << (stable ? "Stable" : "Not stable") << endl;
    for (int i = 0; i < n; i++) {
        cout << B[i].suit << " " << B[i].val << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:5: error: 'msort' was not declared in this scope; did you mean 'qsort'?
   71 |     msort(A, n, 0, n);
      |     ^~~~~
      |     qsort
Language: C++

#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

struct Card {
    char suit;
    int value;

    bool operator<(const Card& c) const {
        return this->value < c.value;
    }
    bool operator<=(const Card& c) const {
        return this->value <= c.value;
    }
    Card& operator=(int val) {
        this->value = val;
        return *val;
    }
};
#define MAX 100000
#define SENTINEL 2000000000
Card L[MAX/2+2],R[MAX/2+2];
void merge(Card *a,int n, int l,int mid,int r) {
    int n1=mid-l;
    int n2=r-mid;
    rep(i,n1) L[i]=a[l+i];
    rep(i,n2) R[i]=a[mid+i];
    L[n1]=SENTINEL;
    R[n2]=SENTINEL;
    int i,j;
    i=j=0;
    for(int k=l;k<r;k++) {
        if(L[i]<=R[j]) a[k]=L[i++];
        else a[k]=R[j++];
    }
}
void merge_sort(Card *a,int n,int l,int r) {
    if(l+1<r) {
        int mid=(l+r)/2;
        merge_sort(a,n,l,mid);
        merge_sort(a,n,mid,r);
        merge(a,n,l,mid,r);
    }
}
int partition(Card *a,int p,int r) {
    int i,j;
    Card x;
    x=a[r];
    i=p-1;
    for(int j=p;j<r;j++) {
        if(a[j]<=x) {
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;
}

void quick_sort(Card *a,int n,int p,int r) {
    int q;
    if(p < r) {
        q = partition(a,p,r);
        quick_sort(a,n,p,q-1);
        quick_sort(a,n,q+1,r);
    }
}

Card A[MAX],B[MAX];
int main() {
    int n;
    cin>>n;
    rep(i,n) {
        cin>>A[i].suit>>A[i].value;
        B[i]=A[i];

    }

    merge_sort(A,n,0,n);
    quick_sort(B,n,0,n-1);
    bool is_stable = true;

    rep(i,n) is_stable &= A[i].suit == B[i].suit;

    if(is_stable) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    rep(i,n) cout<<B[i].suit<<" "<<B[i].value<<endl;

    return 0;
}

Compiler output:
a.cc: In member function 'Card& Card::operator=(int)':
a.cc:46:16: error: invalid type argument of unary '*' (have 'int')
   46 |         return *val;
      |                ^~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#define NMAX 2000001
#define AMAX 10000

int partition(short*,int,int);
void quickSort(short*,int,int);

char C[100000];

int main(){

  unsigned short *A;

  int i,k,n;
  int x,p,q,r;
  int SA[100000];

  scanf("%d",&n);

  p=0;
  r=n-1;

  A=malloc(sizeof(short)*n+1);

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

 for(i=0;i<n;i++){
   SA[i]=A[i];
  }

  quickSort(A,p,r);


  for(i=0;i<n;i++){
    if(SA[i]!=A[i]) k=1; 
  }

  if(k==1) printf("Not stable\n");
  else printf("Stable\n");


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


  return 0;
  
}


int partition(short* A,int p,int r){
  int i,j,x,mv;
  char cmv;
  i=p-1;
  x=A[r];

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
 
      mv=A[i];
      cmv=C[i];
      A[i]=A[j];
      C[i]-C[j];
      A[j]=mv;
      C[j]=cmv;
    }

  }

  mv=A[i+1];
  cmv=C[i+1];
  A[i+1]=A[r];
  C[i+1]=C[r];
  A[r]=mv;
  C[r]=cmv;

  return i+1;
}


void quickSort(short* A,int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:11: error: invalid conversion from 'void*' to 'short unsigned int*' [-fpermissive]
   24 |   A=malloc(sizeof(short)*n+1);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~
      |           |
      |           void*
a.cc:34:13: error: invalid conversion from 'short unsigned int*' to 'short int*' [-fpermissive]
   34 |   quickSort(A,p,r);
      |             ^
      |             |
      |             short unsigned int*
a.cc:7:16: note:   initializing argument 1 of 'void quickSort(short int*, int, int)'
    7 | void quickSort(short*,int,int);
      |                ^~~~~~