func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   int vals[N], found[N];   struct node {     node *left, *right;     int val, size, priority;     node(int v) {       val = v, size = 1, priority = rand(), left = NULL, right = NULL;     }   };   int sz(node* t) { return (t) ? t->size : 0; }   void upd_sz(node*& t) {     if (t) t->size = sz(t->left) + 1 + sz(t->right);   }   void split(node* t, node*& l, node*& r, int k) {     if (!t)       l = r = NULL;     else if (sz(t->left) + 1 <= k)       split(t->right, t->right, r, k - sz(t->left) - 1), l = t;     else       split(t->left, l, t->left, k), r = t;     upd_sz(t);   }   void merge(node*& t, node* l, node* r) {     if (!l || !r)       t = l ? l : r;     else if (l->priority >= r->priority)       merge(l->right, l->right, r), t = l;     else       merge(r->left, l, r->left), t = r;     upd_sz(t);   }   int main() {     srand(time(NULL));     int n, m, x, y;     scanf( %d %d , &n, &m);     node* t = NULL;     for (int i = 1; i <= n; i++) {       merge(t, t, new node(i));     }     node* a;     node* b;     while (m--) {       scanf( %d %d , &x, &y);       split(t, a, t, y);       split(a, a, b, y - 1);       if (vals[b->val] == x) {       } else if (vals[b->val] == 0 && found[x] == 0)         vals[b->val] = x;       else {         printf( -1 n );         return 0;       }       found[x] = 1;       merge(a, b, a);       merge(t, a, t);     }     int f = 1;     for (int i = 1; i <= n; i++) {       if (vals[i] == 0) {         while (found[f] != 0) {           f++;         }         vals[i] = f++;       }     }     for (int i = 1; i <= n; i++) {       printf( %d  , vals[i]);     }     printf(  n );     return 0;   }   