#include <iostream>
#include <algorithm>
#include <string>
int main() {
std::string str = " ";
std::cout << str << "<-" << std::endl;
size_t endpos = str.find_last_not_of(" \t");
size_t startpos = str.find_first_not_of(" \t");
if( std::string::npos != endpos )
{
str = str.substr( 0, endpos+1 );
str = str.substr( startpos );
}
else{
str.erase(std::remove(std::begin(str), std::end(str), ' '), std::end(str));
}
std::cout << str << "<-";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3RyaW5nPgoKaW50IG1haW4oKSB7CglzdGQ6OnN0cmluZyBzdHIgPSAiCQkgICAgICAgICAgICAgICAgICI7CglzdGQ6OmNvdXQgPDwgc3RyIDw8ICI8LSIgPDwgc3RkOjplbmRsOwoJCglzaXplX3QgZW5kcG9zID0gc3RyLmZpbmRfbGFzdF9ub3Rfb2YoIiBcdCIpOwoJc2l6ZV90IHN0YXJ0cG9zID0gc3RyLmZpbmRfZmlyc3Rfbm90X29mKCIgXHQiKTsKICAgCWlmKCBzdGQ6OnN0cmluZzo6bnBvcyAhPSBlbmRwb3MgKQoJewogICAgCXN0ciA9IHN0ci5zdWJzdHIoIDAsIGVuZHBvcysxICk7CiAgICAJc3RyID0gc3RyLnN1YnN0ciggc3RhcnRwb3MgKTsKCX0KCWVsc2V7CgkJc3RyLmVyYXNlKHN0ZDo6cmVtb3ZlKHN0ZDo6YmVnaW4oc3RyKSwgc3RkOjplbmQoc3RyKSwgJyAnKSwgc3RkOjplbmQoc3RyKSk7Cgl9CgkKCXN0ZDo6Y291dCA8PCBzdHIgPDwgIjwtIjsKCXJldHVybiAwOwp9