397.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

string s;

void read() {
    cin >> s;
}

void solve() {
    list<char> ans;
    auto it = ans.begin();

    for(auto c: s) {
        if(c == 'L') {
            if(it != ans.begin()) {
                it--;
            }
        } else if(c == 'R') {
            if(it != ans.end()) {
                it++;
            }
        } else {
            ans.insert(it, c);
        }
    }

    for(auto c: ans) {
        cout << c;
    }
    cout << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
statement.txt
======================
397. Text Editor
Time limit per test: 1.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard



The simplest text editor "Open Word" allows to create and edit only one word. The editor processes keys 'a' -- 'z', and also 'L' (to the left) and 'R' (to the right). After starting his work the editor immediately creates an empty word and sets its cursor to the left-most position. When one of keys 'a' -- 'z' is pressed, the text editor inserts corresponding symbol just after the cursor. After that a cursor moves one position to the right in such a way that it is placed just after new symbol. When key 'L' or 'R' is pressed, the cursor moves one position to the left or to the right respectively. If the cursor can't be moved because it is placed at the left-most or right-most position the command is ignored. Developers of "Open Word" didn't think about the effectiveness so the editor is working slowly if a lot of keys have been pressed.

Your task is to write a program that can process a sequence of key pressings emulating this editor and output result string.

Input
The input file contains one string which consists of symbols 'a' -- 'z', 'L' and 'R'. The string length is not less than 1 and doesn't exceed 106.

Output
Write a required string to the output file.

Example(s)
sample input
sample output
abLcd
acdb

sample input
sample output
icpLLLLLacmRRRRRRRRRRRRc
acmicpc

=================
