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

#include <iostream>

int main(int argc, char *argv[]) {
  std::string s;
  std::cin >> s;

  std::reverse(s.begin(), s.end());
  while (s.back() == 'S' && !s.empty())
    s.pop_back();

  int cnt = 0;
  for (int i = s.size() - 1; i >= 0; --i) {
    if (s.at(i) == 'R')
      cnt++;
    else
      break;
  }
  std::cout << cnt << std::endl;
}


Error: 0

Fixed submission:

#include <iostream>

int main(int argc, char *argv[]) {
  std::string s;
  std::cin >> s;

  int i = 0;
  for (; s.at(i) != 'R' && i < (int)s.size(); ++i)
    ;

  int cnt = 0;
  for (; i < s.size(); ++i) {
    if (s.at(i) == 'R')
      cnt++;
    else
      break;
  }
  std::cout << cnt << std::endl;
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

//   ┏━━┓┏━━┓┏┓┏┓┏┳━┳┓┏━━┓┏━┳┓┏━━┓     ┏┳┓┏┳┓┏━┳━┓┏━━┓┏━┓
//   ┃┏┓┃┃━━┫┃┗┛┃┃┃┃┃┃┃┏┓┃┃┃┃┃┗┃┃┛     ┃┏┛┃┃┃┃┃┃┃┃┃┏┓┃┃╋┃
//   ┃┣┫┃┣━━┃┃┏┓┃┃┃┃┃┃┃┣┫┃┃┃┃┃┏┃┃┓     ┃┗┓┃┃┃┃┃┃┃┃┃┣┫┃┃┓┫
//   ┗┛┗┛┗━━┛┗┛┗┛┗━┻━┛┗┛┗┛┗┻━┛┗━━┛     ┗┻┛┗━┛┗┻━┻┛┗┛┗┛┗┻┛
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  int count = 0;
  cin >> s;
  if (s == "RRR") {
    cout << 3;
  } else if (s == "SRR" || s == "RRS") {
    cout << 2;
  } else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") {
    cout << 1;
  } else {
    std::cout << 0;
  }
  return 0;
}
// By Ashwani Kumar, Indian Institute Of Technology(IIT), Guwahati.
//   ╔══╗╔══╗╔══╗     ╔══╗╔╦╗╔╦═╦╗╔══╗╔╗╔╗╔══╗╔══╗╔══╗
//   ╚║║╝╚║║╝╚╗╔╝     ║╔═╣║║║║║║║║║╔╗║║╚╝║║╔╗║╚╗╔╝╚║║╝
//   ╔║║╗╔║║╗─║║─     ║╚╗║║║║║║║║║║╠╣║║╔╗║║╠╣║─║║─╔║║╗
//   ╚══╝╚══╝─╚╝─     ╚══╝╚═╝╚═╩═╝╚╝╚╝╚╝╚╝╚╝╚╝─╚╝─╚══╝


Error: TLE

Fixed submission:

//   ┏━━┓┏━━┓┏┓┏┓┏┳━┳┓┏━━┓┏━┳┓┏━━┓     ┏┳┓┏┳┓┏━┳━┓┏━━┓┏━┓
//   ┃┏┓┃┃━━┫┃┗┛┃┃┃┃┃┃┃┏┓┃┃┃┃┃┗┃┃┛     ┃┏┛┃┃┃┃┃┃┃┃┃┏┓┃┃╋┃
//   ┃┣┫┃┣━━┃┃┏┓┃┃┃┃┃┃┃┣┫┃┃┃┃┃┏┃┃┓     ┃┗┓┃┃┃┃┃┃┃┃┃┣┫┃┃┓┫
//   ┗┛┗┛┗━━┛┗┛┗┛┗━┻━┛┗┛┗┛┗┻━┛┗━━┛     ┗┻┛┗━┛┗┻━┻┛┗┛┗┛┗┻┛
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  int count = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R') {
      count = 1;
      while (s[i] == 'R') {
        count++;
      }
    }
  }
  cout << count;
  return 0;
}
// By Ashwani Kumar, Indian Institute Of Technology(IIT), Guwahati.
//   ╔══╗╔══╗╔══╗     ╔══╗╔╦╗╔╦═╦╗╔══╗╔╗╔╗╔══╗╔══╗╔══╗
//   ╚║║╝╚║║╝╚╗╔╝     ║╔═╣║║║║║║║║║╔╗║║╚╝║║╔╗║╚╗╔╝╚║║╝
//   ╔║║╗╔║║╗─║║─     ║╚╗║║║║║║║║║║╠╣║║╔╗║║╠╣║─║║─╔║║╗
//   ╚══╝╚══╝─╚╝─     ╚══╝╚═╝╚═╩═╝╚╝╚╝╚╝╚╝╚╝╚╝─╚╝─╚══╝
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define int long long
#define PI 3.14159265
int mod = 1000000009;
#define fi(i, start, end) for (int i = 0; i < n; i++)
#define pb(x) push_back(x)
#define int long long
#define PI 3.14159265
#define all(v) v.begin(), v.end()
#define endl cout << "\\n"
#define ll long long
#define dbg(x)                                                                 \\
  cout << #x << " " << x;                                                      \\
  endl;
#define bye                                                                    \\
  endl;                                                                        \\
  return
using namespace std;
template <typename T>

void debug(vector<T> x) {
  for (auto e : x) {
    cout << e << " ";
  }
  cout << "\\n";
}
/*
1
8 6
1 2 4 1 2 4 1 2

*/

void solve() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  bool start = false;
  int cur = 0;
  vector<int> helper;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      if (!start) {
        start = true;
      }
      cur++;
    } else {
      if (start) {
        helper.push_back(cur);
        cur = 0;
        start = false;
      }
    }
  }
  if (cur > 0)
    helper.push_back(cur);
  int ans = 0;
  if ((int)helper.size() > (int)0)
    ans = *max_element(all(helper));

  cout << ans;
  bye;
}

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

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define int long long
#define PI 3.14159265
int mod = 1000000009;
#define fi(i, start, end) for (int i = 0; i < n; i++)
#define pb(x) push_back(x)
#define int long long
#define PI 3.14159265
#define all(v) v.begin(), v.end()
#define endl cout << "\\n"
#define ll long long
#define dbg(x)                                                                 \\
  cout << #x << " " << x;                                                      \\
  endl;
#define bye                                                                    \\
  endl;                                                                        \\
  return
using namespace std;
template <typename T>

void debug(vector<T> x) {
  for (auto e : x) {
    cout << e << " ";
  }
  cout << "\\n";
}
/*
1
8 6
1 2 4 1 2 4 1 2

*/

void solve() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  bool start = false;
  int cur = 0;
  vector<int> helper;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'S') {
      if (!start) {
        start = true;
      }
      cur++;
    } else {
      if (start) {
        helper.push_back(cur);
        cur = 0;
        start = false;
      }
    }
  }
  if (cur > 0)
    helper.push_back(cur);
  int ans = *max_element(all(helper));
  cout << ans;
  bye;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  ;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  string str;

  cin >> str;
  int c = 0;

  if (str == "SSS")
    c = 0;
  else if (str == "SSR")
    c = 1;
  else if (str == "SRS")
    c = 1;
  else if (str == "SRR")
    c = 2;
  else if (str == "RSS")
    c = 1;
  else if (str == "RSR")
    c = 1;
  else if (str == "RRS")
    c = 2;
  else if (str == "RRR")
    c = 3;

  cout << c << endl;
}

Error: 1

Fixed submission:

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

int main(void) {
  string str;

  cin >> str;
  int c = 0;

  if (str == "SSS")
    c = 0;
  else if (str == "SSR")
    c = 1;
  else if (str == "SRS")
    c = 1;
  else if (str == "SRR")
    c = 2;
  else if (str == "RSS")
    c = 1;
  else if (str == "RSR")
    c = 1;
  else if (str == "RRS")
    c = 2;
  else if (str == "RRR")
    c = 3;

  cout << c << endl;

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string B;
  cin >> B;
  int A = 0;
  rep(i, 3) {
    if (B.at(i) == 'R') {
      A++;
      if (i == 2) {
        break;
      } else {
        if (B.at(i + 1) == 'R') {
          A++;
          if (i == 1) {
            break;
          } else {
            if (B.at(i + 2) == 'R') {
              A++;
              break;
            } else {
              break;
            }
          }
        } else {
          break;
        }
      }
    } else if (i == 2) {
      break;
    }
  }
  cout << A << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string B;
  cin >> B;
  int A = 0;
  rep(i, 3) {
    if (B.at(i) == 'R') {
      A++;
      if (i == 2) {
        break;
      } else {
        if (B.at(i + 1) == 'R') {
          A++;
          if (i == 1) {
            break;
          } else {
            if (B.at(i + 2) == 'R') {
              A++;
              break;
            } else {
              break;
            }
          }
        } else {
          break;
        }
      }
    }
  }
  cout << A << endl;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

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

int solve(string S) {
  int max_global = 0;
  int max_current = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == 'R') {
      max_current++;
      max_global = max(max_global, max_current);
    } else {
      max_global = max(max_global, max_current);
      max_current = 0;
    }
  }
  return max_global;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("../input.txt","r",stdin);

  string S;
  cin >> S;

  cout << solve(S);
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define endl "\\n"
#define mset(arr, val) memset((arr), (val), sizeof(arr))
#define For(i, init, n) for (int64_t(i) = (init); (i) < (n); (i)++)
#define ___                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;

// const double PI = acos(-1.0), E = exp(1.0), EPS = 1e-9;
const int MOD = (int)1e9 + 7, N = (int)1e5;

int main() {
#ifdef MY_PREPROCESSOR
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ___

      string s;
  cin >> s;
  vector<int> cnt;
  int tmp = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != 'R') {
      cnt.push_back(tmp);
      tmp = 0;
    } else {
      tmp++;
    }
  }
  cout << *max_element(cnt.begin(), cnt.end());

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

#include <bits/stdc++.h>
#define mod 1000000007
// #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main() {
  // fast_cin();
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string s;
  cin >> s;
  vector<int> var;
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      count++;
    } else {
      var.push_back(count);
      count = 0;
    }
  }
  var.push_back(count);
  cout << *max_element(var.begin(), var.end());
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define mod 1000000007
#define fast_cin()                                                             \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
using namespace std;

int main() {
  fast_cin();
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string s;
  cin >> s;
  vector<int> var;
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      count++;
    } else {
      var.push_back(count);
      count = 0;
    }
  }
  cout << *max_element(var.begin(), var.end());
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

int main() {
  string s = "";
  cin >> s;
  bool p = s[0] == 'R';
  bool q = s[1] == 'R';
  bool r = s[2] == 'R';
  if (p && q && r) {
    cout << 3 << endl;
  } else if (p && q || q && r) {
    cout << 2 << endl;
  } else {
    if (p || q || r) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}

Error: 1

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  int count = 0;
  int prev = 0;
  string s = "";
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      if (prev == 1)
        count++;
      prev = 1;
    } else {
      prev = 0;
    }
  }
  return count;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  vector<int> v;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'R') {
      cnt++;
      if (i == s.length() - 1) {
        v.push_back(cnt);
        break;
      }
    } else {
      v.push_back(cnt);
      cnt = 0;
    }
  }

  cout << *max_element(v.begin(), v.end()) << endl;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  vector<int> v;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'R') {
      cnt++;
    } else {
      v.push_back(cnt);
      cnt = 0;
    }
  }

  cout << *max_element(v.begin(), v.end()) << endl;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int max_count = 0, count = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'R') {
      count++;
      max_count = max(max_count, count);
    }
    if (s[i] == 'S') {
      count = 0;
    }
  }
  cout << max_count;
  return 0;
}


Error: 2

Fixed submission:

#include <bits/stdc++.h>
int main() {
  char s[3];
  scanf("%s", s);
  if (s[0] == 'R') {
    if (s[1] == 'R') {
      if (s[2] == 'R') {
        return 3;
      }
      return 2;
    }
    return 1;
  } else if (s[1] == 'R') {
    if (s[2] == 'R') {
      return 2;
    }
    return 1;
  } else if (s[2] == 'R') {
    return 1;
  } else
    return 0;
  return 0;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;

int main() {
  string s;
  cin >> s;
  int rCnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R')
      rCnt++;
  }

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

Error: 2

Fixed submission:

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;

int main() {
  string s;
  cin >> s;
  int rCnt = 0;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] == 'R')
      rCnt++;
  }

  if (rCnt == 1) {
    return rCnt;
  }
  if (rCnt == 2 && s[1] == 'R') {
    return rCnt;
  } else {
    return 1;
  }
  return rCnt;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

// g++ foo.cpp -o foo
#include <iostream>
using namespace std;

int main() {
  int countR = 0;
  int maxR = 0;
  string data;
  cin >> data;
  for (int i = 0; i < 3; i++) {
    if (data.at(i) == 'R') {
      countR++;
      if (maxR < countR)
        maxR = countR;
    } else {
      countR = 0;
    }
  }
  cout << maxR << endl;
};

Error: -11

Fixed submission:

// g++ foo.cpp -o foo
#include <iostream>
using namespace std;

int main() {
  int countR = 0;
  int maxR = 0;
  char *data;
  cin >> data;
  for (int i = 0; i < 3; i++) {
    if (maxR < countR)
      maxR = countR;
    if (data[i] == 'R')
      countR += 1;
    else
      countR = 0;
  }
  cout << maxR << endl;
};
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <iostream>
// #include <boost/math/common_factor.hpp>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;

#define all(x) x.begin(), x.end()
#define reg(i, x) for (ll i = 0; i < x; i++)
#define regi(i, a, x) for (ll i = a; i < x; i++)
#define rev(i, n) for (ll i = n - 1; i > 0; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
// const ll INF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
ll MAXN = 10e9;
int main() {
  string s;
  cin >> s;
  vi v;
  int cnt = 0;
  v.pb(0);
  reg(i, s.size()) {
    if (s[i] == 'R')
      cnt++;
    else {
      if (cnt != 0)
        v.pb(cnt);
      cnt = 0;
    }
  }
  if (cnt != 0)
    v.pb(cnt);
  cout << *max_element(all(v)) << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
// #include <boost/math/common_factor.hpp>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;

#define all(x) x.begin(), x.end()
#define reg(i, x) for (ll i = 0; i < x; i++)
#define regi(i, a, x) for (ll i = a; i < x; i++)
#define rev(i, n) for (ll i = n - 1; i > 0; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
// const ll INF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
ll MAXN = 10e9;
int main() {
  string s;
  cin >> s;
  vi v;
  int cnt = 0;
  reg(i, s.size()) {
    if (s[i] == 'R')
      cnt++;
    else {
      if (cnt != 0)
        v.pb(cnt);
      cnt = 0;
    }
  }
  if (cnt != 0)
    v.pb(cnt);
  cout << *max_element(all(v)) << endl;
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

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

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

int main() {
  string str;
  int i, c;
  i = c = 0;
  cin >> str;

  while (1) {
    if (i >= 3) {
      break;
    }
    if (str[i] == 'R') {
      c += 1;
    }
    if (c != 0 && str[i] == 'S') {
      break;
    }
    i += 1;
  }
  cout << c << endl;
}

Error: 0

Fixed submission:

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

int main() {
  string str;
  int i, c;
  i = c = 0;
  cin >> str;

  while (1) {
    if (str[i] == 'R') {
      c += 1;
    }
    if (c != 0 && str[i] == 'S') {
      break;
    }
    i += 1;
  }
  cout << c << endl;
}
Problem p02582 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  string a;
  cin >> a;

  int i, k = 0;

  for (i = 0; i < 3; i++) {
    if (a.at(i) == 'R') {
      k++;
      if (i != 2 && a.at(i + 1) != 'R') {
        break;
      }
    }
  }

  cout << k;

  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  string a;
  cin >> a;

  int i, k = 0;

  for (i = 0; i < 3; i++) {
    if (a.at(i) == 'R') {
      k++;
      if (a.at(i + 1) != 'R') {
        break;
      }
    }
  }

  cout << k;

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

#include <iostream>
#include <string>

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

  if ("RRS" == S || "SRR" == S) {
    std::cout << "2";
  }
  if ("SSS" == S) {
    std::cout << "0";
  }
  if ("RSR" == S || "RSS" == S || "SSR" == S || "SRS" == S) {
    std::cout << "1";
  }
  if ("RRR" == S) {
    std::cout << "3";
  }
  return 0;
}

Error: 1

Fixed submission:

#include <iostream>
#include <string>

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

  if ("RRS" == S || "SRR" == S) {
    std::cout << "2";
  }
  if ("SSS" == S) {
    std::cout << "0";
  }
  if ("RSR" == S || "RSS" == S || "SSR" == S || "SRS" == S) {
    std::cout << "1";
  }
  return 1;
}
Problem p02582 (C++) — buggy submission, verdict: Time Limit Exceeded

// #include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define pb emplace_back
#define LOCAL

using namespace std;

const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
typedef long long ll;
typedef pair<int, int> Pii;

template <typename T> inline void read(T &t) {
  char c = getchar();
  t = 0;
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (isdigit(c))
    t = t * 10 + c - 48, c = getchar();
  t = f * t;
}

template <typename T, typename... Args> inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}

string s;

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

Error: TLE

Fixed submission:

// #include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define pb emplace_back
#define LOCAL

using namespace std;

const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
typedef long long ll;
typedef pair<int, int> Pii;

template <typename T> inline void read(T &t) {
  char c = getchar();
  t = 0;
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (isdigit(c))
    t = t * 10 + c - 48, c = getchar();
  t = f * t;
}

template <typename T, typename... Args> inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}

string s;

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