Hachi

AtCoder
IDabc181_d
Time2000ms
Memory256MB
Difficulty
Given is a digit sequence $S$ consisting of the digits from `1` through `9`. Takahashi, the bee, loves multiples of $8$. He is trying to make a multiple of $8$ by permuting the digit sequence $S$. Determine whether it is possible. ## Constraints * $1 \leq |S| \leq 2 \times 10^5$ * Each character of $S$ is one of the digits from `1` through `9`. ## Input Input is given from Standard Input in the following format: $S$ [samples]
Samples
Input #1
1234
Output #1
Yes

For example, permuting $1234$ into $1432$ results in a multiple of $8$.
Input #2
1333
Output #2
No

There is no way to permute $1333$ into a multiple of $8$.
Input #3
8
Output #3
Yes
API Response (JSON)
{
  "problem": {
    "name": "Hachi",
    "description": {
      "content": "Given is a digit sequence $S$ consisting of the digits from `1` through `9`. Takahashi, the bee, loves multiples of $8$. He is trying to make a multiple of $8$ by permuting the digit sequence $S$. Det",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc181_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is a digit sequence $S$ consisting of the digits from `1` through `9`.\nTakahashi, the bee, loves multiples of $8$.\nHe is trying to make a multiple of $8$ by permuting the digit sequence $S$.\nDet...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments