#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <vector>
#include <algorithm>
std:: vector < std:: string > extractTokens( std:: istream & is)
{
std:: vector < std:: string > tokens;
std:: string token;
while ( is >> token)
tokens.push_back ( token) ;
return tokens;
}
int main( )
{
std:: istringstream is
{
"Brianna\n "
"Lindsey\n "
"Paul\n "
"Lisa\n "
} ;
auto names = extractTokens( is) ;
std:: sort ( names.begin ( ) , names.end ( ) ) ;
std:: vector < std:: string > patterns = { "Li" , "Br" , "Lin" , "P" , "Zi" , "Au" , "i" } ;
for ( auto & pattern : patterns)
{
auto it = std:: lower_bound ( names.begin ( ) , names.end ( ) , pattern) ;
std:: cout << "Results for \" " << pattern << "\" are:\n " ;
if ( it ! = names.end ( ) && it- > find( pattern) == 0 )
{
while ( it ! = names.end ( ) && it- > find( pattern) == 0 )
std:: cout << '\t ' << * it++ << '\n ' ;
}
else
std:: cout << "\t No results.\n " ;
std:: cout << '\n ' ;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBleHRyYWN0VG9rZW5zKHN0ZDo6aXN0cmVhbSYgaXMpCnsKICAgIHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiB0b2tlbnM7CiAgICBzdGQ6OnN0cmluZyB0b2tlbjsKCiAgICB3aGlsZSAoaXMgPj4gdG9rZW4pCiAgICAgICAgdG9rZW5zLnB1c2hfYmFjayh0b2tlbik7CgogICAgcmV0dXJuIHRva2VuczsKfQoKaW50IG1haW4oKQp7CiAgICBzdGQ6OmlzdHJpbmdzdHJlYW0gaXMKICAgIHsKICAgICAgICAiQnJpYW5uYVxuIgogICAgICAgICJMaW5kc2V5XG4iCiAgICAgICAgIlBhdWx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