func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class Key, class Value>   struct Heap {     Value p[100100];     int pos[100100];     vector<Key> hp;     void init() { hp.clear(); }     void swapPos(int i, int a) {       int temp;       temp = pos[hp[a]];       pos[hp[a]] = pos[hp[i]];       pos[hp[i]] = temp;       swap(hp[i], hp[a]);     }     void up(int a) {       int i;       while (1) {         i = a;         if (a + a + 1 < hp.size() && p[hp[i]] > p[hp[a + a + 1]]) {           i = a + a + 1;         }         if (a + a + 2 < hp.size() && p[hp[i]] > p[hp[a + a + 2]]) {           i = a + a + 2;         }         if (i == a) break;         swapPos(i, a);         a = i;       }     }     void down(int a) {       int i, temp;       while (1) {         i = a;         if (a && p[hp[i]] < p[hp[(a - 1) / 2]]) {           i = (a - 1) / 2;         }         if (i == a) break;         swapPos(i, a);         a = i;       }     }     void update(Key k, Value v) {       p[k] = v;       up(pos[k]);       down(pos[k]);     }     void push_heap(Key k, Value v) {       hp.push_back(k);       p[k] = v;       down(pos[k] = hp.size() - 1);     }     Value top() { return p[hp[0]]; }     void pop(Key& k, Value& v) {       k = hp[0];       v = p[hp[0]];       swapPos(0, hp.size() - 1);       hp.pop_back();       up(0);     }     int size() { return hp.size(); }   };   Heap<int, long long int> hp;   template <class T>   struct Graph {     static const int gmaxn = 101000;     static const int gmaxm = 101000;     int ind[gmaxn];     int last[gmaxm * 2], e[gmaxm * 2], gt;     T w[gmaxm * 2];     bool bi;     int n, m;     void init() {       gt = 0;       memset(ind, 0, sizeof(ind));     }     void addE1(int a, int b, T& c) {       gt++;       last[gt] = ind[a];       ind[a] = gt;       e[gt] = b;       w[gt] = c;     }     void addE2(int a, int b, T& c) {       addE1(a, b, c);       addE1(b, a, c);     }     void addE(int a, int b, T& c) {       if (bi)         addE2(a, b, c);       else         addE1(a, b, c);     }     Graph(bool bidirectional = true) { bi = bidirectional; }     void next(int& a) { a = last[a]; }     void dijkstra(vector<int>& S);   };   int from[100100];   long long int dis[100100];   template <class T>   void Graph<T>::dijkstra(vector<int>& S) {     memset(dis, -1, sizeof(dis));     int i, now, j;     long long int nowdis;     for (i = 0; i < S.size(); i++) {       dis[from[S[i]] = S[i]] = 0;       hp.push_heap(S[i], 0);     }     while (hp.size()) {       hp.pop(now, nowdis);       for (i = ind[now]; i; next(i)) {         j = e[i];         if (dis[j] < 0) {           dis[j] = nowdis + w[i];           from[j] = from[now];           hp.push_heap(j, dis[j]);         } else if (dis[j] > nowdis + w[i]) {           dis[j] = nowdis + w[i];           from[j] = from[now];           hp.update(j, dis[j]);         }       }     }   }   Graph<long long int> g;   bool k[100100];   vector<int> s;   int fa[100100];   int findfa(int a) {     if (a == fa[a]) return a;     return fa[a] = findfa(fa[a]);   }   bool merge(int a, int b) {     a = findfa(a);     b = findfa(b);     if (a == b) return 0;     if (rand() & 1) swap(a, b);     fa[a] = b;     return 1;   }   vector<pair<long long int, pair<int, int> > > eg;   int main() {     scanf( %d %d , &g.n, &g.m);     int i, j, a, b, cc;     long long int c;     for (i = 0; i < g.m; i++) {       scanf( %d %d %d , &a, &b, &cc);       c = cc;       g.addE(a, b, c);     }     scanf( %d , &i);     while (i--) {       scanf( %d , &j);       k[j] = 1;       s.push_back(j);     }     g.dijkstra(s);     for (i = 1; i <= g.n; i++) {       fa[i] = i;       for (j = g.ind[i]; j; g.next(j)) {         if (from[i] != from[g.e[j]]) {           eg.push_back(make_pair(dis[i] + dis[g.e[j]] + g.w[j],                                  make_pair(from[i], from[g.e[j]])));         }       }     }     sort(eg.begin(), eg.end());     long long int ans = 0;     if (!k[1]) ans += dis[1];     for (i = 0; i < eg.size(); i++) {       if (merge(eg[i].second.first, eg[i].second.second)) {         ans += eg[i].first;       }     }     printf( %I64d n , ans);     return 0;   }   