#C11122. Rearrange String to Avoid Adjacent Repetitions

    ID: 40404 Type: Default 1000ms 256MiB

Rearrange String to Avoid Adjacent Repetitions

Rearrange String to Avoid Adjacent Repetitions

Given a string S consisting of lowercase letters, determine if it is possible to rearrange its characters so that no two adjacent characters are the same.

If such a rearrangement exists, output Yes; otherwise, output No.

This problem can be mathematically described as follows: Given a string \(S\) of length \(n\), find a permutation \(P(S)\) such that for every \(i=1,2,\ldots,n-1\), \(P(S)_i \neq P(S)_{i+1}\).

inputFormat

The input consists of a single line containing the string S.

Constraints: \(1 \leq |S| \leq 10^5\)

outputFormat

Output a single line: Yes if the rearrangement is possible, and No otherwise.

## sample
aabb
Yes