#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
int main() {
string s;
cin>>s;
stack<int> st;
for(int i=0;i<s.length();i++){
if(s[i]=='('){
st.push(i);
}
else if(s[i]==')'){
reverse(s.begin()+st.top()+1,s.begin()+i);
st.pop();
}
}
string res;
for(int i=0;i<s.length();i++){
if(s[i]!='(' and s[i]!=')'){
res+=s[i];
}
}
cout<<res;
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: