Go: package main

import (
	"fmt"
	"os"
	"bufio"
	"strings"
	"strconv"
)
var MAX = 1000000
type Vertex struct{
	Value int
	Routes map[int]int
	Done bool
}
func NewVertex(value int) *Vertex{
	routes := make(map[int]int)
	// for i, _ := range routes {
	// 	routes[i] = MAX
	// }
	return &Vertex{ value, routes, false }
}

func (v *Vertex) SetRoute(key, weight int) {
	v.Routes[key] = weight
}

type Path struct {
	Key int
	Weight int
}

var count = 0
func ShortestRoutes(list []*Vertex) []int {
	// create result table
	result  := make([]int, len(list))
	// fmt.Println(result)
	for i, _ := range result {
		result[i] = MAX
	}

	queue := make([]Path, 0)
	queue = append(queue, Path{0, 0})
	result[0] = 0

	for len(queue) != 0 {
		count++
		path := queue[0]
		queue = queue[1:]
		for key, weight := range list[path.Key].Routes {
			// fmt.Println(list[path.Key].Routes)
			// set to result
			// fmt.Printf("Path(%d, %d) ? result[%d] => %d, wieght: %d\n", path.Key, path.Weight, key, result[key], weight)
			if path.Weight + weight < result[key] {
				result[key] = path.Weight + weight 
				queue = append(queue, Path{key, result[key]})
			// } else if !list[key].Done {
			// 	queue = append(queue, Path{key, result[key]})
			}
		}
		list[path.Key].Done = true
	}
	return result
}
func main() {
	var n int
	fmt.Scanf("%d", &n)
	list := make([]*Vertex, n)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		scanner.Scan()
		elements := strings.Split(scanner.Text(), " ")
		value, _ := strconv.Atoi(elements[0])
		list[i] = NewVertex(value)
		for j := 2; j < len(elements); j += 2 {
			key, _    := strconv.Atoi(elements[j])
			weight, _ := strconv.Atoi(elements[j + 1])
			list[i].SetRoute(key, weight)
		}
	}

	result := ShortestRoutes(list)
	for i := 0; i < len(result); i++ {
		fmt.Printf("%d %d\n", i, result[i]);
	}
	// fmt.Printf("count: %d\n", count)
}

C++: #include <queue>
#include <stdint.h>
#include <vector>

typedef void (*single_source_shortest_path_callback_t)(int32_t index, int32_t weight);

#define GRAPH_MAX_SIZE 10000
extern bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size,
                                        single_source_shortest_path_callback_t callback);

enum color_t { WHITE, GRAY, BLACK };

static int32_t weights[GRAPH_MAX_SIZE];
static color_t colors[GRAPH_MAX_SIZE];

bool single_source_shortest_path(vector<pair<int32_t, int32_t>> *graph, size_t size, single_source_shortest_path_callback_t callback)
{
  if ((graph == nullptr) || (size == 0)) return false;

  int32_t i;
  for (i = 0; i < GRAPH_MAX_SIZE; i++) {
    weights[i] = INT32_MAX;
    colors[i] = WHITE;
  }

  weights[0] = 0;
  priority_queue<pair<int32_t, int32_t>> que;
  que.push(make_pair(-1 * weights[0], 0));

  while (!que.empty()) {
    pair<int, int> top = que.top();
    que.pop();
    int32_t top_index = top.second;
    int32_t top_weights = (-1) * top.first;
    if (top_weights > weights[top_index]) continue;

    callback(top_index, top_weights);
    colors[top_index] = BLACK;

    vector<pair<int32_t, int32_t>> vertex = graph[top_index];
    for (auto connect_to = vertex.begin(); connect_to != vertex.end(); connect_to++) {
      int32_t index = (*connect_to).first;
      if (colors[index] != BLACK) {
        int32_t new_weight = weights[top_index] + (*connect_to).second;

        if (new_weight < weights[index]) {
          weights[index] = new_weight;
          colors[index] = GRAY;
          que.push(make_pair(-1 * weights[index], index));
        }
      }
    }
  }
  return true;
}

#if !defined(TEST)
static vector<pair<int32_t, int32_t>> graph[GRAPH_MAX_SIZE];
static int32_t routes[GRAPH_MAX_SIZE];

void callback(int32_t index, int32_t weight)
{
  routes[index] = weight;
}

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);

  uint32_t i;
  for (i = 0; i < num; i++) {
    int32_t index, len;
    scanf("%d", &index);
    scanf("%d", &len);
    uint32_t j;
    for (j = 0; j < len; j++) {
      int32_t k, v;
      scanf("%d %d", &k, &v);
      graph[i].push_back(make_pair(k, v));
    }
  }
  single_source_shortest_path(graph, num, callback);

  for (i = 0; i < num; i++) {
    printf("%d %d\n", i, routes[i]);
  }

  return 0;
}
#endif

C++: #include<iostream>
#include<vector>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > M[MAX];

void dijkstra(int s)
{
    int u,  minv;
    int d[MAX], color[MAX];

    for(int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[s] = 0;
    while(1)
    {
        minv = INFTY;
        u = -1;
        for(int i = 0; i < n; i++)
        {
            if(minv > d[i] && color[i] != BLACK)
            {
                u = i;
                minv = d[i];
            }
        }

        if(u == -1) break;
        color[u] = BLACK;
        for(int v = 0; v < M[u].size(); v++)
            if(color[M[u][v].first] != BLACK)
            {
                if(d[M[u][v].first] > M[u][v].second + d[u])
                {
                    d[M[u][v].first] = M[u][v].second + d[u];
                }
            }
    }
    for(int i = 0; i < n; i++)
        cout << i << " " << d[i] << endl;
}

int main()
{
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        int x, k;
        cin >> x >> k;
        for(int j = 0; j < k; j++)
        {
            int v, w;
            cin >> v >> w;
            M[x].push_back(make_pair(v, w));
        }
    }
    dijkstra(0);

    return 0;
}

C++: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Edge{
	Edge(int arg_to,int arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to,dist;
};

struct Info{
	Info(int arg_node_id,int arg_sum_dist){
		node_id = arg_node_id;
		sum_dist = arg_sum_dist;
	}
	bool operator<(const struct Info &arg) const{

		return sum_dist > arg.sum_dist; //総距離の昇順(PQ)
	}

	int node_id,sum_dist;
};

int V;
int min_dist[SIZE];
vector<Edge> G[SIZE];

int main(){

	scanf("%d",&V);

	int node_id,num_node,to,dist;

	for(int i = 0; i < V; i++){

		scanf("%d %d",&node_id,&num_node);
		for(int k = 0; k < num_node; k++){

			scanf("%d %d",&to,&dist);
			G[node_id].push_back(Edge(to,dist));
		}
	}

	for(int i = 0; i < V; i++){

		min_dist[i] = BIG_NUM;
	}

	priority_queue<Info> Q;
	min_dist[0] = 0;

	Q.push(Info(0,0));

	while(!Q.empty()){

		if(Q.top().sum_dist > min_dist[Q.top().node_id]){

			Q.pop();

		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				int next_node = G[Q.top().node_id][i].to;
				int next_dist = Q.top().sum_dist+G[Q.top().node_id][i].dist;

				if(min_dist[next_node] > next_dist){
					min_dist[next_node] = next_dist;
					Q.push(Info(next_node,next_dist));
				}
			}
			Q.pop();
		}
	}

	for(int i = 0; i < V; i++){

		printf("%d %d\n",i,min_dist[i]);
	}

	return 0;
}