Go: package main

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

const BIG_COST = 200000

const (
	ST_NOT_YET = iota
	ST_JOINED
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nNodes := scanInt(sc)

	costs := make([][]int, nNodes)
	graph := make([][]int, nNodes)

	states := make([]int, nNodes)
	costSums := make([]int, nNodes)

	for i := 0; i < nNodes; i++ {
		costs[i] = make([]int, nNodes)
		costSums[i] = BIG_COST
	}

	for i := 0; i < nNodes; i++ {
		u := scanInt(sc)
		k := scanInt(sc)
		graph[u] = make([]int, k)
		for d := 0; d < k; d++ {
			v := scanInt(sc)
			graph[u][d] = v
			costs[u][v] = scanInt(sc)
		}
	}

	costSums[0] = 0
	for {
		minCost := BIG_COST
		var u int

		for i, cost := range costSums {
			if states[i] != ST_JOINED && cost < minCost {
				minCost = cost
				u = i
			}
		}

		if minCost == BIG_COST {
			break
		}

		states[u] = ST_JOINED

		for _, v := range graph[u] {
			cost := minCost + costs[u][v]
			if cost < costSums[v] {
				costSums[v] = cost
			}
		}
	}

	w := bufio.NewWriter(os.Stdout)
	for i, cost := range costSums {
		fmt.Fprintf(w, "%d %d\n", i, cost)
	}
	w.Flush()
}

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

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int G[110][110] = {};
int d[110] = {};
int main(){
    int n;
    cin >> n;
    memset(G,-1,sizeof(G));
    rep(i,n){
        int t,m;
        cin >> t >> m;
        rep(j,m){
            int a,b;
            cin >> a >> b;
            G[t][a] = b;
        }
    }

    rep(i,n) d[i] = 900010000;
    d[0] = 0;
    while(true){
        bool update = false;
        rep(i,n){
            rep(j,n){
                if(i==j) continue;
                if(G[i][j] != -1 && d[i] + G[i][j] < d[j]){
                    d[j] = d[i]+G[i][j];
                    update = true;
                }
            }
        }
        if(!update) break;
    }

    rep(i,n){
        cout << i << " " << d[i] << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
const int INF = 500000;
using namespace std;

int main(void){
  bool used[100];
  int n, G[100][100];
  cin >> n;
  for(int i=0; i < 100; i++){
    used[i] = false;
    for(int j=0; j < 100; j++){
      G[i][j] = INF;
    }
  }
  for(int i=0; i < n; i++){
    int vtmp, k;cin >> vtmp >> k;
    for(int j=0; j < k; j++){
      int v, c; cin >> v >> c;
      G[vtmp][v] = c;   
    }
  }

  int d[100];
  for(int i=0; i < n; i++){
    d[i] = INF;
  }
  d[0] = 0;

  for(int i=0; i < n; i++){
    int mind = INF;
    int minind = -1;
    for(int j=0; j < n; j++){
      if(used[j] == false && d[j] < mind){
        mind = d[j]; minind = j;
      }
    }
    if(minind == -1) break;
    used[minind] = true;
    for(int j=0; j < n; j++){
      if(used[j] == false && G[minind][j] != INF){
        if(d[minind] + G[minind][j] < d[j]){
          d[j] = d[minind] + G[minind][j];
        }
      }
    }
  }
  for(int i=0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<double, double> P;

void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

void warshall_floyd(int n, vector<vector<ll>> &d) {
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int n;
    cin >> n;

    vector<vector<ll>> distances(n, vector<ll>(n, INF));
    rep(i, n) distances[i][i] = 0;
    rep(i, n) {
        int j, k;
        cin >> j >> k;

        rep(l, k) {
            int u, c;
            cin >> u >> c;
            distances[j][u] = c;
        }
    }

    warshall_floyd(n, distances);

    rep(i, n) cout << i << ' ' << distances[0][i] << endl;

}

C++: #include<iostream>
#define N 101
#define INF 1<<21
using namespace std;

int A[N][N];
int n;
int visited[N];
int d[N];
int p[N];

void dijkstra(int b){
    d[b]=0;
    p[b]=-1;
    int node=-1;
    int minval=INF;
    while(1){
        node=-1;
        minval=INF;
        for(int i=0;i<n;i++){
            if(visited[i]==true) continue;
            if(d[i]<minval){
                node=i;
                minval=d[i];
            }
        }
        if(node==-1) break;
        visited[node]=true;
        for(int e=0;e<n;e++){
            if(A[node][e]==INF || visited[e]==true) continue;
            if(d[e]>d[node]+A[node][e]){
                d[e]=d[node]+A[node][e];
            }
        }
    }
}

void init(){
    int k;
    int b,e,val;
    cin>>n;
    for(int i=0;i<n;i++){
        visited[i]=false;
        d[i]=INF;
        p[i]=-1;
        for(int j=0;j<n;j++){
            A[i][j]=INF;
        }
    }
    for(int i=0;i<n;i++){
        cin>>b>>k;
        for(int j=0;j<k;j++){
            cin>>e>>val;
            A[b][e]=val;
        }
    }
}

int main(){
    init();

    dijkstra(0);

    for(int i=0;i<n;i++){
        cout<<i<<' '<<d[i]<<endl;
    }
    return 0;
}