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

/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>

int main() {
  long int a, b, c, d;
  int i;
  long int x, y;
  long int p[4];
  long long int ans;

  scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
  // printf("%d %d %d %d\\n",a, b, c, d);

  p[0] = a * c;
  p[1] = a * d;
  p[2] = b * c;
  p[3] = b * d;

  // printf("%d %d %d %d\\n",p[0], p[1], p[2], p[3]);

  ans = p[0];
  // printf("%lld\\n",ans);

  for (i = 1; i < 4; i++) {
    // printf("%d\\n",i);
    if (p[i] > ans) {
      ans = p[i];
      // printf("%d\\n",i);
      // printf("%lld\\n",ans);
    }

    // printf("%d\\n",p[i]);
  }

  printf("%lld\\n", ans);

  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int a, b, c, d;
  int i, j;
  int x, y;
  long long int p;
  long long int ans;

  scanf("%d %d %d %d", &a, &b, &c, &d);
  // printf("%d %d %d %d\\n",a, b, c, d);

  p = a * c;
  ans = p;

  for (i = a; i < b + 1; i++) {
    for (j = c; j < d + 1; j++) {
      x = i;
      // printf("%d\\n",x);
      y = j;
      // printf("%d\\n",y);
      p = x * y;
      // printf("%lld\\n",p);
      if (p > ans) {
        ans = p;
      }
    }
  }

  printf("%lld\\n", ans);

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans;
  ans = max(max(max(a * c, a * d), b * c), b * d);
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = a * c;
  for (long long i = a; i <= b; i++) {
    for (long long j = c; j <= d; j++) {
      ans = max(ans, i * j);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02554 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

const int N = 1e6 + 10;
const int MOD = 1e9 + 7;
const int64_t INF = 5e18;
const double PI = 2 * acos(0.0);
// template<typename T> using ordered_set = tree<T, null_type, less<T>,
// rb_tree_tag, tree_order_statistics_node_update>;

int n, dp[N][2][2];

int fun(int pos, int zero, int nine) {
  if (pos == 0) {
    return (zero && nine);
  }
  int &tmp = dp[pos][zero][nine];
  if (tmp != -1) {
    return tmp;
  }
  tmp = 0;
  for (int i = 0; i < 10; i++) {
    tmp += fun(pos - 1, (i == 0) | zero, (i == 9) | nine);
    tmp %= MOD;
  }
  return tmp;
}

int main() {
  //    ios::sync_with_stdio(false);
  //    cin.tie(0);
  cin >> n;
  memset(dp, -1, sizeof dp);
  cout << fun(n, 0, 0) << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const int64_t INF = 5e18;
const double PI = 2 * acos(0.0);
// template<typename T> using ordered_set = tree<T, null_type, less<T>,
// rb_tree_tag, tree_order_statistics_node_update>;

int n, dp[N][2][2];

int fun(int pos, int zero, int nine) {
  if (pos == n) {
    return (zero && nine) ? 1 : 0;
  }
  int tmp = dp[pos][zero][nine];
  if (tmp != -1) {
    return tmp;
  }
  tmp = 0;
  for (int i = 0; i < 10; i++) {
    tmp += fun(pos + 1, (i == 0) | zero, (i == 9) | nine);
    tmp %= MOD;
  }
  return tmp;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  memset(dp, -1, sizeof dp);
  cout << fun(0, 0, 0) << '\\n';
  return 0;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

template <typename T> void read(T &x) {
  x = 0;
  int fl = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      fl = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  x *= fl;
}
template <typename T, typename... Args> inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}

typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)

const LL MOD = 1e9 + 7;
const int N = 1000005;

LL dp[4][N];

int main() {
  int n;
  read(n);
  if (n == 1)
    return puts("0"), 0;
  dp[0][1] = 8, dp[1][1] = dp[2][1] = 1, dp[3][1] = 0;
  for (int i = 2; i <= n; i++) {
    dp[0][i] = dp[0][i - 1] * 8 % MOD;
    dp[1][i] = (dp[1][i - 1] * 9 + dp[0][i - 1]) % MOD;
    dp[2][i] = (dp[2][i - 1] * 9 + dp[0][i - 1]) % MOD;
    dp[3][i] = (dp[3][i - 1] * 10 + dp[2][i - 1] + dp[1][i - 1]) % MOD;
  }
  printf("%lld\\n", dp[3][n]);
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)

const LL MOD = 1e9 + 7;
const int N = 1000005;

LL dp[4][N];

int main() {
  int n;
  scanf("%d", &n);
  if (n == 1)
    return puts("0");
  dp[0][1] = 8, dp[1][1] = dp[2][1] = 1, dp[3][1] = 0;
  for (int i = 2; i <= n; i++) {
    dp[0][i] = dp[0][i - 1] * 8 % MOD;
    dp[1][i] = (dp[1][i - 1] * 9 + dp[0][i - 1]) % MOD;
    dp[2][i] = (dp[2][i - 1] * 9 + dp[0][i - 1]) % MOD;
    dp[3][i] = (dp[3][i - 1] * 10 + dp[2][i - 1] + dp[1][i - 1]) % MOD;
  }
  printf("%lld\\n", dp[3][n]);
  return 0;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
typedef long long ll;

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0)
    res += m;
  return res;
}

ll solve(ll n) {
  if (n == 1) {
    return 0;
  }
  ll c = 1;
  for (int i = 0; i < n; i++) {
    c *= 10;
    c %= MOD;
  }

  // 0も9もない
  ll d = 1;
  for (int i = 0; i < n; i++) {
    d *= 8;
    d %= MOD;
  }

  // 0がない
  ll e = 1;
  for (int i = 0; i < n; i++) {
    e *= 9;
    e %= MOD;
  }

  // 0がある
  ll a = mod(c - e, MOD);

  ll ans = mod((2 * a) - mod((c - d), MOD), MOD);
  assert(a >= 0 && c >= 0 && d >= 0 && e >= 0 && ans >= 0);
  // if (a >= 0 && c >= 0 && d >= 0 && e >= 0 && ans >= 0) {
  return ans;
  // }
  // cout << "a = " << a << endl;
  // cout << "c = " << c << endl;
  // cout << "d = " << d << endl;
  // cout << "e = " << e << endl;
  // cout << "ans = " << ans << endl;
}

int main() {
  ll n;
  cin >> n;
  // for (ll i = 1; i < 100; i++) {
  // solve(i);
  // }
  cout << solve(n) << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
typedef long long ll;

ll solve(ll n) {
  if (n == 1) {
    return 0;
  }
  ll c = 1;
  for (int i = 0; i < n; i++) {
    c *= 10;
    c %= MOD;
  }

  // 0も9もない
  ll d = 1;
  for (int i = 0; i < n; i++) {
    d *= 8;
    d %= MOD;
  }

  // 0がない
  ll e = 1;
  for (int i = 0; i < n; i++) {
    e *= 9;
    e %= MOD;
  }

  // 0がある
  ll a = c - e;

  ll ans = (2 * a) - (c - d);
  assert(a >= 0 && c >= 0 && d >= 0 && e >= 0 && ans >= 0);
  // if (a >= 0 && c >= 0 && d >= 0 && e >= 0 && ans >= 0) {
  return ans % MOD;
  // }
  // cout << "a = " << a << endl;
  // cout << "c = " << c << endl;
  // cout << "d = " << d << endl;
  // cout << "e = " << e << endl;
  // cout << "ans = " << ans << endl;
}

int main() {
  ll n;
  cin >> n;
  // for (ll i = 1; i < 100; i++) {
  // solve(i);
  // }
  cout << solve(n) << endl;
  return 0;
}
Problem p02554 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define w(x)                                                                   \\
  int x;                                                                       \\
  cin >> x;                                                                    \\
  while (x--)
ll int n, k;
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  ll int mod = 1e9 + 7;
  ll int ans1 = 1, ans2 = 1, ans3 = 1;
  for (int i = 0; i < n; i++) {
    ans1 = ans1 * 10;
    ans1 %= mod;
    ans2 = ans2 * 9;
    ans2 %= mod;
    ans3 = ans3 * 8;
    ans3 %= mod;
  }
  ll int ans_final = (ans1 - 2 * ans2 + ans3 + mod) % mod;
  while (ans_final < 0)
    ans_final += mod;
  cout << ans_final;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define w(x)                                                                   \\
  int x;                                                                       \\
  cin >> x;                                                                    \\
  while (x--)
ll int n, k;
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  ll int mod = 1e9 + 7;
  ll int ans1 = 1, ans2 = 1, ans3 = 1;
  for (int i = 0; i < n; i++) {
    ans1 = ans1 * 10;
    ans1 %= mod;
    ans2 = ans2 * 9;
    ans2 %= mod;
    ans3 = ans3 * 8;
    ans3 %= mod;
  }
  ll int ans_final = (ans1 - 2 * ans2 + ans3 + mod) % mod;
  while (ans_final < 0)
    ans_final %= mod;
  cout << ans_final;
}
Problem p02554 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

const int MOD = 1e9 + 7;

int pow(int x, int n) {
  long long ret = 1;
  for (int i = 0; i < n; ++i) {
    ret = (ret * x) % MOD;
  }
  return ret;
}

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

  int N;
  cin >> N;

  long long ret = pow(10, N);
  ret = (ret - pow(9, N) + MOD) % MOD;
  ret = (ret - pow(9, N) + MOD) % MOD;
  ret = (ret + pow(8, N) + MOD) % MOD;
  cout << ret << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000000 + 7;

int answer;

void findPermutation(int n, int used) {
  if (n == 0) {
    if ((used & (1 << 0)) && (used & (1 << 9)))
      answer = (answer + 1) % MOD;
    return;
  }

  for (int i = 0; i < 10; ++i) {
    findPermutation(n - 1, used | (1 << i));
  }
}

int main() {
  answer = 0;

  int N;
  cin >> N;

  findPermutation(N, 0);
  cout << answer << endl;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

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

ll N, ans;
int i, j;
ll mod = 1000000007;

ll powmod(ll x, ll y) {
  ll r = 1;
  rep0(i, y) r = r * x % mod;
  return r;
}

int main() {
  cin >> N;
  ans = powmod(10, N) - powmod(9, N) - powmod(9, N) + powmod(8, N);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(i, s, n) for (i = s; i < n; i++)
using namespace std;

long long ans;
int N;
typedef long long ll;
int i, j;

ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[101010], rf[101010];
ll inv(ll x) {
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while (k) {
    if (k & 1)
      res = (res * y) % mod;
    y = (y * y) % mod;
    k /= 2;
  }
  return res;
}
void init() {
  f[0] = 1;
  rep(i, 1, 101010) f[i] = (f[i - 1] * i) % mod;
  rep(i, 0, 101010) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
  ll a = f[n];      // = n!
  ll b = rf[n - k]; // = (n-k)!
  ll c = rf[k];     // = k!

  ll bc = (b * c) % mod;

  return (a * bc) % mod;
}

long long mypow(long long n) {
  long long i, ans = 2;
  rep0(i, n - 1) {
    ans *= 2;
    ans %= 1000000007;
  }
  return ans;
}

int main() {
  init();
  cin >> N;
  if (N > 1) {
    rep(i, 2, N + 1) {
      long long a = mypow(3 * N - 2 * i - 1) * C(N, i);
      a = a % 1000000007;
      ans += a;
      ans = ans % 1000000007;
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }

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

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll ksm(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans * a % mod;
    }
    b >>= 1;
    a = a * a % mod;
  }
  return ans;
}
int main() {
  ll n;
  cin >> n;
  ll ans = (ksm(10, n) - ksm(9, n) - ksm(9, n) + ksm(8, n)) % mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string getString() {
  string x;
  cin >> x;
  if (x.size() < 3 || x.size() > 99) {
    return getString();
  }
  if (x.size() % 2 == 0) {
    return getString();
  }
  int tama = static_cast<int>(x.size());
  for (int i = 0; i < tama; i++) {
    if (x[i] < 96 || x[i] > 122) {
      return getString();
    }
  }

  return x;
}

bool check_palindrome(string caso) {
  int tama = static_cast<int>(caso.size());
  int ptr1 = 0;
  int ptr2 = tama - 1;
  for (int i = 0; i < tama / 2; i++) {
    if (ptr1 == ptr2) {
      return true;
    }
    if (caso[ptr1] != caso[ptr2]) {
      return false;
    }
    ptr1++;
    ptr2--;
  }

  return true;
}

int main() {
  string caso{getString()};
  int tama = static_cast<int>(caso.size());
  if (check_palindrome(caso)) {
    int first_case{((tama - 1) / 2)};
    string caso1{caso[0]};
    for (int i = 1; i < first_case; i++) {
      caso1 += caso[i];
    }
    if (check_palindrome(caso1)) {
      int second_case{(tama + 3) / 2};
      string caso2{caso[second_case - 1]};
      for (int j = second_case; j < caso.size(); j++) {
        caso2 += caso[j];
      }
      if (check_palindrome(caso2)) {
        cout << "YES";
        return 0;
      }
      cout << "NO";
      return 0;
    }
    cout << "NO";
    return 0;
  } else {
    cout << "NO";
  }

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

#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z) {
  if (y == 0)
    return 1;
  else {
    ll p = power(x, y / 2, z);
    ll w = (p * p) % z;
    if (y % 2 == 0)
      return w;
    else
      return (x * w) % z;
  }
}
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  int n;
  cin >> n;
  int k = n + 1;
  ll f[k];
  f[0] = f[1] = 1;
  for (int i = 2; i < k; i++)
    f[i] = (f[i - 1] * i) % hell;
  ll ans = 0, p = f[n];
  for (int i = 2; i <= n; i++) {
    ll a = ((power((f[i] * f[n - i]) % hell, hell - 2, hell)) * p) % hell;
    ll z = ((power(2, 3 * n - 2 * i, hell) - power(2, 3 * n - 3 * i + 1, hell) +
             hell)) %
           hell;
    a = (a * z) % hell;
    ans = (ans + a) % hell;
  }
  cout << ans;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z) {
  if (y == 0)
    return 1;
  else {
    ll p = power(x, y / 2, z);
    ll w = (p * p) % z;
    if (y % 2 == 0)
      return w;
    else
      return (x * w) % z;
  }
}
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  int n;
  cin >> n;
  int k = n + 1;
  ll f[k];
  f[0] = f[1] = 1;
  for (int i = 2; i < k; i++)
    f[i] = (f[i - 1] * i) % hell;
  ll ans = 0, p = f[n];
  for (int i = 2; i <= n; i++) {
    ll a = ((power(f[i], hell - 2, hell)) * p) % hell;
    a = (a * power(f[n - i], hell - 2, hell)) % hell;
    ll z = ((power(2, 3 * n - 2 * i, hell) - power(2, 3 * n - 3 * i + 1, hell) +
             hell)) %
           hell;
    a = (a * z) % hell;
    ans = (ans + a) % hell;
  }
  cout << ans;
}
Problem p02554 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod = 1000000007;
#define REP(i, f, n) for (int i = f; i < (n); i++)

ll afd(ll e, ll n) {
  ll ans = 1;
  REP(i, 0, n) {
    ans *= e;
    ans %= mod;
  }
  return ans;
}

int main() {
  ll ans, n;
  //                  966971091
  cin >> n;
  ans = afd(10, n) - (2 * afd(9, n)) % mod + afd(8, n);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;

  //--debug : end_stop 5er
  // string end_stoper; cin >> end_stoper;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod = 1000000007;
ll cnt = 0;
#define REP(i, f, n) for (int i = f; i < (n); i++)

void afd(int max, int ima, bool zero, bool nin) {
  REP(i, 0, 10) {
    bool zero2 = zero, nin2 = nin;
    if (i == 0)
      zero2 = true;
    if (i == 9)
      nin2 = true;
    if (ima == max) {
      if (zero2 && nin2) {
        cnt++;
        cnt %= mod;
      }
    } else
      afd(max, ima + 1, zero2, nin2);
  }
}

int main() {
  ll n;
  //                  966971091
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  afd(n, 1, false, false);
  cout << cnt << endl;

  //--debug : end_stop 5er
  // string end_stoper; cin >> end_stoper;

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

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {

  ll n;
  cin >> n;
  ll ans = 1;
  ll mod = (ll)(1e9 + 7);
  ll res1, res2, res3;
  res1 = res2 = res3 = 1;

  for (int i = 1; i <= n; i++) {
    res1 = (res1 * 10) % mod;
    res2 = (res2 * 9) % mod;
    res3 = (res3 * 8) % mod;
  }
  ans = ((res1 % mod - 2 * res2 % mod + mod) % mod + res3 % mod) % mod;
  cout << ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int mod = (int)(pow(10, 9) + 7);
  int n;
  cin >> n;
  int dp[n + 1][10];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < 10; i++) {
    dp[0][i] = 0;
    dp[1][i] = 0;
    dp[2][i] = 0;
  }
  dp[2][9] = 1;
  dp[2][0] = 1;

  for (int i = 3; i <= n; i++) {

    for (int d = 0; d < 10; d++) {

      for (int k = 0; k < 10; k++)
        dp[i][d] += (dp[i - 1][k]) % mod;
    }
  }
  int ans = 0;
  for (int d = 0; d < 10; d++) {
    ans = (ans + dp[n][d]) % mod;
  }
  cout << ans << endl;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#define ll long long
using namespace std;

const ll md = 1e9 + 7;

ll q(ll a, int b) {
  ll ans = 1, x = a;
  while (b) {
    if (b & 1)
      ans = (ans * x) % md;
    x = (x * x) % md;
    b >>= 1;
  }

  return ans;
}

int main() {
  int n;
  scanf("%d", &n);
  printf("%lld\\n",
         ((q(10ll, n) + q(8ll, n)) % md - (q(9ll, n) << 1) % md + md) % md);

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
ll f[2006];
int main() {
  ios;
  f[0] = 1;
  for (int i = 3; i <= 2000; ++i)
    for (int j = 3; j <= i; ++j) {
      f[i] = (f[i] + f[i - j]) % mod;
    }
  int s;
  cin >> s;
  cout << f[s] << '\\n';
}
Problem p02554 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define Elhabashy                                                              \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
void input() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
}
const int N = 1e6 + 2, mod = 1e9 + 7;
typedef long long ll;
ll n, dp[N][2][2];
ll solve(int i = 1, bool f1 = 0, bool f2 = 0) {
  if (i > n) {
    if (f1 && f2)
      return 1;
    return 0;
  }
  ll &ret = dp[i][f1][f2];
  if (~ret)
    return ret;
  ret = 0;
  for (int j = 0; j <= 9; j++) {
    if (j == 0)
      ret += solve(i + 1, 1, f2);
    else if (j == 9)
      ret += solve(i + 1, f1, 1);
    else
      ret += solve(i + 1, f1, f2);
    ret %= mod;
  }
  return ret % mod;
}
int main() {
  Elhabashy input();
  cin >> n;
  memset(dp, -1, sizeof dp);
  cout << solve() % mod << endl;
}


Error: MLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define Elhabashy                                                              \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
void input() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
}
const int N = 1e7 + 10, mod = 1e9 + 7;
typedef long long ll;
ll n, dp[N][5][5];
ll solve(int i = 1, bool f1 = 0, bool f2 = 0) {
  if (i > n) {
    if (f1 && f2)
      return 1;
    return 0;
  }
  ll &ret = dp[i][f1][f2];
  if (~ret)
    return ret;
  ret = 0;
  for (int j = 0; j <= 9; j++) {
    if (j == 0)
      ret += solve(i + 1, 1, f2);
    else if (j == 9)
      ret += solve(i + 1, f1, 1);
    else
      ret += solve(i + 1, f1, f2);
    ret %= mod;
  }
  return ret % mod;
}
int main() {
  Elhabashy input();
  cin >> n;
  memset(dp, -1, sizeof dp);
  cout << solve() % mod << endl;
}