docs: def random_weighted_choice(choices):
      """
      Return a random key of choices, weighted by their value.
  
      :param choices: a dictionary of keys and positive integer pairs;
      :return: a random key of choices.
      """
      choices, weights = zip(*choices.items())
      cumdist = list(accumulate(weights))
      x = random.random() * cumdist[-1]
      element = bisect.bisect(cumdist, x)
      return choices[element]