Go: package main

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

const MAX = 100
const INFTY = math.MaxInt64
const WHITE = 0
const GRAY = 1
const BLACK = 2

var n int
var M [MAX][MAX]int

func dijkstra() {
	var minv int
	var d [MAX]int
	var color [MAX]int

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

	d[0] = 0
	color[0] = GRAY
	for {

		minv = INFTY
		u := -1
		for 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 v := 0; v < n; v++ {
			if color[v] != BLACK && M[u][v] != INFTY {
				if d[v] > d[u]+M[u][v] {
					d[v] = d[u] + M[u][v]
					color[v] = GRAY
				}
			}
		}

	}
	for i := 0; i < n; i++ {
		fmt.Printf("%v %v\n", i, d[i])
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			M[i][j] = INFTY
		}
	}

	for i := 0; i < n; i++ {
		sc.Scan()
		f, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		for j := 0; j < k; j++ {
			sc.Scan()
			v, _ := strconv.Atoi(sc.Text())
			sc.Scan()
			c, _ := strconv.Atoi(sc.Text())
			M[f][v] = c
		}
	}
	dijkstra()
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
using namespace std;
const int INF = 2000000000;
const int num = 100;
int n, u, k, v, w;
int m[num][num];
int d[num];
int c[num];
int main() {
	cin >> n;
	fill(m[0], m[num], INF);
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; i++) {
			cin >> v >> w;
			m[u][v] = w;
		}
	}
	fill(d, d + num, INF);
	fill(c, c + num, 0);
	d[0] = 0;
	while (true) {
		int ne = -1;
		int minv = INF;
		for (int i = 0; i < n; i++)
			if (!c[i] && d[i] < minv) {
				ne = i;
			}
		if (ne == -1) break;
		c[ne] = 1;
		for (int i = 0; i < n; i++) {
			if (d[i] > d[ne] + m[ne][i]) d[i] = d[ne] + m[ne][i];
		}
	}
	for (int i = 0; i < n; i++)
		cout << i << " "<< d[i] << endl;
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
#include <queue>
#include <type_traits>
#include <cstdint>
using namespace std;
const int INF = 7+(1e+9);
typedef int Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
//引数 g:隣接リスト,s:始点,dist:各頂点までの距離が入る(負閉路を含む場合,-INF),prev:最短路木の親頂点が入る
//戻値 負閉路が存在しない場合:true,そうでないとき:false
bool shortestPath(const Graph &g,int s,vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF+INF); dist[s] = 0;
  prev.assign(n, -2);
  bool negative_cycle = false;
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(auto e=g[i].begin();e!=g[i].end();e++){
        if(dist[e->dst] > dist[e->src] + e->weight) {
          dist[e->dst] = dist[e->src] + e->weight;
          prev[e->dst] = e->src;
          if (k == n-1) {
            dist[e->dst] = -INF;
            negative_cycle = true;
          }
        }
      }
    }
  }
  return !negative_cycle;
}

//引数 prev:最短路木の親頂点集合,t:終点
//戻値 path:sからtへの最短経路
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}
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[u].push_back(Edge(u,v,c));
        }
    }
    
  // ...
  //頂点数vの空隣接リストgを生成
  // ...
      //隣接リストgにsからtに向かう重さwの辺を追加
  // ...
  vector<Weight> dist;
  vector<int> prev;
  bool negative_cycle=shortestPath(g,0,dist,prev);
  for(int i=0;i<n;i++){
      cout << i <<" ";
      cout << dist[i]<<endl;
  } 
  // ...
}

C++: #include<iostream>
#include<cstdio>
#include<climits>
using namespace std;
 
#define N 1010
int n;
 
int g[N][N];
 
int weight[N];
bool us[N];
 
//prim
void prim(){
 
  int v;
  
  weight[0]=0;
   
  while(true){
    v=-1;
    
    for(int i=0;i<n;i++){
      if(us[i]!=true && (v==-1 ||weight[i]<weight[v]))v=i;
    }
 
    if(v==-1)break;
    us[v]=true;
  
 
    for(int i=0;i<n;i++){
      if(weight[i]>(g[v][i]+weight[v])){
 
        weight[i]=(g[v][i]+weight[v]);
        //      cout <<"fsafa"<<endl;
      }
    }
  }
  
}
 
 
int main(){
 
  int u,k1,c,v;
 
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      g[i][j]=9953535;
    }
  }
 
  //load n
  cin >>n;
 
  //load data
  for(int i=0;i<n;i++){
    weight[i]=INT_MAX;
    us[i]=false;
    scanf("%d %d",&u,&k1);
    for(int j=0;j<k1;j++){
      scanf("%d %d",&v,&c);
      g[u][v]=c;
      //    cout <<g[i][j]<<" ";
    }
    //    cout <<endl;
  }
 
 
 
 
  //print
  prim();
 
  for(int i=0;i<n;i++){
    cout <<i<<" "<<weight[i]<<endl;
  }
  return 0;
 
}

C++: #include <iostream>
using namespace std;

const int MAX = 100;
const int INF = 1 << 29;

int n;
int grid[MAX][MAX];

void solve()
{
	int ans[MAX];
	bool visited[MAX];

	for (int i = 0; i < n; i++) {
		ans[i] = INF;
		visited[i] = false;
	}

	ans[0] = 0;

	while (true) {
		int min = INF;
		int min_index;

		for (int i = 0; i < n; i++) {
			if (min > ans[i] && visited[i] == false) {
				min = ans[i];
				min_index = i;
			}
		}

		if (min == INF) {
			break;
		}


		visited[min_index] = true;

		for (int i = 0; i < n; i++) {
			if (grid[min_index][i] != INF&&ans[i] > ans[min_index] + grid[min_index][i]) {
				ans[i] = ans[min_index] + grid[min_index][i];
			}
		}
	}
	

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

int main()
{
	for (int i = 0; i < MAX; i++) {
		for (int j = 0; j < MAX; j++) {
			grid[i][j] = INF;
		}
	}

	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num >> num;

		for (int j = 0; j < num; j++) {
			int k;
			cin >> k;
			cin >> grid[i][k];
		}
	}

	solve();

	return 0;
}

C++: 
#include<iostream>

using namespace std;


static const int MAX = 100;
static const int inf = (1 << 21);
static const int white = 0;
static const int gray = 1;
static const int black = 2;

int n, m[MAX][MAX];
int sht[MAX];


void dijkstra() {

	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++)
	{
		sht[i] = d[i] = inf;
		p[i] = -1;
		color[i] = white;
	}

	d[0] = 0;
	color[0] = gray;

	while (1)
	{
		minv = inf;
		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 < n; v++) {
			if (color[v] != black && m[u][v] != inf) {
				if (d[v] > d[u] + m[u][v]) {
					d[v] = d[u] + m[u][v];
					color[v] = gray;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == inf ? -1 : d[i]) << endl;

	}
}


int main() {


	cin >> n;

	for (int i = 0;i < n;i++) {
		for (int k = 0; k < n; k++)
		{
			m[i][k] = inf;
		}
	}

	int nm, c, u, v;
	for (int i = 0;i < n;i++) {
		cin >> u >> nm;
		for (int k = 0; k < nm; k++)
		{
			cin >> v >> c;
			m[u][v] = c;
		}
	}

	dijkstra();

	return 0;
}