Dividing a String

AtCoder
IDagc037_a
Time2000ms
Memory256MB
Difficulty
Given is a string $S$ consisting of lowercase English letters. Find the maximum positive integer $K$ that satisfies the following condition: * There exists a partition of $S$ into $K$ non-empty strings $S=S_1S_2...S_K$ such that $S_i \neq S_{i+1}$ ($1 \leq i \leq K-1$). Here $S_1S_2...S_K$ represents the concatenation of $S_1,S_2,...,S_K$ in this order. ## Constraints * $1 \leq |S| \leq 2 \times 10^5$ * $S$ consists of lowercase English letters. ## Input Input is given from Standard Input in the following format: $S$ [samples]
Samples
Input #1
aabbaa
Output #1
4

We can, for example, divide $S$ into four strings `aa`, `b`, `ba`, and `a`.
Input #2
aaaccacabaababc
Output #2
12
API Response (JSON)
{
  "problem": {
    "name": "Dividing a String",
    "description": {
      "content": "Given is a string $S$ consisting of lowercase English letters. Find the maximum positive integer $K$ that satisfies the following condition: *   There exists a partition of $S$ into $K$ non-empty str",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc037_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is a string $S$ consisting of lowercase English letters. Find the maximum positive integer $K$ that satisfies the following condition:\n\n*   There exists a partition of $S$ into $K$ non-empty str...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments