from math import sqrt def dist(p,q): return sqrt((p[0]-q[0])**2+(p[1]-q[1])**2) class A: def __init__(self,d,x): self.d=d self.x=x def __le__(self,other): return self.d<=other.d def __lt__(self,other): return self.dc+dist(Pos[p],Pos[q]): T[q]=c+dist(Pos[p],Pos[q]) heappush(Q,A(c+dist(Pos[p],Pos[q]),q)) print(T[Y])