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 <bits/stdc++.h>
using namespace std;

struct edge {
  int from, to, cost;
};


int INF;
vector<vector<edge>> es;
vector<int> dist;

bool bellmanFord (int n, int s) {
  dist[s] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < es[j].size(); k++) {
        edge e_ = es[j][k];
        if (dist[e_.from] != INF && dist[e_.to] > dist[e_.from] + e_.cost) {
          dist[e_.to] = dist[e_.from] + e_.cost;
          // n回目にも更新があるなら、負の閉路が存在する
          if (i == n - 1) {
            return true;
          }
        }
      }
    }
  }
  return false;
}

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

  INF = 2000000;
  es.resize(n);
  dist = vector<int>(n, INF);

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      edge e;
      e.from = u;
      cin >> e.to >> e.cost;
      es[i].push_back(e);
    }
  }

  bool flg = bellmanFord(n, 0);
  
  for (int i = 0; i < n; i++) {
    cout << i << " " <<  dist[i] << endl;
  }

  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <queue>
using namespace std;

class Vertice;
class Edge;

class Vertice{
private:
	int id;
	int edge_num;
	int *vertice_id_list;
	Edge **edges;
	bool flag_fixed;
	int distance_min;
public:
	Vertice(int id, int edge_num_max);
	~Vertice(){ delete[] edges, vertice_id_list; }
	int getDistanceMin() const { return distance_min; }
	void addEdge(int vertice_id, Edge *edge);
	void addVertices(Vertice *vertices[]);
	void setDistance(int d);
	void serveDistance();
	void setFlagFixed(){ flag_fixed = true; }
};

class Edge{
private:
	int distance;
	Vertice *vertice;
public:
	Edge(int distance){ this->distance = distance; }
	void addVertice(Vertice *vertice){ this->vertice = vertice; }
	void setDistance(int distance){ vertice->setDistance(distance + this->distance); }
};

struct verticeComp {
	bool operator()(const Vertice *v1, const Vertice *v2)
	{
		return v1->getDistanceMin() > v2->getDistanceMin();
	}
};

priority_queue<Vertice*, vector<Vertice*>, verticeComp > PQ; 

Vertice::Vertice(int id, int edge_num_max)
{
	this->id = id;
	edge_num = 0;
	vertice_id_list = new int[edge_num_max];
	edges = new Edge*[edge_num_max];
	flag_fixed = false;
	distance_min = INT_MAX;
}

void Vertice::addEdge(int vertice_id, Edge *edge)
{
	edges[edge_num] = edge;
	vertice_id_list[edge_num] = vertice_id;
	edge_num++;
}

void Vertice::addVertices(Vertice *vertices[])
{
	for (int i = 0; i < edge_num; i++) {
		edges[i]->addVertice(vertices[vertice_id_list[i]]);
	}
}

void Vertice::setDistance(int d)
{
	if (flag_fixed) return;
	if (d < distance_min) distance_min = d;
	PQ.push(this);
}

void Vertice::serveDistance()
{
	if (PQ.empty()) return;
	for (int i = 0; i < edge_num; i++) {
		edges[i]->setDistance(distance_min);
	}
	Vertice *fixed_vertice = PQ.top();
	PQ.pop();
	fixed_vertice->setFlagFixed();
	fixed_vertice->serveDistance();
}

int main(void)
{
	Vertice **vertices;

	int n;
	cin >> n;
	vertices = new Vertice*[n];
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		vertices[u] = new Vertice(u, k);
		for (int j = 0; j < k; j++) {
			int v, c;
			cin >> v >> c;
			vertices[u]->addEdge(v, new Edge(c));
		}
	}
	
	for (int i = 0; i < n; i++) {
		vertices[i]->addVertices(vertices);
	}

	vertices[0]->setDistance(0);
	vertices[0]->serveDistance();

	for (int i = 0; i < n; i++) {
		cout << i << " ";
		cout << vertices[i]->getDistanceMin() << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define MAX_V 100
#define INF (1 << 21)

int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;

int s = 0; // start

void dijkstra()
{
    for (int i = 0; i < V; i++) {
        d[i] = INF;
        used[i] = false;
    }

    d[s] = 0;
    for(;;) {
        int v = -1;
        for (int u = 0; u < V; u++) {
            if (!used[u] && (v == -1 || d[u] < d[v]))
                v = u;
        }
        if (v == -1) break;

        used[v] = true;

        for (int u = 0; u < V; u++) {
            d[u] = min(d[u], d[v] + cost[v][u]);
        }
    }

    for (int u = 0; u < V; u++) {
        cout << u << " " << (d[u] == INF ? -1 : d[u]) << endl;
    }

}
int main()
{
    cin >> V;

    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            cost[i][j] = INF;
        }
    }
    for (int i = 0; i < V; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            cost[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}

C++: 
#include <iostream>
using namespace std;
#define INFTY  (1 << 30)
const int Total = 101;
const int White = 0;//未访问
const int Grey = 1;//访问中
const int Black = 2;//不再访问
int  totalnode,Matrix[Total][Total], Color[Total], DistanceBetweenRootAndNode[Total],Parent[Total];
void includeBuildSingleSourceShortestPath()
{
	int minimumdistance, min;
	DistanceBetweenRootAndNode[0] = 0;//默认以0为根
	Parent[0] = -1;
	Color[0] = Grey;
	while (1)
	{
		minimumdistance = INFTY;
		for (int i = 0; i < totalnode; i++)
		{
			if (Color[i] != Black && DistanceBetweenRootAndNode[i] < minimumdistance)//在未访问或访问的点中找出最短的那个
				minimumdistance = DistanceBetweenRootAndNode[i], min = i;
		}
		if (minimumdistance == INFTY)break;//全部为黑色
		Color[min] = Black;//以min为基础搜相连的结点
		for (int i = 0; i < totalnode; i++)
		{
			if (Matrix[min][i] != 0 && Color[i] != Black)//找出相连且未被设为不再访问的结点
			{
				if (DistanceBetweenRootAndNode[min] + Matrix[min][i] < DistanceBetweenRootAndNode[i])
					//若根到点min的距离 加上 点min到点i的距离 小于 之前根到点i的距离
				{
					DistanceBetweenRootAndNode[i] = DistanceBetweenRootAndNode[min] + Matrix[min][i];
					Parent[i] = min;
					Color[i] = Grey;
				}

			}

		}


	}
}
int main()
{
	int frontnode,backnode,degree,distancebetweenfrontnodeandbacknode;
	cin >> totalnode;
	for (int i = 0; i < totalnode; i++)DistanceBetweenRootAndNode[i] = INFTY;//初始化距离
	for (int i = 0; i < totalnode; i++)Color[i] = White;
	for (int i = 0; i < totalnode; i++)
		for (int j = 0; j < totalnode; j++)
			Matrix[i][j] = 0;
	for (int i = 0; i < totalnode; i++)//有向图
	{
		cin >>frontnode>>degree;//frontnode中题目其实就默认从0开始
		for (int j = 0; j < degree; j++)
		{
			cin >> backnode>> distancebetweenfrontnodeandbacknode;
			Matrix[frontnode][backnode] = distancebetweenfrontnodeandbacknode;
		}
	}
	includeBuildSingleSourceShortestPath();
	for (int i = 0; i < totalnode; i++)
		cout << i <<" "<< DistanceBetweenRootAndNode[i]<<endl;
}