malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, fl = 1;     char st = getchar();     while (st <  0  || st >  9 ) {       if (st ==  - ) fl = -1;       st = getchar();     }     while (st >=  0  && st <=  9 ) x = x * 10 + st -  0 , st = getchar();     return x * fl;   }   const int N = 1e6 + 10, mod = 1e9 + 9;   int n, b, w;   long long ans, fac[8005], invfac[8005];   inline long long ksm(long long x, long long y) {     long long res = 1;     while (y) {       if (y & 1) res = res * x % mod;       x = x * x % mod;       y >>= 1;     }     return res;   }   inline long long C(int x, int y) {     return fac[x] * invfac[y] % mod * invfac[x - y] % mod;   }   int main() {     ans = 1;     n = read();     w = read();     b = read();     fac[0] = 1;     fac[1] = 1;     for (int i = 2; i <= 8000; i++) fac[i] = fac[i - 1] * i % mod;     invfac[0] = invfac[1] = 1;     invfac[8000] = ksm(fac[8000], mod - 2);     for (int i = 7999; i >= 2; i--) {       invfac[i] = invfac[i + 1] * (i + 1) % mod;     }     ans = fac[w] * fac[b] % mod;     ans = ans * (w - 1) % mod;     ans = ans * C(w + b - 3, n - 3) % mod;     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     int w, b;     cin >> w >> b;     vector<int> ve;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       ve.push_back(x);     }     int res = 0;     for (int i = 0, j = n - 1; i <= j; i++, j--) {       if (ve[i] == ve[j] && ve[i] == 2) {         res += (i == j ? 1 : 2) * min(w, b);       } else if (ve[i] == ve[j])         continue;       else if (ve[i] != ve[j]) {         if (ve[i] == 2)           res += (ve[j] == 0 ? w : b);         else if (ve[j] == 2)           res += (ve[i] == 0 ? w : b);         else {           cout << -1 << endl;           return 0;         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> a[100005];   int n, t, v[100005], c[100005];   int main() {     cin >> n;     for (int i = 0; i < n - 1; ++i) cin >> a[i].first >> a[i].second;     for (int i = 0; i < n; ++i) cin >> c[i + 1];     for (int i = 0; i < n - 1; ++i) {       if (c[a[i].first] != c[a[i].second]) {         t++;         v[a[i].first]++;         v[a[i].second]++;       }     }     for (int i = 1; i <= n; ++i) {       if (v[i] == t) {         cout <<  YES n  << i <<   n ;         return 0;       }     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const pair<int, int> DD[] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},                                {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};   template <class T>   T smin(T &a, T b) {     if (a > b) a = b;     return a;   }   template <class T>   T smax(T &a, T b) {     if (a < b) a = b;     return a;   }   int main(void) {     srand(time(0));     cout << fixed << setprecision(7);     cerr << fixed << setprecision(7);     int n;     cin >> n;     if ((n % 4) == 2 || (n % 4) == 3) return puts( NO ) * 0;     puts( YES );     auto go = [&](int a, int b) {       cout << min(a, b) <<     << max(a, b) <<   n ;     };     for (int i = 1; i + 3 <= n; i += 4) {       if (n % 4)         go(i, n), go(i, i + 1), go(i + 1, n), go(n, i + 2), go(i + 2, i + 3),             go(i + 3, n);       else         go(i, i + 1), go(i + 2, i + 3);       go(i + 1, i + 2);       go(i, i + 3);       go(i, i + 2);       go(i + 1, i + 3);     }     vector<pair<int, int> > v;     v.push_back(make_pair(3, 2));     v.push_back(make_pair(2, 2));     v.push_back(make_pair(3, 1));     v.push_back(make_pair(0, 1));     v.push_back(make_pair(1, 3));     v.push_back(make_pair(2, 3));     v.push_back(make_pair(1, 2));     v.push_back(make_pair(1, 1));     v.push_back(make_pair(3, 0));     v.push_back(make_pair(3, 3));     v.push_back(make_pair(0, 2));     v.push_back(make_pair(0, 3));     v.push_back(make_pair(2, 0));     v.push_back(make_pair(2, 1));     v.push_back(make_pair(1, 0));     v.push_back(make_pair(0, 0));     for (int i = 1; i + 3 <= n; i += 4)       for (int j = i + 4; j + 3 <= n; j += 4)         for (auto it : v) go(i + it.first, j + it.second);     cerr <<  Time elapsed :  << clock() * 1000.0 / CLOCKS_PER_SEC <<   ms           <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> v;   int bil;   void gen(long long int now) {     if (now > 1000000000LL) return;     if (now != 0) v.push_back(now);     gen(now * 10 + 4);     gen(now * 10 + 7);   }   int main(void) {     gen(0);     sort(v.begin(), v.end());     cin >> bil;     for (int i = 0; i < v.size(); i++) {       if (v[i] == bil) {         cout << i + 1 << endl;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long const mod = 1e9 + 7;   long long const N = 1e9 + 10;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, a[111] = {}, sol = 0;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       if ((a[i] == 1 || a[i] == 2) && a[i + 1] == a[i])         a[i + 1] = 0;       else if (a[i] == 0)         sol++;       else if (a[i] == 3) {         int c = 0;         if (i > 0 && a[i - 1] == 1) {           a[i] = 2;           while (i < n - 1 && a[i + 1] == 3) {             if (c % 2 == 0)               a[i + 1] = 1;             else               a[i + 1] = 2;             i++, c++;           }           if (i == n - 1 && a[i - 1] == a[i])             sol++;           else if (i < n - 1 && a[i] == a[i + 1])             a[i + 1] = 0;         } else if (i > 0 && a[i - 1] == 2) {           a[i] = 1, c = 0;           while (i < n - 1 && a[i + 1] == 3) {             if (c % 2 == 0)               a[i + 1] = 2;             else               a[i + 1] = 1;             i++, c++;           }           if (i == n - 1 && a[i - 1] == a[i])             sol++;           else if (i < n - 1 && a[i] == a[i + 1])             a[i + 1] = 0;         } else if (i == 0) {           while (i < n && a[i + 1] == 3) i++;         }       }     }     cout << sol;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string s;     cin >> n >> s;     for (int i = 0; i < s.length() - 1; i++) {       if (s[i] > s[i + 1]) {         cout <<  YES  << endl << i + 1 <<     << i + 2;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int p[] = {1, 2, 2, 1};   const int q[] = {1, 1, 2, 2};   const int N = 500005;   int n, m;   int a[N], b[N];   long long ans;   void check(int& a, int b) {     if (!a)       a = b;     else if (a != b)       ans = 0;   }   int F(int a, int b) { return (b & 1) ? a : 3 - a; }   int main() {     scanf( %d%d n , &n, &m);     ans = 1;     char ch;     int k;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         scanf( %c , &ch);         if (ch ==  . ) continue;         k = ch -  1 ;         check(a[j], F(p[k], i));         check(b[i], F(q[k], j));       }       scanf(  n );     }     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         (ans *= ((i == 1 && !a[j]) + 1) * ((j == 1 && !b[i]) + 1)) %= 1000003;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int n, m, en, q[maxn], depth[maxn], f[maxn][20], dist[maxn];   struct edge {     int e;     edge *next;   } * v[maxn], ed[maxn << 1];   void add_edge(int s, int e) {     en++;     ed[en].next = v[s];     v[s] = ed + en;     v[s]->e = e;   }   void bfs(int root) {     int front = 1, tail = 1;     q[1] = root;     depth[1] = 1;     for (; front <= tail;) {       int now = q[front++];       for (edge *e = v[now]; e; e = e->next)         if (!depth[e->e]) {           depth[e->e] = depth[now] + 1;           f[e->e][0] = now;           int p = now, x = 0;           while (f[p][x]) {             f[e->e][x + 1] = f[p][x];             p = f[p][x];             x++;           }           q[++tail] = e->e;         }     }   }   int get_lca(int p1, int p2) {     if (depth[p1] < depth[p2]) swap(p1, p2);     int delta = depth[p1] - depth[p2], x = 0;     while (delta) {       if (delta & 1) p1 = f[p1][x];       delta >>= 1;       x++;     }     x = 0;     while (p1 != p2) {       if (!x || f[p1][x] != f[p2][x]) {         p1 = f[p1][x];         p2 = f[p2][x];         x++;       } else         x--;     }     return p1;   }   int main() {     scanf( %d%d , &n, &m);     for (int a = 1; a < n; a++) {       int s, e;       scanf( %d%d , &s, &e);       add_edge(s, e);       add_edge(e, s);     }     int size = (int)sqrt(n);     bfs(1);     int cnt = 1;     q[1] = 1;     memset(dist, 0x3f, sizeof(dist));     dist[1] = 0;     int opt, p;     for (int a = 1; a <= m; a++) {       scanf( %d%d , &opt, &p);       if (opt == 1) {         q[++cnt] = p;         dist[p] = 0;       } else {         int ans = dist[p];         for (int b = 1; b <= cnt; b++)           ans = min(ans, depth[p] + depth[q[b]] - 2 * depth[get_lca(p, q[b])]);         printf( %d n , ans);       }       if (cnt >= size) {         for (int front = 1, tail = cnt + 1; front != tail;) {           int now = q[front++];           if (front == maxn) front = 0;           for (edge *e = v[now]; e; e = e->next)             if (dist[e->e] > dist[now] + 1) {               dist[e->e] = dist[now] + 1;               q[tail++] = e->e;               if (tail == maxn) tail = 0;             }         }         cnt = 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct ty {     int d[4][11], a;   } t[400005], ans;   int n, m, q, x, y, a[11][100005], co[42], col, fa1, fa2, fa[42];   int find(int x) {     if (x == fa[x]) return x;     return fa[x] = find(fa[x]);   }   ty update(ty x, ty y) {     ty z;     for (int i = 1; i <= n; i++) {       fa[x.d[3][i]] = x.d[3][i];       fa[x.d[2][i]] = x.d[2][i];       fa[y.d[2][i] + 20] = y.d[2][i] + 20;       fa[y.d[3][i] + 20] = y.d[3][i] + 20;     }     z.a = x.a + y.a;     int col = 0;     memset(co, 0, sizeof(co));     for (int i = 1; i <= n; i++)       if (x.d[1][i] == y.d[0][i]) {         fa1 = find(x.d[3][i]);         fa2 = find(y.d[2][i] + 20);         if (fa1 != fa2) {           z.a--;           fa[fa2] = fa1;         }       }     for (int i = 1; i <= n; i++) {       z.d[0][i] = x.d[0][i];       z.d[1][i] = y.d[1][i];       fa1 = find(x.d[2][i]);       if (!co[fa1]) co[fa1] = ++col;       z.d[2][i] = co[fa1];       fa1 = find(y.d[3][i] + 20);       if (!co[fa1]) co[fa1] = ++col;       z.d[3][i] = co[fa1];     }     return z;   }   void build(int o, int l, int r) {     if (l == r) {       t[o].a = 0;       int col = 0;       for (int i = 1; i <= n; i++) {         t[o].d[0][i] = t[o].d[1][i] = a[i][l];         if (a[i][l] != a[i - 1][l]) {           t[o].a++;           col++;         }         t[o].d[2][i] = t[o].d[3][i] = col;       }       return;     }     int mid = (l + r) >> 1;     build(o * 2, l, mid);     build(o * 2 + 1, mid + 1, r);     t[o] = update(t[o * 2], t[o * 2 + 1]);   }   ty find(int o, int l, int r, int L, int R) {     if (l == L && r == R) return t[o];     int mid = (l + r) >> 1;     if (R <= mid)       return find(o * 2, l, mid, L, R);     else if (L > mid)       return find(o * 2 + 1, mid + 1, r, L, R);     else       return update(find(o * 2, l, mid, L, mid),                     find(o * 2 + 1, mid + 1, r, mid + 1, R));   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= n; i++)       for (int r = 1; r <= m; r++) scanf( %d , &a[i][r]);     build(1, 1, m);     for (int i = 1; i <= q; i++) {       scanf( %d%d , &x, &y);       ans = find(1, 1, m, x, y);       printf( %d n , ans.a);     }   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   string best;   void LongestPalindromicPrefix(string str) {     string temp = str +  ? ;     reverse(str.begin(), str.end());     temp += str;     int n = temp.length();     int lps[n];     fill(lps, lps + n, 0);     for (int i = 1; i < n; i++) {       int len = lps[i - 1];       while (len > 0 && temp[len] != temp[i]) {         len = lps[len - 1];       }       if (temp[i] == temp[len]) {         len++;       }       lps[i] = len;     }     if (best.length() < lps[n - 1]) {       best = temp.substr(0, lps[n - 1]);     }   }   int solve() {     int n, i, j;     best.erase();     string s;     cin >> s;     n = s.length();     i = 0, j = n - 1;     string temp;     long long ans = 0;     while (s[i] == s[j] && i <= j) {       temp.push_back(s[i]);       i++;       j--;       ans++;       if (i != j) {         ans++;       }       if (i >= j) {         break;       }     }     int k;     string res;     for (k = i; k <= j; k++) {       res.push_back(s[k]);     }     if (res.length() == 0) {       cout << s <<   n ;       return 0;     }     cout << temp;     LongestPalindromicPrefix(res);     reverse(res.begin(), res.end());     LongestPalindromicPrefix(res);     cout << best;     reverse(temp.begin(), temp.end());     cout << temp <<   n ;     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double l[200006];   int main() {     l[1] = 0;     l[0] = 0;     for (int i = 2; i < 200005; i++) {       l[i] = log(i) + l[i - 1];     }     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     if (k >= m) {       printf( 1.00000 n );     } else if (k + n < m) {       printf( 0.00000 n );     } else {       long double ans = l[n] + l[m] - l[n + k + 1] - l[m - k - 1];       ans = exp(ans);       double tmp = 1.0 - ans;       printf( %.10f n , tmp);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> adj[100005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     bool flag = true;     int test_case = 1, tc;     if (!flag) cin >> test_case;     tc = test_case;     while (tc--) {       int i, j, n, m, sum = 0, ans = 0, cnt = 0, flag = 0;       int maxi = -1e9, mini = 1e9;       string s;       cin >> s;       cin >> n;       m = s.size();       int pre[26][m + 2];       memset(pre, 0, sizeof(pre));       for (i = 0; i < m; i++) pre[s[i] -  a ][i] = 1;       for (i = 0; i < 26; i++) {         for (j = 1; j < m; j++) {           pre[i][j] += pre[i][j - 1];         }       }       while (n--) {         int l, r;         cin >> l >> r;         cnt = 0;         if (r == l) {           cout <<  Yes n ;           continue;         } else if (l == 1) {           for (i = 0; i < 26; i++) {             if (pre[i][r - 1] > 0) cnt++;           }         } else {           for (i = 0; i < 26; i++) {             if (pre[i][r - 1] - pre[i][l - 2] > 0) cnt++;           }         }         if (cnt > 2 or s[l - 1] != s[r - 1])           cout <<  Yes n ;         else           cout <<  No n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100001];   int main() {     ios::sync_with_stdio(0);     int n, mn = 1e9;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       mn = min(mn, a[i]);     }     int last = -1;     int ans = n + 1e1;     for (int i = 1; i <= n; ++i) {       if (a[i] == mn) {         if (last != -1) {           ans = min(ans, i - last);         }         last = i;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int hr, mt;     int h, d, c, n;     scanf( %d%d , &hr, &mt);     scanf( %d%d%d%d , &h, &d, &c, &n);     int p = h + max((1200 - (hr * 60 + mt)) * d, 0), t;     if (p % n != 0)       t = p / n + 1;     else       t = p / n;     double ans = t * c * 0.8;     if (h % n != 0)       t = h / n + 1;     else       t = h / n;     ans = min(ans, t * c * 1.0);     printf( %.3f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, clr[300001][3] = {{0}};   vector<long long> v[300001];   void dfs(long long node, long long parent) {     for (auto x : v[node]) {       if (x == parent) continue;       dfs(x, node);       clr[node][1] += clr[x][1];       clr[node][2] += clr[x][2];     }   }   signed main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     cin >> n;     long long r = 0, b = 0;     for (long long i = 1; i < n + 1; i++) {       long long c;       cin >> c;       if (c == 1) r++;       if (c == 2) b++;       clr[i][c]++;     }     for (long long i = 1; i < n; i++) {       long long x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     dfs(1, 1);     long long ans = 0;     if (b == 0 || r == 0) return cout << n - 1 <<   n , 0;     for (long long i = 1; i < n + 1; i++) {       if ((clr[i][2] == 0 && clr[i][1] == r) ||           (clr[i][1] == 0 && clr[i][2] == b))         ans++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > ans;   int main() {     int n;     scanf( %d , &n);     int a[n + 1], b[n + 1];     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= n; ++i) {       scanf( %d , &b[i]);     }     for (int i = 1; i <= n; ++i) {       if (a[i] != b[i]) {         for (int j = i + 1; j <= n; ++j) {           if (a[i] == b[j]) {             for (int k = j; k > i; k--) {               int sw = b[k];               b[k] = b[k - 1];               b[k - 1] = sw;               ans.push_back(make_pair(k - 1, k));             }             break;           }         }       }     }     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); i++) {       printf( %d %d n , ans[i].first, ans[i].second);     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T x, T y) {     while (y > 0) {       x %= y;       swap(x, y);     }     return x;   }   template <class _T>   inline _T sqr(const _T& x) {     return x * x;   }   template <class _T>   inline string tostr(const _T& a) {     ostringstream os(  );     os << a;     return os.str();   }   const long double PI = 3.1415926535897932384626433832795L;   template <typename T>   inline void input(T& a) {     static int c;     a = 0;     while (!isdigit(c = getchar()) && c !=  - ) {     }     char neg = 0;     if (c ==  - ) {       neg = 1;       c = getchar();     }     while (isdigit(c)) {       a = 10 * a + c -  0 ;       c = getchar();     }     if (neg) a = -a;   }   template <typename T = int>   inline T nxt() {     T res;     input(res);     return res;   }   void solve() {}   void imp() {     puts( IMPOSSIBLE );     exit(0);   }   const int N = 1000010;   vector<int> q[N][2];   int g[N][2];   int r[N];   int maleft[N];   int miright[N];   int n;   int dfs(int v, int le, int ri) {     if (r[v] >= ri) {       imp();     }     if (v >= ri) {       imp();     }     if (le >= ri) {       imp();     }     if (maleft[v] > v) {       g[v][0] = v + 1;       int ret = dfs(v + 1, maleft[v], min(ri, miright[v]));       le = max(le, r[v]);       if (ret < le) {         g[v][1] = ret + 1;         return dfs(ret + 1, le, ri);       } else {         return ret;       }     } else {       le = max(le, r[v]);       if (v < le) {         g[v][1] = v + 1;         return dfs(v + 1, le, ri);       }     }     return v;   }   void print(int v) {     if (v >= n) {       return;     }     if (g[v][0]) {       print(g[v][0]);     }     printf( %d  , v + 1);     if (g[v][1]) {       print(g[v][1]);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int c;     n = nxt();     c = nxt();     char s[10];     for (int i = 0; i < c; ++i) {       int a = nxt() - 1;       int b = nxt() - 1;       if (b <= a) {         imp();       }       scanf( %s , s);       if (s[0] ==  L ) {         q[a][0].push_back(b);       } else {         q[a][1].push_back(b);       }     }     for (int i = 0; i < n; ++i) {       r[i] = i;       maleft[i] = i;       miright[i] = INT_MAX;     }     for (int i = n - 2; i >= 0; --i) {       for (int x : q[i][0]) {         r[i] = max(r[i], r[x]);       }       for (int x : q[i][1]) {         r[i] = max(r[i], r[x]);       }       for (int x : q[i][0]) {         maleft[i] = max(maleft[i], r[x]);       }       for (int x : q[i][1]) {         miright[i] = min(miright[i], x);       }       if (miright[i] <= maleft[i]) {         imp();       }     }     int val = dfs(0, n - 1, n);     assert(val == n - 1);     print(0);     puts(  );     return 0;   };
#include <bits/stdc++.h>   template <typename T>   std::istream& operator>>(std::istream& input, std::vector<T>& v) {     for (T& a : v) input >> a;     return input;   }   void answer(int v) { std::cout << v <<   n ; }   void solve(const std::vector<size_t>& id) {     int z = 0;     std::unordered_map<size_t, size_t> x;     for (const size_t a : id) {       if (a == 0) continue;       const size_t c = ++x[a];       if (c > 2) return answer(-1);       z += (c == 2);     }     answer(z);   }   int main() {     size_t n;     std::cin >> n;     std::vector<size_t> id(n);     std::cin >> id;     solve(id);     return 0;   }
#include <bits/stdc++.h>   std::pair<int, int> a[111111];   int main() {     int i, n, m, max = 0;     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) scanf( %d%d , &a[i].first, &a[i].second);     max = std::max(a[0].second + a[0].first - 1,                    a[m - 1].second - a[m - 1].first + n);     for (i = 1; i < m; i++) {       if (std::abs(a[i].second - a[i - 1].second) > a[i].first - a[i - 1].first) {         puts( IMPOSSIBLE );         return 0;       }       max = std::max(max, std::max(a[i].second, a[i - 1].second) +                               (a[i].first - a[i - 1].first -                                std::abs(a[i].second - a[i - 1].second)) /                                   2);     }     printf( %d , max);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int n, m, pos[N], ans[N];   vector<int> g[N];   map<int, int> tot;   struct data {     int a, i;   } a[N];   bool cmp(data u, data v) { return u.a > v.a; }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i].a), a[i].i = i;       ++tot[a[i].a];     }     sort(a + 1, a + 1 + n, cmp);     for (int i = 1; i <= n; ++i) pos[a[i].i] = i;     for (int i = 1, x, y; i <= m; ++i) {       scanf( %d%d , &x, &y);       x = pos[x], y = pos[y];       g[x].push_back(y);       g[y].push_back(x);     }     int cnt = n;     a[0].a = -1;     for (int i = 1; i <= n; ++i) {       int s = g[i].size();       if (a[i].a != a[i - 1].a) cnt -= tot[a[i].a];       ans[a[i].i] = cnt;       for (int j = 0; j < s; ++j)         if (g[i][j] > i && a[g[i][j]].a != a[i].a) --ans[a[i].i];     }     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     return 0;   }