alexjercan/bugnet huggingface dataset:
Problem p02581 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int n, a[6060], dp[2020][2020], mx[2020], gx[101010][3], sz, mmxx, al;
void ggxx(int x, int y, int vl) {
  gx[sz][0] = x;
  gx[sz][1] = y;
  gx[sz][2] = vl;
  sz++;
}
void gggxxx(int x, int y, int vl) {
  dp[x][y] = max(dp[x][y], vl);
  mx[x] = max(mx[x], vl);
  swap(x, y);
  dp[x][y] = max(dp[x][y], vl);
  mx[x] = max(mx[x], vl);
  mmxx = max(mmxx, vl);
}
void ggggxxxx() {
  for (int i = 0; i < sz; i++) {
    gggxxx(gx[i][0], gx[i][1], gx[i][2]);
  }
  sz = 0;
}
int main() {
  memset(dp, -0x3f3f3f, sizeof(dp));
  memset(mx, -0x3f3f3f, sizeof(mx));
  mmxx = -0x3f3f3f;
  cin >> n;
  for (int i = 0; i < n * 3; i++) {
    cin >> a[i];
    a[i]--;
  }
  gggxxx(a[0], a[1], 0);
  for (int i = 0; i < n - 1; i++) {
    int x[3];
    x[0] = a[3 * i + 2];
    x[1] = a[3 * i + 3];
    x[2] = a[3 * i + 4];
    if (x[0] == x[1] && x[1] == x[2]) {
      al++;
      continue;
    }
    for (int tt = 0; tt < 3; tt++) {
      ggxx(x[0], x[1], max(mmxx, dp[x[2]][x[2]] + 1));
      for (int j = 0; j < n; j++) {
        if (x[0] == x[1]) {
          ggxx(j, x[2], dp[j][x[0]] + 1);
        }
        ggxx(j, x[2], mx[j]);
      }
      swap(x[0], x[1]);
      swap(x[1], x[2]);
    }
    ggggxxxx();
  }
  cout << max(mmxx, dp[a[3 * n - 1]][a[3 * n - 1]] + 1) + al << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, a[2020], dp[2020][2020], mx[2020], gx[101010][3], sz, mmxx, al;
void ggxx(int x, int y, int vl) {
  gx[sz][0] = x;
  gx[sz][1] = y;
  gx[sz][2] = vl;
  sz++;
}
void gggxxx(int x, int y, int vl) {
  dp[x][y] = max(dp[x][y], vl);
  mx[x] = max(mx[x], vl);
  swap(x, y);
  dp[x][y] = max(dp[x][y], vl);
  mx[x] = max(mx[x], vl);
  mmxx = max(mmxx, vl);
}
void ggggxxxx() {
  for (int i = 0; i < sz; i++) {
    gggxxx(gx[i][0], gx[i][1], gx[i][2]);
  }
  sz = 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < n * 3; i++) {
    cin >> a[i];
    a[i]--;
  }
  gggxxx(a[0], a[1], 0);
  for (int i = 0; i < n - 1; i++) {
    int x[3];
    x[0] = a[3 * i + 2];
    x[1] = a[3 * i + 3];
    x[2] = a[3 * i + 4];
    if (x[0] == x[1] && x[1] == x[2]) {
      al++;
      continue;
    }
    for (int tt = 0; tt < 3; tt++) {
      ggxx(x[0], x[1], max(mmxx, dp[x[2]][x[2]] + 1));
      for (int j = 0; j < n; j++) {
        if (x[0] == x[1]) {
          ggxx(j, x[2], dp[j][x[0]] + 1);
        }
        ggxx(j, x[2], mx[j]);
      }
      swap(x[0], x[1]);
      swap(x[1], x[2]);
    }
    ggggxxxx();
  }
  cout << max(mmxx, dp[a[3 * n - 1]][a[3 * n - 1]] + 1) + al << endl;
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int L = 0;
  string w;
  cin >> w;
  for (int i = 0; i < 3; i++) {
    if (w[i] == 'R')
      L++;
  }
  if (w[1] == 'S' && w[0] == 'R')
    L = 1;
  cout << L << endl;
}

Error: -11

Fixed submission:

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

int main() {
  int L = 0;
  bool w = 'S';
  vector<int> S;
  for (int i = 0; i < 3; i++)
    cin >> S[i];
  for (int x : S) {
    if (w == x)
      L++;
    w = x;
    cout << L << endl;
  }
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(), a.end()
#define dbg(n) cout << #n << ' ' << n << endl;
#define dbg_v(v)                                                               \\
  cout << #v << ":";                                                           \\
  for (auto x : v)                                                             \\
    cout << " " << x;                                                          \\
  cout << endl;
int power(ll x, ll y) {
  ll res = 1;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  // cin>>T;
  while (T--) {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < (int)s.length(); i++) {
      int cnt = 0;
      while (s[i] == 'R' && i < (int)s.length()) {
        cnt++;
        i++;
      }
      ans = max(cnt, ans);
    }
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(), a.end()
#define dbg(n) cout << #n << ' ' << n << endl;
#define dbg_v(v)                                                               \\
  cout << #v << ":";                                                           \\
  for (auto x : v)                                                             \\
    cout << " " << x;                                                          \\
  cout << endl;
int power(ll x, ll y) {
  ll res = 1;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  // cin>>T;
  while (T--) {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < (int)s.length(); i++) {
      int cnt = 0;
      while (s[i] == 'R')
        cnt++;
      ans = max(cnt, ans);
    }
    cout << ans << endl;
  }
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string s;
  cin >> s;
  int c = 0;
  set<int> st;
  st.insert(0);
  for (auto x : s) {
    if (x == 'R')
      c++;
    else {
      st.insert(c);
      c = 0;
    }
  }
  st.insert(c);
  cout << *st.rbegin() << endl;
}


Error: 0

Fixed submission:

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

int main() {
  string s;
  cin >> s;
  int c = 0;
  set<int> st;
  for (auto x : s) {
    if (x == 'R')
      c++;
    else {
      st.insert(c);
      c = 0;
    }
  }
  cout << *st.rbegin() << endl;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
#define NL << endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\\n"
#define fill(x, y) memset(x, y, sizeof(y))
#define debug(x)                                                               \\
  { cerr << #x << " = " << x << endl; }
#define inarr(arr, n)                                                          \\
  {                                                                            \\
    for (int i = 0; i < n; i++) {                                              \\
      cin >> arr[i];                                                           \\
    }                                                                          \\
  }
#define out(a) cout << a << endl;
typedef long long ll;
const int MOD = 1e9 + 7;
using namespace std;

void solve() {
  string s;
  cin >> s;
  if (s == "RRR") {
    out(3);
  } else if (s == "RRS" || s == "SRR") {
    out(2);
  } else if (s == "SSS") {
    out(0);
  } else {
    out(1);
  }
  return;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  // int t; cin >> t;
  while (t--)
    solve();
  return 0;
}


Error: 2

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "RRR") {
    return 3;
  } else if (s == "RRS" || s == "SRR") {
    return 2;
  } else if (s == "RSS" || s == "SRS" || s == "SSR") {
    return 1;
  }
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

bool comp(int i, int j) { return (i > j); }
using namespace std;
using ll = long long;
ll r, g, b, w;
bool check(ll r, ll g, ll b, ll w) {
  if (r % 2 + g % 2 + b % 2 + w % 2 > 1)
    return false;
  else
    return true;
}

int main() {
  string s{3};
  while (getline(cin, s)) {
    cin >> s;
    int n_R = 0, n_S = 0;
    for (auto it : s) {
      if (it == 'R')
        n_R++;
      else
        n_S++;
    }
    if (n_R == 0)
      cout << 0 << endl;
    else if (n_R == 1)
      cout << 1 << endl;
    else if (n_R == 3)
      cout << 3 << endl;
    else {
      if (s[0] == 'S' || s[2] == 'S')
        cout << 2 << endl;
      else
        cout << 1 << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

bool comp(int i, int j) { return (i > j); }
using namespace std;
using ll = long long;
ll r, g, b, w;
bool check(ll r, ll g, ll b, ll w) {
  if (r % 2 + g % 2 + b % 2 + w % 2 > 1)
    return false;
  else
    return true;
}

int main() {
  string s{3};
  cin >> s;
  while (s != "") {
    int n_R = 0, n_S = 0;
    for (auto it : s) {
      if (it == 'R')
        n_R++;
      else
        n_S++;
    }
    if (n_R == 0)
      cout << 0 << endl;
    else if (n_R == 1)
      cout << 1 << endl;
    else if (n_R == 3)
      cout << 3 << endl;
    else {
      if (s[0] == 'S' || s[2] == 'S')
        cout << 2 << endl;
      else
        cout << 1 << endl;
    }

    cin >> s;
  }
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {

  string s;
  cin >> s;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
    cout << 3;

  else if (s[0] == 'R' && s[2] == 'R')
    cout << 1 << endl;
  else if (s[0] == 'R' && s[1] == 'R')
    cout << 2 << endl;
  else if (s[1] == 'R' && s[2] == 'R')
    cout << 2 << endl;
  else if (s[0] != 'R' && s[1] != 'R' && s[2] == 'R')
    cout << 1;
  else if (s[0] == 'R' && s[1] != 'R' && s[2] != 'R')
    cout << 1;
  else if (s[0] != 'R' && s[1] == 'R' && s[2] != 'R')
    cout << 1;
  else if (s[0] != 'R' && s[2] != 'R')
    cout << 0;
  else if (s[0] != 'R' && s[1] != 'R')
    cout << 0;
  else if (s[0] != 'R' && s[1] != 'R' && s[2] != 'R')
    cout << 0;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  while (1) {
    string s;
    cin >> s;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R')
      cout << 3;

    else if (s[0] == 'R' && s[2] == 'R')
      cout << 1 << endl;
    else if (s[0] == 'R' && s[1] == 'R')
      cout << 2 << endl;
    else if (s[1] == 'R' && s[2] == 'R')
      cout << 2 << endl;
    else if (s[0] != 'R' && s[1] != 'R' && s[2] == 'R')
      cout << 1;
    else if (s[0] == 'R' && s[1] != 'R' && s[2] != 'R')
      cout << 1;
    else if (s[0] != 'R' && s[1] == 'R' && s[2] != 'R')
      cout << 1;
    else if (s[0] != 'R' && s[2] != 'R')
      cout << 0;
    else if (s[0] != 'R' && s[1] != 'R')
      cout << 0;
    else if (s[0] != 'R' && s[1] != 'R' && s[2] != 'R')
      cout << 0;
  }

  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string S;
  cin >> S;
  long cont = 0;
  vector<size_t> rainy;
  for (auto i = 0; i < S.length(); ++i) {
    if (S[i] == 'R') {
      ++cont;
    } else {
      rainy.push_back(cont);
      cont = 0;
    }
  }
  rainy.push_back(cont);
  cout << *max_element(rainy.cbegin(), rainy.cend()) << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string S;
  cin >> S;
  ll cont = 0;
  vector<ll> rainy;
  for (ll i = 0; i < S.length(); ++i) {
    if (S[i] == 'R') {
      ++cont;
    } else {
      rainy.push_back(cont);
      cont = 0;
    }
  }
  cout << *max_element(rainy.cbegin(), rainy.cend()) << endl;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  // freopen("input.txt","r",stdin);

  string s;
  cin >> s;
  int c = 0;
  if (s == "SRR" || s == "RRS")
    c = 2;
  else if (s == "RRR")
    c = 3;
  else if (s == "SSR" || s == "SRS" || s == "RSS" || s == "RSR")
    c = 1;
  else
    c = 0;
  cout << c << endl;
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  // freopen("input.txt","r",stdin);

  string s;
  cin >> s;
  int c[3], cnt = 0, j = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'R')
      cnt++;
    else
      c[j] = cnt, j++, cnt = 0;
  }
  c[j] = cnt, j++;
  sort(c, c + j);
  cout << c[j - 1] << endl;
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  long long ans = 0;
  long long a = 0;
  for (auto c : s) {
    if (c == 'R') {
      ans++;
      a = max(a, ans);
    } else {
      ans = 0;
    }
  }
  cout << a << endl;
  return 0;
}


Error: 2

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int a = 0;
  for (auto c : s) {
    if (c == 'R') {
      ans++;
      a = max(a, ans);
    } else {
      ans = 0;
    }
  }
  cout << a << endl;
  return a;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

int main() {
  string s;
  cin >> s;
  int c = 0;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
    cout << 3;
    return 0;
  }
  if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S') {
    cout << 0;
    return 0;
  }
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'S') {
    cout << 2;
    return 0;
  }
  if (s[0] == 'R' && s[1] == 'S' && s[2] == 'S') {
    cout << 1;
    return 0;
  }
  if (s[0] == 'S' && s[1] == 'R' && s[2] == 'R') {
    cout << 2;
    return 0;
  }
  if (s[0] == 'S' && s[1] == 'R' && s[2] == 'S') {
    cout << 1;
    return 0;
  }
  if (s[0] == 'R' && s[1] == 'S' && s[2] == 'R') {
    cout << 1;
    return 0;
  }
  cout << 1;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
int solve() {
  string s;
  cin >> s;
  int c = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R') {
      c++;
    }
  }
  cout << c;
}

int main() {
  IOS;
  { solve(); }

  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
// #include <iomainp>
using namespace std;

#define DB(x)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef uint64_t LL;

int main() {
  std::string str;
  cin >> str;

  int num = 0;
  rep(i, 3) {
    if (str[i] == 'S') {
      num++;
    }
  }

  if (num == 1) {
    if (str[1] == 'S') {
      num++;
    }
  }
  cout << 3 - num << endl;

  return 0;
}


Error: 1

Fixed submission:

#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
// #include <iomainp>
using namespace std;

#define DB(x)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef uint64_t LL;

int main() {
  int N, K;
  cin >> N >> K;
  int ANS = 1;

  for (int i = 1;; ++i) {
    ANS *= K;
    if (ANS >= N) {
      cout << i << endl;
      return 1;
    }
  }

  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

int main() {
  char a[3];
  std::cin >> a;

  bool _1 = a[0] == 'R';
  bool _2 = a[1] == 'R';
  bool _3 = a[2] == 'R';

  if (_1 && _2 && _3) {
    std::cout << '3' << std::endl;
  } else if ((_1 && _2) || (_2 && _3)) {
    std::cout << '2' << std::endl;
  } else if (_1 || _2 || _3) {
    std::cout << '1' << std::endl;
  } else {
    std::cout << '0' << std::endl;
  }
  return 0;
}

Error: 1

Fixed submission:

#include <iostream>

int main() {
  char a[3];
  std::cin >> a;

  bool _1 = a[0] == 'R';
  bool _2 = a[1] == 'R';
  bool _3 = a[2] == 'R';

  if (_1 && _2 && _3) {
    std::cout << '3' << std::endl;
  } else if ((_1 && _2) || (_2 && _3)) {
    std::cout << '2' << std::endl;
  } else if (_1 || _2 || _3) {
    std::cout << '1' << std::endl;
  } else {
    std::cout << '0' << std::endl;
  }
  return 1;
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "RRR")
    cout << 3;
  if (s == "RRS")
    cout << 2;
  if (s == "SRR")
    cout << 2;
  if (s == "RSS")
    cout << 1;
  if (s == "SSR")
    cout << 1;
  if (s == "SRS")
    cout << 1;
  if (s == "RSR")
    cout << 1;
  if (s == "SSS")
    cout << 0;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  string s;
  cin >> s;
  int sum = 0;
  bool pan = 0;
  for (int i = 0; i < 3; i++) {
    if (i = 1 && s[i] == 'R')
      pan = 1;
    if (s[i] == 'R' && pan == 1) {
      sum++;
      pan = 1;
    }
    if (s[i] != 'R')
      pan = 0;
  }
  cout << sum;
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pvllvll pair<vector<ll>, vector<ll>>
#define ld long double
#define veci vector<int>
#define vecll vector<ll>

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
  string s;
  cin >> s;
  int cnt = 0, ans = 0;
  for (int i = 0; i < s.sz; ++i) {
    if (s[i] == 'R')
      cnt++;
    else
      ans = max(ans, cnt), cnt = 0;
  }
  cout << max(ans, cnt);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  /// cin >> T;
  while (T--)
    solve(), cout << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pvllvll pair<vector<ll>, vector<ll>>
#define ld long double
#define veci vector<int>
#define vecll vector<ll>

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
  string s;
  cin >> s;
  int cnt = 0, ans = 0;
  for (int i = 0; i < s.sz;) {
    if (s[i] == 'R')
      cnt++;
    else
      ans = max(ans, cnt), cnt = 0;
  }
  cout << max(ans, cnt);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  /// cin >> T;
  while (T--)
    solve(), cout << '\\n';
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int ans;
string s;

int main() {
  cin >> s;
  for (int i = 0, j = 0; i < 3; i = j + 1) {
    j = i;
    while (s[i] == 'R' && j + 1 < 3 && s[j + 1] == 'R')
      j++;
    if (s[i] == 'R')
      ans = max(ans, j - i + 1);
  }
  printf("%d\\n", ans);
  return 0;
}

Error: TLE

Fixed submission:

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

int ans;
string s;

int main() {
  cin >> s;
  for (int i = 0, j = 0; i < 3; i = j + 1) {
    while (s[i] == 'R' && j + 1 < 3 && s[j + 1] == 'R')
      j++;
    if (s[i] == 'R')
      ans = max(ans, j - i + 1);
  }
  printf("%d\\n", ans);
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

// list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int n = 3;
  int tem = 0;
  vector<int> lan(0);
  for (int l = 0; l < n;) {
    int r = 0;
    for (; l + r < n && s[l] == s[l + r]; r++) {
    }
    if (s[l] == 'R') {
      lan.push_back(r);
    }
    l += r;
    r = 0;
  }
  lan.push_back(0);
  cout << *max_element(lan.begin(), lan.end());
}

Error: WA

Fixed submission:

// list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int n = 3;
  int tem = 0;
  vector<int> lan(0);
  for (int l = 0; l < n;) {
    int r = 0;
    for (; l + r < n && s[l] == s[l + r]; r++) {
    }
    if (s[l] == 'R') {
      lan.push_back(r);
    }
    l += r;
    r = 0;
  }
  cout << *max_element(lan.begin(), lan.end());
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MoD 1e9 + 7
#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, a, b) for (int i = b; i > a; i--)
#define pb(a) push_back(a)

template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
  if (a > b)
    a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
  if (a < b)
    a = b;
}

int n;
string s;

void solve() {
  cin >> s;
  s += ".";
  int ans = 0;
  vector<int> v;

  fo(i, 0, 4) {
    if (s[i] == 'R')
      ans++;
    else {
      v.pb(ans);
      ans = 0;
    }
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  cout << v[0] << '\\n';
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define MoD 1e9 + 7
#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, a, b) for (int i = b; i > a; i--)
#define pb(a) push_back(a)

template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
  if (a > b)
    a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
  if (a < b)
    a = b;
}

int n;
string s;

void solve() {
  cin >> s;
  s += ".";
  int ans = 0;
  vector<int> v;

  fo(i, 0, 3) {
    if (s[i] == 'R')
      ans++;
    else {
      v.pb(ans);
      ans = 0;
    }
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  cout << v[0] << '\\n';
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[4];
  int count = 0;
  for (int i = 0; i < 3; i++) {
    cin >> str[i];
    if (str[i] == 'R')
      count++;
  }
  if (str[0] == str[1] == str[2] == 'R')
    count = 3;
  if ((str[0] == 'R') && (str[1] == 'S') && (str[2] == 'R'))
    count = 1;
  cout << count << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[3];
  int count = 0;
  cin >> str;
  str[0] = ' ';
  for (int i = 1; i <= 3; i++) {
    if (str[i] == 'R')
      count++;
    if ((str[i] == 'S') && (str[i - 1] == 'R'))
      count--;
    cout << count << endl;
  }
  cout << count << endl;
  return 0;
}