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

#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
using namespace std;
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define ld long double
#define ll long long int
#define ull unsigned ll
#define ins insert
#define pb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define fo(i, a, b) for (i = a; i < b; ++i)
#define foe(i, a, b) for (i = a; i <= b; ++i)
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = 1; i <= n; i++)
#define per(i, n) for (i = n - 1; i >= 0; i--)
#define per1(i, n) for (i = n; i >= 1; i--)
#define mod 1000000007
#define pi 3.141592653589793238460
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(0)
// #define pbds tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update>

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cout << name << " : " << arg1 << endl;
  // use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

int main() {
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll t, i, j;
  t = 1;
  while (t--) {
    ll n, k;
    string s;
    cin >> s;
    s = s + "P";
    vi v;
    for (i = 0; i < 3; i++) {
      ll cnt = 0;
      if (s[i] == 'R') {
        cnt++;
        while (s[i + 1] == 'R' && i < 3) {
          i++;
          cnt++;
        }
        v.pb(cnt);
      }
    }
    if (sz(v) == 0)
      cout << 0 << '\\n';
    else
      cout << *max_element(all(v)) << '\\n';
  }
  return 0;
}


Error: -11

Fixed submission:

#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
using namespace std;
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define ld long double
#define ll long long int
#define ull unsigned ll
#define ins insert
#define pb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define fo(i, a, b) for (i = a; i < b; ++i)
#define foe(i, a, b) for (i = a; i <= b; ++i)
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, n) for (i = 1; i <= n; i++)
#define per(i, n) for (i = n - 1; i >= 0; i--)
#define per1(i, n) for (i = n; i >= 1; i--)
#define mod 1000000007
#define pi 3.141592653589793238460
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(0)
// #define pbds tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update>

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cout << name << " : " << arg1 << endl;
  // use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

int main() {
  fast;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll t, i, j;
  t = 1;
  while (t--) {
    ll n, k;
    string s;
    cin >> s;
    s = s + "P";
    vi v;
    for (i = 0; i < 3; i++) {
      ll cnt = 0;
      if (s[i] == 'R') {
        cnt++;
        while (s[i + 1] == 'R' && i < 3) {
          i++;
          cnt++;
        }
        v.pb(cnt);
      }
    }
    cout << *max_element(all(v)) << '\\n';
  }
  return 0;
}