stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <algorithm>

#include <fstream>

#include <iomanip>

#include <valarray>

#include <iterator>

#include <stack>

#include <set>

#include <cstring>

#include <cstdlib>

#include <queue>

#include <list>

#include <map>

#include <strstream>

#include <streambuf>

#include <string>

#include <sstream>



#define def(type,vec) vector<type> vec

#define last(arr) arr.size()-a

#define loop(i,n) for(ll i=0 ; i<n ; ++i)

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

#define pb push_back

#define ll long long

#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)



using namespace std;

string int_to_string(int x){

        string str;

        ostringstream temp;

        temp<<x;

        str=temp.str();

        return str;

}



int main(){

    int n,k;

    cin>>n>>k;

    char chr;

    set<char> st;

    loop(i,k){

        cin>>chr;

        st.insert(chr);

    }

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

        string str=int_to_string(i);

        bool x=true;

        loop(j,str.size()){

            if(binary_search(all(st),str[j])){

                x=false;

            }

        }

        if(x){

            cout<<i<<endl;

            break;

        }

    }

}




// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

#define MAX_N 10000

#define MAX_k 9

int N, k;

int D[MAX_k];

int check(int a){

    int i, j, n, m;

n=a;

while(n!=0){

        m = n%10;

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

            if (m==D[j]) return 1;

            n/=10;

}

    return 0;

}

int main(){

    int i;

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

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

        scanf("%d", &D[i]);

    i=N;

    while (1)

    {

        if(check(i)==0)break;

        else

        {

            i++;

        }

    }

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

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int dislike[11] = {0};

int solve(int test)

{

    int tt;

    while (test) {

        if (dislike[test % 10]) {

            return false;

        }

        test /= 10;

    }

    return true;

}

int main()

{

    int N, K;

    cin >> N  >> K;

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

        int t;

        cin >> t;

        dislike[t]++;

    }

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

        if (solve(i)) {

            cout << i << endl;

            break;

        }

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

#define MAX_N 10000

#define MAX_k 9

int N, k;

int D[MAX_k];

int check(int a){

    int i, j, n, m;

n=a;

while(n!=0){

        m = n%10;

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

            if (m==D[j]) return 1;

            n/=10;

}

    return 0;

}

int main(){

    int i;

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

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

        scanf("%d", &D[i]);

    i=N;

    while (1)

    {

        if(check(i)==0)break;

        else

        {

            i++;

        }

    }

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

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int N, K;

int dis[10];



bool fnc(int num)

{

    while (num) {

        int rem = num % 10;

        if (dis[rem]) return false;

        num /= 10;

    }

    return true;

}



int dfs(int num)

{

    if (fnc(num)) return num;

    return dfs(num+1);

}



int main()

{

    cin >> N >> K;

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

        int tmp;

        cin >> tmp;

        dis[tmp] = 1;

    }



    cout << dfs(N);

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

#define MAX_N 10000

#define MAX_k 9

int N, k;

int D[MAX_k];

int check(int a){

    int i, j, n, m;

n=a;

while(n!=0){

        m = n%10;

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

            if (m==D[j]) return 1;

            n/=10;

}

    return 0;

}

int main(){

    int i;

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

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

        scanf("%d", &D[i]);

    i=N;

    while (1)

    {

        if(check(i)==0)break;

        else

        {

            i++;

        }

    }

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

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<set>

using namespace std;



typedef long long int llt;



bool chk(int n,set<int> st)

{

	

	while(n!=0)

	{

		int dig=n%10;

		if(st.find(dig)!=st.end())

		return false;

		n/=10;

	}

	return true;



}



int main()

{

	llt n,k;

	cin>>n>>k;

	set<int> st;

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

	{

		int x;

		cin>>x;

		st.insert(x);

	}

	int res=n;

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

	{

		if(chk(i,st))

		{

			res=i;

			break;

		}

	}

	cout<<res<<endl;

	return 0;

	

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

#define MAX_N 10000

#define MAX_k 9

int N, k;

int D[MAX_k];

int check(int a){

    int i, j, n, m;

n=a;

while(n!=0){

        m = n%10;

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

            if (m==D[j]) return 1;

            n/=10;

}

    return 0;

}

int main(){

    int i;

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

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

        scanf("%d", &D[i]);

    i=N;

    while (1)

    {

        if(check(i)==0)break;

        else

        {

            i++;

        }

    }

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

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <bits/extc++.h>

using namespace __gnu_pbds;

using namespace std;

#define testing 1

#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)

#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)

#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);

#define db(x) cerr << #x << "=" << x << endl

#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl

#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl

#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl

#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl

#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long 

#define pb push_back

#define inf (int)1e9+500

#define oo (ll)1e18+500

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

#define f first

#define s second

#define reach cerr << "LINE: " << __LINE__ << "\n";

typedef pair <int, int> pi;

typedef pair <ll,ll> pl;

typedef pair <pi, int> pii;

typedef tuple<int,int,int> ti3;

string cts(char x) {string t(1,x); return t;}

ll rand(ll a, ll b) { return a + rng() % (b-a+1); }

const int MOD = 1e9 + 7;

template <typename T> void chmax(T& a, T b) {

	a = max(a, b);

}

template <typename T> void chmin(T& a, T b) {

	a = min(a, b);

}

#define MAXN

#if !testing

#define cerr if(0)cout

#endif



int32_t main() {

    IAMSPEED

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

    set<char>cannot;

    FOR(i,1,k) {

        int x; cin >> x;

        cannot.insert(x);

    }

    FOR(i,n,n*100) {

        string str = to_string(i);

        bool can = 1;

        for (auto it : str) {

            if(cannot.find(int(it-'0'))!=cannot.end())can = 0;

        }

        if(can) {

            cout<<i;

            return 0;

        }

    }

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

#define MAX_N 10000

#define MAX_k 9

int N, k;

int D[MAX_k];

int check(int a){

    int i, j, n, m;

n=a;

while(n!=0){

        m = n%10;

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

            if (m==D[j]) return 1;

            n/=10;

}

    return 0;

}

int main(){

    int i;

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

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

        scanf("%d", &D[i]);

    i=N;

    while (1)

    {

        if(check(i)==0)break;

        else

        {

            i++;

        }

    }

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

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

//#include<ext/rope>

//using namespace __gnu_cxx

//#include<ext/pb_ds/priority_queue.hpp>

//using namespace __gnu_pbds;

#define lowbit(x) (x&-x)

#define pb push_back

#define empb emplace_back

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

#define clr(a,b) memset(a,b,sizeof(a))

#define caze(T) for(cin>>T;T;T--)

#define inf (1<<29)

#define Endl ('\n')

#define fi first

#define se second

#define db double

#define ldb long double

#define ll long long

#define pii pair<int,int>

#define pil pair<int,ll>

#define pli pair<ll,int>

#define pll pair<ll,ll>

#define ull unsigned long long

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

inline char nc() {

	#define SZ 1000000

	static char buf[SZ], *p1, *p2;

	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;

}

template<typename T>

inline int scan(T &x) {

	char c, sign=1; 

	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;

	if(c==EOF) return EOF;

	for(x = 0; isdigit(c); c = nc())

		x = (x<<1) + (x<<3) + (c&15);

	return x *= sign, 1;

}

template<typename T, typename...Args>

inline int scan(T &x, Args&...args) {

	return scan(x), scan(args...);

}

const int N=1<<14;

int v[N];

bool ok(int x)

{

	while(x)

	{

		if(v[x%10]) return 0;

		x/=10;

	}

	return 1;

}

int main()

{IOS;

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

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

		cin>>x,v[x]=1;

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

		if(ok(i))

			return cout<<i<<Endl,0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

#define MAX_N 10000

#define MAX_k 9

int N, k;

int D[MAX_k];

int check(int a){

    int i, j, n, m;

n=a;

while(n!=0){

        m = n%10;

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

            if (m==D[j]) return 1;

            n/=10;

}

    return 0;

}

int main(){

    int i;

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

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

        scanf("%d", &D[i]);

    i=N;

    while (1)

    {

        if(check(i)==0)break;

        else

        {

            i++;

        }

    }

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

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#include <unordered_map>

#define int long long int

#define double long double

#define endl "\n"

#define PI 3.141592653589793238462643383279502884

#define sp(x)   setprecision(x)

#define ceil(a,b)   (a+(b-1))/b

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

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

#define alls(s,v)  s.begin(),s.end(),v

#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)

#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)

#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define exit return 0;

using namespace std;

const int N=1000000;

bool prime[N];

void sieve()

{

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<100000000; p++)

    {

        if (prime[p] == true)

        {

            for (int i=p*p; i<100000; i += p)

                prime[i] = false;

        }

    }

}

int power(int x, int y)

{

    int res = 1;

    while (y > 0)

    {

        if (y & 1)

            res = res * x;

        y = y >> 1;

        x = x*x;

    }

    return res;

}

int nxt()

{

    int x;

    cin >> x;

    return x;

}

int findTileCount(int x, int y, int l, int r)

{

    int lcm = (x * y) / __gcd(x, y);

    int countl = (l - 1) / lcm;

    int countr = r / lcm;

    return countr - countl;

}

int32_t main()

{

    base

    int n=nxt(),k=nxt();

    int d[k];

    gena(d,k,nxt);

    int a=n;

    int ans=n;

    int flag=0;

    while(1){

        flag=0;

        a=ans;

        while(a!=0){

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

                if(d[i]==a%10){

                    flag=1;

                    break;

                }

            }

            if(flag==1)break;

            a/=10;

        }

        if(flag==0)break;

        ans++;

    }

    cout<<ans<<endl;

    exit

}




// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <math.h>

#define MAX_N 10000

#define MAX_k 9

int N, k;

int D[MAX_k];

int check(int a){

    int i, j, n, m;

n=a;

while(n!=0){

        m = n%10;

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

            if (m==D[j]) return 1;

            n/=10;

}

    return 0;

}

int main(){

    int i;

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

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

        scanf("%d", &D[i]);

    i=N;

    while (1)

    {

        if(check(i)==0)break;

        else

        {

            i++;

        }

    }

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

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <algorithm>

#include <iostream>

#include <iomanip>

#include <cstring>

#include <string>

#include <vector>

#include <queue>

#include <cmath>

#include <stack>

#include <set>

#include <map>

typedef long long ll;

typedef unsigned int uint;

using namespace std;



int main() {

    cin.sync_with_stdio(false);

    cin.tie(0);



    int n, k;

    cin >> n >> k;



    vector<int> kirai;

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

        int d;

        cin >> d;

        kirai.push_back(d);

    }



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

        int t = i;

        bool valid = true;



        while (t > 0) {

            bool possible = true;

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

                if (t % 10 == kirai[j]) {

                    possible = false;

                }

            }

            if (!possible) valid = false;

            t /= 10;

        }



        if (valid && i >= n) {

            cout << i << endl;

            return 0;

        }

    }

}


// Optimized solution to the same problem (faster):
#include <algorithm>

#include <iostream>

#include <iomanip>

#include <cstring>

#include <string>

#include <vector>

#include <queue>

#include <cmath>

#include <stack>

#include <set>

#include <map>

typedef long long ll;

typedef unsigned int uint;

using namespace std;



int main() {

    cin.sync_with_stdio(false);

    cin.tie(0);



    int n, k;

    cin >> n >> k;

    int kirai[k];

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

        cin >> kirai[i];

    }



    for (int i = n; i < 10 * n; i++) {

        int t = i;

        bool valid = true;



        while (t > 0) {

            bool possible = true;

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

                if (t % 10 == kirai[j]) {

                    possible = false;

                }

            }



            if (!possible) {

                valid = false;

                break;

            }



            t /= 10;

        }



        if (valid) {

            cout << i << endl;

            return 0;

        }

    }

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<cmath>

#include<cstdlib>

#include<queue>

#include<map>

#include<iostream>

#include<algorithm>

#define m(a,b) memset(a,b,sizeof(a));

using namespace std;

const int maxn = 1e4;

const int inf = 1<<30;

typedef long long LL;

int k;

int n;

int main(){

	cin >> n >> k;

	map<int,int>m;

	int a;

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

		cin >> a;

		m[a] = 1;

	}

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

		bool ans = true;

		int a = i;

		while(a){

			int b = a%10;

			if(m[b]) {ans = false;break;}

			a/=10;

		}

		if(ans) {n = i;break;}

	}

	cout << n << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

int n,k,tmp;

bool u[11];

bool check(int t)

{

    while(t)

    {

        if (u[t%10]) return 0;

        t/=10;

    }

    return 1;

}

int main()

{

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

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

    {

        scanf("%d",&tmp);

        u[tmp]=1;

    }

    int cur=n;

    while(!check(cur)) cur++;

    printf("%d",cur);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;



typedef long long LL;



const int N = 100 + 5;







int a[10];



int check(int x){



	while(x){



		if(a[x % 10]) return 0;//每次获取末位数字判断是否不喜欢



		x /= 10;//更高位



		}



	return 1;//当所有都0喜欢就返回1;



	}



int main(){



	ios::sync_with_stdio(false);



	cin.tie(0);



	



	int n , k , q;



	cin>>n>>k;



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



		cin>>q;



		a[q] = 1;



		}



	while(1){



		if(check(n)){



			cout<<n<<endl;



			break;



			}



		n++;//直到找到



		}



	return 0;



	}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

int n,k,tmp;

bool u[11];

bool check(int t)

{

    while(t)

    {

        if (u[t%10]) return 0;

        t/=10;

    }

    return 1;

}

int main()

{

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

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

    {

        scanf("%d",&tmp);

        u[tmp]=1;

    }

    int cur=n;

    while(!check(cur)) cur++;

    printf("%d",cur);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstdlib>

#include<cmath>

#include<cstring>

#include<string>

#include<iostream>

#include<algorithm>

#include<map>

using namespace std;

int f[10];

bool vis[15];

int main(){

	int n,k,a[15],len;

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

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

		scanf("%d",&a[i]);

		vis[a[i]]=1;

	}

	f[0]=1;

	for(int i=1;i<=8;i++) f[i]=f[i-1]*10;

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

		for(int j=1;;j++){

			if(i/f[j]==0){

				len=j;

				break;

			}

		}

		if(len==1){

			if(vis[i]!=1){

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

				break;

			}

		}

		else if(len==2){

			if(vis[i/10]!=1&&vis[i%10]!=1){

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

				break;

			}

		}

		else if(len==3){

			if(vis[i%10]!=1&&vis[i/10%10]!=1&&vis[i/100]!=1){

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

				break;

			}

		}

		else if(len==4){

			if(vis[i%10]!=1&&vis[i/10%10]!=1&&vis[i/100%10]!=1&&vis[i/1000]!=1){

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

				break;

			}

		}

		else if(len==5){

			if(vis[i%10]!=1&&vis[i/10%10]!=1&&vis[i/100%10]!=1&&vis[i/1000%10]!=1&&vis[i/10000]!=1){

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

				break;

			}

		}

	}

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

int n,k,tmp;

bool u[11];

bool check(int t)

{

    while(t)

    {

        if (u[t%10]) return 0;

        t/=10;

    }

    return 1;

}

int main()

{

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

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

    {

        scanf("%d",&tmp);

        u[tmp]=1;

    }

    int cur=n;

    while(!check(cur)) cur++;

    printf("%d",cur);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int arr[10];



bool check(int num) {

    while(num) {

        if(arr[num%10])

            return false;

        num/=10;

    }

    return true;

}



int main()

{

    int n,k;

    int x;

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

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

        scanf("%d",&x);

        arr[x] = 1;

    }

    while(!check(n)) {

        n++;

    }

    printf("%d",n);

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

int n,k,tmp;

bool u[11];

bool check(int t)

{

    while(t)

    {

        if (u[t%10]) return 0;

        t/=10;

    }

    return 1;

}

int main()

{

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

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

    {

        scanf("%d",&tmp);

        u[tmp]=1;

    }

    int cur=n;

    while(!check(cur)) cur++;

    printf("%d",cur);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//### In The Name Of GOD ###



#include <bits/stdc++.h>



using namespace std;



typedef long long ll ;



const int MOD = 1000000007;

const int INF = 30 * 1000 + 20;

const int MAXN = 2600;

const int MLOG = 18;

const int NMAX = 60;



#define int ll

#define pb push_back

#define pp pop_back

#define X first

#define Y second

#define IO ios_base::sync_with_stdio(false);

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

#define ct(x) const_cast<const int&>(x)



int32_t main(){

	int n , k;

	cin >> n >> k;

	bool mark[10] ={};

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

		int a;

		cin >> a;

		mark[a] = true;

	}

	for(int i = n ; i < n*100; i++){

		int a = i;

		while(a > 0 && !mark[a%10])

			a/=10;

		if(a==0){

			cout << i;

			return 0;

		}

	}

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

int n,k,tmp;

bool u[11];

bool check(int t)

{

    while(t)

    {

        if (u[t%10]) return 0;

        t/=10;

    }

    return 1;

}

int main()

{

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

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

    {

        scanf("%d",&tmp);

        u[tmp]=1;

    }

    int cur=n;

    while(!check(cur)) cur++;

    printf("%d",cur);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cmath>

#include <stdio.h>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <cstring>



using namespace std;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define ll long long

#define pii pair < int, int >

#define pll pair < long long, long long>

#define ull unsigned long long

#define vi vector < int >

#define vll vector < long long >

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

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

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

#define sqr(x) ((x) * (x))

#define fname "searching"



const int inf = (int)1e9;

const ll INF = (ll)1e18;

const double eps = 1e-9;

const double pi = acos(-1.0);

const int mod = (int)1e9 + 7;



int n, k;

bool d[10];



int solve(){

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

        string s = to_string(i);

        bool ok = 1;

        for(int j = 0; j < sz(s); ++j){

            if(d[s[j] - '0']){

                ok = 0;

                break;

            }

        }

        if(ok) return i;

    }

    return n;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cin >> n >> k;

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

        cin >> x;

        d[x] = 1;

    }

    

    cout << solve() << "\n";



    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

int n,k,tmp;

bool u[11];

bool check(int t)

{

    while(t)

    {

        if (u[t%10]) return 0;

        t/=10;

    }

    return 1;

}

int main()

{

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

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

    {

        scanf("%d",&tmp);

        u[tmp]=1;

    }

    int cur=n;

    while(!check(cur)) cur++;

    printf("%d",cur);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

set< int > se;



bool check( int n ) {

    while( n ) {

        if( se.count(n%10) ) return true;

        n /= 10;

    } 

    return false;

}



int main() {

    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n, d, temp;

    cin >> n >> d;

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

        cin >> temp;

        se.insert( temp );

    }

    string ans;

    while( check(n) ) n++;

    cout << n << '\n';

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

int n,k,tmp;

bool u[11];

bool check(int t)

{

    while(t)

    {

        if (u[t%10]) return 0;

        t/=10;

    }

    return 1;

}

int main()

{

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

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

    {

        scanf("%d",&tmp);

        u[tmp]=1;

    }

    int cur=n;

    while(!check(cur)) cur++;

    printf("%d",cur);

}


// Fastest known solution for this problem: