Language: C++

int minBigger(int i,string& N,string& ans,set<char>& avlb){
	while (i >= 0){
		for (auto& el : avlb){
			if (el > N[i]){
				ans[i] = el;
				return i;
			}
		}
		i--;
	}
}
int main()
{
	set<char> avlb = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
	int K;
	string N;
	cin >> N >> K;
	for (int i = 0; i < K; ++i){
		char t;
		cin >> t;
		avlb.erase(t);
	}
	int len = N.length();
	N = '0' + N;
	string ans;
	ans.resize(len + 1);
	for (int i = 1; i <= len; ++i){
		if (avlb.find(N[i]) == avlb.end()){
			i = minBigger(i, N, ans, avlb);
			int j = i + 1;
			while (j <= len){
				ans[j] = *avlb.begin();
				j++;
			}
		}
		else{
			ans[i] = N[i];
		}
	}
	if (ans[0] == '\0'){ 
		ans=ans.substr(1, len + 1); 
	}
	cout << ans;
	return 0;
}

Compiler output:
a.cc:1:21: error: 'string' has not been declared
    1 | int minBigger(int i,string& N,string& ans,set<char>& avlb){
      |                     ^~~~~~
a.cc:1:31: error: 'string' has not been declared
    1 | int minBigger(int i,string& N,string& ans,set<char>& avlb){
      |                               ^~~~~~
a.cc:1:43: error: 'set' has not been declared
    1 | int minBigger(int i,string& N,string& ans,set<char>& avlb){
      |                                           ^~~
a.cc:1:46: error: expected ',' or '...' before '<' token
    1 | int minBigger(int i,string& N,string& ans,set<char>& avlb){
      |                                              ^
a.cc: In function 'int minBigger(int, int&, int&, int)':
a.cc:3:33: error: 'avlb' was not declared in this scope
    3 |                 for (auto& el : avlb){
      |                                 ^~~~
a.cc:4:35: error: invalid types 'int[int]' for array subscript
    4 |                         if (el > N[i]){
      |                                   ^
a.cc:5:36: error: invalid types 'int[int]' for array subscript
    5 |                                 ans[i] = el;
      |                                    ^
a.cc: In function 'int main()':
a.cc:14:9: error: 'set' was not declared in this scope
   14 |         set<char> avlb = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
      |         ^~~
a.cc:14:13: error: expected primary-expression before 'char'
   14 |         set<char> avlb = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
      |             ^~~~
a.cc:16:9: error: 'string' was not declared in this scope
   16 |         string N;
      |         ^~~~~~
a.cc:17:9: error: 'cin' was not declared in this scope
   17 |         cin >> N >> K;
      |         ^~~
a.cc:17:16: error: 'N' was not declared in this scope
   17 |         cin >> N >> K;
      |                ^
a.cc:21:17: error: 'avlb' was not declared in this scope
   21 |                 avlb.erase(t);
      |                 ^~~~
a.cc:25:15: error: expected ';' before 'ans'
   25 |         string ans;
      |               ^~~~
      |               ;
a.cc:26:9: error: 'ans' was not declared in this scope
   26 |         ans.resize(len + 1);
      |         ^~~
a.cc:28:21: error: 'avlb' was not declared in this scope
   28 |                 if (avlb.find(N[i]) == avlb.end()){
      |                     ^~~~
a.cc:43:9: error: 'cout' was not declared in this scope
   43 |         cout << ans;
      |         ^~~~
a.cc: In function 'int minBigger(int, int&, int&, int)':
a.cc:11:1: warning: control reaches end of non-void function [-Wreturn-type]
   11 | }
      | ^