#include <iostream>
#include <string>
#include <locale>
std::string trim(const std::string &s)
{
std::string::const_iterator it = s.begin();
while (it != s.end() && isspace(*it))
it++;
std::string::const_reverse_iterator rit = s.rbegin();
while (rit.base() != it && isspace(*rit))
rit++;
return std::string(it, rit.base());
}
int main() {
std::cout<<"'"<<trim(" trim")<<"'"<<std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8bG9jYWxlPgoKc3RkOjpzdHJpbmcgdHJpbShjb25zdCBzdGQ6OnN0cmluZyAmcykKewoJc3RkOjpzdHJpbmc6OmNvbnN0X2l0ZXJhdG9yIGl0ID0gcy5iZWdpbigpOwoJd2hpbGUgKGl0ICE9IHMuZW5kKCkgJiYgaXNzcGFjZSgqaXQpKQoJCWl0Kys7CgoJc3RkOjpzdHJpbmc6OmNvbnN0X3JldmVyc2VfaXRlcmF0b3Igcml0ID0gcy5yYmVnaW4oKTsKCXdoaWxlIChyaXQuYmFzZSgpICE9IGl0ICYmIGlzc3BhY2UoKnJpdCkpCgkJcml0Kys7CgoJcmV0dXJuIHN0ZDo6c3RyaW5nKGl0LCByaXQuYmFzZSgpKTsKfQoKaW50IG1haW4oKSB7CglzdGQ6OmNvdXQ8PCInIjw8dHJpbSgiICB0cmltIik8PCInIjw8c3RkOjplbmRsOwoJcmV0dXJuIDA7Cn0=