Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

////////////////////////////
// 基本要素 (点, 線分, 円)
////////////////////////////

using DD = double;
const DD INF = 1LL<<60;      // to be set appropriately
const DD EPS = 1e-10;        // to be set appropriately
const DD PI = acos(-1.0);
DD torad(int deg) {return (DD)(deg) * PI / 180;}
DD todeg(DD ang) {return ang * 180 / PI;}

/* Point */
struct Point {
    DD x, y;
    Point(DD x = 0.0, DD y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};
inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
inline Point conj(const Point &p) {return Point(p.x, -p.y);}
inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
inline DD dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
inline DD norm(const Point &p) {return dot(p, p);}
inline DD abs(const Point &p) {return sqrt(dot(p, p));}
inline DD amp(const Point &p) {DD res = atan2(p.y, p.x); if (res < 0) res += PI*2; return res;}
inline bool eq(const Point &p, const Point &q) {return abs(p - q) < EPS;}
inline bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x < q.x : p.y < q.y);}
inline bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > EPS ? p.x > q.x : p.y > q.y);}
inline Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}

/* Line */
struct Line : vector<Point> {
    Line(Point a = Point(0.0, 0.0), Point b = Point(0.0, 0.0)) {
        this->push_back(a);
        this->push_back(b);
    }
    friend ostream& operator << (ostream &s, const Line &l) {return s << '{' << l[0] << ", " << l[1] << '}';}
};

/* Circle */
struct Circle : Point {
    DD r;
    Circle(Point p = Point(0.0, 0.0), DD r = 0.0) : Point(p), r(r) {}
    friend ostream& operator << (ostream &s, const Circle &c) {return s << '(' << c.x << ", " << c.y << ", " << c.r << ')';}
};

int n;
Point sp, tp;
vector<Circle> c;
double dist[1010][1010];
double d[1010];
bool seen[1010];

//Dijkstra法　は　隣接リスト　で　O(V^2) ,PriorityQueue で O(ElogV)
//密グラフなら隣接リストでok

void solve() {
	cin >> sp.x >> sp.y >> tp.x >> tp.y;
    cin >> n;
    c.resize(n);
    rep(i, n) {
        cin >> c[i].x >> c[i].y >> c[i].r;
    }
    int s = n, t = n + 1;
    rep(i, n) {
        double ds = abs(c[i] - sp);
        dist[i][s] = dist[s][i] = max(0.0, ds - c[i].r);
        double dt = abs(c[i] - tp);
        dist[i][t] = dist[t][i] = max(0.0, dt - c[i].r);
    }
    rep(i, n) {
        rep(j, n) {
            double di = abs(c[i] - c[j]);
            dist[i][j] = dist[j][i] = max(0.0, di - c[i].r - c[j].r);
        }
    }

    rep(i, n + 2) {
        d[i] = INF;
        seen[i] = false;
    }
    d[s] = 0;
    while(true) {
        int v = -1;
        rep(u, n + 2) {
            if(!seen[u] && (v == -1 || d[u] < d[v])) v = u;
        }
        if(v == -1) break;
        seen[v] = true;
        rep(u, n + 2) {
            chmin(d[u], d[v] + dist[v][u]);
        }
    }
    cout << d[t] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc:58:10: error: conflicting declaration 'const DD INF'
   58 | const DD INF = 1LL<<60;      // to be set appropriately
      |          ^~~
a.cc:29:10: note: previous declaration as 'const ll INF'
   29 | const ll INF=1LL<<60 ;
      |          ^~~
a.cc:65:8: error: using typedef-name 'Point' after 'struct'
   65 | struct Point {
      |        ^~~~~
a.cc:37:21: note: 'Point' has a previous declaration here
   37 | typedef complex<ld> Point;
      |                     ^~~~~
a.cc: In function 'Point operator+(const Point&, const Point&)':
a.cc:70:74: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   70 | inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
      |                                                                          ^
a.cc:70:80: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   70 | inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
      |                                                                                ^
a.cc:70:85: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   70 | inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
      |                                                                                     ^
a.cc:70:91: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   70 | inline Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
      |                                                                                           ^
a.cc: In function 'Point operator-(const Point&, const Point&)':
a.cc:71:74: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   71 | inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
      |                                                                          ^
a.cc:71:80: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   71 | inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
      |                                                                                ^
a.cc:71:85: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   71 | inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
      |                                                                                     ^
a.cc:71:91: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   71 | inline Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
      |                                                                                           ^
a.cc: In function 'Point operator*(const Point&, DD)':
a.cc:72:64: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   72 | inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
      |                                                                ^
a.cc:72:73: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   72 | inline Point operator * (const Point &p, DD a) {return Point(p.x * a, p.y * a);}
      |                                                                         ^
a.cc: In function 'Point operator*(DD, const Point&)':
a.cc:73:68: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   73 | inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
      |                                                                    ^
a.cc:73:77: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   73 | inline Point operator * (DD a, const Point &p) {return Point(a * p.x, a * p.y);}
      |                                                                             ^
a.cc: In function 'Point operator*(const Point&, const Point&)':
a.cc:74:74: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
      |                                                                          ^
a.cc:74:80: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
      |                                                                                ^
a.cc:74:86: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
      |                                                                                      ^
a.cc:74:92: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
      |                                                                                            ^
a.cc:74:97: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
      |                                                                                                 ^
a.cc:74:103: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
      |                                                                                                       ^
a.cc:74:109: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
      |                                                                                                             ^
a.cc:74:115: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   74 | inline Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
      |                                                                                                                   ^
a.cc: In function 'Point operator/(const Point&, DD)':
a.cc:75:64: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   75 | inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
      |                                                                ^
a.cc:75:73: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   75 | inline Point operator / (const Point &p, DD a) {return Point(p.x / a, p.y / a);}
      |                                                                         ^
a.cc: In function 'Point conj(const Point&)':
a.cc:76:51: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   76 | inline Point conj(const Point &p) {return Point(p.x, -p.y);}
      |                                                   ^
a.cc:76:57: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   76 | inline Point conj(const Point &p) {return Point(p.x, -p.y);}
      |                                                         ^
a.cc: In function 'Point rot(const Point&, DD)':
a.cc:77:69: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   77 | inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
      |                                                                     ^
a.cc:77:86: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   77 | inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
      |                                                                                      ^
a.cc:77:102: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   77 | inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
      |                                                                                                      ^
a.cc:77:119: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   77 | inline Point rot(const Point &p, DD ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
      |                                                                                                                       ^
a.cc: In function 'Point rot90(const Point&)':
a.cc:78:53: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'y'
   78 | inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
      |                                                     ^
a.cc:78:58: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   78 | inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
      |                                                          ^
a.cc: In function 'DD cross(const Point&, const Point&)':
a.cc:79:59: error: 'const Point' {aka 'const class std::complex<long double>'} has no member named 'x'
   79 | inline DD cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
      |