Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <algorithm>
- #include <cmath>
- #include <vector>
- #include <set>
- #include <map>
- #include <stack>
- //#include <unordered_set>
- //#include <unordered_map>
- #include <queue>
- //#include <ctime>
- //#include <cassert>
- //#include <complex>
- #include <string>
- #include <cstring>
- //#include <chrono>
- //#include <random>
- #include <bitset>
- using namespace std;
- //using namespace chrono;
- #define pb push_back
- #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
- #define F first
- #define S second
- typedef long long ll;
- typedef vector< int > vi;
- typedef vector< ll > V;
- typedef map<int, int > mp;
- #define debug cout << -1 << endl;
- #define REP(i, a, b) for(int i=a; i<b; i++)
- #define f0r(i, n) for (int i = 0; i < n; ++i)
- #define fore(a, x) for (auto& a : x)
- #define fori(i, a, b) for (int i = (a); i < (b); ++i)
- //#define pop pop_back
- #define sz(a) (int)a.size()
- //#define fin cin
- //#define fout cout
- const ll MOD = 1000000007;
- const int INF = (int)1e9;
- int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
- int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
- const double PI = acos(-1.0);
- const double diff = 1e-6;
- void solve()
- {
- //FastIO;
- //freopen("mowing.in","r",stdin);
- //freopen("mowing.out","w",stdout);
- string str;
- cin >> str;
- int n = str.size();
- stack< char > s;
- for(int i=0; i<n; i++) {
- if(!s.empty()) {
- if(s.top()==str[i]) {
- s.pop();
- continue;
- }
- }
- s.push(str[i]);
- }
- string ans;
- while(!s.empty()) {
- ans += s.top();
- s.pop();
- }
- reverse(ans.begin(), ans.end());
- cout << ans << "\n";
- }
- int main()
- {
- int t;
- t = 1;
- //cin >> t;
- while(t--) {
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement