Substrings

AtCoder
IDabc214_f
Time2000ms
Memory256MB
Difficulty
Given is a string $S$. From this string, Takahashi will make a new string $T$ as follows. * First, mark one or more characters in $S$. Here, no two marked characters should be adjacent. * Next, delete all unmarked characters. * Finally, let $T$ be the remaining string. Here, it is forbidden to change the order of the characters. How many strings are there that can be obtained as $T$? Find the count modulo $(10^9 + 7)$. ## Constraints * $S$ is a string of length between $1$ and $2 \times 10^5$ (inclusive) consisting of lowercase English letters. ## Input Input is given from Standard Input in the following format: $S$ [samples]
Samples
Input #1
abc
Output #1
4

There are four strings that can be obtained as $T$: `a`, `b`, `c`, and `ac`.
Marking the first character of $S$ yields `a`;
marking the second character of $S$ yields `b`;
marking the third character of $S$ yields `c`;
marking the first and third characters of $S$ yields `ac`.
Note that it is forbidden to, for example, mark both the first and second characters.
Input #2
aa
Output #2
1

There is just one string that can be obtained as $T$, which is `a`. Note that marking different positions may result in the same string.
Input #3
acba
Output #3
6

There are six strings that can be obtained as $T$: `a`, `b`, `c`, `aa`, `ab`, and `ca`.
Input #4
chokudai
Output #4
54
API Response (JSON)
{
  "problem": {
    "name": "Substrings",
    "description": {
      "content": "Given is a string $S$. From this string, Takahashi will make a new string $T$ as follows. *   First, mark one or more characters in $S$. Here, no two marked characters should be adjacent. *   Next, d",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc214_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is a string $S$. From this string, Takahashi will make a new string $T$ as follows.\n\n*   First, mark one or more characters in $S$. Here, no two marked characters should be adjacent.\n*   Next, d...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments