Go: package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	MAX_N      = 10000
	MAX_WEIGHT = 100000
)

type Edge struct {
	start  int
	end    int
	weight int
}

type ShortestInfo struct {
	edges    []Edge
	shortest int
}

func main() {
	doMain(os.Stdin)
}

func doMain(reader io.Reader) {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	shortestList := make([]ShortestInfo, n)
	for i := 1; i < n; i++ {
		shortestList[i] = ShortestInfo{edges: []Edge{}, shortest: MAX_N*MAX_WEIGHT + 1}
	}

	adjacentMatrix, err := createAdjacentMatrix(n, sc)
	if err != nil {
		panic(err)
	}

	sssp([]int{0}, shortestList, adjacentMatrix)
	for _, v := range shortestList {
		fmt.Println(v.getEnd(), v.shortest)
	}
}

func (si ShortestInfo) getEnd() int {
	if len(si.edges) == 0 {
		return 0
	} else {
		return si.edges[len(si.edges)-1].end
	}
}

func createAdjacentMatrix(n int, sc *bufio.Scanner) ([][]int, error) {
	adjacentMatrix := make([][]int, n)
	for i := 0; i < n; i++ {
		id, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		adjacentMatrix[id] = make([]int, n)
		for j := 0; j < n; j++ {
			adjacentMatrix[id][j] = -1
		}
		vertexNum, err := nextInt(sc)
		if err != nil {
			return nil, err
		}
		for j := 0; j < vertexNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				return nil, err
			}
			c, err := nextInt(sc)
			if err != nil {
				return nil, err
			}
			adjacentMatrix[id][v] = c
		}
	}
	return adjacentMatrix, nil
}

func sssp(nodeStack []int, shortestList []ShortestInfo, adjacentMatrix [][]int) {
	for len(nodeStack) > 0 {
		currentNode := nodeStack[0]
		nodeStack = nodeStack[1:]
		currentShortest := getShortest(currentNode, shortestList)
		adjacents := findAdjacents(currentNode, adjacentMatrix)
		for i := 0; i < len(adjacents); i++ {
			adj := adjacents[i]
			if currentShortest.shortest+adj.weight < getShortest(adj.end, shortestList).shortest {
				setShortest(adj.end, adj, currentShortest, shortestList)
				nodeStack = append(nodeStack, adj.end)
			}
		}
	}
}

func getShortest(node int, shortestList []ShortestInfo) ShortestInfo {
	return shortestList[node]
}

func setShortest(node int, edge Edge, currentShortest ShortestInfo, shortestList []ShortestInfo) {
	newEdges := make([]Edge, len(currentShortest.edges)+1)
	for i := 0; i < len(newEdges)-1; i++ {
		newEdges[i] = currentShortest.edges[i]
	}
	newEdges[len(newEdges)-1] = edge
	shortestInfo := ShortestInfo{edges: newEdges, shortest: currentShortest.shortest + edge.weight}
	shortestList[node] = shortestInfo
}

func findAdjacents(currentNode int, adjacentMatrix [][]int) []Edge {
	adjacents := adjacentMatrix[currentNode]
	edges := []Edge{}
	for i, v := range adjacents {
		if v >= 0 {
			edges = append(edges, Edge{start: currentNode, end: i, weight: v})
		}
	}
	return edges
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

C++: #include<bits/stdc++.h>
using namespace std;

int cost[100][100];//cost[a][b] a??????b????§?????????????????????????
long long int d[100];//??????s?????????????°??????¢
bool used[100];
int arrow;//????????°

const int INF = 10000000;

void dijkstra(){
  fill(d,d+arrow,INF);
  fill(used,used + arrow,false);
  d[0] = 0;

  while(1){
    int v=-1;
    // ???????????????????????????????????????????????¢???????°???????????????¢???
    for(int u=0;u<arrow;u++){
      if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }

    if(v == -1) break;

    used[v] = true;

    for(int u=0; u<arrow; u++){
      if(cost[v][u] != INF){
        d[u] = min(d[u],d[v] + cost[v][u]);
      }
    }
  }

  for(int u=0; u<arrow; u++){
    cout << u << " " << d[u] << endl;
  }

}

int main(){

    cin >> arrow;

    int n,a,v,c;



    for(int i=0;i<arrow;i++){
      for(int j=0;j<arrow;j++){
        cost[i][j] = INF;
      }
    }

    for(int u=0;u<arrow;u++){

      cin >> n >> a;

      for(int i=0; i<a;i++){
        cin >> v >> c;
        cost[n][v] = c;
      }
    }

    dijkstra();

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> pp;
const int INF = 1001001001;
struct edge{int to, cost;};

int main() {
    int V;
    cin >> V;
    vector< vector<edge> > A(V);
    for(int i=0; i<V; i++) {
        int u,k;
        cin >> u >> k;
        A[u].resize(k);
        for(int j=0; j<k; j++) {
            int v,c;
            cin >> v >> c;
            struct edge e = {v,c};
            A[u][j] = e;
        }
    }

    vector<int> d(V,INF);
    d[0] = 0;
    priority_queue< pp, vector<pp>, greater<pp> > Q;
    Q.push(pp(d[0],0));
    
    while(!(Q.empty())) {
        pp temp = Q.top();
        Q.pop();
        int ct = temp.first;
        int u = temp.second;
        for(int j=0; j<A[u].size(); j++) {
            int v = A[u][j].to;
            int tmpcost = A[u][j].cost;
            if(d[v] > ct + tmpcost) {
                d[v] = ct + tmpcost;
                Q.push(pp(d[v], v));
            }
        }
    }

    for(int i=0; i<V; i++) cout << i << " " << d[i] << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const int INF = numeric_limits<int>::max();

struct Graph {
    struct edge {
        int v, c;
    };
    vector<vector<edge>> adj;
    vector<int> d;
    Graph(int n) {
        adj.assign(n, vector<edge>());
        d.assign(n, INF);
    }
};

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            g.adj[i].push_back({v, c});
        }
    }

    priority_queue<P, vector<P>, greater<P>> pq;
    g.d[0] = 0;
    pq.push(P(0, 0));
    while (!pq.empty()) {
        int c = pq.top().first;
        int u = pq.top().second;
        pq.pop();
        if (g.d[u] < c) continue;
        for (auto e : g.adj[u]) {
            if (g.d[e.v] > g.d[u] + e.c) {
                g.d[e.v] = g.d[u] + e.c;
                pq.push(P(g.d[e.v], e.v));
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << g.d[i] << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int R =10000;
static const int IF = (1<<20);
static const int WH = 0;
static const int GR =1;
static const int BL =2;

int num;
vector<pair<int,int> > ax[R];

void dx(){
  priority_queue<pair<int,int> > Pi;
  int IR[R],i,j,y,x;
  int D[R];

  for(i=0;i<num;i++){
    D[i] = IF;
    IR[i] = WH;
  }

  D[0] = 0;
  Pi.push(make_pair(0,0));
  IR[0] =GR;

  while(!Pi.empty()){
    pair<int,int> F=Pi.top();
    Pi.pop();
    x =F.second;

    IR[x] =BL;

    if(D[x] < F.first * (-1)){
      continue;
    }

    for(j=0;j<ax[x].size();j++){
       y= ax[x][j].first;
       
      if(IR[y] ==BL){
	continue;
      }
      if(D[y] > D[x] + ax[x][j].second){
	 D[y] = D[x] + ax[x][j].second;
	 Pi.push(make_pair(D[y] * (-1),y));
	 IR[y] = GR;
	 }
    }
  }

  for(int i=0;i<num;i++){
    cout << i << " " << (D[i] == IF ? -1 : D[i] ) << endl;
  }
}

int main(){
  int z,x,y,ci,i,j;

  cin >> num;
  for(i=0;i<num;i++){
    cin >> x >> z;

    for(j=0;j<z;j++){
      cin >> y >> ci;
      ax[x].push_back(make_pair(y,ci));
    }
  }
  dx();

  return 0;
}