Go to diff to previous submission
#include <iostream> #include <string> #include <iostream> using namespace std; int main() { string line, bug; int T; size_t pos; while (cin >> T) { cin >> bug; cin.ignore(); for ( ; T; T--) { pos = 0; getline(cin, line); while ((pos = line.find(bug, pos)) != string::npos) { line.erase(pos, bug.length()); pos = pos - bug.length(); pos = (pos < 0) ? 0 : pos; } cout << line << endl; } } return 0; }