alexjercan/bugnet huggingface dataset:
Problem p00101 (C++) — buggy submission, verdict: Runtime Error


#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(), (a).end()

int main(void) {
  string num;
  getline(cin, num);
  int n = atoi(&num[0]);
  while (n--) {
    string s;
    getline(cin, s);
    rep(i, s.size()) {
      if (s[i] == 'H' && s[i + 1] == 'o' && s[i + 2] == 's' &&
          s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n' &&
          s[i + 6] == 'o') {
        s[i + 6] = 'a';
      }
      if (s[i] == '\\n') {
        cout << endl;
        n--;
        break;
        cout << "test" << n << endl;
      }
    }
    cout << s << endl;
  }
}

Error: WA

Fixed submission:


#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(), (a).end()

int main(void) {
  int n;
  cin >> n;
  rep(j, n) {
    string s;
    cin >> s;
    rep(i, s.size() - 6) {
      if (s[i] == 'H' && s[i + 1] == 'o' && s[i + 2] == 's' &&
          s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n' &&
          s[i + 6] == 'o') {
        s[i + 6] = 'a';
      }
    }
    cout << s << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>

int main() {

  char str[1002], ho[] = "Hoshino";
  int n, i;
  char *a;

  scanf("%d\\n", &n);
  for (i = 0; i < n; i++) {
    fgets(str, sizeof(str), stdin);
    while ((a = strstr(str, ho)) != NULL) {
      a[6] = 'a';
    }
    printf("%s", str);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  int n;
  cin >> n;
  while (--n) {
    getline(cin, s);
    for (int i = 0; i < s.size() - 5; i++) {
      if (s[i] == 'H' && s[i + 1] == 'o' && s[i + 2] == 's' &&
          s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n' &&
          s[i + 6] == 'o') {
        s[i + 1] = 'a';
        s[i + 6] = 'o';
      }
    }

    cout << s << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>
int main() {
  char sentence[1050];
  int n, i, j;
  scanf("%d\\n", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < 1050; j++) {
      sentence[j] = getchar();
      if (sentence[j] == '\\n') {
        sentence[j] = 0;
        break;
      }
    }
    for (j = 0; j < 1050; j++) {
      if (sentence[j] == 0)
        break;
      if (!strncmp(sentence + j, "Hoshino", 7)) {
        sentence[j + 6] = 'a';
      }
    }
    puts(sentence);
  }
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>

int main() {
  int b = 0, c;
  char a[1000];
  while (scanf("%c", &a[b]) != EOF)
    b++;
  for (c = 6; c < b; c++) {
    if (a[b - 6] == 'H', a[c - 5] == 'o', a[c - 4] == 's', a[c - 3] == 'h',
        a[c - 2] == 'i', a[c - 1] == 'n', a[c] == 'o')
      a[c] = 'a';
  }
  for (c = 0; c < b; c++)
    printf("%c", a[c]);
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  //	FILE* fp_in = freopen("data.txt", "r", stdin);

  int n;
  string s;
  getline(cin, s);
  n = atoi(s.c_str());

  for (int i = 0; i < n; i++) {
    string str;
    getline(cin, str);
    for (int j = 0; j + 6 < str.length(); j++) {
      string sub;
      sub = str.substr(j, 7);
      if (sub == "Hoshino")
        str[j + 6] = 'a';
    }
    cout << str << endl;
  }

  //	while (1){}
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  // FILE* fp_in = freopen("data.txt", "r", stdin);

  int n;
  string s;
  getline(cin, s);
  n = atoi(s.c_str());

  for (int i = 0; i < n; i++) {
    string str;
    getline(cin, str);
    cout << str.length() << endl;
    for (int j = 0; j <= str.length() - 7; j++) {
      string sub;
      sub = str.substr(j, 7);
      cout << sub << endl;
      if (sub == "Hoshino")
        str[j + 6] = 'a';
    }
    cout << str << endl;
  }

  // while (1){}
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

void solve() {
  int n;
  scanf("%d\\n", &n);
  string name = "Hoshino";
  while (n--) {
    string s;
    getline(cin, s);
    int length = s.length() - name.length() + 1;
    for (int i = 0; i < length; ++i) {
      bool flag = true;
      for (int j = 0; j < name.length(); ++j) {
        if (s[i + j] != name[j]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        s[i + name.length() - 1] = 'a';
      } else {
        continue;
      }
    }
    cout << s << endl;
  }
}

int main() {
  solve();
  return (0);
}

Error: 0

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

void solve() {
  int n;
  scanf("%d\\n", &n);
  string name = "Hoshino";
  while (n--) {
    string s;
    getline(cin, s);
    for (int i = 0; i < s.length() - name.length() + 1; ++i) {
      bool flag = true;
      for (int j = 0; j < name.length(); ++j) {
        if (s[i + j] != name[j]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        s[i + name.length() - 1] = 'a';
      } else {
        continue;
      }
    }
    cout << s << endl;
  }
}

int main() {
  solve();
  return (0);
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <typeinfo>
#include <vector>
#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  getchar();

  rep(i, n) {
    string s;
    getline(cin, s);
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'H' && s[i + 1] == 'o' && s[i + 2] == 's' &&
          s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n' &&
          s[i + 6] == 'o') {
        s[i + 6] = 'a';
      }
    }
    cout << s << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <typeinfo>
#include <vector>
#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  getchar();

  rep(i, n) {
    string s;
    getline(cin, s);
    for (int i = 0; i < s.size() - 6; i++) {
      if (s[i] == 'H' && s[i + 1] == 'o' && s[i + 2] == 's' &&
          s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n' &&
          s[i + 6] == 'o') {
        s[i + 6] = 'a';
      }
    }
    cout << s << endl;
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
string s;

int main() {
  cin >> n;
  cin.ignore();
  REP(i, n) {
    getline(cin, s);
    while (s.find("Hoshino") != -1) {
      s[s.find("Hoshino") + 6] = 'a';
    }
    cout << s << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
string s;

int main() {
  cin >> n;
  cin.ignore();
  while (n--) {
    getline(cin, s);
    bool f = 0;
    for (int i = 0; i < s.size() - 6; i++) {
      string t = s.substr(i, 7);
      if (t == "Hoshino") {
        s[i + 6] = 'a';
      }
    }
    cout << s << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;

int main() {
  string str;
  int n;
  cin >> n;
  getline(cin, str);
  for (int i = 0; i < n; i++) {
    getline(cin, str);
    for (int j = 0; j < int(str.size()) - 6; j++) {
      if (str.substr(j, 7) == "Hoshino")
        str.replace(j, 7, "Hoshina");
    }
    cout << str << endl;
  }
}


Error: 0

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

int main() {
  string str;
  int n;
  cin >> n;
  getline(cin, str);
  for (int i = 0; i < n; i++) {
    getline(cin, str);
    for (int j = 0; j < str.size() - 6; j++) {
      if (str[j] == 'H') {
        if (str.substr(j + 1, 6) == "oshino")
          str.replace(j, 7, "Hoshina");
        else if (str.substr(j + 1, 6) == "oshina")
          str.replace(j, 7, "Hoshino");
      }
    }
    cout << str << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
  int n;
  string h = "Hoshino";
  string s;
  cin >> n;
  getline(cin, s);
  stringstream ss(s);
  ss >> n;
  rep(loop, n) {
    getline(cin, s);
    rep(i, s.size()) {
      if (i + h.size() - 1 >= s.size())
        break;
      bool same = true;
      rep(j, h.size()) {
        if (s[i + j] != h[j]) {
          same = false;
          break;
        }
      }
      if (same)
        s[i + h.size() - 1] = 'a';
    }
    cout << s << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
  int n;
  string h = "Hoshino";
  string s;
  cin >> n;
  getline(cin, s);
  stringstream ss(s);
  ss >> n;
  rep(loop, n) {
    getline(cin, s);
    rep(i, s.size() - h.size() + 1) {
      bool same = true;
      rep(j, h.size()) {
        if (s[i + j] != h[j]) {
          same = false;
          break;
        }
      }
      if (same)
        s[i + h.size() - 1] = 'a';
    }
    cout << s << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int n;

  char str[2000];

  cin >> n;

  cin.ignore();

  for (int loop = 0; loop < n; loop++) {
    gets(str);

    for (int i = 0; i <= 1000; i++) {
      if (str[i] == 'H' && str[i + 1] == 'o' && str[i + 2] == 's' &&
          str[i + 3] == 'h' && str[i + 4] == 'i' && str[i + 5] == 'n' &&
          str[i + 6] == 'o') {
        str[i + 6] = 'a';
      }
      if (str[i] == '\\0') {
        break;
      }
      cout << str[i];
    }

    cout << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int n;

  string str;

  cin >> n;

  cin.ignore();
  for (int loop = 0; loop < n; loop++) {
    getline(cin, str);

    for (int i = 0; i < str.size() - 6; i++) {
      if (str[i] == 'H' && str[i + 1] == 'o' && str[i + 2] == 's' &&
          str[i + 3] == 'h' && str[i + 4] == 'i' && str[i + 5] == 'n' &&
          str[i + 6] == 'o') {
        str[i + 6] = 'a';
      }
    }

    cout << str << endl;
  }

  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;

int n;
string s;

bool match(int index, string pattern) {
  if (index + pattern.size() > s.size())
    return false;
  for (int i = 0; i < pattern.size(); i++) {
    if (s[index + i] != pattern[i])
      return false;
  }
  return true;
}

int change() {
  string after = "Hoshina", before = "Hoshino";
  for (int i = 0; i < s.size(); i++) {
    if (match(i, before)) {
      for (int j = 0; j < before.size(); j++) {
        s[i + j] = after[j];
      }
    }
  }
  return 0;
}

int main() {
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; i++) {
    getline(cin, s);
    change();
    cout << s << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  string n;
  getline(cin, n);
  string s;
  while (getline(cin, s)) {
    for (int i = 0; i < s.size() - 6; i++) {
      if (s[i] == 'H' && s[i + 1] == 'o' && s[i + 2] == 's' &&
          s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n' &&
          s[i + 6] == 'o') {
        s[i + 6] = 'a';
      }
    }
    cout << s << endl;
  }

  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  int n;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    getline(cin, a);
    int h = a.size();
    for (int j = 0; j <= h - 7; j++) {
      if (a[j] == 'H' && a[j + 1] == 'o' && a[j + 2] == 's' &&
          a[j + 3] == 'h' && a[j + 4] == 'i' && a[j + 5] == 'n' &&
          a[j + 6] == 'o')
        a[j + 6] = 'a';
    }
    if (i != 0)
      cout << a << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
  string f;
  char a[2000];
  int n;
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; i++) {
    getline(cin, f);
    for (int j = 0; j < f.size(); j++)
      a[j] = f[j];
    for (int j = 0; j < f.size() - 6; j++) {
      if (a[j] == 'H' && a[j + 1] == 'o' && a[j + 2] == 's' &&
          a[j + 3] == 'h' && a[j + 4] == 'i' && a[j + 5] == 'n' &&
          a[j + 6] == 'o')
        a[j + 6] = 'a';
    }
    for (int j = 0; j < f.size(); j++)
      cout << a[j];
    cout << endl;
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)

#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort((c).begin(), (c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  cin.ignore();

  string from = "Hoshino";
  REP(i, N) {
    string S;
    getline(cin, S);

    while (true) {
      int res = S.find("Hoshino", 0);
      if (res == -1)
        break;

      S.replace(res, 7, "Hoshina");
    }
    cout << S << "\\n";
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)

#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort((c).begin(), (c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  string S, from = "Hoshino";
  REP(i, N) {
    getline(cin, S);

    REP(i, S.size() - 6) {
      if (S.substr() == from)
        S.replace(i, 7, "Hoshina");
    }
    cout << S << "\\n";
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T> T RoundOff(T a) { return int(a + .5 - (a < 0)); }
template <class T, class C> void chmax(T &a, C b) {
  if (a < b)
    a = b;
}
template <class T, class C> void chmin(T &a, C b) {
  if (b < a)
    a = b;
}
template <class T, class C> pair<T, C> mp(T a, C b) { return make_pair(a, b); }

int main() {
  int n;
  cin >> n;
  cin.get();

  while (n--) {
    string str;

    getline(cin, str);

    REP(i, 6, str.size())
    if (str.substr(i - 6, 7) == "Hoshino")
      str[i] = 'a';

    cout << str << endl;
  }
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 1) > this->size() (which is 0)


Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T> T RoundOff(T a) { return int(a + .5 - (a < 0)); }
template <class T, class C> void chmax(T &a, C b) {
  if (a < b)
    a = b;
}
template <class T, class C> void chmin(T &a, C b) {
  if (b < a)
    a = b;
}
template <class T, class C> pair<T, C> mp(T a, C b) { return make_pair(a, b); }

int main() {
  int n;
  cin >> n;
  cin.sync();

  while (n--) {
    string str;

    getline(cin, str);

    rep(i, str.size() - 6) {
      if (str.substr(i, 7) == "Hoshino") {
        str[i += 6] = 'a';
      }
    }

    cout << str << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  cin.get();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    for (int j = 0; j < s.size(); j++) {
      if (s.substr(j, 7) == "Hoshino")
        s[j + 6] = 'a';
    }
    cout << s << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;
  cin.get();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    for (int j = 0; j <= s.size() - 7; j++) {
      if (s.substr(j, 7) == "Hoshino")
        s[j + 6] = 'a';
    }
    cout << s << endl;
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

int main() {
  const string search = "Hoshino";

  int n;
  cin >> n;
  cin.get();

  string text;
  while (n--) {
    getline(cin, text);
    for (int i = 0; i < (int)text.size();) {
      int j;
      for (j = 0; j < (int)search.size(); ++j) {
        if ((int)text.size() < i + j || search[j] != text[i + j]) {
          i += (j == 0 ? 1 : j);
          break;
        }
      }
      if (j == (int)search.size()) {
        text[i + j - 1] = 'a';
        i += j;
      }
    }
    cout << text << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

int main() {
  const string search = "Hoshino";

  int n;
  cin >> n;
  cin.get();

  string text;
  while (n--) {
    getline(cin, text);
    for (int i = 0; i < (int)text.size();) {
      int j;
      for (j = 0; j < (int)search.size(); ++j) {
        if ((int)text.size() < i + j || search[j] != text[i + j]) {
          break;
        }
      }
      if (j == (int)search.size()) {
        text[i + j - 1] = 'a';
      }
      i += j;
    }
    cout << text << endl;
  }

  return 0;
}