func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 100;   vector<int> g[maxn];   int father[maxn];   int a[maxn];   int findfather(int x) {     int a = x;     while (x != father[x]) x = father[x];     while (a != father[a]) {       int z = a;       a = father[a];       father[z] = x;     }     return x;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       g[a[i]].push_back(i);     }     int wjm = n;     for (int i = 1; i <= m; i++) father[i] = i;     for (int i = 2; i <= n; i++)       if (a[i - 1] == a[i]) wjm--;     printf( %d n , wjm - 1);     for (int i = 1; i < m; i++) {       int x, y;       scanf( %d%d , &x, &y);       int faX = findfather(x);       int faY = findfather(y);       if (g[faX].size() > g[faY].size()) swap(faX, faY);       for (int j : g[faX]) {         if (j + 1 <= n && a[j + 1] == faY) wjm--;         if (j - 1 >= 1 && a[j - 1] == faY) wjm--;         g[faY].push_back(j);       }       for (int j : g[faX]) a[j] = faY;       father[faX] = faY;       printf( %d n , wjm - 1);     }   }   