import re
def convert(name):
return re.sub(r'([A-Z]*)([A-Z][a-z]+)', lambda x: (x.group(1) + '_' if x.group(1) else '') + x.group(2) + '_', name).rstrip('_').lower()
print convert('CamelCase')
print convert('HTTP')
print convert('HTTPRequest')
print convert('SecureHTTPRequest')
print convert('SecureHTTP')
aW1wb3J0IHJlCgpkZWYgY29udmVydChuYW1lKToKICAgIHJldHVybiByZS5zdWIocicoW0EtWl0qKShbQS1aXVthLXpdKyknLCBsYW1iZGEgeDogKHguZ3JvdXAoMSkgKyAnXycgaWYgeC5ncm91cCgxKSBlbHNlICcnKSArIHguZ3JvdXAoMikgKyAnXycsIG5hbWUpLnJzdHJpcCgnXycpLmxvd2VyKCkKCnByaW50IGNvbnZlcnQoJ0NhbWVsQ2FzZScpICAgIApwcmludCBjb252ZXJ0KCdIVFRQJykKcHJpbnQgY29udmVydCgnSFRUUFJlcXVlc3QnKQpwcmludCBjb252ZXJ0KCdTZWN1cmVIVFRQUmVxdWVzdCcpCnByaW50IGNvbnZlcnQoJ1NlY3VyZUhUVFAnKQo=