Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

const double PI = 3.14159265358979;
/******変数定義start******/
ll n, m;
vector<string> a, b;
/*******変数定義end*******/

ll solve() {
  cin >> n >> m;
  a.resize(n);
  b.resize(m);
  REP(i, n) { cin >> a[i]; }
  REP(i, m) { cin >> b[i]; }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n - m; j++) {
      if (a[i].substr(j, m) == b[0]) {
        ll count = 0;
        for (ll k = 0; k < m; k++) {
          if (a[i + k].substr(j, m) == b[k]) {
            count++;
          }
        }
        if (count == m) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}
int main() {

  // clock_t start = clock();
  cout << std::fixed << std::setprecision(10);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll end = solve();
  /*
  clock_t end = clock();
  const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
  1000.0; printf("time %lf[ms]\n", time);
  */
  return end;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

const double PI = 3.14159265358979;
/******変数定義start******/
ll n, m;
vector<string> a, b;
/*******変数定義end*******/

ll solve() {
  cin >> n >> m;
  a.resize(n);
  b.resize(m);
  REP(i, n) { cin >> a[i]; }
  REP(i, m) { cin >> b[i]; }
  for (ll i = 0; i < n - m + 1; i++) {
    for (ll j = 0; j < n - m + 1; j++) {
      if (a[i].substr(j, m) == b[0]) {
        ll count = 0;
        for (ll k = 0; k < m; k++) {
          if (a[i + k].substr(j, m) == b[k]) {
            count++;
          }
        }
        if (count == m) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}
int main() {

  // clock_t start = clock();
  cout << std::fixed << std::setprecision(10);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll end = solve();
  /*
  clock_t end = clock();
  const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
  1000.0; printf("time %lf[ms]\n", time);
  */
  return end;
}