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

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

int main() {
  string M;
  cin >> M;
  int N = M.size();
  bool A = true;
  for (int i = 0; i < N; i++) {
    if (!(M.at(i) == M.at(N - 1 - i))) {
      A = false;
    }
    if ((i == (N - 1 - i)) || (i == N / 2)) {
      break;
    }
  }
  for (int i = 0; i < N; i++) {
    if (!(M.at(i) == M.at(((N - 1) / 2) - 1 - i))) {
      A = false;
    }
    if (i == (((N - 1) / 2) - 1 - i) || (N / 4)) {
      break;
    }
  }

  for (int i = 0; i < N; i++) {
    if (!(M.at(((N + 3) / 2) - 1 + i) == M.at((N - 1) - i))) {
      A = false;
    }
    if (((((N + 3) / 2) - 1 + i) == ((N - 1) - i)) || N / 4) {
      break;
    }
  }

  if (A == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Error: 0

Fixed submission:

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

int main() {
  string M;
  cin >> M;
  int N = M.size();
  bool A = true;
  for (int i = 0; i < N; i++) {
    if (!(M.at(i) == M.at(N - 1 - i))) {
      A = false;
    }
    if (i == (N - 1 - i)) {
      break;
    }
  }
  for (int i = 0; i < N; i++) {
    if (!(M.at(i) == M.at(((N - 1) / 2) - 1 - i))) {
      A = false;
    }
    if (i == (((N - 1) / 2) - 1 - i)) {
      break;
    }
  }

  for (int i = 0; i < N; i++) {
    if (!(M.at(((N + 3) / 2) - 1 + i) == M.at((N - 1) - i))) {
      A = false;
    }
    if ((((N + 3) / 2) - 1 + i) == ((N - 1) - i)) {
      break;
    }
  }

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

#include <iostream>
using namespace std;

int main() {
  string s, zeihan, kouhan, condition;
  int n;
  cin >> s;
  n = s.size();

  for (int i = 0; i < (n - 1) / 2; i++) {
    if (s[i] != s[n - i - 1]) {
      cout << "No" << endl;
      return 0;
    }
  }

  zeihan = s.substr(0, (n - 1) / 2);
  kouhan = s.substr((n + 1) / 2, n - 1);

  int k;

  if (((n - 1) / 2) % 2 == 1) {
    k = (((n - 1) / 2) - 1) / 2;
  } else {
    k = ((n - 1) / 2) / 2;
  }

  for (int i = 0; i < k; i++) {
    if (zeihan[i] != zeihan[(n - 1) / 2 - i - 1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  string s, zeihan, kouhan, condition;
  int n;
  cin >> s;
  n = s.size();

  for (int i = 0; i < (n - 1) / 2; i++) {
    if (s[i] != s[n - i - 1]) {
      cout << "No" << endl;
      exit(1);
    }
  }

  zeihan = s.substr(0, (n - 1) / 2);
  kouhan = s.substr((n + 1) / 2, n - 1);

  int k;

  if (((n - 1) / 2) % 2 == 1) {
    k = (((n - 1) / 2) - 1) / 2;
  } else {
    k = ((n - 1) / 2) / 2;
  }

  for (int i = 0; i < k; i++) {
    if (zeihan[i] != zeihan[(n - 1) / 2 - i - 1]) {
      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 t = s.size();
  int f = (t - 1) / 2;
  int l = (t + 3) / 2;

  string fs;
  string ls;

  for (int i = 0; i < f; ++i) {
    fs += s[i];
  }

  for (int i = l - 1; i < t; ++i) {
    ls += s[i];
  }

  if (fs == ls)
    puts("Yes");
  else
    puts("No");
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 4) >= this->size() (which is 3)


Fixed submission:

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

int main() {
  string S;
  cin >> S;
  int N, i;
  N = S.size();

  bool f = false;

  vector<char> a((N - 1) / 2);
  vector<char> b((N - 1) / 2);
  vector<char> vec(N);

  for (i = 0; i < N; i++) {
    vec.at(i) = S.at(i);
  }
  for (i = 0; i < ((N - 1) / 2 - 1); i++) {
    a.at(i) = vec.at(i);
  }

  for (i = ((N - 1) / 2 + 1); i < N; i++) {
    b.at(i) = vec.at(i);
  }

  if (a == b) {
    f = true;
  }

  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)
const int INF = 2147483647; // int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  string r = "";
  for (int i = n - 1; i >= 0; i--)
    r += s[i];
  if (s == r) {
    string f = "";
    for (int i = (n - 1) / 2 - 1; i >= 0; i--)
      f += s[i];
    if (f == s.substr(0, (n - 1) / 2)) {
      string b = "";
      for (int i = n - 1; i >= (n + 3) / 2 - 1; i--)
        b += s[i];
      string c = s.substr((n + 3) / 2 - 1);
      if (b == c) {
        cout << "Yes\\n";
        return 0;
      }
    }
  }
  cout << "No\\n";
  return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647; // int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  string re_s = s;
  reverse(re_s.begin(), re_s.end());
  if (s == re_s) {
    int n = s.length();
    string b = s.substr(0, (n - 1) / 2);
    string re_b = b;
    reverse(re_b.begin(), re_b.end());
    if (b == re_b) {
      string f = s.substr((n + 3) / 2 + 1);
      string re_f = f;
      reverse(re_f.begin(), re_f.end());
      if (f == re_f) {
        cout << "Yes\\n";
        return 0;
      }
    }
  }
  cout << "No\\n";
  return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/
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();

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

  if (judge) {
    for (int i = 0; i < n / 2; i++) {
      if (s.at(i) != s.at((n - 1) / 2 - 1 - i)) {
        judge = false;
        break;
      }
    }
  }

  if (judge) {
    int j = 0;
    for (int i = (n + 3) / 2 - 1; i < n; i++) {
      if (s.at(i) != s.at(n - 1 - j)) {
        judge = false;
        break;
      }
      j++;
    }
  }
  if (judge) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


Fixed submission:

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

int main() {
  string s;
  cin >> s;
  int n = s.size();

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

  if (judge) {
    for (int i = 0; i < (n - 1) / 4; i++) {
      if (s.at(i) != s.at((n - 1) / 2 - 1 - n)) {
        judge = false;
        break;
      }
    }
  }

  if (judge) {
    int j = 0;
    for (int i = (n + 3) / 2 - 1; i < n; i++) {
      if (s.at(i) != s.at(n - 1 - j)) {
        judge = false;
        break;
      }
      j++;
    }
  }
  if (judge) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
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();
  if (S.substr(0, (N - 1) / 2) == S.substr((N + 3) / 2 - 1, (N - 1) / 2)) {

    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;

  cin >> S;
  int N = S.size();
  string a;
  string b;
  for (int i = 0; i < (N - 1) / 2; i++) {
    a += S.at(i);

    for (int j = 0; j < (N - 1) / 2; j++) {
      b += S.at(N - 1 - j);
      if (a.at(i) == b.at(N - 1 - j) && i == j) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  char S[100];
  char mae[50] = {};
  char ato[50] = {};
  char mae_mae[25] = {};
  char mae_ato[25] = {};
  char ato_mae[25] = {};
  char ato_ato[25] = {};

  scanf("%s", &S);

  strncpy(mae, S, (strlen(S) - 1) / 2);
  for (int i = 0; i < (strlen(S) - 1) / 2; ++i) {
    ato[i] = S[(strlen(S) - 1 - i)];
  }
  if (strcmp(mae, ato) != 0) {
    printf("No");
    return 0;
  }

  if (strlen(mae) % 2 == 1) {
    strncpy(mae_mae, mae, (strlen(mae) - 1) / 2);
    strncpy(ato_mae, ato, (strlen(ato) - 1) / 2);
    for (int i = 0; i < (strlen(mae) - 1) / 2; ++i) {
      mae_ato[i] = S[(strlen(mae) - 1 - i)];
      ato_ato[i] = S[(strlen(mae) - 1 - i)];
    }

  } else {
    strncpy(mae_mae, mae, strlen(mae) / 2);
    strncpy(ato_mae, ato, strlen(ato) / 2);
    for (int i = 0; i < (strlen(mae)) / 2; ++i) {
      mae_ato[i] = S[(strlen(mae) - 1 - i)];
      ato_ato[i] = S[(strlen(mae) - 1 - i)];
    }
  }

  if (strcmp(mae_mae, mae_ato) != 0 || strcmp(ato_mae, ato_ato) != 0) {
    printf("No");
    return 0;
  } else {
    printf("Yes");
    return 0;
  }
}

int A() {
  int N, M;
  int ans;
  scanf("%d %d", &N, &M);

  ans = (N - 1) * N / 2 + (M - 1) * M / 2;
  printf("%d", ans);

  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  char S[100];
  char mae[50] = {};
  char ato[50] = {};
  char mae_mae[25] = {};
  char mae_ato[25] = {};
  char ato_mae[25] = {};
  char ato_ato[25] = {};

  scanf("%s", &S);

  strncpy(mae, S, (strlen(S) - 1) / 2);
  for (int i = 0; i < (strlen(S) - 1) / 2; ++i) {
    ato[i] = S[(strlen(S) - 1 - i)];
  }
  if (strcmp(mae, ato) != 0) {
    printf("No");
    return 0;
  }

  if (strlen(mae) % 2 == 1) {
    strncpy(mae_mae, mae, (strlen(mae) - 1) / 2);
    strncpy(ato_mae, ato, (strlen(ato) - 1) / 2);
    for (int i = 0; i < (strlen(mae) - 1) / 2; ++i) {
      mae_ato[i] = S[(strlen(mae) - 1 - i)];
      ato_ato[i] = S[(strlen(mae) - 1 - i)];
    }

  } else {
    strncpy(mae_mae, mae, strlen(mae) / 2);
    strncpy(ato_mae, ato, strlen(ato) / 2);
    for (int i = 0; i < (strlen(mae)) / 2; ++i) {
      strncpy(mae_ato, mae + strlen(mae) / 2 + 1, strlen(mae));
      strncpy(ato_ato, ato + strlen(ato) / 2 + 1, strlen(ato));
    }
  }

  if (strcmp(mae_mae, mae_ato) != 0 || strcmp(ato_mae, ato_ato) != 0) {
    printf("No");
    return 0;
  } else {
    printf("Yes");
    return 0;
  }
}

int A() {
  int N, M;
  int ans;
  scanf("%d %d", &N, &M);

  ans = (N - 1) * N / 2 + (M - 1) * M / 2;
  printf("%d", ans);

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

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define rept(i, a, b) for (int i = a; i < b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;

bool isPalindrome(const string &s) {
  stack<char> q;
  string ans;
  if (s.size() % 2 == 1)
    ans = s.substr(0, (s.size() - 1) / 2) +
          s.substr((s.size() + 1) / 2, (s.size() - 1) / 2);
  else
    ans = s;
  int N = ans.size();
  rep(i, N / 2) {
    q.push(ans[i]);
    // out("push " << ans[i]);
  }
  rept(i, N / 2, ans.size()) {
    // out("check " << ans[i]);
    if (q.top() != ans[i])
      return false;
    q.pop();
  }
  return true;
}

int main() {
  // out(isPalindrome("akasaka"));
  // out(isPalindrome("prdrp"));
  // out(isPalindrome("abbalabba"));
  // out(isPalindrome("lassal"));
  string S;
  in(S);
  // out(S.substr(0, (S.size()-1)/2));
  // out(S.substr((S.size()+1)/2, (S.size()-1)/2));
  if (isPalindrome(S) && isPalindrome(S.substr(0, (S.size() - 1) / 2)) &&
      isPalindrome(S.substr((S.size() + 1) / 2, (S.size() - 1) / 2)))
    out("Yes");
  else
    out("No");

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define rept(i, a, b) for (int i = a; i < b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;

bool isPalindrome(const string &s) {
  stack<char> q;
  int N = s.size();
  string ans;
  if (N % 2 == 1)
    ans = s.substr(0, (N - 1) / 2) + s.substr((N + 1) / 2, (N - 1) / 2);
  rep(i, (N - 1) / 2) { q.push(ans[i]); }
  rept(i, (N - 1) / 2, N - 1) {
    if (q.top() != ans[i])
      return false;
    q.pop();
  }
  return true;
}

int main() {
  string S;
  in(S);
  if (isPalindrome(S) && isPalindrome(S.substr(0, (S.size() - 1) / 2)) &&
      isPalindrome(S.substr((S.size() + 1) / 2, (S.size() - 1) / 2)))
    out("Yes");
  else
    out("No");

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

#include <bits/stdc++.h>

#define REP(i, s, N) for (int i = s; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

bool judge(string str) {
  string str1 = str;
  reverse(str.begin(), str.end());
  return str == str1;
}

int main() {
  string S;
  cin >> S;
  int N = S.length();
  string S2 = S.substr(0, (N - 1) / 2);
  string S3 = S.substr((N + 3) / 2 - 1);

  if (judge(S) && judge(S2) && judge(S3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define REP(i, s, N) for (int i = s; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

bool judge(string str) {
  bool a = true;
  int h = str.length() / 2;

  if (str.length() == 1) {
    a = true;
    //}else if(str.length()%2==0){
    //  a = false;
  } else {
    int k = 1;
    while (h - k >= 0) {
      if (str.at(h - k) == str.at(h + k)) {
        k++;
        // continue;
      } else {
        a = false;
        break;
      }
    }
  }
  return a;
}

int main() {
  string S;
  cin >> S;
  int N = S.length();
  string S2 = S.substr(0, (N - 1) / 2);
  string S3 = S.substr((N + 3) / 2 - 1);

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

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

bool IsPalindrome(string s) {
  string aux = s;
  reverse(aux.begin(), aux.end());
  return s == aux;
}
bool IsPalindrome2(string s) {
  int a = s.size();
  string s2;
  for (int i = 0; i < (a - 1) / 2; i++) {
    s2 += s[i];
  }
  string aux = s2;
  reverse(aux.begin(), aux.end());
  return s2 == aux;
}
bool IsPalindrome3(string s) {
  int a = s.size();
  string s3;
  for (int i = (a + 3) / 2 - 1; i < a; i++) {
    s3 += s[i];
  }
  string aux = s3;
  reverse(aux.begin(), aux.end());
  return s3 == aux;
}

int main() {
  string s;
  bool a = false, b = false, c = false, d = false;
  cin >> s;
  a = IsPalindrome(s);
  b = IsPalindrome2(s);
  c = IsPalindrome3(s);
  d = a && b && c;
  if (d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Error: 0

Fixed submission:

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

bool IsPalindrome(string s) {
  string aux = s;
  reverse(aux.begin(), aux.end());
  return s == aux;
}
bool IsPalindrome2(string s) {
  int a = s.size();
  int b = (a - 1) / 2;
  string s2(b, ' ');
  for (int i = 0; i < b + 1; i++) {
    s2[i] = s[i];
  }
  string aux = s2;
  reverse(aux.begin(), aux.end());
  return s2 == aux;
}
bool IsPalindrome3(string s) {
  int a = s.size();
  int b = (a + 3) / 2;
  string s3(a - b, ' ');
  for (int i = b; i < a + 1; i++) {
    s3[i] = s[i];
  }
  string aux = s3;
  reverse(aux.begin(), aux.end());
  return s3 == aux;
}

int main() {
  string s;
  bool a = false, b = false, c = false, d = false;
  cin >> s;
  a = IsPalindrome(s);
  b = IsPalindrome2(s);
  c = IsPalindrome3(s);
  d = a && b && c;
  if (d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <functional>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
// #include <bits/stdc++.h>

using namespace std;

int main() {
  bool j1, j2, j3;
  j1 = true;
  j2 = true;
  j3 = true;
  string ss;
  cin >> ss;
  int n;
  n = ss.size();
  vector<char> s;
  for (int i = 0; i < n; i++) {
    s.push_back(ss[i]);
  }
  // 条件1
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i]) {
      j1 = false;
    }
  }
  // 条件2
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n / 2 - 1 - i]) {
      j2 = false;
    }
  }
  // 条件3
  for (int i = n / 2 + 1; i < n; i++) {
    if (s[i] != s[n - 1 - i]) {
      j3 = false;
    }
  }
  if (j1 && j2 && j3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
// #include <bits/stdc++.h>

using namespace std;

int main() {
  string ss;
  cin >> ss;
  vector<char> s;
  for (int i = 0; i < ss.size(); i++) {
    s.push_back(ss[i]);
  }
  // 条件1
  for (int i = 0; i < ss.size(); i++) {
    if (s[i] != s[ss.size() - i - 1]) {
      cout << "No" << endl;
      return 1;
    }
  }
  // 条件2
  for (int i = 0; i < ss.size() / 4; i++) {
    if (s[i] != s[((ss.size() - i) / 2) - 1]) {
      cout << "No" << endl;
      return 1;
    }
  }
  // 条件3
  for (int i = 0; i < ss.size() / 4; i++) {
    if (s[i + ((ss.size() + 3) / 2) - 1] != s[ss.size() - i - 1]) {
      cout << "No" << endl;
      return 1;
    }
  }

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

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

int main() {
  string S;
  int i, j, k;
  int I, J, K;
  cin >> S;

  for (k = 0; k < S.length() - 1; k++) {
    K = S.length() - 1 - k;
    if (S.at(k) != S.at(K)) {
      cout << "No" << endl;
      return 0;
    }
  }

  for (i = 0; i < ((S.length() - 1) / 2); i++) {
    I = (S.length() - 1) / 2 - 1 - i;
    if (S.at(i) == S.at(I)) {
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  J = 0;
  for (j = ((S.length() + 3) / 2 - 1);
       j < (((S.length() + 3) / 2 - 1) + S.length()) / 2; j++) {
    J += 1;
    if (S.at(j) != S.at(S.length() - J)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

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;
  int i, j, k;
  int I, J;
  cin >> S;

  for (k = 0; k < S.length() - 1; k++) {
    if (S.at(k) != S.at(S.length() - k)) {
      cout << "No" << endl;
      return 0;
    }
  }

  for (i = 0; i < ((S.length() - 1) / 2); i++) {
    I = (S.length() - 1) / 2 - 1 - i;
    if (S.at(i) == S.at(I)) {
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  J = 0;
  for (j = ((S.length() + 3) / 2 - 1);
       j < (((S.length() + 3) / 2 - 1) + S.length()) / 2; j++) {
    J += 1;
    if (S.at(j) != S.at(S.length() - J)) {
      cout << "No" << endl;
      return 0;
    }
  }

  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 N = S.size();
  vector<char> list1((N - 1) / 2);
  vector<char> list2((N - 1) / 2);
  vector<char> list3((N - 1) / 2);
  vector<char> list4((N - 1) / 2);
  for (int i = 0; i < (N - 1) / 2; i++) {
    list1.at(i) = S.at(i);
    list3.at((N - 1) / 2 - 1 - i) = S.at(i);
    list2.at(i) = S.at(N - 1 - i);
    list4.at((N - 1) / 2 - 1 - i) = S.at(N - 1 - i);
  }
  if (list1 == list3 && list2 == list4 && list1 == list4) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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 N = S.size();
  vector<char> list1((N - 1) / 2);
  vector<char> list2((N - 1) / 2);
  vector<char> list3((N - 1) / 2);
  vector<char> list4((N - 1) / 2);
  for (int i = 0; i < (N - 1) / 2; i++) {
    list1.at(i) = S.at(i);
    list3.at((N - 1) / 2 - 1 - i) = S.at(i);
    list2.at(i) = S.at(N - i);
    list4.at((N - 1) / 2 - 1 - i) = S.at(N - i);
  }
  if (list1 == list3 && list2 == list4) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
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();

  bool ok1, ok2, ok3;
  string T = S;
  reverse(T.begin(), T.end());
  ok1 = S == T;
  string U = S.substr(0, N / 2);
  string V = U;
  reverse(V.begin(), V.end());
  ok2 = U == V;
  /* string W = S.substr((N + 1) / 2, U.size());
  string X = W;
  reverse(X.begin(), X.end());
  if (W == X) {
      ok3 = true;
  } */

  if (ok1 && ok2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Error: 0

Fixed submission:

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

int main() {
  string S;
  cin >> S;
  int N = S.size();

  bool ok1 = true, ok2 = true, ok3 = true;
  for (int i = 0; i <= (N - 1) / 2; i++) {
    if (S.at(i) != S.at(N - 1 - i)) {
      ok1 = false;
    }
  }
  for (int i = 0; i <= ((N - 1) / 2 - 1) / 2; i++) {
    if (S.at(i) != S.at((N - 1) / 2 - 1 - i)) {
      ok2 = false;
    }
  }
  for (int i = (N + 3) / 2 - 1; i <= (N + (N + 3) / 2) / 2; i++) {
    if (S.at(i) != S.at((N + 3) / 2 - 1 + (N + (N + 3) / 2) / 2 - i)) {
      ok3 = false;
    }
  }

  if (ok1 && ok2 && ok3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}