Buggy python submission (verdict: Runtime Error):
xs,ys,xt,yt=map(int,input().split())
N=int(input())
import numpy as np
XYR=np.empty((N+2,3),dtype=np.float64)
XYR[1:-1,:]=np.array([input().split() for i in range(N)])
XYR[0,:]=[xs,ys,0]
XYR[-1,:]=[xt,yt,0]
X,Y,R=XYR.T
c=np.maximum(0,np.sqrt(np.square(X[None,:]-X[:,None])+np.square(Y[None,:]-Y[:,None]))-R[None,:]-R[:,None])
from scipy.sparse import*
g=csgraph.csgraph_from_dense(c,null_value=np.inf)
print(csgraph.dijkstra(g,directed=0,indices=0)[-1])

Fixed submission:
xs,ys,xt,yt=map(int,input().split())
N=int(input())
import numpy as np
XYR=np.empty((N+2,3),dtype=np.float64)
XYR[1:-1,:]=np.array([input().split() for i in range(N)])
XYR[0,:]=xs,ys,0
XYR[-1,:]=xt,yt,0
X,Y,R=XYR.T
c=np.maximum(0,np.sqrt(np.square(X[None,:]-X[:,None])+np.square(Y[None,:]-Y[:,None]))-R[None,:]-R[:,None])
c[range(N+2),range(N+2)]=-1
from scipy.sparse import*
g=csgraph.csgraph_from_dense(c,null_value=-1)
print(csgraph.dijkstra(g,indices=0)[-1])

Buggy python submission (verdict: Time Limit Exceeded):
xs,ys,xt,yt=map(int,input().split())
N=int(input())
XYR=[[xs,ys,0]]+[list(map(int,input().split())) for i in range(N)]+[[xt,yt,0]]
inf=10**20
c=[[max(0,((XYR[i][0]-XYR[j][0])**2+(XYR[i][1]-XYR[j][1])**2)**.5-XYR[i][2]-XYR[j][2]) for j in range(N+2)] for i in range(N+2)]
from heapq import heappop,heappush
def dij(c,N,s):
    d=[inf]*N
    d[s]=0
    q=[]
    heappush(q,(0,s))
    while q:
        i=heappop(q)[1]
        for j,w in enumerate(c[i]):
            temp=d[i]+w
            if d[j]>temp:
                d[j]=temp
                heappush(q,(d[j],j))
    return d
print(dij(c,N+2,0)[-1])

Fixed submission:
xs,ys,xt,yt=map(int,input().split())
N=int(input())
import numpy as np
XYR=np.empty((N+2,3),dtype=np.float64)
XYR[1:-1,:]=np.array([input().split() for i in range(N)])
XYR[0,:]=xs,ys,0
XYR[-1,:]=xt,yt,0
X,Y,R=XYR.T
c=np.maximum(0,np.sqrt(np.square(X[None,:]-X[:,None])+np.square(Y[None,:]-Y[:,None]))-R[None,:]-R[:,None])
c[range(N+2),range(N+2)]=-1
from scipy.sparse import*
g=csgraph.csgraph_from_dense(c,null_value=-1)
print(csgraph.dijkstra(g,indices=0)[-1])

Buggy python submission (verdict: Time Limit Exceeded):
xs,ys,xt,yt=map(int,input().split())
N=int(input())
XYR=[[xs,ys,0]]+[list(map(int,input().split())) for i in range(N)]+[[xt,yt,0]]
c=[[None]*(N+2) for i in range(N+2)]
for i in range(N+2):
    for j in range(N+2):
        c[i][j]=max(1e-12,((XYR[i][0]-XYR[j][0])**2+(XYR[i][1]-XYR[j][1])**2)**.5-XYR[i][2]-XYR[j][2])
from scipy.sparse import*
g=csr_matrix(c)
print("%.12f"%csgraph.dijkstra(g,directed=0,indices=0)[-1])

Fixed submission:
xs,ys,xt,yt=map(int,input().split())
N=int(input())
import numpy as np
XYR=np.empty((N+2,3),dtype=np.float64)
XYR[1:-1,:]=np.array([input().split() for i in range(N)])
XYR[0,:]=xs,ys,0
XYR[-1,:]=xt,yt,0
X,Y,R=XYR.T
c=np.maximum(0,np.sqrt(np.square(X[None,:]-X[:,None])+np.square(Y[None,:]-Y[:,None]))-R[None,:]-R[:,None])
c[range(N+2),range(N+2)]=-1
from scipy.sparse import*
g=csgraph.csgraph_from_dense(c,null_value=-1)
print(csgraph.dijkstra(g,indices=0)[-1])

Buggy python submission (verdict: Time Limit Exceeded):
xs,ys,xt,yt=map(int,input().split())
N=int(input())
XYR=[[xs,ys,0]]+[list(map(int,input().split())) for i in range(N)]+[[xt,yt,0]]
inf=10**20
c=[[None]*(N+2) for i in range(N+2)]
for i in range(N+2):
    for j in range(N+2):
        c[i][j]=max(0,((XYR[i][0]-XYR[j][0])**2+(XYR[i][1]-XYR[j][1])**2)**.5-XYR[i][2]-XYR[j][2])
from heapq import heappop,heappush
def dij(c,N,s):
    d=[inf]*N
    d[s]=0
    q=[]
    heappush(q,(0,s))
    while q:
        i=heappop(q)[1]
        for j,w in enumerate(c[i]):
            temp=d[i]+w
            if d[j]>temp:
                d[j]=temp
                heappush(q,(d[j],j))
    return d
print(dij(c,N+2,0)[-1])

Fixed submission:
xs,ys,xt,yt=map(int,input().split())
N=int(input())
import numpy as np
XYR=np.empty((N+2,3),dtype=np.float64)
XYR[1:-1,:]=np.array([input().split() for i in range(N)])
XYR[0,:]=xs,ys,0
XYR[-1,:]=xt,yt,0
X,Y,R=XYR.T
c=np.maximum(0,np.sqrt(np.square(X[None,:]-X[:,None])+np.square(Y[None,:]-Y[:,None]))-R[None,:]-R[:,None])
c[range(N+2),range(N+2)]=-1
from scipy.sparse import*
g=csgraph.csgraph_from_dense(c,null_value=-1)
print(csgraph.dijkstra(g,indices=0)[-1])