Go: package main

import (
	"bufio"
	"fmt"
	"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() {
	sc := bufio.NewScanner(os.Stdin)
	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{1}, shortestList, adjacentMatrix)
	for _, v := range shortestList {
		fmt.Printf("%d %d\n", v.getEnd()-1, v.shortest)
	}
}

func (si ShortestInfo) getEnd() int {
	if len(si.edges) == 0 {
		return 1
	} 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-1]
}

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-1] = shortestInfo
}

func findAdjacents(currentNode int, adjacentMatrix [][]int) []Edge {
	adjacents := adjacentMatrix[currentNode-1]
	edges := []Edge{}
	for i, v := range adjacents {
		if v > 0 {
			edges = append(edges, Edge{start: currentNode, end: i + 1, 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 main()
{
    int n, inf = 100000000;
    scanf("%d", &n);
    vector<vector<pair<int, int>>> a(n, vector<pair<int, int>>(0));
    for (int i = 0, u, k; i < n; i++)
    {
        scanf("%d %d", &u, &k);
        for (int j = 0, v, c; j < k; j++)
        {
            scanf("%d %d", &v, &c);
            a[i].push_back(make_pair(c, v));
        }
    }
    
    vector<int> cost(n, inf), vis(n, 0);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > q;
    cost[0] = 0;
    q.push(make_pair(0, 0));
    for (pair<int, int> t; !q.empty(); )
    {
        
        t = q.top();
        q.pop();
        vis[t.second] = true;
        if (cost[t.second] < t.first)
        {
            continue;
        }
        for (int i = 0; i < a[t.second].size(); i++)
        {
            pair<int, int> j = a[t.second][i];
            if (!vis[j.second] && cost[j.second] > cost[t.second] + j.first)
            {
                cost[j.second] = cost[t.second] + j.first;
                q.push(make_pair(cost[j.second], j.second));
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        printf("%d %d\n", i, cost[i]);
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
vector<vector<P> > G;
signed main(){
  int n;
  cin>>n;
  int INF=1LL<<55LL;
  G.resize(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(P(v,c));
    }
  }
  int d[n];
  for(int i=0;i<n;i++) d[i]=INF;
  d[0]=0;

  priority_queue<P,vector<P>,greater<P> > q;
  d[0]=0;
  q.push(P(0,0));

  while(!q.empty()){
    P p=q.top();q.pop();
    int u=p.second,c=p.first;
    //cout<<u<<" "<<c<<endl;
    if(d[u]<c) continue;
    for(P e:G[u]){
      int v=e.first,w=e.second;
      if(d[v]>d[u]+w){
	d[v]=d[u]+w;
	q.push(P(d[v],v));
	//cout<<v<<":"<<d[v]<<endl;
      }
    }
  }
  
  for(int i=0;i<n;i++) cout<<i<<" "<<d[i]<<endl;
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<utility>

#define INF 9999999999

using namespace std;

const int MAX_N = 100000;

int d[MAX_N];

struct edge{
	int to;   //?????????
	int cost; //?????????
};

typedef pair<int,int>P;

void dijkstra(int s,int n)
{
	int k,l,p,q,r,u,v,cost,m;
	vector<edge> edgelist[n];
	for(int i=0;i<n;i++){
		scanf("%d",&u);
		scanf("%d",&m);
		for(int j=0;j<m;j++){
			edge e;
			scanf("%d",&v);
			scanf("%d",&cost);
			e.to = v;	e.cost = cost;
			edgelist[i].push_back(e);
		}
	}
	priority_queue<P,vector<P>,greater<P> > que;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		vector<edge>::iterator it = edgelist[v].begin();
		while(it != edgelist[v].end()){
			if(d[it->to] > d[v] + it->cost){
				d[it->to] = d[v] + it->cost;
				que.push(P(d[it->to],it->to));
			}
			it++;
		}
	}
}

int main()
{
	int k,l,m,n,s;
	scanf("%d",&n); // ?????°?????\???
	fill(d,d+n,INF);
	dijkstra(0,n);
	for(int i=0;i<n;i++){
		printf("%d %d\n",i,d[i]);
	}
}