Go: package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

type Item struct {
	value    int // The value of the item; arbitrary.
	priority int // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}
func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

type Q struct {
	pq *PriorityQueue
	ds map[int]int // It has always same value as pq. For random access.
}

func newQ() *Q {
	pq := new(PriorityQueue)
	heap.Init(pq)
	return &Q{
		pq: pq,
		ds: make(map[int]int),
	}
}
func (q *Q) pop() (u, d int) {
	item := heap.Pop(q.pq).(*Item)
	delete(q.ds, item.value)
	return item.value, item.priority
}
func (q *Q) get(u int) (int, bool) { // returns d
	d, ok := q.ds[u]
	return d, ok
}
func (q *Q) set(u, d int) {
	q.ds[u] = d
	for _, item := range *q.pq {
		if item.value != u {
			continue
		}

		item.priority = d
		heap.Fix(q.pq, item.index)
		return
	}
	heap.Push(q.pq, &Item{
		priority: d,
		value:    u,
	})
}
func (q *Q) len() int {
	return len(q.ds)
}

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(r, &n)
	cs := make([]map[int]int, n) // []v_i -> c_i
	for h := 0; h < n; h++ {
		var u, k int
		fmt.Fscan(r, &u, &k)
		m := make(map[int]int)
		for i := 0; i < k; i++ {
			var v, c int
			fmt.Fscan(r, &v, &c)
			m[v] = c
		}

		cs[u] = m
	}

	q := newQ()
	q.set(0, 0)
	visited := make(map[int]struct{})
	out := make([]int, n)

	for q.len() > 0 {
		u, d := q.pop()
		for uu, c := range cs[u] {
			// Consider the connection between u and uu.
			if _, ok := visited[uu]; ok {
				continue
			}
			dd := d + c
			if d, ok := q.get(uu); !ok || d > dd {
				q.set(uu, dd)
			}
		}

		out[u] = d
		visited[u] = struct{}{}
	}

	for u, d := range out {
		fmt.Println(u, d)
	}
}

C++: 
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);

		int u = in.nextInt();
		int[][] mat = new int[u][u];
		for (int i = 0; i < u; i++) {
			Arrays.fill(mat[i], -1);
		}
		for (int i = 0; i < u; i++) {
			int fromNode = in.nextInt();
			int toNodeCount = in.nextInt();
			for (int j = 0; j < toNodeCount; j++) {
				int toNode = in.nextInt();
				int edgeWeight = in.nextInt();
				mat[fromNode][toNode] = edgeWeight;
			}
		}

		// solve
		Set<Integer> x = new HashSet<>();
		Set<Integer> y = new HashSet<>();
		boolean[] visit = new boolean[u];
		for (int i = 1; i < u; i++) {
			y.add(i);
		}
		int[] nodeCost = new int[u];
		Arrays.fill(nodeCost, Integer.MAX_VALUE);
		x.add(0);
		nodeCost[0] = 0;
		visit[0] = true;

		while (!y.isEmpty()) {
			int min = Integer.MAX_VALUE;
			int v = -1;
			for (int from : x) {
				for (int to = 0; to < u; to++) {
					int visitCost = mat[from][to] + nodeCost[from];
					// toのノードが最小コストで訪問済でない場合
					if (mat[from][to] != -1 && !visit[to] && visitCost <= nodeCost[to]) {
						nodeCost[to] = visitCost;
						if (nodeCost[to] < min) {
							min = nodeCost[to];
							v = to;
						}
					}
				}
			}
			x.add(v);
			y.remove(v);
			visit[v] = true;
		}

		for (int i = 0; i < u; i++) {
			System.out.println(i + " " + nodeCost[i]);
		}
	}

}

C++: // ※注意t C++14でコンパイルしないとエラーがでます
// ダイクストラ法
// ALDS1_12_C http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_C&lang=jp
#include <bits/stdc++.h>
using namespace std;

struct Vertex {                       // 頂点の情報を構造体Vertexで表す
    vector<pair<int, int>> neighbor;  // 隣接する頂点とそこまでの距離
    bool fixed = false;               // この頂点が確定しているか否か
    int fixed_cost = 0;               // 確定したコスト（始点からの最短距離）
};

int main(void) {
    // ■■ 初期化・データの読み込み ■■ 　
    int n;
    cin >> n;
    Vertex vertexs[n];  // n個の頂点を用意する
    for(int i = 0; i < n; i++) {
        int v, k;  // v:頂点　　k:vに隣接する頂点の数
        cin >> v >> k;
        for(int j = 0; j < k; j++) {
            int vi, ci;
            cin >> vi >> ci;
            vertexs[v].neighbor.push_back(make_pair(ci, vi));  // 各頂点vに対して、（隣接する頂点までのコスト(距離) と　その隣接頂点 ）をneighbor に読み込む
        }
    }

    // ■■ ダイクストラ法を実行 ■■ 　
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;  // pair< 出発点からの頂点までのコスト , 頂点 > の値を持つpriority_queue　（greaterにしないと昇順にならない）
    que.push(make_pair(0, 0));
    while(!que.empty()) {
        int cost = que.top().first;
        int v = que.top().second;
        que.pop();
        if(vertexs[v].fixed == false) {
            vertexs[v].fixed = true;
            vertexs[v].fixed_cost = cost;
            for(int i = 0; i < int(vertexs[v].neighbor.size()); i++) {
                int vi = vertexs[v].neighbor[i].second;  // vi: 頂点vに隣接するi番目の頂点
                int ci = vertexs[v].neighbor[i].first;   // ci: 頂点vから頂点viまでのコスト
                if(vertexs[vi].fixed == false) {
                    que.push(make_pair(cost + ci, vi));
                }
            }
        }
    }

    for(int i = 0; i < n; i++) {
        cout << i << " " << vertexs[i].fixed_cost << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define INF 1000000000
#define MAX_N 10000
using namespace std;
int n;
int d[MAX_N];

struct edge {
	int to, cost;
	edge(int to_, int cost_) : to(to_), cost(cost_) {}
};
typedef pair<int, int> P;
vector<edge> G[MAX_N];

void Dijkstra(int start) {
	fill(d, d + n, INF);
	priority_queue<P, vector<P>, greater<P>> que;
	d[start] = 0;
	que.push(P(0, start));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main()
{
	cin >> n;
	for (int i = 0, u, k; i < n; i++) {
		cin >> u >> k;
		for (int j = 0, v, c; j < k; j++) {
			cin >> v >> c;
			G[u].push_back(edge(v, c));
		}
	}
	Dijkstra(0);
	for (int i = 0; i < n; i++) {
		cout << i << ' ' << d[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<cstring>
#define P pair<int,int>//cost to
using namespace std;

vector<P>rinsetu[100];
int mincost[100];
signed main() {
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d; cin >> c >> d;
		for (int e = 0; e < d; e++) {
			int f, g; scanf("%d%d", &f, &g);
			rinsetu[c].push_back(P(g,f));
		}
	}
	fill(mincost, mincost + a, 1 << 29);
	mincost[0] = 0;
	priority_queue<P, vector<P>, greater<P>>Q;
	Q.push(P(0,0));
	while (Q.size()) {
		P t = Q.top(); Q.pop();
		if (t.first > mincost[t.second])continue;
		for (P i : rinsetu[t.second]) {
			if (mincost[i.second] > t.first + i.first) {
				mincost[i.second] = t.first + i.first;
				Q.push(P(t.first + i.first,i.second));
			}
		}
	}
	for (int i = 0; i < a; i++) {
		cout << i << " " << mincost[i] << endl;
	}
}