#include <iostream>
#include <vector>
using namespace std;
vector<int> commands;
void Init() {
 //cout<<"init done"<<endl;
}
void TypeLetter(char L) {
  commands.push_back(int(L));
  //cout<<"letter added"<<endl;
}
void UndoCommands(int U) {
  commands.push_back(-U);
  //cout<<U<<" commands undone"<<endl;
}
bool first = true;
vector<char>text;
char GetLetter(int P) {
  if (first){
    // for (int i: commands){
    //   cout<<i<<' ';
    // }
    // cout<<endl;
    first = false;
    int i = commands.size()-1;
    while (i > 0){
      if (commands[i] < 0){
        for (int j = 0; j <= -commands[i]; ++j){
          commands.pop_back();
        }
        i = commands.size()-1;
      }else{
        i--;
      }
    }
    // for (int i: commands){
    //   cout<<i<<' ';
    // }
    // cout<<endl;
    for (int i: commands){
      text.push_back((char)i);
    }
  }
  return text[P];
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |