Language: C++

#include <stdio.h>
#define MAX 100000
#define INF 1<<30

struct Card {
    char suit;
    int value;
}

void merge(struct Card A[], int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    
    int L[n1+1], R[n2+1];
    for(int i=0; i<n1; i++) L[i].value = A[left + i].value;
    for(int i=0; i<n2; i++) R[i].value = A[mid + i].value;
    L[n1].value = R[n2].value = INF;
    
    int i=0, j=0;
    for (int k=left; k<right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(struct 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);
    }
}

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

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 main() {
    int n, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    scanf("%d", &n);
    
    for (int 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, 0, n);
    mergeSort(B, 0, n-1);
    
    for (int 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 (int i=0; i<n; i++) {
        printf("%c %d\n", B[i].suit, B[i].value);
    }
    printf("\n");
    return 0;
}


Compiler output:
a.cc:8:2: error: expected ';' after struct definition
    8 | }
      |  ^
      |  ;
a.cc: In function 'void merge(Card*, int, int, int)':
a.cc:16:34: error: request for member 'value' in 'L[i]', which is of non-class type 'int'
   16 |     for(int i=0; i<n1; i++) L[i].value = A[left + i].value;
      |                                  ^~~~~
a.cc:17:34: error: request for member 'value' in 'R[i]', which is of non-class type 'int'
   17 |     for(int i=0; i<n2; i++) R[i].value = A[mid + i].value;
      |                                  ^~~~~
a.cc:18:11: error: request for member 'value' in 'L[n1]', which is of non-class type 'int'
   18 |     L[n1].value = R[n2].value = INF;
      |           ^~~~~
a.cc:18:25: error: request for member 'value' in 'R[n2]', which is of non-class type 'int'
   18 |     L[n1].value = R[n2].value = INF;
      |                         ^~~~~
a.cc:20:9: error: redeclaration of 'int i'
   20 |     int i=0, j=0;
      |         ^
a.cc:11:9: note: 'int i' previously declared here
   11 |     int i, j, k;
      |         ^
a.cc:20:14: error: redeclaration of 'int j'
   20 |     int i=0, j=0;
      |              ^
a.cc:11:12: note: 'int j' previously declared here
   11 |     int i, j, k;
      |            ^
a.cc:22:18: error: request for member 'value' in 'L[i]', which is of non-class type 'int'
   22 |         if (L[i].value <= R[j].value) {
      |                  ^~~~~
a.cc:22:32: error: request for member 'value' in 'R[j]', which is of non-class type 'int'
   22 |         if (L[i].value <= R[j].value) {
      |                                ^~~~~
a.cc:23:23: error: no match for 'operator=' (operand types are 'Card' and 'int')
   23 |             A[k] = L[i];
      |                       ^
a.cc:5:8: note: candidate: 'constexpr Card& Card::operator=(const Card&)'
    5 | struct Card {
      |        ^~~~
a.cc:5:8: note:   no known conversion for argument 1 from 'int' to 'const Card&'
a.cc:5:8: note: candidate: 'constexpr Card& Card::operator=(Card&&)'
a.cc:5:8: note:   no known conversion for argument 1 from 'int' to 'Card&&'
a.cc:26:23: error: no match for 'operator=' (operand types are 'Card' and 'int')
   26 |             A[k] = R[j];
      |                       ^
a.cc:5:8: note: candidate: 'constexpr Card& Card::operator=(const Card&)'
    5 | struct Card {
      |        ^~~~
a.cc:5:8: note:   no known conversion for argument 1 from 'int' to 'const Card&'
a.cc:5:8: note: candidate: 'constexpr Card& Card::operator=(Card&&)'
a.cc:5:8: note:   no known conversion for argument 1 from 'int' to 'Card&&'