#include <iostream>
#include <algorithm>
#include <string>
int main()
{
std::string hay = "whoknowswhereitisfoobar";
std::string needle = "foo";
auto loc = hay.find(needle);
if ( loc != std::string::npos )
{
std::reverse(hay.begin() + loc, hay.begin() + loc + needle.size());
}
std::cout << hay << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3RyaW5nPgoKaW50IG1haW4oKQp7CiAgIHN0ZDo6c3RyaW5nIGhheSA9ICJ3aG9rbm93c3doZXJlaXRpc2Zvb2JhciI7CiAgIHN0ZDo6c3RyaW5nIG5lZWRsZSA9ICJmb28iOwogICBhdXRvIGxvYyA9IGhheS5maW5kKG5lZWRsZSk7CiAgIGlmICggbG9jICE9IHN0ZDo6c3RyaW5nOjpucG9zICkKICAgewogICAgICBzdGQ6OnJldmVyc2UoaGF5LmJlZ2luKCkgKyBsb2MsIGhheS5iZWdpbigpICsgbG9jICsgbmVlZGxlLnNpemUoKSk7CiAgIH0KICAgc3RkOjpjb3V0IDw8IGhheSA8PCBzdGQ6OmVuZGw7CgogICByZXR1cm4gMDsKfQo=