Problem p02730 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long int
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vppll vector<pair<pll, pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll, ll>
#define fir first
#define sec second
#define _cin                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);
#define fo(i, b) for (i = 0; i < b; i++)
#define repa(i, a, b) for (i = a; i < b; i++)
#define repb(i, a, b) for (i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18 + 1);
const long long int MIN = (ll)(-1e18 - 1);
const long long int mod = (ll)(1e9 + 7);
using namespace std;

ll max(ll a, ll b, ll c) { return max(max(a, b), c); }
ll min(ll a, ll b, ll c) { return min(min(a, b), c); }
ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
ll power(ll a, ll n) {
  ll p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
    }
    n >>= 1;
    a *= a;
  }
  return p;
}
ll power_mod(ll a, ll n, ll mod_) {
  ll p = 1;
  while (n) {
    if (n % 2) {
      p = (p * a) % mod_;
    }
    n /= 2;
    a = (a * a) % mod_;
  }
  return p % mod_;
}
/*Code Begins*/

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
  _cin;
  // cout << setprecision(15);
  ll mn = MAX, mx = MIN;
  ll n, t, m, k, i, j, sum = 0, prev, flag = 0, cnt = 0;
  ll x = 0, y = 0, fx, diff, tot = 0, l, r;
  int TC = 1;
  // cin >> TC;
  while (TC--) {
    string s;
    cin >> s;
    n = s.length();
    string t1, t2;
    flag = 0;
    fo(i, (n - 1) / 2) t1.pb(s[i]);
    repa(i, (n + 3) / 2 - 1, n) t2.pb(s[i]);
    // cout << t1 << endl << t2;
    fo(i, n) {
      if (s[i] != s[n - 1 - i])
        flag = 1;
    }
    fo(i, t1.length()) {
      if (t1[i] != t1[t1.length() - 1 - i])
        flag = 1;
    }
    fo(i, t2.length()) {
      if (t2[i] != t2[t2.length() - 1 - i])
        flag = 1;
    }
    flag ? cout << "No" : cout << "Yes";
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vppll vector<pair<pll, pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll, ll>
#define fir first
#define sec second
#define _cin                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);
#define fo(i, b) for (i = 0; i < b; i++)
#define repa(i, a, b) for (i = a; i < b; i++)
#define repb(i, a, b) for (i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18 + 1);
const long long int MIN = (ll)(-1e18 - 1);
const long long int mod = (ll)(1e9 + 7);
using namespace std;

ll max(ll a, ll b, ll c) { return max(max(a, b), c); }
ll min(ll a, ll b, ll c) { return min(min(a, b), c); }
ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
ll power(ll a, ll n) {
  ll p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
    }
    n >>= 1;
    a *= a;
  }
  return p;
}
ll power_mod(ll a, ll n, ll mod_) {
  ll p = 1;
  while (n) {
    if (n % 2) {
      p = (p * a) % mod_;
    }
    n /= 2;
    a = (a * a) % mod_;
  }
  return p % mod_;
}
/*Code Begins*/

int main() {
  _cin;
  // cout << setprecision(15);
  ll mn = MAX, mx = MIN;
  ll n, t, m, k, i, j, sum = 0, prev, flag = 0, cnt = 0;
  ll x = 0, y = 0, fx, diff, tot = 0, l, r;
  int TC = 1;
  // cin >> TC;
  while (TC--) {
    string s;
    cin >> s;
    n = s.length();
    string t1, t2;
    flag = 0;
    fo(i, (n - 1) / 2) t1.pb(s[i]);
    repa(i, (n + 3) / 2 - 1, n) t2.pb(s[i]);
    // cout << t1 << endl << t2;
    fo(i, n) {
      if (s[i] != s[n - 1 - i])
        flag = 1;
    }
    fo(i, t1.length()) {
      if (t1[i] != t1[t1.length() - 1 - i])
        flag = 1;
    }
    fo(i, t2.length()) {
      if (t2[i] != t2[t2.length() - 1 - i])
        flag = 1;
    }
    flag ? cout << "No" : cout << "Yes";
  }
  return 0;
}