Codeforces Round 156 (Div. 2)
B
Code Parsing
Codeforces
1200
原题
← AC →
翻译中…

Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string $*s*$, consisting of characters "x" and "y", and uses two following operations at runtime:

翻译中…
  1. Find two consecutive characters in the string, such that the first of them equals "y", and the second one equals "x" and swap them. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string.
  2. Find in the string two consecutive characters, such that the first of them equals "x" and the second one equals "y". Remove these characters from the string. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string.
翻译中…

The input for the new algorithm is string $*s*$, and the algorithm works as follows:

翻译中…
  1. If you can apply at least one of the described operations to the string, go to step 2 of the algorithm. Otherwise, stop executing the algorithm and print the current string.
  2. If you can apply operation 1, then apply it. Otherwise, apply operation 2. After you apply the operation, go to step 1 of the algorithm.
翻译中…

Now Vitaly wonders, what is going to be printed as the result of the algorithm's work, if the input receives string $*s*$.

翻译中…

Input

翻译中…

The first line contains a non-empty string $*s*$.

翻译中…

It is guaranteed that the string only consists of characters "x" and "y". It is guaranteed that the string consists of at most $10^{6}$ characters. It is guaranteed that as the result of the algorithm's execution won't be an empty string.

翻译中…

Output

翻译中…

In the only line print the string that is printed as the result of the algorithm's work, if the input of the algorithm input receives string $*s*$.

翻译中…

Note

翻译中…

In the first test the algorithm will end after the first step of the algorithm, as it is impossible to apply any operation. Thus, the string won't change.

翻译中…

In the second test the transformation will be like this:

翻译中…
  1. string "yxyxy" transforms into string "xyyxy";
  2. string "xyyxy" transforms into string "xyxyy";
  3. string "xyxyy" transforms into string "xxyyy";
  4. string "xxyyy" transforms into string "xyy";
  5. string "xyy" transforms into string "y".
翻译中…

As a result, we've got string "y".

翻译中…

In the third test case only one transformation will take place: string "xxxxxy" transforms into string "xxxx". Thus, the answer will be string "xxxx".

翻译中…

样例

Input #1
x
Output #1
x
InputCopy OutputCopy
Input #2
yxyxy
Output #2
y
InputCopy OutputCopy
Input #3
xxxxxy
Output #3
xxxx
InputCopy OutputCopy
题目信息
题号
255B
时间限制
2 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。