input: def kmeans(k: int, data: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
      """
      Perform k-means clustering on data
      >>> kmeans(2, np.array([[1, 2], [2, 3], [8, 8], [9, 9]]))
      (array([0., 0., 1., 1.]), array([[1.5, 2.5], [8.5, 8.5]]))
      >>> kmeans(3, np.array([[1, 2], [2, 3], [8, 8], [9, 9], [5, 6], [6, 7]]))
      """
output:     n = data.shape[0]
      centroids = data[np.random.choice(n, k, replace=False)]
      labels = np.zeros(n)
      while True:
          old_centroids = centroids.copy()
          distances = np.linalg.norm(data[:, np.newaxis] - centroids, axis=2)
          labels = np.argmin(distances, axis=1)
          for i in range(k):
              centroids[i] = np.mean(data[labels == i], axis=0)
          if np.all(old_centroids == centroids):
              break
      return labels, centroids