alexjercan/bugnet huggingface dataset:
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

//@author yash2040
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set                                                            \\
  tree<int, null_type, less<int>, rb_tree_tag,                                 \\
       tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
int dp[2002][670];
int getans(int sum, int dig, int S) {
  if (sum == S)
    return 1;
  if (dp[sum][dig] != -1)
    return dp[sum][dig];
  int ans = 0;
  for (int i = 3; i <= S; i++) {
    if (i + sum > S)
      break;
    else {
      int x = getans(sum + i, dig + 1, S);
      ans += x;
      if (ans >= mod) {
        ans -= mod;
      }
      // ans=((ans%mod)+(getans(sum+i,dig+1,S)%mod))%mod;
    }
  }
  return dp[sum][dig] = ans;
}
int32_t main() {
  fast();
  memset(dp, -1, sizeof(dp));
  int S;
  cin >> S;
  cout << getans(0, 0, S) << "\\n";
}


Error: TLE

Fixed submission:

//@author yash2040
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set                                                            \\
  tree<int, null_type, less<int>, rb_tree_tag,                                 \\
       tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
int dp[2002][670];
int getans(int sum, int dig, int S) {
  if (sum == S)
    return 1;
  if (dp[sum][dig] != -1)
    return dp[sum][dig];
  int ans = 0;
  for (int i = 3; i <= S; i++) {
    if (i + sum > S)
      break;
    else {
      ans = ((ans % mod) + (getans(sum + i, dig + 1, S) % mod)) % mod;
    }
  }
  return dp[sum][dig] = ans % mod;
}
int32_t main() {
  fast();
  memset(dp, -1, sizeof(dp));
  int S;
  cin >> S;
  cout << getans(0, 0, S) << "\\n";
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector<vi> vii;
#define fi first
#define se second
#define pb push_back
#define forn(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define forr(i, n) for (int i = n; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
const int MAXN = 1e5 + 5;
const LL m = 1e9 + 7;
void fio() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

LL dp[2005][2005], pref[2005][2005];

int main() {
  fio();
  LL s;
  cin >> s;
  for1(i, s - 1) {
    dp[i][0] = 1;
    if (i >= 3)
      dp[i][1] = 1;
    for (int k = 1; k <= (i - 3) && k >= 0; k++) {
      if (i >= 3)
        dp[i][k + 1] = pref[i - 3][k];
    }
    for (int k = 1; k <= i; k++) {
      pref[i][k] = (pref[i - 1][k] + dp[i][k]) % m;
    }
  }
  LL su = 0;

  if (s <= 2)
    cout << 0 << endl;
  else {
    for (int i = 1; i <= (s - 3); i++)
      su = (su + pref[s - 3][i]) % m;
    cout << (su + 1) % m << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector<vi> vii;
#define fi first
#define se second
#define pb push_back
#define forn(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define forr(i, n) for (int i = n; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
const int MAXN = 1e5 + 5;
const LL m = 1e9 + 7;
void fio() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

LL dp[2005][2005], pref[2005][2005];

int main() {
  fio();
  LL s;
  cin >> s;
  for1(i, s - 1) {
    dp[i][0] = 1;
    if (i >= 3)
      dp[i][1] = 1;
    for (int k = 1; k <= (i - 3) && k >= 0; k++) {
      if (i >= 3)
        dp[i][k + 1] = pref[i - 3][k];
    }
    for (int k = 1; k <= i; k++) {
      pref[i][k] = (pref[i - 1][k] + dp[i][k]) % m;
    }
  }
  LL su = 0;
  // for(int i = 1; i <= (s-1); i++){
  // 	cout<<i<<": ";
  // 	for(int j = 0; j<= (s-1); j++){
  // 		cout<<dp[i][j]<<" ";
  // 	}
  // 	cout<<endl;
  // }

  for (int i = 1; i <= (s - 1); i++) {
    su = (su + pref[s - 3][i]) % m;
  }
  if (s <= 2)
    cout << 0 << endl;
  else
    cout << (su + 1) % m << endl;
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>

using namespace std;
typedef long long ll;
const int N = 2010;
const ll mod = 1e9 + 7;
ll f[N];

int main() {
  int s;
  cin >> s;
  f[0] = 1;
  for (int i = 3; i <= s; i++)
    for (int j = 3; j <= i; j++)
      f[i] = (f[i] + f[i - j]) % mod;
  cout << f[s] << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int>> small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
const ll mod = 1e9 + 7;
int T;
int s;
ll dp[2500][2500];

int main() {
  scanf("%d", &s);
  dp[0][0] = 1;
  for (int i = 1; i <= s / 3; i++) {
    for (int k = 3; k <= s; k++) {
      for (int j = 3; j <= k; j++)
        dp[i][k] = (dp[i - 1][k - j] + dp[i][k]) % mod;
    }
  }
  ll ans = 0;
  for (int i = 1; i <= s / 3; i++)
    ans = (ans + dp[i][s]) % mod;
  printf("%lld\\n", ans);
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> dp(n + 1);
  dp[0] = 1;
  for (int i = 3; i <= n; i++) {
    for (int j = 3; j <= n; j++) {
      if (i - j >= 0) {
        dp[i] += dp[i - j];
        dp[i] %= MOD;
      }
    }
  }
  cout << dp[n] % MOD << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

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

const int N = 2000;
const int MOD = 1e9 + 7;
const int M = (2000 + 2) / 3;
int dp[M][N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  memset(dp, -1, sizeof dp);
  function<int(int, int)> solve = [&](int idx, int sum) {
    if (sum < 0)
      return 0;
    if (sum == 0)
      return 1;
    if (dp[idx][sum] != -1)
      return dp[idx][sum] % MOD;
    long long ans = 0;
    for (int i = 3; i <= sum; i++) {
      ans += solve(idx + 1, sum - i);
      ans %= MOD;
    }
    return dp[idx][sum] = ans % MOD;
  };
  int result = solve(0, n);
  result %= MOD;
  cout << result << '\\n';
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
#define mod 1000000007

int main() {
  ll n;
  cin >> n;
  vector<ll> dp(n + 1);

  dp[0] = 1;

  for (ll i = 3; i <= n; i++) {
    ll cur = 0;
    for (ll j = 3; j <= i; j++) {
      cur = (cur + dp[i - j]) % mod;
    }
    dp[i] = cur;
  }

  cout << dp[n] << "\\n";
}

Error: 0

Fixed submission:

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

typedef long long ll;
#define mod 1000000007

int main() {
  ll n;
  cin >> n;
  vector<ll> dp(n + 1);
  dp[3] = 1;
  dp[0] = 1;

  for (ll i = 4; i <= n; i++) {
    ll cur = 0;
    for (ll j = 3; j <= i; j++) {
      cur = (cur + dp[i - j]) % mod;
    }
    dp[i] = cur;
  }

  cout << dp[n] << "\\n";
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
const double PI = 3.14159265358979323846;
const in MOD = 1000000007;
const in INF = 1e18 + 7;
const int inf = 1e9 + 7;
using P = pair<int, int>;
vector<int> dx = {0, 1, -1, 0};
vector<int> dy = {1, 0, 0, -1};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int s;
  cin >> s;
  vector<vector<in>> dp(max(s / 3, 1), vector<in>(s + 1, 0));
  REP(i, 3, s + 1) dp[0][i] = 1;
  in ans = 0;
  ans += dp[0][s];

  for (int i = 1; i < s / 3; i++) {
    in sum = 0;
    REP(j, 3 * i + 3, s + 1) {
      sum += dp[i - 1][j - 3];
      sum %= MOD;
      dp[i][j] = sum;
    }
    ans += dp[i][s];
    ans %= MOD;
  }
  cout << ans << endl;
} /*
 ./problem.exe
 */

Error: 0

Fixed submission:

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
const double PI = 3.14159265358979323846;
const in MOD = 1000000007;
const in INF = 1e18 + 7;
const int inf = 1e9 + 7;
using P = pair<int, int>;
vector<int> dx = {0, 1, -1, 0};
vector<int> dy = {1, 0, 0, -1};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int s;
  cin >> s;
  vector<vector<in>> dp(s / 3, vector<in>(s + 1, 0));
  REP(i, 3, s + 1) dp[0][i] = 1;
  in ans = 0;
  ans += dp[0][s];

  for (int i = 1; i < s / 3; i++) {
    in sum = 0;
    REP(j, 3 * i + 3, s + 1) {
      sum += dp[i - 1][j - 3];
      sum %= MOD;
      dp[i][j] = sum;
    }
    ans += dp[i][s];
    ans %= MOD;
  }
  cout << ans << endl;
} /*
 ./problem.exe
 */
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define endl "\\n"
#define mm 998244353

ll power(ll x, ll y, ll p) {
  ll res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
ll modInverse(ll A, ll M) { return power(A, M - 2, M); }
const int N = 2001;
int dp[N];

void init(int n) {
  dp[0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 3; i + j <= n; j++) {
      dp[i + j] = ((dp[i + j] % mod) + (dp[i] % mod)) % mod;
    }
  }
}

void solve() {
  int n;
  cin >> n;
  if (n <= 2) {
    cout << 0 << endl;
    return;
  }
  init(n);
  ll ans = dp[n];
  cout << ans << endl;
}

int main() {
#ifdef JUDGE
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif
  boost;
  int t = 1; // cin>>t;
  for (int i = 1; i <= t; i++)
    solve();
  return 0;
}

Error: TLE

Fixed submission:

/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define endl "\\n"
#define mm 998244353

ll power(ll x, ll y, ll p) {
  ll res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
ll modInverse(ll A, ll M) { return power(A, M - 2, M); }
const int N = 2001;
int dp[N][N];

int solve(int n, int sum) {
  if (n == 0 && sum == 0)
    return 1;
  if (n == 0)
    return 0;
  if (n > sum || sum <= 0)
    return 0;
  if (dp[n][sum] != -1)
    return dp[n][sum];
  ll ans = 0;
  for (int i = 3; i <= sum; i++) {
    ans = ((ans % mod) + (solve(n - 1, sum - i) % mod)) % mod;
  }
  dp[n][sum] = ans;
  return ans;
}

void solve() {
  int n;
  cin >> n;
  memset(dp, -1, sizeof(dp));
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = ((ans % mod) + (solve(i, n) % mod)) % mod;
  }
  cout << ans << endl;
}

int main() {
#ifdef JUDGE
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif
  boost;
  int t = 1; // cin>>t;
  for (int i = 1; i <= t; i++)
    solve();
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int dp(int n, int m[]) {
  if (m[n - 3] == 0)
    dp(n - 3, m);
  if (m[n - 1] == 0)
    dp(n - 1, m);
  m[n] = (m[n - 3] + m[n - 1]) % 1000000007;
  return 0;
}

int main() {
  int nom[2000] = {
      0,
  };
  nom[3] = nom[4] = nom[5] = 1;
  int n;
  cin >> n;
  if (n < 6)
    cout << nom[n];
  else {
    dp(n, nom);
    cout << nom[n];
  }
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int dp(int n, int m[]) {
  if (m[n - 3] == 0)
    dp(n - 3, m);
  if (m[n - 1] == 0)
    dp(n - 1, m);
  m[n] = (m[n - 3] + m[n - 1]) % 1000000007;
}

int main() {
  int nom[2000] = {
      0,
  };
  nom[3] = nom[4] = nom[5] = 1;
  int n;
  cin >> n;
  if (n < 6)
    cout << nom[n];
  else {
    dp(n, nom);
    cout << nom[n];
  }
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int mark[200003] = {};
int limit = 0;
long long dp[200005] = {};
long long getSum(long long n) {
  if (dp[n] != -1 && n >= 0) {
    return dp[n];
  }
  if (n == 0) {
    return 1;
  }
  if (n < 0) {
    return 0;
  }
  long long res = 0;
  for (int i = 1; i <= limit; i++) {
    if (n - mark[i] >= 0) {
      res = (res + getSum(n - mark[i])) % mod;
    }
  }
  return dp[n] = res % mod;
}
void solve() {
  long long n;
  cin >> n;
  for (int i = 3; i <= n; i++) {
    limit++;
    mark[limit] = i;
  }
  long long sum = getSum(n) % mod;
  cout << sum << endl;
}
int main() {
  memset(dp, -1, sizeof(dp));
  solve();
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int mark[200003] = {};
int limit = 0;
int dp[200005] = {};
long long getSum(long long n) {
  if (dp[n] != -1 && n >= 0) {
    return dp[n];
  }
  if (n == 0) {
    return 1;
  }
  if (n < 0) {
    return 0;
  }
  long long res = 0;
  for (int i = 1; i <= limit; i++) {
    res = (res + getSum(n - mark[i])) % mod;
  }
  return dp[n] = res % mod;
}
void solve() {
  long long n;
  cin >> n;
  for (int i = 3; i <= n; i++) {
    limit++;
    mark[limit] = i;
  }
  long long sum = getSum(n) % mod;
  cout << sum << endl;
}
int main() {
  memset(dp, -1, sizeof(dp));
  solve();
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const ll mod = 1e9 + 7;
ll n, dp[777][2020], s[777][2020], ans;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;

  dp[0][0] = s[0][0] = 1;

  for (int i = 1; i <= n / 3 + 1; i++) {
    for (int j = 1; j <= n; j++) {
      if (j >= 3)
        (dp[i][j] += s[i - 1][j - 3]) %= mod;
      s[i][j] = (s[i][j - 1] + dp[i][j]) % mod;
    }
  }

  for (int i = 1; i <= n / 3 + 1; i++)
    ans = (ans + s[i][n]) % mod;

  cout << ans;
}

Error: TLE

Fixed submission:

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

const ll mod = 1e9 + 7;
ll n, dp[777][2020], ans;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;

  dp[0][0] = 1;

  for (int i = 1; i <= n / 3 + 1; i++) {
    for (int j = i * 3; j <= n; j++) {
      for (int k = 0; k <= j - 3; k++) {
        (dp[i][j] += dp[i - 1][k]) %= mod;
      }
    }
  }

  for (int i = 1; i <= n / 3 + 1; i++)
    ans = (ans + dp[i][n]) % mod;

  cout << ans;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int s;
  cin >> s;
  long long fib[s];
  const int mod = 1e9 + 7;
  fib[0] = 0;
  fib[1] = 0;
  fib[2] = 1;
  for (int i = 3; i < s; i++) {
    fib[i] = (fib[i - 1] + fib[i - 3]) % mod;
  }
  cout << fib[s - 1];
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int s;
  cin >> s;
  long long fib[s + 1];
  const int mod = 1e9 + 7;

  fib[0] = 0;
  fib[1] = 0;
  fib[2] = 0;
  fib[3] = 1;

  for (int i = 4; i <= s; ++i) {
    fib[i] = (fib[i - 1] + fib[i - 3]) % mod;
  }
  cout << fib[s];
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

const int N = 2010;
long long mod = 1e9 + 7;
long long cache[N];
long long s;

long long dp(long long num) {
  if (num > s)
    return 0;
  if (num == s)
    return 1;

  long long &ans = cache[num];
  if (ans != -1)
    return ans;

  ans = 0;
  for (long long nnum = 3; nnum <= s; nnum++) {
    if (nnum + num <= s)
      ans = (ans + dp(num + nnum)) % mod;
    else
      break;
  }

  return ans % mod;
}

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

  cin >> s;
  memset(cache, -1, sizeof(cache));

  long long ans = dp(0);
  cout << ans;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

const int N = 2010;
long long mod = 1e9 + 7;
long long cache[N][N];
long long s;

long long dp(int ind, long long num) {
  if (num > s || ind >= N)
    return 0;
  if (num == s)
    return 1;

  long long &ans = cache[ind][num];
  if (ans != -1)
    return ans;

  ans = 0;
  for (long long nnum = 3; nnum <= s; nnum++) {
    if (nnum + num <= s)
      ans = (ans + dp(ind + 1, num + nnum)) % mod;
    else
      break;
  }

  return ans % mod;
}

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

  cin >> s;
  memset(cache, -1, sizeof(cache));

  long long ans = dp(0, 0);
  cout << ans;

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

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

int main() {
  int s;
  cin >> s;
  vector<int> F(s + 1, 0);
  for (int i = 3; i <= s; ++i) {
    F[i] = 1;
  }
  int mod = 1e9 + 7;
  for (int i = 1; i <= s; ++i) {
    for (int j = 0; j < i; ++j) {
      if (j >= 3 && i - j >= 3) {
        F[i] = (F[i] + F[j]) % mod;
      }
    }
  }
  cout << F[s] << endl;
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int s;
  cin >> s;
  vector<int> F(s, 0);
  for (int i = 3; i <= s; ++i) {
    F[i] = 1;
  }
  int mod = 1e9 + 7;
  for (int i = 5; i <= s; ++i) {
    for (int j = 0; j < i; ++j) {
      if (j >= 3 && i - j >= 3) {
        F[i] = (F[i] + F[j]) % mod;
      }
    }
  }
  cout << F[s] << endl;
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int mark[20003] = {};
int limit = 0;
int dp[200005] = {};
long long getSum(int n) {
  if (dp[n] != -1 && n >= 0) {
    return dp[n];
  }
  if (n == 0) {
    // cout << n << endl;
    // cout << Count << endl;
    // Count++;
    return 1;
  }
  if (n < 0) {
    return 0;
  }
  long long res = 0;
  for (int i = 1; i <= limit; i++) {
    // cout << mark[i] << endl;
    int tt = n - mark[i];
    if (tt >= 0) {
      res = (res + getSum(tt)) % mod;
    }
  }
  // cout << n << " " << res << endl;
  return dp[n] = res % mod;
}
void solve() {
  long long n;
  cin >> n;
  for (int i = 3; i <= n; i++) {
    limit++;
    mark[limit] = i;
  }
  // cout << limit << endl;
  long long sum = getSum(n) % mod;
  cout << sum << endl;
}
int main() {
  memset(dp, -1, sizeof(dp));
  solve();
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int mark[2003] = {};
int limit = 0;
long long dp[2005] = {};
int getSum(int n) {
  if (dp[n] != -1 && n >= 0) {
    return dp[n];
  }
  if (n == 0) {
    // cout << n << endl;
    // cout << Count << endl;
    // Count++;
    return 1;
  }
  if (n < 0) {
    return 0;
  }
  int res = 0;
  for (int i = 1; i <= limit; i++) {
    // cout << mark[i] << endl;
    int tt = n - mark[i];
    if (tt >= 0) {
      res = (res + getSum(tt)) % mod;
    }
  }
  // cout << n << " " << res << endl;
  dp[n] = res % mod;
}
void solve() {
  int n;
  cin >> n;
  for (int i = 3; i <= n; i++) {
    limit++;
    mark[limit] = i;
  }
  // cout << limit << endl;
  long long sum = getSum(n) % mod;
  cout << sum << endl;
}
int main() {
  memset(dp, -1, sizeof(dp));
  solve();
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <vector>

#define reps(i, s, n) for (int(i) = (s); (i) < (n); (i)++)
#define rep(i, n) reps(i, 0, n)
using namespace std;
using ll = long long;

ll dp[2010][710];
ll mod = 1e9 + 7;

int main() {
  rep(i, 2010) {
    rep(j, 710) { dp[i][j] = 0; }
  }
  dp[3][1] = 1;

  int s;
  cin >> s;
  reps(i, 4, 2010) {
    rep(j, 701) {
      dp[i][j] = dp[i - 1][j];
      if (i - 3 >= 0 && j >= 1)
        dp[i][j] = (dp[i][j] + dp[i - 3][j - 1]) % mod;
    }
  }

  ll ans = 0;
  rep(i, 700) { ans = (ans + dp[s][i]) % mod; }

  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <vector>

#define reps(i, s, n) for (int(i) = (s); (i) < (n); (i)++)
#define rep(i, n) reps(i, 0, n)
using namespace std;
using ll = long long;

ll dp[2000][701];
ll mod = 1e9 + 7;

int main() {
  rep(i, 2000) {
    rep(j, 701) { dp[i][j] = 0; }
  }
  dp[3][1] = 1;

  int s;
  cin >> s;
  reps(i, 4, 2000) {
    rep(j, 701) {
      dp[i][j] = dp[i - 1][j];
      if (i - 3 >= 0 && j >= 1)
        dp[i][j] = (dp[i][j] + dp[i - 3][j - 1]) % mod;
    }
  }

  ll ans = 0;
  rep(i, 700) { ans = (ans + dp[s][i]) % mod; }

  cout << ans << endl;
  return 0;
}