Language: C++

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<ll, int> lli;
struct edge { int v; ll w; };

vector<edge> G[100];
ll d1[100], d2[100];

void dijkstra(int n, vector<edge> G[], int s, ll d[]) {
	fill(d, d + n, LONG_MAX); d[s] = 0;
	priority_queue<lli, vector<lli>, greater<lli> > q;
	q.push(lli(0, s));
	while (!q.empty()) {
		lli p = q.top(); q.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (int j = 0; j < G[u].size(); j++) {
			edge e = G[u][j];
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				q.push(lli(d[e.v], e.v));
			}
		}
	}
}

int main() {
	for (;;) {
		int n, m; scanf("%d%d", &n, &m);
		if (n == 0) break;
		for (int u = 0; u < n; u++) G[u].clear();
		for (; m > 0; m--) {
			int a, b, c; scanf("%d%d%d", &a, &b, &c);
			edge e1 = {b - 1, c}; G[a - 1].push_back(e1);
			edge e2 = {a - 1, c}; G[b - 1].push_back(e2);
		}
		dijkstra(n, G, 0, d1);
		dijkstra(n, G, n - 1, d2);
		ll ans = LONG_MAX;
		for (int u = 0; u < n; u++)
			for (int i = 0; i < G[u].size(); i++)
				for (int j = 0; j < G[u].size(); j++) {
					ll v1 = G[u][i].v, v2 = G[u][j].v;
					if (d1[v1] == LONG_MAX || d2[v2] == LONG_MAX) continue;
					ans = min(ans, d1[v1] + d2[v2]);
				}
		printf("%d\n", ans);
	}
}
#include <climits>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<ll, int> lli;
struct edge { int v; ll w; };

vector<edge> G[100];
ll d1[100], d2[100];

void dijkstra(int n, vector<edge> G[], int s, ll d[]) {
	fill(d, d + n, LONG_MAX); d[s] = 0;
	priority_queue<lli, vector<lli>, greater<lli>> q;
	q.push(lli(0, s));
	while (!q.empty()) {
		lli p = q.top(); q.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (int j = 0; j < G[u].size(); j++) {
			edge e = G[u][j];
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				q.push(lli(d[e.v], e.v));
			}
		}
	}
}

int main() {
	for (;;) {
		int n, m; scanf("%d%d", &n, &m);
		if (n == 0) break;
		for (int u = 0; u < n; u++) G[u].clear();
		for (; m > 0; m--) {
			int a, b, c; scanf("%d%d%d", &a, &b, &c);
			edge e1 = {b - 1, c}; G[a - 1].push_back(e1);
			edge e2 = {a - 1, c}; G[b - 1].push_back(e2);
		}
		dijkstra(n, G, 0, d1);
		dijkstra(n, G, n - 1, d2);
		ll ans = LONG_MAX;
		for (int u = 0; u < n; u++)
			for (int i = 0; i < G[u].size(); i++)
				for (int j = 0; j < G[u].size(); j++) {
					ll v1 = G[u][i].v, v2 = G[u][j].v;
					if (d1[v1] == LONG_MAX || d2[v2] == LONG_MAX) continue;
					ans = min(ans, d1[v1] + d2[v2]);
				}
		printf("%d\n", ans);
	}
}

Compiler output:
a.cc:5:19: warning: extra tokens at end of #include directive
    5 | #include <cstring>#include <algorithm>
      |                   ^
a.cc:72:8: error: redefinition of 'struct edge'
   72 | struct edge { int v; ll w; };
      |        ^~~~
a.cc:18:8: note: previous definition of 'struct edge'
   18 | struct edge { int v; ll w; };
      |        ^~~~
a.cc:74:14: error: redefinition of 'std::vector<edge> G [100]'
   74 | vector<edge> G[100];
      |              ^
a.cc:20:14: note: 'std::vector<edge> G [100]' previously declared here
   20 | vector<edge> G[100];
      |              ^
a.cc:75:4: error: redefinition of 'll d1 [100]'
   75 | ll d1[100], d2[100];
      |    ^~
a.cc:21:4: note: 'll d1 [100]' previously declared here
   21 | ll d1[100], d2[100];
      |    ^~
a.cc:75:13: error: redefinition of 'll d2 [100]'
   75 | ll d1[100], d2[100];
      |             ^~
a.cc:21:13: note: 'll d2 [100]' previously declared here
   21 | ll d1[100], d2[100];
      |             ^~
a.cc:77:6: error: redefinition of 'void dijkstra(int, std::vector<edge>*, int, ll*)'
   77 | void dijkstra(int n, vector<edge> G[], int s, ll d[]) {
      |      ^~~~~~~~
a.cc:23:6: note: 'void dijkstra(int, std::vector<edge>*, int, ll*)' previously defined here
   23 | void dijkstra(int n, vector<edge> G[], int s, ll d[]) {
      |      ^~~~~~~~
a.cc:95:5: error: redefinition of 'int main()'
   95 | int main() {
      |     ^~~~
a.cc:41:5: note: 'int main()' previously defined here
   41 | int main() {
      |     ^~~~