#include using namespace std; typedef pair P; vector

edges[200000]; int main(){ int N, M; cin >> N >> M; for(int i=0; i, greater

> que; que.push({0, 0}); while(que.size()){ auto p = que.top(); que.pop(); int64_t d = p.first; int i = p.second; if(d > dist[i]) continue; for(auto& e : edges[i]){ int j = e.first; int64_t d2 = d + e.second; if(d2 < dist[j]){ dist[j] = d2; que.push({d2, j}); } } } for(int i=0; i