Problem p02571 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <cmath>
using namespace std;

#define coutv(v)                                                               \
  for (int i = 0; i < (v).size(); ++i)                                         \
    cout << v[i] << ' ';                                                       \
  cout << endl;
#define coutvv(v)                                                              \
  for (int i = 0; i < (v).size(); ++i) {                                       \
    for (int j = 0; j < (v[i]).size(); ++j)                                    \
      cout << v[i][j] << ' ';                                                  \
    cout << endl;                                                              \
  }
#define debugv(v)                                                              \
  {                                                                            \
    for (int i = 0; i < (v).size(); ++i)                                       \
      cerr << v[i] << ' ';                                                     \
    cerr << endl;                                                              \
  }
#define debugvv(v)                                                             \
  {                                                                            \
    for (int i = 0; i < (v).size(); ++i) {                                     \
      for (int j = 0; j < (v[i]).size(); ++j)                                  \
        cerr << v[i][j] << ' ';                                                \
      cerr << endl;                                                            \
    }                                                                          \
  }
#define stringtovector(s, v)                                                   \
  {                                                                            \
    for (int i = 0; i < (s).size(); ++i)                                       \
      v.push_back(s[i]);                                                       \
  };
#define TC                                                                     \
  int TESTCASE;                                                                \
  cin >> TESTCASE;                                                             \
  while (TESTCASE--)
typedef long long ll;
const int mod = 1000000007;

int main() {
  string s;
  string t;
  cin >> s >> t;
  vector<int> c;
  for (int i = 0; i < s.length() - t.length(); i++) {
    c.push_back(0);
    for (int j = 0; j < t.length(); j++) {
      if (s[i + j] != t[j]) {
        c[i] += 1;
      }
    }
  }
  sort(c.begin(), c.end());
  cout << c[0];
}


Fixed submission:
#include <bits/stdc++.h>
#include <cmath>
using namespace std;

#define coutv(v)                                                               \
  for (int i = 0; i < (v).size(); ++i)                                         \
    cout << v[i] << ' ';                                                       \
  cout << endl;
#define coutvv(v)                                                              \
  for (int i = 0; i < (v).size(); ++i) {                                       \
    for (int j = 0; j < (v[i]).size(); ++j)                                    \
      cout << v[i][j] << ' ';                                                  \
    cout << endl;                                                              \
  }
#define debugv(v)                                                              \
  {                                                                            \
    for (int i = 0; i < (v).size(); ++i)                                       \
      cerr << v[i] << ' ';                                                     \
    cerr << endl;                                                              \
  }
#define debugvv(v)                                                             \
  {                                                                            \
    for (int i = 0; i < (v).size(); ++i) {                                     \
      for (int j = 0; j < (v[i]).size(); ++j)                                  \
        cerr << v[i][j] << ' ';                                                \
      cerr << endl;                                                            \
    }                                                                          \
  }
#define stringtovector(s, v)                                                   \
  {                                                                            \
    for (int i = 0; i < (s).size(); ++i)                                       \
      v.push_back(s[i]);                                                       \
  };
#define TC                                                                     \
  int TESTCASE;                                                                \
  cin >> TESTCASE;                                                             \
  while (TESTCASE--)
typedef long long ll;
const int mod = 1000000007;

int main() {
  string s;
  string t;
  cin >> s >> t;
  vector<int> c;
  for (int i = 0; i < s.length() - t.length() + 1; i++) {
    c.push_back(0);
    for (int j = 0; j < t.length(); j++) {
      if (s[i + j] != t[j]) {
        c[i] += 1;
      }
    }
  }
  sort(c.begin(), c.end());
  cout << c[0];
}