#K63302. CamelCase and SnakeCase Conversion

    ID: 31723 Type: Default 1000ms 256MiB

CamelCase and SnakeCase Conversion

CamelCase and SnakeCase Conversion

You are given a string in one of two formats: CamelCase or snake_case. Depending on the conversion type specified, your task is to convert the input string from CamelCase to snake_case or from snake_case to CamelCase.

The program will first read an integer mode from standard input. If mode is 1, the input string (given on the next line) will be in CamelCase and needs to be converted to snake_case. If mode is 2, the input string will be in snake_case and must be converted to CamelCase.

For example, using the formulas below:

  • CamelCase to snake_case: \( s = \text{camel_to_snake}(S) \)
  • snake_case to CamelCase: \( S = \text{snake_to_camel}(s) \)

Ensure that your solution reads from stdin and writes to stdout.

inputFormat

The first line of input contains an integer mode (1 or 2). The second line contains the string to convert.

Mode 1: Convert a CamelCase string to snake_case.

Mode 2: Convert a snake_case string to CamelCase.

outputFormat

Output the converted string on a single line.

## sample
1
camelCaseString
camel_case_string