malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   double prob[maxn];   int main() {     ios::sync_with_stdio(false);     int n, p;     while (cin >> n >> p) {       int l, r;       for (int i = 0; i < n; ++i) {         cin >> l >> r;         prob[i] = (double)(r / p - (l - 1) / p) / (r + 1 - l);       }       double sum = 0;       for (int i = 0; i < n; ++i) {         int j = (i + 1) % n;         sum += 1.0 - (1 - prob[i]) * (1 - prob[j]);       }       printf( %.8lf n , sum * 2000);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int MAX = -1000000000000000000;   const long long int MIN = 1000000000000000000;   const long long int inf = 1000000000000000000;   const long long int KOK = 100000;   const long long int LOG = 30;   const long long int li = 105;   const long long int mod = 1000000007;   long long int n, m, cev, b, a[li], k, dp[105][100005], PS[li][li];   string s;   vector<int> v;   long long int f(long long int sira, long long int topl) {     long long int mn = inf;     if (topl <= 0) return 0;     if (sira > n) {       return inf;     }     if (~dp[sira][topl]) return dp[sira][topl];     for (int i = sira; i <= n; i++) {       mn = min(mn, f(i + 1, topl - PS[sira][i] + PS[sira][sira - 1]) + 1);     }     return dp[sira][topl] = mn;   }   int main() {     memset(dp, -1, sizeof(dp));     scanf( %lld %lld , &n, &m);     for (long long int i = 1; i <= n; i++) {       scanf( %lld , &a[i]);     }     sort(a + 1, a + n + 1);     reverse(a + 1, a + n + 1);     for (long long int i = 1; i <= n; i++) {       long long int at = 0;       for (long long int j = i; j <= n; j++) {         PS[i][j] = PS[i][j - 1] + max(a[j] - at, 0ll);         at++;       }     }     long long int yess = f(1, m);     if (yess >= inf) {       printf( -1 n );       return 0;     }     printf( %lld n , yess);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1061109567;   const int MAXN = 510005;   int dp[MAXN];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout.precision(20);     int n, d;     cin >> n >> d;     memset(dp, 0, sizeof dp);     dp[0] = 1;     int items[n];     for (int i = 0; i < n; i++) cin >> items[i];     for (int j = 0; j < n; j++) {       for (int i = MAXN - items[j]; i >= 0; i--)         if (dp[i]) dp[i + items[j]] = 1;     }     int itCount = 0;     int i = 0;     while (i < 500000) {       bool flag = false;       for (int j = i + d; j >= i + 1; j--) {         if (dp[j]) {           itCount++;           i = j;           flag = true;           break;         }       }       if (!flag) break;     }     cout << i <<     << itCount << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[1005][1005], i, m, ans, k, l, j, q, x, n, ma, mi;   string s;   int main() {     cin >> n >> k;     if (k >= (n + 1) / 2) {       cout << -1;       return 0;     }     cout << n * k << endl;     for (int i = 1; i <= n; i++) {       int w = k;       for (int j = 1; j <= n; j++) {         if (a[i][j] == 1 || i == j) continue;         cout << i <<     << j << endl;         a[i][j] = 1;         a[j][i] = 1;         w--;         if (!w) break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     string oper;     bool val;     int left = -1;     int right = -1;     bool will_left_change = false;     bool will_right_change = false;   };   vector<Node> tree;   bool f(bool l_val, bool r_val, string oper) {     if (oper ==  AND ) {       return (l_val && r_val);     } else if (oper ==  OR ) {       return (l_val || r_val);     } else if (oper ==  XOR ) {       return (l_val ^ r_val);     }   }   void calc(Node &v) {     if (v.oper ==  IN ) return;     calc(tree[v.left]);     if (v.right != -1) {       calc(tree[v.right]);     }     if (v.right == -1)       v.val = !tree[v.left].val;     else {       v.val = f(tree[v.left].val, tree[v.right].val, v.oper);     }     if (v.right == -1)       v.will_left_change = true;     else {       v.will_left_change = (f(tree[v.left].val, tree[v.right].val, v.oper) !=                             f(!tree[v.left].val, tree[v.right].val, v.oper));       v.will_right_change = (f(tree[v.left].val, tree[v.right].val, v.oper) !=                              f(tree[v.left].val, !tree[v.right].val, v.oper));     }   }   vector<int> ans;   void calc_leaves(Node &v, int ones_cnt, int depth, int v_index) {     if (v.oper ==  IN ) {       if (ones_cnt == depth) {         ans[v_index] = !tree[1].val;       } else {         ans[v_index] = tree[1].val;       }       return;     }     calc_leaves(tree[v.left], ones_cnt + (int)v.will_left_change, depth + 1,                 v.left);     if (v.right != -1) {       calc_leaves(tree[v.right], ones_cnt + (int)v.will_right_change, depth + 1,                   v.right);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     tree.resize(n + 1);     ans.resize(n + 1, -1);     for (int i = 1; i <= n; i++) {       string s;       cin >> s;       if (s ==  IN ) {         int z;         cin >> z;         tree[i].oper = s;         tree[i].val = z;       } else if (s ==  NOT ) {         int id;         cin >> id;         tree[i].oper = s;         tree[i].left = id;       } else {         int left, right;         cin >> left >> right;         tree[i].oper = s;         tree[i].left = left;         tree[i].right = right;       }     }     calc(tree[1]);     calc_leaves(tree[1], 0, 0, -1);     for (int i = 1; i <= n; i++) {       if (ans[i] != -1) cout << ans[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   priority_queue<long long> q;   int n, k;   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < k; i++) q.push(0);     for (int i = 0; i < n; i++) {       long long s, m;       scanf( %I64d%I64d , &s, &m);       long long num = q.top();       q.pop();       num = max(-num, s);       printf( %I64d n , m + num);       q.push(-(m + num));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, a, b, c, r;     cin >> t;     while (t--) {       cin >> a >> b >> c >> r;       int min = a < b ? a : b;       int max = min == a ? b : a;       int res = max - min + 1;       if (c - r >= min && c + r <= max) {         res = res - 2 * r - 1;       } else if (min > c - r && max < c + r) {         res = 0;       } else if (c - r >= min && c - r <= max && c + r >= max) {         res = res - (max - c + r) - 1;       } else if (c + r <= max && c + r >= min && min >= c - r) {         res = res - (c + r - min) - 1;       }       res = res == max - min + 1 ? max - min : res;       cout << res << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, a[2006];   int one, g, mn = 1e9;   int gcd(int _a, int _b) { return _b == 0 ? _a : gcd(_b, _a % _b); }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       g = gcd(g, a[i]);       if (a[i] == 1) one++;     }     if (one != 0) {       printf( %d n , n - one);       return 0;     }     if (g != 1) {       puts( -1 );       return 0;     }     for (int i = 1; i <= n; i++) {       int b = a[i];       for (int j = i + 1; j <= n; j++) {         b = gcd(b, a[j]);         if (b == 1) {           mn = min(mn, j - i);           break;         }       }     }     printf( %d n , mn + n - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxk = 11;   long long p[maxk];   void init() {     p[0] = 1;     for (int i = 1; i <= maxk; ++i) p[i] = p[i - 1] * 10;   }   long long f(long long x) {     if (x == 0) return 0;     long long ret = 0;     int pc = maxk - 1;     while (p[pc] > x) --pc;     ret += (pc + 1) * (x - p[pc] + 1);     while (pc > 0) {       --pc;       ret += (pc + 1) * (p[pc + 1] - p[pc]);     }     return ret;   }   typedef long long (*FUN)(long long);   long long bis(long long pos, FUN fun) {     long long ans = 0;     long long l = 0, r = 1000000000;     while (l < r) {       long long mid = l + (r - l) / 2;       if (fun(mid) < pos)         ans = mid, l = mid + 1;       else         r = mid;     }     return ans;   }   long long g(long long x) {     if (x == 0) return 0;     int pc = maxk - 1;     while (p[pc] > x) --pc;     long long ret = 0;     ret += (pc + 1) * (x - p[pc] + 1) * (1 + x - p[pc] + 1) / 2;     while (pc > 0) {       --pc;       ret += (pc + 1) * 9 * p[pc] * (x + x - (p[pc] - 1) - (p[pc + 1] - 2)) / 2;     }     return ret;   }   char cc[100000];   int main() {     init();     int q;     long long k;     scanf( %d , &q);     long long temp = 0;     while (q--) {       scanf( %lld , &k);       long long ans = bis(k, g);       k -= g(ans);       ans = bis(k, f);       k -= f(ans);       sprintf(cc,  %lld , ans + 1);       printf( %c n , cc[k - 1]);     }     getchar();     getchar();     return 0;   }
#include <bits/stdc++.h>   const long long inf = 1e16;   using namespace std;   long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f * x;   }   int n;   long long ans, d[505][505];   struct tmp {     long long a, b, k;     bool operator<(const tmp &o) const { return b > o.b; }   } a[505];   int main() {     n = read();     for (int i = 1; i <= n; i++) a[i] = tmp{read(), read(), read()};     sort(a + 1, a + 1 + n);     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= i; j++) {         d[i][j] = d[i - 1][j];         if (j > 0)           d[i][j] = max(d[i][j], d[i - 1][j - 1] + a[i].a - (j - 1) * a[i].b);         d[i][j] = max(d[i][j], d[i - 1][j] + a[i].a - a[i].k * a[i].b);       }     }     for (int i = 1; i <= n; i++) ans = max(ans, d[n][i]);     return 0 * printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int c1, c2;       int d1, d2;       int diff1, diff2;       for (int i = 0; i < 3; i++) {         if ((n - i) % 3 == 0) {           c2 = (n - i) / 3;           c1 = n - 2 * c2;           diff1 = i;           break;         }       }       for (int i = 0; i < 3; i++) {         if ((n - i) % 3 == 0) {           d2 = (n + i) / 3;           d1 = n - 2 * d2;           diff2 = i;           break;         }       }       if (diff1 < diff2)         cout << c1 <<     << c2 <<   n ;       else         cout << d1 <<     << d2 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long int n = 0, m, l = 0, k, a, b, c, sum = 0, i, r = 0, j, second, h,                 first = 0, sc, ans = 0, x, t, y;   double aa, pp;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> k >> b >> n >> t;     if (k == 1) {       ans = (ceil((1 + n * b - t) * 1.0 / b));       if (ans <= 0)         cout << 0;       else         cout << ans;       return 0;     }     aa = (t * (k - 1)) + t * b;     aa = aa / (t * (k - 1) + b);     pp = n * (log(k)) - log(t) + log(aa);     pp = pp / log(k);     if (pp - floor(pp) < 1e-12) {       cout << setprecision(10) << floor(pp);       return 0;     }     ans = ceil(pp);     if (ans <= 0)       cout << 0;     else       cout << ans;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   const long double pi = acos(-1.0);   const long double eps = 1e-5;   const int INF = 0x3f3f3f3f;   const long long INFLL = 0x3f3f3f3f3f3f3f3f;   struct poi {     double x, y;   } p[200010];   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n;     cin >> n;     for (int i = (1); i <= (n); i++) cin >> p[i].x >> p[i].y;     if (n & 1) {       cout <<  NO ;       return 0;     }     poi c;     c.x = (p[1].x + p[n / 2 + 1].x) / 2;     c.y = (p[1].y + p[n / 2 + 1].y) / 2;     for (int i = (2); i <= (n / 2); i++) {       if (fabs((p[i].x + p[i + n / 2].x) / 2 - c.x) < eps &&           fabs((p[i].y + p[i + n / 2].y) / 2 - c.y) < eps)         ;       else {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int n, m, h, t, maxv;   int e[maxn][2];   set<int> mp[maxn];   vector<int> g[maxn];   vector<int> xv, yv;   set<int> comm;   bool check(int x, int y, vector<int> &xv, vector<int> &yv, set<int> &comm) {     int lx = max(0, (int)(h - xv.size()));     int ly = max(0, (int)(t - yv.size()));     if (comm.size() >= lx + ly) {       printf( YES n );       printf( %d %d n , x, y);       set<int>::iterator it = comm.begin();       int mx = min((int)xv.size(), h);       for (int i = 0; i < mx; i++) printf( %d  , xv[i]);       for (int i = 0; i < lx; i++) {         printf( %d  , *it);         it++;       }       printf(  n );       int my = min((int)yv.size(), t);       for (int i = 0; i < my; i++) printf( %d  , yv[i]);       for (int i = 0; i < ly; i++) {         printf( %d  , *it);         it++;       }       printf(  n );       return true;     }     return false;   }   bool solve(int x, int y) {     if (mp[x].size() <= h || mp[y].size() <= t) return false;     int cnt = mp[x].size() - 1;     for (int i = 0; i < g[y].size() && cnt < h + t; i++) {       int tx = g[y][i];       if (tx == x) continue;       if (mp[x].count(tx) == 0) cnt++;     }     if (cnt < h + t) return false;     xv.clear();     yv.clear();     comm.clear();     for (set<int>::iterator it = mp[x].begin();          it != mp[x].end() && xv.size() <= h && comm.size() <= maxv; it++) {       int ty = *it;       if (ty == y) continue;       if (mp[y].find(ty) != mp[y].end())         comm.insert(ty);       else         xv.push_back(ty);     }     for (set<int>::iterator it = mp[y].begin();          it != mp[y].end() && yv.size() <= t && comm.size() <= maxv; it++) {       int tx = *it;       if (tx == x) continue;       if (mp[x].find(tx) != mp[x].end())         comm.insert(tx);       else         yv.push_back(tx);     }     if (check(x, y, xv, yv, comm)) return true;     return false;   }   int main() {     scanf( %d%d%d%d , &n, &m, &h, &t);     maxv = h + t;     for (int i = 1; i <= n; i++) mp[i].clear();     for (int i = 0; i < m; i++) {       int tx, ty;       scanf( %d%d , &tx, &ty);       mp[tx].insert(ty);       mp[ty].insert(tx);       g[tx].push_back(ty);       g[ty].push_back(tx);     }     int flags = false;     for (int i = 1; i <= n; i++)       if (flags == false)         for (int j = 0; j < g[i].size(); j++) {           if (solve(i, g[i][j])) {             flags = true;             break;           }         }     if (!flags) printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, G, R, d[100127], w[100127], rt, tot = 0, mi[100127 * 20],                                             c[100127 * 20][2];   long long f[100127], s[100127], ans;   void change(int &p, int l, int r, int x, int v) {     if (!p) p = ++tot;     mi[p] = v;     if (l == r) return;     int mid = (1ll * l + r) >> 1;     (x <= mid) ? change(c[p][0], l, mid, x, v)                : change(c[p][1], mid + 1, r, x, v);   }   int Ask(int p, int l, int r, int L, int R) {     if (R < L) return n + 1;     if ((!p) || (R < l) || (r < L)) return n + 1;     if ((L <= l) && (r <= R)) return mi[p];     int mid = (1ll * l + r) >> 1;     return min(Ask(c[p][0], l, mid, L, R), Ask(c[p][1], mid + 1, r, L, R));   }   inline int Get(int v) {     if (v >= R) return Ask(rt, 0, R + G - 1, (v + G) % (R + G), v - 1);     return min(Ask(rt, 0, R + G - 1, v + G, R + G - 1),                Ask(rt, 0, R + G - 1, 0, v - 1));   }   inline long long calc(int x, int y, int v) {     if (y == n + 1) return 0;     v = (v + s[y] - s[x]) % (R + G);     return R + G - v;   }   int main() {     scanf( %d%d%d , &n, &G, &R);     int i, p, x;     for (i = 1; i <= n + 1; i++) scanf( %d , &d[i]);     w[n + 1] = n + 1;     f[n + 1] = 0;     for (i = 2; i <= n + 1; i++) s[i] = s[i - 1] + d[i];     for (i = n; i >= 1; i--) {       w[i] = Get(s[i] % (R + G));       change(rt, 0, R + G - 1, s[i] % (R + G), i);     }     for (i = n; i >= 1; i--) f[i] = f[w[i]] + s[w[i]] - s[i] + calc(i, w[i], 0);     scanf( %d , &m);     while (m--) {       scanf( %d , &x);       ans = d[1] + x;       x = (x + d[1]) % (G + R);       if (x >= G) {         ans += R + G - x;         x = 0;       }       p = Get((R + G - x) % (R + G));       ans += f[p] + s[p] + calc(1, p, x);       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T gcd(T a, T b) {     while (b ^= a ^= b ^= a %= b)       ;     return a;   }   template <class T>   T lcm(T a, T b) {     return (a / gcd<T>(a, b) * b);   }   template <class T>   inline int countbit(T n) {     return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));   }   template <class T>   inline bool isPrimeNumber(T n) {     if (n <= 1) return false;     for (T i = 2; i * i <= n; i++)       if (n % i == 0) return false;     return true;   }   template <class T>   inline T powerMod(T p, int e, T m) {     if (e == 0)       return 1 % m;     else if (e % 2 == 0) {       T t = powerMod(p, e / 2, m);       return multiplyMod(t, t, m);     } else       return multiplyMod(powerMod(p, e - 1, m), p, m);   }   bool isUpperCase(char c) { return c >=  A  && c <=  Z ; }   bool isLowerCase(char c) { return c >=  a  && c <=  z ; }   char toLowerCase(char c) { return (isUpperCase(c)) ? (c + 32) : c; }   char toUpperCase(char c) { return (isLowerCase(c)) ? (c - 32) : c; }   template <class T>   string toString(T n) {     ostringstream ost;     ost << n;     ost.flush();     return ost.str();   }   int toInt(string s) {     int r = 0;     istringstream sin(s);     sin >> r;     return r;   }   double toDouble(string s) {     double r = 0;     istringstream sin(s);     sin >> r;     return r;   }   const double pi = acos(-1.0);   int main() {     string s;     cin >> s;     int pos = -14;     vector<string> v = { 01:10 ,   02:20 ,  03:30 ,  04:40 ,  05:50 ,                          10:01 ,   11:11 ,  12:21 ,  13:31 ,  14:41 ,                           15:51 ,  20:02 ,  21:12 ,  22:22 ,  23:32 };     for (int i = 0; i < v.size(); i++) {       if (s < v[i]) {         pos = i;         break;       }     }     if (pos == -14)       cout <<  00:00 ;     else       cout << v[pos];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, t, tbl[510][510], star[510][510], sum[510];   int main() {     scanf( %d%d%d , &n, &m, &t);     if (t == 0) {       long long ans = 0;       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) ans += i * j;       cout << ans << endl;       return 0;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %1d , tbl[i] + j);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         star[i][j] = (tbl[i][j] && tbl[i - 1][j] && tbl[i + 1][j] &&                       tbl[i][j - 1] && tbl[i][j + 1]);     long long ans = 0;     for (int i = 2; i < n; i++) {       memset(sum, 0, sizeof(sum));       for (int j = i; j < n; j++) {         for (int k = 2; k < m; k++) sum[k] += star[j][k];         for (int k = 2, l = 2, now = 0; k < m; k++) {           while (l < m && (l <= k || now < t)) now += sum[l++];           if (now >= t) ans += m - l + 1;           now -= sum[k];         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> a;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     while (n--) {       int temp_val;       string temp_s;       cin >> temp_val >> temp_s;       sort(temp_s.begin(), temp_s.end());       if (a[temp_s] < 1)         a[temp_s] = temp_val;       else         a[temp_s] = min(a[temp_s], temp_val);     }     int ans = INT_MAX;     if (a[ A ] >= 1 && a[ B ] >= 1 && a[ C ] >= 1) ans = a[ A ] + a[ B ] + a[ C ];     if (a[ A ] >= 1 && a[ BC ] >= 1) ans = min(ans, a[ A ] + a[ BC ]);     if (a[ C ] >= 1 && a[ AB ] >= 1) ans = min(ans, a[ C ] + a[ AB ]);     if (a[ B ] >= 1 && a[ AC ] >= 1) ans = min(ans, a[ B ] + a[ AC ]);     if (a[ AB ] >= 1 && a[ BC ] >= 1) ans = min(ans, a[ AB ] + a[ BC ]);     if (a[ AC ] >= 1 && a[ AB ] >= 1) ans = min(ans, a[ AC ] + a[ AB ]);     if (a[ BC ] >= 1 && a[ AC ] >= 1) ans = min(ans, a[ BC ] + a[ AC ]);     if (a[ ABC ] >= 1) ans = min(ans, a[ ABC ]);     if (ans == INT_MAX)       cout << -1 << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   long long i, j, r, c, fre[1000], ans;   char na, name1[1000][1000];   using namespace std;   int main() {     scanf( %lld %lld %c , &r, &c, &na);     for (i = 0; i < r; i++) {       for (j = 0; j < c; j++) {         scanf(  %c , &name1[i][j]);       }     }     for (i = 0; i < r; i++) {       for (j = 0; j < c; j++) {         if (name1[i][j] == na) {           if (i - 1 >= 0) {             fre[(int)name1[i - 1][j]]++;           }           if (i + 1 < r) {             fre[(int)name1[i + 1][j]]++;           }           if (j + 1 < c) {             fre[(int)name1[i][j + 1]]++;           }           if (j - 1 >= 0) {             fre[(int)name1[i][j - 1]]++;           }         }       }     }     for (i = 65; i <= 90; i++) {       if (fre[i] > 0) {         ans++;       }     }     if (fre[(int)na] > 0) {       ans--;     }     printf( %lld n , ans);   }
#include <iostream>   #include <iomanip>   #include<iterator> // for iterators   #include<vector> // for vectors   #include <utility>   #include <algorithm>   #include <set>   #include <map>   #include <stack>   #include <unordered_map>   using namespace std;      int main()   {       int t, n, temp; scanf( %d , &t);       vector<int> v;       while (t --)       {           scanf( %d , &n);           for (int i = 0; i < n; ++i)           {               scanf( %d , &temp);               v.emplace_back(temp);           }           sort(v.begin() , v.end());           int counter = 0;           for (int i = 1; i < v.size(); ++i)           {               if (v[i] > v[0])                   counter ++;           }           printf( %d n  , counter);           v.clear();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long a, long long b) {     long long res = 1;     a %= 998244353;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % 998244353 % 998244353;       a = a * a % 998244353;     }     return res;   }   long long gcd(long long a, long long b) {     if (a < b) return gcd(b, a);     if (b == 0) return a;     return gcd(b, a % b);   }   long long n, m;   long long flg = 0;   vector<long long> ad[500005];   long long t[500005];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ;     long long i, j, k, x;     cin >> n >> m;     for (i = 0; i < m; i++) {       cin >> j >> k;       ad[j].push_back(k);       ad[k].push_back(j);     }     vector<pair<long long, long long> > ans;     for (i = 1; i <= n; i++) {       cin >> t[i];       ans.push_back(make_pair(t[i], i));     }     sort(ans.begin(), ans.end());     for (i = 1; i <= n; i++) {       set<long long> tp;       for (auto x : ad[i]) {         tp.insert(t[x]);       }       for (j = 1; j < t[i]; j++) {         auto it = tp.find(j);         if (it == tp.end()) {           cout << -1 <<   n ;           return 0;         } else {           tp.erase(j);         }       }       auto it = tp.find(t[i]);       if (it != tp.end()) {         cout << -1 <<   n ;         return 0;       }     }     for (i = 0; i < ans.size(); i++) {       cout << ans[i].second <<    ;     }     cout <<   n ;     return 0;   }