stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <vector>

#include <queue>

#include <functional>



using namespace std;

typedef pair<int, int> P;

static const int INF = 1e9;

static const int SIZE = 100001;

struct edge

{

	int to;

	int cost;

};



vector<edge> G[SIZE];

int d[SIZE];



void solve()

{

	int V, E, start;

	cin >> V >> E >> start;

	for (int i = 0; i < E; ++i)

	{

		int from, to, cost;

		scanf("%d %d %d", &from, &to, &cost);

//		cin >> from >> to >> cost;

		edge e;

		e.to = to;

		e.cost = cost;

		G[from].push_back(e);

	}

	for (int i = 0; i < SIZE; ++i)

	{

		d[i] = INF;

	}

	d[start] = 0;

	priority_queue<P, vector<P>, greater<P> > pque;

	pque.push(P(0, start));

	while (!pque.empty())

	{

		P p = pque.top();

		pque.pop();

		int v = p.second;

		for (int i = 0; i < G[v].size(); ++i)

		{

			edge e = G[v][i];

			if (d[e.to] > d[v] + e.cost)

			{

				d[e.to] = d[v] + e.cost;

				pque.push(P(d[e.to], e.to));

			}

		}

	}

	for (int i = 0; i < V; ++i)

	{

		if (d[i] == INF)

		{

			cout << "INF" << endl;

		}

		else

		{

			cout << d[i] << endl;

		}

	}

}



int main()

{

	solve();

	return(0);

}

// Faster C++ solution for the same problem (measured speedup: 1.1137013309628414x):
#include <iostream>

#include <cstdio>

#include <string>

#include <vector>

#include <algorithm>

#include <set>

#include <map>

#include <queue>

#include <cmath>



using namespace std;

typedef pair<int, int> P;

typedef pair<P, int> PI;

static const long long int INF = 1e18;



class Edge

{

public:

	int to;

	int cost;

};

vector<Edge> edge[100001];



void solve()

{

	int V, E, r;

	cin >> V >> E >> r;

	for (int i = 0; i < E; ++i)

	{

		int s, t, d;

		scanf("%d %d %d", &s, &t, &d);

		Edge e;

		e.to = t;

		e.cost = d;

		edge[s].push_back(e);

	}

	vector<long long int> D(V);

	for (int i = 0; i < V; ++i)

	{

		D[i] = INF;

	}

	D[r] = 0;

	priority_queue<P, vector<P>, greater<P> > pque;

	pque.push(P(0, r));

	while (!pque.empty())

	{

		P p = pque.top();

		pque.pop();

		int v = p.second;

		if (D[v] < p.first)

		{

			continue;

		}

		for (int i = 0; i < edge[v].size(); ++i)

		{

			Edge e = edge[v][i];

			if (D[e.to] > D[v] + e.cost)

			{

				D[e.to] = D[v] + e.cost;

				pque.push(P(D[e.to], e.to));

			}

		}

	}

	for (int i = 0; i < V; ++i)

	{

		if (D[i] == INF)

		{

			cout << "INF" << endl;

		}

		else

		{

			cout << D[i] << endl;

		}

	}

}



int main()

{

	solve();

	return(0);

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <queue>

#include <algorithm>

#include <functional>

using namespace std;



#define MAX_V 100001

const long long INF = 1LL<<60;



static int V, E, r;

static vector<pair<int, long long> > graph[MAX_V];

static long long dist[MAX_V];



int main() {

  cin >> V >> E >> r;

  for (int i = 0; i < E; ++i) {

    int s, t; long long w;

    cin >> s >> t >> w;

    graph[s].push_back(make_pair(t, w));

  }



  priority_queue<pair<long long,int>, vector<pair<long long,int> >, greater<pair<long long, int> > > que;



  for (int i = 0; i < MAX_V; ++i) dist[i] = INF;

  dist[r] = 0;

  que.push(make_pair(0, r));



  while (!que.empty()) {

    long long curDist = que.top().first;

    int curVertex = que.top().second;

    que.pop();



    if (dist[curVertex] < curDist) continue;



    for (int i = 0; i < graph[curVertex].size(); ++i) {

      int toVertex = graph[curVertex][i].first;

      long long toDist = curDist + graph[curVertex][i].second;



      if (dist[toVertex] > toDist) {

	dist[toVertex] = toDist;

	que.push(make_pair(toDist, toVertex));

      }

    }

  }



  for (int i = 0; i < V; ++i) {

    if (dist[i] < INF) cout << dist[i] << endl;

    else cout << "INF" << endl;

  }

}


// Faster C++ solution for the same problem (measured speedup: 4.332195008796224x):
#include <iostream>

#include <vector>

#include <queue>

using namespace std;



// 無限大を表す値

const long long INF = 1LL<<60;



// 辺を表す型，ここでは重みを表す型を long long 型とします

struct Edge {

    int to; // 隣接頂点番号

    long long w; // 重み

    Edge(int to, long long w) : to(to), w(w) {}

};



// 重み付きグラフを表す型，各頂点の隣接リストを辺集合で表す

typedef vector<vector<Edge> > Graph;



// 緩和処理 (更新が行われたときは true を返し，行われないときは false を返す)

bool chmin(long long& a, long long b) {

    if (a > b) {

        a = b;

        return true;

    }

    else return false;

}



int main() {

    // 頂点数と辺数，始点

    int N, M, s; cin >> N >> M >> s;



    // グラフ

    Graph G(N);

    for (int i = 0; i < M; ++i) {

        int a, b, w;

        cin >> a >> b >> w;

        G[a].push_back(Edge(b, w));

    }



    // Dijkstra 法

    vector<long long> dist(N, INF);

    dist[s] = 0;



    // (d[v], v) のペアを要素としたヒープを作ります

    priority_queue<pair<long long, int>,

                   vector<pair<long long, int> >,

                   greater<pair<long long, int> > > que;

    que.push(make_pair(dist[s], s));



    // Dijkstra 法の反復を開始

    while (!que.empty()) {

        // v: 使用済みでない頂点のうち d[v] が最小の頂点

        // d: v に対するキー値

        int v = que.top().second;

        long long d = que.top().first;

        que.pop();



        // d > dist[v] は，(d, v) がゴミであることを意味する

        if (d > dist[v]) continue; 



        // 頂点 v を始点とした辺たちを緩和

        for (auto e : G[v]) {

            if (chmin(dist[e.to], dist[v] + e.w)) {

                // 更新があるならヒープに新たに追加

                que.push(make_pair(dist[e.to], e.to)); 

            }

        }

    }

    

    // 結果出力

    for (int v = 0; v < N; ++v) {

        if (dist[v] < INF) cout << dist[v] << endl;

        else cout << "INF" << endl;

    }

}
// Slower C++ solution:
#include "bits/stdc++.h"

#include <cassert>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

#define all(a)  (a).begin(),(a).end()

#define vi vector<int>

#define pb push_back

#define INF 999999999

//#define INF (1LL<<59)



#define MAX_V 100000



struct edge{int to,cost;};

vector<edge> G[MAX_V];

int d[MAX_V];



void dijkstra(int s){

    priority_queue< pii,vector<pii>,greater<pii> > que;

    rep(i,MAX_V)d[i]=INF;

    d[s]=0;

    que.push(pii(0,s));

    

    while(que.size()){

        pii p=que.top();

        que.pop();

        

        int v=p.second;

        if(d[v]<p.first)continue;

        

        rep(i,G[v].size()){

            edge e=G[v][i];

            if(d[e.to]>d[v]+e.cost){

                d[e.to]=d[v]+e.cost;

                que.push(pii(d[e.to],e.to));

            }

        }

    }

}







int main(){

    int v,e,s;

    cin>>v>>e>>s;

    rep(i,e){

        int a,b,c;

        cin>>a>>b>>c;

        G[a].pb(edge{b,c});

    }

    

    dijkstra(s);

    

    rep(i,v){

        if(d[i]==INF)cout<<"INF"<<endl;

        else cout<<d[i]<<endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 1.1131170229244371x):
#include "bits/stdc++.h"

#include <cassert>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

#define all(a)  (a).begin(),(a).end()

#define vi vector<int>

#define pb push_back

#define INF 999999999

//#define INF (1LL<<59)



//verified AOJ GRL_1

#define MAX_V 100000

struct edge{int to,cost;};

vector<edge> G[MAX_V];



void dijkstra(int s, vector<int> &d){

    priority_queue< pii,vector<pii>,greater<pii> > que;

    rep(i,d.size())d[i]=INF;

    d[s]=0;

    que.push(pii(0,s));

    

    while(que.size()){

        pii p=que.top();

        que.pop();

        

        int v=p.second;

        if(d[v]<p.first)continue;

        

        rep(i,G[v].size()){

            edge e=G[v][i];

            if(d[e.to]>d[v]+e.cost){

                d[e.to]=d[v]+e.cost;

                que.push(pii(d[e.to],e.to));

            }

        }

    }

}





int main(){

    int v,e,s;

    cin>>v>>e>>s;

    rep(i,e){

        int a,b,c;

        cin>>a>>b>>c;

        G[a].pb(edge{b,c});

    }

    

    vi d(v);

    dijkstra(s,d);

    

    rep(i,v){

        if(d[i]==INF)cout<<"INF"<<endl;

        else cout<<d[i]<<endl;

    }

}
// Slower C++ solution:
#include "bits/stdc++.h"

#include <cassert>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

#define all(a)  (a).begin(),(a).end()

#define vi vector<int>

#define pb push_back

#define INF 999999999

//#define INF (1LL<<59)



#define MAX_V 100000



struct edge{int to,cost;};

vector<edge> G[MAX_V];

int d[MAX_V];



void dijkstra(int s){

    priority_queue< pii,vector<pii>,greater<pii> > que;

    rep(i,MAX_V)d[i]=INF;

    d[s]=0;

    que.push(pii(0,s));

    

    while(que.size()){

        pii p=que.top();

        que.pop();

        

        int v=p.second;

        if(d[v]<p.first)continue;

        

        rep(i,G[v].size()){

            edge e=G[v][i];

            if(d[e.to]>d[v]+e.cost){

                d[e.to]=d[v]+e.cost;

                que.push(pii(d[e.to],e.to));

            }

        }

    }

}







int main(){

    int v,e,s;

    cin>>v>>e>>s;

    rep(i,e){

        int a,b,c;

        cin>>a>>b>>c;

        G[a].pb(edge{b,c});

    }

    

    dijkstra(s);

    

    rep(i,v){

        if(d[i]==INF)cout<<"INF"<<endl;

        else cout<<d[i]<<endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 1.1131170229244371x):
#include "bits/stdc++.h"

#include <cassert>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

#define all(a)  (a).begin(),(a).end()

#define vi vector<int>

#define pb push_back

#define INF 999999999

//#define INF (1LL<<59)



//verified AOJ GRL_1

#define MAX_V 100000

struct edge{int to,cost;};

vector<edge> G[MAX_V];



void dijkstra(int s, vector<int> &d){

    priority_queue< pii,vector<pii>,greater<pii> > que;

    rep( i,d.size() )d[i]=INF;

    d[s] = 0;

    que.push( pii(0,s) );

    

    while( que.size() ){

        pii p=que.top();

        que.pop();

        

        int v=p.second;

        if(d[v]<p.first)continue;

        

        rep(i,G[v].size()){

            edge e=G[v][i];

            if(d[e.to]>d[v]+e.cost){

                d[e.to]=d[v]+e.cost;

                que.push(pii(d[e.to],e.to));

            }

        }

    }

}





int main(){

    int v,e,s;

    cin>>v>>e>>s;

    rep(i,e){

        int a,b,c;

        cin>>a>>b>>c;

        G[a].pb(edge{b,c});

    }

    

    vi d(v);

    dijkstra(s,d);

    

    rep(i,v){

        if(d[i]==INF)cout<<"INF"<<endl;

        else cout<<d[i]<<endl;

    }

}
// Slower C++ solution:
#include "bits/stdc++.h"

#include <cassert>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

#define all(a)  (a).begin(),(a).end()

#define vi vector<int>

#define pb push_back

#define INF 999999999

//#define INF (1LL<<59)



#define MAX_V 100000



struct edge{int to,cost;};

vector<edge> G[MAX_V];

int d[MAX_V];



void dijkstra(int s){

    priority_queue< pii,vector<pii>,greater<pii> > que;

    rep(i,MAX_V)d[i]=INF;

    d[s]=0;

    que.push(pii(0,s));

    

    while(que.size()){

        pii p=que.top();

        que.pop();

        

        int v=p.second;

        if(d[v]<p.first)continue;

        

        rep(i,G[v].size()){

            edge e=G[v][i];

            if(d[e.to]>d[v]+e.cost){

                d[e.to]=d[v]+e.cost;

                que.push(pii(d[e.to],e.to));

            }

        }

    }

}







int main(){

    int v,e,s;

    cin>>v>>e>>s;

    rep(i,e){

        int a,b,c;

        cin>>a>>b>>c;

        G[a].pb(edge{b,c});

    }

    

    dijkstra(s);

    

    rep(i,v){

        if(d[i]==INF)cout<<"INF"<<endl;

        else cout<<d[i]<<endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 1.1131170229244371x):
#include "bits/stdc++.h"

#include <cassert>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

#define all(a)  (a).begin(),(a).end()

#define vi vector<int>

#define pb push_back

#define INF 999999999

//#define INF (1LL<<59)

 

//verified AOJ GRL_1

#define MAX_V 100000

struct edge{int to,cost;};

vector<edge> G[MAX_V];

 

void dijkstra(int s, vector<int> &d){

    priority_queue< pii,vector<pii>,greater<pii> > que;

    rep( i,d.size() )d[i]=INF;

    d[s] = 0;

    que.push( pii(0,s) );

     

    while( que.size() ){

        pii p=que.top();

        que.pop();

         

        int v=p.second;

        if(d[v]<p.first)continue;

         

        rep(i,G[v].size()){

            edge e=G[v][i];

            if(d[e.to]>d[v]+e.cost){

                d[e.to]=d[v]+e.cost;

                que.push(pii(d[e.to],e.to));

            }

        }

    }

}

 

 

int main(){

    int v,e,s;

    cin>>v>>e>>s;

    rep(i,e){

        int a,b,c;

        cin>>a>>b>>c;

        G[a].pb(edge{b,c});

    }

     

    vi d(v);

    dijkstra(s,d);

     

    rep(i,v){

        if(d[i]==INF)cout<<"INF"<<endl;

        else cout<<d[i]<<endl;

    }

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <sstream>

#include <algorithm>

#include <vector>

#include <utility>

#include <functional>

#include <stack>

#include <queue>

#include <map>

#include <set>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#include <deque>

#include <ctime>



using namespace std;

  

#define rep(i,n) REP(i,0,n)

#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)

#define pb push_back

#define mp make_pair

#define all(r) (r).begin(),(r).end()

#define rall(r) (r).rbegin(),(r).rend()

#define fi first

#define se second



typedef long long ll;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

 

const ll LINF = 1e18;

const ll MOD = 86400;

double EPS = 1e-8;

const double PI = acos(-1);



struct Edge{

	int to;

	ll cost;

};



ll d[100100];

vector<Edge> es[100100];



int main(){

	int v, e, s;

	cin>>v>>e>>s;

	rep(i, e){

		int a, b, c;

		cin>>a>>b>>c;

		es[a].pb({b,c});

	}

	rep(i, 100100) d[i] = 1e18;

	auto dijkstra =[&]{

		typedef pair<ll, int> P;

		priority_queue<P, vector<P>, greater<P> > q;

		P p;

		q.push({0LL, s});

		d[s] = 0LL;

		while(!q.empty()){

			p = q.top();

			q.pop();

			int from = p.se;

			ll c = p.fi;

			for(auto & e : es[from]){

				int to = e.to;

				ll cost = c + e.cost;

				if(cost < d[to]){

					d[to] = cost;

					q.push({cost, to});

				}

			}

		}

	};

	dijkstra();

	rep(i, v) {

		if(d[i] == 1e18) cout<<"INF"<<endl;

		else cout<<d[i]<<endl;

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.2384199032936172x):
#include <bits/stdc++.h>



using namespace std;

  

#define rep(i,n) REP(i,0,n)

#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)

#define pb push_back

#define all(r) (r).begin(),(r).end()

#define rall(r) (r).rbegin(),(r).rend()

#define fi first

#define se second



typedef long long ll;

typedef vector<int> vi;

typedef vector<ll> vl;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

 

const ll LINF = 1e18;

const ll MOD = 86400;

const int INF = 1e9;

double EPS = 1e-8;



struct Edge

{

	int to;

	ll cost;

};



ll d[100010];

vector<Edge> es[100010];



int E, V;



int main(){

	int start;

	cin>>V>>E>>start;

	rep(i, E){

		int s, t, d;

		cin>>s>>t>>d;

		es[s].pb({t, d});

	}

	

	auto dijkstra = [&]{

		typedef pair<ll, int> P;

		priority_queue<P, vector<P>, greater<P> > q;

		P p;

		rep(i, V) d[i] = 1e18;

		q.push({0, start});

		d[start] = 0;

		while(!q.empty()){

			p = q.top();

			int from = p.se;

			ll cost = p.fi;

			q.pop();

			if(d[from] < cost) continue;

			for(auto&e :es[from]){

				int to = e.to;

				ll newCost = cost + e.cost;

				if(d[to] > newCost){

					d[to] = newCost;

					q.push({newCost, to});

				}

			}

		}

	};

	dijkstra();

	for(int i = 0; i < V; i++){

		if(d[i] == 1e18) cout<<"INF"<<endl;

		else cout<<d[i]<<endl;

	}

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#define MIN(a, b) ((a < b) ? a : b)

#define INF 1000000001

#define N 100000



using namespace std;



struct edge {

  int source;

  int target;

  int weight;

};



vector<edge> edges;



int distances[N];

int prev_distances[N] = {0};







int main() {

  int V, E, r;



  cin >> V >> E >> r;



  for (int i = 0; i < E; i++) {

    int source, target, distance;

    cin >> source >> target >> distance;

    edge new_edge = { source, target, distance};

    edges.push_back(new_edge);

    

  }



  //initialize distances array

 

  for (int i = 0; i < N; i++) {

    distances[i] = INF ; //max value

  }



  distances[r] = 0;



 

  for (int i = 1; i < V; i++) {

    for (int j=0; j< V; j++) {

      prev_distances[j] = distances[j];  

    }

    

    for (vector<edge>::iterator edgeptr = edges.begin(); edgeptr != edges.end(); edgeptr++) {

      distances[edgeptr->target] = MIN(distances[edgeptr->source] + edgeptr->weight, distances[edgeptr->target]);

    

    }



    bool same = true;

    for (int j=0; j< V; j++) {

      if (distances[j] != prev_distances[j]) {

	same = false;

	break;

      }

    }



    if (same) break;

  }



  for (int i = 0; i < V; i++) {

    if (distances[i] == INF) {

      cout << "INF" << endl;

    } else {

      cout << distances[i] << endl;

    }

  }

}

  



    

// Faster C++ solution for the same problem (measured speedup: 1.3927278403358652x):
#include <iostream>

#include <limits>

#include <queue>

#include <vector>



using namespace std;



struct Edge {

    int source, target, distance;

};



struct Node {

    int vertex, weight;

    bool operator > (const Node& node) const {

        return weight > node.weight;

    }

};





int main()

{

    int n_vertices, n_edges, source_node;

    cin >> n_vertices >> n_edges >> source_node;

    vector< vector<Edge> > adjlist(n_vertices);



    for (int i = 0; i < n_edges; ++i) {

        int source, target, distance;

        cin >> source >> target >> distance;

        adjlist[source].emplace_back(Edge{source, target, distance});

    }



    vector<int> closed(n_vertices, numeric_limits<int>::max());

    priority_queue<Node, vector<Node>, greater<Node> > open;



    open.push(Node{source_node, 0});

    while (!open.empty()) {

        auto node = open.top();

        open.pop();

        if (closed[node.vertex] != numeric_limits<int>::max()) continue;

        for (auto edge : adjlist[node.vertex]) {

            int child = edge.target;

            int distance = edge.distance;

            open.push(Node{child, node.weight + distance});

        }

        closed[node.vertex] = node.weight;

    }



    for (auto weight : closed) {

        if (weight == numeric_limits<int>::max()) {

            cout << "INF";

        } else {

            cout << weight;

        }

        cout << endl;

    }

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#define MIN(a, b) ((a < b) ? a : b)

#define INF 1000000001

#define N 100000



using namespace std;



struct edge {

  int source;

  int target;

  int weight;

};



vector<edge> edges;



int distances[N];

int prev_distances[N] = {0};







int main() {

  int V, E, r;



  cin >> V >> E >> r;



  for (int i = 0; i < E; i++) {

    int source, target, distance;

    cin >> source >> target >> distance;

    edge new_edge = { source, target, distance};

    edges.push_back(new_edge);

    

  }



  //initialize distances array

 

  for (int i = 0; i < N; i++) {

    distances[i] = INF ; //max value

  }



  distances[r] = 0;



 

  for (int i = 1; i < V; i++) {

    for (int j=0; j< V; j++) {

      prev_distances[j] = distances[j];  

    }

    

    for (vector<edge>::iterator edgeptr = edges.begin(); edgeptr != edges.end(); edgeptr++) {

      distances[edgeptr->target] = MIN(distances[edgeptr->source] + edgeptr->weight, distances[edgeptr->target]);

    

    }



    bool same = true;

    for (int j=0; j< V; j++) {

      if (distances[j] != prev_distances[j]) {

	same = false;

	break;

      }

    }



    if (same) break;

  }



  for (int i = 0; i < V; i++) {

    if (distances[i] == INF) {

      cout << "INF" << endl;

    } else {

      cout << distances[i] << endl;

    }

  }

}

  



    

// Faster C++ solution for the same problem (measured speedup: 1.3926467908856668x):
#include <iostream>

#include <limits>

#include <queue>

#include <vector>



using namespace std;



struct Edge {

    int source, target, distance;

};



struct Node {

    int vertex, weight;

    bool operator > (const Node& node) const {

        return weight > node.weight;

    }

};





int main()

{

    int n_vertices, n_edges, source_node;

    cin >> n_vertices >> n_edges >> source_node;

    vector< vector<Edge> > adjlist(n_vertices);



    for (int i = 0; i < n_edges; ++i) {

        int source, target, distance;

        cin >> source >> target >> distance;

        adjlist[source].emplace_back(Edge{source, target, distance});

    }



    int visited = 0;

    vector<int> closed(n_vertices, numeric_limits<int>::max());

    priority_queue<Node, vector<Node>, greater<Node> > open;



    open.push(Node{source_node, 0});

    while (visited != n_vertices && !open.empty()) {

        auto node = open.top();

        open.pop();

        if (closed[node.vertex] != numeric_limits<int>::max()) continue;

        for (auto edge : adjlist[node.vertex]) {

            int child = edge.target;

            int distance = edge.distance;

            open.push(Node{child, node.weight + distance});

        }

        closed[node.vertex] = node.weight;

        visited++;

    }



    for (auto weight : closed) {

        if (weight == numeric_limits<int>::max()) {

            cout << "INF";

        } else {

            cout << weight;

        }

        cout << endl;

    }

}