prithivMLmods/Coder-Stat huggingface dataset:
Problem p02735 (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 = 1e9;
int h, w;
vector<vector<int>> dp(100, vector<int>(100, INF));
string s[100];

int dx[2] = {1, 0};
int dy[2] = {0, 1};

int dfs(int i, int j) {
  if (dp[i][j] != INF)
    return dp[i][j];
  int res = INF;
  rep(k, 2) {
    int nx = i + dx[k], ny = j + dy[k];
    if (nx < h && ny < w) {
      if (s[i][j] == s[nx][ny])
        res = min(dfs(nx, ny), res);
      else
        res = min(dfs(nx, ny) + 1, res);
    }
  }
  return res;
}

int main() {
  cin >> h >> w;
  rep(i, h) cin >> s[i];
  if (s[h - 1][w - 1] == '#')
    dp[h - 1][w - 1] = 1;
  else
    dp[h - 1][w - 1] = 0;
  int ans = dfs(0, 0);
  if (s[0][0] == '#')
    ans++;
  cout << ans / 2 << 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 = 1e9;
int h, w;
vector<vector<int>> dp(100, vector<int>(100, INF));
string s[100];

int dx[2] = {1, 0};
int dy[2] = {0, 1};

int dfs(int i, int j) {
  if (dp[i][j] != INF)
    return dp[i][j];
  int res = INF;
  rep(k, 2) {
    int nx = i + dx[k], ny = j + dy[k];
    if (nx < h && ny < w) {
      if (s[i][j] == s[nx][ny])
        res = min(dfs(nx, ny), res);
      else
        res = min(dfs(nx, ny) + 1, res);
    }
  }
  return dp[i][j] = res;
}

int main() {
  cin >> h >> w;
  rep(i, h) cin >> s[i];
  if (s[h - 1][w - 1] == '#')
    dp[h - 1][w - 1] = 1;
  else
    dp[h - 1][w - 1] = 0;
  int ans = dfs(0, 0);
  if (s[0][0] == '#')
    ans++;
  cout << ans / 2 << endl;
  return 0;
}
Problem p02736 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <stdio.h>

int popcnt(int x) {
  x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  x = (x & 0x0f0f0f0f) + ((x >> 4) & 0x0f0f0f0f);
  x = (x & 0x00ff00ff) + ((x >> 8) & 0x00ff00ff);
  x = (x & 0x0000ffff) + ((x >> 16) & 0x0000ffff);
  return x;
}
int log2(int x) { return popcnt((x & -x) - 1); }

int n;
char a[1000100];
int solve(int div = 1) {
  int mod = 0, one = 0, exp = 0;
  for (int i = 0; i < n; i++) {
    mod ^= (a[i] / div % 2) & (!(bool)exp);
    one |= (a[i] / div) == 1;
    exp += log2(n - i - 1) - log2(i + 1);
  }
  if (mod & 1)
    return 1;
  if (one)
    return 0;
  return solve(2) * 2;
}
int main() {
  scanf("%d", &n);
  scanf("%s", a);
  for (int i = 0; i < n; i++)
    a[i] = a[i] - '0' - 1;
  printf("%d\n", solve());
}

Fixed submission:
#include <algorithm>
#include <stdio.h>

int popcnt(int x) {
  x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  x = (x & 0x0f0f0f0f) + ((x >> 4) & 0x0f0f0f0f);
  x = (x & 0x00ff00ff) + ((x >> 8) & 0x00ff00ff);
  x = (x & 0x0000ffff) + ((x >> 16) & 0x0000ffff);
  return x;
}
int log2(int x) { return popcnt((x & -x) - 1); }

int n;
char a[1000100];
int solve(int div = 1) {
  int mod = 0, one = div == 2, exp = 0;
  for (int i = 0; i < n; i++) {
    mod ^= (a[i] / div % 2) & (!(bool)exp);
    one |= (a[i] / div) == 1;
    exp += log2(n - i - 1) - log2(i + 1);
  }
  if (mod & 1)
    return 1;
  if (one)
    return 0;
  return solve(2) * 2;
}
int main() {
  scanf("%d", &n);
  scanf("%s", a);
  for (int i = 0; i < n; i++)
    a[i] = a[i] - '0' - 1;
  printf("%d\n", solve());
}
Problem p02736 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define rep(i, a, b) for (lld i = a; i <= b; i++)
#define repr(i, a, b) for (lld i = a; i >= b; i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
using namespace std;
lld n, m;
lld arr[300000];
string st;
int main() {
  ios;
  lld TESTS, q, a, s, b, r, k, c, p, h, w, d, x, y, z, xs, ys, t;
  TESTS = 1;
  //     ans=0;
  // cin>>TESTS;
  //  memset(dpt,0,sizeof(dpt));memset(dput,0,sizeof(dput));
  // memset(dsu1,0,sizeof(dsu1));
  while (TESTS--) {
    bool cont = false;
    cin >> n;
    cin >> st;
    rep(i, 0, n - 1) if (st[i] == '2') cont = true;
    rep(i, 0, n - 1) {
      if (cont) {
        (st[i] == '1' || st[i] == '3') ? arr[i] = 1 : arr[i] = 0;
      } else
        (st[i] == '1') ? arr[i] = 1 : arr[i] = 0;
      // cout<<arr[i]<<" ";
    }
    lld change = 0;
    rep(i, 0, n - 1) if (arr[i] && ((n - 1) & i) == i) change ^= 1;
    (change) ? ((cont) ? cout << 1 : cout << 2) : cout << 0;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define rep(i, a, b) for (lld i = a; i <= b; i++)
#define repr(i, a, b) for (lld i = a; i >= b; i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
using namespace std;
lld n, m;
lld arr[3000000];
string st;
int main() {
  ios;
  lld TESTS, q, a, s, b, r, k, c, p, h, w, d, x, y, z, xs, ys, t;
  TESTS = 1;
  //     ans=0;
  // cin>>TESTS;
  //  memset(dpt,0,sizeof(dpt));memset(dput,0,sizeof(dput));
  // memset(dsu1,0,sizeof(dsu1));
  while (TESTS--) {
    bool cont = false;
    cin >> n;
    cin >> st;
    rep(i, 0, n - 1) if (st[i] == '2') cont = true;
    rep(i, 0, n - 1) {
      if (cont) {
        (st[i] == '1' || st[i] == '3') ? arr[i] = 1 : arr[i] = 0;
      } else
        (st[i] == '1') ? arr[i] = 1 : arr[i] = 0;
      // cout<<arr[i]<<" ";
    }
    lld change = 0;
    rep(i, 0, n - 1) if (arr[i] && ((n - 1) & i) == i) change ^= 1;
    (change) ? ((cont) ? cout << 1 : cout << 2) : cout << 0;
  }
  return 0;
}
Problem p02736 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200005, p = 998244353, inf = 0x3f3f3f3f;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-')
      f = -1;
  for (; isdigit(ch); ch = getchar())
    g = g * 10 + ch - '0';
  return f * g;
}
int n, m, fl, ans, a[N], b[N];
char ch[N];
int calc(int x) {
  int t = 0;
  while ((x & 1) == 0)
    x >>= 1, t++;
  return t;
}
int C(int n, int m) { return (b[n] - b[m] - b[n - m]) ? 0 : 1; }
int main() {
  //	freopen("a.in","r",stdin);
  //	freopen("a.out","w",stdout);
  n = read();
  scanf(" %s", ch + 1);
  for (int i = 1; i <= n; i++)
    a[i] = ch[i] - '1';
  fl = 2;
  for (int i = 1; i <= n; i++)
    if (a[i] == 1)
      fl = 1;
  if (fl == 1)
    for (int i = 1; i <= n; i++)
      a[i] &= 1;
  else
    for (int i = 1; i <= n; i++)
      a[i] /= 2;

  for (int i = 1; i <= n; i++)
    b[i] = b[i - 1] + calc(i);
  for (int i = 1; i <= n; i++)
    ans = (ans + C(n - 1, i - 1) * a[i]) & 1;
  printf("%d\n", ans * fl);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1000005, p = 998244353, inf = 0x3f3f3f3f;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-')
      f = -1;
  for (; isdigit(ch); ch = getchar())
    g = g * 10 + ch - '0';
  return f * g;
}
int n, m, fl, ans, a[N], b[N];
char ch[N];
int calc(int x) {
  int t = 0;
  while ((x & 1) == 0)
    x >>= 1, t++;
  return t;
}
int C(int n, int m) { return (b[n] - b[m] - b[n - m]) ? 0 : 1; }
int main() {
  //	freopen("a.in","r",stdin);
  //	freopen("a.out","w",stdout);
  n = read();
  scanf(" %s", ch + 1);
  for (int i = 1; i <= n; i++)
    a[i] = ch[i] - '1';
  fl = 2;
  for (int i = 1; i <= n; i++)
    if (a[i] == 1)
      fl = 1;
  if (fl == 1)
    for (int i = 1; i <= n; i++)
      a[i] &= 1;
  else
    for (int i = 1; i <= n; i++)
      a[i] /= 2;

  for (int i = 1; i <= n; i++)
    b[i] = b[i - 1] + calc(i);
  for (int i = 1; i <= n; i++)
    ans = (ans + C(n - 1, i - 1) * a[i]) & 1;
  printf("%d\n", ans * fl);
  return 0;
}
Problem p02736 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string A;
  cin >> N >> A;
  vector<int> aa(N);
  bool exist1 = false;
  for (int i = 0; i < N; ++i) {
    aa[i] = A[i] - '1';
    if (aa[i] == 1)
      exist1 = true;
  }

  vector<int> a(1, 0);
  for (int i = 1; i < N; ++i) {
    map<int, int> b;
    for (int x : a) {
      b[x] ^= 1;
      b[x + 1] ^= 1;
    }
    a.clear();
    for (auto p : b)
      if (p.second)
        a.push_back(p.first);
  }

  if (exist1) {
    int r = 0;
    for (auto i : a) {
      r ^= aa[i] & 1;
    }
    cout << r << endl;
  } else {
    int r = 0;
    for (auto i : a) {
      r ^= aa[i];
    }
    cout << r << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string A;
  cin >> N >> A;
  vector<int> aa(N);
  bool exist1 = false;
  for (int i = 0; i < N; ++i) {
    aa[i] = A[i] - '1';
    if (aa[i] == 1)
      exist1 = true;
  }

  vector<int> a;
  for (int i = 0; i < N; ++i) {
    if ((i | (N - 1 - i)) == N - 1)
      a.push_back(i);
  }

  if (exist1) {
    int r = 0;
    for (auto i : a) {
      r ^= aa[i] & 1;
    }
    cout << r << endl;
  } else {
    int r = 0;
    for (auto i : a) {
      r ^= aa[i];
    }
    cout << r << endl;
  }
}
Problem p02736 (C++)

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n - 1); i >= 0; --i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1000005;
const int INF = 1001001001;
const int MOD = 1000000007;

vector<int> table;
void init(int N) {
  table.resize(N);
  for (int i = 1; i < N; ++i) {
    int x = i, res = 0;
    while (x > 0 && x % 2 == 0) {
      x /= 2;
      res++;
    }
    table[i] = table[i - 1] + res;
  }
}

int f(vector<int> &V) {
  int N = V.size(), res = 0;
  rep(i, N) {
    if (table[N - 1] == table[i] + table[N - 1 - i]) {
      res += V[i];
    }
  }

  if (res % 2)
    return 1;
  if (count(V.begin(), V.end(), 1) > 0)
    return 0;
  for (int &i : V)
    i /= 2;
  return 2 * f(V);
}

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

  vector<int> A(N);
  rep(i, N) A[i] = S[i] - '1';

  init(N);
  cout << f(A) << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n - 1); i >= 0; --i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1000005;
const int INF = 1001001001;
const int MOD = 1000000007;

vector<int> table;
void init(int N) {
  table.resize(N);
  for (int i = 1; i < N; ++i) {
    int x = i, res = 0;
    while (x > 0 && x % 2 == 0) {
      x /= 2;
      res++;
    }
    table[i] = table[i - 1] + res;
  }
}

int f(vector<int> &V) {
  int N = V.size(), res = 0;
  rep(i, N) {
    if (table[N - 1] == table[i] + table[N - 1 - i]) {
      res += V[i];
    }
  }

  if (res % 2)
    return 1;
  if (count(V.begin(), V.end(), 1) > 0)
    return 0;
  for (int &i : V)
    i /= 2;
  if (count(V.begin(), V.end(), V[0]) == N)
    return 0;
  return 2 * f(V);
}

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

  vector<int> A(N);
  rep(i, N) A[i] = S[i] - '1';

  init(N);
  cout << f(A) << endl;
}
Problem p02737 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> E[3];
  for (int i = 0; i < 3; i++) {
    int M;
    cin >> M;
    E[i].resize(N);
    for (int j = 0; j < M; j++) {
      int a, b;
      cin >> a >> b;
      E[i][a - 1].push_back(b - 1);
      E[i][b - 1].push_back(a - 1);
    }
  }

  vector<int> G[3];
  set<int> S;
  for (int i = 0; i < 3; i++) {
    G[i] = vector<int>(N);
    for (int j = N - 1; j >= 0; j--) {
      S.clear();
      for (int e : E[i][j])
        if (e > j)
          S.insert(G[i][e]);
      for (int k = 0;; k++)
        if (S.count(k) == 0) {
          G[i][j] = k;
          break;
        }
    }
  }

  long long M = 998244353LL;
  vector<long long> P10(N + 1);
  P10[0] = 1;
  for (int i = 1; i <= N; i++)
    P10[i] = P10[i - 1] * (1000000000000000000 % M) % M;

  vector<long long> GS[3];
  int MG[3];
  for (int i = 0; i < 3; i++) {
    GS[i] = vector<long long>(N);
    for (int j = 0; j < N; j++) {
      GS[i][G[i][j]] += P10[j + 1];
      GS[i][G[i][j]] %= M;
      MG[i] = max(MG[i], G[i][j]);
    }
  }

  long long ans = 0;
  for (int i = 0; i <= MG[0]; i++)
    for (int j = 0; j <= MG[1]; j++) {
      int k = i ^ j;
      if (k <= MG[2]) {
        ans += GS[0][i] * GS[1][j] % M * GS[2][k] % M;
        ans %= M;
      }
    }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> E[3];
  for (int i = 0; i < 3; i++) {
    int M;
    cin >> M;
    E[i].resize(N);
    for (int j = 0; j < M; j++) {
      int a, b;
      cin >> a >> b;
      E[i][a - 1].push_back(b - 1);
      E[i][b - 1].push_back(a - 1);
    }
  }

  vector<int> G[3];
  set<int> S;
  for (int i = 0; i < 3; i++) {
    G[i] = vector<int>(N);
    for (int j = N - 1; j >= 0; j--) {
      S.clear();
      for (int e : E[i][j])
        if (e > j)
          S.insert(G[i][e]);
      for (int k = 0;; k++)
        if (S.count(k) == 0) {
          G[i][j] = k;
          break;
        }
    }
  }

  long long M = 998244353LL;
  vector<long long> P10(N + 1);
  P10[0] = 1;
  for (int i = 1; i <= N; i++)
    P10[i] = P10[i - 1] * (1000000000000000000 % M) % M;

  vector<long long> GS[3];
  int MG[3] = {};
  for (int i = 0; i < 3; i++) {
    GS[i] = vector<long long>(N);
    for (int j = 0; j < N; j++) {
      GS[i][G[i][j]] += P10[j + 1];
      GS[i][G[i][j]] %= M;
      MG[i] = max(MG[i], G[i][j]);
    }
  }

  long long ans = 0;
  for (int i = 0; i <= MG[0]; i++)
    for (int j = 0; j <= MG[1]; j++) {
      int k = i ^ j;
      if (k <= MG[2]) {
        ans += GS[0][i] * GS[1][j] % M * GS[2][k] % M;
        ans %= M;
      }
    }
  cout << ans << endl;
}
Problem p02738 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define f(i, j) f[i][j + 3000]
#define int long long

using namespace std;
const int N = 2100;

int n, P;
int f[N][N + 3000];

signed main(void) {
  cin >> n >> P;
  f(0, 0) = 1;
  for (int i = 0; i < n * 3; ++i)
    for (int j = -n; j <= 3 * n; ++j) {
      f(i + 1, j + 1) = (f(i + 1, j + 1) + f(i, j)) % P;
      f(i + 2, j - 1) = (f(i + 2, j - 1) + f(i, j) * (i + 1) % P) % P;
      f(i + 3, j) = (f(i + 3, j) + f(i, j) * (i + 1) % P * (i + 2) % P) % P;
    }
  int res = 0;
  for (int i = 0; i <= n; ++i)
    res = (res + f(n * 3, i * 3)) % P;
  cout << res << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define f(i, j) f[i][j + 3000]
#define int long long

using namespace std;
const int N = 6100;

int n, P;
int f[N][N + 3000];

signed main(void) {
  cin >> n >> P;
  f(0, 0) = 1;
  for (int i = 0; i < n * 3; ++i)
    for (int j = -n; j <= 3 * n; ++j) {
      f(i + 1, j + 1) = (f(i + 1, j + 1) + f(i, j)) % P;
      f(i + 2, j - 1) = (f(i + 2, j - 1) + f(i, j) * (i + 1) % P) % P;
      f(i + 3, j) = (f(i + 3, j) + f(i, j) * (i + 1) % P * (i + 2) % P) % P;
    }
  int res = 0;
  for (int i = 0; i <= n; ++i)
    res = (res + f(n * 3, i * 3)) % P;
  cout << res << endl;
  return 0;
}
Problem p02738 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 5005;
int n, m, f[N][N], M;
signed main() {
  scanf("%lld%lld", &n, &M);
  f[0][n + 1] = 1;
  for (int i = 0; i <= 3 * n; i++)
    for (int j = -n; j <= 3 * n; j++) {
      (f[i + 1][j + 1 + (n + 1)] += f[i][j + (n + 1)]) %= M;
      (f[i + 2][j - 1 + (n + 1)] += f[i][j + (n + 1)] * (i + 1)) %= M;
      (f[i + 3][j + (n + 1)] += f[i][j + (n + 1)] * (i + 2) % M * (i + 1)) %= M;
    }
  int ans = 0;
  for (int i = 0; i <= n; i++)
    (ans += f[3 * n][3 * i + (n + 1)]) %= M;
  printf("%lld\n", ans);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 8005;
int n, m, f[N][N], M;
signed main() {
  scanf("%lld%lld", &n, &M);
  f[0][n + 1] = 1;
  for (int i = 0; i <= 3 * n; i++)
    for (int j = -n; j <= 3 * n; j++) {
      (f[i + 1][j + 1 + (n + 1)] += f[i][j + (n + 1)]) %= M;
      (f[i + 2][j - 1 + (n + 1)] += f[i][j + (n + 1)] * (i + 1)) %= M;
      (f[i + 3][j + (n + 1)] += f[i][j + (n + 1)] * (i + 2) % M * (i + 1)) %= M;
    }
  int ans = 0;
  for (int i = 0; i <= n; i++)
    (ans += f[3 * n][3 * i + (n + 1)]) %= M;
  printf("%lld\n", ans);
  return 0;
}
Problem p02738 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define cs const
using namespace std;
int Mod;
int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b) { return 1ll * a * b % Mod; }
void Add(int &a, int b) { a = add(a, b); }
void Dec(int &a, int b) { a = dec(a, b); }
void Mul(int &a, int b) { a = mul(a, b); }
cs int N = 2050;
int n, f[N][N * 12];
int main() {
#ifdef FSYolanda
  freopen("1.in", "r", stdin);
#endif
  scanf("%d%d", &n, &Mod);
  n *= 3;
  f[0][0 + n] = 1;
  for (int i = 1, u = n; i <= u; i++) {
    for (int j = -(i >> 1); j <= i; j++) {
      Add(f[i][j + 1 + n], f[i - 1][j + n]);
      if (i > 1)
        Add(f[i][j - 1 + n], mul(f[i - 2][j + n], i - 1));
      if (i > 2)
        Add(f[i][j + n], mul(f[i - 3][j + n], (i - 1) * (i - 2)));
    }
  }
  int as = 0;
  for (int i = n; i <= n + n; i++)
    Add(as, f[n][i]);
  cout << as;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define cs const
using namespace std;
int Mod;
int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b) { return 1ll * a * b % Mod; }
void Add(int &a, int b) { a = add(a, b); }
void Dec(int &a, int b) { a = dec(a, b); }
void Mul(int &a, int b) { a = mul(a, b); }
cs int N = 6e3 + 50;
int n, f[N][N * 2];
int main() {
#ifdef FSYolanda
  freopen("1.in", "r", stdin);
#endif
  scanf("%d%d", &n, &Mod);
  n *= 3;
  f[0][0 + n] = 1;
  for (int i = 1, u = n; i <= u; i++) {
    for (int j = -(i >> 1); j <= i; j++) {
      Add(f[i][j + 1 + n], f[i - 1][j + n]);
      if (i > 1)
        Add(f[i][j - 1 + n], mul(f[i - 2][j + n], i - 1));
      if (i > 2)
        Add(f[i][j + n], mul(f[i - 3][j + n], (i - 1) * (i - 2)));
    }
  }
  int as = 0;
  for (int i = n; i <= n + n; i++)
    Add(as, f[n][i]);
  cout << as;
  return 0;
}
Problem p02738 (C++)

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

const int N3 = 3005;
const int N4 = 4005;
int inv2;
int n, n3, n4, mod;
int f[N3][N4];

inline void add(int &x, int y) {
  x += y;
  x >= mod ? x -= mod : 0;
}

int main() {
  scanf("%d%d", &n, &mod);
  f[0][n] = 1;
  n3 = n * 3;
  n4 = n * 4;
  inv2 = mod + 1 >> 1;
  for (int i = 0; i < n3; ++i)
    for (int j = 0; j <= n4; ++j)
      if (f[i][j]) {
        if (i + 1 <= n3 && j + 1 <= n4)
          add(f[i + 1][j + 1], f[i][j]);
        if (i + 2 <= n3 && j - 1 >= 0)
          f[i + 2][j - 1] = (1ll * f[i][j] * (i + 1) + f[i + 2][j - 1]) % mod;
        if (i + 3 <= n3)
          f[i + 3][j] = (1ll * f[i][j] * (i + 1) * (i + 2) + f[i + 3][j]) % mod;
      }
  int ans = 0;
  for (int j = n; j <= n4; ++j)
    add(ans, f[n3][j]);
  printf("%d\n", ans);
}

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

const int N3 = 6005;
const int N4 = 8005;
int inv2;
int n, n3, n4, mod;
int f[N3][N4];

inline void add(int &x, int y) {
  x += y;
  x >= mod ? x -= mod : 0;
}

int main() {
  scanf("%d%d", &n, &mod);
  f[0][n] = 1;
  n3 = n * 3;
  n4 = n * 4;
  inv2 = mod + 1 >> 1;
  for (int i = 0; i < n3; ++i)
    for (int j = 0; j <= n4; ++j)
      if (f[i][j]) {
        if (i + 1 <= n3 && j + 1 <= n4)
          add(f[i + 1][j + 1], f[i][j]);
        if (i + 2 <= n3 && j - 1 >= 0)
          f[i + 2][j - 1] = (1ll * f[i][j] * (i + 1) + f[i + 2][j - 1]) % mod;
        if (i + 3 <= n3)
          f[i + 3][j] = (1ll * f[i][j] * (i + 1) * (i + 2) + f[i + 3][j]) % mod;
      }
  int ans = 0;
  for (int j = n; j <= n4; ++j)
    add(ans, f[n3][j]);
  printf("%d\n", ans);
}
Problem p02738 (C++)

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

int modadd(int a, int b, int m) {
  int da = m - a;
  if (da <= b) {
    return b - da;
  } else {
    return a + b;
  }
}

int modmul(int n, int b, int m) {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = modadd(ans, b, m);
  }
  return ans;
}

int main(void) {
  int n, m;
  cin >> n;
  cin >> m;

  int *f = (int *)malloc(sizeof(int) * (3 * n + 1) * (n + 1));
  for (int i = 0; i <= 3 * n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i <= 1) {
        f[i * (n + 1) + j] = 1;
      } else {
        if (n - j > (3 * n) - i) {
          f[i * (n + 1) + j] = 0;
        } else {
          int ans = f[(i - 1) * (n + 1) + j];
          if (i - 3 >= 0 && j > 0)
            ans = modadd(
                ans,
                modmul((i - 1),
                       modmul((i - 2), f[(i - 3) * (n + 1) + j - 1], m), m),
                m);
          if (i - 2 >= 0 && j > 0)
            ans = modadd(ans, modmul((i - 1), f[(i - 2) * (n + 1) + j - 1], m),
                         m);
          f[i * (n + 1) + j] = ans;
        }
      }
    }
  }

  cout << f[3 * n * (n + 1) + n];
}

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

int modadd(int a, int b, int m) {
  int da = m - a;
  if (da <= b) {
    return b - da;
  } else {
    return a + b;
  }
}

int modmul(int n, int b, int m) {
  long long int tmp = (long long int)b;
  tmp *= n;
  return tmp % m;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = modadd(ans, b, m);
  }
  return ans;
}

int main(void) {
  int n, m;
  cin >> n;
  cin >> m;

  int *f = (int *)malloc(sizeof(int) * (3 * n + 1) * (n + 1));
  for (int i = 0; i <= 3 * n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i <= 1) {
        f[i * (n + 1) + j] = 1;
      } else {
        if (n - j > (3 * n) - i) {
          f[i * (n + 1) + j] = 0;
        } else {
          int ans = f[(i - 1) * (n + 1) + j];
          if (i - 3 >= 0 && j > 0)
            ans = modadd(
                ans,
                modmul((i - 1),
                       modmul((i - 2), f[(i - 3) * (n + 1) + j - 1], m), m),
                m);
          if (i - 2 >= 0 && j > 0)
            ans = modadd(ans, modmul((i - 1), f[(i - 2) * (n + 1) + j - 1], m),
                         m);
          f[i * (n + 1) + j] = ans;
        }
      }
    }
  }

  cout << f[3 * n * (n + 1) + n];
}
Problem p02738 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
using namespace std;
#define N 6005
#define INF 0x3f3f3f3f
#define LL long long
int n, MOD, f[4][N];
int rd() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return f * x;
}
int main() {
  n = rd(), MOD = rd();
  f[0][N] = 1;
  for (int i = 1; i <= 3 * n; i++) {
    int l = N - (i - 1), r = N + (i - 1);
    for (int j = l; j <= r; j++) {
      for (int k = 3; k >= 1; k--)
        f[k][j] = f[k - 1][j];
      f[0][j] = 0;
    }
    for (int j = l; j <= r; j++) {
      f[0][j + 1] = (f[0][j + 1] + f[1][j]) % MOD;
      int del = i - 1;
      f[0][j - 1] = (f[0][j - 1] + 1ll * f[2][j] * del % MOD) % MOD;
      del = 1ll * (i - 1) * (i - 2) % MOD;
      f[0][j] = (f[0][j] + 1ll * f[3][j] * del % MOD) % MOD;
    }
  }
  int ans = 0;
  for (int i = N; i <= N + 3 * n; i++)
    ans = (ans + f[0][i]) % MOD;
  printf("%d\n", ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <vector>
using namespace std;
#define N 6005
#define INF 0x3f3f3f3f
#define LL long long
int n, MOD, f[4][N * 2];
int rd() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return f * x;
}
int main() {
  n = rd(), MOD = rd();
  f[0][N] = 1;
  for (int i = 1; i <= 3 * n; i++) {
    int l = N - (i - 1), r = N + (i - 1);
    for (int j = l; j <= r; j++) {
      for (int k = 3; k >= 1; k--)
        f[k][j] = f[k - 1][j];
      f[0][j] = 0;
    }
    for (int j = l; j <= r; j++) {
      f[0][j + 1] = (f[0][j + 1] + f[1][j]) % MOD;
      int del = i - 1;
      f[0][j - 1] = (f[0][j - 1] + 1ll * f[2][j] * del % MOD) % MOD;
      del = 1ll * (i - 1) * (i - 2) % MOD;
      f[0][j] = (f[0][j] + 1ll * f[3][j] * del % MOD) % MOD;
    }
  }
  int ans = 0;
  for (int i = N; i <= N + 3 * n; i++)
    ans = (ans + f[0][i]) % MOD;
  printf("%d\n", ans);
  return 0;
}
Problem p02738 (C++)

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

using namespace std;

const int maxn = 1003;

int n, m;

long long fast_pow(long long num, int deg) {
  long long ans = 1, pow = num;
  while (deg) {
    if (deg & 1)
      ans = ans * pow % m;

    deg >>= 1;

    pow = pow * pow % m;
  }

  return ans;
}

long long add(long long a, long long b) {
  a += b;
  if (a >= m)
    a -= m;

  return a;
}

void read() { cin >> n >> m; }

long long dp[maxn * 3][maxn * 6];
void solve() {
  dp[0][3 * n + 1] = 1;
  for (int i = 1; i <= 3 * n; i++) {
    auto to_mult = fast_pow(i, m - 2);
    for (int j = -3 * n; j <= 3 * n; j++) {
      dp[i][j + 3 * n + 1] =
          add(dp[i][j + 3 * n + 1], dp[i - 1][j - 1 + 3 * n + 1]);
      if (i >= 2)
        dp[i][j + 3 * n + 1] =
            add(dp[i][j + 3 * n + 1], dp[i - 2][j + 1 + 3 * n + 1]);

      if (i >= 3)
        dp[i][j + 3 * n + 1] =
            add(dp[i][j + 3 * n + 1], dp[i - 3][j + 3 * n + 1]);

      dp[i][j + 3 * n + 1] = dp[i][j + 3 * n + 1] * to_mult % m;
    }
  }

  long long ans = 0;
  for (int j = 0; j <= 3 * n; j++)
    ans = add(ans, dp[3 * n][j + 3 * n + 1]);

  for (int i = 1; i <= 3 * n; i++)
    ans = ans * i % m;

  cout << ans << endl;
}

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

  read();
  solve();
}


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

using namespace std;

const int maxn = 2003;

int n, m;

long long fast_pow(long long num, int deg) {
  long long ans = 1, pow = num;
  while (deg) {
    if (deg & 1)
      ans = ans * pow % m;

    deg >>= 1;

    pow = pow * pow % m;
  }

  return ans;
}

long long add(long long a, long long b) {
  a += b;
  if (a >= m)
    a -= m;

  return a;
}

void read() { cin >> n >> m; }

long long dp[maxn * 3][maxn * 6];
void solve() {
  dp[0][3 * n + 1] = 1;
  for (int i = 1; i <= 3 * n; i++) {
    auto to_mult = fast_pow(i, m - 2);
    for (int j = -3 * n; j <= 3 * n; j++) {
      dp[i][j + 3 * n + 1] =
          add(dp[i][j + 3 * n + 1], dp[i - 1][j - 1 + 3 * n + 1]);
      if (i >= 2)
        dp[i][j + 3 * n + 1] =
            add(dp[i][j + 3 * n + 1], dp[i - 2][j + 1 + 3 * n + 1]);

      if (i >= 3)
        dp[i][j + 3 * n + 1] =
            add(dp[i][j + 3 * n + 1], dp[i - 3][j + 3 * n + 1]);

      dp[i][j + 3 * n + 1] = dp[i][j + 3 * n + 1] * to_mult % m;
    }
  }

  long long ans = 0;
  for (int j = 0; j <= 3 * n; j++)
    ans = add(ans, dp[3 * n][j + 3 * n + 1]);

  for (int i = 1; i <= 3 * n; i++)
    ans = ans * i % m;

  cout << ans << endl;
}

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

  read();
  solve();
}
Problem p02738 (C++)

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

// using namespace __gnu_pbds;

#define N 2000001

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;

ll d[3001][6003], n, P, offset = 3000;

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

  d[0][offset] = 1;
  d[1][offset + 1] = 1;

  for (int i = 2; i <= 3 * n; i++)
    for (int j = -i / 2; j <= i; j++) {
      d[i][offset + j] += d[i - 1][offset + j - 1];
      if (d[i][offset + j] >= P)
        d[i][offset + j] -= P;
      d[i][offset + j] += d[i - 2][offset + j + 1] * (i - 1) % P;
      if (d[i][offset + j] >= P)
        d[i][offset + j] -= P;
      if (i > 2)
        d[i][offset + j] += d[i - 3][offset + j] * (i - 1) * (i - 2) % P;
    }

  ll ans = 0;

  for (int i = 0; i <= 3 * n; i++) {
    ans += d[3 * n][offset + i];
    if (ans >= P)
      ans -= P;
  }

  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>

// using namespace __gnu_pbds;

#define N 2000001

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;

ll d[10001][10003], n, P, offset = 3000;

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

  d[0][offset] = 1;
  d[1][offset + 1] = 1;

  for (int i = 2; i <= 3 * n; i++)
    for (int j = -i / 2; j <= i; j++) {
      d[i][offset + j] += d[i - 1][offset + j - 1];
      if (d[i][offset + j] >= P)
        d[i][offset + j] -= P;
      d[i][offset + j] += d[i - 2][offset + j + 1] * (i - 1) % P;
      if (d[i][offset + j] >= P)
        d[i][offset + j] -= P;
      if (i > 2)
        d[i][offset + j] += d[i - 3][offset + j] * (i - 1) * (i - 2) % P;
    }

  ll ans = 0;

  for (int i = 0; i <= 3 * n; i++) {
    ans += d[3 * n][offset + i];
    if (ans >= P)
      ans -= P;
  }

  cout << ans;
}
Problem p02738 (C++)

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

long long f[6005][6005 << 1], mod, ans;
int n;

int main() {
  cin >> n >> mod;
  f[0][3 * n] = 1;
  for (int i = 1; i <= 3 * n; i++)
    for (int j = -i / 2; j <= i; j++) {
      f[i][j + 3 * n] += f[i - 1][j + 3 * n - 1];
      f[i][j + 3 * n] += (i - 1) * f[i - 2][j + 1 + 3 * n];
      f[i][j + 3 * n] += (i - 1) * (i - 2) * f[i - 3][j + 3 * n];
      f[i][j + 3 * n] %= mod;
    }
  for (int i = 3 * n; i <= 6 * n; i++)
    ans = (ans + f[3 * n][i]) % mod;
  cout << ans << endl;
}

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

long long f[6005][6005 << 1], mod, ans;
int n;

int main() {
  cin >> n >> mod;
  f[0][3 * n] = 1;
  for (int i = 1; i <= 3 * n; i++)
    for (int j = -3 * n; j <= 3 * n; j++) {
      if (i)
        f[i][j + 3 * n] += f[i - 1][j + 3 * n - 1];
      if (i > 1)
        f[i][j + 3 * n] += (i - 1) * f[i - 2][j + 1 + 3 * n];
      if (i > 2)
        f[i][j + 3 * n] += (i - 1) * (i - 2) * f[i - 3][j + 3 * n];
      f[i][j + 3 * n] %= mod;
    }
  for (int i = 3 * n; i <= 6 * n; i++)
    ans = (ans + f[3 * n][i]) % mod;
  cout << ans << endl;
}
Problem p02741 (C++)

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

int main() {
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;

  cout << a.at(k) << endl;

  return 0;
}

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

int main() {
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;

  cout << a.at(k - 1) << endl;

  return 0;
}
Problem p02741 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main(void) {
  int K;
  vector<int> L = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;

  cout << L.at(K) << endl;
  return 0;
}


Fixed submission:
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main(void) {
  int K;
  vector<int> L = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;

  cout << L.at(K - 1) << endl;
  return 0;
}
Problem p02741 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define coyes cout << "Yes" << endl;
#define cono cout << "No" << endl;
#define coYes cout << "YES" << endl;
#define coNo cout << "NO" << endl;
using namespace std;
using ll = long long int;
string large_al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string small_al = "abcdefghijklmnopqrstuvwxyz";
using Graph = vector<vector<int>>;
using i64 = int64_t;

int main() {
  int k;
  cin >> k;
  string s1 = "111212152215121#1515221#2254141";
  if (1 <= k <= 15) {
    cout << s1.at(k - 1) << endl;
  } else if (k == 16) {
    cout << 14 << endl;
  } else if (17 <= k <= 23) {
    cout << s1.at(k - 1) << endl;
  } else if (k == 24) {
    cout << 15 << endl;
  } else if (25 <= k <= 31) {
    cout << s1.at(k - 1) << endl;
  } else {
    cout << 51 << endl;
  }
}


Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define coyes cout << "Yes" << endl;
#define cono cout << "No" << endl;
#define coYes cout << "YES" << endl;
#define coNo cout << "NO" << endl;
using namespace std;
using ll = long long int;
string large_al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string small_al = "abcdefghijklmnopqrstuvwxyz";
using Graph = vector<vector<int>>;
using i64 = int64_t;

int main() {
  int k;
  cin >> k;
  vector<int> s = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << s.at(k - 1) << endl;
}
Problem p02741 (C++)

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

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

  string t = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, "
             "2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51,";

  int sum = 0;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == ',') {
      sum += 1;
      if (sum == K) {
        if (t.at(i - 2) == ' ') {
          cout << t.at(i - 1) << endl;
        } else {
          cout << t.at(i - 2) << t.at(i - 1) << endl;
        }
      }
    }
  }
}

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

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

  string t = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, "
             "2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51,";

  int sum = 0;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == ',') {
      sum += 1;
      if (sum == K) {
        if (K == 1) {
          cout << 1 << endl;
          break;
        }
        if (t.at(i - 2) == ' ') {
          cout << t.at(i - 1) << endl;
        } else {
          cout << t.at(i - 2) << t.at(i - 1) << endl;
        }
      }
    }
  }
}
Problem p02741 (C++)

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

using namespace std;

int main() {

  int K;
  cin >> K;
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a.at(K) << endl;
}

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

using namespace std;

int main() {

  int K;
  cin >> K;
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a.at(K - 1) << endl;
}
Problem p02741 (C++)

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

int main() {
  int K;
  cin >> K;
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << vec.at(K) << endl;
}

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

int main() {
  int K;
  cin >> K;
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << vec.at(K - 1) << endl;
}
Problem p02741 (C++)

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

int main() {
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int a;
  cin >> a;
  cout << vec.at(a) << endl;

  return 0;
}


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

int main() {
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int a;
  cin >> a;
  cout << vec.at(a - 1) << endl;

  return 0;
}
Problem p02741 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define stop(x)                                                                \
  {                                                                            \
    cout << x << endl;                                                         \
    exit(0);                                                                   \
  }
#define all(x) x.begin(), x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
typedef long long ll;
using namespace std;

void file() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  if (freopen("input.txt", "r", stdin))
    ;
  if (freopen("output.txt", "w", stdout))
    ;
#endif
}

int main() {
  file();

  int ar[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
              1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << ar[k - 1] << endl;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define stop(x)                                                                \
  {                                                                            \
    cout << x << endl;                                                         \
    exit(0);                                                                   \
  }
#define all(x) x.begin(), x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
typedef long long ll;
using namespace std;

void file() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  if (freopen("input.txt", "r", stdin))
    ;
  if (freopen("output.txt", "w", stdout))
    ;
#endif
}

int main() {
  // file();

  int ar[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
              1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << ar[k - 1] << endl;
}
Problem p02741 (C++)

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

int main() {
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << vec.at(K) << endl;
}

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

int main() {
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << vec.at(K - 1) << endl;
}
Problem p02741 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int k;
  cin >> k;
  vec1 t = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
            1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << t.at(k + 1) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int k;
  cin >> k;
  vec1 t = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
            1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << t.at(k - 1) << endl;
}
Problem p02741 (C++)

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

int main() {
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  cin >> K;

  cout << vec.at(K) << endl;
}


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

int main() {
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int K;
  cin >> K;

  cout << vec.at(K - 1) << endl;
}
Problem p02741 (Python)

Buggy submission (status: Runtime Error):
num = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
input = int(input())
print(num[input])


Fixed submission:
num = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
input = int(input())
print(num[input - 1])
Problem p02741 (Python)

Buggy submission (status: Runtime Error):
import math

a, b, c = map(int, input().split())

result = math.sqrt(a) + math.sqrt(b) < math.sqrt(c)

if result:
    print("Yes")
else:
    print("No")


Fixed submission:
l = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
N = int(input())
print(l[N - 1])
Problem p02741 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;
  cout << a.at(K);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;
  cout << a.at(K - 1);
}
Problem p02741 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, n) for (int i = 1; i <= (int)(n); i++)
#define co(x) cout << x << endl
typedef long long int lint;

int main() {
  vector<int> X = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  co(X.at(K + 1));
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, n) for (int i = 1; i <= (int)(n); i++)
#define co(x) cout << x << endl
typedef long long int lint;

int main() {
  vector<int> X = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                   1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  co(X.at(K - 1));
}
Problem p02741 (C++)

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

  vector<int> vec(32);
  vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << vec.at(K) << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  cin >> K;

  vector<int> vec(32);
  vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << vec.at(K - 1) << endl;
}
Problem p02741 (C++)

Buggy submission (status: Runtime Error):
// I am so vegetable
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _defor(i, a, b) for ((i) = (a); (i) < (b); ++i)
#define _rfor(i, a, b) for (int i = (a); i > (b); --i)
#define _sfor(p, st) for (auto &p : st)
#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5 + 5;
const int MOD = 1e9 + 7;
const double exps = 1e-8;
int main() {
#ifdef _LOCAL_
  ifstream cin("E:\\acm dream\\in.txt");
  ofstream cout("E:\\acm dream\\out.txt");
#endif
  // srand((unsigned)time(nullptr));
  FIO;
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
             1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << a[n - 1] << '\n';
  return 0;
}

Fixed submission:
// I am so vegetable
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _defor(i, a, b) for ((i) = (a); (i) < (b); ++i)
#define _rfor(i, a, b) for (int i = (a); i > (b); --i)
#define _sfor(p, st) for (auto &p : st)
// #define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5 + 5;
const int MOD = 1e9 + 7;
const double exps = 1e-8;
int main() {
#ifdef _LOCAL_
  ifstream cin("E:\\acm dream\\in.txt");
  ofstream cout("E:\\acm dream\\out.txt");
#endif
  // srand((unsigned)time(nullptr));
  FIO;
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
             1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << a[n - 1] << '\n';
  return 0;
}
Problem p02741 (C++)

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

int main() {
  vector<int> nb = {1, 1, 1, 2, 1};
  int input;
  cin >> input;
  cout << nb.at(input - 1) << endl;
}

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

int main() {
  vector<int> nb = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                    1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int input;
  cin >> input;
  cout << nb.at(input - 1) << endl;
}
Problem p02741 (C++)

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

int main() {
  int K;
  vector<int> vec;
  vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;
  cout << vec.at(K) << endl;
}


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

int main() {
  int K;
  vector<int> vec;
  vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> K;
  cout << vec.at(K - 1) << endl;
}
Problem p02741 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << '\n';
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << '\n';
}
Problem p02741 (C++)

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

int main() {
  vector<int> vec(32);
  vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << vec.at(k);
  return 0;
}

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

int main() {
  vector<int> vec(32);
  vec = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << vec.at(k - 1);
  return 0;
}