Language: C++

#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
#define A

struct card
{
	card(const card&a) {
		mark = a.mark;
		num = a.num;
	}
	card(const char* str)
	{
		*this = str;
	}
	card() {}

	char mark;
	int	num;

	void operator = (const char * str) {
		mark = str[0];
		num = str[1] - 0x30;
	}
	bool operator < ( const card & right)const {
		return num < right.num;
	}


};

template<typename T>
int bubbleSort(list<T>&arr, int n) {
	int cunt = 0;
	bool cont = true;
	while (cont)
	{
		list<typename T>::iterator it1 = arr.begin(), it2 = arr.begin();
		advance(it2, 1);
		cont = false;
		for (int i = 1; i < n; ++i, advance(it1, 1), advance(it2, 1))
		{
			if ( *it2 < *it1 ) {
				swap(*it1, *it2);
				cont = true;
				cunt++;
			}
		}
	}
	return cunt;
}
//template int bubbleSort(list<int>&arr, int n);

template <typename T>
int selectionSort(list<T>& arr, int n) {
	int cunt = 0;
	list<T>::iterator it1, it2, min, itend = arr.end();
	for (it1 = arr.begin(); it1 != itend; advance(it1, 1))
	{
		min = it1;
		for (it2 = next(it1); it2 != itend; advance(it2, 1))
		{
			if (*it2 < *min)
				min = it2;
		}
		if (it1 != min) {
			cunt++;
			swap(*it1, *min);
		}
	}
	return cunt;
}

void listPrint(list<int>& arr) {
	list<int>::iterator it = arr.begin(),itend = arr.end();
	cout << *it;
	advance(it, 1);
	for (; it != itend; advance(it, 1))
		cout << " " << *it;
	cout << endl;
}

#ifdef D
int main(void)
{
	int n;
	cin >> n;
	list<card> arr1, arr2;
	char str[3];
	for (int i = 0 ; i< n; ++i)
	{
		cin >> str;
		card c(str);
		arr1.push_back(c);
		arr2.push_back(c);
	}

	return 0;
}
#endif // D

#ifdef B
int main(void)
{
	int n;
	cin >> n;
	list<int> arr(n);
	for (auto &a : arr)
		cin >> a;
	int cunt = selectionSort(arr,n);
	listPrint(arr);
	cout <<  cunt << endl;
	return 0;
}
#endif // B

#ifdef A
int main(void)
{
	int cunt = 0;
	int n;
	cin >> n;
	list<int> arr(n);
	for (auto& a : arr)
		cin >> a;
	cunt = bubbleSort(arr, n);
	listPrint(arr);
	cout << cunt << endl;
	return 0;
}
#endif // A

Compiler output:
a.cc: In function 'int bubbleSort(std::__cxx11::list<T>&, int)':
a.cc:39:32: error: template argument 1 is invalid
   39 |                 list<typename T>::iterator it1 = arr.begin(), it2 = arr.begin();
      |                                ^
a.cc:39:32: error: template argument 2 is invalid
a.cc:39:44: error: qualified-id in declaration before 'it1'
   39 |                 list<typename T>::iterator it1 = arr.begin(), it2 = arr.begin();
      |                                            ^~~
a.cc:40:25: error: 'it2' was not declared in this scope
   40 |                 advance(it2, 1);
      |                         ^~~
a.cc:42:53: error: 'it1' was not declared in this scope
   42 |                 for (int i = 1; i < n; ++i, advance(it1, 1), advance(it2, 1))
      |                                                     ^~~
a.cc: In function 'int selectionSort(std::__cxx11::list<T>&, int)':
a.cc:58:9: error: need 'typename' before 'std::__cxx11::list<T>::iterator' because 'std::__cxx11::list<T>' is a dependent scope
   58 |         list<T>::iterator it1, it2, min, itend = arr.end();
      |         ^~~~~~~
a.cc:58:26: error: expected ';' before 'it1'
   58 |         list<T>::iterator it1, it2, min, itend = arr.end();
      |                          ^~~~
      |                          ;
a.cc:59:14: error: 'it1' was not declared in this scope
   59 |         for (it1 = arr.begin(); it1 != itend; advance(it1, 1))
      |              ^~~
a.cc:59:40: error: 'itend' was not declared in this scope
   59 |         for (it1 = arr.begin(); it1 != itend; advance(it1, 1))
      |                                        ^~~~~
a.cc:62:22: error: 'it2' was not declared in this scope
   62 |                 for (it2 = next(it1); it2 != itend; advance(it2, 1))
      |                      ^~~
a.cc:64:37: error: overloaded function with no contextual type information
   64 |                         if (*it2 < *min)
      |                                     ^~~
a.cc:69:37: error: overloaded function with no contextual type information
   69 |                         swap(*it1, *min);
      |                                     ^~~