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

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

signed main() {
  int n;
  while (cin >> n && n != 0) {
    vi d(n);
    rep(i, 0, n) cin >> d[i];

    bool f[100000];
    memset(f, 0, sizeof(f));

    rep(i, 0, n) {
      f[i] = d[i];
      if (i % 2 && f[i - 1] != d[i]) {
        repb(j, i - 1, 0) {
          if (f[j] == d[i])
            break;
          f[j] = d[i];
        }
      }
    }

    int ans = 0;
    rep(i, 0, n) if (!f[i]) ans++;
    o(ans);
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
using namespace std;

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    vector<int> d(n), f(n, 0);
    rep(i, 0, n) cin >> d[i];

    f[0] = d[0];
    rep(i, 1, n) {
      if (i % 2 == 0 || d[i] == f[i - 1]) {
        f[i] = d[i];
      } else {
        int ind;
        for (ind = i - 1; ind >= 0; ind--) {
          if (f[ind] == d[i]) {
            ind++;
            break;
          }
        }
        if (ind < 0)
          ind = 0;
        rep(j, ind, i + 1) { f[j] = d[i]; }
      }
    }
    int ans = 0;
    rep(i, 0, n) {
      if (f[i] == 0)
        ans++;
    }
    cout << ans << endl;
  }
}
Problem p00450 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <vector>
typedef std::pair<int, int> P;
int main() {
  int n, i, x;
  while (scanf("%d", &n), n) {
    std::vector<std::pair<int, int>> v;
    for (i = 0; i < n; ++i) {
      scanf("%d", &x);
      if (i & 1) {
        if (v.back().first == x)
          v.back().second++;
        else {
          P p(v.back());
          v.pop_back();
          if (!v.empty())
            v.back().second += 1 + p.second;
          else
            v.push_back(P(x, p.second + 1));
        }
      } else {
        if (!v.empty() && v.back().first == x)
          v.back().second++;
        else
          v.push_back(P(x, 1));
      }
    }
    for (x = i = 0; i < v.size(); ++i)
      if (!v[i].first)
        x += v[i].second;
    printf("%d\\n", x);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bitset>
#include <stdio.h>
int main() {
  std::bitset<50000> b;
  int n, i, j, x, y;
  while (scanf("%d", &n), n) {
    b.reset();
    for (i = 0; i < n; ++i) {
      scanf("%d", &x);
      if (i & 1) {
        b[i / 2] = x;
        if (y != x)
          for (j = i / 2 - 1; j >= 0; --j)
            if (b[j] != x)
              b[j] = x;
            else
              break;
      }
      y = x;
    }
    printf("%d\\n", 2 * (n / 2 - b.count()) + (n & 1 ? !x : 0));
  }
  return 0;
}
Problem p00450 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define INF (1 << 29)
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int n;
  vector<int> v; // 白:正,黒:負
  while (cin >> n, n) {
    int c;
    v.clear();
    v.push_back(0);
    for (int i = 1; i <= n; i++) {
      cin >> c;
      if (c == 0) { // 白
        if (i & 1) {
          if (0 < v.back())
            ++v.back();
          else
            v.push_back(1);
        } else {
          if (0 < v.back())
            ++v.back();
          else {
            int a = -v.back();
            v.pop_back();
            if (v.empty())
              v.push_back(a + 1);
            else
              v.back() += a + 1;
          }
        }
      } else { // 黒
        if (i & 1) {
          if (0 <= v.back())
            v.push_back(-1);
          else
            --v.back();
        } else {
          if (0 < v.back()) {
            int a = v.back();
            v.pop_back();
            if (v.empty())
              v.push_back(-(a + 1));
            else
              v.back() -= a + 1;
          } else {
            --v.back();
          }
        }
      }
    }
    int ans = 0;
    rep(i, v.size()) {
      if (0 < v[i])
        ans += v[i];
    }
    cout << ans << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define INF (1 << 29)
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int n;
  vector<int> v; // 白:正,黒:負
  while (cin >> n, n) {
    int c;
    v.clear();
    v.push_back(0);
    v.push_back(0);
    for (int i = 1; i <= n; i++) {
      cin >> c;
      if (c == 0) { // 白
        if (i & 1) {
          if (0 < v.back())
            ++v.back();
          else
            v.push_back(1);
        } else {
          if (0 < v.back())
            ++v.back();
          else {
            int a = -v.back();
            v.pop_back();
            v.back() += a + 1;
          }
        }
      } else { // 黒
        if (i & 1) {
          if (0 < v.back())
            v.push_back(-1);
          else
            --v.back();
        } else {
          if (0 < v.back()) {
            int a = v.back();
            v.pop_back();
            v.back() -= a + 1;
          } else {
            --v.back();
          }
        }
      }
    }
    int ans = 0;
    rep(i, v.size()) {
      if (0 < v[i])
        ans += v[i];
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00450 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int n, stones[100001], sum;
int main() {
  while (cin >> n && n) {
    for (int i = 1; i <= n; i++) {
      cin >> stones[i];
      if (i % 2 == 0 && stones[i] != stones[i - 1]) {
        for (int j = i - 1; j > 0; j--) {
          if (stones[j] != stones[i]) {
            stones[j] = stones[i];
          } else {
            break;
          }
        }
      }
    }

    sum = 0;
    for (int i = 1; i <= n; i++) {
      if (!stones[i]) {
        sum++;
      }
    }

    cout << sum << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  while (1) {
    int n, stones[100001], sum = 0, loop;

    cin >> n;
    if (!n) {
      break;
    }

    for (int i = 1; i <= n; i++) {
      cin >> stones[i];
      if (!stones[i]) {
        sum++;
      }
      if (i == 1) {
        continue;
      }

      if (i % 2 == 0 && stones[i] != stones[i - 1]) {
        loop = i;
        while (stones[--loop] != stones[i]) {
          stones[loop] = stones[i];
          if (stones[loop]) {
            sum--;
          } else {
            sum++;
          }
        }
      }
    }

    cout << sum << endl;
  }

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

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> black;
    vector<int> white;
    int now;
    cin >> now;
    if (now == 1)
      black.push_back(1);
    else
      white.push_back(1);
    for (int i = 2; i <= n; i++) {
      int in;
      cin >> in;

      if (i % 2 == 0) {
        if (in == now) {
          if (in)
            black[black.size() - 1]++;
          else
            white[white.size() - 1]++;

        } else {

          if (in) {
            if (!black.empty())
              black[black.size() - 1] += white[white.size() - 1] + 1;
            else
              black.push_back(white[white.size() - 1] + 1);
            white.pop_back();
          } else {
            if (!white.empty())
              white[white.size() - 1] += black[black.size() - 1] + 1;
            else
              white.push_back(black[black.size() - 1] + 1);
            black.pop_back();
          }
        }

      } else {
        if (in == now) {
          if (in)
            black[black.size() - 1]++;
          else
            white[white.size() - 1]++;
        } else {
          if (in)
            black.push_back(1);
          else
            white.push_back(1);
        }
      }

      now = in;
    }
    int ans = 0;
    for (int i = 0; i < white.size(); i++)
      ans += white[i];
    cout << ans << endl;
  }
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> black;
    vector<int> white;
    int now;
    cin >> now;
    white.push_back(0);
    black.push_back(0);
    if (now == 1)
      black.push_back(1);
    else
      white.push_back(1);
    for (int i = 2; i <= n; i++) {
      int in;
      cin >> in;

      if (i % 2 == 0) {
        if (in == now) {
          if (in)
            black[black.size() - 1]++;
          else
            white[white.size() - 1]++;

        } else {

          if (in) {
            black[black.size() - 1] += white[white.size() - 1] + 1;
            white.pop_back();
          } else {
            white[white.size() - 1] += black[black.size() - 1] + 1;
            black.pop_back();
          }
        }

      } else {
        if (in == now) {
          if (in)
            black[black.size() - 1]++;
          else
            white[white.size() - 1]++;
        } else {
          if (in)
            black.push_back(1);
          else
            white.push_back(1);
        }
      }

      now = in;
    }
    int ans = 0;
    for (int i = 0; i < white.size(); i++)
      ans += white[i];
    cout << ans << endl;
  }
}
Problem p00450 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

struct Info {
  int color, num;
};
vector<Info> V;

void add(int col, bool odd) {

  if (V.empty()) {
    V.push_back((Info){col, 1});
    return;
  }

  if (odd) {
    // odd
    if (V.back().color == col)
      V.back().num++;
    else
      V.push_back((Info){col, 1});
  } else {
    // even
    if (V.back().color == col)
      V.back().num++;
    else {
      int tmp = 1;
      while (!V.empty() && V.back().color != col) {
        tmp += V.back().num;
        V.pop_back();
      }
      V.push_back((Info){col, tmp});
    }
  }
}

void print() {
  for (int i = 0; i < (int)V.size(); i++)
    cout << V[i].color << " " << V[i].num << endl;
  cout << endl;
}

int main() {
  int n;
  while (cin >> n && n) {
    V.clear();
    for (int i = 0; i < n; i++) {
      int in;
      cin >> in;
      add(in, !(i % 2));
      // print();
    }

    int ans = 0;
    for (int i = 0; i < (int)V.size(); i++)
      if (V[i].color == 0)
        ans += V[i].num;

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;

const int MAX = 100001;
int table[MAX];
int n;
int white;

void init() {
  fill(table, table + MAX, -1);
  white = 0;
}

void solve(int in, int pos) {
  // 0: white 1: black

  if (in == 0)
    white++;

  if (pos % 2) {
    table[pos] = in;
  } else {
    if (table[pos - 1] == in) {
      table[pos] = in;
    } else {
      int tmp = pos - 1;
      table[pos] = in;

      while (table[tmp] != in && tmp > 0) {
        if (table[tmp] == 1) {
          table[tmp] = 0;
          white++;
        } else {
          table[tmp] = 1;
          white--;
        }
        tmp--;
      }
    }
  }
}

int main() {

  while (cin >> n && n) {
    init();
    for (int i = 1; i <= n; i++) {
      int in;
      cin >> in;
      solve(in, i);
    }

    cout << white << endl;
  }
  return 0;
}
Problem p00450 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bitset>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const int MAX_N = 100000;

int main() {
  int n;
  while (cin >> n && n) {

    vector<int> lengh(n);
    int left, right = 0, before;
    lengh[right] = 1;

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

      int buf;
      cin >> buf;

      if (i) {

        if (before == buf) {

          lengh[right]++;

        } else if ((i + 1) % 2 == 0) {

          if (right == 0) {

            lengh[right]++;
            left = buf;

          } else {

            lengh[right - 1] += lengh[right] + 1;
            lengh[right] = 0;
            right--;
          }
        } else {

          right++;
          lengh[right] = 1;
        }

      } else
        left = before = buf;

      before = buf;
    }

    int res = 0;
    for (int i = 0; i < lengh.size(); i++) {
      if (!left)
        res += lengh[i];
      left = !left;
    }

    cout << res << endl;
  }
}

Error: TLE

Fixed submission:

#include <bitset>
#include <iostream>
// #include <ctime>
using namespace std;
typedef long long ll;

const int MAX_N = 100000;

int main() {
  int n;
  while (cin >> n && n) {
    // clock_t start = clock();

    bitset<MAX_N> table;
    table.set();

    for (int i = 0; i < n; i++) {
      int buf;
      cin >> buf;
      table[i] = buf; // rand()%2;

      if ((i + 1) % 2 == 0)
        for (int j = i - 1; j + 1 && table[j] != table[i]; j--)
          table[j].flip();
    }
    cout << MAX_N - table.count() << endl;
    // cout << clock() - start << endl;
  }
}
Problem p00450 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

#define MAX 100020
using namespace std;

int main() {
  while (true) {
    int n;
    int ans = 0;
    int white = 0;
    int black = 0;
    int cont[MAX] = {
        0,
    };
    int a[MAX] = {
        3,
    };

    scanf("%d", &n);

    if (n == 0)
      break;

    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
    }

    for (int i = 1; i <= n; ++i) {
      if (a[i] == a[i - 1])
        cont[i] = cont[i - 1] + 1;
      else
        cont[i] = 1;

      if (i % 2 == 0 && a[i] != a[i - 1]) {
        if (a[i] == 0) {
          white += cont[i - 1];
          black -= cont[i - 1];
          cont[i] = cont[i - 1] + cont[i - 1 - cont[i - 1]] + 1;
        } else {
          white -= cont[i - 1];
          black += cont[i - 1];
          cont[i] = cont[i - 1] + cont[i - 1 - cont[i - 1]] + 1;
        }
      }
      if (a[i] == 0) {
        ++white;
      } else {
        ++black;
      }
    }

    printf("%d\\n", white);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

#define MAX 100020
using namespace std;

int main() {
  while (true) {
    int n;
    int ans = 0;
    int a[MAX] = {
        0,
    };

    scanf("%d", &n);
    if (n == 0)
      break;

    for (int i = 1; i <= n; ++i) {
      int c;

      scanf("%d", &c);

      if (i % 2 == 0) {
        for (int d = i - 1; d > 0; --d) {
          if (a[d] == c)
            break;
          else
            a[d] = c;
        }
      }
      a[i] = c;
    }
    /*ans = 0;
    for(int i = 1; i <= n; ++i){
            if( a[i] == 0 ) ++ans;
    }*/
    printf("%d\\n", ans);
  }
  return 0;
}
Problem p00450 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>

using namespace std;

struct DATA {
  int x;
  int count;
};

void OddNumber(vector<DATA> &, int);
void EvenNnumber(vector<DATA> &, int);

int main() {
  int i, j, n, x, count;
  vector<DATA> data;

  while (1) {
    cin >> n;
    if (n == 0)
      break;

    for (i = 0; i < n; ++i) {
      cin >> x;
      if (i % 2 == 0)
        OddNumber(data, x);
      else
        EvenNnumber(data, x);
    }

    for (i = 0, count = 0; i < data.size(); ++i) {
      if (data[i].x == 0)
        count += data[i].count;
    }

    cout << count << endl;
    data.clear();
  }
  return 0;
}

void OddNumber(vector<DATA> &data, int x) {
  DATA _data;
  if (data.size() != 0 && x == data[data.size() - 1].x) {
    ++data[data.size() - 1].count;
  } else {
    _data.x = x;
    _data.count = 1;
    data.push_back(_data);
  }
}

void EvenNnumber(vector<DATA> &data, int x) {
  if (x == data[data.size() - 1].x) {
    ++data[data.size() - 1].count;
  } else if (data.size() == 1) {
    data[data.size() - 1].x = x;
    ++data[data.size() - 1].count;
  } else {
    data[data.size() - 2].count += (data[data.size() - 1].count + 1);
    data.pop_back();
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int i, j, n, x, count;
  vector<int> data;

  while (1) {
    cin >> n;
    if (n == 0)
      break;

    for (i = 0; i < n; ++i) {
      cin >> x;

      if (i % 2 == 1 && x != data[data.size() - 1]) {
        for (j = data.size() - 1; j > -1; --j) {
          if (x == data[j])
            break;
          data[j] = x;
        }
      }
      data.push_back(x);
    }

    for (i = 0, count = 0; i < data.size(); ++i) {
      if (data[i] == 0)
        ++count;
    }

    cout << count << endl;
    data.clear();
  }
  return 0;
}
Problem p00450 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

void solve() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    bool c[100001];
    for (int i = 0; i < n; ++i) {
      cin >> c[i];
      if ((i + 1) % 2 == 0) {
        if (i - 1 >= 0 && c[i - 1] != c[i]) {
          for (int j = i - 1; j >= 0; --j) {
            if (c[j] == c[i]) {
              break;
            }
            c[j] = c[i];
          }
        }
      }
    }
    cout << count(c, c + n, false) << endl;
  }
}

int main() {
  solve();
  return (0);
}

Error: TLE

Fixed submission:

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

using namespace std;

void solve() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    bool c[100001];
    for (int i = 0; i < n; ++i) {
      cin >> c[i];
    }
    for (int i = 0; i < n; ++i) {
      if ((i + 1) % 2 == 0) {
        if (c[i - 1] != c[i]) {
          int pos = i - 1;
          while (pos >= 0 && c[pos] != c[i]) {
            c[pos] = !c[pos];
            --pos;
          }
        }
      }
    }
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      if (c[i] == false) {
        ++sum;
      }
    }
    cout << sum << endl;
  }
}

int main() {
  solve();
  return (0);
}
Problem p00451 (C++) — buggy submission, verdict: Time Limit Exceeded

// AOJ:0528 common sub-string
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
string s, t;
int roop1, ans = 0, memo[4000][4000];
int main() {
  while (cin >> s >> t) {
    ans = 0;
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
        if (s[i] == t[j] && memo[i][j] == 0) {
          memo[i][j] = 1;
          roop1 = 1;
          while (1) {
            if (s[i + roop1] == 0 || t[j + roop1] == 0) {
              break;
            } else {
              if (s[i + roop1] == t[j + roop1]) {
                memo[i + roop1][j + roop1] = 1;
                roop1++;
              } else if (s[i + roop1] != t[j + roop1]) {
                break;
              }
            }
          }
          ans = max(ans, roop1);
        }
      }
    }
    cout << ans << endl;
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
        memo[i][j] = 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
string s, t;
int roop1, roop2 = 0, save, ans = 0;
int main() {
  while (cin >> s >> t) {
    roop2 = 0;
    ans = 0;
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
        if (s[i] == t[j]) {
          roop1 = 1;
          save = 1;
          while (1) {
            if (s[i + roop1] == 0 || t[j + roop1] == 0) {
              break;
            } else {
              if (s[i + roop1] == t[j + roop1]) {
                save += 1;
                roop1++;
              } else if (s[i + roop1] != t[j + roop1]) {
                break;
              }
            }
          }
          ans = max(ans, save);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00451 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int i, j, k;
  string s, t;
  while (cin >> s) {
    cin >> t;
    int sln = s.length(), tln = t.length();
    int mx = 0;
    for (i = 0; i < sln; i++) {
      for (j = 0; j < min(sln - i, tln); j = k) {
        for (; j < min(sln - i, tln) && s[i + j] != t[j]; j++)
          ;
        for (k = j; k < min(sln - i, tln) && s[i + k] == t[k]; k++)
          ;
        mx = max(mx, k - j);
      }
    }
    for (i = 0; i < tln; i++) {
      for (j = 0; j < min(tln - i, sln); j = k) {
        for (; j < min(tln - i, sln) && t[i + j] != s[j]; j++)
          ;
        for (k = j; k < min(tln - i, sln) && t[i + k] == s[k]; k++)
          ;
        mx = max(mx, k - j);
      }
    }
    cout << mx << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
  int i, j;
  int sln, tln, mx;
  string s, t;
  while (cin >> s) {
    cin >> t;
    sln = s.length();
    mx = 0;
    for (i = 0; i < sln - mx + 1; i++) {
      for (j = mx + 1; j < sln - i + 1; j++) {
        if (t.find(s.substr(i, j)) != string::npos)
          mx = j;
        else
          break;
      }
    }
    cout << mx << endl;
  }
  return 0;
}
Problem p00451 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

string s, t;
bool memo[4003][4003];
int main() {
  while (cin >> s >> t) {
    for (int i = 0; i < 4003; i++) {
      for (int j = 0; j < 4003; j++) {
        memo[i][j] = false;
      }
    }

    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
        if (s[i] == t[j]) {
          memo[i][j] = true;
        }
      }
    }

    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
        if (memo[i][j]) {
          int sum = 1;
          memo[i][j] = false;
          for (int k = 1; k < max(s.size() - i, t.size() - j); k++) {
            if (memo[i + k][j + k]) {
              sum++;
              memo[i + k][j + k] = false;
            } else {
              ans = max(ans, sum);
              break;
            }
          }
        }
      }
    }

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

string s, t;
int main() {
  while (cin >> s >> t) {
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
        if (s[i] == t[j] && ans < t.size() - j) {
          int sum = 1;
          for (int k = 1; k < min(s.size() - i, t.size() - j); k++) {
            if (s[i + k] == t[j + k]) {
              sum++;
            } else {
              ans = max(ans, sum);
              if (ans >= s.size() - i) {
                goto goal;
              }
              break;
            }
          }
        }
      }
    }

  goal:

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