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

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int main() {
  int s;
  cin >> s;
  ll dp[2010];
  dp[3] = 1;
  for (int i = 4; i < 2010; i++) {
    dp[i] = (dp[i - 1] + dp[i - 3]) % mod;
  }
  cout << dp[s] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int s, ans;
const int mod = 1e9 + 7;
void dfs() {
  if (s == 0)
    ans = (ans + 1) % mod;
  for (int i = 3; i <= s; i++) {
    s -= i;
    dfs();
    s += i;
  }
  return;
}
int main() {
  cin >> s;
  dfs();
  cout << ans << endl;
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
int d[2010];
int main() {
  int n;
  cin >> n;
  d[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i - 3; j++) {
      d[i] += d[j];
      d[i] %= mod;
    }
  }
  cout << d[n] << "\\n";
  return 0;
}

Error: -11

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
long long mod = 1e9 + 7;
long long s, ans, res, c[2010][2010];
int main() {
  cin >> s;
  c[1][1] = c[1][0] = 1;
  for (int i = 2; i <= 2100; i++) {
    c[i][0] = 1;
    // cout<<1<<endl;
    for (int j = 1; j <= 2100; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  // cout<<1<<endl;
  while (s >= 3) {
    s -= 3;
    res++;
    ans = (ans + c[s + res - 1][res - 1]) % mod; // cout<<ans<<endl;
  }
  cout << ans << endl;
  // system("pause");
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define na
#define ll long long
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vll vector<pair<ll, ll>>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define pb push_back
#define inf 1000000007
#define f(i, a, b) for (i = a; i < b; i++)
#define re0 return 0
using namespace std;
bool cmp(pair<ll, int> &a, pair<ll, int> &b) {
  if (a.ff == b.ff)
    return a.ss < b.ss;

  return a.ff > b.ff;
}
vector<vector<int>> v(100001);
map<pair<int, int>, int> q;
int vis[100001];
int cc;
ll exp(ll j, ll n) {
  ll i = n, res = 1;

  while (j > 0) {
    if (j & 1)
      res *= i;
    res %= (ll)inf;
    i = i * i;
    i %= (ll)inf;
    j >>= 1;
  }

  return (res - 1ll) % (ll)inf;
}
void dfs(int node, int par) {
  vis[node] = 1;
  q[{min(par, node), max(par, node)}] = cc;
  cc--;

  for (auto child : v[node]) {
    if (vis[child] == 0) {
      dfs(child, node);
    }
  }
}
int main() {
#ifdef ha
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ll s, i, j;
  cin >> s;

  if (s < 3) {
    cout << 0;
    re0;
  }
  ll dp[s + 1];

  f(i, 3, s + 1) dp[i] = 1;

  for (i = 3; i <= s; i++) {
    for (j = 3; j <= i - 3; j++) {
      dp[i] += (dp[i - j]) % inf;
      dp[i] %= inf;
    }
  }
  cout << dp[s];
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define na
#define ll long long
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vll vector<pair<ll, ll>>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define pb push_back
#define inf 1000000007
#define f(i, a, b) for (i = a; i < b; i++)
#define re0 return 0
using namespace std;
bool cmp(pair<ll, int> &a, pair<ll, int> &b) {
  if (a.ff == b.ff)
    return a.ss < b.ss;

  return a.ff > b.ff;
}
vector<vector<int>> v(100001);
map<pair<int, int>, int> q;
int vis[100001];
int cc;
ll exp(ll j, ll n) {
  ll i = n, res = 1;

  while (j > 0) {
    if (j & 1)
      res *= i;
    res %= (ll)inf;
    i = i * i;
    i %= (ll)inf;
    j >>= 1;
  }

  return (res - 1ll) % (ll)inf;
}
void dfs(int node, int par) {
  vis[node] = 1;
  q[{min(par, node), max(par, node)}] = cc;
  cc--;

  for (auto child : v[node]) {
    if (vis[child] == 0) {
      dfs(child, node);
    }
  }
}
int main() {
#ifdef ha
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ll s, i, j;
  cin >> s;

  if (s < 3) {
    cout << 0;
    re0;
  }
  ll dp[s + 1];

  dp[3] = 1, dp[4] = 1, dp[5] = 1;
  f(i, 3, s + 1) dp[i] = 1;
  for (i = 3; i <= s; i++) {
    for (j = 3; j <= i; j++) {
      if (i - j >= 3) {
        dp[i] += (dp[i - j]) % inf;
        dp[i] %= inf;
      }
    }
  }
  cout << dp[s];
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 2001
#define mod 1000000007

int n, nn;
int dp[MAXN * 9];

int solve(int j) {
  if (j == n)
    return dp[j] = 1;
  if (j > n)
    return dp[j] = 0;
  if (dp[j] != -1)
    return dp[j];
  int ret = 0;
  for (int f = 3; f <= n - j; f++)
    ret = (ret + solve(j + f)) % mod;
  return dp[j] = ret;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  int ans = 0;
  memset(dp, -1, sizeof(dp));
  cout << solve(0) << endl;
}


Error: TLE

Fixed submission:

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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 2001
#define mod 1000000007

int n, nn;
int dp[MAXN][MAXN * 9];

int solve(int i, int j) {
  if (j == n)
    return dp[i][j] = 1;
  if (j > n)
    return dp[i][j] = 0;
  if (dp[i][j] != -1)
    return dp[i][j];
  int ret = 0;
  for (int f = 3; f <= n - j; f++)
    ret = (ret + solve(i + 1, j + f)) % mod;
  return dp[i][j] = ret;
}
signed main() {
  scanf("%d", &n);
  int ans = 0;
  memset(dp, -1, sizeof(dp));
  printf("%d\\n", solve(0, 0));
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

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

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

  int s;
  const int MOD = 1e9 + 7;
  cin >> s;

  vector<int> dp(s + 1, 0);

  dp[0] = 1;
  for (int i = 3; i <= s; i++)
    for (int j = 3; j <= i; j++)
      dp[i] = (dp[i] + dp[i - j]) % MOD;

  cout << dp[s] << endl;

  return 0;
}


Error: 0

Fixed submission:

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

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

  int s;
  const int MOD = 1e9 + 7;
  cin >> s;

  vector<int> dp(s, 0);

  dp[0] = 1;
  for (int i = 3; i <= s; i++)
    for (int j = 3; j <= i; j++)
      dp[i] = (dp[i] + dp[i - j]) % MOD;

  cout << dp[s] << endl;

  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#define ll long long
const ll mod = 1e9 + 7;
ll dp[2005] = {0}, n;
int main() {
  scanf("%lld", &n);
  dp[0] = 1;
  dp[1] = 0;
  dp[2] = 0;
  for (ll i = 3; i <= n; i++) {
    for (ll j = 3; i - j >= 0; j++) {
      dp[i] += dp[i - j];
      dp[i] %= mod;
    }
    //	printf("%lld\\n",dp[i]);
  }
  printf("%lld\\n", dp[n]);
}

Error: TLE

Fixed submission:

#include <stdio.h>
#define mod 1000000007
#define ll long long
ll sp(ll a, ll b) {
  ll c = 1;
  while (a) {
    if (a & 1) {
      c *= b;
      c %= mod;
    }
    b *= b;
    b %= mod;
    a >>= 1;
  }
  return c;
}
int main() {
  ll n, ans = 0;
  scanf("%lld", &n);
  if (n >= 3) {
    ans += 1;
  }
  ll x = 2;
  while (x * 3 <= n) {
    ans += n - 3 * x + 1;
  }
  printf("%lld\\n", ans % mod);
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

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

// Template START
#define endl "\\n"
#define async                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present(x, y) (x.find(y) != x.end())
const int mod = (int)1e9 + 7;
template <class T> auto matrix(int r, int c, T v) {
  return vector<vector<T>>(r, vector<T>(c, v));
}
template <class T> auto matrix(int o1, int o2, int o3, T v) {
  return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<T>(o3, v)));
}
#define v vector
// Template END

int power(int x, int n) {
  if (n == 0)
    return 1;
  else if (n & 1)
    return (x * power((x * x) % mod, n / 2)) % mod;
  return power((x * x) % mod, n / 2) % mod;
}

signed main() {
  int s;
  cin >> s;
  // assert( s <= 2000 ) ;
  v<int> dp(s + 1, 0);
  dp[0] = 1;
  // dp[3] = 1 ;
  for (int i = 3; i <= s; i++) {
    for (int j = 3; (i - j) >= 0; j++) {
      (dp[i] += dp[i - j]) %= mod;
    }
  }
  cout << dp[s];
  return 0;
}

Error: WA

Fixed submission:

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

// Template START
#define endl "\\n"
#define async                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present(x, y) (x.find(y) != x.end())
const int mod = (int)1e9 + 7;
template <class T> auto matrix(int r, int c, T v) {
  return vector<vector<T>>(r, vector<T>(c, v));
}
template <class T> auto matrix(int o1, int o2, int o3, T v) {
  return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<T>(o3, v)));
}
#define v vector
// Template END

int power(int x, int n) {
  if (n == 0)
    return 1;
  else if (n & 1)
    return (x * power((x * x) % mod, n / 2)) % mod;
  return power((x * x) % mod, n / 2) % mod;
}

signed main() {
  int s;
  cin >> s;
  assert(s <= 2000);
  v<int> dp(s + 1, 0);
  dp[0] = 1;
  dp[3] = 1;
  for (int i = 4; i <= s; i++) {
    for (int j = 3; (i - j) >= 0; j++) {
      (dp[i] += dp[i - j]) %= mod;
    }
  }
  cout << dp[s];
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int s;
  cin >> s;
  vector<int> sum(s + 1, 0);
  vector<int> dp(s + 1, 0);
  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;
  sum[3] = 1;
  sum[4] = 2;
  sum[5] = 3;
  if (s >= 6) {
    for (int i = 6; i < s + 1; i++) {
      dp[i] = 1 + sum[i - 3];

      if (dp[i] >= mod) {
        dp[i] = dp[i] % mod;
      }
      sum[i] = sum[i - 1] + dp[i];
      if (sum[i] >= mod) {
        sum[i] = sum[i] % mod;
      }
    }
  }
  cout << dp[s] << endl;
}

Error: 0

Fixed submission:

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

int main() {
  int s;
  cin >> s;
  vector<int> sum(s, 0);
  vector<int> dp(s, 0);
  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;
  sum[3] = 1;
  sum[4] = 2;
  sum[5] = 3;
  for (int i = 6; i < s + 1; i++) {
    dp[i] = 1 + sum[i - 3];

    if (dp[i] >= mod) {
      dp[i] = dp[i] % mod;
    }
    sum[i] = sum[i - 1] + dp[i];
    if (sum[i] >= mod) {
      sum[i] = sum[i] % mod;
    }
  }
  cout << dp[s] << endl;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define INF (1LL << 50)
#define MOD 1000000007

int main() {
  int S;
  cin >> S;
  if (S < 3) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> ans(S + 1);
  // ans[i] = ans[i-3] + ans[i-4] + ... + ans[0]
  // ans[i-1] =          ans[i-4] + ... + ans[0]
  // ans[i] = ans[i-1] + ans[i-3]
  ans[3] = 1;
  for (int i = 4; i <= S; i++) {
    ans[i] = ans[i - 1] + ans[i - 3];
    ans[i] %= MOD;
  }
  cout << ans[S] << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define INF (1LL << 50)
#define MOD 1000000007

int main() {
  int S;
  cin >> S;
  vector<ll> ans(S + 1);
  // ans[i] = ans[i-3] + ans[i-4] + ... + ans[0]
  // ans[i-1] =          ans[i-4] + ... + ans[0]
  // ans[i] = ans[i-1] + ans[i-3]
  ans[3] = 1;
  for (int i = 4; i <= S; i++) {
    ans[i] = ans[i - 1] + ans[i - 3];
    ans[i] %= MOD;
  }
  cout << ans[S] << endl;
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#define mk make_pair
#define pk push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
int n, f[2005], g[2005];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  int ans = 0;
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    memcpy(g, f, sizeof f);
    for (int j = 3; j <= n; ++j)
      if (i >= j)
        (f[i] += g[i - j]) %= mod;
  }
  cout << f[n] << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#define mk make_pair
#define pk push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
int n, f[2005][2005];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  int ans = 0;
  f[0][0] = 1;
  for (int i = 1; i <= n / 3; ++i) {
    for (int j = i * 3; j <= n; ++j)
      for (int k = 3; k <= j; ++k)
        (f[j][i] += f[j - k][i - 1]) %= mod;
    (ans += f[n][i]) %= mod;
  }
  cout << ans << endl;
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define M 1010
#define N 1000000
#define D double
#define LL long long
using namespace std;
LL n, dp[N], mod = 1e9 + 7;
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  dp[3] = 1;
  for (int i = 4; i <= n; i++)
    dp[i] = (dp[i - 1] + dp[i - 3]) % mod;
  cout << dp[n];
  return 0;
}
/*
 */


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#define M 1010
#define N 1000000
#define D double
#define LL long long
#pragma GCC optimize(2)
using namespace std;
LL n, a[N], sum = 0, mod = 1e9 + 7;
;
void zbc(LL s, LL x) {
  for (int i = 3; i <= s; i++)
    if (i < n) {
      s -= i;
      a[x] = i;
      if (s == 0)
        sum = (sum + 1) % mod;
      else
        zbc(s, x + 1);
      s += i;
    }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  if (n < 3) {
    cout << 0;
    return 0;
  }
  if (n == 3) {
    cout << 1;
    return 0;
  }
  a[0] = 1;
  zbc(n, 1);
  cout << sum % mod + 1;
  return 0;
}
/*
 */
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
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 vec(a, y, x) vector<vector<char>> a(y, vector<char>(x))
const double PI = 3.14159265358979323846;
const in MOD = 1000000007;
const in INF = 1e18 + 7;
const int inf = 1e9 + 7;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};

int main() {
  int s;
  cin >> s;
  vector<in> a(s + 1, 0);

  for (int i = 3; i <= s; i++) {
    a.at(i) = 1;
    for (int j = 3; j < i; j++) {
      if (i - j < 3)
        break;
      a.at(i) += a.at(i - j);
      a.at(i) = a.at(i) % MOD;
    }
  }
  cout << a.at(s) << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
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 vec(a, y, x) vector<vector<char>> a(y, vector<char>(x))
const double PI = 3.14159265358979323846;
const in MOD = 1000000007;
const in INF = 1e18 + 7;
const int inf = 1e9 + 7;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};

int main() {
  int s;
  cin >> s;
  vector<in> a(s + 1);
  rep(i, 3) a.at(i) = 0;
  for (int i = 3; i <= s; i++) {
    a.at(i) = 1;
    for (int j = 3; j <= s; j++) {
      if (i - j < 3)
        break;
      a.at(i) += a.at(i - j);
      a.at(i) = a.at(i) % MOD;
    }
  }
  cout << a.at(s) << endl;
}
Problem p02555 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

const ll N = 100001;

int dp[667][2010];

const ll mod = 1000000000 + 7;

int main() {

  int S;
  cin >> S;

  int p = S / 3;

  for (int i = 3; i <= S; ++i) {
    dp[1][i] = 1;
  }
  /*
      for(int i=0;i<=p;i++){
          for(int j=0;j<=S;j++){
              cout<<dp[i][j]<<" ";
          }
          cout<<endl;
      }
      */

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

    cout<<"========="<<endl;
     for(int i=0;i<=p;i++){
    for(int j=0;j<=S;j++){
        cout<<dp[i][j]<<" ";
    }
    cout<<endl;

}
*/
  }

  ll ans = 0;

  for (int i = 1; i <= p; i++) {

    ans = (ans + dp[i][S]) % mod;
  }

  cout << ans << endl;
}


Error: 0

Fixed submission:

// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
  // A[n] = A[n - 1] + A[n - 3]
  ll n;
  cin >> n;
  vector<ll> A(n + 1, 0);
  A.at(3) = 1;
  rep2(i, 4, n + 1) { A.at(i) = (A.at(i - 1) + A.at(i - 3)) % MOD; }
  cout << A.at(n) << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}
Problem p02555 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define fastIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll MOD = 1E9 + 7, INF = 2E18 + 5;
const double PI = 2 * acos(0.0);
const long double EPS = 1.0E-14;

ll dp[2000];
ll n;

ll check(ll val) {
  if (val == 0)
    return 1;
  if (dp[val] != -1)
    return dp[val];

  ll ans = 0;
  for (int i = 3; i <= 2000; i++) {
    if (val - i >= 0) {
      ans += check(val - i);
      ans %= MOD;
    }
  }
  return dp[val] = ans;
}

int main() {
  ll ans = 0;
  cin >> n;

  memset(dp, -1, sizeof dp);

  for (int i = 3; i <= 2000; i++) {
    if (n - i >= 0) {
      ans += check(n - i);
      ans %= MOD;
    }
  }
  cout << ans;

  return 0;
}


Error: TLE

Fixed submission:

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

#define fastIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll MOD = 1E9 + 7, INF = 2E18 + 5;
const double PI = 2 * acos(0.0);
const long double EPS = 1.0E-14;

ll dp[2000][2000];
ll n;

ll check(ll pos, ll val) {
  if (val == 0)
    return 1;
  if (dp[pos][val] != -1)
    return dp[pos][val];

  ll ans = 0;
  for (int i = 3; i <= 2000; i++) {
    if (val - i >= 0) {
      ans += check(pos + 1, val - i);
      ans %= MOD;
    }
  }
  return dp[pos][val] = ans;
}

int main() {
  ll ans = 0;
  cin >> n;

  memset(dp, -1, sizeof dp);

  for (int i = 3; i <= 2000; i++) {
    if (n - i >= 0) {
      ans += check(0, n - i);
      ans %= MOD;
    }
  }
  cout << ans;

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

#include <bits/stdc++.h>
#include <iostream>

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pi 3.14159265358979323846
#define Q                                                                      \\
  ll _;                                                                        \\
  cin >> _;                                                                    \\
  while (_--)
#define endl "\\n"
#define flush fflush(stdout);

int main() {

  fast

      ll i,
      j, n;
  cin >> n;
  ll dp[2001];
  for (i = 0; i <= n; i++) {
    dp[i] = 0;
  }
  dp[0] = 1;
  dp[1] = 0;
  dp[2] = 0;
  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;

  for (i = 6; i <= n; i++) {
    for (j = 0; j <= i - 3; j++) {
      dp[i] = (dp[j] % MOD) + (dp[i] % MOD);
      dp[i] = dp[i] % MOD;
    }
  }
  ll ans = dp[n] % MOD;
  cout << ans % MOD << endl;
}

//    cout << fixed << setprecision(12);


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100005
#define MOD 1000000007
#define fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define pi 3.14159265358979323846
#define Q                                                                      \\
  ll _;                                                                        \\
  cin >> _;                                                                    \\
  while (_--)
#define endl "\\n"
#define flush fflush(stdout);

int main() {

  fast

      ll i,
      j, n;
  cin >> n;
  ll dp[n + 1];
  for (i = 0; i <= n; i++) {
    dp[i] = 0;
  }
  dp[0] = 1;
  dp[1] = 0;
  dp[2] = 0;
  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;

  for (i = 6; i <= n; i++) {
    for (j = 0; j <= i - 3; j++) {
      dp[i] = (dp[j] % MOD) + (dp[i] % MOD);
      dp[i] = dp[i] % MOD;
    }
  }
  ll ans = dp[n] % MOD;
  cout << ans % MOD << endl;
}

//    cout << fixed << setprecision(12);