input: from typing import List
  
  def gini(x: List[int]) -> float:
      """Calculate the Gini coefficient of a given dataset.
  
      >>> gini([2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 21])
      0.605
      """
      import numpy as np
      unique_values, value_counts = np.unique(x, return_counts=True)
      x_value_counts = value_counts
      x_cum_sum = np.cumsum(x_value_counts)
      n = len(x)
      lorenz = x_cum_sum / n
      lorenz = np.insert(lorenz, 0, 0)
      width = lorenz[1:] - lorenz[:-1]
      gini_coef = (1 / n) * np.sum(width * (lorenz[1:] + lorenz[:-1]))
      return gini_coef
output:     import numpy as np
      unique_values, value_counts = np.unique(x, return_counts=True)
      x_value_counts = value_counts
      x_cum_sum = np.cumsum(x_value_counts)
      n = len(x)
      lorenz = x_cum_sum / n
      lorenz = np.insert(lorenz, 0, 0)
      width = lorenz[1:] - lorenz[:-1]
      gini_coef = (1 / n) * np.sum(width * (lorenz[1:] + lorenz[:-1]))
      return gini_coef