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 <vector>
#define rep(i,N) for(int i = 0; i<(int)(N); i++)
#define REP(i,k,N) for(int i = k; i<(int)(N); i++)
#define INF 100000000
typedef long long ll;
using namespace std;

int main(){
        int n;
        cin >> n;
        vector< vector<int> > G(n, vector<int>(n,INF));
        int u,k,v,c;
        rep(i,n){
                cin >> u >>k;
                rep(j,k){
                        cin >> v >> c;
                        G[u][v] = c;
                }
        }

        vector<ll> d(n, INF * n);
        d[0]=0;
        bool update = true;
        while(update) {
                update  = false;
                rep(from,n) {
                        if(d[from] >= INF * n) continue;

                        rep(to,n){
                                if(from == to) continue;

                                if(d[to] > d[from] + G[from][to]) {
                                        update = true;
                                        d[to] = d[from] + G[from][to];
                                }

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

        return 0;
}

C++: //B//
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
 
int main()
{
	int n;
	scanf("%d",&n);
	int data[105][105]={0};
	int vis[105][105]={0};
	int dis[105]={0};
	int tag[105]={0};
	int i,j,k;
	for(i=0;i<n;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		for(j=0;j<y;j++)
		{
			int a,b;
			scanf("%d %d",&a,&b);
			data[x][a]=b;
			vis[x][a]=1;
		}
	}
	int mina=-1; 
	tag[0]=1;
	for(i=1;i<n;i++)
	{
		if(vis[0][i]==1&&tag[i]==0)
		{
			dis[i]=data[0][i];
			if(mina==-1) mina=data[0][i];				
			else if(data[0][mina]>data[0][i]) mina=i;
		}	
	}
	for(j=1;j<n;j++)
	{
		for(i=1;i<n;i++)
		{
			if(vis[mina][i]==1&&tag[i]==0)
			{
				if(dis[i]==0)
				{
					dis[i]=dis[mina]+data[mina][i];
				}
				else
				{
					dis[i]=min(dis[i],dis[mina]+data[mina][i]);
				}
				
			}	
		}
		mina=-1;
		for(i=1;i<n;i++)
		{
			if(tag[i]==0)
			{
				if(mina==-1) mina=i;				
				else if(dis[mina]>dis[i]) mina=i;
			}	
		}
		tag[mina]=1;
	}	
	
	printf("0 0\n");
	for(k=1;k<n;k++)
	{
		printf("%d %d\n",k,dis[k]);
	}
	
	 
	return 0;
}

C++: #include <iostream>
#include <cstring> 
#include <algorithm> 
#include <vector> 
#define INF 2000000000 //??¨?????????????????¢????¶??????????????????????????????§????????°???????????¨????????????????????????
             
#define MAX_V 100
     using namespace std;
     int v,u,c,k,vertex;//number of vertices
     int d[MAX_V];
     int ver[100]={};
     int path[100][100]={};
     int path_exist[100][100];
     int min_index;
     bool used[MAX_V];
     int num_used=0,l;
     vector<int> q;
     void dijkstra(int s)
     {
             fill(d,d+v,INF);
             memset(used,false,sizeof(used));//(s,val,end)?????¢?????§s??????end?????§?????¢???????¢???????false??§?????????
             d[s]=0;
             while(q.size()-num_used != 0){
             		while(used[l]==true){
             			l++;
             		}
             		min_index=l;
                     for(int j=0;j<q.size();j++){
                     	if(!used[j]){//???????????¢????????????????¨??????????????????????????????¶
                     		if(d[min_index] > d[j]/*??´??????*/)
                     		min_index=q.at(j);
                     	}
                     }
                        used[min_index]=true;
                        num_used+=1;
                        for(int j=0;j<ver[min_index];j++){//min_index????????°????????????????????????edge????????¨??????????????????????????°
			  d[path_exist[min_index][j]]=min(d[path_exist[min_index][j]], d[min_index] + path[min_index][path_exist[min_index][j]]);/*??´??????*/
                        } 
            }
            return;
    }
    int main(){
        cin>>v;

        for(int i=0; i<v;i++){
        	cin>>u;
        	cin>>k;
        	ver[u]=k;
        	q.push_back(i);
        	for(int j=0;j< k ; j++){
        		cin>>vertex;
        		cin>>c;
        		path[u][vertex]= c;
        		path_exist[u][j]=vertex;

        	}
        }

        dijkstra(0);
        for(int i=0;i<v;i++){
        	cout<<i<<" "<<d[i]<<endl;
        }
        return 0;
    }