func_code_string: #include <bits/stdc++.h>   using namespace std;   const int base = 13331;   const int MOD = 1e9 + 7;   const int MOD1 = 998244353;   const int mod = 65536;   const long long INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   const int N = 1e6 + 10, M = 20000010;   const int NN = 3e5 + 10;   inline long long read() {     char ch = getchar();     long long f = 1, x = 0;     while (ch >  9  || ch <  0 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n, m, k, idx = 0;   int c[N], ex[N], ey[N];   bool vis[N];   map<pair<int, int>, int> mp;   vector<int> ve[N];   struct Undo_Dsu {     stack<pair<int, int> > st;     int fa[N], siz[N];     void init() {       while (!st.empty()) st.pop();       for (int i = 1; i <= 2 * n + 1; i++) fa[i] = i, siz[i] = 1;     }     int getrt(int x) { return x == fa[x] ? x : getrt(fa[x]); }     bool merge(int u, int v) {       int fax = getrt(u), fay = getrt(v);       if (fax == fay) return false;       if (siz[fax] > siz[fay]) swap(fax, fay), swap(u, v);       fa[fax] = fay, siz[fay] += siz[fax];       st.push({fax, fay});       return true;     }     void undo() {       pair<int, int> no = st.top();       fa[no.first] = no.first;       siz[no.second] -= siz[no.first];       st.pop();     }   } dsu;   int main() {     n = read(), m = read(), k = read();     dsu.init();     for (int i = 1; i <= n; i++) c[i] = read();     int u, v;     long long cnt = k;     for (int i = 1; i <= m; i++) {       u = read(), v = read();       ex[i] = u, ey[i] = v;       if (c[u] == c[v]) {         int fx = dsu.getrt(u);         int fy = dsu.getrt(v);         if (fx == fy) {           if (!vis[c[u]]) {             vis[c[u]] = 1;             --cnt;           }         } else           dsu.merge(u, v + n), dsu.merge(v, u + n);       }     }     long long ans = cnt * (cnt - 1) / 2;     for (int i = 1; i <= m; i++) {       if (c[ex[i]] != c[ey[i]] && !vis[c[ex[i]]] && !vis[c[ey[i]]]) {         int lc = c[ex[i]], rc = c[ey[i]];         if (lc > rc) swap(lc, rc);         int id = mp[make_pair(lc, rc)];         if (!id) id = mp[make_pair(lc, rc)] = ++idx;         ve[id].push_back(i);       }     }     for (auto in : mp) {       int w = in.second;       int now = dsu.st.size();       for (auto v : ve[w]) {         int uid = ex[v], vid = ey[v];         int fu = dsu.getrt(uid), fv = dsu.getrt(vid);         if (fu == fv) {           --ans;           break;         }         dsu.merge(uid, vid + n);         dsu.merge(vid, uid + n);       }       while (dsu.st.size() > now) dsu.undo();     }     printf( %lld n , ans);     return 0;   }   