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<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 <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:17: error: need 'typename' before 'std::__cxx11::list<T>::iterator' because 'std::__cxx11::list<T>' is a dependent scope
   39 |                 list<T>::iterator it1 = arr.begin(), it2 = arr.begin();
      |                 ^~~~~~~
a.cc:39:34: error: expected ';' before 'it1'
   39 |                 list<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:57:9: error: need 'typename' before 'std::__cxx11::list<T>::iterator' because 'std::__cxx11::list<T>' is a dependent scope
   57 |         list<T>::iterator it1, it2, min, itend = arr.end();
      |         ^~~~~~~
a.cc:57:26: error: expected ';' before 'it1'
   57 |         list<T>::iterator it1, it2, min, itend = arr.end();
      |                          ^~~~
      |                          ;
a.cc:58:14: error: 'it1' was not declared in this scope
   58 |         for (it1 = arr.begin(); it1 != itend; advance(it1, 1))
      |              ^~~
a.cc:58:40: error: 'itend' was not declared in this scope
   58 |         for (it1 = arr.begin(); it1 != itend; advance(it1, 1))
      |                                        ^~~~~
a.cc:61:22: error: 'it2' was not declared in this scope
   61 |                 for (it2 = next(it1); it2 != itend; advance(it2, 1))
      |                      ^~~
a.cc:63:37: error: overloaded function with no contextual type information
   63 |                         if (*it2 < *min)
      |                                     ^~~
a.cc:68:37: error: overloaded function with no contextual type information
   68 |                         swap(*it1, *min);
      |                                     ^~~
a.cc: In instantiation of 'int bubbleSort(std::__cxx11::list<T>&, int) [with T = int]':
a.cc:126:19:   required from here
  126 |         cunt = bubbleSort(arr, n);
      |                ~~~~~~~~~~^~~~~~~~
a.cc:39:26: error: dependent-name 'std::__cxx11::list<T>::iterator' is parsed as a non-type, but instantiation yields a type
   39 |                 list<T>::iterator it1 = arr.begin(), it2 = arr.begin();
      |                          ^~~~~~~~
a.cc:39:26: note: say 'typename std::__cxx11::list<T>::iterator' if a type is meant