Message from Aliens

AtCoder
IDzone2021_d
Time2000ms
Memory256MB
Difficulty
You are given a ciphertext $S$. It can be decrypted by the following procedure: * Let $T$ be an empty string. * For each $i = 1, 2, \dots, |S|$ in this order, do the following: ($|S|$ denotes the length of $S$) * if the $i$\-th character of $S$ is `R`, reverse $T$; * if the $i$\-th character of $S$ is not `R`, add that character to the end of $T$. * After the operation above, if there are two consecutive same characters in $T$, remove those two characters. Repeat this operation as long as it can be done. (We can prove that the final string obtained does not depend on the order the characters are removed.) Print the string $T$ obtained by this procedure. ## Constraints * $S$ consists of lowercase English letters and `R`. * $1 ≤ |S| ≤ 5 \times 10^5$ ## Input Input is given from Standard Input in the following format: $S$ [samples]
Samples
Input #1
ozRnonnoe
Output #1
zone

We can decrypt it as follows:

*   Initially, $T$ is an empty string.
*   Add `o` at the end of $T$, making it `o`.
*   Add `z` at the end of $T$, making it `oz`.
*   Reverse $T$, making it `zo`.
*   Add `n` at the end of $T$, making it `zon`.
*   Add `o` at the end of $T$, making it `zono`.
*   Add `n` at the end of $T$, making it `zonon`.
*   Add `n` at the end of $T$, making it `zononn`.
*   Add `o` at the end of $T$, making it `zononno`.
*   Add `e` at the end of $T$, making it `zononnoe`.
*   Delete two consecutive `n`s from $T$, making it `zonooe`.
*   Delete two consecutive `o`s from $T$, making it `zone`.
Input #2
hellospaceRhellospace
Output #2
The answer may be an empty string.
API Response (JSON)
{
  "problem": {
    "name": "Message from Aliens",
    "description": {
      "content": "You are given a ciphertext $S$. It can be decrypted by the following procedure: *   Let $T$ be an empty string. *   For each $i = 1, 2, \\dots, |S|$ in this order, do the following: ($|S|$ denotes the",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "zone2021_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a ciphertext $S$. It can be decrypted by the following procedure:\n\n*   Let $T$ be an empty string.\n*   For each $i = 1, 2, \\dots, |S|$ in this order, do the following: ($|S|$ denotes the...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments