Language: C++

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

int Upper_Num(int num, vector<int> n_d){
	for (int i = 0; i < n_d.size(); ++i){
		if (n_d[i] > num)return n_d[i];
	}
	return -1;
}

int main(){
	string N;
	int K;
	cin >> N >> K;
	vector<int> D(K);
	for (int i = 0; i < K; ++i){
		cin >> D[i];
	}

	vector<int> N_D;
	for (int i = 0; i < 10; ++i){
		if (find(D.begin(), D.end(), i) == D.end()){
			N_D.push_back(i);
		}
	}

	int max_index = -1;
	for (int i = 0; i < N.size(); ++i){
		if (find(D.begin(), D.end(), N[i] - '0') != D.end()){
			max_index = i;
		}
	}
	
	if (max_index == -1){
		cout << N << endl;
		return 0;
	}

	while (true){
		if (max_index + 1 > N.size()){
			for (int i = 0; i < N.size(); ++i){
				if (N_D[0]==0)N[i] = '0';
				else N[i] = '0' + N_D[1];
			}
			cout << N_D[1] << N << endl;
			return 0;
		}

		if (Upper_Num(N[max_index] - '0', N_D) != -1){
			N[max_index] = Upper_Num(N[max_index] - '0', N_D) + '0';
			for (int i = max_index - 1; i >= 0; --i){
				N[i] = N_D[0] + '0';
			}
			break;
		}
		else{
			++max_index;
		}
	}

	cout << N << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:25: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   24 |                 if (find(D.begin(), D.end(), i) == D.end()){
      |                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~
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:1:
/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:24:25: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   24 |                 if (find(D.begin(), D.end(), i) == D.end()){
      |                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:31:25: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
   31 |                 if (find(D.begin(), D.end(), N[i] - '0') != D.end()){
      |                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:31:25: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   31 |                 if (find(D.begin(), D.end(), N[i] - '0') != D.end()){
      |                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~