#K62677. Transform String to Palindrome

    ID: 31585 Type: Default 1000ms 256MiB

Transform String to Palindrome

Transform String to Palindrome

Given a string s, determine whether it can be rearranged (or transformed by the allowed operations) to form a palindrome. A palindrome is a string that reads the same forward and backward. The necessary and sufficient condition for such a transformation is that at most one character in the string appears an odd number of times. In mathematical terms, if we let \( f(c) \) be the frequency of character \( c \) in the string, then the string can be rearranged into a palindrome if and only if

[ \sum_{c \in \text{alphabet}} \mathbf{1}_{{f(c) ;%; 2 \neq 0}} \leq 1, ]

where \( \mathbf{1}_{\{\cdot\}} \) is the indicator function.

inputFormat

The input consists of a single line containing the string s. The string may contain any printable characters, and it can be empty. The input is read from standard input (stdin).

outputFormat

Output a single line to standard output (stdout) containing "YES" if it is possible to rearrange the string into a palindrome, and "NO" otherwise.

## sample
ababa
YES