#include <bits/stdc++.h>
#define Longgggg ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define endl '\n'
using namespace std;
// Bitwise
#define MASK(i) (1LL << (i))
#define BIT(x, i) (1LL & ((x) >> (i)))
#define ON(x, i) ((x) | MASK(i))
#define OFF(x, i) ((x) & ~MASK(i))
#define LASTBIT(mask) ((mask) & -(mask))
// Other
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define mod(x, k) ((((x) % (k)) + (k)) % (k))
#define all(x) begin(x), end(x)
#define fi first
#define se second
#define IN "A.in"
#define OUT "A.out"
#define DEBUG "debug.out"
const int INF = (int) 1e9+5;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) 1e9+7;
const int mxN = 200005;
int n, m, S, T, U, V;
vector <pair <ll, ll>> adj[mxN];
vector <ll> d(mxN), par(mxN);
set <pair <ll, ll>> path;
void dijkstra(int s, int t) {
    fill(all(d), LINF);
    fill(all(par), -1);
    priority_queue <pair <ll, ll>, vector <pair <ll, ll>>, greater<>> q;
    q.push({0, s});
    d[s] = 0;
    par[s] = s;
    while (!q.empty()) {
        ll u = q.top().se, dis = q.top().fi;
        q.pop();
        if (dis > d[u]) continue;
        for (auto &x : adj[u]) {
            ll v = x.fi, w = x.se;
            if (path.count({min(u, v), max(u, v)})) w = 0;
            if (d[v] > d[u] + w) {
                d[v] = d[u] + w;
                par[v] = u;
                q.push({d[v], v});
            }
        }
    }
}
void solve() {
    cin >> n >> m >> S >> T >> U >> V;
    FOR(i, 1, m) {
        int u, v, w; cin >> u >> v >> w;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
    dijkstra(S, T);
    ll st = T;
    while (st != S) {
        path.insert({min(par[st], st), max(par[st], st)});
        st = par[st];
    }
    dijkstra(U, V);
    cout << d[V] << endl;
}
signed main() {
    if (fopen(IN, "r")) {
        freopen(IN, "r", stdin);
        freopen(OUT, "w", stdout);
        freopen(DEBUG, "w", stderr);
    }
    Longgggg
    ll t = 1; 
    // cin >> t;
    while (t--) solve();
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         freopen(IN, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~
commuter_pass.cpp:83:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |         freopen(OUT, "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~
commuter_pass.cpp:84:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         freopen(DEBUG, "w", stderr);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |