prithivMLmods/Coder-Stat huggingface dataset:
Problem p02582 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <iomanip>

using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
int main() {
  string a;
  cin >> a;
  int count = 0;
  int i = 0;
  while (i < 3) {
    if (a[i] == 'R') {
      count++;
    }
  }
  if (count == 2) {
    if (a[0] == 'R' && a[2] == 'R') {
      count = 1;
    }
  }
  cout << count;
}

Fixed submission:
#include <bits/stdc++.h>
#include <iomanip>

using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
int main() {
  string a;
  cin >> a;
  int count = 0;
  int i = 0;
  while (i < 3) {
    if (a[i] == 'R') {
      count++;
    }
    i++;
  }
  if (count == 2) {
    if (a[0] == 'R' && a[2] == 'R') {
      count = 1;
    }
  }
  cout << count;
}
Problem p02582 (C++)

Buggy submission (status: 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 (a.at(i + 1) != 'R') {
        break;
      }
    }
  }

  cout << k;

  return 0;
}

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 (i != 2 && a.at(i + 1) != 'R') {
        break;
      }
    }
  }

  cout << k;

  return 0;
}
Problem p02582 (C++)

Buggy submission (status: 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;
}

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;
}
Problem p02582 (C++)

Buggy submission (status: 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";
  }
  return 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";
  }
  if ("RRR" == S) {
    std::cout << "3";
  }
  return 0;
}
Problem p02582 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string s;
  getline(cin, s);
  vector<int> count;
  int c = 0;
  ;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      c++;
    } else {
      count.push_back(c);
      c = 0;
    }
  }
  sort(count.begin(), count.end(), greater<int>());
  cout << count[0];
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string s;
  getline(cin, s);
  vector<int> count;
  int c = 0;
  ;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      c++;
    } else {
      count.push_back(c);
      c = 0;
    }
    count.push_back(c);
  }
  sort(count.begin(), count.end(), greater<int>());
  cout << count[0];
  return 0;
}
Problem p02582 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <vector>
using namespace std;

int main(void) {
  char S[3];
  cin >> S;

  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    if (S[i] == 'R')
      ++ans;
  }
  if (ans == 2 && S[1] == 'S')
    ans = 1;

  cout << ans;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <vector>
using namespace std;

int main(void) {
  string S;
  cin >> S;

  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    if (S[i] == 'R')
      ++ans;
  }
  if (ans == 2 && S[1] == 'S')
    ans = 1;

  cout << ans;
  return 0;
}
Problem p02582 (C++)

Buggy submission (status: 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;) {
    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;
}


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; ++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;
}
Problem p02582 (C++)

Buggy submission (status: 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[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;
}

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 = 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;
}
Problem p02582 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02582 (C++)

Buggy submission (status: 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) {
    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;
}

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) {
    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;
}
Problem p02582 (C++)

Buggy submission (status: 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;
        }
      }
    }
  }
  cout << A << endl;
}

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;
        }
      }
    } else if (i == 2) {
      break;
    }
  }
  cout << A << endl;
}
Problem p02582 (C++)

Buggy submission (status: 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++;
    } else {
      v.push_back(cnt);
      cnt = 0;
    }
  }

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


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++;
      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;
}
Problem p02582 (C++)

Buggy submission (status: 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;

  return 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;
}
Problem p02582 (C++)

Buggy submission (status: 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 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 0;
}
Problem p02582 (C++)

Buggy submission (status: 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 (str[i] == 'R') {
      c += 1;
    }
    if (c != 0 && str[i] == 'S') {
      break;
    }
    i += 1;
  }
  cout << c << endl;
}

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 (i >= 3) {
      break;
    }
    if (str[i] == 'R') {
      c += 1;
    }
    if (c != 0 && str[i] == 'S') {
      break;
    }
    i += 1;
  }
  cout << c << endl;
}
Problem p02582 (Python)

Buggy submission (status: Runtime Error):
s = input()

cnt = 0
L = []
for i in s:
    if i == "R":
        cnt += 1
    else:
        L.append(cnt)
        cnt = 0

print(max(L))


Fixed submission:
s = input()

cnt = 0
L = []
for i in s:
    if i == "R":
        cnt += 1
    else:
        L.append(cnt)
        cnt = 0
L.append(cnt)
print(max(L))
Problem p02582 (C++)

Buggy submission (status: 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;
  }
  cout << *max_element(lan.begin(), lan.end());
}

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;
  }
  lan.push_back(0);
  cout << *max_element(lan.begin(), lan.end());
}
Problem p02582 (C++)

Buggy submission (status: 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, 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();
  }
}


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, 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();
  }
}
Problem p02582 (Python)

Buggy submission (status: Runtime Error):
S = int(input())

flag = False
ans = 0
for i in range(len(S)):
    if S[i] == "R":
        ans += 1
        flag = True
    elif S[i] == "S" and flag:
        break

print(ans)


Fixed submission:
S = input()

flag = False
ans = 0
for i in range(len(S)):
    if S[i] == "R":
        ans += 1
        flag = True
    elif S[i] == "S" and flag:
        break

print(ans)
Problem p02582 (Python)

Buggy submission (status: Runtime Error):
S = input()
rain_d = 0
for s in S:
    if s == "R":
        rain_d += 1
        max_rain_d = rain_d
    elif s == "S":
        rain_d = 0
print(max_rain_d)


Fixed submission:
S = input()
rain_d = 0
max_rain_d = 0
for s in S:
    if s == "R":
        rain_d += 1
        max_rain_d = rain_d
    elif s == "S":
        rain_d = 0
print(max_rain_d)
Problem p02582 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02582 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-
s = input()

maxs = 0
ans = []
for a in s:
    if a == "R":
        maxs += 1
    else:
        ans.append(maxs)
        maxs = 0


print(max(ans))


Fixed submission:
# -*- coding: utf-8 -*-
s = input()

maxs = 0
ans = []
for a in s:
    if a == "R":
        maxs += 1
    else:
        ans.append(maxs)
        maxs = 0


ans.append(maxs)
print(max(ans))
Problem p02582 (Python)

Buggy submission (status: Runtime Error):
s = input()

if "RRR" in s:
    ans = 3
elif "RR" in s:
    ans = 2
elif "R" in s:
    ans = 1

print(ans)


Fixed submission:
s = input()

if "RRR" in s:
    ans = 3
elif "RR" in s:
    ans = 2
elif "R" in s:
    ans = 1
else:
    ans = 0

print(ans)
Problem p02582 (C++)

Buggy submission (status: 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;
  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;
}


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;
  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;
}
Problem p02582 (Python)

Buggy submission (status: Runtime Error):
s = input()

ans = s.index("S")

print(ans)


Fixed submission:
s = input()

if "RRR" in s:
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
Problem p02582 (Python)

Buggy submission (status: Runtime Error):
S = input()

R = []
r = 0
for s in S:
    if s == "R":
        r += 1
    if s == "S":
        R.append(r)
        r = 0

print(max(R))


Fixed submission:
S = input()

R = []
r = 0
for s in S:
    if s == "R":
        r += 1
    if s == "S":
        R.append(r)
        r = 0
    R.append(r)

print(max(R))
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
// using ll = long long;

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < L.size() - 2; i++) {
    for (int j = i + 1; j < L.size() - 1; j++) {
      if (L[i] == L[j])
        continue;
      auto itel = upper_bound(L.begin(), L.end(), L[j]);
      int l = itel - L.begin();

      auto ite = lower_bound(L.begin(), L.end(), L[i] + L[j]);
      int r = ite - L.begin();
      // cerr << l << " " << r << endl;
      ans += r - l;
    }
  }

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
// using ll = long long;

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> L(N);
  if (N < 3) {
    cout << 0 << endl;
    return 0;
  }
  rep(i, N) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < L.size() - 2; i++) {
    for (int j = i + 1; j < L.size() - 1; j++) {
      if (L[i] == L[j])
        continue;
      auto itel = upper_bound(L.begin(), L.end(), L[j]);
      int l = itel - L.begin();

      auto ite = lower_bound(L.begin(), L.end(), L[i] + L[j]);
      int r = ite - L.begin();
      // cerr << l << " " << r << endl;
      ans += r - l;
    }
  }

  cout << ans << endl;
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
const int inf = 1e9 + 7;
const int N = 1e6 + 9;

int main() {
  ios_base::sync_with_stdio(0);
  int a, b, n;
  cin >> n;
  // set<int> st;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    // st.insert(a);
    v.pb(a);
  }
  // for(int p: st) {
  // v.pb(p);
  // }
  sort(v.begin(), v.end());
  int cnt = 0;
  for (int i = 0; i < v.size(); ++i) {
    // cout<<v[i]<<endl;
    for (int j = i + 1; j < v.size(); ++j)
      if (v[j] != v[i]) {
        for (int k = j + 1; k < v.size(); ++k)
          if (v[k] != v[i] && v[k] != v[j]) {
            if (v[i] + v[j] > v[k]) {
              cerr << v[i] << " " << v[j] << " " << v[k] << endl;
              cerr << " " << i + 1 << " " << j + 1 << " " << k + 1 << endl;
              ++cnt;
            }
          }
      }
  }
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
const int inf = 1e9 + 7;
const int N = 1e6 + 9;

int main() {
  ios_base::sync_with_stdio(0);
  int a, b, n;
  cin >> n;
  // set<int> st;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    // st.insert(a);
    v.pb(a);
  }
  // for(int p: st) {
  // v.pb(p);
  // }
  sort(v.begin(), v.end());
  int cnt = 0;
  for (int i = 0; i < v.size(); ++i) {
    // cout<<v[i]<<endl;
    for (int j = i + 1; j < v.size(); ++j)
      if (v[j] != v[i]) {
        for (int k = j + 1; k < v.size(); ++k)
          if (v[k] != v[i] && v[k] != v[j]) {
            if (v[i] + v[j] > v[k]) {
              // cerr<<v[i]<<" "<<v[j]<<" "<<v[k]<<endl;
              // cerr<<" "<<i+1<<" "<<j+1<<" "<<k+1<<endl;
              ++cnt;
            }
          }
      }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02583 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d", __LINE__)
using namespace std;
long long a[114511141];
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  if (n < 3)
    return printf("0");
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      for (int k = j + 1; k <= n; k++)
        if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
          if (a[i] + a[j] > a[k])
            if (a[i] + a[k] > a[j])
              if (a[j] + a[k] > a[i])
                cnt++;
  printf("%d", cnt);
  return 0;
}


Fixed submission:
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d", __LINE__)
using namespace std;
long long a[114511141];
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  if (n < 3)
    return printf("0"), 0;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &a[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      for (int k = j + 1; k <= n; k++)
        if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
          if (a[i] + a[j] > a[k])
            if (a[i] + a[k] > a[j])
              if (a[j] + a[k] > a[i])
                cnt++;
  printf("%d", cnt);
  return 0;
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main() {

  int N;
  cin >> N;
  vector<ull> L(N);
  for (int i = 0; i < N; i++)
    cin >> L.at(i);

  ull a = 0, b = 0, c = 0, cnt = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        a = L.at(i);
        b = L.at(j);
        c = L.at(k);

        if ((a + b > c) && (b + c > a) && (c + a > b) && (L.at(i) != L.at(j)) &&
            (L.at(j) != L.at(k)) && (L.at(k) != L.at(i))) {
          cerr << i + 1 << " " << j + 1 << " " << k + 1 << endl;
          cerr << L.at(i) << " " << L.at(j) << " " << L.at(k) << endl;
          cerr << a << " " << b << " " << c << endl;
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main() {

  int N;
  cin >> N;
  vector<ull> L(N);
  for (int i = 0; i < N; i++)
    cin >> L.at(i);

  ull a = 0, b = 0, c = 0, cnt = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        a = L.at(i);
        b = L.at(j);
        c = L.at(k);

        if ((a + b > c) && (b + c > a) && (c + a > b) && (L.at(i) != L.at(j)) &&
            (L.at(j) != L.at(k)) && (L.at(k) != L.at(i))) {
          //                    cerr << i+1 << " " << j+1 << " " << k+1 << endl;
          //                    cerr << L.at(i) << " " << L.at(j) << " " <<
          //                    L.at(k) << endl; cerr << a << " " << b << " " <<
          //                    c << endl;
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int n;

int main() {
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; j < n; k++) {
        if (a[i] + a[j] > a[k]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        if (a[i] + a[j] > a[k] && a[i] != a[j] && a[i] != a[k] &&
            a[j] != a[k]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

typedef long long ll;
// forループ
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
  switch (c) {
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
  case '3':
    return 3;
  case '4':
    return 4;
  case '5':
    return 5;
  case '6':
    return 6;
  case '7':
    return 7;
  case '8':
    return 8;
  case '9':
    return 9;
  default:
    return 0;
  }
}

ll a, b, c, s, t, x, y, z;
ll A, B, C, S, T, X, Y, Z;

ll cnt;

long double pi = 3.14159265358979323846;

string N, M;

unsigned long long D;

signed main() {

  cin >> a;

  vector<int> f(a);

  REP(i, a) cin >> f[i];

  // cout << f.size() << endl;

  for (x = 0; x < f.size() - 2; x++) {
    for (y = x + 1; y < f.size() - 1; y++) {
      for (z = y + 1; z < f.size(); z++) {
        if (f[x] != f[y] && f[y] != f[z] && f[x] != f[z] &&
            f[x] + f[y] > f[z] && f[z] + f[y] > f[x] && f[x] + f[z] > f[y]) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
  ;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

typedef long long ll;
// forループ
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
  switch (c) {
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
  case '3':
    return 3;
  case '4':
    return 4;
  case '5':
    return 5;
  case '6':
    return 6;
  case '7':
    return 7;
  case '8':
    return 8;
  case '9':
    return 9;
  default:
    return 0;
  }
}

ll a, b, c, s, t, x, y, z;
ll A, B, C, S, T, X, Y, Z;

ll cnt;

long double pi = 3.14159265358979323846;

string N, M;

unsigned long long D;

signed main() {

  cin >> a;

  vector<int> f(a);

  REP(i, a) cin >> f[i];

  // cout << f.size() << endl;

  for (x = 0; x < a - 2; x++) {
    for (y = x + 1; y < a - 1; y++) {
      for (z = y + 1; z < a; z++) {
        if (f[x] != f[y] && f[y] != f[z] && f[x] != f[z] &&
            f[x] + f[y] > f[z] && f[z] + f[y] > f[x] && f[x] + f[z] > f[y]) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
  ;

  return 0;
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> L;

  cin >> N;
  L.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  sort(L.begin(), L.end());

  int count = 0;

  for (int i = 0; i < L.size() - 2; i++) {
    for (int k = i + 1; k < L.size() - 1; k++) {
      if (L[i] == L[k])
        continue;
      for (int n = k + 1; n < L.size(); n++) {
        if (L[k] == L[n])
          continue;
        if (L[i] + L[k] > L[n]) {
          count++;
        } else {
          break;
        }
      }
    }
  }

  cout << count << endl;

  return 0;
}


Fixed submission:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> L;

  cin >> N;
  L.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  sort(L.begin(), L.end());

  int count = 0;

  for (int i = 0; i < L.size(); i++) {
    for (int k = i + 1; k < L.size(); k++) {
      if (L[i] == L[k])
        continue;
      for (int n = k + 1; n < L.size(); n++) {
        if (L[k] == L[n])
          continue;
        if (L[i] + L[k] > L[n]) {
          count++;
        } else {
          break;
        }
      }
    }
  }

  cout << count << endl;

  return 0;
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define rt return
#define yy cout < "Yes\n"
#define nn cout << "No\n"
#define er erase
#define cl clear
#define bg begin
#define bk break
#define ct continue
using namespace std;
struct st {};
bool cmp() { return 1; }
int go() { return 0; }
void recur() {}
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; j++) {
        if (a[i] + a[j] > a[k])
          ans++;
      }
    }
  }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
}

Fixed submission:
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define rt return
#define yy cout < "Yes\n"
#define nn cout << "No\n"
#define er erase
#define cl clear
#define bg begin
#define bk break
#define ct continue
using namespace std;
struct st {};
bool cmp() { return 1; }
int go() { return 0; }
void recur() {}
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k])
          continue;
        if (a[i] + a[j] > a[k])
          ans++;
      }
    }
  }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--)
    solve();
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  long int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; i < n; j++)
      for (int k = j + 1; k < n; k++) {
        if (arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k]) {
          if (arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] &&
              arr[j] + arr[k] > arr[i])
            cnt++;
        }
      }
  cout << cnt;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  long int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = j + 1; k < n; k++) {
        if (arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k]) {
          if (arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] &&
              arr[j] + arr[k] > arr[i])
            cnt++;
        }
      }
  cout << cnt;
}
Problem p02583 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  int64_t N;
  cin >> N;
  vector<int64_t> L(N);
  if (N < 3) {
    cout << 0;
    return 0;
  }
  for (int64_t i = 0; i < N; i++) {
    cin >> L.at(i);
  }

  sort(L.begin(), L.end());

  int64_t cnt = 0;
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = i + 1; j < N; j++) {
      if (L.at(i) == L.at(j)) {
        continue;
      }
      for (int64_t k = j + 1; k < N; j++) {
        if (L.at(i) == L.at(k) or L.at(j) == L.at(k)) {
          continue;
        }
        if (L.at(i) + L.at(j) > L.at(k) and L.at(j) + L.at(k) > L.at(i) and
            L.at(k) + L.at(i) > L.at(j)) {
          cnt++;
        }
      }
    }
  }
  cout << cnt;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  int64_t N;
  cin >> N;
  vector<int64_t> L(N);
  if (N < 3) {
    cout << 0;
    return 0;
  }
  for (int64_t i = 0; i < N; i++) {
    cin >> L.at(i);
  }

  sort(L.begin(), L.end());

  int64_t cnt = 0;
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = i + 1; j < N; j++) {
      if (L.at(i) == L.at(j)) {
        continue;
      }
      for (int64_t k = j + 1; k < N; k++) {
        if (L.at(i) == L.at(k) or L.at(j) == L.at(k)) {
          continue;
        }
        if (L.at(i) + L.at(j) > L.at(k) and L.at(j) + L.at(k) > L.at(i) and
            L.at(k) + L.at(i) > L.at(j)) {
          cnt++;
        }
      }
    }
  }
  cout << cnt;

  return 0;
}
Problem p02583 (C++)

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

int main() {
  int N;
  cin >> N;

  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }

  sort(L.begin(), L.end());

  long long int ans = 0;
  for (int i = 0; i < L.size() - 2; i++) {
    for (int j = i + 1; j < L.size() - 1; j++) {
      for (int k = j + 1; k < L.size(); k++) {
        vector<long long int> l(3);
        l.at(0) = L.at(i);
        l.at(1) = L.at(j);
        l.at(2) = L.at(k);
        sort(l.begin(), l.end());

        if (l.at(0) == l.at(1) || l.at(1) == l.at(2)) {
          continue;
        } else if (l.at(2) < l.at(0) + l.at(1)) {
          ans++;
        } else {
          break;
        }
      }
    }
  }

  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;

  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }

  sort(L.begin(), L.end());

  long long int ans = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        vector<long long int> l(3);
        l.at(0) = L.at(i);
        l.at(1) = L.at(j);
        l.at(2) = L.at(k);
        sort(l.begin(), l.end());

        if (l.at(0) == l.at(1) || l.at(1) == l.at(2)) {
          continue;
        } else if (l.at(2) < l.at(0) + l.at(1)) {
          ans++;
        } else {
          break;
        }
      }
    }
  }

  cout << ans << endl;
}
Problem p02583 (C++)

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

int main() {
  int n, count = 0;
  int L[n];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> L[i];
  }
  if (n < 3) {
    cout << count << endl;
  } else {
    for (int i = 0; i < n - 2; i++) {
      for (int j = 1; j < n - 1; j++) {
        for (int k = 2; k < n; k++) {
          if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
            if (i < j && j < k && i < k) {
              if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] &&
                  L[k] + L[i] > L[j]) {
                count++;
              }
            }
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}

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

int main() {
  int n, count = 0;
  int L[n];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> L[i];
  }
  if (n < 3) {
    cout << count << endl;
  } else {
    for (int i = 0; i < n - 2; i++) {
      for (int j = 1; j < n - 1; j++) {
        for (int k = 2; k < n; k++) {
          if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
            if (i < j && j < k) {
              if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] &&
                  L[k] + L[i] > L[j]) {
                count++;
              }
            }
          }
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
Problem p02583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> L;

  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (L[i] != L[j]) {
        for (int k = j + 1; k < N; k++) {
          if (L[i] != L[k] && L[j] != L[k]) {
            if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] &&
                L[j] + L[k] > L[i]) {
              cnt++;
            }
          }
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int L[100];

  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (L[i] != L[j]) {
        for (int k = j + 1; k < N; k++) {
          if (L[i] != L[k] && L[j] != L[k]) {
            if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] &&
                L[j] + L[k] > L[i]) {
              cnt++;
            }
          }
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9 + 7;
// const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  ll cnt = 0;
  for (ll i = 0; i < l.size() - 2; i++) {
    for (ll j = i + 1; j < l.size() - 1; j++) {
      for (ll k = j + 1; k < l.size(); k++) {
        if (l[i] == l[j] || l[j] == l[k])
          continue;
        if (l[i] + l[j] > l[k])
          cnt++;
        if (l[i] + l[j] <= l[k])
          break;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9 + 7;
// const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  ll cnt = 0;
  for (ll i = 0; i < l.size(); i++) {
    for (ll j = i + 1; j < l.size(); j++) {
      for (ll k = j + 1; k < l.size(); k++) {
        if (l[i] == l[j] || l[j] == l[k])
          continue;
        if (l[i] + l[j] > l[k])
          cnt++;
        if (l[i] + l[j] <= l[k])
          break;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}
Problem p02583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9 + 7;
// const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  ll cnt = 0;
  for (ll i = 0; i < l.size() - 2; i++) {
    for (ll j = i + 1; j < l.size(); j++) {
      for (ll k = j + 1; k < l.size(); k++) {
        if (l[i] == l[j] || l[j] == l[k])
          continue;
        if (l[i] + l[j] > l[k])
          cnt++;
        if (l[i] + l[j] <= l[k])
          break;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < int(N); ++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9 + 7;
// const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];
  sort(l.begin(), l.end());
  ll cnt = 0;
  for (ll i = 0; i < l.size(); i++) {
    for (ll j = i + 1; j < l.size() - 1; j++) {
      for (ll k = j + 1; k < l.size(); k++) {
        if (l[i] == l[j] || l[j] == l[k])
          continue;
        if (l[i] + l[j] > l[k])
          cnt++;
        if (l[i] + l[j] <= l[k])
          break;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}