Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

void SolveA()
{
	string s;
	cin >> s;

	const char *ss = s.c_str();

	int bee = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (ss[i] == '1')
		{
			bee++;
		}
	}

	printf("%d\n", bee);
}

void SolveB()
{
	int n;
	scanf("%d", &n);

	vector<int> A;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		A.push_back(tmp);
	}

	int counter = 0;
	bool flagLoop = true;
	while (flagLoop)
	{
		bool flagAllEven = true;
		for (int i = 0; i < n; i++)
		{
			if (A[i] % 2 != 0)
			{
				flagAllEven = false;
				flagLoop = false;
			}
		}
		if (flagAllEven == true)
		{
			for (int i = 0; i < n; i++)
			{
				A[i] /= 2;
			}
			counter++;
		}
	}

	printf("%d\n", counter);
}

bool vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

void SolveC()
{
	int N, K;
	scanf("%d %d", &N, &K);

	//int *numKind = new int[N]();
	vector<int> numKind;
	numKind.resize(N + 1, 0);
	int clock = 0;
	vector<int> kind;
	
	for (int i = 1; i < N + 1; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		if (vector_finder(kind, tmp))
		{
			numKind[tmp]++;
		}
		else
		{
			kind.push_back(tmp);
			numKind[tmp]++;
			clock++;
		}
	}

	if (clock <= K)
	{
		printf("0\n");
		return;
	}

	int cntChange = 0;
	while (clock > K)
	{
		int minIdx = kind[0];
		for (int i = 0; i < kind.size(); i++)
		{
			if (numKind[minIdx] == 0)
			{
				minIdx = kind[i];
			}
			else
			{
				if (numKind[kind[i]] < numKind[minIdx])
				{
					minIdx = kind[i];
				}
			}
		}
		while (numKind[minIdx] > 0)
		{
			numKind[minIdx]--;
			cntChange++;
		}
		clock--;
	}

	printf("%d\n", cntChange);
}

int main()
{
	//SolveA();
	//SolveB();
	SolveC();
}



Compiler output:
a.cc: In function 'bool vector_finder(std::vector<int>, int)':
a.cc:69:29: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   69 |         auto itr = std::find(vec.begin(), vec.end(), number);
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:4:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:69:29: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   69 |         auto itr = std::find(vec.begin(), vec.end(), number);
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~