#include #include #include #include #include #include #include void u8toi(char *str, int *array) { int i; int n = strlen(str); for(i = 0; i < n; ++i) { int flag = str[i]; int mask = ~flag; mask |= (mask >> 1); mask |= (mask >> 2); mask |= (mask >> 4); int res = str[i] & mask; while( 0xC0 <= (unsigned char)flag ) { i += 1; flag <<= 1; res <<= 6; res |= str[i] & 0x3F; } *array++ = res; } *array++ = 0; } class Tclass { public: Tclass(); Tclass(int a, std::vector b) { data = std::pair>(a, b); } std::pair> data; }; bool operator < (const Tclass& left, const Tclass& right) { return left.data.first < right.data.first; } void itou8(int *array, char *str) { int i; while( *array != 0 ) { int c = *array; char str2[8]; int len = 0; char c2; if( c < 0x80 ) { str2[0] = c; len = 1; } else { while( c != 0 ) { c2 = (c & 0x3f); str2[len] = c2; len += 1; c >>= 6; } } if( len != 1 ) { str2[len - 1] |= (((unsigned char)(0xff)) << (8 - len)); for(i = 0; i < len - 1; ++i) { str2[i] |= 0x80; } } for(i = len - 1; i >= 0; --i) { *str++ = str2[i]; } array += 1; } *str++ = 0; } int main() { char str[1000]; fgets(str, sizeof(str), stdin); str[strlen(str)-1] = '\0'; int str2[1000]; u8toi(str, str2); itou8(str2, str); //printf("%s\n", str); char t[100] = "w"; int t2[100]; u8toi(t, t2); int tt = t2[0]; int temp = 0; std::vector ttstr; std::vector candi; for(int i = 0; ; ++i) { //printf(" %d\n", str2[i]); if( str2[i] == 0 ) break; if( str2[i] == tt ) { temp += 1; } else { if( temp != 0 ) { if( ttstr.size() != 0 ) { candi.push_back(Tclass(temp, ttstr)); ttstr.clear(); } } ttstr.push_back(str2[i]); temp = 0; } } if( temp != 0 ) { if( ttstr.size() != 0 ) { candi.push_back(Tclass(temp, ttstr)); ttstr.clear(); } } std::stable_sort(candi.begin(), candi.end()); int llen = 0; if( candi.size() != 0 ) { llen = candi[candi.size()-1].data.first; } bool flag = true; for(int i = 0; i < (int)candi.size(); ++i) { if( candi[i].data.first != llen ) continue; char res[1000]; int rest[1000]; for(int j = 0; j < (int)candi[i].data.second.size(); ++j) { rest[j] = candi[i].data.second[j]; } rest[candi[i].data.second.size()] = 0; itou8(rest, res); if( res[0] != '\0' ) { printf("%s\n", res); flag = false; } } if( flag ) { printf("\n"); } return 0; }