#C853. String Modification Based on Specific Rules

    ID: 52522 Type: Default 1000ms 256MiB

String Modification Based on Specific Rules

String Modification Based on Specific Rules

Given a string s, modify it according to the following rules:

  • If s contains only alphabetic characters (a–z, A–Z), reverse the string and swap the case of each letter. For example, if s = "abcXYZ", then the output should be "zyxCBA".
  • If s contains only digits (0–9), compute the sum of all digits and output the sum as a string. For example, if s = "12345", the output is "15".
  • If s contains a mix of alphabetic characters and digits (and no other characters), replace each alphabetic character with its position in the alphabet (i.e. a/A = 1, b/B = 2, …, z/Z = 26) while keeping the digits unchanged. For instance, if s = "a1b2c3" or s = "A1B2C3", the output should be "112233". This rule can be represented in \( \LaTeX \) as: \( \text{position}(ch) = \text{ord}(\text{tolower}(ch)) - \text{ord}('a') + 1 \).
  • If s is an empty string, output "Empty String".
  • For any other cases (for example, when s contains special characters), output "Invalid Input".

The program will read input from standard input (stdin) and write the result to standard output (stdout).

inputFormat

The input consists of a single line containing the string s. Note that s may be empty.

outputFormat

Output a single line representing the modified string according to the specified rules.

## sample
abcXYZ
zyxCBA