



"""simple docstring"""






import numpy as np


def 							A__ (     UpperCamelCase__       ,							UpperCamelCase__       ,							UpperCamelCase__    ):


  '''simple docstring'''


  _SCREAMING_SNAKE_CASE        =			n_draws * class_counts / class_counts.sum()
  # floored means we don't overshoot n_samples, but probably undershoot
  _SCREAMING_SNAKE_CASE        =			np.floor(UpperCamelCase__    )
  # we add samples according to how much "left over" probability
  # they had, until we arrive at n_samples
  _SCREAMING_SNAKE_CASE        =			int(n_draws - floored.sum()    )
  if need_to_add > 0:
    _SCREAMING_SNAKE_CASE        =			continuous - floored
    _SCREAMING_SNAKE_CASE        =			np.sort(np.unique(UpperCamelCase__    )    )[::-1]
    # add according to remainder, but break ties
    # randomly to avoid biases
    for value in values:
      ((_SCREAMING_SNAKE_CASE)    ,     )        =			np.where(remainder == value    )
      # if we need_to_add less than what's in inds
      # we draw randomly from them.
      # if we need to add more, we add them all and
      # go to the next value
      _SCREAMING_SNAKE_CASE        =			min(len(UpperCamelCase__    )       ,							UpperCamelCase__    )
      _SCREAMING_SNAKE_CASE        =			rng.choice(UpperCamelCase__       ,							size=UpperCamelCase__       ,							replace=UpperCamelCase__    )
      floored[inds] += 1
      need_to_add -= add_now
      if need_to_add == 0:
        break
  return floored.astype(np.intaa    )







def 							A__ (     UpperCamelCase__       ,							UpperCamelCase__       ,							UpperCamelCase__       ,							UpperCamelCase__       ,							UpperCamelCase__=10    ):


  '''simple docstring'''


  _SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE        =			np.unique(UpperCamelCase__       ,							return_inverse=UpperCamelCase__    )
  _SCREAMING_SNAKE_CASE        =			classes.shape[0]
  _SCREAMING_SNAKE_CASE        =			np.bincount(UpperCamelCase__    )
  if np.min(UpperCamelCase__    ) < 2:
    raise ValueError('''Minimum class count error'''    )
  if n_train < n_classes:
    raise ValueError(
        '''The train_size = %d should be greater or ''' '''equal to the number of classes = %d''' % (n_train, n_classes)    )
  if n_test < n_classes:
    raise ValueError(
        '''The test_size = %d should be greater or ''' '''equal to the number of classes = %d''' % (n_test, n_classes)    )
  _SCREAMING_SNAKE_CASE        =			np.split(np.argsort(UpperCamelCase__       ,							kind='''mergesort'''    )       ,							np.cumsum(UpperCamelCase__    )[:-1]    )
  for _ in range(UpperCamelCase__    ):
    _SCREAMING_SNAKE_CASE        =			approximate_mode(UpperCamelCase__       ,							UpperCamelCase__       ,							UpperCamelCase__    )
    _SCREAMING_SNAKE_CASE        =			class_counts - n_i
    _SCREAMING_SNAKE_CASE        =			approximate_mode(UpperCamelCase__       ,							UpperCamelCase__       ,							UpperCamelCase__    )

    _SCREAMING_SNAKE_CASE        =			[]
    _SCREAMING_SNAKE_CASE        =			[]

    for i in range(UpperCamelCase__    ):
      _SCREAMING_SNAKE_CASE        =			rng.permutation(class_counts[i]    )
      _SCREAMING_SNAKE_CASE        =			class_indices[i].take(UpperCamelCase__       ,							mode='''clip'''    )
      train.extend(perm_indices_class_i[: n_i[i]]    )
      test.extend(perm_indices_class_i[n_i[i] : n_i[i] + t_i[i]]    )
    _SCREAMING_SNAKE_CASE        =			rng.permutation(UpperCamelCase__    )
    _SCREAMING_SNAKE_CASE        =			rng.permutation(UpperCamelCase__    )

    yield train, test





"""simple docstring"""






from math import gcd


def 							A__ (     UpperCamelCase__ = 12_000    ):


  '''simple docstring'''


  _SCREAMING_SNAKE_CASE        =			0
  for d in range(max_d + 1    ):
    for n in range(d // 3 + 1       ,							(d + 1) // 2    ):
      if gcd(UpperCamelCase__       ,							UpperCamelCase__    ) == 1:
        fractions_number += 1
  return fractions_number


if __name__ == "__main__":
    print(F'''{solution() = }''')
