func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   ostream& operator<<(ostream& os, vector<T> v) {     os <<  [ ;     string sep;     for (const T& el : v) os << sep << el, sep =  ,  ;     return os <<  ] ;   }   void dbg_out() { cerr << endl; }   template <typename Head, typename... Tail>   void dbg_out(Head H, Tail... T) {     cerr <<     << H;     dbg_out(T...);   }   int dsu_find(vector<int>& parents, int a) {     return (parents[a] == a) ? a : (parents[a] = dsu_find(parents, parents[a]));   }   bool dsu_union(vector<int>& parents, int a, int b) {     int pa = dsu_find(parents, a);     int pb = dsu_find(parents, b);     if (pa != pb) {       parents[pa] = pb;       return true;     }     return false;   }   void run() {     int m, n;     cin >> m >> n;     vector<long long> a(m + 1), b(n + 1);     for (int i = 1; i < m + 1; i++) cin >> a[i];     for (int j = 1; j < n + 1; j++) cin >> b[j];     auto cost = [&](int x, int y) -> long long {       int u = min(x, y), v = max(x, y);       return a[u] + b[v - m];     };     long long tot_cost = 0;     vector<pair<long long, pair<int, int> > > edgelist;     for (int i = 1; i < m + 1; i++) {       int s;       cin >> s;       for (int x = 0; x < s; x++) {         int j;         cin >> j;         edgelist.push_back(make_pair(a[i] + b[j], make_pair(i, m + j)));         tot_cost += (a[i] + b[j]);       }     }     sort(edgelist.begin(), edgelist.end(),          greater<pair<long long, pair<int, int> > >());     vector<int> parents(m + n + 1);     for (int i = 1; i < m + n + 1; i++) parents[i] = i;     long long mst_cost = 0;     for (pair<long long, pair<int, int> > e : edgelist) {       ;       if (dsu_find(parents, e.second.first) !=           dsu_find(parents, e.second.second)) {         mst_cost += e.first;         dsu_union(parents, e.second.first, e.second.second);         ;       }     }     cout << tot_cost - mst_cost <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     run();   }   