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

Buggy submission (status: Time Limit Exceeded):
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#define FR first
#define SC second
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 200010, p = 1000000007, inf = 100000000;
int pow(int a, int b, int c) {
  if (a == 0)
    return 0;
  int d = a, e = 1;
  while (b) {
    if (b & 1)
      e = (1LL * e * d) % c;
    d = 1LL * d * d % c;
    b >>= 1;
  }
  return e;
}
int random(int n) { return 1LL * rand() * rand() % n + 1; }
struct Edge {
  int y, ne;
};
/*int read(int &x)
{
        while (buf[pt]<=32&&pt<len) pt++;
        if (pt>=len) return 0;
        x=0;
        while (buf[pt]>32) x=x*10+buf[pt++]-48;
        return 1;
}*/
int sg(int n, int k) { return n % k == 0 ? n / k : sg(n - n / k - 1, k); }
int main() {
  int n, m, ans = 0;
  scanf("%d", &n);
  while (n--) {
    int x, k;
    scanf("%d%d", &x, &k);
    ans ^= sg(x, k);
  }
  if (ans)
    cout << "Takahashi";
  else
    cout << "Aoki";
  return 0;
}


Fixed submission:
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#define FR first
#define SC second
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 200010, p = 1000000007, inf = 100000000;
int pow(int a, int b, int c) {
  if (a == 0)
    return 0;
  int d = a, e = 1;
  while (b) {
    if (b & 1)
      e = (1LL * e * d) % c;
    d = 1LL * d * d % c;
    b >>= 1;
  }
  return e;
}
int random(int n) { return 1LL * rand() * rand() % n + 1; }
struct Edge {
  int y, ne;
};
/*int read(int &x)
{
        while (buf[pt]<=32&&pt<len) pt++;
        if (pt>=len) return 0;
        x=0;
        while (buf[pt]>32) x=x*10+buf[pt++]-48;
        return 1;
}*/
int sg(int n, int k) {
  if (n < k)
    return 0;
  if (n % k == 0)
    return n / k;
  else {
    int t = n / k + 1;
    return sg(n - t * ((n % k - 1) / t + 1), k);
  }
}
int main() {
  int n, m, ans = 0;
  scanf("%d", &n);
  while (n--) {
    int x, k;
    scanf("%d%d", &x, &k);
    ans ^= sg(x, k);
  }
  if (ans)
    cout << "Takahashi";
  else
    cout << "Aoki";
  return 0;
}
Problem p03422 (C++)

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

int k;
int f(int n) {
  if (n % k == 0)
    return n / k;
  if (n < k)
    return 0;
  return f((n / k) * (k - 1) + n % k - 1);
}

int main() {
  // freopen("1.in","r",stdin);
  int ans = 0;
  int n;
  cin >> n;
  while (n--) {
    int a;
    cin >> a >> k;
    ans ^= f(a);
  }
  if (ans)
    puts("Takahashi");
  else
    puts("Aoki");
}

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

int k;
int f(int n) {
  if (n % k == 0)
    return n / k;
  int d = n / k + 1;
  return f(n - d * ((n % k - 1) / d + 1));
}

int main() {
  // freopen("1.in","r",stdin);
  int ans = 0;
  int n;
  cin >> n;
  while (n--) {
    int a;
    cin >> a >> k;
    ans ^= f(a);
  }
  if (ans)
    puts("Takahashi");
  else
    puts("Aoki");
}
Problem p03422 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int n, ans;
int sg(int x, int y) {
  return x % y == 0 ? x / y : sg(1ll * x * (y - 1) / y, y);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    ans ^= sg(x, y);
  }
  cout << (ans ? "Takahashi\n" : "Aoki\n");
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, ans;
int sg(int x, int y) {
  int u = x / y;
  x = u * y + (x + y) % (u + 1);
  if (x == u * y)
    return u;
  else
    return sg(x - u - 1, y);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    ans ^= sg(x, y);
  }
  cout << (ans ? "Takahashi\n" : "Aoki\n");
  return 0;
}
Problem p03422 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iostream>
#define int long long
using namespace std;
int n, sum, x, y, i;
signed main() {
  scanf("%lld", &n);
  while (n--) {
    scanf("%lld%lld", &x, &y);
    if (y <= x) {
      while (x % y != 0)
        x -= x / y + 1;
      sum ^= x / y;
    }
  }
  if (!sum)
    puts("Aoki");
  else
    puts("Takahashi");
}

Fixed submission:
#include <cstdio>
#include <iostream>
#define int long long
using namespace std;
int n, sum, x, y, i;
signed main() {
  scanf("%lld", &n);
  while (n--) {
    scanf("%lld%lld", &x, &y);
    if (y <= x) {
      while (x % y != 0) {
        int tmp = (x - x / y * y) / (x / y + 1);
        if (!tmp)
          x -= x / y + 1;
        else
          x -= tmp * (x / y + 1);
      }
      sum ^= x / y;
    }
  }
  if (!sum)
    puts("Aoki");
  else
    puts("Takahashi");
}
Problem p03422 (C++)

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

int naive(int N, int K) {
  deque<int> q;
  q.push_front(0);
  int T = N / K;
  for (int i = 1; i <= T; i++) {
    int rot = K % q.size();
    for (int j = 0; j < rot; j++) {
      int cur = q.front();
      q.pop_front();
      q.push_back(cur);
    }
    q.push_front(i);
  }
  return q[N % K];
}

int go(int N, int K) {
  while (1) {
    if (N % K == 0)
      return N / K;
    if (N < K)
      return 0;
    if (N / K <= 1000)
      return naive(N, K);
    N -= N / K + 1;
  }
}

int main() {
  int N;
  scanf("%d", &N);
  int g = 0;
  for (int i = 0; i < N; i++) {
    int a, k;
    scanf("%d%d", &a, &k);
    g ^= go(a, k);
  }
  printf(g ? "Takahashi\n" : "Aoki\n");
}


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

int naive(int N, int K) {
  deque<int> q;
  q.push_front(0);
  int T = N / K;
  for (int i = 1; i <= T; i++) {
    int rot = K % q.size();
    for (int j = 0; j < rot; j++) {
      int cur = q.front();
      q.pop_front();
      q.push_back(cur);
    }
    q.push_front(i);
  }
  return q[(N % K) % q.size()];
}

int go(int N, int K) {
  while (1) {
    if (N % K == 0)
      return N / K;
    if (N < K)
      return 0;
    if (N / K <= 1000)
      return naive(N, K);
    N -= N / K + 1;
  }
}

int main() {
  int N;
  scanf("%d", &N);
  int g = 0;
  for (int i = 0; i < N; i++) {
    int a, k;
    scanf("%d%d", &a, &k);
    g ^= go(a, k);
  }
  printf(g ? "Takahashi\n" : "Aoki\n");
}
Problem p03422 (C++)

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

using namespace std;

typedef long long LL;
typedef pair<int, int> P2;
typedef pair<pair<int, int>, int> P3;
typedef pair<pair<int, int>, pair<int, int>> P4;
#define PB(a) push_back(a)
#define MP(a, b) make_pair((a), (b))
#define M3P(a, b, c) make_pair(make_pair((a), (b)), (c))
#define M4P(a, b, c, d) make_pair(make_pair((a), (b)), make_pair((c), (d)))
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define repm(i, a, b) for (int i = (int)(a); i > (int)(b); --i)

int N;

int solve(int a, int k) {
  vector<int> v;
  v.PB(0);
  for (int i = 1; i * k <= a; ++i) {
    vector<int> u;
    u.PB(i);
    int z = k % i;
    repp(j, 0, i) { u.PB(v[(z + j) % i]); }
    swap(v, u);
  }
  return v[a % k];
}

int calc(int a, int k) {
  if (k > 1000000)
    return solve(a, k);
  if (a < k)
    return 0;
  if (a % k == 0)
    return a / k;
  return calc(a - a / k - 1, k);
}

int main() {
  cin >> N;
  int g = 0;
  repp(i, 0, N) {
    int A, K;
    cin >> A >> K;
    g ^= calc(A, K);
  }
  cout << (g != 0 ? "Takahashi" : "Aoki") << endl;
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> P2;
typedef pair<pair<int, int>, int> P3;
typedef pair<pair<int, int>, pair<int, int>> P4;
#define PB(a) push_back(a)
#define MP(a, b) make_pair((a), (b))
#define M3P(a, b, c) make_pair(make_pair((a), (b)), (c))
#define M4P(a, b, c, d) make_pair(make_pair((a), (b)), make_pair((c), (d)))
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define repm(i, a, b) for (int i = (int)(a); i > (int)(b); --i)

int N;

int solve(int a, int k) {
  vector<int> v;
  v.PB(0);
  for (int i = 1; i * k <= a; ++i) {
    vector<int> u;
    u.PB(i);
    int z = k % i;
    repp(j, 0, i) { u.PB(v[(z + j) % i]); }
    swap(v, u);
  }
  int y = v.size();
  return v[(a % k) % y];
}

int calc(int a, int k) {
  if (k > 1000000)
    return solve(a, k);
  if (a < k)
    return 0;
  if (a % k == 0)
    return a / k;
  return calc(a - a / k - 1, k);
}

int main() {
  cin >> N;
  int g = 0;
  repp(i, 0, N) {
    int A, K;
    cin >> A >> K;
    g ^= calc(A, K);
  }
  cout << (g != 0 ? "Takahashi" : "Aoki") << endl;
  return 0;
}
Problem p03422 (C++)

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

int n;

int cal(int i, int k) {
  if (i < k)
    return 0;
  if (i % k == 0)
    return i / k;
  int low = (i / k) * k + k, t = i / k + 1;
  i -= max(i / k + 1, (i - low) / t * t);
  return cal(i, k);
}

int main() {
  cin >> n;
  int sg = 0;
  for (int i = 1; i <= n; i++) {
    int a, k;
    cin >> a >> k;
    sg ^= cal(a, k);
  }
  cout << (sg ? "Takahashi" : "Aoki");
  return 0;
}


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

int n;

int cal(int i, int k) {
  if (i < k)
    return 0;
  if (i % k == 0)
    return i / k;
  int t = i / k + 1, low = (i / k) * k + t;
  i -= max(i / k + 1, (i - low) / t * t);
  return cal(i, k);
}

int main() {
  cin >> n;
  int sg = 0;
  for (int i = 1; i <= n; i++) {
    int a, k;
    cin >> a >> k;
    sg ^= cal(a, k);
  }
  cout << (sg ? "Takahashi" : "Aoki");
  return 0;
}
Problem p03423 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i = 3;
  int x = 0;
  while (n != 0) {
    x += (n / i);
    n %= i;
    i++;
  }
  cout << x << "\n";
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;
  cout << n / 3 << "\n";
}
Problem p03423 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int n, s = 0;
  int p = 3;
  cin >> n;
  while (n) {
    while (n >= p + 3 || n == p) {
      s++;
      n -= p;
    }
    p++;
  }
  cout << s;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, s = 0;
  int p = 3;
  cin >> n;
  if (n <= 2) {
    cout << 0;
    return 0;
  }
  while (n) {
    while (n >= p + 3 || n == p) {
      s++;
      n -= p;
    }
    p++;
  }
  cout << s;
  return 0;
}
Problem p03423 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a / b << endl;
}

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

int main() {
  int a;
  cin >> a;
  cout << a / 3 << endl;
}
Problem p03423 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(5);
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S.at(0) == 'M')
      vec[0]++;
    if (S.at(0) == 'A')
      vec[1]++;
    if (S.at(0) == 'R')
      vec[2]++;
    if (S.at(0) == 'C')
      vec[3]++;
    if (S.at(0) == 'H')
      vec[4]++;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  if (vec[0] == 0 || vec[1] == 0 || vec[2] == 0) {
    cout << 0 << endl;
  } else if (vec[3] == 0) {
    cout << vec[0] * vec[1] * vec[2] << endl;
  } else if (vec[4] == 0) {
    cout << vec[0] * vec[1] * vec[2] + vec[0] * vec[1] * vec[3] +
                vec[0] * vec[3] * vec[2] + vec[3] * vec[1] * vec[2]
         << endl;
  } else {
    int S = 0;
    S += vec[2] * vec[3] * vec[4];
    S += vec[1] * vec[3] * vec[4];
    S += vec[1] * vec[2] * vec[4];
    S += vec[1] * vec[2] * vec[3];
    S += vec[0] * vec[3] * vec[4];
    S += vec[0] * vec[2] * vec[4];
    S += vec[0] * vec[2] * vec[3];
    S += vec[0] * vec[1] * vec[4];
    S += vec[0] * vec[1] * vec[3];
    S += vec[0] * vec[1] * vec[2];
    cout << S << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  cout << N / 3 << endl;
}
Problem p03423 (C++)

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

int main() {
  int N;
  cin >> N;
  int p = 0;
  while (3 <= N) {
    N - 3;
    p++;
  }
  cout << p << endl;
}


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

int main() {
  int N;
  cin >> N;
  cout << N / 3 << endl;
}
Problem p03423 (C++)

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

int main() {
  int N;
  cin >> N;
  int group;
  while (2 < N) {
    group++;
    N - 3;
  }
  cout << group << endl;
}

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

int main() {
  int N;
  cin >> N;
  cout << (N - N % 3) / 3 << endl;
}
Problem p03423 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  cout << N / x << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  cout << N / 3 << endl;
  return 0;
}
Problem p03423 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;
#define MP make_pair
#define all(v) v.begin(), v.end()
#define EPS 1e-9
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = {0, 1, -1, 0, 1, -1, 1, -1};
const int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
ll fast_power(double base, ll power) {
  if (power == 1)
    return base;
  if (power % 2 == 0)
    return fast_power((base * base), power / 2);
  else
    return (base * fast_power((base * base), power / 2));
}
// #pragma warning (disable : 4996)
void Qalbaz() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(2);
}

int main() {

  Qalbaz();

  int n;
  cin >> n;

  cout << n / 3;

  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;
#define MP make_pair
#define all(v) v.begin(), v.end()
#define EPS 1e-9
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = {0, 1, -1, 0, 1, -1, 1, -1};
const int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
ll fast_power(double base, ll power) {
  if (power == 1)
    return base;
  if (power % 2 == 0)
    return fast_power((base * base), power / 2);
  else
    return (base * fast_power((base * base), power / 2));
}
// #pragma warning (disable : 4996)
void Qalbaz() {
#ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(2);
}

int main() {

  Qalbaz();

  int n;
  cin >> n;

  cout << n / 3;

  return 0;
}
Problem p03423 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  cout << a / b << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int a;
  cin >> a;
  cout << a / 3 << endl;
  return 0;
}
Problem p03424 (C++)

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

int main() {

  // 初期化
  int i = 0;
  string text;
  bool flag = false;

  cin >> i;

  // 入力検索
  while (i > 0) {
    cin >> text;
    if (text == "Y")
      flag = true;
  }

  // 出力
  if (flag)
    cout << "Four";
  else
    cout << "Three";
}

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

int main() {

  // 初期化
  int i = 0;
  string text;
  bool flag = false;

  cin >> i;

  // 入力検索
  while (i > 0) {
    cin >> text;
    if (text == "Y")
      flag = true;
    i--;
  }

  // 出力
  if (flag)
    cout << "Four";
  else
    cout << "Three";
}
Problem p03424 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main(void) {
  int n, i;
  char a[101];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%c", &a[i]);
  i = 0;
  while (i != n) {
    if (a[i] == 'Y') {
      printf("Four\n");
      return 1;
    }
    i++;
  }
  printf("Three\n");
  return 0;
}


Fixed submission:
#include <stdio.h>
int main(void) {
  int n, i;
  char a[101];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%c", &a[i]);
  i = 0;
  while (i != n) {
    if (a[i] == 'Y') {
      printf("Four\n");
      return 0;
    }
    i++;
  }
  printf("Three\n");
  return 0;
}
Problem p03424 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  string d = "Y";
  int i, x = 0;
  string color[100];
  cin >> i;
  for (; i > 0; i--) {
    cin >> color[i];
    if (color[i] == d) {
      x = 1;
    }
  }
  if (x == 1) {
    cout << "Four";
  } else {
    cout << "Three";
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  string d = "Y";
  int i, x = 0;
  string color[1000];
  cin >> i;
  for (; i > 0; i--) {
    cin >> color[i];
    if (color[i] == d) {
      x = 1;
    }
  }
  if (x == 1) {
    cout << "Four";
  } else {
    cout << "Three";
  }
  return 0;
}
Problem p03424 (C++)

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      exit(1);
    }
  }
  cout << "Three" << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      exit(0);
    }
  }
  cout << "Three" << endl;
  return 0;
}
Problem p03424 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<char> text;
  for (int i = 0; i < n; i++) {
    cin >> text.at(i);
  }
  for (int i = 0; i < n; i++) {
    if (text.at(i) == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<char> text(n);
  for (int i = 0; i < n; i++) {
    cin >> text.at(i);
  }
  for (int i = 0; i < n; i++) {
    if (text.at(i) == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}
Problem p03424 (C++)

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

int main() {
  int N;
  int i, l = 0;
  string S;
  cin >> N;

  while (i < N) {
    cin >> S.at(i);
    if (S.at(i) == 'Y') {
      l = 1;
    }
    i++;
  }

  if (l == 0) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}


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

int main() {
  int N;
  int i, l = 0;
  string S;
  cin >> N;

  while (i < N) {
    cin >> S;
    if (S == "Y") {
      l = 1;
    }
    i++;
  }

  if (l == 0) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}
Problem p03424 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int N;
  char S[11];
  string str;
  str = "Three";
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == 'Y') {
      str = "Four";
      break;
    }
  }
  cout << str;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int N;
  char S[101];
  string str;
  str = "Three";
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == 'Y') {
      str = "Four";
      break;
    }
  }
  cout << str;
}
Problem p03424 (C++)

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

int main() {
  int i, N, for4 = 0;
  string S[100] = {0};

  cin >> N;

  for (i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == "Y")
      for4++;
  }
  if (for4 > 0)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


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

int main() {
  int i, N, for4 = 0;
  string S[100];

  cin >> N;

  for (i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == "Y")
      for4++;
  }
  if (for4 > 0)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}
Problem p03424 (C++)

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

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

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

  bool count = false;
  for (int i = 0; i < N; i++) {
    if (bag.at(i) == 'Y') {
      count = true;
    }
  }
  if (count) {

    cout << "Four" << endl;
  }

  else {

    cout << "Three" << endl;
  }
}


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

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

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

  bool count = false;
  for (int i = 0; i < N; i++) {
    if (bag.at(i) == 'Y') {
      count = true;
    }
  }
  if (count) {

    cout << "Four" << endl;
  }

  else {

    cout << "Three" << endl;
  }
}
Problem p03424 (C++)

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

int main() {
  // ここにプログラムを追記
  int N;
  cin >> N;
  vector<char> hina;
  for (int i = 0; i < N; i++) {
    cin >> hina.at(i);
  }
  bool Y = false;

  for (int i = 0; i < N; i++) {
    if (hina.at(i) == 'Y') {
      Y = true;
      break;
    }
  }
  if (Y) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

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

int main() {
  // ここにプログラムを追記
  int N;
  cin >> N;
  vector<char> hina(N);
  for (int i = 0; i < N; i++) {
    cin >> hina.at(i);
  }
  bool Y = false;

  for (int i = 0; i < N; i++) {
    if (hina.at(i) == 'Y') {
      Y = true;
      break;
    }
  }
  if (Y) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}
Problem p03424 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int p = 0;
  while (p < N) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (p == N - 1) {
      cout << "Three" << endl;
      p++;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int p = 0;
  while (p < N) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    p++;
  }
  if (p == N) {
    cout << "Three" << endl;
  }
}
Problem p03424 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
S = set(map(int, input().split()))

print("Three" if len(S) == 3 else "Four")


Fixed submission:
N = int(input())
S = set(input().split())

print("Three" if len(S) == 3 else "Four")
Problem p03424 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  bool f = false;
  cin >> n;
  string s;
  cin >> s;
  REP(i, n) {
    if (s.at(i) == 'Y')
      f = true;
  }
  if (f)
    cout << "Four"
         << "\n";
  else
    cout << "Three"
         << "\n";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  bool f = false;
  cin >> n;
  vector<char> s(n);
  REP(i, n) { cin >> s.at(i); }
  REP(i, n) {
    if (s.at(i) == 'Y')
      f = true;
  }
  if (f)
    cout << "Four"
         << "\n";
  else
    cout << "Three"
         << "\n";
  return 0;
}
Problem p03424 (Python)

Buggy submission (status: Runtime Error):
(N,) = map(int, input().split())
X = set(map(int, input().split()))
if len(X) == 3:
    print("Three")
else:
    print("Four")


Fixed submission:
(N,) = map(int, input().split())
X = set(map(str, input().split()))
if len(X) == 3:
    print("Three")
else:
    print("Four")
Problem p03424 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
s = list(map(int, input().split()))

print("Four" if "Y" in s else "Three")


Fixed submission:
n = int(input())
s = list(input().split())

print("Four" if "Y" in s else "Three")
Problem p03424 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
S = list(map(int, input().split()))

if "Y" in S:
    print("Four")
else:
    print("Three")


Fixed submission:
N = int(input())
S = list(map(str, input().split()))

if "Y" in S:
    print("Four")
else:
    print("Three")
Problem p03424 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
s = list(map(input().split()))
print(len(set(s)))


Fixed submission:
N = int(input())
s = list(map(str, input().split()))
print(["Four", "Three"][len(set(s)) == 3])
Problem p03424 (Python)

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


def main():
    """Function."""
    n = int(input())
    s = list(map(str, input().split()))

    check = set()
    for i in range(n):
        check.append(s[i])

    if len(check) == 3:
        print("Three")
    else:
        print("Four")


if __name__ == "__main__":
    main()


Fixed submission:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())
    s = list(map(str, input().split()))

    check = set()
    for i in range(n):
        check.add(s[i])

    if len(check) == 3:
        print("Three")
    else:
        print("Four")


if __name__ == "__main__":
    main()
Problem p03424 (Python)

Buggy submission (status: Runtime Error):
n = input()
s = list(map(int, input().split()))

if "Y" in s:
    print("Four")
else:
    print("Three")


Fixed submission:
n = input()
s = list(input().split())

if "Y" in s:
    print("Four")
else:
    print("Three")
Problem p03424 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
ans = "Four" if "Y" in list(map(int, input().split())) else "Three"
print(ans)


Fixed submission:
N = int(input())
ans = "Four" if "Y" in list(input().split()) else "Three"
print(ans)
Problem p03424 (C++)

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

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

  int is_four = 0;
  int i = 0;
  while (i < n) {
    char color;
    cin >> color;
    if (color == 'Y')
      is_four = 1;
  }
  if (is_four)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


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

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

  int is_four = 0;
  int i = 0;
  while (i < n) {
    char color;
    cin >> color;
    if (color == 'Y')
      is_four = 1;
    i++;
  }
  if (is_four)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}
Problem p03424 (C++)

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

int main() {
  int N;
  int Y = 0;
  string S[100];
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> S[i];
    if (S[i] == "Y") {
      Y = 1;
    }
  }
  cout << endl;
  if (Y == 1) {
    cout << "Four" << endl;
  } else if (Y == 0) {
    cout << "Three" << endl;
  }
}


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

int main() {
  int N;
  int Y = 0;
  string S[101];
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> S[i];
    if (S[i] == "Y") {
      Y = 1;
    }
  }
  cout << endl;
  if (Y == 1) {
    cout << "Four" << endl;
  } else if (Y == 0) {
    cout << "Three" << endl;
  }
}
Problem p03424 (Python)

Buggy submission (status: Runtime Error):
def main(n, s):
    a = set(s)

    if len(a) == 3:
        print("Three")
    elif len(a) == 4:
        print("Four")


if __name__ == "__main__":
    n = int(input())
    s = list(map(int, input().split()))

    main(n, s)


Fixed submission:
def main(n, s):
    a = set(s)

    if len(a) == 3:
        print("Three")
    elif len(a) == 4:
        print("Four")


if __name__ == "__main__":
    n = int(input())
    s = list(input().split())

    main(n, s)
Problem p03424 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
// #include <algorithm>

using namespace std;

int main() {
  int N;
  cin >> N;
  string S[N - 1];
  bool isFour = false;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == "Y") {
      isFour = true;
    }
  }

  if (isFour) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
  // cout << result << endl;

  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
// #include <algorithm>

using namespace std;

int main() {
  int N;
  cin >> N;
  string S[N];
  bool isFour = false;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == "Y") {
      isFour = true;
    }
  }

  if (isFour) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
  // cout << result << endl;

  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> res(5, 0);
  rep(i, n) {
    string s;
    cin >> s;
    if (s[0] == 'M')
      res[0]++;
    if (s[0] == 'A')
      res[1]++;
    if (s[0] == 'R')
      res[2]++;
    if (s[0] == 'C')
      res[3]++;
    if (s[0] == 'H')
      res[4]++;
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        ans += res[i] * res[j] * res[k];
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> res(5, 0);
  rep(i, n) {
    string s;
    cin >> s;
    if (s[0] == 'M')
      res[0]++;
    if (s[0] == 'A')
      res[1]++;
    if (s[0] == 'R')
      res[2]++;
    if (s[0] == 'C')
      res[3]++;
    if (s[0] == 'H')
      res[4]++;
  }
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += res[i] * res[j] * res[k];
      }
    }
  }
  cout << ans << endl;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める
typedef long long ll;
typedef long double ld;
int main() {
  ll n;
  cin >> n;
  string s;
  vector<pair<char, ll>> v(n);
  vector<char> c = {'M', 'A', 'R', 'C', 'H'};
  REP(i, 5) { v[i].first = c[i]; }
  REP(i, n) {
    cin >> s;
    char ini = s[0];
    REP(j, 5) {
      if (v[j].first == ini) {
        v[j].second++;
        break;
      }
    }
  }
  ll sum = 0;
  REP(i, 3) {
    ll a = v[i].second;
    FOR(j, i + 1, 4) {
      ll b = v[j].second;
      FOR(k, j + 1, 5) {
        ll c = v[k].second;
        sum += a * b * c;
      }
    }
  }
  cout << sum;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   // 最大値を求める
#define MIN(x) *min_element(ALL(x))   // 最小値を求める
typedef long long ll;
typedef long double ld;
int main() {
  ll n;
  cin >> n;
  string s;
  vector<pair<char, ll>> v(5);
  vector<char> c = {'M', 'A', 'R', 'C', 'H'};
  REP(i, 5) { v[i].first = c[i]; }
  REP(i, n) {
    cin >> s;
    char ini = s[0];
    REP(j, 5) {
      if (v[j].first == ini) {
        v[j].second++;
        break;
      }
    }
  }
  ll sum = 0;
  REP(i, 3) {
    ll a = v[i].second;
    FOR(j, i + 1, 4) {
      ll b = v[j].second;
      FOR(k, j + 1, 5) {
        ll c = v[k].second;
        sum += a * b * c;
      }
    }
  }
  cout << sum;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9) + 7;
void fastIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int main() {
  fastIO();
  ll n;
  cin >> n;
  vector<ll> march(5);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    s[0] == 'M' ? march[0]++ : march[0] = march[0];
    s[0] == 'A' ? march[1]++ : march[1] = march[1];
    s[0] == 'R' ? march[2]++ : march[2] = march[2];
    s[0] == 'C' ? march[3]++ : march[3] = march[3];
    s[0] == 'H' ? march[4]++ : march[4] = march[4];
  }
  ll tot = 0;
  for (int a = 0; a < n; a++) {
    for (int b = a + 1; b < n; b++) {
      for (int c = b + 1; c < n; c++) {
        tot += march[a] * march[b] * march[c];
      }
    }
  }
  cout << tot << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9) + 7;
void fastIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int main() {
  fastIO();
  ll n;
  cin >> n;
  vector<ll> march(5);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    s[0] == 'M' ? march[0]++ : march[0] = march[0];
    s[0] == 'A' ? march[1]++ : march[1] = march[1];
    s[0] == 'R' ? march[2]++ : march[2] = march[2];
    s[0] == 'C' ? march[3]++ : march[3] = march[3];
    s[0] == 'H' ? march[4]++ : march[4] = march[4];
  }
  ll tot = 0;
  for (int a = 0; a < 5; a++) {
    for (int b = a + 1; b < 5; b++) {
      for (int c = b + 1; c < 5; c++) {
        tot += march[a] * march[b] * march[c];
      }
    }
  }
  cout << tot << endl;
}
Problem p03425 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<string> s(100000);
  set<char> march;
  march.insert('M');
  march.insert('A');
  march.insert('R');
  march.insert('C');
  march.insert('H');
  map<char, ull> memo;
  memo['M'] = 0;
  memo['A'] = 0;
  memo['R'] = 0;
  memo['C'] = 0;
  memo['H'] = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    char init = s[i].at(0);
    if (march.count(init)) {
      memo[init]++;
    }
  }

  ull ans = 0;
  vector<ull> num(5, 0);
  num[0] = memo['M'];
  num[1] = memo['A'];
  num[2] = memo['R'];
  num[3] = memo['C'];
  num[4] = memo['H'];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        ans += num[i] * num[j] * num[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(100000);
  set<char> march;
  march.insert('M');
  march.insert('A');
  march.insert('R');
  march.insert('C');
  march.insert('H');
  map<char, ull> memo;
  memo['M'] = 0;
  memo['A'] = 0;
  memo['R'] = 0;
  memo['C'] = 0;
  memo['H'] = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    char init = s[i].at(0);
    if (march.count(init)) {
      memo[init]++;
    }
  }

  ull ans = 0;
  vector<ull> num(5, 0);
  num[0] = memo['M'];
  num[1] = memo['A'];
  num[2] = memo['R'];
  num[3] = memo['C'];
  num[4] = memo['H'];
  int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
  int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
  int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

  for (int i = 0; i < 10; i++) {
    ans += num[P[i]] * num[Q[i]] * num[R[i]];
  }
  cout << ans << endl;
  return 0;
}
Problem p03425 (C++)

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

int main() {

  long long i, j, k, Sum = 0, N;
  cin >> N;
  map<char, long long> S;
  string s;
  vector<char> I = {'M', 'A', 'R', 'C', 'H'};

  for (i = 0; i < N; i++) {
    cin >> s;
    S[s[0]]++;
  }
  for (i = 0; i < N; i++) {
    for (j = i + 1; j < N; j++) {
      for (k = j + 1; k < N; k++) {
        Sum += S[I[i]] * S[I[j]] * S[I[k]];
      }
    }
  }
  cout << Sum << endl;
  return 0;
}

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

int main() {

  long long i, j, k, Sum = 0, N;
  cin >> N;
  map<char, long long> S;
  string s;
  vector<char> I = {'M', 'A', 'R', 'C', 'H'};

  for (i = 0; i < N; i++) {
    cin >> s;
    S[s[0]]++;
  }
  for (i = 0; i < 5; i++) {
    for (j = i + 1; j < 5; j++) {
      for (k = j + 1; k < 5; k++) {
        Sum += S[I[i]] * S[I[j]] * S[I[k]];
      }
    }
  }
  cout << Sum << endl;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {

  int n;
  cin >> n;

  string s[100010];
  ll MARCH[5] = {};

  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  for (int i = 0; i < n; i++) {
    switch (s[i][0]) {
    case 'M':
      MARCH[0]++;
      break;
    case 'A':
      MARCH[1]++;
      break;
    case 'R':
      MARCH[2]++;
      break;
    case 'C':
      MARCH[3]++;
      break;
    case 'H':
      MARCH[4]++;
      break;
    }
  }

  ll ans = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        ans += MARCH[i] * MARCH[j] * MARCH[k];
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {

  int n;
  cin >> n;

  string s[100010];
  ll MARCH[5] = {};

  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  for (int i = 0; i < n; i++) {
    switch (s[i][0]) {
    case 'M':
      MARCH[0]++;
      break;
    case 'A':
      MARCH[1]++;
      break;
    case 'R':
      MARCH[2]++;
      break;
    case 'C':
      MARCH[3]++;
      break;
    case 'H':
      MARCH[4]++;
      break;
    }
  }

  ll ans = 0;

  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += MARCH[i] * MARCH[j] * MARCH[k];
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = n; i >= m; i--)
#define REPO(i, n) for (int i = 1; i <= n; i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(), n.end()

int main() {
  ll n, b[5] = {}, ans = 0;
  string s;
  char a[5] = {'M', 'A', 'R', 'C', 'H'};
  cin >> n;
  REP(i, n) {
    cin >> s;
    REP(j, 5) if (s[0] == a[j]) b[j]++;
  }
  REP(i, n - 2) {
    FOR(j, i + 1, n - 1) {
      FOR(k, j + 1, n) { ans += b[i] * b[j] * b[k]; }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = n; i >= m; i--)
#define REPO(i, n) for (int i = 1; i <= n; i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(), n.end()

int main() {
  ll n, b[5] = {}, ans = 0;
  string s;
  char a[5] = {'M', 'A', 'R', 'C', 'H'};
  cin >> n;
  REP(i, n) {
    cin >> s;
    REP(j, 5) if (s[0] == a[j]) b[j]++;
  }
  REP(i, 3) {
    FOR(j, i + 1, 4) {
      FOR(k, j + 1, 5) { ans += b[i] * b[j] * b[k]; }
    }
  }
  cout << ans << endl;
}
Problem p03425 (C++)

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<ll> num(5, 0);
  REP(i, N) {
    cin >> S[i];
    // cout << S[i][0] << endl;

    if (S[i][0] == 'M')
      num[0] = num[0] + 1;
    else if (S[i][0] == 'A')
      num[1] = num[1] + 1;
    else if (S[i][0] == 'R')
      num[2] = num[2] + 1;
    else if (S[i][0] == 'C')
      num[3] = num[3] + 1;
    else if (S[i][0] == 'H')
      num[4] = num[4] + 1;
  }

  ll 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) {
        ans = ans + (num[i] * num[j] * num[k]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<ll> num(5, 0);
  REP(i, N) {
    cin >> S[i];
    // cout << S[i][0] << endl;

    if (S[i][0] == 'M')
      num[0] = num[0] + 1;
    else if (S[i][0] == 'A')
      num[1] = num[1] + 1;
    else if (S[i][0] == 'R')
      num[2] = num[2] + 1;
    else if (S[i][0] == 'C')
      num[3] = num[3] + 1;
    else if (S[i][0] == 'H')
      num[4] = num[4] + 1;
  }

  ll ans = 0;
  for (int i = 0; i < 3; ++i) {
    for (int j = i + 1; j < 4; ++j) {
      for (int k = j + 1; k < 5; ++k) {
        ans = ans + (num[i] * num[j] * num[k]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p03425 (C++)

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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n, 0);

  rep(i, n) {
    string s;
    cin >> s;
    if (s.at(0) == 'M') {
      v.at(0)++;
    } else if (s.at(0) == 'A') {
      v.at(1)++;
    } else if (s.at(0) == 'R') {
      v.at(2)++;
    } else if (s.at(0) == 'C') {
      v.at(3)++;
    } else if (s.at(0) == 'H') {
      v.at(4)++;
    }
  }
  ll ans = 0;
  for (int bit = 0; bit < (1 << 5); bit++) {
    ll sum = 1;
    int a = 0;
    rep(i, 5) {
      if (bit & (1 << i)) {
        a++;
        sum *= v.at(i);
      }
    }
    if (a == 3) {
      ans += sum;
    }
  }
  cout << ans << endl;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(5, 0);

  rep(i, n) {
    string s;
    cin >> s;
    if (s.at(0) == 'M') {
      v.at(0)++;
    } else if (s.at(0) == 'A') {
      v.at(1)++;
    } else if (s.at(0) == 'R') {
      v.at(2)++;
    } else if (s.at(0) == 'C') {
      v.at(3)++;
    } else if (s.at(0) == 'H') {
      v.at(4)++;
    }
  }
  ll ans = 0;
  for (int bit = 0; bit < (1 << 5); bit++) {
    ll sum = 1;
    int a = 0;
    rep(i, 5) {
      if (bit & (1 << i)) {
        a++;
        sum *= v.at(i);
      }
    }
    if (a == 3) {
      ans += sum;
    }
  }
  cout << ans << endl;
}