#C3144. Rearrange to Palindrome

    ID: 46539 Type: Default 1000ms 256MiB

Rearrange to Palindrome

Rearrange to Palindrome

You are given a string S consisting of lowercase English letters. Your task is to determine whether it is possible to rearrange the characters of S to form a palindrome.

A palindrome is a string that reads the same forwards and backwards. The necessary and sufficient condition for a string to be rearranged into a palindrome is that at most one character appears an odd number of times. In mathematical terms, if we denote by freq(c) the frequency of character c in S, then the condition is:

$$\sum_{c \in \text{alphabet}} \left( freq(c) \bmod 2 \right) \le 1$$

If the condition is satisfied, output YES; otherwise, output NO.

inputFormat

The input is read from standard input. It consists of a single line containing the string S.

Constraints:

  • 1 \leq |S| \leq 10^5
  • S contains only lowercase English letters.

outputFormat

Output a single line to standard output: YES if the characters of S can be rearranged to form a palindrome, or NO otherwise.

## sample
aabb
YES