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

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, ans = 0, i = 1;
  scanf("%d", &n);
  while (true) {
    if (i * 2 - 1 > n) {
      printf("%d\\n", ans);
      return 0;
    } else {
      ans++;
    }
    i *= 2;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    bitset<30> b(i);
    if (b.count() > ans) {
      ans = b.count();
    }
  }
  printf("%d\\n", ans);
  return 0;
}
Problem p02126 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <exception>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define per(i, a, n) for (ll i = (a); i > (n); i--)
#define lep(i, a, n) for (ll i = (a); i <= (n); i++)
#define pel(i, a, n) for (ll i = (a); i >= (n); i--)
#define clr(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9 + 7;
ll n, m, l;
string s, t;
ll d[200010], dp[550][550];

int main() {
  cin >> n >> m >> l;
  rep(i, 0, l) cin >> d[i];
  vector<vector<int>> vec(l);
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    a--;
    vec[a].pb(b);
  }
  // puts("!!!!!!!!");
  rep(i, 0, l) { sort(all(vec[i]), greater<int>()); }
  // puts("!!!!!!");

  vi ans;
  rep(i, 0, l) {
    ll p = min((ll)d[i], (ll)vec[i].sz);
    rep(j, 0, p) ans.pb(vec[i][j]);
  }

  // puts("!!!!!!");
  sort(all(ans), greater<int>());
  ll p = 0;
  rep(i, 0, m) p += ans[i];
  // puts("ans");
  print(p);
  return 0;
}


Error: MLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <exception>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define per(i, a, n) for (ll i = (a); i > (n); i--)
#define lep(i, a, n) for (ll i = (a); i <= (n); i++)
#define pel(i, a, n) for (ll i = (a); i >= (n); i--)
#define clr(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9 + 7;
ll n, m, l;
string s, t;
ll d[200010], dp[550][550];

int main() {
  cin >> n >> m >> l;
  rep(i, 0, l) cin >> d[i];
  vector<vector<int>> vec(l, vector<int>(n));
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    a--;
    vec[a].pb(b);
  }
  rep(i, 0, l) { sort(all(vec[i]), greater<int>()); }
  vi ans;
  rep(i, 0, l) { rep(j, 0, d[i]) ans.pb(vec[i][j]); }
  sort(all(ans), greater<int>());
  ll p = 0;
  rep(i, 0, m) p += ans[i];
  // puts("ans");
  print(p);
  return 0;
}
Problem p02126 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int>>
template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) {
  auto inner = vectors(tail...);
  return vectors<decltype(inner)>(x, inner);
}
using ll = long long;
using ld = long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
#define MAX 9999999
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int W, H;
bool inrange(int x, int y) { return (0 <= x && x < W) && (0 <= y && y < H); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
#define MP make_pair
signed main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> lim(C);
  rep(i, C) cin >> lim[i];
  priority_queue<pii, vector<pii>> que;
  rep(i, N) {
    pii temp;
    cin >> temp.first >> temp.second;
    swap(temp.first, temp.second);
    que.push(temp);
  }
  int ans = 0;
  while (M > 0 && !que.empty()) {
    pii temp = que.top();
    que.pop();
    if (lim[temp.second - 1] == 0)
      continue;
    lim[temp.second - 1]--;
    ans += temp.first;
    --M;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int>>
template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) {
  auto inner = vectors(tail...);
  return vectors<decltype(inner)>(x, inner);
}
using ll = long long;
using ld = long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
#define MAX 9999999
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int W, H;
bool inrange(int x, int y) { return (0 <= x && x < W) && (0 <= y && y < H); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
#define MP make_pair
signed main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> lim(C);
  rep(i, C) cin >> lim[i];
  priority_queue<pii, vector<pii>> que;
  rep(i, N) {
    pii temp;
    cin >> temp.first >> temp.second;
    que.push(temp);
  }
  int ans = 0;
  while (M > 0) {
    pii temp = que.top();
    que.pop();
    if (lim[temp.first - 1] == 0)
      continue;
    lim[temp.first - 1]--;
    ans += temp.second;
    --M;
  }
  cout << ans << endl;
}
Problem p02126 (C++) — buggy submission, verdict: Runtime Error

#include "algorithm"
#include "bitset"
#include "climits"
#include "cmath"
#include "cstdio"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> N >> M >> K;
  vector<queue<int>> v(1001);
  vector<int> num(K);
  for (int i = 0; i < K; i++) {
    cin >> num[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> L >> R;
    L--;
    v[R].push(L);
  }
  int ans = 0;
  for (int i = 1000; i > 0; i--) {
    while (!v[i].empty()) {
      int box = v[i].front();
      v[i].pop();
      if (num[box]) {
        num[box]--;
        M--;
        ans += i;
        if (!M) {
          cout << ans << endl;
          return 0;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include "algorithm"
#include "bitset"
#include "climits"
#include "cmath"
#include "cstdio"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> N >> M >> K;
  vector<queue<int>> v(1001);
  vector<int> num(N);
  for (int i = 0; i < K; i++) {
    cin >> num[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> L >> R;
    L--;
    v[R].push(L);
  }
  int ans = 0;
  for (int i = 1000; i > 0; i--) {
    while (!v[i].empty()) {
      int box = v[i].front();
      v[i].pop();
      if (num[box]) {
        num[box]--;
        M--;
        ans += i;
        if (!M) {
          cout << ans << endl;
          return 0;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02127 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define P(p) cout << (p) << endl
#define rep(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rrep(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(), greater<int>());
#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
#define ret return
#define C(i) cin >> i
#define C2(i, j) cin >> i >> j
#define C3(i, j, k) cin >> i >> j >> k
#define C4(i, j, k, m) cin >> i >> j >> k >> m
////////////////////////////////////////////////////////////

int main() {
  string s, t;
  cin >> s >> t;

  string now = t, bef = "";

  rep(i, 1, 22) {
    string chk = now;
    int idx = 0;
    char c = chk[idx];

    bool f = false;
    rep(j, 0, s.size()) {
      if (s[j] == c) {
        if (++idx >= chk.size()) {
          f++;
          break;
        }
        c = chk[idx];
      }
    }

    // P(now);
    // P(f);
    if (f) {
      bef = now;

    } else {
      P(i - 1);
      break;
    }

    if (s.size() < (long long)bef.size() * (t.size() + 1)) {
      P(i);
      break;
    }

    if (i > 0) {
      string tmp = bef;
      rep(j, 0, t.size()) tmp += t[j] + bef;
      now = tmp;
    }
  }

  ret 0;
}


Error: MLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define P(p) cout << (p) << endl
#define rep(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rrep(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(), greater<int>());
#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
#define ret return
#define C(i) cin >> i
#define C2(i, j) cin >> i >> j
#define C3(i, j, k) cin >> i >> j >> k
#define C4(i, j, k, m) cin >> i >> j >> k >> m
////////////////////////////////////////////////////////////

int main() {
  string s, t;
  cin >> s >> t;

  string now, bef = "";

  rep(i, 1, 22) {
    if (i > 0) {
      string tmp = bef;
      rep(j, 0, t.size()) tmp += t[j] + bef;
      now = tmp;
    }

    string chk = now;
    int idx = 0;
    char c = chk[idx];

    bool f = false;
    rep(j, 0, s.size()) {
      if (s[j] == c) {
        if (++idx >= chk.size()) {
          f++;
          break;
        }
        c = chk[idx];
      }
    }

    if (f)
      bef = now;
    else {
      P(i - 1);
      break;
    }
  }

  ret 0;
}
Problem p02127 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  string s, t;
  cin >> s >> t;
  int dep = 1;
  string targ = t;
  while (1) {
    int pos = 0;
    rep(i, s.length()) {
      if (pos >= (int)targ.length())
        break;
      if (s[i] == targ[pos]) {
        pos++;
      }
    }
    if (pos < (int)targ.length())
      break;
    dep++;
    lint nxtlen = (t.length() + 1) * (lint)targ.size() + t.length();
    if (s.length() < nxtlen)
      break;
    string nxt = targ;
    rep(i, t.length()) nxt += t[i] + targ;
    targ = nxt;
  }
  cout << dep - 1 << endl;
}


Error: MLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  string s, t;
  cin >> s >> t;
  int dep = 1;
  string targ = t;
  while (1) {
    int pos = 0;
    rep(i, s.length()) {
      if (pos >= (int)targ.length())
        break;
      if (s[i] == targ[pos]) {
        pos++;
      }
    }
    if (pos < (int)targ.length())
      break;
    dep++;
    string nxt = targ;
    rep(i, t.length()) nxt += t[i] + targ;
    targ = nxt;
  }
  cout << dep - 1 << endl;
}
Problem p02127 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb emplace_back
#define INF (1e9 + 1)

bool isSubstr(string &s, string &t) {
  int p = 0;
  rep(i, s.size()) {
    if (s[i] == t[p]) {
      p++;
    }
    if (p == t.size())
      break;
  }

  if (p == t.size())
    return true;
  else
    return false;
}

int main() {
  string s, t;

  cin >> s >> t;

  //    vector<string> vs(18,"");
  //    vs[1] = t;
  //    int l = t.size();
  //    for(int i=2;i<18;i++){
  //        l = (l+1)*t.size() + l;
  //        if(l>s.size())break;
  //        vs[i] = t;
  //        rep(j,vs[i-1].size()){
  //            vs[i]+=string(1,vs[i-1][j]);
  //            vs[i]+=t;
  //        }
  //        assert(l==vs[i].size());
  //    }
  //
  //    for(int i=1;i<18;i++)if(vs[i]=="")vs[i] = "*";

  vector<string> vs(2);
  vs[1] = t;
  int ok = 0;
  for (int i = 1; i < 18; i++) {

    if (isSubstr(s, vs[i % 2]))
      ok = i;
    else
      break;
    int l = (vs[i % 2].size() + 1) * t.size() + vs[i % 2].size();

    if (l > s.size())
      break;
    vs[(i + 1) % 2] = t;
    rep(j, vs[i % 2].size()) {
      vs[(i + 1) % 2] += string(1, vs[i % 2][j]);
      vs[(i + 1) % 2] += t;
    }
  }
  cout << ok << endl;
}


Error: MLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb emplace_back
#define INF (1e9 + 1)

bool isSubstr(string &s, string &t) {
  int p = 0;
  rep(i, s.size()) {
    if (s[i] == t[p]) {
      p++;
    }
    if (p == t.size())
      break;
  }

  if (p == t.size())
    return true;
  else
    return false;
}

int main() {
  string s, t;

  cin >> s >> t;

  vector<string> vs(18, "");
  vs[1] = t;
  int l = t.size();
  for (int i = 2; i < 18; i++) {
    l = (l + 1) * t.size() + l;
    if (l > 100000)
      break;
    vs[i] = t;
    rep(j, vs[i - 1].size()) {
      vs[i] += string(1, vs[i - 1][j]);
      vs[i] += t;
    }
    assert(l == vs[i].size());
  }

  for (int i = 1; i < 18; i++)
    if (vs[i] == "")
      vs[i] = "*";

  int ok = 0;
  for (int i = 1; i < 18; i++) {
    if (isSubstr(s, vs[i]))
      ok = i;
    else
      break;
  }
  cout << ok << endl;
}
Problem p02127 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  string s, t;

  cin >> s >> t;

  string x = t;
  int ans = 0;
  for (int i = 0; x.size() <= s.size(); i++) {
    // check
    // cerr << "x: " << x << endl;
    int idx = 0;
    for (char ch : s) {
      if (idx < x.size() and ch == x[idx]) {
        idx++;
      }
    }
    if (idx != x.size())
      break;

    ans++;

    long long size = x.size() * (t.size() + 1) + t.size();
    if (size > s.size())
      break;

    string y = x;
    for (char ch : t) {
      y.push_back(ch);
      y += x;
    }
    x = y;
  }

  cout << ans << endl;

  return 0;
}


Error: MLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  string s, t;

  cin >> s >> t;

  string x = t;
  int ans = 0;
  for (int i = 0; x.size() <= s.size(); i++) {
    // check
    // cerr << "x: " << x << endl;
    int idx = 0;
    for (char ch : s) {
      if (idx < x.size() and ch == x[idx]) {
        idx++;
      }
    }
    if (idx != x.size())
      break;

    ans++;

    string y = x;
    for (char ch : t) {
      y.push_back(ch);
      y += x;
    }
    x = y;
  }

  cout << ans << endl;

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

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

bool check(string T, string P) {
  if (P.length() > T.length())
    return false;

  int index = 0;
  for (int i = 0; i < T.length(); i++) {
    if (T[i] == P[index]) {
      index++;
      if (index == P.length())
        return true;
    }
  }
  return false;
}

int main() {

  string T, base_P, work_P, next_P;
  getline(cin, T);
  getline(cin, base_P);

  int ans = 0;

  work_P = base_P;
  while (check(T, work_P)) {
    ans++;

    next_P = base_P;

    if ((work_P.length() + 1) * (base_P.length()) + work_P.length() >
        T.length())
      break;

    for (int i = 0; i < work_P.length(); i++) {
      next_P += work_P[i] + base_P;
    }
    work_P = next_P;
  }

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

  return 0;
}


Error: MLE

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <time.h>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

bool check(string T, string P) {
  if (P.length() > T.length())
    return false;

  int index = 0;
  for (int i = 0; i < T.length(); i++) {
    if (T[i] == P[index]) {
      index++;
      if (index == P.length())
        return true;
    }
  }
  return false;
}

int main() {

  string T, base_P, work_P, next_P;
  getline(cin, T);
  getline(cin, base_P);

  int ans = 0;

  work_P = base_P;
  while (check(T, work_P)) {
    ans++;

    next_P = base_P;

    for (int i = 0; i < work_P.length(); i++) {
      next_P += work_P[i] + base_P;
    }
    work_P = next_P;
  }

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

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int MAX_N = (1 << 21) - 1;
const ll inf = numeric_limits<ll>::max() / 3;

string s, t;

bool ok(string u) {
  int p;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (p == (int)u.size())
      return true;
    if (s[i] == u[p])
      ++p;
  }
  return p == (int)u.size();
}

int main(void) {
  cin >> s >> t;
  string now = t;
  int res = 0;
  ll sz = (ll)t.size();
  while (true) {
    if (!ok(now))
      break;
    ++res;
    ll sznow = (ll)now.size();
    if (sznow * (sz + 1) + sz > (ll)s.size())
      break;
    string tmp = now;
    for (int i = 0; i < (int)t.size(); ++i) {
      now += string(1, t[i]);
      now += tmp;
    }
  }
  cout << res << endl;
  return 0;
}


Error: MLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int MAX_N = (1 << 21) - 1;
const ll inf = numeric_limits<ll>::max() / 3;

string s, t;

bool ok(string u) {
  int p;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (p == (int)u.size())
      return true;
    if (s[i] == u[p])
      ++p;
  }
  return p == (int)u.size();
}

int main(void) {
  cin >> s >> t;
  string now = t;
  int res = 0;
  while (true) {
    if (!ok(now))
      break;
    ++res;
    string tmp = now;
    for (int i = 0; i < (int)t.size(); ++i) {
      now += string(1, t[i]);
      now += tmp;
    }
  }
  cout << res << endl;
  return 0;
}
Problem p02127 (C++) — buggy submission, verdict: Memory Limit Exceeded


#if 1
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cstdint>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

auto &in = std::cin;
auto &out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI =
    3.141592653589793238462643383279502884197169399375105820974944;

std::string s, t, tori;

int main() {
  using std::endl;
  in.sync_with_stdio(false);
  out.sync_with_stdio(false);
  in.tie(nullptr);
  out.tie(nullptr);

  in >> s >> t;
  tori = t;

  int32_t lev = 0;
  auto s_iter = s.begin();
  auto t_iter = t.begin();
  while (s_iter != s.end()) {
    if (*s_iter == *t_iter) {
      ++t_iter;
      if (t_iter == t.end()) {
        ++lev;
        std::string new_t = t;
        for (auto &ss : tori) {
          new_t.push_back(ss);
          new_t += t;
          if (new_t.size() > s.size()) {
            out << lev << endl;
            return 0;
          }
        }
        auto oldt_size = t.size();
        t = std::move(new_t);
        t_iter = t.begin() + oldt_size;
      }
    }
    ++s_iter;
  }
  out << lev << endl;

  return 0;
}
#endif


Error: MLE

Fixed submission:


#if 1
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cstdint>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

auto &in = std::cin;
auto &out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI =
    3.141592653589793238462643383279502884197169399375105820974944;

std::string s, t, tori;

int main() {
  using std::endl;
  in.sync_with_stdio(false);
  out.sync_with_stdio(false);
  in.tie(nullptr);
  out.tie(nullptr);

  in >> s >> t;
  tori = t;

  int32_t lev = 0;
  auto s_iter = s.begin();
  auto t_iter = t.begin();
  while (s_iter != s.end()) {
    if (*s_iter == *t_iter) {
      ++t_iter;
      if (t_iter == t.end()) {
        ++lev;
        std::string new_t = t;
        for (auto &ss : tori) {
          new_t.push_back(ss);
          new_t += t;
        }
        auto oldt_size = t.size();
        t = std::move(new_t);
        t_iter = t.begin() + oldt_size;
      }
    }
    ++s_iter;
  }
  out << lev << endl;

  return 0;
}
#endif