Language: C++

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cout << #x << " = " << x << endl;
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    solve();
    return 0;
}

const double eps = 1e-5;
const int MAXN = 1e5 + 10;
const double INF = 1e20 + 10;
int n;
vec<vec<int>> cycl;
int xs, ys, xf, yf;
vec<pair<double, int>> g[MAXN];

double get_dist(vec<int> &a, vec<int> &b) {
    int x1 = a[0], y1 = a[1], r1 = a[2];
    int x2 = b[0], y2 = b[1], r2 = b[2];
    if ((r1 + r2) * (r1 + r2) >= (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) {
        return 0.;
    }
    else {
        return max(0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2));
    }
}

void solve() {
    cin >> xs >> ys >> xf >> yf;
    cin >> n;
    cycl.resize(n, vec<int>(3));
    for (int i = 0; i < n; ++i) {
        cin >> cycl[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            double wt = get_dist(cycl[i], cycl[j]);
            g[i].pb({wt, j});
            g[j].pb({wt, i});
        }
    }
    for (int i = 0; i < n; ++i) {
        vec<int> tmp = {xs, ys, 0};
        double wt = get_dist(tmp, cycl[i]);
        g[n].pb({wt, i});
        g[i].pb({wt, n});
    }
    for (int i = 0; i < n; ++i) {
        vec<int> tmp = {xf, yf, 0};
        double wt = get_dist(tmp, cycl[i]);
        g[n + 1].pb({wt, i});
        g[i].pb({wt, n + 1});
    }

    vec<double> dist(MAXN, INF);
    dist[n] = 0.;
    set<pair<double, int>> se;
    se.insert({0., n});
    while (!se.empty()) {
        auto it = *se.begin();
        se.erase(se.begin());
        for (auto nxt : g[it.y]) {
            if (dist[nxt.y] > dist[it.y] + nxt.x) {
                se.erase({dist[nxt.y], nxt.y});
                dist[nxt.y] = dist[it.y] + nxt.x;
                se.insert({dist[nxt.y], nxt.y});
            }
        }
    }

    cout << dist[n + 1] << endl;
}

Compiler output:
a.cc: In function 'long double get_dist(std::vector<long long int>&, std::vector<long long int>&)':
a.cc:70:19: error: no matching function for call to 'max(double, long double)'
   70 |         return max(0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:70:19: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   70 |         return max(0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:70:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   70 |         return max(0., sqrtl((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - (double)(r1 + r2));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~