import re


def camel_to_snake( s, separator='_' ):
    """
    Converts camel to snake case

    >>> camel_to_snake('CamelCase')
    'camel_case'

    >>> camel_to_snake('Camel_Case')
    'camel_case'

    >>> camel_to_snake('camelCase')
    'camel_case'

    >>> camel_to_snake('USA')
    'usa'

    >>> camel_to_snake('TeamUSA')
    'team_usa'

    >>> camel_to_snake('Team_USA')
    'team_usa'

    >>> camel_to_snake('R2D2')
    'r2_d2'

    >>> camel_to_snake('ToilPre310Box',separator='-')
    'toil-pre-310-box'

    >>> camel_to_snake('Toil310Box',separator='-')
    'toil-310-box'
    """
    s = re.sub( '([a-z0-9])([A-Z])', r'\1%s\2' % separator, s )
    s = re.sub( '([a-z])([A-Z0-9])', r'\1%s\2' % separator, s )
    return s.lower( )