stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

template <class T> string toStr(T par) {

	ostringstream oss;

	oss<<par;

	return oss.str();

}

string s;

int n, k, q, dislikes[11];

int main()

{

    cin >> n >> k;

    for(int i = 0; i < k ; i++)

    {

        cin >> q;

        dislikes[q] = 1;

    }



    while(true)

    {

        int prev_n = n, cnt = 0;

        bool ok = false;

        s = toStr(n);

        for(int i = s.size() - 1; i >= 0; i--)

        {

            if(dislikes[s[i] - '0'])

                ok = true;

        }

        if(ok) n++;

        else break;

    }

    cout << n << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.6410646915044331x):
                #include<bits/stdc++.h>

                using namespace std;

                typedef long long ll;

                #define MAX 200005

                bool arr[12];

                bool chk(int a)

                {

                    while(a > 0)

                    {

                        int c = a % 10;

                        if(arr[c])return false;

                        a /= 10;

                    }

                    return true;

                }

                int main()

                {

                      int n,k;scanf("%d%d",&n,&k);



                      for(int i = 0 ; i < k ; i++)

                      {

                            int a;scanf("%d",&a);

                            arr[a] = true;

                      }

                      for(int i = n ; ; i++)

                      {

                            if(chk(i))

                            {

                                printf("%d\n",i);

                                break;

                            }

                      }



                }
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

int num[100005];

bool judge(int n)

{

	while(n)

	{

		int b=n%10;

		if(num[b])

		{

		  	return false;

		}

	   n/=10;	  

	}

	return true;

}

int main()

{

	int N,K;

	while(scanf("%d%d",&N,&K)!=EOF)

	{

		memset(num,0,sizeof(num));

		int k;

		for(int i=0;i<K;i++)

		{

			scanf("%d",&k);

			  num[k]=1;

		}

		for(int i=N;;i++)

		{

			if(judge(i))

			{

				printf("%d\n",i);

				break;

			}

		}

	}

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.414676412839494x):
                #include<bits/stdc++.h>

                using namespace std;

                typedef long long ll;

                #define MAX 200005

                bool arr[12];

                bool chk(int a)

                {

                    while(a > 0)

                    {

                        int c = a % 10;

                        if(arr[c])return false;

                        a /= 10;

                    }

                    return true;

                }

                int main()

                {

                      int n,k;scanf("%d%d",&n,&k);



                      for(int i = 0 ; i < k ; i++)

                      {

                            int a;scanf("%d",&a);

                            arr[a] = true;

                      }

                      for(int i = n ; ; i++)

                      {

                            if(chk(i))

                            {

                                printf("%d\n",i);

                                break;

                            }

                      }



                }
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main()

{

  int n, k; cin >> n >> k;

  vector<char> d;

  for (int i = 0; i < k; i++) {

	char t; cin >> t;

	d.push_back(t);

  }

  while (true) {

	bool flag = true;

	string s = to_string(n);

	for (int i = 0; i < s.size(); i++) {

	  for (int j = 0; j < k; j++) {

		if (s[i] == d[j]) {

		  flag = false;

		}

	  }

	}

	if (flag) {

	  cout << n << endl;

	  return 0;

	}

	n++;

  }

  return 0;

}




// Faster C++ solution for the same problem (measured speedup: 1.1703364129479081x):
#include <bits/stdc++.h>

using namespace std;



int main() {

	ios::sync_with_stdio(false);

	cin.tie(0);  

	

	int n, k;

	cin >> n >> k;

	vector<int> num(10);

	for(int i = 0; i < k; i++) {

		int x;

		cin >> x;

		num[x]++;

	}

	while(true) {

		int m = n;

		bool ok = true;

		while(m > 0) {

			if(num[m % 10]) ok = false;

			m /= 10;

		}

		if(ok) {

			cout << n << endl;

			return 0;

		}

		n++;

	}

	return 0;	

}
// Slower C++ solution:
#include<iostream>

#include<string.h>

using namespace std;



int main(){ 

  int n, k;

  cin >> n >> k;

  int nums[10]{};

  

  while(k--){

    int index;

    cin >> index;

    nums[index]++;

  }



  bool found = false;

  int pay = n;

    

  while(!found){

	string money =  to_string(pay);

    bool have = true;

    for(int i=0;i<money.length();++i){

    	char c = money[i];

      	int digit = c -'0';

      	if(nums[digit]==1){

        	have = false;

          	break;

        }

    }

    if(have) found = true;

    else pay++;

  }

  cout << pay << endl;

  

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1672688282648083x):
#include <bits/stdc++.h>



using namespace std;



int digits[10];



bool works(int x){

	bool is = true;

	while(x){

		int d = x%10;

		if(digits[d]==1){

			is = false;

			break;

		}

		x/=10;

	}

	return is;

}



int main(){

	int n,k;

	cin >> n >> k;



	while(k--){

		int c;

		cin >> c;

		digits[c] = 1;

		//cout << "se marco el digito " << c << endl;

	}

	bool found = false;

	while(!found){

		if(works(n))break;

		else{

			n++;

		}

	}

	cout << n << endl;



	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <climits>

#include <algorithm>

#include <cmath>

#include <map>

#include <set>

#include <string>

#include <bitset>

#include <utility>

#include <numeric>

#include <queue>

#include <stack>



using ll = long long;

using namespace std;



constexpr int MOD = 1e9 + 7;

constexpr ll MOD_LL = ll(1e9 + 7);



int main(void) {

	int n, k;

	cin >> n >> k;

	

	vector<int> ng(10, 0);

	for(int i = 0; i < k; ++i) {

		int a;

		cin >> a;

		ng[a] = 1;

	}

	

	for(int i = n; i < 100000; ++i) {

		int tmp = i;

		vector<int> digits;

		

		while( tmp ) {

			digits.push_back(tmp % 10);

			tmp /= 10;

		}

		

		bool ok = true;

		for(int j = 0; j < digits.size(); ++j) {

			if( ng[digits[j]] == 1 ) {

				ok = false;

				break;

			}

		}

		

		if( ok && n <= i ) {

			cout << i << endl;

			return 0;

		}

	}

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.128856961078483x):
#include <iostream>

#include <vector>

#include <climits>

#include <algorithm>

#include <cmath>

#include <map>

#include <set>

#include <string>

#include <bitset>

#include <utility>

#include <numeric>

#include <queue>

#include <stack>



using ll = long long;

using namespace std;



constexpr int MOD = 1e9 + 7;

constexpr ll MOD_LL = ll(1e9 + 7);



int main(void) {

	int n, k;

	cin >> n >> k;

	

	vector<int> ng(10, 0);

	for(int i = 0; i < k; ++i) {

		int a;

		cin >> a;

		ng[a] = 1;

	}

	

	for(int i = n; i < 100000; ++i) {

		int tmp = i;

		bool ok = true;

		

		while( tmp ) {

			if( ng[tmp % 10] == 1 ) {

				ok = false;

				break;

			}

			

			tmp /= 10;

		}

		

		if( ok && n <= i ) {

			cout << i << endl;

			break;

		}

	}

	

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;



int main()

{

	int n, k;

	cin >> n >> k;

	vector<int> d(k);

	for(auto &ref : d){

		cin >> ref;

	}



	while(true){

		string str_n = to_string(n);

		bool find_f = false;

		for(auto i : d){

			if(str_n.find(to_string(i)) != -1){//嫌いな数字が含まれていた場合

				find_f = true;

			}

		}

		if(!find_f){//嫌いな数字が一つも含まれていなかった場合

			break;//ループを抜けて出力

		}

		n++;

	}

	cout << n;

}


// Faster C++ solution for the same problem (measured speedup: 1.8999329305281762x):
#include <iostream>

#include <vector>



using namespace std;



int main()

{

	int n, k;

	cin >> n >> k;

	vector<int> d(k);

	for(auto &ref : d){

		cin >> ref;

	}



	while(true){

		string str_n = to_string(n);

		bool find_f = false;

		for(auto i : d){

			if(str_n.find(to_string(i)) != -1){//嫌いな数字が含まれていた場合

				find_f = true;

				break;

			}

		}

		if(!find_f){//嫌いな数字が一つも含まれていなかった場合

			break;//ループを抜けて出力

		}

		n++;

	}

	cout << n;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int k, n;

bool disliked[125];

 

bool cek(int x) {

    while(x > 0) {

        int now = x % 10;

        if(disliked[now]) return false;

        x /= 10;

    }

	return true;

}

 

int main() {

	scanf("%d %d", &n, &k);

	for(int i = 0 ; i < 123 ; i++) disliked[i] = false;

    for(int i = 0 ; i  < k ; i++ ) {

        int qwe;

        scanf("%d", &qwe);

        disliked[qwe] = true;

    }

 

	for(int i = n ; i < INT_MAX-1 ; i++) {

		if(cek(i)) {

			printf("%d\n", i);

			return 0;

		}

	}

 

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.054370325236817x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

int n,k;

char a[15];

bool num[15];



bool check(int a) {

    int cnt=0;

    while (a) {

        if (!num[a%10]) return false;

        a/=10;

    }

    return true;

}



int main() {

    memset(num,1,sizeof(num));

    scanf("%d%d",&n,&k);

    int tmp;

    for (int i=1;i<=k;i++) {

        scanf("%d",&tmp);

        num[tmp]=0;

    }

    int ans=n;

    while (!check(ans)) ans++;

    printf("%d\n", ans);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int gl(int x)

{

	using namespace std;

	int leng=0;

	while(x)

	{

		x/=10;

		leng++;

	}

	return leng;

}

int main()

{

	int n, k;

	cin>>n>>k;

	int no[10] = {0};

	for(int i = 1; i <= k; i++){

		int t;

		cin>>t;

		no[t] = 1;

	}

	int nown = n;

	while(1){

        int len = gl(nown);

        int cnt = 0;

		int flag = 0;

		int nownn;

		int nownt = nown;

		while(1){

            nownn = nownt % 10;

            nownt /= 10;

            cnt++;

            if(cnt > len)break;

			if(no[nownn] == 1){

				flag = 1;

				break;

			}

		}

		if(flag == 0){

			cout<<nown;

			break;

		}

		nown++;

	}

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.174442872151722x):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

int n,k;

char a[15];

bool num[15];



bool check(int a) {

    int cnt=0;

    while (a) {

        if (!num[a%10]) return false;

        a/=10;

    }

    return true;

}



int main() {

    memset(num,1,sizeof(num));

    scanf("%d%d",&n,&k);

    int tmp;

    for (int i=1;i<=k;i++) {

        scanf("%d",&tmp);

        num[tmp]=0;

    }

    int ans=n;

    while (!check(ans)) ans++;

    printf("%d\n", ans);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long llong;



int main(void) {

	int n, k; cin >> n >> k;

	vector<int> dislike(k);

	for (int i = 0; i < k; i++) cin >> dislike[i];



	for (int x = n; x < 100000; x++) {

		int tmp = x;

		set<int> s;

		while (tmp != 0) {

			s.insert(tmp % 10);

			tmp /= 10;

		}



		bool flag = true;



		for (int i = 0; i < k; i++) {

			if (s.count(dislike[i])) {

				flag = false;

				break;

			}

		}

		if (flag) {

			cout << x << endl;

			break;

		}

	}



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1928046019461347x):
#include <bits/stdc++.h>

using namespace std;

typedef long long llong;



int main(void) {

	int n, k; cin >> n >> k;

	vector<int> dislike(10);

	for (int i = 0; i < k; i++) {

		int a; cin >> a;

		dislike[a]++; //嫌いな数字の添え字に1を立てる

	}



	int ans = n;

	while (true) {

		bool flag = true;

		int tmp = ans;

		while (tmp != 0) {

			// 嫌いな数字が含まれているかチェックする

			if (dislike[tmp % 10] == 1) {

				flag = false;

				break;

			}

			tmp /= 10;

		}



		if (flag) {

			cout << ans << endl;

			break;

		}

		ans++;

	}



	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main(){

  int N,K; cin >> N >> K;

  

  vector<int> vec; 

  for(int i = 0; i < K; i++){

    int d; cin >> d;  vec.push_back(d);}

  

  for(int i = N; i < 100000; i++){

    

    bool flag = true;

    

    int tmp = i;

    set<int> s;

    while( tmp > 0){

      s.insert( tmp% 10); tmp /= 10;}

    //　s中にあって、vecにもある数があればfalse

    for(int j = 0; j < K; j++){

      if(s.count( vec[j])){ flag = false;} }

    

    if( flag){ cout << i << endl; break;}

  }

  

  return 0;}

    

    

// Faster C++ solution for the same problem (measured speedup: 1.2538543751922593x):
#include<bits/stdc++.h>



using namespace std;



int main(){

  int N,K; cin >> N >> K;

 vector<int> vec(11);

  for(int i = 0; i < K; i++){ int k; cin >> k; vec[k]++;}

  int ans;

  for(int x = N; x < 10000000; x++){

    //xが答えなりうるかを調べる

    int tmp = x; bool flag = true;

    while(tmp > 0){ 

      int c = tmp% 10; 

      if( vec[c] > 0){ flag = false; }

      tmp /= 10;}

    

    if( flag ){  ans = x; break;}

  }

  

  cout << ans << endl; return 0;}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main(){

  int N,K; cin >> N >> K;

  

  vector<int> vec; 

  for(int i = 0; i < K; i++){

    int d; cin >> d;  vec.push_back(d);}

  

  for(int i = N; i < 100000; i++){

    

    bool flag = true;

    

    int tmp = i;

    set<int> s;

    while( tmp > 0){

      s.insert( tmp% 10); tmp /= 10;}

    //　s中にあって、vecにもある数があればfalse

    for(int j = 0; j < K; j++){

      if(s.count( vec[j])){ flag = false;} }

    

    if( flag){ cout << i << endl; break;}

  }

  

  return 0;}

    

    

// Faster C++ solution for the same problem (measured speedup: 1.25549324493737x):
#include<bits/stdc++.h>



using namespace std;



bool num[10];

// true →　useable



int main(){

int N,K; 

 cin >> N >> K;

  

  for(int i = 0; i < 10; i++){ num[i] = true;}

  

  for(int i = 0; i < K; i++){

    int d; cin >> d;

    num[d] = false;}

  

 

  int pay = N;

  

  while(1){

     int k = pay; bool flag = true;

    while( k > 0){

     if( !num[k % 10]){ flag = false;}

      k /= 10;}

    

    if( flag){ break; }

    pay++;

  }

  

  cout << pay << endl; return 0;}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<string>

#include<map>

using namespace std;



int main(){

    int n, k;

    cin >> n >> k;

    map<string, bool> d;



    int x;

    for (int i = 0; i < k; i++){

        cin >> x;

        d[to_string(x)] = true;

    }



    string s;

    bool check = true;

    string z;

    while (1){

        s = to_string(n);

        check = true;

        for (int i = 0; i < s.size(); i++){

            z = s[i];

            if (d[z]) check = false;

        }



        if (check) break;

        n++;

    }



    cout << n << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4264113022104743x):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<vector>

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)

#define sc(x) scanf("%d",&x);

int main(){

    int n, k;

    sc(n) sc(k)

    int x, d[10];

    fill(d, d + 10, 0);

    REP(i, k){

        sc(x)

        d[x] = 1;

    }



    int check, ans = n;

    while(1){

        check = ans;

        while (check > 0){

            if (d[check % 10] == 1){

                ans++;

                break;

            }else check /= 10;

        }

        if (check == 0) break;

    }

    cout << ans << endl;

    return 0;

}
// Slower C++ solution:
/*------------------------------------

.....Bismillahir Rahmanir Rahim.......

created by muslim.time: 2:24:23 pm....

------------------------------------*/

#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <cmath>

#include <vector>

#include <set>

#include <map>

#include <cstring>

#include <unordered_map>

#include <queue>

#define   mod  998244353

#define   int  long long 

#define   ld long double

#define   pb push_back

#define  sz(x)  (int)x.size()

#define  ff first

#define  ss second

#define  pii  pair<int,int>

using namespace std;



inline void solve(){ 

    map <int,bool> mp; 

    int yen; cin>> yen;

    int n; cin>>n;

    while (n--){

        int a; cin>>a;

        mp[a]=true;

    }

    while (1){

        string s=to_string(yen);

        int l=s.size();

        bool ok=true;

        for (int i=0;i<l;i++){

            if (mp[s[i]-'0']) {

                ok=false;

                break;

            }

        }

        if (ok) break;

        yen++;

    }

    cout << yen << endl;

}



signed main()

{

    int n=1; // cin>>n;

    while (n--) solve();

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1549354285592628x):
/*------------------------------------

........Bismillahir Rahmanir Rahim....

..........created by Abdul Aziz.......

------------------------------------*/

#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <cmath>

#include <vector>

#include <set>

#include <map>

#include <cstring>

#include <unordered_map>

#include <queue>

#define   mod  998244353

#define   int  long long 

#define   ld   long double

#define   pb   push_back

#define   vi  vector<int> 

#define   dbg(x)  cerr << #x << " = " << x << '\n'

#define   sz(x)  (int)x.size()

#define   all(a) (a.begin(),a.end())

#define   ff   first

#define   ss   second

#define   pii  pair<int,int> 

#define   lcm(a,b) (a*b)/__gcd(a,b) 

using namespace std;



int n,k;

map <int,bool> mp; 



bool fun(int a){

	while (a){

		if (mp[a%10]) return false;

		a /= 10;

	}

	return true;

}



inline void solve(){

    cin >> n >> k ; 

    for (int i=1;i<=k;i++) {

    	int a; cin >> a; 

    	mp[a] = true;

    }

    while (true){

    	if (fun(n)){

    		cout << n << endl;

    		return; 

    	} n++ ; 

    }

}



signed main()

{

    int n=1; // cin>>n;

    while (n--) solve();

    return 0;

}
// Slower C++ solution:
/*------------------------------------

.....Bismillahir Rahmanir Rahim.......

created by muslim.time: 2:24:23 pm....

------------------------------------*/

#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <cmath>

#include <vector>

#include <set>

#include <map>

#include <cstring>

#include <unordered_map>

#include <queue>

#define   mod  998244353

#define   int  long long 

#define   ld long double

#define   pb push_back

#define  sz(x)  (int)x.size()

#define  ff first

#define  ss second

#define  pii  pair<int,int>

using namespace std;



inline void solve(){ 

    map <int,bool> mp; 

    int yen; cin>> yen;

    int n; cin>>n;

    while (n--){

        int a; cin>>a;

        mp[a]=true;

    }

    while (1){

        string s=to_string(yen);

        int l=s.size();

        bool ok=true;

        for (int i=0;i<l;i++){

            if (mp[s[i]-'0']) {

                ok=false;

                break;

            }

        }

        if (ok) break;

        yen++;

    }

    cout << yen << endl;

}



signed main()

{

    int n=1; // cin>>n;

    while (n--) solve();

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.175685246564841x):
/*------------------------------------ 

........Bismillahir Rahmanir Rahim.... 

..........created by Abdul Aziz....... 

------------------------------------*/ 

#include <iostream> 

#include <algorithm> 

#include <stdio.h> 

#include <cmath> 

#include <vector> 

#include <set> 

#include <map> 

#include <cstring> 

#include <unordered_map> 

#include <queue> 

#define   mod  998244353 

#define   int  long long 

#define   ld   long double 

#define   pb   push_back 

#define   vi  vector<int> 

#define   dbg(x)  cerr << #x << " = " << x << '\n' 

#define   sz(x)  (int)x.size() 

#define   all(a) (a.begin(),a.end()) 

#define   ff   first 

#define   ss   second 

#define   pii  pair<int,int> 

#define   lcm(a,b) (a*b)/__gcd(a,b) 

using namespace std; 

 

int n,k; 

map <int,bool> mp; 

int h[9],l=0,ans=100000000; 

 

void fun(int num){ 

	if (num >= n){

		ans = min(ans,num);

		return;

	}

	for (int i=0;i<l;i++){

		int x=num*10+h[i];

		if (x) fun(x);

	}

} 

 

inline void solve(){ 

    cin >> n >> k ; 

    for (int i=1;i<=k;i++) { 

    	int a; cin >> a; 

    	mp[a] = true; 

    } 

    for (int i=0;i<10;i++) 

    	if (!mp[i]) h[l++] = i; 

    fun(0);

    cout << ans << endl;

}



signed main()

{

    int n=1; // cin>>n;

    while (n--) solve();

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#ifdef _DEBUG

#define debug(x) cout<<#x<<": "<<x<<endl

#else

#define debug(x)

#endif



using namespace std;



int main() {

    int N; int K;

    cin >> N >> K;

    set<int> ds;

    for (int i = 0; i < K; ++i) {

        int d;

        cin >> d;

        ds.insert(d);

    }



    for (int n = N;; ++n) {

        string n_str = to_string(n);

        bool found = false;

        for (const auto d : n_str) {

            if (ds.count(d - '0')) {

                found = true;

            }

        }

        if (found) { continue; }

        cout << n << endl;

        break;

    }

}

// Faster C++ solution for the same problem (measured speedup: 1.2127766493005627x):
#include <bits/stdc++.h>



#ifdef _DEBUG

#define debug(x) cout<<#x<<": "<<x<<endl

#else

#define debug(x)

#endif



using namespace std;



int main() {

    string N; int K;

    cin >> N >> K;

    set<int> ds;

    for (int i = 0; i < K; ++i) {

        int d;

        cin >> d;

        ds.insert(d);

    }



    int min_not_in_ds = -1;

    for (int t = 0; t <= 9; ++t) {

        if (!ds.count(t)) {

            min_not_in_ds = t;

            break;

        }

    }

    assert(min_not_in_ds >= 0);



    bool can_pay = true;

    deque<int> res;

    for (int i = 0; i < N.size(); ++i) {

        int di = N[N.size() - 1 - i] - '0';

        if (can_pay) {

            for (int t = di; t <= 9; ++t) {

                if (!ds.count(t)) {

                    res.push_front(t);

                    if (t > di) {

                        for (int k = 1; k < res.size(); ++k) {

                            res[k] = min_not_in_ds;

                        }

                    }

                    goto next1;

                }

            }

            can_pay = false;

            res.push_front(min_not_in_ds);

next1:;

        } else {

            for (int t = di + 1; t <= 9; ++t) {

                if (!ds.count(t)) {

                    res.push_front(t);

                    for (int k = 1; k < res.size(); ++k) {

                        res[k] = min_not_in_ds;

                    }

                    can_pay = true;

                    goto next2;

                }

            }

            res.push_front(min_not_in_ds);

next2:;

        }

    }



    if (!can_pay) {

        for (int t = 1; t <= 9; ++t) {

            if (!ds.count(t)) {

                res.push_front(t);

                break;

            }

        }

    }

    for (auto d : res) {

        cout << d;

    }

    cout << endl;

}