import re


def camel_to_snake(s):
  """Convert `CamelCase` to the `snake_case`.

  Credits:
  * https://stackoverflow.com/users/1522117
  * https://stackoverflow.com/users/3423324/luckydonald

  References:
  * https://stackoverflow.com/a/12867228
  """
  a = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)(?<!_)[A-Z](?=[a-z]))')
  return a.sub(r'_\1', s).lower()