Optimizing implementation of Dijkstra I am using a std::priority_queue to implement Dijkstra's algorithm:

while(!Q.empty())
{
    u = Q.top().first;
    Q.pop();
    int size=G[u].size();
    for(int i=0; i&lt;size; i++)//tle
    {
        v = G[u][i].first;
        w = G[u][i].second;
        //cout&lt;&lt;u&lt;&lt;" "&lt;&lt;v&lt;&lt;" "&lt;&lt;w&lt;&lt;endl;
        if(d[v] &gt; d[u] + w)
        {
            d[v] = d[u] + w;
            Q.push(pp(v,d[v]));

        }
    }
}


But I think it is a bit slow for competitive programming (\$O(e + v*v)\$).  How can I improve my implementation?
Handling vertices multiple times
There are two places where you are doing extra work because you are handling vertices multiple times:

When you find a shorter path to a vertex, you currently push that vertex with the new path length into your priority queue.  While this works, you still have the old vertex in the priority queue as well.  You will eventually pop the vertex off twice (and handle it twice), which is not ideal.  If you kept track of which vertices you've already handled, you could quickly skip duplicate vertices when you come across them.

When you handle a new vertex, you iterate over all of its edges.  But if you see an edge to a vertex that has already been handled, you don't need to deal with it.  Right now, you could be pushing vertices back onto your priority queue that you've already dealt with.