adj is the adjacency list, cost has weights of the edges. I have used set instead of priority queue.
long long distance(vector > &