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 106 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.

Examples
input

Copy
x
output

Copy
x
input

Copy
yxyxy
output

Copy
y
input

Copy
xxxxxy
output

Copy
xxxx
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".

#include<bits/stdc++.h>
#define N 1000005
using namespace std;
typedef long long ll;
char a[N];
int main(){
cin>>a;
int b=,c=;
int len=strlen(a);
for(int i=;i<len;i++)
if(a[i]=='x')
b++;
else c++;
if(b>c)for(int i=;i<=b-c;i++)cout<<'x';
else for(int i=;i<=c-b;i++)cout<<'y'; return ;
}

codeforce 225B Code Parsing的更多相关文章

  1. GCN code parsing

    GCN code parsing 2018-07-18 20:39:11 utils.py  --- load data  def load_data(path="../data/cora/ ...

  2. Rewrite MSIL Code on the Fly with the .NET Framework Profiling API

    http://clrprofiler.codeplex.com/ http://blogs.msdn.com/b/davbr/archive/2012/11/19/clrprofiler-4-5-re ...

  3. Codeforces Round #156 (Div. 2)

    A. Greg's Workout 模3求和,算最大值. B. Code Parsing 最后左半部分为x,右半部分为y,那么从中间不断去掉xy,直到其中一种全部消去. C. Almost Arith ...

  4. eclipseGUI的可视化开发工具插件

    一   各种GUI开发插件的特色 Eclipse并不自带GUI的可视化开发工具,那么如果要在Eclipse进行可视化的GUI开发,就需要依靠第三方的插件. 1. Visual Editor Eclip ...

  5. Dojo Style Guide

    Contents: General Quick Reference Naming Conventions Specific Naming Conventions Files Variables Lay ...

  6. 浏览器详谈及其内部工作机制 —— web开发必读

    浏览器介绍 如今,浏览器格局基本上是五分天下,分别是:IE.Firefox.Safari.Chrome.Opera,而浏览器引擎就更加集中了,主要是四大巨头:IE的浏览器排版引擎Trident,目前随 ...

  7. Awesome Go精选的Go框架,库和软件的精选清单.A curated list of awesome Go frameworks, libraries and software

    Awesome Go      financial support to Awesome Go A curated list of awesome Go frameworks, libraries a ...

  8. codeforce 421D D. Bug in Code

    题目链接: http://codeforces.com/problemset/problem/421/D D. Bug in Code time limit per test 1 secondmemo ...

  9. (完全背包)Writing Code -- Codeforce 544C

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=99951#problem/C  (zznu14) Writing Code  Writin ...

随机推荐

  1. linux之进程管理(二)

    一.查看进程 ps   aux 查看系统所有的进程数据 ps   -lA 查看所有系统的数据 ps   axjf 连同部分进程树状态 ps参数 -A   显示所有进程,等效 -e -a   不与ter ...

  2. hive常用函数一

    Hive概念 Hive最适合于数据仓库应用程序,使用该应用程序进行相关静态数据分析,不需要快速响应出结果,而数据本身不会发生频繁变化. Hdfs分布式文件系统限制了hive,使其不支持记录级别的更新. ...

  3. C# 基础知识系列- 9 字符串的更多用法(二)

    0. 前言 上一篇文章介绍了字符串自身的一些方法,就是对象方法.在字符串体系中,还有一些是string类提供的静态方法.这两部分构成了字符串体系,当然还有一些三方库为字符串提供了扩展方法. 这里简单的 ...

  4. FreeRTOS操作系统工程建立和操作系统的概念

    一.建立工程步骤如下: 二.详细步骤流程如下: 1.新建工程文件夹,然后在里面建立如下几个文件: 2.使用keil5建立工程: a.建立工程: b.添加内核文件: 3.建立文件分组: 4.创建main ...

  5. 王者荣耀英雄全皮肤4K高清大图,python爬虫帮你保存下来

    前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取t.cn ...

  6. mapstruct使用详解

    我们都知道,随着一个工程的越来越成熟,模块划分会越来越细,其中实体类一般存于 domain 之中,但 domain 工程最好不要被其他工程依赖,所以其他工程想获取实体类数据时就需要在各自工程写 mod ...

  7. Linux学习笔记(三)目录和文件都能操作的命令

    目录和文件都能操作的命令 rm cp mv rm 英文原意:remove files or directories 功能:删除文件或目录 语法:rm 选项[-fir] 文件或目录 rm -f 强制删除 ...

  8. sudo -s 命令 [oh-my-zsh] 提示检测到不安全目录

    运行sudo -s 命令时,[oh-my-zsh] 冒出下面一大堆提示: [oh-my-zsh] Insecure completion-dependent directories detected: ...

  9. 快速从零开始安装Laravel5.2教程

    前面 本文默认你Win电脑什么都没装,也就是从零开始安装Laravel,并且环境都由我来指定分配哈! 环境 首先搭建运行环境,先到 PhpStudy官网 下载PhpStudy的Windows版本.然后 ...

  10. ACNet: 特别的想法,腾讯提出结合注意力卷积的二叉神经树进行细粒度分类 | CVPR 2020

    论文提出了结合注意力卷积的二叉神经树进行弱监督的细粒度分类,在树结构的边上结合了注意力卷积操作,在每个节点使用路由函数来定义从根节点到叶子节点的计算路径,结合所有叶子节点的预测值进行最终的预测,论文的 ...