Language: C++

include <iostream>
#include <cassert>

struct Card {
  char suit;
  int value;
};


void bubble_sort(Card cards[], const int n) {
  bool sorted;

  while(!sorted) {
    sorted = true;
    for (int i = n - 1; i > 0; i--) {
      if (cards[i].value < cards[i - 1].value) {
        Card tmp = cards[i];
        cards[i] = cards[i - 1];
        cards[i - 1] = tmp;
        sorted = false;
      }
    }
  }
}

void selection_sort(Card cards[], int n) {
  for (int i = 0; i < n; i++) {
    int min_index = i;
    for (int j = i + 1; j < n; j++) {
      if (cards[j].value < cards[min_index].value) {
        min_index = j;
      }
    }
    if (cards[min_index].value < cards[i].value) {
      Card tmp = cards[i];
      cards[i] = cards[min_index];
      cards[min_index] = tmp;
    }
  }
}


bool is_stable(Card input[], Card sorted[], int n) {
  for (int i = 0; i < n - 1; i++) {
    if (sorted[i].value == sorted[i+1].value) {
      for (int j = 0; j < n; j++) {
        if (input[j].value == sorted[i].value) {
          if (input[j].suit == sorted[i].suit) {
            return true;
          } else if (input[j].suit == sorted[i+1].suit) {
            return false;
          }
        }
      }
    }
  }
  assert(true);
  return false;
}


int main() {
  const int BUF_SIZE = 36;
  Card input[BUF_SIZE];
  int n;
  Card sorted[BUF_SIZE];
 bool stable = false;

  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> input[i].suit >> input[i].value;
  }

  for (int i = 0; i < n; i++) {
    sorted[i] = input[i];
  }

  bubble_sort(sorted, n);

  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      std::cout << sorted[i].suit << sorted[i].value << std::endl;
    }
    else {
      std::cout << sorted[i].suit << sorted[i].value << " ";
    }
  }


  if (is_stable(input, sorted, n)) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }

  for (int i = 0; i < n; i++) {
    sorted[i] = input[i];
  }

  selection_sort(sorted, n);

  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      std::cout << sorted[i].suit << sorted[i].value << std::endl;
    }
    else {
      std::cout << sorted[i].suit << sorted[i].value << " ";
    }
  }

  if (is_stable(input, sorted, n)) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }

  return 0;
}



Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:69:8: error: 'cin' is not a member of 'std'
   69 |   std::cin >> n;
      |        ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <cassert>
  +++ |+#include <iostream>
    3 | 
a.cc:71:10: error: 'cin' is not a member of 'std'
   71 |     std::cin >> input[i].suit >> input[i].value;
      |          ^~~
a.cc:71:10: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:82:12: error: 'cout' is not a member of 'std'
   82 |       std::cout << sorted[i].suit << sorted[i].value << std::endl;
      |            ^~~~
a.cc:82:12: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:82:62: error: 'endl' is not a member of 'std'
   82 |       std::cout << sorted[i].suit << sorted[i].value << std::endl;
      |                                                              ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <cassert>
  +++ |+#include <ostream>
    3 | 
a.cc:85:12: error: 'cout' is not a member of 'std'
   85 |       std::cout << sorted[i].suit << sorted[i].value << " ";
      |            ^~~~
a.cc:85:12: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:91:10: error: 'cout' is not a member of 'std'
   91 |     std::cout << "Stable" << std::endl;
      |          ^~~~
a.cc:91:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:91:35: error: 'endl' is not a member of 'std'
   91 |     std::cout << "Stable" << std::endl;
      |                                   ^~~~
a.cc:91:35: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:93:10: error: 'cout' is not a member of 'std'
   93 |     std::cout << "Not stable" << std::endl;
      |          ^~~~
a.cc:93:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:93:39: error: 'endl' is not a member of 'std'
   93 |     std::cout << "Not stable" << std::endl;
      |                                       ^~~~
a.cc:93:39: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:104:12: error: 'cout' is not a member of 'std'
  104 |       std::cout << sorted[i].suit << sorted[i].value << std::endl;
      |            ^~~~
a.cc:104:12: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:104:62: error: 'endl' is not a member of 'std'
  104 |       std::cout << sorted[i].suit << sorted[i].value << std::endl;
      |                                                              ^~~~
a.cc:104:62: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:107:12: error: 'cout' is not a member of 'std'
  107 |       std::cout << sorted[i].suit << sorted[i].value << " ";
      |            ^~~~
a.cc:107:12: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:112:10: error: 'cout' is not a member of 'std'
  112 |     std::cout << "Stable" << std::endl;
      |          ^~~~
a.cc:112:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:112:35: error: 'endl' is not a member of 'std'
  112 |     std::cout << "Stable" << std::endl;
      |                                   ^~~~
a.cc:112:35: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:114:10: error: 'cout' is not a member of 'std'
  114 |     std::cout << "Not stable" << std::endl;
      |          ^~~~
a.cc:114:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:114:39: error: 'endl' is not a member of 'std'
  114 |     std::cout << "Not stable" << std::endl;
      |                                       ^~~~
a.cc:114:39: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'