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

#include <bits/stdc++.h>
using namespace std;
string s, st, stt;
bool check(string str) {
  if (str.size() % 2) {
    string s1 = "";
    string s2 = "";
    int i = 0, j = str.size() - 1;
    while (i <= (s.size() - 2) / 2 && j >= str.size() / 2 + 1) {
      s1 += str[i];
      s2 += str[j];
      i++;
      j--;
    }
    if (s1 == s2)
      return true;
    else
      return false;
  } else {
    string s1 = "";
    string s2 = "";
    int i = 0, j = str.size() - 1;
    while (i <= (s.size() - 1) / 2 && j >= (str.size() - 1) / 2 + 1) {
      s1 += str[i];
      s2 += str[j];
      i++;
      j--;
    }
    if (s1 == s2)
      return true;
    else
      return false;
  }
}
int main() {

  cin >> s;
  st = "";
  stt = "";
  for (int i = 0; i < s.size(); i++) {
    if (i < (s.size() - 1) / 2)
      st += s[i];
    if (i >= (s.size() + 3) / 2 - 1)
      stt += s[i];
  }
  // cout<<st<<" "<<stt;

  if (check(s) == true && check(st) == true && check(stt) == true)
    cout << "Yes";
  else
    cout << "No";
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
string s, st, stt;
bool check(string str) {
  if (str.size() % 2) {
    string s1 = "";
    string s2 = "";
    for (int i = 0; i <= (str.size() - 2) / 2; i++) {
      s1 += str[i];
    }
    for (int i = str.size() - 1; i >= str.size() / 2 + 1; i--) {
      s2 += str[i];
    }
    if (s1 == s2)
      return true;
    else
      return false;
  } else {
    string s1 = "";
    string s2 = "";
    for (int i = 0; i <= (str.size() - 1) / 2; i++) {
      s1 += str[i];
    }
    for (int i = str.size() - 1; i >= (str.size() - 1) / 2 + 1; i--) {
      s2 += str[i];
    }
    if (s1 == s2)
      return true;
    else
      return false;
  }
}
int main() {

  cin >> s;
  st = "";
  stt = "";
  for (int i = 0; i < (s.size() - 1) / 2; i++)
    st += s[i];
  for (int i = (s.size() + 3) / 2 - 1; i < s.size(); i++)
    stt += s[i];

  if (check(s) == true && check(st) == true && check(stt) == true)
    cout << "Yes";
  else
    cout << "No";
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string str, a, b, ans = "Yes";
  int l;
  cin >> str;
  l = str.size();
  a = str.substr(0, (l - 1) / 2);
  b = str.substr((l + 3) / 2 - 1, l);
  if (a != b)
    ans = "No";
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string str;
  int l;
  cin >> str;
  l = (str.size() - 1) / 2;
  for (int i = 0; i < (l) / 2; i++) {
    if (str[i] != str[l - (i + 1)]) {
      // cout << str[i] << ' ' << str[l-(i+1)] << endl;
      cout << "No" << endl;
      exit(1);
    }
  }
  l = (str.size() + 3) / 2;
  for (int i = l; i < (str.size() - l) / 2; i++) {
    if (str[i] != str[l - (i + 1)]) {
      // cout << str[i] << ' ' << str[l-(i+1)] << endl;
      cout << "No" << endl;
      exit(1);
    }
  }

  cout << "Yes" << endl;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int i, sw, l, c;
  sw = 0;
  c = 0;
  l = s.size();

  for (i = 0; i < l; ++i) {
    if (s.at(i) == s.at(l - 1 - i))
      sw++;
  }
  if (sw == l) {
    c++;
  }
  sw = 0;

  for (i = 0; i < (l - 1) / 2; ++i) {
    if (s.at(i) == s.at((l - 1) / 2 - 1 - i))
      sw++;
  }
  if (sw == (l - 1) / 2) {
    c++;
  }
  sw = 0;

  for (i = 0; i < (l - 3) / 2; ++i) {
    if (s.at((l + 1) / 2 + i) == s.at(l - 1 - i))
      sw++;
  }
  if (sw == (l - 3) / 2) {
    c++;
  }
  sw = 0;

  if (c == 3)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}

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


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int i, sw, l, c;
  sw = 0;
  c = 0;
  l = s.size();

  for (i = 0; i < l; ++i) {
    if (s.at(i) == s.at(l - 1 - i))
      sw++;
  }
  if (sw == l)
    c++;
  sw = 0;

  for (i = 0; i < (l - 1) / 2; ++i) {
    if (s.at(i) == s.at((l - 1) / 2 - 1 - i))
      sw++;
  }
  if (sw == (l - 1) / 2)
    c++;
  sw = 0;

  for (i = (l + 1) / 2; i < l; ++i) {
    if (s.at(i) == s.at((l - i) + (l + 1) / 2))
      sw++;
  }
  if (sw == l)
    c++;
  sw = 0;

  if (c == 3)
    cout << "Yes";
  else
    cout << "No";

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

#include <iostream>
#include <string>

using namespace std;

bool sample(string s) {
  string t(s.rbegin(), s.rend());
  return s == t;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (sample(s) && sample(s.substr(0, (n - 1) / 2)) &&
      sample(s.substr((n + 1) / 2))) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  int N, i;
  string s;
  cin >> s;

  N = s.length();

  for (i = 1; i <= N; i++) {
    if (s[i] == s[N - i - 1])
      continue;
    else {
      cout << "No";
      return -1;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string a;
  cin >> a;
  ll b = a.size();
  ll c = (b - 1) / 2;
  for (ll i = 0; i < c / 2 + 1; i++) {
    if (a.at(i) != a.at(c - i - 1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (ll i = 0; i < c + 1; i++) {
    if (a.at(i) != a.at(c - i + c)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string a;
  cin >> a;
  ll b = a.size();
  ll c = (b - 1) / 2;
  for (ll i = 0; i < c / 2 + 2; i++) {
    if (a.at(i) != a.at(c - i - 1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (ll i = 0; i < c / 2 + 2; i++) {
    if (a.at(i + c + 1) != a.at(c - i + c)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

bool isKaibun(string s) {
  for (int i = 0; i < s.length() / 2; i++) {
    if (s[i] != s[s.length() - 1 - i])
      return false;
  }
  return true;
}

int main() {

  string str;
  cin >> str;
  int n = str.length();
  bool f1 = false, f2 = false, f3 = false;
  if (isKaibun(str))
    f1 = true;
  if (isKaibun(str.substr(0, (n - 1) / 2)))
    f2 = true;
  if (isKaibun(str.substr((((n + 3) / 2) - 1), n)))
    f3 = true;

  if (f1 && f2 && f3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Error: WA

Fixed submission:

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

bool huiwen(string s, int low, int high) {
  if (s[low] != s[high]) {
    return false;
  }
  if (low == high || low == high - 1) {
    return true;
  }
  return huiwen(s, low + 1, high - 1);
}
bool judge(string str) {
  int l = str.length();
  int i, j;
  int flag = 0;
  if (l < 7)
    return false;
  else {

    for (i = 0, j = ((l - 1) / 2) - 1; i <= j; i++, j--) {
      huiwen(str, i, j);
    }

    for (i = ((l + 3) / 2) - 1, j = l - 1; i <= j; i++, j--) {
      huiwen(str, i, j);
    }
  }
}
bool input(string str) {
  int l = str.length();
  int i, j;
  for (i = 0; i < l; i++) {
    if (str[i] >= 'a' && str[i] <= 'z')
      return true;
    else
      return false;
  }
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool res = huiwen(s, 0, n - 1);
  bool flag = judge(s);
  bool ks = input(s);
  if (res == 1 && flag == 1 && ks == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, N) for (ll(i) = 0; (i) < (N); (i)++)
const int mod = 1000000007;

bool judge(string s) {
  bool res = true;
  int r = s.length() - 1;
  for (int i = 0; i < r; ++i) {
    if (s[i] != s[r])
      res = false;
    --r;
  }
  return res;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  string left = "";
  string right = "";
  for (int i = 0; i < (n - 1) / 2; ++i) {
    left += s[i];
  }
  for (int i = (n + 2) / 2; i < n; ++i) {
    right += s[i];
  }
  // cout << left << ' ' << right << endl;
  bool ans1 = judge(s);
  bool ans2 = judge(left);
  bool ans3 = judge(right);
  if (ans1 && ans2 && ans3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, N) for (ll(i) = 0; (i) < (N); (i)++)
const int mod = 1000000007;

bool judge(string s) {
  bool res = true;
  int r = s.length() - 1;
  for (int i = 0; i != r; ++i) {
    if (s[i] != s[r])
      res = false;
    --r;
  }
  return res;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  string left = "";
  string right = "";
  for (int i = 0; i < (n - 1) / 2; ++i) {
    left += s[i];
  }
  for (int i = (n + 2) / 2; i < n; ++i) {
    right += s[i];
  }
  bool ans1 = judge(s);
  bool ans2 = judge(left);
  bool ans3 = judge(right);
  if (ans1 && ans2 && ans3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
bool ispal(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i])
      return false;
  }
  return true;
}
int main() {
  string S;
  cin >> S;
  int N = S.length();
  if (ispal(S) && ispal(S.substr(0, (N - 1) / 2)) &&
      ispal(S.substr((N + 3) / 2 - 1, (N - 3) / 2 + 1)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
bool ispal(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i])
      return false;
  }
  return true;
}
int main() {
  string S;
  cin >> S;
  int N = S.length();
  if (ispal(S) && ispal(S.substr(0, (N - 1) / 2)) &&
      ispal(S.substr((N + 3) / 2 + 1, (N - 3) / 2 + 1)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

bool loop(string s) {
  int cont = 0;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] == s[s.size() - i - 1]) {
      cont++;
    } else {
      break;
    }
  }

  if (cont == s.size() / 2) {
    return true;
  } else {
    return false;
  }
}

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

  bool a = loop(s);
  bool first = loop(s.substr(0, s.size() / 2));
  bool end = loop(s.substr(s.size() / 2 + 1));

  if (a && first && end) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Error: 0

Fixed submission:

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

bool loop(string s) {
  if (s.size() == 1)
    return true;
  int cont = 0;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] == s[s.size() - i - 1]) {
      cont++;
    } else {
      break;
    }
  }

  if (cont == s.size() / 2) {
    string first = s.substr(0, s.size() / 2);
    string end = s.substr(s.size() / 2 + 1);
    bool f = loop(first);
    bool s = loop(end);
    if (f && s) {
      return true;
    } else {
      return false;
    }
  } else {
    return false;
  }
}

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

  bool f = loop(s);

  if (f) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

bool round_word(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++) {
    if (s.at(i) != s.at(n - 1 - i)) {
      return false;
    }
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  if (round_word(s) && round_word(s.substr(0, (n - 1) / 2)) &&
      round_word(s.substr((n + 3) / 2 - 1))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

bool round_word(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++) {
    if (s.at(i) != s.at(n - 1 - i)) {
      return false;
    }
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  if (round_word(s) && round_word(s.substr(0, (n - 1) / 2)) &&
      round_word(s.substr((n + 3) / 2 + 1))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

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

#include <iostream>
using namespace std;

bool is_palindrome(string s) {
  string t(s.rbegin(), s.rend());
  return s == t;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (is_palindrome(s) && is_palindrome(s.substr(0, (n - 1) / 2)) &&
      is_palindrome(s.substr((n + 1) / 2))) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}


Error: WA

Fixed submission:

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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  int wer = 0;
  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j >= 0; j--) {
      if (S.at(i) != S.at(j)) {
        ans++;
      }
    }
  }
  if (ans != 0) {
    cout << "No" << endl;
  } else {
    for (int i = 0; i < (N - 1) / 2; i++) {
      for (int j = (N - 1) / 2; j >= 0; j--) {
        if (S.at(i) != S.at(j)) {
          wer++;
        }
      }
    }
    for (int i = (N + 3) / 2; i < N; i++) {
      for (int j = N; j >= (N + 3) / 2; j--) {
        if (S.at(i) != S.at(j)) {
          wer++;
        }
      }
    }
    if (wer != 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

bool kaibun(string s) {
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] != s[n - i - 1]) {
      return false;
    }
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  if (kaibun(s) && kaibun(s.substr(0, (n - 1) / 2)) &&
      kaibun(s.substr(((n + 3) / 2) - 1))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Error: 0

Fixed submission:

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

bool kaibun(string s) {
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] != s[n - i - 1]) {
      return false;
    }
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  if (kaibun(s) && kaibun(s.substr(0, (n - 1) / 2)) &&
      kaibun(s.substr(((n + 3) / 2) + 1))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string S;
  cin >> S;
  bool t = true;
  int n = 0;
  int last;
  int size = (int)S.size();
  last = size - 1;
  while (1) {
    if (n == last)
      break;
    if (S[n] != S[last]) {
      cout << "No";
      return 0;
    }
    ++n;
    --last;
  }
  n = 0;
  int lasta;
  lasta = (size - 1) / 2 - 1;
  while (1) {
    if (n == lasta)
      break;
    if (S[n] != S[lasta]) {
      cout << "No";
      return 0;
    }
    if (lasta - n == 1)
      break;
    ++n;
    --lasta;
  }
  int start;
  start = (size + 3) / 2 - 1;
  last = size - 1;
  while (1) {
    if (start == last)
      break;
    if (S[start] != S[last]) {
      cout << "No";
      return 0;
    }
    if (last - start == 1)
      break;
    ++start;
    --last;
  }
  if (t)
    cout << "Yes";
  if (t == false)
    cout << "No";
}


Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  string S;
  cin >> S;
  bool t = true;
  int n = 0;
  int last;
  last = S.size();
  while (1) {
    if (n == last)
      break;
    if (S[n] != S[last])
      t = false;
    ++n;
    --last;
  }
  n = 0;
  int lasta;
  lasta = (S.size() - 1) / 2;
  while (1) {
    if (n == lasta)
      break;
    if (S[n] != S[lasta])
      t = false;
    ++n;
    --lasta;
  }
  int start;
  start = (S.size() + 3) / 2;
  last = S.size();
  while (1) {
    if (start == last)
      break;
    if (S[start] != S[last])
      t = false;
    ++start;
    --last;
  }
  if (t)
    cout << "Yes";
  if (t == false)
    cout << "No";
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long n, i, j, k, count = 0, ans = 0, x, a, b, c;
  string s;
  cin >> s;
  n = s.length();
  if (n == 1) {
    cout << "Yes";
    return 0;
  }
  for (i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1])
      count = 1;
  }
  if (n <= 3) {
    if (count == 1)
      cout << "No";
    else
      cout << "Yes";
    return 0;
  }
  x = (n - 1) / 2;
  for (i = 0; i < x / 2; i++) {
    if (s[i] != s[x - i - 1])
      count = 1;
  }
  x = (n + 3) / 2;
  x--;
  i = x;
  j = n - 1;
  while (i >= j) {
    if (s[i] != s[j])
      count = 1;
    i++;
    j--;
  }
  if (count == 1)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}

Error: WA

Fixed submission:

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

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long n, i, j, k, count = 0, ans = 0, x, a, b, c;
  string s;
  cin >> s;
  n = s.length();
  for (i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1])
      count = 1;
  }
  x = (n - 1) / 2;
  for (i = 0; i < x / 2; i++) {
    if (s[i] != s[x - i - 1])
      count = 1;
  }
  x = (n + 3) / 2;
  x--;
  i = x;
  j = n - 1;
  while (i >= j) {
    if (s[i] != s[j])
      count = 1;
    i++;
    j--;
  }
  if (count == 1)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
Problem p02730 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <string.h>
bool f(char *s, int i, int j) {
  int t = j / 2;
  for (int k = i; k <= t; k++) {
    if (s[k] != s[j - k + 1])
      return 0;
  }
  return 1;
}
int main() {
  char s[10000] = {'a'};
  scanf("%s", s + 1);
  int N = strlen(s) - 1;
  if (f(s, 1, (N - 1) / 2) && f(s, (N + 3) / 2, N) && f(s, 1, N))
    printf("Yes\\n");
  else
    printf("No\\n");
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>
bool f(char *s, int i, int j) {
  int t = j / 2; // 1 2 3
  for (int k = i; k <= t; k++) {
    if (s[k] != s[j - k + 1])
      return 0;
  }
  return 1;
}
int main() {
  char s[1000];
  while (scanf("%s", s + 1)) {
    int N = strlen(s) - 1;
    printf("%d\\n", f(s, 1, (N - 1) / 2) && f(s, (N + 3) / 2, N) && f(s, 1, N));
  }
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string s;
  cin >> s;
  int n = s.size(), m = 1;
  int nn = (n - 1) / 2;
  vector<char> t(n), ss(nn), tt(nn);

  for (int i = 0; i < n; i++) {
    t.at(i) = s.at(n - 1 - i);
  }
  for (int i = 0; i < nn; i++) {
    ss.at(i) = s.at(i);
    tt.at(i) = s.at(n - 1 - i);
  }

  for (int i = 0; i < n; i++) {
    if (s.at(i) != t.at(i)) {
      m = -1;
      break;
    }
  }
  for (int i = 0; i < nn; i++) {
    if (ss.at(i) != ss.at(nn - 1 - i)) {
      m = -1;
      break;
    }
  }
  for (int i = 0; i < nn; i++) {
    if (tt.at(i) != tt.at(nn - 1 - i)) {
      m = -1;
      break;
    }
  }

  if (m > 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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


Fixed submission:

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

int main() {
  string s, t, ss, tt;
  cin >> s;
  int n = s.size(), m = 1;
  for (int i = 0; i < n; i++) {
    t.at(i) = s.at(n - 1 - i);
  }
  for (int i = 0; i < (n - 1) / 2; i++) {
    ss.at(i) = s.at(i);
    tt.at(i) = s.at(n - 1 - i);
  }

  for (int i = 0; i < n; i++) {
    if (s.at(i) != t.at(i)) {
      m = -1;
      break;
    }
  }
  for (int i = 0; i < (n - 1) / 2; i++) {
    if (ss.at(i) == tt.at(i)) {
      m = -1;
      break;
    }
  }

  if (m > 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

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

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

int main() {
  string S;
  cin >> S;
  int n = (S.size() - 1) / 2;
  bool ans = 1;
  for (int i = 0; i < (n + 1) / 2; i++) {
    if (S.at(i) != S.at(n - 1 - i) || S.at(i) != S.at(n + 1 + i) ||
        S.at(i) != S.at(S.size() - 1 - i)) {
      ans = 0;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}


Error: WA

Fixed submission:

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

int main() {
  string S;
  cin >> S;
  int n = (S.size() - 1) / 2;
  bool ans = 1;
  for (int i = 0; i < (n + 1) / 2; i++) {
    if (S.at(i) != S.at(n - 1 - i) || S.at(i) != S.at(n + 1 + 1) ||
        S.at(i) != S.at(S.size() - 1 - i)) {
      ans = 0;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define ll long long
#define gcd(a, b) __gcd(a, b)
#define pi 2 * acos(0.0)
// use emplace_back() instead of push_back()
template <typename T> void print(T t) {
  for (const auto &e : t)
    cout << e << " ";
  cout << endl;
}
bool isPalindrome(string str) {
  // Start from leftmost and rightmost corners of str
  int l = 0;
  int h = str.size() - 1;

  // Keep comparing characters while they are same
  while (h > l) {
    if (str[l++] != str[h--]) {
      return false;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  ll t, n, b, m;
  string s, s1, s2;
  cin >> s;
  s1 = "";
  s2 = "";
  n = s.size();
  for (ll i = 0; i < (n - 1) / 2; i++)
    s1 += s[i];
  for (ll i = ((n + 3) / 2) - 1; i < n; i++)
    s2 += s[i];
  if (!isPalindrome(s))
    cout << "No\\n";
  else if (!isPalindrome(s1)) {
    cout << "No\\n";
  } else if (!isPalindrome(s2)) {
    cout << "No\\n";
  } else
    cout << "Yes\\n";
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define ll long long
#define gcd(a, b) __gcd(a, b)
#define pi 2 * acos(0.0)
// use emplace_back() instead of push_back()
template <typename T> void print(T t) {
  for (const auto &e : t)
    cout << e << " ";
  cout << endl;
}
bool isPalindrome(string str) {
  // Start from leftmost and rightmost corners of str
  int l = 0;
  int h = str.size() - 1;

  // Keep comparing characters while they are same
  while (h > l) {
    if (str[l++] != str[h--]) {
      return false;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll t, n, b, m;
  string s, s1, s2;
  cin >> s;
  s1 = "";
  s2 = "";
  n = s.size();
  for (ll i = 0; i < (n - 1) / 2; i++)
    s1 += s[i];
  for (ll i = ((n + 3) / 2) - 1; i < n; i++)
    s2 += s[i];
  if (!isPalindrome(s))
    cout << "NO\\n";
  else if (!isPalindrome(s1)) {
    cout << "NO\\n";
  } else if (!isPalindrome(s2)) {
    cout << "NO\\n";
  } else
    cout << "YES\\n";
  return 0;
}