#include <iostream>
using namespace std;
#include <boost/algorithm/string.hpp>
size_t word_count( const string & text )
{
vector<string> words;
boost::split( words, text, boost::is_any_of(" :-,."), boost::token_compress_on );
return std::accumulate( words.begin(), words.end(), 0,
[]( size_t n, const string & s ) -> size_t { return n + (s.size() % 2 == 0 ? 1 : 0);} );
}
int main() {
cout << word_count("test test abc asdf") << std::endl; //prints 3
cout << word_count("AAA A AAA") << std::endl; //prints 0
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Ym9vc3QvYWxnb3JpdGhtL3N0cmluZy5ocHA+CgpzaXplX3Qgd29yZF9jb3VudCggY29uc3Qgc3RyaW5nICYgdGV4dCApCnsKCXZlY3RvcjxzdHJpbmc+IHdvcmRzOwoJYm9vc3Q6OnNwbGl0KCB3b3JkcywgdGV4dCwgYm9vc3Q6OmlzX2FueV9vZigiIDotLC4iKSwgYm9vc3Q6OnRva2VuX2NvbXByZXNzX29uICk7CglyZXR1cm4gc3RkOjphY2N1bXVsYXRlKCB3b3Jkcy5iZWdpbigpLCB3b3Jkcy5lbmQoKSwgMCwKCVtdKCBzaXplX3QgbiwgY29uc3Qgc3RyaW5nICYgcyApIC0+IHNpemVfdCB7IHJldHVybiBuICsgKHMuc2l6ZSgpICUgMiA9PSAwID8gMSA6IDApO30gKTsKfQoKaW50IG1haW4oKSB7Cgljb3V0IDw8IHdvcmRfY291bnQoInRlc3QgdGVzdCBhYmMgYXNkZiIpIDw8IHN0ZDo6ZW5kbDsgLy9wcmludHMgMwoJY291dCA8PCB3b3JkX2NvdW50KCJBQUEgQSBBQUEiKSA8PCBzdGQ6OmVuZGw7IC8vcHJpbnRzIDAKfQ==