input: def kmeans(k: int, data: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
      """
      Perform k-means clustering on data.
      
      >>> kmeans(2, np.array([[1, 1], [2, 2], [10, 10], [11, 11]]))
      (array([0, 0, 1, 1]), array([[ 1.5,  1.5], [10.5, 10.5]]))
      >>> kmeans(3, np.array([[1, 1], [2, 2], [5, 5], [10, 10], [11, 11], [15, 15]]))
      (array([0, 0, 0, 1, 1, 2]), array([[ 2.66666667,  2.66666667], [10.5, 10.5], [15., 15.]]))
      """
output:     n = data.shape[0]
      centroids = data[np.random.choice(n, k, replace=False)]
      labels = np.zeros(n)
      
      while True:
          old_centroids = np.copy(centroids)
          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