Buggy python submission (verdict: Runtime Error):
  points = [[False for i in range(5001)] for j in range(5001)]
  ps = []

  for i in range(n):
    x, y = map(int,input().split())
    points[x][y] = True
    ps.append((x,y))

  ans = 0

  for i in range(n):
    for j in range(n):
      p1 = ps[i]
      p2 = ps[j]
      vx = p2[0] - p1[0]
      vy = p2[1] - p1[1]
      p3 = p1[0] + vy, p1[1] - vx
      if points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]:
        ans = max(ans, vx ** 2 + vy ** 2)

  print(ans)






Fixed submission:
def main():
  while True:
    n = int(input())
    if not n:
      break
    ps = [tuple(map(int,input().split())) for i in range(n)]
    dic = set()
    for t in ps:
      dic.add(t)
    ans = 0
  
    for i in range(n):
      p1 = ps[i]
      p1x = p1[0]
      p1y = p1[1]
      for j in range(n):
        p2 = ps[j]
        p2x = p2[0]
        p2y = p2[1]
        vx = p2x - p1x
        vy = p2y - p1y
        if (p1x + vy , p1y - vx) in dic and (p2x + vy , p2y - vx) in dic:
          ans = max(ans, vx ** 2 + vy ** 2)
    

    print(ans)
main()

Buggy python submission (verdict: Runtime Error):
def main():
  while True:
    n = int(input())
    if not n:
      break
    points = [[False for i in range(5001)] for j in range(5001)]
    ps = []
  
    for i in range(n):
      x, y = map(int,input().split())
      points[x][y] = True
      ps.append((x,y))
  
    ans = 0
  
    for i in range(n):
      for j in range(n):
        p1 = ps[i]
        p2 = ps[j]
        vx = p2[0] - p1[0]
        vy = p2[1] - p1[1]
        if  0 <= p1[0] + vy <= 5000 and 0 <= p1[1] - vx <= 5000 and 0 <= p2[0] + vy <= 5000 and 0 <= p2[1] - vx <= 5000:
          if  points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]:
            ans = max(ans, vx ** 2 + vy ** 2)
  
    print(ans)
main()  





Fixed submission:
def main():
  while True:
    n = int(input())
    if not n:
      break
    ps = [tuple(map(int,input().split())) for i in range(n)]
    dic = set()
    for t in ps:
      dic.add(t)
    ans = 0
  
    for i in range(n):
      p1 = ps[i]
      p1x = p1[0]
      p1y = p1[1]
      for j in range(n):
        p2 = ps[j]
        p2x = p2[0]
        p2y = p2[1]
        vx = p2x - p1x
        vy = p2y - p1y
        if (p1x + vy , p1y - vx) in dic and (p2x + vy , p2y - vx) in dic:
          ans = max(ans, vx ** 2 + vy ** 2)
    

    print(ans)
main()

Buggy python submission (verdict: Runtime Error):
def main():
  while True:
    n = int(input())
    if not n:
      break
    points = [[False for i in range(5001)] for j in range(5001)]
    ps = []
  
    for i in range(n):
      x, y = map(int,input().split())
      points[x][y] = True
      ps.append((x,y))
  
    ans = 0
  
    for i in range(n):
      for j in range(n):
        p1 = ps[i]
        p2 = ps[j]
        vx = p2[0] - p1[0]
        vy = p2[1] - p1[1]
        if  0 <= p1[0] + vy <= 5000 and 0 <= p1[1] - vx <= 5000 and 0 <= p2[0] + vy <= 5000 and 0 <= p2[1] - vx <= 5000:
          if  points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]:
            ans = max(ans, vx ** 2 + vy ** 2)
  
    print(ans)
main()  





Fixed submission:
def main():
  while True:
    n = int(input())
    if not n:
      break
    ps = [tuple(map(int,input().split())) for i in range(n)]
    dic = set()
    for t in ps:
      dic.add(t)
    ans = 0
  
    for i in range(n):
      p1 = ps[i]
      p1x = p1[0]
      p1y = p1[1]
      for j in range(n):
        p2 = ps[j]
        p2x = p2[0]
        p2y = p2[1]
        vx = p2x - p1x
        vy = p2y - p1y
        if (p1x + vy , p1y - vx) in dic and (p2x + vy , p2y - vx) in dic:
          ans = max(ans, vx ** 2 + vy ** 2)
    

    print(ans)
main()

Buggy python submission (verdict: Runtime Error):
def main():
  while True:
    n = int(input())
    if not n:
      break
    points = [[False for i in range(5001)] for j in range(5001)]
    ps = []
  
    for i in range(n):
      x, y = map(int,input().split())
      points[x][y] = True
      ps.append((x,y))
  
    ans = 0
  
    for i in range(n):
      for j in range(n):
        p1 = ps[i]
        p2 = ps[j]
        vx = p2[0] - p1[0]
        vy = p2[1] - p1[1]
        if  0 <= p1[0] + vy <= 5000 and 0 <= p1[1] - vx <= 5000 and 0 <= p2[0] + vy <= 5000 and 0 <= p2[1] - vx <= 5000:
          if  points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]:
            ans = max(ans, vx ** 2 + vy ** 2)
  
    print(ans)
main()  





Fixed submission:
def main():
  while True:
    n = int(input())
    if not n:
      break
    ps = [tuple(map(int,input().split())) for i in range(n)]
    dic = set()
    for t in ps:
      dic.add(t)
    ans = 0
  
    for i in range(n):
      p1 = ps[i]
      p1x = p1[0]
      p1y = p1[1]
      for j in range(n):
        p2 = ps[j]
        p2x = p2[0]
        p2y = p2[1]
        vx = p2x - p1x
        vy = p2y - p1y
        if (p1x + vy , p1y - vx) in dic and (p2x + vy , p2y - vx) in dic:
          ans = max(ans, vx ** 2 + vy ** 2)
    

    print(ans)
main()

Buggy python submission (verdict: Runtime Error):
def main():
  points = [[False for i in range(5001)] for j in range(5001)]
  while True:
    n = int(input())
    if not n:
      break
    ps = []

    for i in range(n):
      x, y = map(int,input().split())
      points[x][y] = True
      ps.append((x,y))
  
    ans = 0
  
    for i in range(n):
      for j in range(n):
        p1 = ps[i]
        p2 = ps[j]
        vx = p2[0] - p1[0]
        vy = p2[1] - p1[1]
        if  0 <= p1[0] + vy <= 5000 and 0 <= p1[1] - vx <= 5000 and 0 <= p2[0] + vy <= 5000 and 0 <= p2[1] - vx <= 5000:
          if  points[p1[0] + vy][p1[1] - vx] and points[p2[0] + vy][p2[1] - vx]:
            ans = max(ans, vx ** 2 + vy ** 2)
    
    for p in ps:
      points[p[0]][p[1]] = False

    print(ans)
main()  





Fixed submission:
def main():
  while True:
    n = int(input())
    if not n:
      break
    ps = [tuple(map(int,input().split())) for i in range(n)]
    dic = set()
    for t in ps:
      dic.add(t)
    ans = 0
  
    for i in range(n):
      p1 = ps[i]
      p1x = p1[0]
      p1y = p1[1]
      for j in range(n):
        p2 = ps[j]
        p2x = p2[0]
        p2y = p2[1]
        vx = p2x - p1x
        vy = p2y - p1y
        if (p1x + vy , p1y - vx) in dic and (p2x + vy , p2y - vx) in dic:
          ans = max(ans, vx ** 2 + vy ** 2)
    

    print(ans)
main()