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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define INF 100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i, n) for (int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>())
#define clr(a, b) memset((a), (b), sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P>> PQ;

int n;
string str;

int main() {
  cin >> n;
  cin.ignore();
  rep(i, n) {
    getline(cin, str);
    if (str.size() < 7) {
      cout << str << endl;
      continue;
    }
    rep(j, str.size() - 6) {
      if (str[j] == 'H' && str[j + 1] == 'o' && str[j + 2] == 's' &&
          str[j + 3] == 'h' && str[j + 4] == 'i' && str[j + 5] == 'n' &&
          str[j + 6] == 'o') {
        str[j + 6] = 'a';
      }
    }
    cout << str << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define INF 100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i, n) for (int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>())
#define clr(a, b) memset((a), (b), sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P>> PQ;

int n;
string str;

int main() {
  cin >> n;
  cin.ignore();
  rep(i, n) {
    getline(cin, str);
    rep(j, str.size() - 6) {
      if (str[j] == 'H' && str[j + 1] == 'o' && str[j + 2] == 's' &&
          str[j + 3] == 'h' && str[j + 4] == 'i' && str[j + 5] == 'n' &&
          str[j + 6] == 'o') {
        str[j + 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;
  getchar();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    int a = s.size();

    if (a >= 7) {
      for (int j = 0; j < a - 6; j++) {
        string sb;
        sb = s.substr(j, 7);
        if (sb == "Hoshino") {
          s.replace(j, 7, "Hoshina");
        }
      }
    }
    cout << s << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  string s;
  cin >> n;

  for (int i = 0; i < n; i++) {
    getline(cin, s);
    int z = s.size();

    if (z >= 7) {
      for (int i = 0; i < z - 6; i++) {
        string sb = s.substr(i, 7);
        if (sb == "Hoshino") {
          s.replace(i, i + 7, "Hoshina");
        }
      }
    }
    cout << s << endl;
  }

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

#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define reep(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) reep((i), 0, (n))
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI = 6 * asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
static const int INF = 1 << 24;

template <class T>
void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

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

Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define reep(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) reep((i), 0, (n))
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI = 6 * asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
static const int INF = 1 << 24;

template <class T>
void initvv(vector<vector<T>> &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

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

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

const string a = "Hoshino";
const string b = "Hoshina";
int n;
string str;

int main() {
  cin >> n;
  cin.get();
  while (n--) {
    getline(cin, str);
    for (int i = 0; i <= (int)str.size() - (int)a.size(); i++) {
      if (str.substr(i, a.size()) == a)
        str.replace(i, b.size(), b);
    }
    cout << str << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

const string a = "Hoshino";
const string b = "Hoshina";
int n;
string str;

int main() {
  cin >> n;
  cin.get();
  while (n--) {
    getline(cin, str);
    for (int i = 0; i <= str.size() - a.size(); i++) {
      if (str.substr(i, a.size()) == a)
        str.replace(i, b.size(), b);
      else if (str.substr(i, b.size()) == b)
        str.replace(i, a.size(), a);
    }
    cout << str << endl;
  }

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

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  string str;

  cin >> n;
  cin.ignore();
  while (n > 0) {
    getline(cin, str);
    int len = 0;
    while (1) {
      len = str.find("Hoshino", len);
      if (len == -1)
        break;
      str[len + 6] = 'a';
    }
    cout << str << endl;
    n--;
  }
  return (0);
}

Error: -11

Fixed submission:

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

int main() {
  string str;
  int n;

  cin >> n;
  cin.ignore();
  while (n > 0) {
    getline(cin, str);
    int len = 0;
    while (1) {
      len = str.find("Hoshino", len);
      if (len == -1)
        break;
      str[len + 666666] = 'a';
    }
    cout << str << endl;
    n--;
  }
  return (0);
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

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

void Hoshina(string &str) {
  if (str.size() < 7) {
  } else {
    for (unsigned 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;
}

int main() {
  int n;
  string str;
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; ++i) {
    getline(cin, str);
    Hoshina(str);
  }
  return 0;
}

Error: WA

Fixed submission:

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

void Hoshina(string &str) {
  for (unsigned 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;
}

int main() {
  int n;
  string str;
  cin >> n;
  cin.ignore();
  for (int i = 0; i < n; ++i) {
    getline(cin, str);
    Hoshina(str);
    cin.ignore();
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {

  int n;
  string s;
  string d = "Hoshina";
  cin >> n;
  cin.ignore();
  while (n--) {
    getline(cin, s);
    for (int i = 6; i < s.size(); i++) {
      if (s.substr(i - 6, 7) == "Hoshino")
        s.at(i) = 'a';
    }
    cout << s << endl;
  }
}

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


Fixed submission:

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {

  int n;
  string s;
  string d = "Hoshina";
  cin >> n;
  cin.ignore();
  while (n--) {
    getline(cin, s);
    while (1) {
      unsigned int loc = s.find("Hoshino");
      if (loc != string::npos)
        s.replace(loc, d.size(), d);
      else
        break;
    }
    cout << s << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int main(void) {
  string check = "Hoshino";
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string str;
    if (i == 0)
      cin.ignore();
    getline(cin, str);
    if (str.length() < 7) {
      cout << str << endl;
      continue;
    }
    for (int j = 0; j < str.length() - 6; j++) {
      for (int k = 0; k < 7; k++) {
        // printf("%c %c\\n", check[k], str[j+k]);
        if (check[k] == str[j + k] && k < 6)
          continue;
        else if (check[k] == str[j + k] && k == 6) {
          str[j + k] = 'a';
        } else
          break;
      }
    }
    cout << str << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main(void) {
  string check = "Hoshino";
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string str;
    if (i == 0)
      cin.ignore();
    getline(cin, str);
    for (int j = 0; j < str.length() - 6; j++) {
      for (int k = 0; k < 7; k++) {
        // printf("%c %c\\n", check[k], str[j+k]);
        if (check[k] == str[j + k] && k < 6)
          continue;
        else if (check[k] == str[j + k] && k == 6) {
          str[j + k] = 'a';
        } else
          break;
      }
    }
    cout << str << endl;
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

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

using namespace std;

int main() {
  int n, i, j;
  ios::sync_with_stdio();
  string s;

  scanf("%d", &n);
  cin.get();
  for (i = 0; i < n; i++) {
    getline(cin, s);

    for (j = 0; j + 6 < 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.h>

using namespace std;

int main() {
  int n, i, j;
  ios::sync_with_stdio();
  string s;

  scanf("%d", &n);
  cin.get();
  for (i = 0; i < n; i++) {
    getline(cin, s);

    for (j = 0; s[j + 6] != '\\0'; j++) {
      if (s.substr(j, 7) == "Hoshino")
        s[j + 6] = 'a';
    }

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

#include <iostream>
using namespace std;

int n;
string A;

int main() {

  cin >> n;

  getline(cin, A);
  while (n--) {

    getline(cin, A);
    for (int i = 0; i < (int)A.size() - 6; i++) {

      if (A.substr(i, 7) == "Hoshino")
        A.replace(i, 7, "Hoshina");
    }
    cout << A << "\\n";
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int n;
string A;

int main() {

  cin >> n;

  getline(cin, A);
  while (n--) {

    getline(cin, A);
    for (int i = 0; i < A.length() - 6; i++) {

      if (A.substr(i, 7) == "Hoshino")
        A.replace(i, 7, "Hoshina");
    }
    cout << A << endl;
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int main() {
  int n;
  string s;
  cin >> n;
  getline(cin, s);
  rep(i, n) {
    getline(cin, s);
    for (int j = 7; j <= s.size(); j++) {
      if (s.substr(j - 7, 7) == "Hoshino")
        s[j - 1] = 'a';
    }
    cout << s << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int main() {
  int n;
  string s;
  cin >> n;
  getline(cin, s);
  rep(i, n) {
    getline(cin, s);
    rep(j, s.size() - 6) {
      if (s.substr(j, 7) == "Hoshino")
        s[j + 6] = 'a';
    }
    cout << s << 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() {
  char ho[8] = {'H', 'o', 's', 'h', 'i', 'n', 'o'};
  int n;
  string s;
  cin >> n;
  cin.ignore();
  while (n--) {
    getline(cin, s);
    int a = s.length();
    rep(i, a - 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';
        i += 6;
      }
    }
    cout << s << endl;
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main() {
  char ho[8] = {'H', 'o', 's', 'h', 'i', 'n', 'o'};
  int n;
  string s;
  cin >> n;
  cin.ignore();
  while (n--) {
    getline(cin, s);
    rep(i, s.size() - 6) {
      //			cout<<i<<endl;
      bool f = true;
      rep(j, 7) {
        if (s[i + j] != ho[j]) {
          f = false;
          break;
        }
      }
      if (f) {
        s[i + 1] = 'a';
      }
    }
    cout << s << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  getchar();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    for (int j = 0; j < (int)s.size() - 6; j++) {
      string hos = s.substr(j, 7);
      if (hos == "Hoshino") {
        s[j + 6] = 'a';
      }
    }
    cout << s << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  getchar();
  for (int i = 0; i < n; i++) {
    string s;
    getline(cin, s);
    for (int j = 0; j < s.size() - 6; j++) {
      string hos = s.substr(j, 7);
      if (hos == "Hoshino") {
        s[j + 6] = 'a';
      }
    }
    cout << s << endl;
  }
}
Problem p00101 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

int main(void) {
  char sentence[1050];
  int n;
  scanf("%d\\n", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 1050; j++) {
      sentence[j] = getchar();
      if (sentence[j] == '\\n') {
        sentence[j] = 0;
        break;
      }
    }
    for (int j = 0; j < 1025; i++) {
      if (sentence[j] == 0)
        break;
      if (!strncmp(sentence + j, "Hoshino", 7)) {
        sentence[j + 6] = 'a';
      }
    }
    puts(sentence);
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while (n--) {
    string s;
    getline(cin, s);
    if (s.length() >= 7) {
      for (int i = 0; i < s.length() - 6; i++) {
        if (s.substr(i, 7) == "Hoshino")
          s.replace(i, 7, "Hoshina");
      }
    }
    cout << s << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while (n--) {
    string s;
    getline(cin, s);
    for (int i = 0; i < s.length() - 6; i++) {
      if (s.substr(i, 7) == "Hoshino")
        s.replace(i, 7, "Hoshina");
    }
    cout << s << endl;
  }
  return 0;
}
Problem p00101 (C++) — buggy submission, verdict: Memory Limit Exceeded

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

using namespace std;

int main(void) {

  int n;
  string bun;
  char inp;

  cin >> n;
  getchar();
  for (int i = 0; i < n; i++) {
    bun = ("");
    while (1) {
      inp = getchar();
      if (inp == '\\n')
        break;
      bun += inp;
    }
    for (int cnt = 6; cnt <= bun.length() - 1; cnt++) {
      if (bun[cnt] == 'o' && bun[cnt - 1] == 'n' && bun[cnt - 2] == 'i' &&
          bun[cnt - 3] == 'h' && bun[cnt - 4] == 's' && bun[cnt - 5] == 'o' &&
          bun[cnt - 6] == 'H')
        bun[cnt] = 'a';
    }
    cout << bun << endl;
  }

  return 0;
}

Error: MLE

Fixed submission:

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

using namespace std;

int main(void) {
  std::ios_base::sync_with_stdio(false);

  int n;
  string bun;
  char inp;

  cin >> n;
  getchar();
  for (int i = 0; i < n; i++) {
    bun = ("");
    while (1) {
      inp = getchar();
      if (inp == '\\n')
        break;
      bun += inp;
    }
    for (int cnt = 7; cnt < bun.length(); cnt++) {
      if (bun[cnt] == 'o' && bun[cnt - 1] == 'n' && bun[cnt - 2] == 'i' &&
          bun[cnt - 3] == 'h' && bun[cnt - 4] == 's' && bun[cnt - 5] == 'o' &&
          bun[cnt - 6] == 'H')
        bun[cnt] = 'a';
    }
    cout << bun << endl;
  }

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

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

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while (n--) {
    string s, t, u;
    getline(cin, s);
    t = "Hoshino";
    u = "Hoshina";
    for (int i = 0; i < s.size(); ++i) {
      if (s.substr(i, t.size()) == t) {
        cout << u;
        i += t.size() - 1;
      } else {
        cout << s[i];
      }
    }
    cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main(void) {
  int n;
  string str;

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

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

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

int main(void) {
  int n;
  string str;

  cin >> n;
  cin.ignore();
  while (n--) {
    getline(cin, str);
    for (int i = 0; i < str.size(); i++) {
      if (str.substr(i, 7) == "Hoshino")
        str[i + 6] = 'a';
    }
    cout << str << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main(void) {
  int n;
  string str;

  cin >> n;
  cin.ignore();
  while (n--) {
    getline(cin, str);
    for (int i = 0; i < str.size() - 6; i++) {
      if (str.substr(i, 7) == "Hoshino")
        str[i + 6] = 'a';
    }
    cout << str << endl;
  }

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

#include <iostream>
#include <string>

int main() {
  const std::string str_false = "Hoshino";
  const std::string str_true = "Hoshina";

  u_int num_of_data;
  std::string text;
  std::cin >> num_of_data;
  std::cin.ignore();

  for (u_int i = 0; i < num_of_data; ++i) {
    getline(std::cin, text);
    int index = 0;

    while ((index = text.find(str_false, index)) != (int)std::string::npos)
      text.replace(index, str_false.size(), str_true);
    std::cout << text << std::endl;
  }

  return 0;
}

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


Fixed submission:

#include <iostream>
#include <string>

int main() {
  const std::string str_false = "Hoshino";
  const std::string str_true = "Hoshina";

  u_int num_of_data;
  std::string text;
  std::cin >> num_of_data;
  std::cin.ignore();

  for (u_int i = 0; i < num_of_data; ++i) {
    getline(std::cin, text);
    u_int index;

    while ((index = text.find(str_false, index)) != std::string::npos)
      text.replace(index, str_false.size(), str_true);
    std::cout << text << std::endl;
  }

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

#include <iostream>
#include <string>

int main() {
  const std::string str_false = "Hoshino";
  const std::string str_true = "Hoshina";

  u_int num_of_data;
  std::string text;
  std::cin >> num_of_data;
  std::cin.ignore();

  for (u_int i = 0; i < num_of_data; ++i) {
    getline(std::cin, text);
    int index = 0;

    while ((index = text.find(str_false, index)) != std::string::npos)
      text.replace(index, str_false.size(), str_true);
    std::cout << text << std::endl;
  }

  return 0;
}

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


Fixed submission:

#include <iostream>
#include <string>

int main() {
  const std::string str_false = "Hoshino";
  const std::string str_true = "Hoshina";

  u_int num_of_data;
  std::string text;
  std::cin >> num_of_data;
  std::cin.ignore();

  for (u_int i = 0; i < num_of_data; ++i) {
    getline(std::cin, text);
    u_int index = 0;

    while ((index = text.find(str_false, index)) != std::string::npos)
      text.replace(index, str_false.size(), str_true);
    std::cout << text << std::endl;
  }

  return 0;
}