Problem:
Problem A
Rearranging a Sequence
You are given an ordered sequence of integers, ($1, 2, 3, ..., n$). Then, a number of requests will be given. Each request specifies an integer in the sequence. You need to move the specified integer to the head of the sequence, leaving the order of the rest untouched. Your task is to find the order of the elements in the sequence after following all the requests successively.
Input
The input consists of a single test case of the following form.
$n$ $m$
$e_1$
...
$e_m$
The integer $n$ is the length of the sequence ($1 \leq n \leq 200000$). The integer $m$ is the number of requests ($1 \leq m \leq 100000$). The following $m$ lines are the requests, namely $e_1, ...,  e_m$, one per line. Each request $e_i$ ($1 \leq i \leq m$) is an integer between 1 and $n$, inclusive, designating the element to move. Note that, the integers designate the integers themselves to move, not their positions in the sequence.
Output
Output the sequence after processing all the requests. Its elements are to be output, one per line, in the order in the sequence.
Sample Input 1
5 3
4
2
5
Sample Output 1
5
2
4
1
3
Sample Input 2
10 8
1
4
7
3
4
10
1
3
Sample Output 2
3
1
10
4
7
2
5
6
8
9
In Sample Input 1, the initial sequence is (1, 2, 3, 4, 5). The first request is to move the integer 4 to the head, that is, to change the sequence to (4, 1, 2, 3, 5). The next request to move the integer 2 to the head makes the sequence (2, 4, 1, 3, 5). Finally, 5 is moved to the head, resulting in (5, 2, 4, 1, 3).

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m;cin >> n >> m;
    vector<int> a(n,true);
    
    vector<int> e(m);
    for (int i = 0; i < m; i++)cin >> e[i];
    for (int i = m-1; i >= 0; i--){
        if (a[e[i]-1]){
            cout << e[i] << endl;
            a[e[i]-1] = false; 
        }
    }
    for (int i = 0; i < n; i++)if (a[i])cout << i+1 << endl;
}
accuracy: 1
time_ms: 150
memory_kb: 4320
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

bool chmin(auto& a, const auto& b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, const auto& b) { return a < b ? a = b, 1 : 0; }

ll mod = 998244353;

ifstream in;
ofstream out;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    if(argc > 2) {
        in.open(argv[1]);
        cin.rdbuf(in.rdbuf());
        out.open(argv[2]);
        cout.rdbuf(out.rdbuf());
    }

    ll n, m;
    cin >> n >> m;
    set<ll> sh;
    for(int i = 0; i < n; i++) sh.insert(i + 1);

    vector<ll> e(m);
    for(auto& x : e) cin >> x;
    reverse(e.begin(), e.end());

    for(auto& x : e) {
        if(sh.contains(x)) {
            cout << x << endl;
        }
        sh.erase(x);
    }
    for(auto& x : sh) cout << x << endl;

    return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 13568
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ll = long long;

bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; }
bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    vector<bool> seen(N, false);
    vector<int> E(M);
    for (auto &e : E) cin >> e, e--;
    reverse(E.begin(), E.end());
    vector<int> ans;
    for (auto e : E) {
        if (seen[e]) continue;
        seen[e] = true;
        ans.push_back(e);
    }
    for (int i = 0; i < N; i++) {
        if (!seen[i]) ans.push_back(i);
    }
    for (auto e : ans) cout << e + 1 << '\n';
}
accuracy: 1
time_ms: 10
memory_kb: 5004
final_rank: 5

code_snippet: #include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ve = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define rep(i,s,n) for(ll i = (ll)s;i < (ll)n;i++)
#define rrep(i,l,r) for(ll i = r-1;i >= l;i--)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
#define UB(A,x) (int)(upper_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T> inline bool chmax(T &a,T b){if(a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a,T b){if(a > b){a = b;return true;}return false;}
ld dist(ld x1,ld y1,ld x2, ld y2){return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}


int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n,m;cin >> n >> m;
  vi b(n+1);
  iota(ALL(b),0);
  int cl = 0;
  rep(i,0,m){
    int e;cin >> e;
    b[e] = --cl;
  }
  vi idx(n);iota(ALL(idx),1);
  sort(ALL(idx),[&](int i,int j){return b[i] < b[j];});
  rep(i,0,n)cout << idx[i] << endl;
  

  return 0;
}
accuracy: 1
time_ms: 150
memory_kb: 6224
final_rank: 15

code_snippet: #include <bits/stdc++.h>

using namespace std;

int ar[200005];
int n,m,x;
stack<int> st;

int main()
{
    while(scanf("%d %d",&n,&m)!=EOF)
    {
        for(int i=n; i>0; i--)
        {
            ar[i]=0;
            st.push(i);
        }
        for(int i=0; i<m; i++)
        {
            scanf("%d",&x);
            st.push(x);
        }

        while(!st.empty())
        {
            int y= st.top();
            st.pop();
            if(ar[y]==1) continue;
            printf("%d\n", y);
            ar[y]=1;
        }
    }
}
accuracy: 1
time_ms: 10
memory_kb: 5592
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define range(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i == (v.size() - 1) ? "" : ", ");
    }
    os << "]";
    return os;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2> p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T> s) {
    if (s.empty()) {
        os << "{}";
        return os;
    }
    os << "{";
    auto it = s.begin();
    while (it != s.end()) {
        cout << *it << (++it == s.end() ? "}" : ", ");
    }
    return os;
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> v(n + q);
    rep(i, n) v[i] = n - i;
    rep(i, q) {
        int x;
        cin >> x;
        v[n + i] = x;
    }

    vector<bool> seen(n + 1, false);
    rrep(i, n + q - 1) {
        if (seen[v[i]]) continue;
        seen[v[i]] = true;
        cout << v[i] << "\n";
    }
}
accuracy: 1
time_ms: 20
memory_kb: 4608
final_rank: 9

code_snippet: #include <stdio.h>
#include <bits/stdtr1c++.h>

#define MAX 1000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl

using namespace std;

struct node{
    node *l, *r, *parent;
    int val, subtree, priority;

    inline node(){
        l = r = parent = 0;
    }

    inline node(int v){
        val = v, priority = rand();
        l = r = parent = 0, subtree = 1;
    }

    inline node(long long v, int p){
        l = r = 0, subtree = 1;
        val = v, priority = p;
    }

    inline void update(){
        subtree = 1;
        if (l){
            l->parent = this;
            subtree += l->subtree;
        }
        if (r){
            r->parent = this;
            subtree += r->subtree;
        }
    }
} pool[MAX];

struct Treap{
    int idx;
    struct node* root;

    inline int size(node* &cur){
        if (cur) cur->update();
        return (cur ? cur->subtree : 0);
    }

    inline int size(){
        return (root ? root->subtree : 0);
    }

    inline int rank(node* cur){
        int counter = 1 + size(cur->l);
        while (cur->parent){
            if (cur->parent->r == cur) counter += (size(cur->parent->l) + 1);
            cur = cur->parent;
        }
        return counter;
    }

    inline void merge(node* &cur, node* l, node* r){
        if (!l || !r) cur = l ? l : r;
        else if (l->priority > r->priority) merge(l->r, l->r, r), cur = l;
        else merge(r->l, l, r->l), cur = r;
        if (cur) cur->update();
    }

    inline void split(node* cur, node* &l, node* &r, int key, int counter = 0){
        if (!cur){
            l = r = 0;
            return;
        }

        int cur_key = counter + (cur->l ? cur->l->subtree : 0);
        if (key <= cur_key) split(cur->l, l, cur->l, key, counter), r = cur;
        else split(cur->r, cur->r, r, key, cur_key + 1), l = cur;
        if (cur) cur->update();
    }

    inline void insert(int i, int v){
        node *l, *r;
        split(root, l, r, i);
        pool[idx] = node(v);
        merge(root, l, &pool[idx++]);
        merge(root, root, r);
    }

    inline int query(int a, int b){
        node *l, *r, *m;
        split(root, l, r, a - 1);
        split(r, m, r, b - a + 1);
        int res = m->val;
        merge(m, m, r);
        merge(root, l, m);
        return res;
    }

    inline void move_front(int i){
        node *l, *r, *m;
        split(root, l, r, i - 1);
        split(r, m, r, 1);
        merge(root, m, l);
        merge(root, root, r);
    }

    Treap(){
        srand(time(0));
        idx = 1, root = 0;
    }
};

int n, ar[MAX];

int main(){
    int q, i, j, k, l, x;

    while (scanf("%d %d", &n, &q) != EOF){
        assert(q != 99736);
        Treap T = Treap();
        for (i = 1; i <= n; i++) T.insert(i, i);

        while (q--){
            scanf("%d", &x);
            k = T.rank(&pool[x]);
            T.move_front(k);
        }

        for (i = 1; i <= n; i++) printf("%d\n", T.query(i, i));
    }
    return 0;
}
accuracy: 0.3548387096774194
time_ms: 150
memory_kb: 44520
final_rank: 20

code_snippet: #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;
}
accuracy: 1
time_ms: 10
memory_kb: 4344
final_rank: 2

code_snippet: #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define MAXN 200500

using namespace std;

int n,m;
struct data{
	int from,to;
}a[MAXN];

int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		a[i].from=i-1;
		a[i].to=i+1;
	}
	a[1].from=1;
	a[n].to=n;
	int x;int start=1;
	for(int i=1;i<=m;i++){
		scanf("%d",&x);
		if(x==start) continue;
		a[a[x].to].from=a[x].from;
		a[a[x].from].to=a[x].to;
		a[start].from=x;
		a[x].to=start;
		a[x].from=x;
		start=x;
	}
	for(int i=start,cnt=1;cnt<=n;i=a[i].to,cnt++)
		printf("%d\n",i);
}
/*
10 8
1
4
7
3
4
10
1
3


*/
accuracy: 0.6129032258064516
time_ms: 10
memory_kb: 4508
final_rank: 19

code_snippet: #include<iostream>
using namespace std;
int n,m,a[200005],bo[200005];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) scanf("%d",&a[i]);
	for (int i=m;i>=1;i--) 
	if (bo[a[i]]==0)
	{
		bo[a[i]]=1;
		printf("%d\n",a[i]);
	}
	for (int i=1;i<=n;i++)
	if (bo[i]==0) printf("%d\n",i);	
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4736
final_rank: 4

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <ranges>
namespace ranges = std::ranges;
int N, M, E[200020];
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cin >> N >> M;
    for (int i = 0 ; i < M ; i++) {
        std::cin >> E[M - i - 1];
        E[M - i - 1]--;
    }
    std::vector<int> ans, used(N);
    ans.reserve(N);
    for (int i = 0 ; i < M ; i++) {
        if (used[E[i]]) continue;
        ans.push_back(E[i]);
        used[E[i]] = true;
    }
    for (int i = 0 ; i < N ; i++) if (!used[i]) ans.push_back(i);
    for (int a : ans) std::cout << a + 1 << '\n';
}
accuracy: 1
time_ms: 10
memory_kb: 5376
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) a.begin(),a.end()
#define reps(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, a, n) for (int i = (a); i > (int)(n); i--)
const long long mod = 1000000007;
const long long INF = 1e18;
ll myceil(ll a, ll b) {return (a+b-1)/b;}


void solve() {
    ll n,m;
    cin >> n >> m;
    vector<int> v(m);
    rep(i,m) {
        cin >> v[i];
        v[i]--;
    }

    vector<int> alr(n,1);

    rep(i,m) {
        if (alr[v[m-i-1]]) {
            cout << v[m-i-1]+1 << endl;
            alr[v[m-i-1]] = 0;
        }
    }

    rep(i,n) {
        if (alr[i]) {
            cout << i+1 << endl;
        }
    }
    return;
}


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int t = 1;
    //cin >> t;
    rep(i,t) {
        solve();
    }
}
accuracy: 1
time_ms: 140
memory_kb: 4372
final_rank: 10

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
using ll = long long;
const int MOD = 1000000007;
const int Mod = 998244353;
const int MAX = 1000000005;
const long long INF = 1000000000000000005LL;
using namespace std;
//using namespace atcoder;


void solve() {
    
}

int main() {
    ios::sync_with_stdio(0); cin.tie();
    int n, m;
    cin >> n >> m;
    vector<int> front(n+1), back(n+1);
    for (int i = 1; i < n; i++) back[i] = i+1;
    for (int i = 2; i <= n; i++) front[i] = i-1;
    int head = 1;
    while (m--) {
        int e;
        cin >> e;
        if (e == head) continue;
        int frontElem = front[e], backElem = back[e];
        back[frontElem] = backElem;
        front[backElem] = frontElem;
        front[e] = 0;
        back[e] = head;
        front[head] = e;
        head = e;
        //for (int i = 1; i <= n; i++) cout << front[i] << " " << back[i] << endl;
    }
    int now = head;
    while (now != 0) {
        cout << now << endl;
        now = back[now];
    }
}
accuracy: 1
time_ms: 140
memory_kb: 4664
final_rank: 11

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

#include <unistd.h>

namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf


uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
    char num[10000][4];
    constexpr Pre() : num() {
        for (int i = 0; i < 10000; i++) {
            int n = i;
            for (int j = 3; j >= 0; j--) {
                num[i][j] = n % 10 | '0';
                n /= 10;
            }
        }
    }
} constexpr pre;

inline void load() {
    memmove(ibuf, ibuf + pil, pir - pil);
    pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
    pil = 0;
    if (pir < SZ)
        ibuf[pir++] = '\n';
}

inline void flush() {
    fwrite(obuf, 1, por, stdout);
    por = 0;
}

void rd(char &c) {
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
}

void rd(string &x) {
    x.clear();
    char c;
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
    do {
        x += c;
        if (pil == pir)
            load();
        c = ibuf[pil++];
    } while (!isspace(c));
}

template <typename T> void rd_real(T &x) {
    string s;
    rd(s);
    x = stod(s);
}

template <typename T> void rd_integer(T &x) {
    if (pil + 100 > pir)
        load();
    char c;
    do
        c = ibuf[pil++];
    while (c < '-');
    bool minus = 0;
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (c == '-') {
            minus = 1, c = ibuf[pil++];
        }
    }
    x = 0;
    while ('0' <= c) {
        x = x * 10 + (c & 15), c = ibuf[pil++];
    }
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (minus)
            x = -x;
    }
}

void rd(int &x) {
    rd_integer(x);
}
void rd(ll &x) {
    rd_integer(x);
}
void rd(i128 &x) {
    rd_integer(x);
}
void rd(uint &x) {
    rd_integer(x);
}
void rd(ull &x) {
    rd_integer(x);
}
void rd(u128 &x) {
    rd_integer(x);
}
void rd(double &x) {
    rd_real(x);
}
void rd(long double &x) {
    rd_real(x);
}

template <class T, class U> void rd(pair<T, U> &p) {
    return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T> void rd_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
        auto &x = std::get<N>(t);
        rd(x);
        rd_tuple<N + 1>(t);
    }
}
template <class... T> void rd(tuple<T...> &tpl) {
    rd_tuple(tpl);
}

template <size_t N = 0, typename T> void rd(array<T, N> &x) {
    for (auto &d : x)
        rd(d);
}
template <class T> void rd(vector<T> &x) {
    for (auto &d : x)
        rd(d);
}

void read() {}
template <class H, class... T> void read(H &h, T &...t) {
    rd(h), read(t...);
}

void wt(const char c) {
    if (por == SZ)
        flush();
    obuf[por++] = c;
}
void wt(const string s) {
    for (char c : s)
        wt(c);
}
void wt(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++)
        wt(s[i]);
}

template <typename T> void wt_integer(T x) {
    if (por > SZ - 100)
        flush();
    if (x < 0) {
        obuf[por++] = '-', x = -x;
    }
    int outi;
    for (outi = 96; x >= 10000; outi -= 4) {
        memcpy(out + outi, pre.num[x % 10000], 4);
        x /= 10000;
    }
    if (x >= 1000) {
        memcpy(obuf + por, pre.num[x], 4);
        por += 4;
    } else if (x >= 100) {
        memcpy(obuf + por, pre.num[x] + 1, 3);
        por += 3;
    } else if (x >= 10) {
        int q = (x * 103) >> 10;
        obuf[por] = q | '0';
        obuf[por + 1] = (x - q * 10) | '0';
        por += 2;
    } else
        obuf[por++] = x | '0';
    memcpy(obuf + por, out + outi + 4, 96 - outi);
    por += 96 - outi;
}

template <typename T> void wt_real(T x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << double(x);
    string s = oss.str();
    wt(s);
}

void wt(int x) {
    wt_integer(x);
}
void wt(ll x) {
    wt_integer(x);
}
void wt(i128 x) {
    wt_integer(x);
}
void wt(uint x) {
    wt_integer(x);
}
void wt(ull x) {
    wt_integer(x);
}
void wt(u128 x) {
    wt_integer(x);
}
void wt(double x) {
    wt_real(x);
}
void wt(long double x) {
    wt_real(x);
}

template <class T, class U> void wt(const pair<T, U> val) {
    wt(val.first);
    wt(' ');
    wt(val.second);
}
template <size_t N = 0, typename T> void wt_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
        if constexpr (N > 0) {
            wt(' ');
        }
        const auto x = std::get<N>(t);
        wt(x);
        wt_tuple<N + 1>(t);
    }
}
template <class... T> void wt(tuple<T...> tpl) {
    wt_tuple(tpl);
}
template <class T, size_t S> void wt(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}
template <class T> void wt(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}

void print() {
    wt('\n');
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
    wt(head);
    if (sizeof...(Tail))
        wt(' ');
    print(forward<Tail>(tail)...);
}
void __attribute__((destructor)) _d() {
    flush();
}
} // namespace fastio


using fastio::flush;
using fastio::print;
using fastio::read;

inline void first(bool i = true) {
    print(i ? "first" : "second");
}
inline void Alice(bool i = true) {
    print(i ? "Alice" : "Bob");
}
inline void Takahashi(bool i = true) {
    print(i ? "Takahashi" : "Aoki");
}
inline void yes(bool i = true) {
    print(i ? "yes" : "no");
}
inline void Yes(bool i = true) {
    print(i ? "Yes" : "No");
}
inline void No() {
    print("No");
}
inline void YES(bool i = true) {
    print(i ? "YES" : "NO");
}
inline void NO() {
    print("NO");
}
inline void Yay(bool i = true) {
    print(i ? "Yay!" : ":(");
}
inline void Possible(bool i = true) {
    print(i ? "Possible" : "Impossible");
}
inline void POSSIBLE(bool i = true) {
    print(i ? "POSSIBLE" : "IMPOSSIBLE");
}

/**
 * @brief Fast IO
 */

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(N,-1);
    rep(i,0,M) {
        int A;
        cin >> A;
        A--;
        X[A] = i;
    }
    vector<pair<int,int>> V(N);
    rep(i,0,N) V[i] = {-X[i],i};
    sort(ALL(V));
    rep(i,0,N) cout << V[i].second + 1 << endl;
}
accuracy: 1
time_ms: 160
memory_kb: 5588
final_rank: 16

code_snippet: #include <bits/stdc++.h>

int main() {
    int n, q;
    std::cin >> n >> q;
    std::vector<int> a(q);
    for (int i = 0; i < q; i++) {
        std::cin >> a[i];
        a[i]--;
    }
    std::vector<bool> used(n);
    std::vector<int> ans;
    for (int i = q - 1; i >= 0; i--) {
        if (!used[a[i]]) {
            used[a[i]] = true;
            ans.push_back(a[i]);
        }
    }
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            ans.push_back(i);
        }
    }
    for (auto v: ans) {
        std::cout << v + 1 << '\n';
    }
}
accuracy: 1
time_ms: 20
memory_kb: 4568
final_rank: 8

code_snippet: #include <bits/stdc++.h>

#define rep(i,s,n) for(int i = int(s); i < int(n); i++)
#define rrep(i,s,n) for(int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<class T>
bool chmin(T &a, T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

template<class T>
bool chmax(T &a, T b) {
    if(a >= b) return false;
    a = b;
    return true;
}

using namespace std;

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vector<int> e(m);
    rep(i,0,m) cin >> e[i];

    vector<bool> seen(n+1);
    rrep(i,0,m){
        if (seen[e[i]]) continue;
        cout << e[i] << '\n';
        seen[e[i]] = 1;
    }

    rep(i,1,n+1){
        if (seen[i]) continue;
        cout << i << '\n';
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3596
final_rank: 1

code_snippet: #include <iostream>
#include <vector>
using namespace std;

int N,M;

int main(void) {
  cin >> N >> M;
  vector<int> q(M);
  for (int i = 0; i < M; ++i) {
    cin >> q[i];
    --q[i];
  }
  vector<bool> used(N, false);
  for (int i = M-1; i >= 0; --i) {
    if (used[q[i]]) {
      continue;
    }
    else {
      cout << q[i] + 1 << endl;
      used[q[i]] = true;
    }
  }
  for (int i = 0; i < N; ++i) {
    if (!used[i]) {
      cout << i + 1 << endl;
    }
  }
}
accuracy: 1
time_ms: 150
memory_kb: 3604
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define per(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define per2(i, l, r) for (int i = (r)-1; i >= (l); i--)
#define each(e, v) for (auto &e : v)
#define MM << " " <<
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
using maxheap = priority_queue<T>;

template <typename T>
bool chmax(T &x, const T &y) {
    return (x < y) ? (x = y, true) : false;
}

template <typename T>
bool chmin(T &x, const T &y) {
    return (x > y) ? (x = y, true) : false;
}

template <typename T>
int flg(T x, int i) {
    return (x >> i) & 1;
}

template <typename T>
void print(const vector<T> &v, T x = 0) {
    int n = v.size();
    for (int i = 0; i < n; i++) cout << v[i] + x << (i == n - 1 ? '\n' : ' ');
    if (v.empty()) cout << '\n';
}

template <typename T>
void printn(const vector<T> &v, T x = 0) {
    int n = v.size();
    for (int i = 0; i < n; i++) cout << v[i] + x << '\n';
}

template <typename T>
int lb(const vector<T> &v, T x) {
    return lower_bound(begin(v), end(v), x) - begin(v);
}

template <typename T>
int ub(const vector<T> &v, T x) {
    return upper_bound(begin(v), end(v), x) - begin(v);
}

template <typename T>
void rearrange(vector<T> &v) {
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
}

template <typename T>
vector<int> id_sort(const vector<T> &v, bool greater = false) {
    int n = v.size();
    vector<int> ret(n);
    iota(begin(ret), end(ret), 0);
    sort(begin(ret), end(ret), [&](int i, int j) { return greater ? v[i] > v[j] : v[i] < v[j]; });
    return ret;
}

template <typename S, typename T>
pair<S, T> operator+(const pair<S, T> &p, const pair<S, T> &q) {
    return make_pair(p.first + q.first, p.second + q.second);
}

template <typename S, typename T>
pair<S, T> operator-(const pair<S, T> &p, const pair<S, T> &q) {
    return make_pair(p.first - q.first, p.second - q.second);
}

template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &p) {
    S a;
    T b;
    is >> a >> b;
    p = make_pair(a, b);
    return is;
}

template <typename S, typename T>
ostream &operator<<(ostream &os, const pair<S, T> &p) {
    return os << p.first << ' ' << p.second;
}

struct io_setup {
    io_setup() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

const int inf = (1 << 30) - 1;
const ll INF = (1LL << 60) - 1;
// const int MOD = 1000000007;
const int MOD = 998244353;

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> a(M);
    rep(i, M) cin >> a[i], a[i]--;

    reverse(all(a));
    vector<bool> used(N, false);

    vector<int> ans;

    rep(i, M) {
        if (!used[a[i]]) {
            used[a[i]] = true;
            ans.eb(a[i]);
        }
    }

    rep(i, N) {
        if (!used[i]) ans.eb(i);
    }

    printn(ans, 1);
}
accuracy: 1
time_ms: 10
memory_kb: 4452
final_rank: 3

code_snippet: #include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define rep(i,s,f) for (ll i = (s);i < (ll)(f);i++)

int main(){
    int n,m;
    cin >>n>>m;
    vector<int>vec(m);
    rep(i,0,m)cin>>vec[i];
    vector<bool>used(n+1,false);
    for(int i=m-1;i>=0;i--){
        if(used[vec[i]]){
            //ignore
        }else{
            cout<<vec[i]<<endl;
            used[vec[i]]=true;
        }
    }

    rep(i,1,n+1){
        if(used[i]==false){
            cout<<i<<endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 150
memory_kb: 3640
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    int last[n];
    for (int i = 0; i < n; i++) {
        last[i] = -1;
    }
    for (int i = 0; i < m; i++) {
        int e;
        cin >> e;
        e--;
        last[e] = i;
    }

    set<pair<int,int>> heads;
    set<int> remains;

    for (int i = 0; i < n; i++) {
        if(last[i] == -1) remains.insert(i);
        else heads.insert({-last[i], i});
    }

    for (auto x: heads) cout << x.second + 1 << endl;
    for (auto x: remains) cout << x + 1 << endl;
}
accuracy: 1
time_ms: 180
memory_kb: 13568
final_rank: 18