Language: C++

#include <cstdio>
#include <cstdlib>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
map<string,bool> bmap;
short card[10];
short select[4],temp[4];
bool used[10];
int n,k,num;
void solve(int m) {
	if(m==k) {
		for(int i=0;i<k;i++)temp[i]=select[i];
		do {
			stringstream str;
			for(int i=0;i<k;i++)str<<(int)select[i];
			if(bmap.find(str.str())==bmap.end())num++;
			bmap[str.str()]=true;
		}while(next_permutation(select,select+k));
		for(int i=0;i<k;i++)select[i]=temp[i];
	}else {
		for(int i=0;i<n;i++) {
			if(used[i]==false) {
				used[i]=true;
				select[m]=card[i];
				solve(m+1); 
				used[i]=false;
			}
		}
	}
}
int main() {
	while(scanf("%d %d",&n,&k),n) {
		for(int i=0;i<n;i++)scanf("%d",&card[i]);
		fill(used,used+10,0);
		bmap.clear();
		num=0;
		solve(0);
		printf("%d\n",num);
	}
}

Compiler output:
a.cc:11:15: error: 'short int select [4]' redeclared as different kind of entity
   11 | short select[4],temp[4];
      |               ^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:514,
                 from /usr/include/c++/14/cstdlib:79,
                 from a.cc:2:
/usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
  102 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~
a.cc: In function 'void solve(int)':
a.cc:16:53: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |                 for(int i=0;i<k;i++)temp[i]=select[i];
      |                                                     ^
a.cc:16:53: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'short int' [-fpermissive]
   16 |                 for(int i=0;i<k;i++)temp[i]=select[i];
      |                                             ~~~~~~~~^
      |                                                     |
      |                                                     int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)
a.cc:19:63: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |                         for(int i=0;i<k;i++)str<<(int)select[i];
      |                                                               ^
a.cc:19:50: error: cast from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'int' loses precision [-fpermissive]
   19 |                         for(int i=0;i<k;i++)str<<(int)select[i];
      |                                                  ^~~~~~~~~~~~~~
a.cc:22:54: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |                 }while(next_permutation(select,select+k));
      |                                                ~~~~~~^~
a.cc:23:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   23 |                 for(int i=0;i<k;i++)select[i]=temp[i];
      |                                             ^
a.cc:23:46: error: assignment of read-only location '*(select + ((sizetype)i))'
   23 |                 for(int i=0;i<k;i++)select[i]=temp[i];
      |                                     ~~~~~~~~~^~~~~~~~
a.cc:28:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |                                 select[m]=card[i];
      |                                         ^
a.cc:28:42: error: assignment of read-only location '*(select + ((sizetype)m))'
   28 |                                 select[m]=card[i];
      |                                 ~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_tree.h:63,
                 from /usr/include/c++/14/map:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]':
/usr/include/c++/14/bits/stl_algo.h:2910:22:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2910 |               std::iter_swap(__i, __j);
      |               ~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:22:26:   required from here
   22 |                 }while(next_permutation(select,select+k));
      |                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:185:11: error: no matching function for call to 'swap(int (&)(int, fd_set*, fd_set*, fd_set*, timeval*), int (&)(int, fd_set*, fd_set*, fd_set*, timeval*))'
  185 |       swap(*__a, *__b);
      |       ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
                 from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::__enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = void]':
/usr/include/c++/14/type_traits:2323:11:   required by substitution of 'template<class ... _Cond> using std::_Require = std::__enable_if_t<((bool)std::__and_<_Bn>::value)> [with _Cond = {std::__not_<std::__is_tuple_like<int(int, fd_set*, fd_set*, fd_set*, timeval*)> >, std::is_move_constructible<int(int, fd_set*, fd_set*, fd_set*, timeval*)>, std::is_move_assignable<int(int, fd_set*, fd_set*, fd_set*, timeval*)>}]'
 2323 |     using _Require = __enable_if_t<__and_<_Cond...>::value>;
      |           ^~~~~~~~
/usr/include/c++/14/bits/move.h:226:5:   required by substitution of 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = int(int, fd_set*, fd_set*, fd_set*, timeval*)]'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/stl_algobase.h:185:11:   required from 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]'
  185 |       swap(*__a, *__b);
      |       ~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2910:22:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2910 |               std::iter_swap(__i, __j);
      |               ~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:22:26:   required from here
   22 |                 }while(next_permutation(select,select+k));
      |                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/type_traits:138:11: error: no type named 'type' in 'struct std::enable_if<false, void>'
  138 |     using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _ForwardIterator2 = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]':
/usr/include/c++/14/bits/stl_algo.h:2910:22:   required from 'bool std::__next_permutation(_BidirectionalIterator, _BidirectionalIterator, _Compare) [with _BidirectionalIterator = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*); _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 2910 |               std::iter_swap(__i, __j);
      |               ~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2951:2:   required from 'bool std::next_permutation(_BIter, _BIter) [with _BIter = int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)]'
 2950 |       return std::__next_permutation
      |              ~~~~~~~~~~~~~~~~~~~~~~~
 2951 |         (__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:22:26:   required from here
   22 |                 }while(next_permutation(select,select+k));
      |                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
  250 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~
/usr/include/c++/14/bits/move.h:250:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:185:11: note:   mismatched types '_Tp [_Nm]' and 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
  185 |       swap(*__a, *__b);
      |       ~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
 1089 |     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algobase.h:185:11: note:   mismatched types 'std::pair<_T1, _T2>' and 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
  185 |       swap(*__a, *__b);
      |       ~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
 1106 |     swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note:   template argument ded