Language: C++

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

static const int MAX_NUM = 100000;

void MargeElem(pair<int, num> elem[], int start, int mid, int end)
{
    int i, j, k, l;
    pair<int, num> tmp1[MAX_NUM/2];
    pair<int, num> tmp2[MAX_NUM/2];

    i = end - mid;
    j = mid - start;
    k = (i > j) ? i : j;

    for (l = 0; l < k; l++) {
        tmp1[l] = elem[start+l];
        tmp2[l] = elem[mid+l];
    }
    tmp1[j] = 0x7FFFFFF;
    tmp2[i] = 0x7FFFFFF;

    j = 0;
    k = 0;
    for (i = start; i < end; i++) {
        if (tmp1[j].first <= tmp2[k].first) {
            elem[i] = tmp1[j];
            ++j;
        }
        else {
            elem[i] = tmp2[k];
            ++k;
        }
    }

    return;
}

void MargeSort(pair<int, num> elem[], int start, int end)
{
    int mid;

    if (start < end) {
        mid = (start + end) / 2;
        MargeSort(elem, start, mid);
        MargeSort(elem, mid, end);
        MargeElem(elem, start, mid, end);
    }

    return;
}

int PartitionSort(pair<int, char> elem[], int start, int end)
{
    int i;
    int target;
    int left;

    left = start - 1;
    target = elem[end-1].first;

    for (i = start; i < end - 1; i++) {
        if (target >= elem[i].first) {
            ++left;
            swap(elem[left], elem[i]);
        }
    }
    ++left;
    swap(elem[left], elem[end-1]);

    return left;
}


void QuickSort(pair<int, char> elem[], int start, int end)
{
    int mid;

    mid = PartitionSort(elem, start, end);

    if (start < mid - 1) {
        QuickSort(elem, start, mid);
    }
    if (mid < end - 1) {
        QuickSort(elem, mid, end);
    }

    return;
}

int main(void)
{
    int i, j;
    char c[7];
    int num;
    pair<int, char> elem[MAX_NUM];
    pair<int, char> elem2[MAX_NUM];

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%s %d", &c, &j);
        elem[i].first  = j;
        elem[i].second = c[0];
        elem2[i].first  = j;
        elem2[i].second = c[0];
    }

    QuickSort(elem,  0, num);
    MargeSort(elem2, 0, num);

    for (i = 0; i < num; i++) {
        if (elem[i] != elem2[i]) {
            break;
        }
    }
    if (i == num) {
        printf("Stable\n");
    }
    else {
        printf("Not Stable\n");
    }

    for (i = 0; i < num; i++) {
        printf("%c %d\n", elem[i].second, elem[i].first);
    }

    return 0;
}

Compiler output:
a.cc:7:26: error: 'num' was not declared in this scope; did you mean 'enum'?
    7 | void MargeElem(pair<int, num> elem[], int start, int mid, int end)
      |                          ^~~
      |                          enum
a.cc:7:29: error: template argument 2 is invalid
    7 | void MargeElem(pair<int, num> elem[], int start, int mid, int end)
      |                             ^
a.cc: In function 'void MargeElem(int*, int, int, int)':
a.cc:10:15: error: 'num' was not declared in this scope; did you mean 'enum'?
   10 |     pair<int, num> tmp1[MAX_NUM/2];
      |               ^~~
      |               enum
a.cc:10:18: error: template argument 2 is invalid
   10 |     pair<int, num> tmp1[MAX_NUM/2];
      |                  ^
a.cc:27:21: error: request for member 'first' in 'tmp1[j]', which is of non-class type 'int'
   27 |         if (tmp1[j].first <= tmp2[k].first) {
      |                     ^~~~~
a.cc:27:38: error: request for member 'first' in 'tmp2[k]', which is of non-class type 'int'
   27 |         if (tmp1[j].first <= tmp2[k].first) {
      |                                      ^~~~~
a.cc: At global scope:
a.cc:40:26: error: 'num' was not declared in this scope; did you mean 'enum'?
   40 | void MargeSort(pair<int, num> elem[], int start, int end)
      |                          ^~~
      |                          enum
a.cc:40:29: error: template argument 2 is invalid
   40 | void MargeSort(pair<int, num> elem[], int start, int end)
      |                             ^
a.cc: In function 'int main()':
a.cc:110:15: error: cannot convert 'std::pair<int, char>*' to 'int*'
  110 |     MargeSort(elem2, 0, num);
      |               ^~~~~
      |               |
      |               std::pair<int, char>*
a.cc:40:31: note:   initializing argument 1 of 'void MargeSort(int*, int, int)'
   40 | void MargeSort(pair<int, num> elem[], int start, int end)
      |                ~~~~~~~~~~~~~~~^~~~~~