#include #include using namespace std; int main() { short repeating; cin >> repeating; for (int j = 0; j < repeating; j++) { string input; cin >> input; ostringstream save; int powtorzylosie = 1; for (int i = 0; i < input.length(); i++) { if (input[i] == input[i+1]) { powtorzylosie++; } else { if (powtorzylosie > 1) { if (powtorzylosie == 2) { save << input[i] << input[i]; } else { save << input[i] << powtorzylosie; } } else { save << input[i]; } powtorzylosie = 1; } } cout << save.str() << endl; } return 0; }