#C11047. Valid Palindrome Checker

    ID: 40320 Type: Default 1000ms 256MiB

Valid Palindrome Checker

Valid Palindrome Checker

In this problem, you are given a string S which may contain alphanumeric characters, spaces, and punctuation. Your task is to determine whether the string is a valid palindrome. A valid palindrome is defined as a string which, after removing all non-alphanumeric characters and converting all letters to lowercase, reads the same forwards and backwards. Mathematically, if we define the transformation ( T(s) ) as follows:

[ T(s) = \text{lowercase}({ c \in s \mid c \text{ is alphanumeric} }) ]

Then S is a palindrome if and only if

[ T(s) = T(s)^{rev} ]

where ( T(s)^{rev} ) is the reverse of ( T(s) ). This challenge is fundamental for understanding string manipulation and is commonly tested in programming competitions.

inputFormat

The input is read from standard input (stdin) as a single string S. The string can contain spaces, punctuation, and both uppercase and lowercase letters.

outputFormat

Output to standard output (stdout) a single string: 'YES' if the input string is a valid palindrome according to the conditions described, and 'NO' otherwise.## sample

A man, a plan, a canal: Panama
YES