stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#define __USE_MINGW_ANSI_STDIO 0

#include <bits/stdc++.h>

using namespace std;

#define ll long long int

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

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N, K;

    cin >> N >> K;

    int D[K];

    rep(i, K) {

        cin >> D[i];

    }

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

        int flag = 0;

        string tmp = std::to_string(i);

        rep(k, tmp.length()) {

            rep(j, K) {

                //cout << tmp[k] - '0' << " " << D[j] << endl;

                if (tmp[k] - '0' == D[j]) {

                    flag = 1;

                    break;

                }

            }

            if (flag == 1) break;

        }

        if (flag == 0) {

            cout << i << endl;

            return 0;

        }

    }





    return 0;

}


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

using namespace std;

#define ll long long int

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

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000



int D[9];

int K;

bool check(int num) {

    while(num > 0){

        int tmp = num % 10;

        rep(i, K) {

            if (tmp == D[i]) return false;

        }

        num /= 10;

    }

    return true;

}





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N;

    cin >> N >> K;



    rep(i, K) cin >> D[i];

    while(true) {

        if (check(N)) {

            cout << N << endl;

            return 0;

        }

        N++;

    }







    return 0;

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

#include <algorithm>

#include <functional>

#include <iostream>

#include <string>

#include <vector>

using namespace std;



//前提:解は必ず存在する

int main() {

  int N, K;

  cin >> N >> K;



  vector<int> D;



  //配列D、嫌いな数字を入れていく。

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

    int d;

    cin >> d;

    D.push_back(d);

  }



  // 嫌いな数字が出現した際に立つフラグ

  bool flag;



  for (int ans = N; ans <= 99999; ans++) {

    // ansを文字列に変換

    string str = to_string(ans);

    flag = false;



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

      // 嫌いな数字を文字に変換

      char judge = '0' + D[i];



      // ans中にD[i]が出現したらフラグを立てる

      if (str.find(judge) != string::npos) {

        flag = true;

        break;

      }

    }



    // 嫌いな数字が出現してなかったら表記して終了

    if (flag == false) {

      cout << ans << endl;

      return 0;

    }

  }

}


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

#include <string>

#include <vector>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <stack>

#include <queue>

#include <numeric>

#include <map>

#include <unordered_map>

#include <set>

#include <fstream>

#include <chrono>

#include <random>

#include <bitset>

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

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

#define rall(x) x.rbegin(), x.rend()

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

#define pb push_back

using ll = long long;

using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}

ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}





bool ok(int N,vector<int>& D){

  while(N){

    rep(i,sz(D)){

      if(N%10==D[i]) return false;

    }

    N/=10;

  }

  return true;

}



void solve(){

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

  vector<int> D(K); rep(i,K) cin >> D[i];

  while(1){

    if(ok(N,D)) {

      cout << N << endl;

      break;

    }

    else N++;

  }

}



int main(){

  solve();

  return 0;

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

using namespace std;

int main() {

  int n, k;

  bool flag = true;

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

  int d[k];

  for(int i = 0; i < n; i++) scanf("%d", &d[i]);

  while(flag) {

    flag = false;

    string str = to_string(n);

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

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

        string tmp = to_string(d[i]);

        if(str.at(j) == tmp.at(0)) {

          flag = true;

          break;

        }

      }

      if(flag) break;

    }

    if(flag) n++;

  }

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

}

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

using namespace std;

int main() {

  int n, k;

  bool flag = true;

  cin >> n >> k;

  vector<int> d(k);

  for(int i = 0; i < k; i++) cin >> d.at(i);

  while(flag) {

    flag = false;

    int tmp = n;

    while(tmp) {

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

        if ((tmp%10) == d.at(i)) {

          tmp = 0;

          flag = true;

          break;

        }

      }

      tmp /= 10;

    }

    if (flag) n++;

  }

  cout << n << endl;

  return 0;

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

using namespace std;

int main()

{

	int n,m,a[200001];

	bool b1[200001],b2[200001];

	cin>>n>>m;

	memset(b1,1,sizeof(b1));

	memset(b2,1,sizeof(b2));

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

		cin>>a[i];

		b1[a[i]]=false;

	}

	for(int i=m;i>=1;i--){

		if (b2[a[i]]==true){

			cout<<a[i]<<endl;

			b2[a[i]]=0;

		}

	}

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

		if (b1[i]==true) cout<<i<<endl;

	}

	return 0;

}

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <climits>

using namespace std;



int N, M;//?度? n 的序列,有 m 个操作

int F[205000];

bool Jud[205000];



int main()

{

    cin >> N >> M;

    memset(Jud, true, sizeof(Jud));

    for(int i = 1; i <= M; i++)    cin >> F[i];

    for(int i = M; i >= 1; i--)

        if(Jud[F[i]] == true){

            Jud[F[i]] = false;

            cout << F[i] << endl;

        }

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

        if(Jud[i] == true)

            cout << i << endl;

    return 0;

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

#include<iostream>

#include<memory.h>

using namespace std;

bool vis[200005];

bool vis1[200005];

int a[200005];

int main()

{

    memset(vis,0,sizeof(vis));

    memset(vis1,0,sizeof(vis1));

    int n,m;

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

    int j=0;

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

    {

        int b;

        scanf("%d",&b);

        vis[b]=1;

        a[j++]=b;

    }

    while(j--)

    {

        if(vis1[a[j]]==0)

        {

            printf("%d\n",a[j]);

            vis1[a[j]]=1;

        }

    } 

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

    {

        if(vis[i]==0) 

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

    }

    return 0;

} 

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <climits>

using namespace std;



int N, M;//?度? n 的序列,有 m 个操作

int F[205000];

bool Jud[205000];



int main()

{

    cin >> N >> M;

    memset(Jud, true, sizeof(Jud));

    for(int i = 1; i <= M; i++)    cin >> F[i];

    for(int i = M; i >= 1; i--)

        if(Jud[F[i]] == true){

            Jud[F[i]] = false;

            cout << F[i] << endl;

        }

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

        if(Jud[i] == true)

            cout << i << endl;

    return 0;

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

using namespace std;



int main()

{

    int n,m;

    cin>>n>>m;\

    int mark[n+1],check[n+1];

    memset(mark,0,sizeof(mark));

    memset(check,0,sizeof(check));

    vector<int>v;

    while(m--)

    {

        int p;

        cin>>p;

        v.push_back(p);

    }

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

    {

        if(check[v[i]]==0)

        {

            check[v[i]]=1;

            cout<<v[i]<<endl;

        }

        mark[v[i]]=1;

    }

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

    {

        if(mark[i]==0)

            cout<<i<<endl;

    }

}

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

#include<cstring>

using namespace std;

int n,m;

bool flag[250000];

int a[250000];

int main()

{

	memset(flag,1,sizeof(flag));

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

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

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

	for(int i=m;i>=1;i--)

		if(flag[a[i]])

		printf("%d\n",a[i]),flag[a[i]]=0;

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

		if(flag[i])

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

		return 0;

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

using namespace std;



#define N 1000002

#define pb push_back

int hit[N], a[N];

int main(){

    int n, m;

    cin >> n >> m;

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

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

    }

    for (int i=m; i>=1; i--){

        int x = a[i];

        if (hit[x] == 0) printf("%d\n", x);

        hit[x] = 1;

    }

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

        if (hit[i] == 0) printf("%d\n", i);

    }

    return 0;

}

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

#include<cstring>

using namespace std;

int n,m;

bool flag[250000];

int a[250000];

int main()

{

	memset(flag,1,sizeof(flag));

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

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

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

	for(int i=m;i>=1;i--)

		if(flag[a[i]])

		printf("%d\n",a[i]),flag[a[i]]=0;

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

		if(flag[i])

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

		return 0;

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

using namespace std;

int main()

{

	int n,m,a[200001];

	bool b1[200001],b2[200001];

	cin>>n>>m;

	memset(b1,1,sizeof(b1));

	memset(b2,1,sizeof(b2));

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

		cin>>a[i];

		b1[a[i]]=false;

	}

	for(int i=m;i>=1;i--){

		if (b2[a[i]]==true){

			cout<<a[i]<<endl;

			b2[a[i]]=0;

		}

	}

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

		if (b1[i]==true) cout<<i<<endl;

	}

	return 0;

}

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

#include<cstring>

using namespace std;

int n,m;

bool flag[250000];

int a[250000];

int main()

{

	memset(flag,1,sizeof(flag));

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

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

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

	for(int i=m;i>=1;i--)

		if(flag[a[i]])

		printf("%d\n",a[i]),flag[a[i]]=0;

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

		if(flag[i])

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

		return 0;

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

#include<iostream>

#include<memory.h>

using namespace std;

bool vis[200005];

bool vis1[200005];

int a[200005];

int main()

{

    memset(vis,0,sizeof(vis));

    memset(vis1,0,sizeof(vis1));

    int n,m;

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

    int j=0;

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

    {

        int b;

        scanf("%d",&b);

        vis[b]=1;

        a[j++]=b;

    }

    while(j--)

    {

        if(vis1[a[j]]==0)

        {

            printf("%d\n",a[j]);

            vis1[a[j]]=1;

        }

    } 

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

    {

        if(vis[i]==0) 

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

    }

    return 0;

} 

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

#include<cstring>

using namespace std;

int n,m;

bool flag[250000];

int a[250000];

int main()

{

	memset(flag,1,sizeof(flag));

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

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

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

	for(int i=m;i>=1;i--)

		if(flag[a[i]])

		printf("%d\n",a[i]),flag[a[i]]=0;

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

		if(flag[i])

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

		return 0;

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <climits>

using namespace std;



int N, M;//?度? n 的序列,有 m 个操作

int F[205000];

bool Jud[205000];



int main()

{

    cin >> N >> M;

    memset(Jud, true, sizeof(Jud));

    for(int i = 1; i <= M; i++)    cin >> F[i];

    for(int i = M; i >= 1; i--)

        if(Jud[F[i]] == true){

            Jud[F[i]] = false;

            cout << F[i] << endl;

        }

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

        if(Jud[i] == true)

            cout << i << endl;

    return 0;

}

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

#include<cstring>

using namespace std;

int n,m;

bool flag[250000];

int a[250000];

int main()

{

	memset(flag,1,sizeof(flag));

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

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

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

	for(int i=m;i>=1;i--)

		if(flag[a[i]])

		printf("%d\n",a[i]),flag[a[i]]=0;

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

		if(flag[i])

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

		return 0;

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

using namespace std;

int main()

{

	int n,m,a[200001];

	bool b1[200001],b2[200001];

	cin>>n>>m;

	memset(b1,1,sizeof(b1));

	memset(b2,1,sizeof(b2));

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

		cin>>a[i];

		b1[a[i]]=false;

	}

	for(int i=m;i>=1;i--){

		if (b2[a[i]]==true){

			cout<<a[i]<<endl;

			b2[a[i]]=0;

		}

	}

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

		if (b1[i]==true) cout<<i<<endl;

	}

	return 0;

}

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

using namespace std;



using VI = vector<int>;

using VVI = vector<VI>;

using PII = pair<int, int>;

using LL = long long;

using VL = vector<LL>;

using VVL = vector<VL>;

using PLL = pair<LL, LL>;

using VS = vector<string>;



#define ALL(a)  begin((a)),end((a))

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define EB emplace_back

#define MP make_pair

#define MT make_tuple

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

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))



#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define REP(i,n)  FOR(i,0,n)



#define FF first

#define SS second



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

template<class S, class T>

istream& operator>>(istream& is, pair<S,T>& p){

  return is >> p.FF >> p.SS;

}

template<class T>

istream& operator>>(istream& is, vector<T>& xs){

  for(auto& x: xs)

	is >> x;

  return is;

}

template<class S, class T>

ostream& operator<<(ostream& os, const pair<S,T>& p){

  return os << p.FF << " " << p.SS;

}

template<class T>

ostream& operator<<(ostream& os, const vector<T>& xs){

  for(unsigned int i=0;i<xs.size();++i)

	os << (i?" ":"") << xs[i];

  return os;

}

template<class T>

void maxi(T& x, T y){

  if(x < y) x = y;

}

template<class T>

void mini(T& x, T y){

  if(x > y) x = y;

}





const double EPS = 1e-10;

const double PI  = acos(-1.0);

const LL MOD = 1e9+7;



int main(){

  cin.tie(0);

  ios_base::sync_with_stdio(false);



  int N, M;

  cin >> N >> M;



  VI qs(M);

  cin >> qs;

  vector<bool> used(N+1);



  VI ans;

  for(int i=M-1;i>=0;--i){

	int x = qs[i];

	if(used[x]) continue;

	ans.PB(x);

	used[x] = true;

  }



  FOR(i,1,N+1)

	if(!used[i])

	  ans.PB(i);

  for(int x: ans) cout << x << endl;



  return 0;

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

#include<iostream>

#include<memory.h>

using namespace std;

bool vis[200005];

bool vis1[200005];

int a[200005];

int main()

{

    memset(vis,0,sizeof(vis));

    memset(vis1,0,sizeof(vis1));

    int n,m;

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

    int j=0;

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

    {

        int b;

        scanf("%d",&b);

        vis[b]=1;

        a[j++]=b;

    }

    while(j--)

    {

        if(vis1[a[j]]==0)

        {

            printf("%d\n",a[j]);

            vis1[a[j]]=1;

        }

    } 

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

    {

        if(vis[i]==0) 

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

    }

    return 0;

} 

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

using namespace std;



using VI = vector<int>;

using VVI = vector<VI>;

using PII = pair<int, int>;

using LL = long long;

using VL = vector<LL>;

using VVL = vector<VL>;

using PLL = pair<LL, LL>;

using VS = vector<string>;



#define ALL(a)  begin((a)),end((a))

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define EB emplace_back

#define MP make_pair

#define MT make_tuple

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

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))



#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define REP(i,n)  FOR(i,0,n)



#define FF first

#define SS second



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

template<class S, class T>

istream& operator>>(istream& is, pair<S,T>& p){

  return is >> p.FF >> p.SS;

}

template<class T>

istream& operator>>(istream& is, vector<T>& xs){

  for(auto& x: xs)

	is >> x;

  return is;

}

template<class S, class T>

ostream& operator<<(ostream& os, const pair<S,T>& p){

  return os << p.FF << " " << p.SS;

}

template<class T>

ostream& operator<<(ostream& os, const vector<T>& xs){

  for(unsigned int i=0;i<xs.size();++i)

	os << (i?" ":"") << xs[i];

  return os;

}

template<class T>

void maxi(T& x, T y){

  if(x < y) x = y;

}

template<class T>

void mini(T& x, T y){

  if(x > y) x = y;

}





const double EPS = 1e-10;

const double PI  = acos(-1.0);

const LL MOD = 1e9+7;



int main(){

  cin.tie(0);

  ios_base::sync_with_stdio(false);



  int N, M;

  cin >> N >> M;



  VI qs(M);

  cin >> qs;

  vector<bool> used(N+1);



  VI ans;

  for(int i=M-1;i>=0;--i){

	int x = qs[i];

	if(used[x]) continue;

	ans.PB(x);

	used[x] = true;

  }



  FOR(i,1,N+1)

	if(!used[i])

	  ans.PB(i);

  for(int x: ans) cout << x << endl;



  return 0;

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <climits>

using namespace std;



int N, M;//?度? n 的序列,有 m 个操作

int F[205000];

bool Jud[205000];



int main()

{

    cin >> N >> M;

    memset(Jud, true, sizeof(Jud));

    for(int i = 1; i <= M; i++)    cin >> F[i];

    for(int i = M; i >= 1; i--)

        if(Jud[F[i]] == true){

            Jud[F[i]] = false;

            cout << F[i] << endl;

        }

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

        if(Jud[i] == true)

            cout << i << endl;

    return 0;

}

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

using namespace std;



using VI = vector<int>;

using VVI = vector<VI>;

using PII = pair<int, int>;

using LL = long long;

using VL = vector<LL>;

using VVL = vector<VL>;

using PLL = pair<LL, LL>;

using VS = vector<string>;



#define ALL(a)  begin((a)),end((a))

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define EB emplace_back

#define MP make_pair

#define MT make_tuple

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

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))



#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define REP(i,n)  FOR(i,0,n)



#define FF first

#define SS second



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

template<class S, class T>

istream& operator>>(istream& is, pair<S,T>& p){

  return is >> p.FF >> p.SS;

}

template<class T>

istream& operator>>(istream& is, vector<T>& xs){

  for(auto& x: xs)

	is >> x;

  return is;

}

template<class S, class T>

ostream& operator<<(ostream& os, const pair<S,T>& p){

  return os << p.FF << " " << p.SS;

}

template<class T>

ostream& operator<<(ostream& os, const vector<T>& xs){

  for(unsigned int i=0;i<xs.size();++i)

	os << (i?" ":"") << xs[i];

  return os;

}

template<class T>

void maxi(T& x, T y){

  if(x < y) x = y;

}

template<class T>

void mini(T& x, T y){

  if(x > y) x = y;

}





const double EPS = 1e-10;

const double PI  = acos(-1.0);

const LL MOD = 1e9+7;



int main(){

  cin.tie(0);

  ios_base::sync_with_stdio(false);



  int N, M;

  cin >> N >> M;



  VI qs(M);

  cin >> qs;

  vector<bool> used(N+1);



  VI ans;

  for(int i=M-1;i>=0;--i){

	int x = qs[i];

	if(used[x]) continue;

	ans.PB(x);

	used[x] = true;

  }



  FOR(i,1,N+1)

	if(!used[i])

	  ans.PB(i);

  for(int x: ans) cout << x << endl;



  return 0;

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

using namespace std;

int main()

{

	int n,m,a[200001];

	bool b1[200001],b2[200001];

	cin>>n>>m;

	memset(b1,1,sizeof(b1));

	memset(b2,1,sizeof(b2));

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

		cin>>a[i];

		b1[a[i]]=false;

	}

	for(int i=m;i>=1;i--){

		if (b2[a[i]]==true){

			cout<<a[i]<<endl;

			b2[a[i]]=0;

		}

	}

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

		if (b1[i]==true) cout<<i<<endl;

	}

	return 0;

}

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



using namespace std;



#define INF 1001000100010001000

#define MOD 1000000007

#define EPS 1e-10

#define int long long

#define rep(i, N) for (int i = 0; i < N; i++)

#define Rep(i, N) for (int i = 1; i < N; i++)

#define For(i, a, b) for (int i = (a); i < (b); i++)

#define pb push_back

#define eb emplace_back

#define mp make_pair

#define i_i pair<int, int>

#define vi vector<int>

#define vvi vector<vi >

#define vb vector<bool>

#define vvb vector<vb >

#define vp vector< i_i >

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

#define Int(x) int x; cin >> x;

#define int2(x, y) Int(x); Int(y);

#define int3(x, y, z) Int(x); int2(y, z);

#define fir first

#define sec second

#define ffir first.first

#define fsec first.second

#define sfir second.first

#define ssec second.second

#define Decimal fixed << setprecision(10)



//int dxy[5] = {0, 1, 0, -1, 0};

// cmd



signed main()

{

    std::ios::sync_with_stdio(false);

    std::cin.tie(0);



    int2(n, m);

    vb used(n, false);

    vector<int> data(m);

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

        cin >> data[i];

        used[data[i]-1] = true;

    }



    vb out(n, false);

    for (int i = m-1; i >= 0; i--) {

        if (!out[data[i]-1]) {

            cout << data[i] << endl;

            out[data[i]-1] = true;

        }

    }



    rep(i, n) {

        if (!used[i]) cout << i+1 << endl;

    }

    



    return 0;

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

#include<iostream>

#include<memory.h>

using namespace std;

bool vis[200005];

bool vis1[200005];

int a[200005];

int main()

{

    memset(vis,0,sizeof(vis));

    memset(vis1,0,sizeof(vis1));

    int n,m;

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

    int j=0;

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

    {

        int b;

        scanf("%d",&b);

        vis[b]=1;

        a[j++]=b;

    }

    while(j--)

    {

        if(vis1[a[j]]==0)

        {

            printf("%d\n",a[j]);

            vis1[a[j]]=1;

        }

    } 

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

    {

        if(vis[i]==0) 

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

    }

    return 0;

} 

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



using namespace std;



#define INF 1001000100010001000

#define MOD 1000000007

#define EPS 1e-10

#define int long long

#define rep(i, N) for (int i = 0; i < N; i++)

#define Rep(i, N) for (int i = 1; i < N; i++)

#define For(i, a, b) for (int i = (a); i < (b); i++)

#define pb push_back

#define eb emplace_back

#define mp make_pair

#define i_i pair<int, int>

#define vi vector<int>

#define vvi vector<vi >

#define vb vector<bool>

#define vvb vector<vb >

#define vp vector< i_i >

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

#define Int(x) int x; cin >> x;

#define int2(x, y) Int(x); Int(y);

#define int3(x, y, z) Int(x); int2(y, z);

#define fir first

#define sec second

#define ffir first.first

#define fsec first.second

#define sfir second.first

#define ssec second.second

#define Decimal fixed << setprecision(10)



//int dxy[5] = {0, 1, 0, -1, 0};

// cmd



signed main()

{

    std::ios::sync_with_stdio(false);

    std::cin.tie(0);



    int2(n, m);

    vb used(n, false);

    vector<int> data(m);

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

        cin >> data[i];

        used[data[i]-1] = true;

    }



    vb out(n, false);

    for (int i = m-1; i >= 0; i--) {

        if (!out[data[i]-1]) {

            cout << data[i] << endl;

            out[data[i]-1] = true;

        }

    }



    rep(i, n) {

        if (!used[i]) cout << i+1 << endl;

    }

    



    return 0;

}