Language: C++

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

struct TCard{
	int Number;
	char Mark;
    bool operator<=(const TCard &Y) const;
    bool operator==(const TCard &Y) const;	
};

bool TCard::operator<=(const TCard &Y) const
{
	return Number <= Y.Number;
}
bool TCard::operator==(const TCard &Y) const
{
	return Mark == Y.Mark;
}

int Partition(vector<TCard>& A, int p, int r)
{
	int i = p-1;
	for(int j = p; j < r; j++){
		if(A[j] <= A[r]){
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i+1], A[r]);
	return i+1;
}

void QuickSort(vector<TCard>& 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;
	cin >> n;
	vector<TCard> A(n);
	for(int i = 0; i < n; i++){
		cin >> A[i].Mark >> A[i].Number;
	}
	vector<TCard> B = A;
	std::stable_sort(B.begin(), B.end());
	QuickSort(A, 0, n-1);
	if(A == B){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
	for(int i = 0; i < n; i++){
		cout << A[i].Mark << ' ' << A[i].Number << endl;
	}
	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<TCard*, std::vector<TCard> >; _Iterator2 = __gnu_cxx::__normal_iterator<TCard*, std::vector<TCard> >]':
/usr/include/c++/14/bits/stl_algo.h:1777:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 1777 |           if (__comp(__i, __first))
      |               ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2748:25:   required from 'void std::__inplace_stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2748 |           std::__insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4956:28:   required from 'void std::__stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 4956 |         std::__inplace_stable_sort(__first, __last, __comp);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4994:36:   required from 'void std::stable_sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >]'
 4994 |       _GLIBCXX_STD_A::__stable_sort(__first, __last,
      |                                    ^
a.cc:53:18:   required from here
   53 |         std::stable_sort(B.begin(), B.end());
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'TCard' and 'TCard')
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1241 |     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'TCard' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1249 |     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'TCard' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<TCard*, std::vector<TCard> >; _Iterator2 = TCard*]':
/usr/include/c++/14/bits/stl_algo.h:2258:14:   required from 'void std::__move_merge_adaptive(_InputIterator1, _InputIterator1, _InputIterator2, _InputIterator2, _OutputIterator, _Compare) [with _InputIterator1 = TCard*; _InputIterator2 = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _OutputIterator = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2258 |           if (__comp(__first2, __first1))
      |               ~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2368:30:   required from 'void std::__merge_adaptive(_BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator, _Distance, _Distance, _Pointer, _Compare) [with _BidirectionalIterator = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Distance = long int; _Pointer = TCard*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2368 |           std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2369 |                                      __first, __comp);
      |                                      ~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2708:28:   required from 'void std::__stable_sort_adaptive(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Pointer, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Pointer = TCard*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2708 |       std::__merge_adaptive(__first, __middle, __last,
      |       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 2709 |                             __middle - __first, __last - __middle,
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2710 |                             __buffer, __comp);
      |                             ~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4952:29:   required from 'void std::__stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 4952 |         std::__stable_sort_adaptive(__first,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
 4953 |                                     __first + _DistanceType(__buf.size()),
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4954 |                                     __last, __buf.begin(), __comp);
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4994:36:   required from 'void std::stable_sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >]'
 4994 |       _GLIBCXX_STD_A::__stable_sort(__first, __last,
      |                                    ^
a.cc:53:18:   required from here
   53 |         std::stable_sort(B.begin(), B.end());
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'TCard' and 'TCard')
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1241 |     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'TCard' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1249 |     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:45:23: note:   'TCard' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   45 |       { return *__it1 < *__it2; }
      |                ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = TCard*; _Iterator2 = __gnu_cxx::__normal_iterator<TCard*, std::vector<TCard> >]':
/usr/include/c++/14/bits/stl_algo.h:2297:14:   required from 'void std::__move_merge_adaptive_backward(_BidirectionalIterator1, _BidirectionalIterator1, _BidirectionalIterator2, _BidirectionalIterator2, _BidirectionalIterator3, _Compare) [with _BidirectionalIterator1 = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _BidirectionalIterator2 = TCard*; _BidirectionalIterator3 = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2297 |           if (__comp(__last2, __last1))
      |               ~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2374:39:   required from 'void std::__merge_adaptive(_BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator, _Distance, _Distance, _Pointer, _Compare) [with _BidirectionalIterator = __gnu_cxx::__normal_iterator<TCard*, vector<TCard> >; _Distance = long int; _Pointer = TCard*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2374 |           std::__move_merge_adaptive_backward(__first, __middle, __buffer,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2375 |                                               __buffer_end, __last, __c