Buggy python submission (verdict: Runtime Error):
from math import sqrt
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense

def calc_dist(p1,p2):
    return max(0, sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) - (p1[2]+p2[2]))

xs, ys, xg, yg = map(int, input().split())
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
p = [[xs,ys,0], [xg,yg,0]] + p
n += 2
edges = [[float("inf")]*n for i in range(n)]
for i in range(n):
    for j in range(i,n):
        edges[i][j] = edges[j][i] = calc_dist(p[i], p[j])
edges = csgraph_from_dense(edges, null_value=float("inf"))
dist = dijkstra(edges, directed=False, indices=0)
print(dist[1])

Fixed submission:
from math import sqrt
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
# https://atcoder.jp/users/nadare881

def calc_dist(p1,p2):
    return max(0, sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) - (p1[2]+p2[2]))

xs, ys, xg, yg = map(int, input().split())
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
p = [[xs,ys,0], [xg,yg,0]] + p
n += 2
edges = [[float("inf")]*n for i in range(n)]
for i in range(n):
    for j in range(i,n):
        if i == j :continue
        edges[i][j] = edges[j][i] = calc_dist(p[i], p[j])
edges = csgraph_from_dense(edges, null_value=float("inf"))
dist = dijkstra(edges, directed=False, indices=0)
print(dist[1])

Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt
import heapq

class Dijkstra(object):
    def __init__(self, n):
        self.visited = {}
        self.edges = [{} for i in range(n)]
        self.cnt = 0
        self.n = n

    def add_edge(self, s, t, w, directed=True):
        self.edges[s][t] = w
        if not directed:
            self.edges[t][s] = w

    def solve(self, start):
        que = []
        heapq.heappush(que, (0,start, start))

        while que:
            if self.cnt == self.n:
                break
            w, s, prev = heapq.heappop(que)
            if s in self.visited:continue
            self.visited[s] = w
            self.cnt += 1
            for edge in self.edges[s]:
                if edge not in self.visited:
                    heapq.heappush(que, (w+self.edges[s][edge], edge, s))
        return self.visited

def calc_dist(p1,p2):
    return max(0, sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) - (p1[2]+p2[2]))

xs, ys, xg, yg = map(int, input().split())
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
p = [[xs,ys,0], [xg,yg,0]] + p
n += 2

D = Dijkstra(n)
for i in range(n):
    for j in range(i,n):
        D.add_edge(i,j, calc_dist(p[i],p[j]), directed=False)
ans = D.solve(0)[1]
print(ans)

Fixed submission:
from math import sqrt
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
# https://atcoder.jp/users/nadare881

def calc_dist(p1,p2):
    return max(0, sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) - (p1[2]+p2[2]))

xs, ys, xg, yg = map(int, input().split())
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
p = [[xs,ys,0], [xg,yg,0]] + p
n += 2
edges = [[float("inf")]*n for i in range(n)]
for i in range(n):
    for j in range(i,n):
        if i == j :continue
        edges[i][j] = edges[j][i] = calc_dist(p[i], p[j])
edges = csgraph_from_dense(edges, null_value=float("inf"))
dist = dijkstra(edges, directed=False, indices=0)
print(dist[1])