Go: package main

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

const (
	white int = iota
	gray
	black
)

type node struct {
	id     int
	parent int
	edge   []int
	weight []int
	color  int
}

type graph struct {
	nodes    []node
	distance []int
}

var infty = 1 << 32
var null = -1

func constructgraph() *graph {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)

	g := &graph{make([]node, n), make([]int, n)}

	for i := 0; i < n; i++ {
		id := nextInt(sc)
		edges := nextInt(sc)
		n := node{}
		n.id = id
		n.edge = make([]int, edges)
		n.weight = make([]int, edges)
		n.color = white
		for j := 0; j < edges; j++ {
			to := nextInt(sc)
			w := nextInt(sc)
			n.edge[j] = to
			n.weight[j] = w
		}
		g.nodes[id] = n
	}
	return g
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func (g *graph) preparedijkstra(s int) {
	for i := 0; i < len(g.nodes); i++ {
		g.nodes[i].color = white
		g.nodes[i].parent = null
		g.distance[i] = infty
	}
	g.distance[s] = 0
}

func (g *graph) dijkstra(s int) []int {
	g.preparedijkstra(s)

	for {
		var u int
		mincost := infty
		for i, d := range g.distance {
			if g.nodes[i].color != black && mincost > d {
				mincost = d
				u = i
			}
		}

		if mincost == infty {
			break
		}

		g.nodes[u].color = black

		for i, e := range g.nodes[u].edge {
			if g.nodes[e].color != black {
				if g.distance[e] > g.distance[u]+g.nodes[u].weight[i] {
					g.distance[e] = g.distance[u] + g.nodes[u].weight[i]
					g.nodes[e].parent = u
					g.nodes[e].color = gray
				}
			}
		}
	}
	return g.distance
}

func printShortestPath(d []int) {
	for i, v := range d {
		fmt.Printf("%d %d\n", i, v)
	}
}

func main() {
	g := constructgraph()
	d := g.dijkstra(0)
	printShortestPath(d)
}

C++: #include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int n;					//えぬ
int a[100][100] = {0};	//辺の重さ
int f[100] = {0};		//その頂点が調査済みかどうか

int main(){
	cin >> n;
	//まず辺の重さをaに入れる
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			a[i][j] = -1;
		}
	}
	a[0][0] = 0;
	for ( int i = 0; i < n; i++ ) {
		int u;
		cin >> u;
		int k;
		cin >> k;
		for ( int j = 0; j < k; j++ ) {
			int v;
			cin >> v;
			cin >> a[u][v];
		}
	}
	for ( int i = 0; i < n - 1; i++ ) {
		int k = -1;
		int v = 0;
		for ( int j = 1; j < n; j++ ) {
			if ( a[0][j] == -1 || f[j] == 1 ) continue;
			if ( k == -1 || a[0][j] < k ) {
				v = j;
				k = a[0][j];
			}
		}
		f[v] = 1;
		for ( int j = 1; j < n; j++ ) {
			if ( v == j ) continue;
			if ( a[v][j] == -1 || f[j] == 1 ) continue;
			if ( a[0][j] == -1 || a[0][j] > a[0][v] + a[v][j] ) {
				a[0][j] = a[0][v] + a[v][j];
			}
		}
	}
	for ( int i = 0; i < n; i++ ) {
		cout << i << " " << a[0][i] << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int N;
int G[100][100];
int d[100];
int used[100];
const int INF=99999999;
int c;
void dijkstra(int s){
  for(int u=0;u<N;u++)d[u]=INF;
  d[s]=0;
  while(1 && c<10){   
    int v=-1;
    for(int u=0;u<N;u++){
      if((v==-1 || d[v]>d[u]) && !used[u])v=u;
    }
    if(v==-1)break;
    used[v]=1;
    for(int u=0;u<N;u++){
      d[u]=min(d[u],d[v]+G[v][u]);
    }
    c++;
  }
}
int main(){

  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      G[i][j]=INF;
      if(i==j)G[i][j]=0;
    }
  }
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    int u,k,c,v;
    scanf("%d %d",&u,&k);
    for(int j=0;j<k;j++){
      scanf("%d %d",&c,&v);
      G[u][c]=v;
     
    }
  }
  dijkstra(0);
  for(int i=0;i<N;i++)printf("%d %d\n",i,d[i]);
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<queue>
using namespace std;
template< typename FirstType, typename SecondType >
struct PairComparator {
  bool operator()( const pair<FirstType, SecondType>& p1, const pair<FirstType, SecondType>& p2 ) const 
    {  
		return p1.first > p2.first;
    }
};
bool inMST(vector< std::pair<int,int> > & MST,int j) {
	for (int k=0;k<(int)MST.size();++k){
		if(j == MST[k].second)
			return true;
	}
	return false;
}
int main(){
	int n;
	cin >> n;
	vector<int> E(n*n,-1);
	vector<int> DPG(n,-1);
	vector< std::pair<int,int> > MST;
	for(int j=0;j<n;++j) {
		int u,k; 
		cin >> u >> k;
		for(int i=0;i<k;++i){
			int v,c;
			cin >> v >> c;
			E[u*n+v] = c;
		}
	}
	priority_queue<pair<int,pair<int,int> >,vector< pair<int,pair<int,int> > >,
		PairComparator<int,pair<int,int> > > r;

	int cost = 0;
	int i=0;
	MST.push_back(pair<int,int>(i,i));
	DPG[i] = 0;
	while((int)MST.size() < n) {
		int ii=i*n;
		for (int j=0;j<n;++j) {
			if (E[ii+j] >= 0) {
				pair<int,int> add = std::make_pair(i,j);
				if (!inMST(MST,add.second)){
					r.push(std::pair<int,std::pair<int,int> >(E[ii+j],add));
				}
			}
		}
		pair<int,pair<int,int> > top;
		while (!r.empty()) {
			top = r.top();
			r.pop();
			if (!inMST(MST,top.second.second)){
				break;
			}
		}
		cost += top.first;
		MST.push_back(top.second);
		i = top.second.second;
		DPG[i] = DPG[top.second.first] + top.first;
		for(int j=0;j<n;++j){
			if (DPG[j] < 0)continue;
			if (E[i*n+j] < 0)continue;
			DPG[j] = std::min(DPG[j],DPG[i] + E[i*n+j]);
		}
	}
	for (int j=0;j<n;++j) {
		cout << j << " " <<  DPG[j] << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,G[1001][1001],dis[1001],vis[1001],inf=10e8;
void dij(int u){
	for(int i=0;i<n;i++){
	 dis[i]=G[u][i];
	}
	int k;
	vis[u]=1;dis[u]=0;
	for(int i=0;i<n-1;i++){
		int min=inf ;
		for(int j=0;j<n;j++){
			if(vis[j]==0&&dis[j]<min){
				min=dis[j];
				k=j;
			}
		}
		vis[k]=1;
		for(int j=0;j<n;j++){
			if(!vis[j]&&dis[j]>dis[k]+G[k][j])
			dis[j]=dis[k]+G[k][j];
		}
	}
}
int main(){
	scanf("%d",&n);
	int c,v1,v2,k;
	for(int i=0;i<n;i++){
		scanf("%d%d",&v1,&k);
		for(int j=0;j<k;j++){
			scanf("%d%d",&v2,&c);
			G[v1][v2]=c;
		}
	}
	
		for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
		  if(G[i][j]==0&&i!=j){
		  	G[i][j]=inf;
		  }
	}
	
	
//	for(int i=0;i<n;i++){
//		for(int j=0;j<n;j++){
//			printf("%d ",G[i][j]);
//		}printf("\n"); 
//	}
	dij(0);
	for(int i=0;i<n;i++)
	printf("%d %d\n",i,dis[i]);
}