func_code_string: #include <bits/stdc++.h>   int next[1 + (1000 * (1000 - 1)) * 2], hh[1 + (1000 * (1000 - 1)) * 2], l_;   int link(int l, int h) {     next[l_] = l;     hh[l_] = h;     return l_++;   }   int ij[(1000 * (1000 - 1))], ww[(1000 * (1000 - 1))], ao[1000];   long long ww_[1000][1000];   int pq[1 + 1000], iq[1000], cnt;   long long *dd;   int less(int u, int v) { return dd[u] < dd[v]; }   int i2(int i) {     return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;   }   void pq_up(int u) {     int i, j, v;     for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j) pq[iq[v] = i] = v;     pq[iq[u] = i] = u;   }   void pq_dn(int u) {     int i, j, v;     for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j) pq[iq[v] = i] = v;     pq[iq[u] = i] = u;   }   void pq_add_last(int u) { iq[u] = ++cnt; }   int pq_remove_first() {     int u = pq[1], v = pq[cnt--];     iq[v] = 1;     pq_dn(v);     return u;   }   void dijkstra(int s, int n) {     int h, i, j, l, w;     memset(dd, 0x3f, n * sizeof *dd), dd[s] = 0;     pq_add_last(s), pq_up(s);     while (cnt) {       i = pq_remove_first();       for (l = ao[i]; l; l = next[l]) {         h = hh[l];         j = i ^ ij[h];         w = ww[h];         if (dd[j] > dd[i] + w) {           if (dd[j] == 0x3f3f3f3f3f3f3f3fLL) pq_add_last(j);           dd[j] = dd[i] + w;           pq_up(j);         }       }     }   }   int main() {     int n, m, s, t, h, i, j, w, d, c;     scanf( %d%d%d%d , &n, &m, &s, &t), s--, t--;     l_ = 1;     for (h = 0; h < m; h++) {       scanf( %d%d%d , &i, &j, &w), i--, j--;       ij[h] = i ^ j;       ww[h] = w;       ao[i] = link(ao[i], h);       ao[j] = link(ao[j], h);     }     for (i = 0; i < n; i++) {       dd = ww_[i];       dijkstra(i, n);     }     l_ = 1;     m = 0;     for (i = 0; i < n; i++) {       scanf( %d%d , &d, &c);       dd = ww_[i];       ao[i] = 0;       for (j = 0; j < n; j++)         if (j != i && dd[j] <= d) {           ij[m] = i ^ j;           ww[m] = c;           ao[i] = link(ao[i], m++);         }     }     dijkstra(s, n);     printf( %lld n , dd[t] == 0x3f3f3f3f3f3f3f3fLL ? -1 : dd[t]);     return 0;   }   