Problem p02730 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define flash                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define pb push_back
#define ff first
#define ss second
signed main() {
  flash char str[99];
  cin >> str;
  int n = strlen(str), flag = 0, glag = 0;
  // cout<<n;
  for (int i = 0; i < n; i++) {
    if (str[i] != str[n - i - 1]) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    cout << "No";
    return 0;
  } else
    glag++;
  int k = (n - 3) / 2 + 1;
  for (int i = 0; i < k; i++) {
    if (str[i] != str[k - i - 1]) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    cout << "No";
    return 0;
  } else
    glag++;
  int j = (n + 1) / 2;
  for (int i = j; i < n; i++) {
    if (str[i] != str[n - i - 1]) {
      flag = 1;
      break;
    }
  }
  // cout<<f;
  if (flag) {
    cout << "No";
    return 0;
  } else
    glag++;
  if (glag == 3)
    cout << "Yes";
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define flash                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repc(i, a, b, c)                                                       \\
  for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\\n'
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n + 1) ft.pb((ft[i - 1] * i) % mod);
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) ((ft[n] * mod_in((ft[r] * ft[(n) - (r)]) % mod)) % mod)
#define deb(x) cout << #x << " " << x << endl;
ll digit(long long n) { return floor(log10(n) + 1); }
vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);
void sieve() {
  is_prime[0] = is_prime[1] = 0;
  for (int i = 2; i * i <= 1000000; i++)
    if (is_prime[i])
      repc(j, i * i, 1000000, i) is_prime[j] = 0;
}
ll power(ll x, ll y);
ll gcd(ll a, ll b);
vector<ll> adj[10];
ll visited[10] = {0};
bool checkPalindrome(string s);
int main() {
  flash;
  string s;
  cin >> s;
  ll n = s.size();
  string r1 = s.substr(0, (n - 1) / 2);
  string r2 = s.substr((n + 3) / 2 + 1, n - 1);
  if (checkPalindrome(s) == 1 && checkPalindrome(r1) == 1 &&
      checkPalindrome(r2) == 1) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
//
//
//
//
// kaam ke functions
ll power(ll x, ll y) {
  ll res = 1;
  x %= mod;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res % mod;
}

bool checkPalindrome(string s) {
  string r = s;
  int i = 0;
  for (auto itr = s.rbegin(); itr != s.rend(); itr++) {
    r[i] = *itr;
    i++;
  }
  if (r == s)
    return 1;
  return 0;
}
ll gcd(ll a, ll b) {
  if (a == 0)
    return b;

  return gcd(b % a, a);
}