alexjercan/bugnet huggingface dataset:
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

#define _USE_MATH_DEFINES // M_PI等のフラグ

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <vector>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

using namespace std;

void solve() {
  string S, T;
  cin >> S >> T;

  int ans = T.size();
  for (int i = 0; i <= S.size() - T.size(); i++) {
    int ret = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S.at(i + j) != T.at(j))
        ret++;
    }
    ans = min(ans, ret);
  }

  cout << ans << endl;
}

int main(int argc, char const *argv[]) {
  solve();
  return 0;
}

Error: 0

Fixed submission:

#define _USE_MATH_DEFINES // M_PI等のフラグ

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <string>
#include <vector>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

using namespace std;

void solve() {
  string S, T;
  cin >> S >> T;

  int ans = T.size();
  for (int i = 0; i < S.size() - T.size() - 1; i++) {
    int ret = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S.at(i + j) != T.at(j))
        ret++;
    }
    ans = min(ans, ret);
  }

  cout << ans << endl;
}

int main(int argc, char const *argv[]) {
  solve();
  return 0;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

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

int dist(string a, string b) {
  int s = 0;
  for (int i = 0; i < a.length(); i++)
    s += (a[i] != b[i]);
  return s;
}

int main() {
  string a, b;
  cin >> a >> b;
  int m = 100000000;
  for (int i = 0; i <= a.length() - b.length(); i++) {
    m = min(m, dist(b, a.substr(i, b.length())));
  }
  cout << m << endl;
}

Error: WA

Fixed submission:

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

int dist(string a, string b) {
  int s = 0;
  for (int i = 0; i < a.length(); i++)
    s += (a[i] == b[i]);
  return s;
}

int main() {
  string a, b;
  cin >> a >> b;
  int m = 100000000;
  for (int i = 0; i + b.length() < a.length(); i++) {
    m = min(m, dist(b, a.substr(i, b.length())));
  }
  return m;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sort(v) sort(v.begin(), v.end())
#define pb push_back
/*
ll ar[1000000+9]={0};
void seiv() {
ll n=1000000,i,j;
ar[1]=1;
for(i=4;i<=n;i+=2)ar[i]=1;
for(i=3;i<=n;i+=2)
{ if(ar[i]==0)
{ for(j=i*i;j<=n;j+=i*2)ar[j]=1; }
 }
}*/
int main() {
  string s, t;
  ll a, b, c, d, i, j, k, l;
  cin >> s >> t;
  l = 11000000000;
  d = 0;
  for (i = 0; i <= s.size() - t.size(); i++) {
    d = 0;
    for (j = 0, k = i; j < t.size(); j++, k++) {
      if (s[k] != t[j])
        d++;
    }
    // cout<<k<<endl;
    l = min(l, d);
  }
  cout << l << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sort(v) sort(v.begin(), v.end())
#define pb push_back
/*
ll ar[1000000+9]={0};
void seiv() {
ll n=1000000,i,j;
ar[1]=1;
for(i=4;i<=n;i+=2)ar[i]=1;
for(i=3;i<=n;i+=2)
{ if(ar[i]==0)
{ for(j=i*i;j<=n;j+=i*2)ar[j]=1; }
 }
}*/
int main() {
  string s, t;
  ll a, b, c, d, i, j, k, l;
  cin >> s >> t;
  l = 11000000000;
  d = 0;
  for (i = 0; i < s.size() - t.size() - 1; i++) {
    d = 0;
    for (j = 0, k = i; j < t.size(); j++, k++) {
      if (s[k] != t[j])
        d++;
    }
    // cout<<k<<endl;
    l = min(l, d);
  }
  cout << l << endl;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t>> Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x)                                                            \\
  Sort(x);                                                                     \\
  reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back(make_pair((a), (b)))

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename V, typename T> bool find_num(V v, T num) {
  if (find(ALL(v), num) == v.end()) {
    return false;
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  string t;
  cin >> t;
  std::vector<int64_t> v;
  if (s.length() == t.length()) {
    if (s == t) {
      cout << 0 << endl;
    } else {
      int64_t ans = 0;
      rep(i, s.length()) {
        if (s[i] != t[i])
          ans++;
      }
      cout << ans << endl;
    }
    return 0;
  }
  rep(i, s.length() - t.length()) {
    // if ( s.at(i) == t.at(i) ) {
    int64_t num = t.length();
    rep(j, t.length()) {
      if (s[i + j] == t[j]) {
        num--;
      }
    }
    v.push_back(num);
    // }
  }
  if (v.empty())
    v.push_back(t.length());
  Sort(v);
  cout << v[0] << endl;
  return 0;
}


Error: 0

Fixed submission:

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t>> Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x)                                                            \\
  Sort(x);                                                                     \\
  reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back(make_pair((a), (b)))

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename V, typename T> bool find_num(V v, T num) {
  if (find(ALL(v), num) == v.end()) {
    return false;
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  string t;
  cin >> t;
  std::vector<int64_t> v;
  if (s.length() == t.length()) {
    if (s == t) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i, s.length() - t.length()) {
    int64_t num = 0;
    rep(j, t.length()) {
      if (s[i + j] != t[j]) {
        num++;
      }
    }
    v.push_back(num);
  }
  cout << *min_element(ALL(v)) << endl;
  return 0;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
using namespace std;
using ll = long long;
int main() {
  string a, b;
  cin >> a >> b;
  int n = a.size(), m = b.size();
  vector<int> c;
  int count = 0;
  if (n == m) {
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        count++;
      }
    }
    cout << count << endl;
    count = 0;
    return 0;
  }
  for (int i = 0; i < n - m + 1; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i + j] != b[j]) {
        count++;
      }
    }
    c.push_back(count);
    count = 0;
  }
  sort(c.begin(), c.end());
  cout << c[0] << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
using namespace std;
using ll = long long;
int main() {
  string a, b;
  cin >> a >> b;
  int n = a.size(), m = b.size();
  vector<int> c;
  int count = 0;
  if (n == m) {
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        count++;
      }
    }
    cout << count << endl;
    count = 0;
  }
  for (int i = 0; i < n - m; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i + j] != b[j]) {
        count++;
      }
    }
    c.push_back(count);
    count = 0;
  }
  sort(c.begin(), c.end());
  cout << c[0] << endl;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int minx = 10000;
  for (int i = 0; i < s.size() - t.size() + 1; i++) {
    int x = 0;
    for (int j = 0; j < t.size(); j++) {
      if (t.at(j) != s.at(i + j)) {
        x += 1;
      }
    }
    minx = min(minx, x);
  }
  cout << minx << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int minx = 1001;
  for (int i = 0; i < s.size() - t.size() - 1; i++) {
    int x = 0;
    for (int j = 0; j < t.size(); j++) {
      if (t.at(j) != s.at(i + j)) {
        x += 1;
      }
    }
    minx = min(minx, x);
  }
  cout << minx << endl;
}
Problem p02571 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int e = s.size();
  int b = t.size();
  int c = 0;
  int m = 0;
  for (int i = 0; i <= e - b; i++) {
    for (int j = 0; j < b; j++) {
      if (t[j] == s[j + i]) {
        c++;
      }
    }
    m = max(m, c);
    c = 0;
  }
  cout << b - m;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int e = s.size();
  int b = t.size();
  int c = 0;
  int m = 0;
  for (int i = 0; i <= e - b; i++) {
    for (int j = 0; j < b; i++) {
      if (t[j] == s[j + i]) {
        c++;
      }
    }
    m = max(m, c);
    c = 0;
  }
  cout << b - m;
}
Problem p02571 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int minimumChar(string S1, string S2) {
  int n = S1.size(), m = S2.size();
  int ans = INT_MAX;
  for (int i = 0; i < m - n + 1; i++) {
    int minRemovedChar = 0;
    for (int j = 0; j < n; j++) {
      if (S1[j] != S2[i + j]) {
        minRemovedChar++;
      }
    }
    ans = min(minRemovedChar, ans);
  }
  return ans;
}
int main() {
  string s, ss;
  cin >> s >> ss;
  cout << minimumChar(ss, s) << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
inline int read() {
  int res = 0;
  bool bo = 0;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    bo = 1;
  else
    res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  return bo ? ~res + 1 : res;
}
const int N = 3e5 + 5;
priority_queue<int> Hea;
int n, m, ecnt, nxt[N], adj[N], go[N], cnt[N], ans[N];
void add_edge(int u, int v) {
  nxt[++ecnt] = adj[u];
  adj[u] = ecnt;
  go[ecnt] = v;
  cnt[v]++;
}
void work() {
  int i, x, y, tot = 0;
  ecnt = 0;
  memset(adj, 0, sizeof(adj));
  memset(cnt, 0, sizeof(cnt));
  n = read();
  m = read();
  bool flag = 0;
  for (i = 1; i <= m; i++) {
    x = read();
    y = read();
    add_edge(y, x);
    if (x == y)
      flag = 1;
  }
  if (flag)
    return (void)puts("Impossible!");
  for (i = 1; i <= n; i++)
    if (!cnt[i])
      Hea.push(i);
  while (!Hea.empty()) {
    int u = Hea.top();
    Hea.pop();
    ans[++tot] = u;
    for (int e = adj[u], v; e; e = nxt[e])
      if (!(--cnt[v = go[e]]))
        Hea.push(v);
  }
  if (tot < n)
    return (void)puts("Impossible!");
  for (i = n; i; i--)
    printf("%d ", ans[i]);
  printf("\\n");
}
int main() {
  int T = read();
  while (T--)
    work();
  return 0;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define LL long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

LL gcd(LL C, LL D) {
  if (C < D)
    gcd(D, C);

  if (C % D == 0)
    return D;
  else
    gcd(D, C % D);
}

int main() {
  string s, t;
  int ans = 0;

  cin >> s >> t;
  for (int i = 0; i < s.length() - t.length() + 1; i++) {
    int cnt = 0;
    rep(j, t.length()) {
      if (s[i + j] == t[j]) {
        cnt++;
      }
    }
    ans = max(ans, cnt);
  }

  cout << t.length() - ans << endl;
  return 0;
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>

#define LL long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

LL gcd(LL C, LL D) {
  if (C < D)
    gcd(D, C);

  if (C % D == 0)
    return D;
  else
    gcd(D, C % D);
}

int main() {
  string s, t;
  int ans = 0;

  cin >> s >> t;
  for (int i = 0; i < s.length() - t.length() + 1; i++) {
    int cnt = 0;
    rep(j, t.length()) {
      if (s[i + j] == t[j]) {
        cnt++;
      }
    }
    ans = max(ans, cnt);
  }

  return t.length() - ans;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
  int i, len, lent, a, j, k, m = 0, saisyou = 10000, c = 0;
  char s[10000];
  char t[10000];
  scanf("%s", s);
  scanf("%s", t);
  len = strlen(s);
  lent = strlen(t);
  a = (len - lent) + 1;

  for (i = 0; i < a; i++) {
    m = i;
    for (j = 0; j < lent; j++) {
      if (s[m] != t[j]) {
        c++;
      }
      m++;
    }
    if (saisyou > c)
      saisyou = c;
    c = 0;
  }
  cout << saisyou << endl;

  return 0;
}


Error: 0

Fixed submission:

// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
  int i, len, lent, a, j, k, m = 0, saisyou = 1000, c = 0;
  char s[10000];
  char t[10000];
  scanf("%s", s);
  scanf("%s", t);
  len = strlen(s);
  lent = strlen(t);
  a = (len - lent) + 1;

  for (i = 0; i < a; i++) {

    for (j = 0; j < lent; j++) {
      if (s[m] != t[j]) {
        c++;
      }
      m++;
    }
    if (saisyou > c)
      saisyou = c;
    c = 0;
  }
  cout << saisyou << endl;

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string s, t;
int check(int tpos, int spos) {
  int ans = 0;
  int tl = tpos + 1;
  int sl = spos + 1;
  while (tpos >= 0) {
    if (s[spos] != t[tpos])
      ans++;
    tpos--;
    spos--;
  }
  while (tl < int(t.size())) {
    if (t[tl] != s[sl])
      ans++;
    tl++;
    sl++;
  }
  return ans;
}
int main() {
  cin >> s >> t;
  vector<int> res;
  set<char> st;
  map<char, int> mp;
  int f = 0;
  for (int i = 0; i < int(t.size()); ++i) {
    mp[t[i]] = i;
  }
  for (char c : t)
    st.insert(c);
  for (int i = 0; i < int(s.size()); ++i) {
    if (st.find(s[i]) != st.end()) {
      if (i >= mp[s[i]] && (s.size() - 1) - i >= ((t.size() - 1) - mp[s[i]])) {
        int temp = check(mp[s[i]], i);
        f = 1;
        res.push_back(temp);
      }
      // else cout << i << "\\n";
    }
  }
  sort(res.begin(), res.end());
  if (f)
    cout << res[0];
  else
    cout << t.size();
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string s, t;
int check(int tpos, int spos) {
  int ans = 0;
  int tl = tpos + 1;
  int sl = spos + 1;
  while (tpos >= 0) {
    if (s[spos] != t[tpos])
      ans++;
    tpos--;
    spos--;
  }
  while (tl < int(t.size())) {
    if (t[tl] != s[sl])
      ans++;
    tl++;
    sl++;
  }
  return ans;
}
int main() {
  cin >> s >> t;
  vector<int> res;
  set<char> st;
  map<char, int> mp;
  for (int i = 0; i < int(t.size()); ++i) {
    mp[t[i]] = i;
  }
  for (char c : t)
    st.insert(c);
  for (int i = 0; i < int(s.size()); ++i) {
    if (st.find(s[i]) != st.end()) {
      if (i >= mp[s[i]] && (s.size() - 1) - i >= ((t.size() - 1) - mp[s[i]])) {
        int temp = check(mp[s[i]], i);
        res.push_back(temp);
      }
      // else cout << i << "\\n";
    }
  }
  sort(res.begin(), res.end());
  cout << res[0];
  return 0;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main() {
  string s, t;
  cin >> s >> t;
  int ans = MOD;
  int temp = 0;
  if (s.size() == t.size()) {
    for (int i = 0; i < s.size(); i++) {
      if (s.at(i) != t.at(i)) {
        temp++;
      }
    }
    ans = temp;
  }
  for (int i = 0; i < (s.size() - t.size()); i++) {
    temp = 0;
    for (int k = 0; k < t.size(); k++) {
      if (s.at(i + k) != t.at(k)) {
        temp++;
      }
    }
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main() {
  string s, t;
  cin >> s >> t;
  int ans = MOD;
  int temp = 0;
  for (int i = 0; i < (s.size() - t.size() - 1); i++) {
    temp = 0;
    for (int k = 0; k < t.size(); k++) {
      if (s.at(i + k) != t.at(k)) {
        temp++;
      }
    }
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a, int b) {
  if (a > b) {
    return a;
  }
  return b;
}
int min(int a, int b) {
  if (a < b) {
    return a;
  }
  return b;
}
int main(void) {
  string s, t;
  cin >> s >> t;
  // cin>>t;
  int y, j;
  int ans = t.size();
  int cnt;
  // cout<<s.at(2)<<endl;
  // int a=s.size()-t.size();
  // cout<<a<<endl;
  rep(i, s.size() - t.size() + 1) {
    cnt = 0;

    // cout<<1<<endl;
    for (j = 0; j < t.size(); ++j) {
      // cout<<1<<endl;
      y = i + j;
      if (t.at(j) != s.at(y)) {
        cnt++;
      }
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 6) >= this->size() (which is 6)


Fixed submission:

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a, int b) {
  if (a > b) {
    return a;
  }
  return b;
}
int min(int a, int b) {
  if (a < b) {
    return a;
  }
  return b;
}
int main(void) {
  string s, t;
  cin >> s >> t;
  // cin>>t;
  int ans, y;
  ans = 1020;
  int cnt;
  // cout<<s.at(2)<<endl;
  // int a=s.size()-t.size();
  // cout<<a<<endl;
  rep(i, s.size()) {
    cnt = 0;
    // cout<<1<<endl;
    rep(j, t.size()) {
      y = i + j;
      if (s.at(y) != t.at(j)) {
        cnt++;
      }
      ans = min(ans, cnt);
    }
  }
  cout << ans << endl;
}
Problem p02571 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  string S, T;
  cin >> S >> T;
  int ans = T.size();
  int s = S.size();
  int t = T.size();
  for (int i = 0; i <= s - t; i++) {
    int d = 0;
    for (int j = 0; j < t; j++) {
      if (S[i + j] != T[j]) {
        d++;
      }
    }
    ans = min(ans, d);
  }
  cout << ans;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string S, T;
  cin >> S >> T;
  int ans = T.size();
  int s = S.size();
  int t = T.size();
  for (int i = 0; i <= s - t; i++) {
    int d = 0;
    for (int j = 0; j < t; i++) {
      if (S[i + j] != T[j]) {
        d++;
      }
    }
    ans = min(ans, d);
  }
  cout << ans;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

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

ll gcd(ll a, ll b) {
  if (b > a)
    swap(a, b);
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
ll rep_jijo(ll n, ll x) {
  if (x == 0)
    return 1;
  if (x % 2 == 0) {
    ll t = rep_jijo(n, x / 2);
    return t * t % mod;
  }
  return n * rep_jijo(n, x - 1) % mod;
}
ll c2(ll n) { return n * (n - 1) / 2; }
int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size() - t.size();
  int ts = t.size();

  vector<int> a(n + 1);
  for (int i = 0; i < ts; i++) {
    for (int j = 0; j <= n; j++) {
      if (s[i + j] != t[i]) {
        a[j]++;
      }
    }
  }
  if (n == 0) {
    cout << a[0] << endl;
    return 0;
  }
  rep(i, n) {
    if (a[i] < a[i + 1])
      a[i + 1] = a[i];
  }
  cout << a[n - 1] << endl;
}


Error: 0

Fixed submission:

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

ll gcd(ll a, ll b) {
  if (b > a)
    swap(a, b);
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
ll rep_jijo(ll n, ll x) {
  if (x == 0)
    return 1;
  if (x % 2 == 0) {
    ll t = rep_jijo(n, x / 2);
    return t * t % mod;
  }
  return n * rep_jijo(n, x - 1) % mod;
}
ll c2(ll n) { return n * (n - 1) / 2; }
int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size() - t.size();
  int ts = t.size();
  vector<int> a(n);
  for (int i = 0; i < ts; i++) {
    for (int j = 0; j <= n; j++) {
      if (s[i + j] == t[i]) {
        a[j]++;
      }
    }
  }
  if (n == 0) {
    cout << ts - a[0] << endl;
    return 0;
  }
  rep(i, n - 1) {
    if (a[i] > a[i + 1])
      a[i + 1] = a[i];
  }
  cout << ts - a[n - 1] << endl;
}
Problem p02571 (C++) — buggy submission, verdict: Runtime Error

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

void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main() {
  boost();
  string s1, s2;
  cin >> s1 >> s2;

  ll n = s1.length(), m = s2.length();
  ll i, j;
  vector<ll> v;
  for (i = 0; i <= n - m; i++) {
    ll count = 0, k = 0;
    for (j = i; j < i + m; j++) {
      if (s1[j] != s2[k])
        count++;
      k++;
    }
    // cout << j << endl;
    // cout << s1[i] << endl;
    v.push_back(count);
  }
  sort(v.begin(), v.end());
  cout << v[0] << endl;
}

Error: 0

Fixed submission:

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

void boost() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main() {
  boost();
  string s1, s2;
  cin >> s1 >> s2;

  ll n = s1.length(), m = s2.length();
  ll i, j;
  vector<ll> v;
  for (i = 0; i < n - m; i++) {
    ll count = 0, k = 0;
    for (j = i; j < i + m; j++) {
      if (s1[j] != s2[k])
        count++;
      k++;
    }
    v.push_back(count);
  }
  sort(v.begin(), v.end());
  cout << v[0] << endl;
}