malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 10, mod = 1e9 + 9;   const int maxn = 500010;   const long double eps = 1e-5;   const int EPS = 500 * 500;   template <typename T>   void read(T &x) {     x = 0;     char ch = getchar();     long long first = 1;     while (!isdigit(ch)) {       if (ch ==  - ) first *= -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch - 48;       ch = getchar();     }     x *= first;   }   template <typename T, typename... Args>   void read(T &first, Args &...args) {     read(first);     read(args...);   }   int main() {     std::ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int _;     cin >> _;     while (_--) {       int n, second;       cin >> n >> second;       cout << second / (n / 2 + 1) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> Dn;   int L[310];   int C[310];   int N;   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) scanf( %d , L + i);     for (int i = 1; i <= N; i++) scanf( %d , C + i);     for (int i = 1; i <= N; i++) {       if (Dn.find(L[i]) == Dn.end() || Dn[L[i]] > C[i]) Dn[L[i]] = C[i];       for (map<int, int>::iterator it = Dn.begin(); it != Dn.end(); it++) {         int temp = gcd(it->first, L[i]);         if (Dn.find(temp) == Dn.end() || Dn[temp] > it->second + C[i]) {           Dn[temp] = it->second + C[i];         }       }     }     if (Dn.find(1) == Dn.end())       printf( -1 n );     else       printf( %d n , Dn[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double EPS = (long double)1e-9;   const long double PI = acos(0) * 2;   bool isZero(const long double& x) { return abs(x) <= EPS; }   int sign(const long double& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }   long long gcd(long long a, long long b) {     for (; b; a %= b, swap(a, b)) {     }     return abs(a);   }   pair<long long, long long> operator+(const pair<long long, long long>& a,                                        const pair<long long, long long>& b) {     return pair<long long, long long>(a.first + b.first, a.second + b.second);   }   pair<long long, long long> operator-(const pair<long long, long long>& a,                                        const pair<long long, long long>& b) {     return pair<long long, long long>(a.first - b.first, a.second - b.second);   }   pair<long long, long long> operator*(const pair<long long, long long>& a,                                        const long long& b) {     return pair<long long, long long>(a.first * b, a.second * b);   }   long long operator*(const pair<long long, long long>& a,                       const pair<long long, long long>& b) {     return a.first * b.second - b.first * a.second;   }   long long ccw(const pair<long long, long long>& a,                 const pair<long long, long long>& b,                 const pair<long long, long long>& c) {     return a * b + b * c + c * a;   }   void fg(vector<int> G[], int a, int b) {     G[a].push_back(b);     G[b].push_back(a);   }   void fg(vector<pair<int, int> > G[], int a, int b, int c) {     G[a].push_back({b, c});     G[b].push_back({a, c});   }   const int MAXN = 1000055;   int E[MAXN][2];   int D[MAXN];   char A[MAXN][6];   int B[MAXN], C[MAXN];   int N;   void dfs1(int i) {     if ( I  == A[i][0]) {       D[i] = B[i];       return;     }     if ( N  == A[i][0]) {       dfs1(B[i]);       D[i] = !D[B[i]];       return;     }     dfs1(B[i]);     dfs1(C[i]);     if ( A  == A[i][0]) {       D[i] = D[B[i]] & D[C[i]];     } else if ( O  == A[i][0]) {       D[i] = D[B[i]] | D[C[i]];     } else {       D[i] = D[B[i]] ^ D[C[i]];     }   }   void dfs2(int i) {     if ( I  == A[i][0]) return;     if ( N  == A[i][0]) {       E[B[i]][0] = E[i][1];       E[B[i]][1] = E[i][0];       dfs2(B[i]);       return;     }     if ( A  == A[i][0]) {       E[B[i]][0] = E[i][0];       E[B[i]][1] = E[i][D[C[i]]];       E[C[i]][0] = E[i][0];       E[C[i]][1] = E[i][D[B[i]]];     } else if ( O  == A[i][0]) {       E[B[i]][0] = E[i][D[C[i]]];       E[B[i]][1] = E[i][1];       E[C[i]][0] = E[i][D[B[i]]];       E[C[i]][1] = E[i][1];     } else {       E[B[i]][0] = E[i][D[C[i]]];       E[B[i]][1] = E[i][D[C[i]] ^ 1];       E[C[i]][0] = E[i][D[B[i]]];       E[C[i]][1] = E[i][D[B[i]] ^ 1];     }     dfs2(B[i]);     dfs2(C[i]);   }   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) {       scanf(  %s%d , A[i], &B[i]);       if ( I  != A[i][0] &&  N  != A[i][0]) scanf( %d , &C[i]);     }     dfs1(1);     E[1][0] = 0;     E[1][1] = 1;     dfs2(1);     for (int i = 1; i <= N; i++)       if ( I  == A[i][0]) putchar(E[i][!B[i]] ?  1  :  0 );     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 6;   long long int arr[2000005], brr[2000005], crr[2000005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n, k, ans;     cin >> n >> k;     vector<pair<int, int> > v;     for (int i = 1; i <= n; i++) cin >> arr[i];     while (k--) {       int mx = 0;       for (int i = 1; i <= n; i++)         if (!mx || arr[i] > arr[mx]) mx = i;       int mn = 0;       for (int i = 1; i <= n; i++)         if (!mn || arr[i] < arr[mn]) mn = i;       if (mx == mn) {         ans = 0;         break;       }       arr[mx]--;       arr[mn]++;       v.push_back({mx, mn});     }     int mx = 0;     for (int i = 1; i <= n; i++)       if (!mx || arr[i] > arr[mx]) mx = i;     int mn = 0;     for (int i = 1; i <= n; i++)       if (!mn || arr[i] < arr[mn]) mn = i;     ans = arr[mx] - arr[mn];     cout << ans <<     << v.size() << endl;     for (int i = 0; i < v.size(); i++)       cout << v[i].first <<     << v[i].second << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string s;     cin >> n;     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  L ) {         if (i - 1 >= 0 && s[i - 1] !=  * ) {           for (int j = i - 1; j >= 0; j--) {             if (s[j] ==  R ) {               int aux = i - j + 1;               if (aux % 2 != 0) s[j + aux / 2] =  . ;               break;             } else {               if (s[j] ==  . ) s[j] =  * ;             }           }         }       }       if (s[i] ==  R ) {         if (i + 1 < s.size() && s[i + 1] !=  * ) {           for (int j = i; j < s.size(); j++) {             if (s[j] ==  L ) {               int aux = j - i + 1;               if (aux % 2 != 0) s[i + aux / 2] =  . ;               break;             } else {               if (s[j] ==  . ) s[j] =  * ;             }           }         }       }     }     int ans = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  . ) ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> edge[1005];   int vis[2][1005];   int d[2][1005];   int adj[1005][1005];   void djikstra(int s, int id) {     priority_queue<pair<int, int> > PQ;     PQ.push(make_pair(0, s));     d[id][s] = 0;     while (!PQ.empty()) {       pair<int, int> p = PQ.top();       PQ.pop();       int v = p.second;       int cd = -p.first;       if (cd != d[id][v] || vis[id][v]) continue;       vis[id][v] = 1;       for (int i = 0; i < edge[v].size(); i++) {         int u = edge[v][i];         int nd = cd + 1;         if (!vis[id][u] && nd < d[id][u]) {           d[id][u] = nd;           PQ.push(make_pair(-nd, u));         }       }     }   }   int main() {     int n, m, s, t;     scanf( %d%d%d%d , &n, &m, &s, &t);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d%d , &u, &v);       edge[u].push_back(v);       edge[v].push_back(u);       adj[u][v] = adj[v][u] = 1;     }     for (int i = 1; i <= n; i++) {       d[0][i] = d[1][i] = n;     }     djikstra(s, 0);     djikstra(t, 1);     int th = d[0][t];     int ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (adj[i][j]) continue;         int dist = min(d[0][i] + d[1][j], d[0][j] + d[1][i]);         if (dist + 1 >= th) ans++;       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int N;   vector<int> a, b;   int main() {     int n, m, k, x;     cin >> n >> m >> k;     for (int i = 0; i < n; ++i) {       cin >> x;       a.push_back(x);     }     for (int i = 0; i < m; ++i) {       cin >> x;       b.push_back(x);     }     sort(a.begin(), a.end());     sort(b.begin(), b.end());     int i = a.size() - 1;     int j = b.size() - 1;     while (i >= 0 && j >= 0 && a[i] <= b[j]) {       --i;       --j;     }     if (i >= 0)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     if (m == 3 && n != 4 && n != 3) {       cout << -1;       return false;     }     int x = 0, y = 0;     for (int i = 1; i <= m; i++) {       cout << x <<     << y << endl;       x++;       y += i;     }     x = 1000000, y = 0;     for (int i = 1; i <= n - m; i++) {       cout << x <<     << y << endl;       x--;       y += i;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100, M = 10 + 10, SQ = 333;   pair<int, int> nxt[N][M];   char a[N][M];   bool mark[N][M];   int n, m, q;   bool OK(pair<int, int> x) {     return x.first > 0 && x.second > 0 && x.second <= m;   }   pair<int, int> go(int x, int y) {     if (!OK({x, y})) return {x, y};     if (nxt[x][y].first != -2) return nxt[x][y];     if (a[x][y] ==  ^ )       return x % SQ ? nxt[x][y] = go(x - 1, y) : nxt[x][y] = {x - 1, y};     if (mark[x][y]) return nxt[x][y] = {-1, -1};     mark[x][y] = true;     if (a[x][y] ==  > ) nxt[x][y] = go(x, y + 1);     if (a[x][y] ==  < ) nxt[x][y] = go(x, y - 1);     mark[x][y] = false;     return nxt[x][y];   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     for (int i = 0; i < N; i++)       for (int j = 0; j < M; j++) nxt[i][j] = {-2, -2};     cin >> n >> m >> q;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> a[i][j];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) go(i, j);     while (q--) {       char tp;       int x, y;       cin >> tp >> x >> y;       if (tp ==  A ) {         pair<int, int> tmp = {x, y};         while (OK(tmp)) tmp = nxt[tmp.first][tmp.second];         cout << tmp.first <<     << tmp.second <<   n ;       } else {         cin >> a[x][y];         int A = 0;         while (A <= x) A += SQ;         for (int i = x; i <= min(A, n); i++)           for (int j = 1; j <= m; j++) nxt[i][j] = {-2, -2};         for (int i = x; i <= min(A, n); i++)           for (int j = 1; j <= m; j++) go(i, j);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int arr[n];     for (auto& elem : arr) {       cin >> elem;     }     for (int i = 1; i <= n; ++i) {       for (int j = 0; j < n; ++j) {         if (arr[j] == i) {           cout << j + 1 <<    ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   const int mod = 1000000007;   int a, b, c, d, e, f, g, h, i, j;   int Mi[N * N];   int F[N][N], K;   void Work() {     Mi[0] = 1;     for (int ii = 1; ii <= a * a; ii++) Mi[ii] = (Mi[ii - 1] << 1) % mod;     F[0][0] = 1;     for (int ii = 1; ii <= a; ii++)       for (int jj = 1; jj <= K; jj++) {         for (int kk = 0; kk < ii; kk++)           (F[ii][jj] += (long long)F[kk][jj - 1] * (Mi[ii - kk] - 1) % mod *                         (Mi[(ii - kk) * kk]) % mod) %= mod;       }     int an = 0;     for (int ii = 0; ii <= a; ii++)       (an += (long long)F[ii][K] * Mi[(a - ii) * ii] % mod) %= mod;     cout << an << endl;   }   int main() {     cin >> a >> K;     Work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long q, a[555555], k, l, m, n, o, p;   const long long mod = 1e9 + 7;   queue<long long> qq[100005];   struct node {     node *left, *right;     long long val;     node() {       val = 0;       left = right = this;     }     node(node *le, node *re, long long va) {       le = left, re = right;       val = va;     }   };   node *ver[555555];   void build(long long s, long long e, node *r) {     if (s == e) {       return;     }     r->left = new node(NULL, NULL, 0);     r->right = new node(NULL, NULL, 0);     build(s, ((s + e) / 2), r->left), build(((s + e) / 2) + 1, e, r->right);   }   void update(long long s, long long e, long long id, long long val, node *r1,               node *r2) {     if (s > id || e < id) return;     if (s == e) {       r2->val = val;       return;     }     if (id <= ((s + e) / 2)) {       r2->right = r1->right;       r2->left = new node(NULL, NULL, 0);       update(s, ((s + e) / 2), id, val, r1->left, r2->left);     } else {       r2->left = r1->left;       r2->right = new node(NULL, NULL, 0);       update(((s + e) / 2) + 1, e, id, val, r1->right, r2->right);     }     r2->val = r2->left->val + r2->right->val;   }   long long query(long long s, long long e, node *r1, long long l, long long r) {     if (l > e || s > r) return 0;     if (l <= s && e <= r) return r1->val;     return query(s, ((s + e) / 2), r1->left, l, r) +            query(((s + e) / 2) + 1, e, r1->right, l, r);   }   void solve() {     cin >> n >> m;     ver[0] = new node();     for (long long i = 1; i <= n; i++) cin >> a[i];     for (long long i = 1; i <= n; i++) {       k = a[i];       ver[i * 2 - 1] = new node(NULL, NULL, 0);       ver[i * 2] = new node(NULL, NULL, 0);       update(1, n, i, 1, ver[i * 2 - 2], ver[i * 2 - 1]);       if (qq[k].size() == m) {         long long op = qq[k].front();         qq[k].pop();         update(1, n, op, 0, ver[i * 2 - 1], ver[i * 2]);       } else         ver[i * 2] = ver[i * 2 - 1];       qq[k].push(i);     }     long long last = 0, s, e;     cin >> l;     while (l--) {       cin >> s >> e;       o = (s + last) % n + 1;       p = (e + last) % n + 1;       if (o > p) swap(o, p);       last = query(1, n, ver[2 * p], o, n);       cout << last << endl;     }   }   int main() {     q = 1;     while (q--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long dp[5010][5010]={};   long long cnt[5010]={};   long long a[5000];   long long mod=1e9+7;   signed main()   {       int n,k,q;       cin>>n>>k>>q;       for(int i=0;i<n;i++){           cin>>a[i];       }       for(int i=0;i<n;i++)dp[i][0]=1;       for(int j=1;j<=k;j++){           dp[0][j]=dp[1][j-1];           for(int i=1;i<n-1;i++){               dp[i][j]=dp[i-1][j-1]+dp[i+1][j-1];               dp[i][j]%=mod;           }           dp[n-1][j]=dp[n-2][j-1];       }       long long b;       long long sum=0;       for(int i=0;i<n;i++){           for(int j=0;j<=k;j++){               b=dp[i][j]*dp[i][k-j];               b%=mod;               cnt[i]+=b;               cnt[i]%=mod;           }           sum+=(cnt[i]*a[i])%mod;           sum%=mod;       }       for(int i=0;i<q;i++){           long long x,y;           cin>>x>>y;           long long f=cnt[x-1]*(y),g=cnt[x-1]*a[x-1];           sum+=mod+(f%mod+mod)%mod-(g%mod+mod)%mod;           sum%=mod;           a[x-1]=y;           cout<<sum<<  n ;       }      }
#include <bits/stdc++.h>   using namespace std;   int main() {     char a[200];     char c;     int i = 0;     while ((c = getchar()) !=   n ) {       a[i] = c;       i++;     }     for (int k = 0; k < i - 2; k++) {       if (a[k] ==  W  && a[k + 1] ==  U  && a[k + 2] ==  B ) {         a[k] =    ;         a[k + 1] =    ;         a[k + 2] =    ;       }     }     int s;     for (s = 0; s < i; s++) {       if (a[s] !=    ) {         cout << a[s];         break;       }     }     for (int j = s + 1; j < i; j++) {       if (a[j] !=     && a[j - 1] !=    ) cout << a[j];       if (a[j] !=     && a[j - 1] ==    ) cout <<     << a[j];     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string t;     cin >> t;     string s;     bool a = true;     for (int i = 0; i < t.size(); i++) {       if (a && t[i] ==  0 ) {         a = false;         continue;       }       s.push_back(t[i]);     }     if (a) s.erase(s.begin());     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   int a[105];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     int s = 0;     for (int i = 0; i < n; ++i) {       int t = 0;       for (int j = i; j < n; ++j) {         t ^= a[j];         if (s < t) s = t;       }     }     printf( %d n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<pair<long long, long long>, long long> O;   map<pair<long long, long long>, long long>::iterator oit;   map<long long, long long> X, Y;   map<long long, long long>::iterator it;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       double x, y;       cin >> x >> y;       O[make_pair(x, y)]++;       X[x]++;       Y[y]++;     }     long long cnt = 0;     for (it = X.begin(); it != X.end(); ++it)       if (it->second > 1) cnt += (it->second - 1) * (it->second) / 2;     for (it = Y.begin(); it != Y.end(); ++it)       if (it->second > 1) cnt += (it->second - 1) * (it->second) / 2;     for (oit = O.begin(); oit != O.end(); ++oit)       if (oit->second > 1) cnt -= (oit->second - 1) * (oit->second) / 2;     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> num, con, a;   vector<vector<int> > g(1000001);   bool used[1000001];   void dfs(int v) {     num.push_back(v);     con.push_back(a[v - 1]);     used[v] = true;     if (g[v].empty()) return;     for (int i = 0; i < g[v].size(); i++)       if (!used[g[v][i]]) dfs(g[v][i]);     return;   }   int main() {     int n, m;     cin >> n >> m;     int x, y;     a.assign(n, 0);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; i < m; i++) {       scanf( %d%d , &x, &y);       g[x].push_back(y);       g[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       num.resize(0);       con.resize(0);       if (used[i]) continue;       dfs(a[i - 1]);       sort(num.begin(), num.end());       sort(con.rbegin(), con.rend());       for (int j = 0; j < num.size(); j++) {         a[num[j] - 1] = con[j];       }     }     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 7;   const int M = 2e6 + 7;   const int lim = 1e6;   const int mod = 1e9 + 7;   const int inf = 0x3f3f3f3f;   long long ksm(long long a, long long b, long long p) {     long long ret = 1;     while (b) {       if (b & 1) (ret *= a) %= p;       (a *= a) %= p;       b >>= 1;     }     return ret;   }   long long inv(long long x) { return ksm(x, mod - 2, mod); }   int main() {     long long k, x, a = 1, b = 1, f1 = 0, f2 = 0;     scanf( %lld , &k);     for (int i = 1; i <= k; i++) {       scanf( %lld , &x);       if (x % 2 == 0) f1 = 1;       if (x == 0) f2 = 1;       (b *= x % (mod - 1)) %= mod - 1;       (a *= x % 2) %= 2;     }     b = (b - 1 + mod - 1) % (mod - 1);     long long bb = ksm(2, b, mod);     if (f1 == 0) f1 = -1;     long long aa = (bb + f1 + mod) % mod, t = ksm(2, (a - 1 + 2) % 2, 3);     t = (t + f1 + 3) % 3;     if (t == 0)       aa = aa * inv(3) % mod;     else       bb *= 3;     printf( %lld/%lld n , aa, bb);     return 0;   }
#include <bits/stdc++.h>   inline long long gcd(long long a, long long b) {     return (b ? gcd(b, a % b) : a);   }   inline long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   inline int cmp(double x, double y = 0, double tol = 1e-7) {     return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;   }   using namespace std;   const int MAXN = 1e5 + 5;   vector<int> adj[MAXN];   int y[MAXN];   int qy[MAXN];   void G(int n, int pai) {     y[n] = 0;     for (int i = 0; i < adj[n].size(); i++) {       int x = adj[n][i];       if (x != pai && adj[x].size() <= 2) G(x, n);     }   }   int main() {     int n, a, b, x;     cin >> n;     for (int i = 0; i < n - 1; i++) {       scanf( %d %d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     for (int i = 0; i < MAXN; i++) y[i] = 1;     memset(qy, 0, sizeof qy);     for (int i = 1; i < n + 1; i++) {       if (adj[i].size() == 1 && y[i]) G(i, -1);     }     for (int i = 1; i < n + 1; i++) {       int a = 0, b = 0;       for (int j = 0; j < adj[i].size(); j++) {         x = adj[i][j];         if (y[x])           a++;         else           b++;       }       qy[i] = a + max(b - 2, 0);     }     bool ans = true;     for (int i = 1; i < n + 1; i++) {       if (!y[i]) continue;       int cnt = 0;       for (int j = 0; j < adj[i].size(); j++) {         a = adj[i][j];         if (qy[a] > 1) cnt++;       }       if (cnt > 2) {         ans = false;         break;       }     }     cout << (ans ?  Yes n  :  No n );   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c, d, k, t;   int main() {     cin >> t;     while (t--) {       cin >> a >> b >> c >> d >> k;       bool isok = 0;       for (int i = 1; i <= k; i++) {         if (i * c >= a && (k - i) * d >= b) {           isok = 1;           cout << i <<     << k - i << endl;           break;         }       }       if (!isok) cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200002;   double eps = 1e-9;   int T, N, M, K, mx, sum, ans;   int a, b, c;   bool visit[MAXN], call[MAXN];   int color[MAXN];   vector<int> v[MAXN];   map<int, int> mp;   void dfs(int n) {     mp[color[n]]++;     for (auto i : v[n])       if (!visit[i]) {         visit[i] = 1;         dfs(i);       }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> N >> M >> K;     for (int i = 0; i < N; i++) cin >> color[i];     for (int i = 0; i < M; i++) {       cin >> a >> b;       --a, --b;       call[a] = call[b] = 1;       v[a].push_back(b);       v[b].push_back(a);     }     for (int i = 0; i < N; i++)       if (call[i] && !visit[i]) {         visit[i] = 1;         mp.clear();         dfs(i);         mx = 0;         sum = 0;         for (auto i : mp) {           mx = max(mx, i.second);           sum += i.second;         }         ans += (sum - mx);       }     cout << ans << endl;   }