#include <iostream>
#include <sstream>
#include <climits>
void PrintSmallestPalindromeWord(std::string str) {
std::istringstream ss(str);
std::string word;
size_t min = INT_MAX;
std::string minword;
while (ss >> word) {
std::string rev_word(word.rbegin(), word.rend());
int wordlen = word.size();
if (word == rev_word && wordlen >= 3) {
if (wordlen < min) {
min = wordlen;
minword = word;
}
}
}
std::cout << minword << "\n";
}
int main()
{
std::string str = "c madam c++ civic java rotator pytyp dart php";
PrintSmallestPalindromeWord(str);
}
/*
run:
php
*/