Problem p03227 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define start_routine() int begtime = clock();
#define end_routine()                                                          \
  int endtime = clock();                                                       \
  cerr << endl                                                                 \
       << "Time elapsed: " << (endtime - begtime) * 1000 / CLOCKS_PER_SEC      \
       << " ms";                                                               \
  return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end()

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

#define int long long

const int inf = (int)5e15;
const int upper = 1e5 + 10;
const int M = 1000000007;

int answer = 0;

char arr[1005][1005];
// int fac[upper], invfac[upper];
// int modexp (int a, int b, int m) {
// 	if (b == 0) return 1;
// 	int ans = modexp (a, b/2, m);
// 	ans = (ans * ans) % m;

// 	if (b % 2 == 1) ans = (ans * a) % m;

// 	return ans;
// }
// void prec() {
// 	fac[0] = 1;
// 	for (int i = 1; i < upper; i += 1) fac[i] = (fac[i - 1] * i) % M;
// 	invfac[upper - 1] = modexp(fac[upper - 1], M - 2, M);
// 	for (int i = upper - 2; i >= 0; i -= 1) invfac[i] = (invfac[i + 1] * (i
// + 1)) % M;
// }

signed main() {
  start_routine();
  speed();
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// freopen("errlog.txt", "w", stderr);
#endif

  string s;
  cin >> s;
  if (len(s) == 2) {
    cout << s;
  } else {
    reverse(all(s));
    cout << s;
  }
  end_routine();
}

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

#define start_routine() int begtime = clock();
#define end_routine()                                                          \
  int endtime = clock();                                                       \
  cerr << endl                                                                 \
       << "Time elapsed: " << (endtime - begtime) * 1000 / CLOCKS_PER_SEC      \
       << " ms";                                                               \
  return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;

#define PB push_back
#define MP make_pair

#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'

#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end()

using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

#define int long long

const int inf = (int)5e15;
const int upper = 1e5 + 10;
const int M = 1000000007;

int answer = 0;

char arr[1005][1005];
// int fac[upper], invfac[upper];
// int modexp (int a, int b, int m) {
// 	if (b == 0) return 1;
// 	int ans = modexp (a, b/2, m);
// 	ans = (ans * ans) % m;

// 	if (b % 2 == 1) ans = (ans * a) % m;

// 	return ans;
// }
// void prec() {
// 	fac[0] = 1;
// 	for (int i = 1; i < upper; i += 1) fac[i] = (fac[i - 1] * i) % M;
// 	invfac[upper - 1] = modexp(fac[upper - 1], M - 2, M);
// 	for (int i = upper - 2; i >= 0; i -= 1) invfac[i] = (invfac[i + 1] * (i
// + 1)) % M;
// }

signed main() {
  start_routine();
  speed();
#ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// freopen("errlog.txt", "w", stderr);
#endif

  string s;
  cin >> s;
  if (len(s) == 2) {
    cout << s;
  } else {
    reverse(all(s));
    cout << s;
  }
  end_routine();
}