Commencement

AtCoder
IDabc349_b
Time2000ms
Memory256MB
Difficulty
A string $S$ consisting of lowercase English letters is a **good string** if and only if it satisfies the following property for all integers $i$ not less than $1$: * There are exactly zero or exactly two different letters that appear exactly $i$ times in $S$. Given a string $S$, determine if it is a good string. ## Constraints * $S$ is a string of lowercase English letters with a length between $1$ and $100$, inclusive. ## Input The input is given from Standard Input in the following format: $S$ [samples]
Samples
Input #1
commencement
Output #1
Yes

For the string `commencement`, the number of different letters that appear exactly $i$ times is as follows:

*   $i=1$: two letters (`o` and `t`)
*   $i=2$: two letters (`c` and `n`)
*   $i=3$: two letters (`e` and `m`)
*   $i\geq 4$: zero letters

Therefore, `commencement` satisfies the condition of a good string.
Input #2
banana
Output #2
No

For the string `banana`, there is only one letter that appears exactly one time, which is `b`, so it does not satisfy the condition of a good string.
Input #3
ab
Output #3
Yes
API Response (JSON)
{
  "problem": {
    "name": "Commencement",
    "description": {
      "content": "A string $S$ consisting of lowercase English letters is a **good string** if and only if it satisfies the following property for all integers $i$ not less than $1$: *   There are exactly zero or exac",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc349_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A string $S$ consisting of lowercase English letters is a **good string** if and only if it satisfies the following property for all integers $i$ not less than $1$:\n\n*   There are exactly zero or exac...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments