code: def rectangles_from_points(S):
      
      answ = 0
      pairs = {}
      for j in range(len(S)):
          for i in range(j):
              px, py = S[i]
              qx, qy = S[j]
              center = (px + qx, py + qy)
              dist = (px - qx) ** 2 + (py - qy) ** 2
              sign = (center, dist)
              if sign in pairs:
                  answ += len(pairs[sign])
                  pairs[sign].append((i, j))
              else:
                  pairs[sign] = [(i, j)]
      return answ
docs: How many rectangles can be formed from a set of points
  
      :param S: list of points, as coordinate pairs
      :returns: the number of rectangles
      :complexity: :math:`O(n^2)`