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

#include <stdio.h>
int main() {

  char string[100] = {};
  int size = 0, t = 0;

  scanf("%s", string);
  while (string[size] != '\\0') {
    size++;
  }

  for (int i = 0; i < (size - 1) / 2; i++) {

    if ((string[i] != string[size - i - 1]) ||
        (string[i] != string[((size - 3) / 2) - i]) ||
        (string[((size + 1) / 2) + i] != string[size - i - 1])) {
      t = 1;
      break;
    }
  }

  switch (t) {
  case 1:
    printf("No");
    break;

  default:
    puts("Yes");
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
int main() {

  char string[100] = {};
  int size = 0, s;

  scanf("%s", string[100]);
  while (string[size] != '\\0') {
    size++;
  }

  for (int i = 0; i < (size - 1) / 2; i++) {

    if ((string[i] != string[size - i - 1]) ||
        (string[i] != string[((size - 3) / 2) - i]) ||
        (string[((size + 1) / 2) + i] != string[size - i - 1])) {
      s = 1;
      break;
    }
  }

  switch (s) {
  case 1:
    printf("No");
    break;

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

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(k, a, b) for (int k = (a); k < (b); k++)
#define FORE(k, a, b) for (int k = (a); k <= (b); k++)
#define REP(k, a) for (int k = 0; k < (a); k++)

#define ALL(c) (c).begin(), (c).end()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))

#define dump(x) cerr << #x << ": " << (x) << endl;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool is_palind(string s) {
  if (s.size() <= 1)
    return true;
  return (s[0] != s[s.size() - 1]) ? false
                                   : is_palind(s.substr(1, s.size() - 2));
}

int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  cout << ((is_palind(s) && is_palind(s.substr(0, n / 2)) &&
            is_palind(s.substr((n + 3) / 2 - 1, n / 2)))
               ? "Yes"
               : "No")
       << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(k, a, b) for (int k = (a); k < (b); k++)
#define FORE(k, a, b) for (int k = (a); k <= (b); k++)
#define REP(k, a) for (int k = 0; k < (a); k++)

#define ALL(c) (c).begin(), (c).end()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))

#define dump(x) cerr << #x << ": " << (x) << endl;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

bool is_palind(string s) {
  if (s.size() == 1)
    return true;
  return (s[0] != s[s.size() - 1]) ? false
                                   : is_palind(s.substr(1, s.size() - 2));
}

int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  cout << ((is_palind(s) && is_palind(s.substr(0, n / 2)) &&
            is_palind(s.substr((n + 3) / 2 - 1, n / 2)))
               ? "Yes"
               : "No")
       << endl;

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

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template <typename T> vector<T> make_v(size_t a, T b) {
  return vector<T>(a, b);
}

template <typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

  const int n = s.size();

  auto check = [&](int l, int r) {
    for (int i = l, j = r - 1; i <= j; i++, j--) {
      if (s[i] != s[j])
        return false;
    }

    return true;
  };

  if (check(0, n) && check(0, (n - 1) / 2) && (check((n + 3) / 2 - 1, n))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template <typename T> vector<T> make_v(size_t a, T b) {
  return vector<T>(a, b);
}

template <typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

  const int n = s.size();

  auto isPalindrome = [](const string &s) {
    const int n = s.size();

    for (int i = 0, j = n - 1; i <= j; i++, j--) {
      if (s[i] != s[j])
        return false;
    }

    return true;
  };

  if (isPalindrome(s) && isPalindrome(s.substr(0, (n - 1) / 2)) &&
      isPalindrome(s.substr((n + 3) / 2 + 1, n))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

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

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

int main() {
  string S;
  cin >> S;
  long N = (long)(S.length());
  for (long i = 0; i < (N + 1) / 2; i++) {
    if (S[i] != S[N - 1 - i]) {
      cout << "No";
      exit(0);
    }
  }
  for (long i = 0; i < (N - 1) / 2; i++) {
    if (S[i] != S[(N - 1) / 2 - 1 - i]) {
      cout << "No";
      exit(0);
    }
  }
  for (long i = (N + 3) / 2 - 1; i < (N - 1); i++) {
    if (S[i] != S[N - 1 - i + ((N + 3) / 2 - 1)]) {
      cout << "No";
      exit(0);
    }
  }
  cout << "Yes";
}

Error: WA

Fixed submission:

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

int main() {
  string S;
  cin >> S;
  long N = (long)(S.length());
  for (long i = 0; i < (N + 1) / 2; i++) {
    if (S[i] != S[N - 1 - i]) {
      cout << "No";
      exit(1);
    }
  }
  for (long i = 0; i < (N - 1) / 2; i++) {
    if (S[i] != S[(N - 1) / 2 - 1 - i]) {
      cout << "No";
      exit(1);
    }
  }
  for (long i = (N + 3) / 2 - 1; i < (N - 1); i++) {
    if (S[i] != S[N - 1 - i + ((N + 3) / 2 - 1)]) {
      cout << "No";
      exit(1);
    }
  }
  cout << "Yes";
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

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

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

Error: 0

Fixed submission:

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

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  string ans = "No";
  if (check(s) && check(s.substr(0, n / 2)) && check(s.substr((n + 3) / 2 + 1)))
    ans = "Yes";
  cout << ans << 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 (n % 2 == 0) {
    cout << "No";
    return 0;
  }
  bool ok = true;
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i]) {
      ok = false;
      break;
    }
  }
  if (!ok) {
    cout << "No";
    return 0;
  }
  string s1 = s.substr(0, n / 2);
  string s2 = s.substr((n + 1) / 2, n / 2);
  n = n / 2;
  // cout << s1 << " " << s2 << endl;
  for (int i = 0; i < n / 2; i++) {
    if (s1[i] != s1[n - 1 - i]) {
      ok = false;
      break;
    }
  }
  for (int i = 0; i < n / 2; i++) {
    if (s2[i] != s2[n - 1 - i]) {
      ok = false;
      break;
    }
  }
  if (!ok) {
    cout << "No";
    return 0;
  }
  cout << "Yes";
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (s.length() % 2 == 0) {
    cout << "No";
    return 1;
  }
  bool ok = true;
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 - i]) {
      ok = false;
      break;
    }
  }
  if (!ok) {
    cout << "No";
    return 1;
  }
  string s1 = s.substr(0, n / 2);
  string s2 = s.substr((n + 1) / 2, n / 2);
  n = n / 2;
  // cout << s1 << " " << s2 << endl;
  for (int i = 0; i < n / 2; i++) {
    if (s1[i] != s1[n - 1 - i]) {
      ok = false;
      break;
    }
  }
  for (int i = 0; i < n / 2; i++) {
    if (s2[i] != s2[n - 1 - i]) {
      ok = false;
      break;
    }
  }
  if (!ok) {
    cout << "No";
    return 1;
  }
  cout << "Yes";
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

bool A(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}
int main() {
  string s;

  cin >> s;
  bool ans = true;
  if (!A(s))
    ans = false;
  if (!A(s.substr(0, s.size() / 2)))
    ans = false;

  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();
  for (int i = 0; i < (n - 1) / 2; i++) {
    if (S.at(i) != S.at(((n - 1) / 2) - i)) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int j = 0; j < (n - 1) / 2; j++) {
    if (S.at(j + (n + 3) / 2 - 1) != S.at(n - j)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
// typedef pair<int, int> P;
// priority_queue<int, vector<int>, greater<int> > q;
int main() {
  IOS;
  char s[110];
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  int a = 1, b = (n - 1) / 2, c = (n + 3) / 2, d = n;
  bool p1 = 1, p2 = 1, p3 = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i] != s[n - i + 1]) {
      p1 = 0;
      break;
    }
  }
  for (int i = 1; i <= b; i++) {
    if (s[i] != s[b - i + 1]) {
      p2 = 0;
      break;
    }
  }
  int temp = d - c;
  for (int i = c; i < (c + d) / 2; i++) {
    if (s[i] != s[i + temp]) {
      p3 = 0;
      break;
    }
    temp -= 2;
  }
  if (p1 && p2 && p3)
    cout << "Yes";
  else
    cout << "No";
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define IOS                                                                    \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x, y) memset(x, y, sizeof(x))
using namespace std;
int dt[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {0, 0}};
// typedef pair<int, int> P;
// priority_queue<int, vector<int>, greater<int> > q;
int comb(int n, int m) {
  if (n - m < m)
    m = n - m;
  if (m == 0)
    return 1;
  return comb(n - 1, m - 1) * n / m;
}
int main() {
  IOS;
  int n, m;
  cin >> n >> m;
  if (n != 1 && m != 1)
    cout << comb(n, 2) + comb(m, 2);
  else {
    if ((n == 0 && m == 0) || (n == 1 && m == 1)) {
      cout << 0;
      return 0;
    } else if (n == 1 || n == 0) {
      cout << comb(m, 2);
    } else if (m == 1 || m == 0) {
      cout << comb(n, 2);
    }
  }
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a) begin((a)), end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

bool is_palindrome(string S, int start, int end) {
  rep(i, 0, end) {
    if (S.at(i) != S.at(end - i))
      return false;
  }
  return true;
}

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

  bool flg1 = is_palindrome(S, 0, N - 1);
  bool flg2 = is_palindrome(S, 0, (N - 1) / 2 - 1);
  bool flg3 = is_palindrome(S, (N + 3) / 2 - 1, N - 1);

  if (flg1 and flg2 and flg3) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a) begin((a)), end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

bool is_palindrome(string S) {
  deque<char> deq;
  for (auto c : S)
    deq.push_back(c);

  while (true) {
    if (deq.size() == 1)
      break;
    char front = deq.front();
    deq.pop_front();
    char back = deq.back();
    deq.pop_back();
    if (front != back)
      return false;
  }
  return true;
}

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

  bool flg1 = is_palindrome(S);
  bool flg2 = is_palindrome(S.substr(0, (N - 1) / 2));
  bool flg3 = is_palindrome(S.substr((N + 3) / 2 - 1));

  if (flg1 and flg2 and flg3) {
    cout << "Yes" << endl;
    return 0;
  }

  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;

  bool flag = false;
  int n = s.size();
  s.insert(0, "0");
  for (int i = 1; i <= n / 2; i++) {
    if (s.at(i) == s.at(n - i + 1)) {
      if (i == n / 2)
        flag = true;
    } else {
      flag = false;
      break;
    }
  }

  if (flag) {
    for (int i = 1; i <= (n - 1 + 2) / 4; i++) {
      if (s.at(i) == s.at((n - 1) / 2 - i + 1)) {
        if (i == (n - 1 + 2) / 4)
          flag = true;
      } else {
        flag = false;
        break;
      }
    }
  }

  if (flag) {
    for (int i = (n + 3) / 2; i <= (n - 3 + 2) / 4 + (n + 3) / 2; i++) {
      if (s.at(i) == s.at(n - i + (n + 3) / 2)) {
        if (i == (n - 3 + 2) / 4 + (n + 3) / 2)
          flag = true;
      } else {
        flag = false;
        break;
      }
    }
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Error: 0

Fixed submission:

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

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

  bool flag = false;
  int n = s.size();
  s.insert(0, "0");
  for (int i = 1; i <= n / 2; i++) {
    if (s.at(i) == s.at(n - i + 1)) {
      if (i == n / 2)
        flag = true;
    } else {
      flag = false;
      break;
    }
  }

  for (int i = 1; i <= (n - 1) / 4; i++) {
    if (s.at(i) == s.at((n - 1) / 2 - i + 1)) {
      if (i == (n - 1) / 4)
        flag = true;
    } else {
      flag = false;
      break;
    }
  }

  for (int i = (n + 3) / 2; i <= (n - 3) / 4 + 1 + (n + 3) / 2; i++) {
    if (s.at(i) == s.at(n - i + (n + 3) / 2)) {
      if (i == (n - 3) / 4 + (n + 3) / 2 + 1)
        flag = true;
    } else {
      flag = false;
      break;
    }
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

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

#include <cstdio>
#include <cstring>
#define ri register int
#define N 100
char str[N];
int len;
bool hw(int l, int r) {
  for (ri i = 0; i <= (r - l + 1) / 2; ++i) {
    if (str[l + i] != str[r - i]) {
      return false;
    }
  }
  return true;
}
int main() {
  scanf("%s", str), len = strlen(str),
                    puts(hw(0, len - 1) && hw(0, (len - 1) / 2 - 1) &&
                                 hw((len - 1) / 2 + 1, len - 1)
                             ? "Yes"
                             : "No");
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <cstring>
#define ri register int
#define N 100
char str[N];
int len;
bool search(int l, int r) {
  if (l == r) {
    return true;
  }
  for (ri i = 0; i < len / 2; ++i) {
    if (str[i] != str[len - 1 - i]) {
      return false;
    }
  }
  return search(l, (l + r) / 2 - 1) && search((l + r) / 2 + 1, r);
}
int main() {
  scanf("%s", str), len = strlen(str),
                    puts(search(0, len - 1) == true ? "Yes" : "No");
  return 0;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], flag[N];
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  int l = s.size();
  for (int i = 0; i < l; i++) {
    if (s[i] != s[l - 1 - i]) {
      cout << "No";
      return 0;
    }
  }
  for (int i = 0; i < (l - 1) / 2; i++) {
    if (s[i] != s[(l - 1) / 2 - i - 1]) {
      cout << "No";
      return 0;
    }
  }
  for (int i = (l + 3) / 2 - 1; i < l; i++) {
    if (s[i] != s[l - i - 1]) {
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";
  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], flag[N];
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  int l = s.size();
  for (int i = 0; i < (l - 1) / 2; i++) {
    if (s[i] != s[(l - 1) / 2 - i - 1]) {
      cout << "No";
      return 0;
    }
  }
  for (int i = (N + 3) / 2 - 1; i < N; i++) {
    if (s[i] != s[N - (i - 3)]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
Problem p02730 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <string.h>
char s[105];
int check(int m, int n) {
  int i, j;
  for (i = m, j = n; i != j && i < j; i++, j--)
    if (s[i] != s[j])
      return 0;
  return 1;
}
int main() {
  int m = 0, n = 0, l, r, p = 0;
  scanf("%s", s);
  l = 0;
  r = strlen(s) - 1;
  p = check(l, r);
  l = ((strlen(s) + 3) / 2) - 1;
  r = strlen(s) - 1;
  m = check(l, r);
  l = 0;
  r = ((strlen(s) - 1) / 2) - 1;
  n = check(l, r);
  if (n & m && p)
    printf("Yes", n, m);
  else
    printf("No");
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  long long n, m, ans = 0;
  scanf("%lld%lld", &n, &m);
  while (n > 1)
    ans += --n;
  while (m > 1)
    ans += --m;
  printf("%lld", ans);
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int, int>;
ll mod = 1000000007, mod2 = 998244353;

void chmin(long long &a, long long b) {
  if (a > b)
    a = b;
}
void chmax(long long &a, long long b) {
  if (a < b)
    a = b;
}
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

string s1, s2, s3, s4, s5;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  s1.resize((n - 1) / 2);
  s2.resize((n - 1) / 2);
  s3.resize((n - 1) / 2);
  s4.resize((n - 1) / 2);
  for (int i = 0; i < (s.size() - 1) / 2; ++i) {
    s1[i] = s[i];
    s2[i] = s[i];
  }
  reverse(s2.begin(), s2.end());
  for (int i = (s.size() - 1) / 2 + 1; i < s.size(); ++i) {
    s3[i - (n + 1) / 2] = s[i];
    s4[i - (n + 1) / 2] = s[i];
  }
  reverse(s4.begin(), s4.end());
  s5 = s;
  reverse(s5.begin(), s5.end());
  if (s1 == s2 && s3 == s4 && s5 == s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int, int>;
ll mod = 1000000007, mod2 = 998244353;

void chmin(long long &a, long long b) {
  if (a > b)
    a = b;
}
void chmax(long long &a, long long b) {
  if (a < b)
    a = b;
}
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

string s1, s2, s3, s4;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  s1.resize((n - 1) / 2);
  s2.resize((n - 1) / 2);
  s3.resize((n - 1) / 2);
  s4.resize((n - 1) / 2);
  for (int i = 0; i < (s.size() - 1) / 2; ++i) {
    s1[i] = s[i];
    s2[i] = s[i];
  }
  reverse(s2.begin(), s2.end());
  for (int i = (s.size() - 1) / 2 + 1; i < s.size(); ++i) {
    s3[i] = s[i];
    s4[i] = s[i];
  }
  reverse(s4.begin(), s4.end());
  if (s1 == s2 && s3 == s4) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p02730 (C++) — buggy submission, verdict: Runtime Error

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

string s, a, b;
int n, mid;

bool pal(string a) {
  string b = a;
  reverse(b.begin(), b.end());
  if (b == a)
    return true;
  else
    return false;
}

int main() {

  cin >> s;
  n = s.length();
  mid = n / 2;
  a = s.substr(0, mid);
  b = s.substr(mid + 1);

  if (pal(s) and pal(a) and pal(b))
    cout << "Yes";
  else
    cout << "No";
}


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 <bits/stdc++.h>
using namespace std;

string s, a, b;
int n, mid;

bool pal(string a) {
  string b = a;
  reverse(b.begin(), b.end());
  if (b == a)
    return true;
  else
    return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  cin >> s;
  n = s.length();
  mid = n / 2;
  a = s.substr(0, mid);
  b = s.substr(mid + 1);

  if (pal(s) and pal(a) and pal(b))
    cout << "Yes";
  else
    cout << "No";
}