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

// Biscuit_Generator
// https://atcoder.jp/contests/abc125/tasks/abc125_a
// date: 2020-08-15T19:20:35.753917

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

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _repd(i, n) repdi(i, 0, n)
#define repdi(i, a, b) for (ll i = (ll)b - 1; i >= (ll)a; i--)
#define repd(...) _overload3(__VA_ARGS__, repdi, _repd, )(__VA_ARGS__)

#define all(x) x.begin(), x.end()
#define SIZE(x) ((ll)(x).size())

#define PB push_back // 挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T, typename... Args> void CIN(T &first, Args &...args) {
  ((cin >> first), ..., (cin >> args)); // C++17
}

template <char Sep, typename T, typename... Args>
void COUNT_NL(const T &first, const Args &...args) {
  ((cout << first), ..., (cout << Sep << args)); // C++17
}

template <typename... Words> void COUT(Words... words) {
  COUNT_NL<' '>(words...);
  cout << endl;
  return;
}

#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

#define INF 1000000000000 // 10^12:∞
#define MOD 1000000007    // 10^9+7:合同式の法
#define MAXR 100000       // 10^5:配列の最大のrange

int solve(void) {
  string s;
  CIN(s);
  ll cnt = 0;
  ll top = 0;
  rep(i, 3) {
    if (s[i] == 'R') {
      cnt++;
      chmax(top, cnt);
    } else {
      cnt = 0;
    }
  }
  COUT(top);
  return 0;
}

int main(void) {
  // 入力の高速化用のコード
  // ios::sync_with_stdio(false);
  // cin.tie(nullptr);

  solve();
  return 0;
}


Error: 0

Fixed submission:

// Biscuit_Generator
// https://atcoder.jp/contests/abc125/tasks/abc125_a
// date: 2020-08-15T19:20:35.753917

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

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _repd(i, n) repdi(i, 0, n)
#define repdi(i, a, b) for (ll i = (ll)b - 1; i >= (ll)a; i--)
#define repd(...) _overload3(__VA_ARGS__, repdi, _repd, )(__VA_ARGS__)

#define all(x) x.begin(), x.end()
#define SIZE(x) ((ll)(x).size())

#define PB push_back // 挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T, typename... Args> void CIN(T &first, Args &...args) {
  ((cin >> first), ..., (cin >> args)); // C++17
}

template <char Sep, typename T, typename... Args>
void COUNT_NL(const T &first, const Args &...args) {
  ((cout << first), ..., (cout << Sep << args)); // C++17
}

template <typename... Words> void COUT(Words... words) {
  COUNT_NL<' '>(words...);
  cout << endl;
  return;
}

#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

#define INF 1000000000000 // 10^12:∞
#define MOD 1000000007    // 10^9+7:合同式の法
#define MAXR 100000       // 10^5:配列の最大のrange

int solve(void) {
  string s;
  CIN(s);
  ll cnt = 0;
  rep(i, 3) {
    if (s[i] == 'R') {
      cnt++;
    }
  }
  COUT(cnt);
}

int main(void) {
  // 入力の高速化用のコード
  // ios::sync_with_stdio(false);
  // cin.tie(nullptr);

  solve();
  return 0;
}