import re


def CamelToSnakeCase(input_string):
  """Converts camelCase to snake_case."""

  # Prepend every uppercase character with an underscore
  # e.g. camelCase -> camel_Case
  with_underscores = re.sub(r'([A-Z])', r'_\1', input_string)

  # Ensure a name starting with an uppercase letter does not have an underscore
  # e.g. CamelCase -> _Camel_Case -> Camel_Case
  without_leading_underscore = with_underscores.lstrip('_')

  # Convert all characters to lowercase
  # e.g. camel_Case -> camel_case
  return without_leading_underscore.lower()