Runtime error on test 2. but I did everything as the problem statement says ...
Problem : https://codeforces.me/group/MWSDmqGsZm/contest/219856/problem/L
int n, m; cin >> n >> m;
string s; cin >> s;
while (m--) {
string op; cin >> op;
if (op == "substr") {
int l, r; cin >> l >> r;
l--, r--;
cout << s.substr(l, r + 1) << '\n';
} else if (op == "sort") {
int l, r; cin >> l >> r;
l--, r--;
sort(s.begin() + l, s.begin() + r + 1);
} else if (op == "pop_back") {
s.pop_back();
} else if (op == "back") {
cout << s.back() << '\n';
} else if (op == "reverse") {
int l, r; cin >> l >> r;
l--, r--;
reverse(s.begin() + l, s.begin() + r + 1);
} else if (op == "front") {
cout << s.front() << '\n';
} else if (op == "push_back") {
char i; cin >> i;
s.push_back(i);
} else {
int pos; cin >> pos;
pos--;
cout << s[pos] << '\n';
}
}