prithivMLmods/Coder-Stat huggingface dataset:
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> N(n), M(m);
  rep(i, n) cin >> N[i];
  rep(i, m) cin >> M[i];

  // nから切り出し→比較まで
  for (int i = 0; i <= n - m + 1; i++) {
    for (int j = 0; j <= n - m + 1; j++) {
      // 以降のforで比較フェイズ
      int ok = 1;
      rep(k, m) {
        string tmp = N[i + k].substr(j, m);
        if (tmp != M[k])
          ok = 0;
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> N(n), M(m);
  rep(i, n) cin >> N[i];
  rep(i, m) cin >> M[i];

  // nから切り出し→比較まで
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      // 以降のforで比較フェイズ
      int ok = 1;
      rep(k, m) {
        string tmp = N[i + k].substr(j, m);
        if (tmp != M[k])
          ok = 0;
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

  int n, m;
  cin >> n >> m;

  vector<string> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  vector<string> b(m);
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }

  bool ans;

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

      for (int k = 0; k < m; ++k) {
        for (int l = 0; l < m; ++l) {
          if (a[i + k][j + l] != b[k][l]) {
            ans = false;
          }
        }
      }

      if (ans) {
        puts("Yes");
        return 0;
      }
    }
  }

  puts("No");
}

Fixed submission:
#include <bits/stdc++.h>

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

  int n, m;
  cin >> n >> m;

  vector<string> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  vector<string> b(m);
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }

  bool ans;

  for (int i = 0; i < n - m + 1; ++i) {
    for (int j = 0; j < n - m + 1; ++j) {
      ans = true;

      for (int k = 0; k < m; ++k) {
        for (int l = 0; l < m; ++l) {
          if (a[i + k][j + l] != b[k][l]) {
            ans = false;
          }
        }
      }

      if (ans) {
        puts("Yes");
        return 0;
      }
    }
  }

  puts("No");
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, 1, 0, -1};

int main() {

  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i, n) cin >> a.at(i);
  rep(i, m) cin >> b.at(i);

  bool ans = false;

  rep(i, n) {
    rep(j, n) {
      int x = i;
      int y = j;
      int cnt = 0;
      rep(k, m) {
        rep(l, m) {
          if (a.at(x + k).at(y + l) == b.at(k).at(l)) {
            cnt++;
          } else {
            break;
          }
        }
      }
      if (cnt == m * m) {
        ans = true;
        break;
      }
    }
    if (ans)
      break;
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, 1, 0, -1};

int main() {

  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i, n) cin >> a.at(i);
  rep(i, m) cin >> b.at(i);

  bool ans = false;

  rep(i, n - (m - 1)) {
    rep(j, n - (m - 1)) {
      int x = i;
      int y = j;
      int cnt = 0;
      rep(k, m) {
        rep(l, m) {
          if (a.at(x + k).at(y + l) == b.at(k).at(l)) {
            cnt++;
          } else {
            break;
          }
        }
      }
      if (cnt == m * m) {
        ans = true;
        break;
      }
    }
    if (ans)
      break;
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (ll i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (ll i = 0; i < n - m + 1; i++) {
    for (ll j = 0; j < n - m + 1; j++) {
      bool flag = true;
      for (ll k = j; k < j + m; k++) {
        if (a[k].substr(i, m) != b[k]) {
          flag = false;
        }
      }
      if (flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (ll i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (ll i = 0; i < n - m + 1; i++) {
    for (ll j = 0; j < n - m + 1; j++) {
      bool flag = true;
      for (ll k = j; k < j + m; k++) {
        if (a[k].substr(i, m) != b[k - j]) {
          flag = false;
        }
      }
      if (flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int n, m;
vector<string> A, B;

bool match_temp(int w, int h) {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (A[h + i][w + j] != B[i][j]) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  for (int i = 0; i < m; i++) {
    string tmp;
    cin >> tmp;
    B.push_back(tmp);
  }

  bool flg = false;
  for (int h = 0; h < n - m + 1; h++) { // vertical search
    size_t Pos = A[h].find(B[h]);
    if (Pos == string::npos) {
      continue;
    }
    for (int w = 0; w < n - m + 1; w++) { // horizontal search
      if (match_temp(w, h)) {
        flg = true;
      }
      if (flg) {
        break;
      }
    }
  }
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int n, m;
vector<string> A, B;

bool match_temp(int w, int h) {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (A[h + i][w + j] != B[i][j]) {
        return false;
      }
    }
  }
  return true;
}

int main() {
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    A.push_back(tmp);
  }
  for (int i = 0; i < m; i++) {
    string tmp;
    cin >> tmp;
    B.push_back(tmp);
  }

  bool flg = false;
  for (int h = 0; h < n - m + 1; h++) {   // vertical search
                                          /*
                                              size_t Pos = A[h].find(B[h]);
                                              if(Pos == string::npos){
                                                cout << "npos: " << h << endl;
                                                continue;
                                              }
                                              */
    for (int w = 0; w < n - m + 1; w++) { // horizontal search
      if (match_temp(w, h)) {
        flg = true;
      }
      if (flg) {
        break;
      }
    }
  }
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define int long long
#define double long double
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int, vector<int>, greater<int>>
#define PriP                                                                   \
  priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a) (a).begin(), (a).end()

signed main() {
  int n, m;
  cin >> n >> m;
  V<string> a(n);
  fo(i, n) { cin >> a[i]; }
  V<string> b(m);
  fo(i, m) { cin >> b[i]; }

  bool can = 0;

  for (int x = 0; x <= n - m + 1; x++) {
    for (int y = 0; y <= n - m + 1; y++) {
      bool c = 1;
      fo(i, m) {
        fo(j, m) {
          if (a[x + i][y + j] != b[i][j])
            c = 0;
        }
      }
      if (c)
        can = 1;
    }
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define int long long
#define double long double
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int, vector<int>, greater<int>>
#define PriP                                                                   \
  priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a) (a).begin(), (a).end()

signed main() {
  int n, m;
  cin >> n >> m;
  V<string> a(n);
  fo(i, n) { cin >> a[i]; }
  V<string> b(m);
  fo(i, m) { cin >> b[i]; }

  bool can = 0;

  for (int x = 0; x < n - m + 1; x++) {
    for (int y = 0; y < n - m + 1; y++) {
      bool c = 1;
      fo(i, m) {
        fo(j, m) {
          if (a[x + i][y + j] != b[i][j])
            c = 0;
        }
      }
      if (c)
        can = 1;
    }
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  rep(i, n - m + 1) {
    rep(j, n - m + 1) {
      bool flag = true;
      rep(k, m) {
        if (a[i + k].substr(j, m) != b[i + k]) {
          flag = false;
        }
      }
      if (flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  rep(i, n - m + 1) {
    rep(j, n - m + 1) {
      bool flag = true;
      rep(k, m) {
        if (a[i + k].substr(j, m) != b[k]) {
          flag = false;
        }
      }
      if (flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
  int i, j, s, t, n, m;
  cin >> n;
  cin >> m;
  char picturea[n][n];
  char pictureb[m][m];
  for (i = 0; i < n; i++)
    scanf("%s", picturea[i]);
  for (i = 0; i < m; i++)
    scanf("%s", pictureb[i]);

  /*for(i=0;i<n;i++){
      for(j=0;j<n;j++){
          printf("%c",picturea[i][j]);
      }
      printf("\n");
  }
  for(i=0;i<m;i++){
      for(j=0;j<m;j++){
          printf("%c",pictureb[i][j]);
      }
      printf("\n");
  }*/
  int k = n - m; // k=1
  int ct = 0;
  int hantei = 0;

  for (s = 0; s <= k; s++) {   // 0~1
    for (t = 0; t <= k; t++) { // 0~1
      ct = 0;
      for (i = 0; i < m; i++) { // s=0 0~1 s=1 1~2
        for (j = 0; j < m; j++) {
          if (picturea[i + s][j + t] != pictureb[i][j])
            ct++;
        }
      }
      if (ct == 0)
        hantei = 1;
    }
  }
  if (hantei == 0)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}

Fixed submission:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
  int i, j, s, t, n, m;
  cin >> n;
  cin >> m;
  char picturea[n][n];
  char pictureb[m][m];
  for (i = 0; i < n; i++)
    scanf("%s", picturea[i]);
  for (i = 0; i < m; i++)
    scanf("%s", pictureb[i]);

  /*for(i=0;i<n;i++){
      for(j=0;j<n;j++){
          printf("%c",picturea[i][j]);
      }
      printf("\n");
  }
  for(i=0;i<m;i++){
      for(j=0;j<m;j++){
          printf("%c",pictureb[i][j]);
      }
      printf("\n");
  }*/
  int k = n - m; // k=1
  int ct = 0;
  int hantei = 0;

  for (s = 0; s <= k; s++) {   // 0~1
    for (t = 0; t <= k; t++) { // 0~1
      ct = 0;
      if (picturea[s][t] != pictureb[0][0])
        ct = 1;

      if (picturea[s][t] == pictureb[0][0]) {
        for (i = 0; i < m; i++) { // s=0 0~1 s=1 1~2
          for (j = 0; j < m; j++) {
            if (picturea[i + s][j + t] != pictureb[i][j])
              ct++;
          }
        }
      }
      if (ct == 0)
        hantei = 1;
    }
  }
  if (hantei == 0)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;
}
Problem p03804 (C++)

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

signed main() {
  int N, M;
  cin >> N >> M;

  vector<string> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  vector<string> B(M);
  for (int i = 0; i < M; i++)
    cin >> B.at(i);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {

      bool hantei = true;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A.at(i + k).at(j + l) != B.at(k).at(l))
            hantei = false;
        }
      }
      if (hantei == true) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

signed main() {
  int N, M;
  cin >> N >> M;

  vector<string> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  vector<string> B(M);
  for (int i = 0; i < M; i++)
    cin >> B.at(i);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {

      bool hantei = true;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (i + k >= N || j + l >= N) {
            hantei = false;
            break;
          }
          if (A.at(i + k).at(j + l) != B.at(k).at(l))
            hantei = false;
        }
      }
      if (hantei == true) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  char a[50][50], b[50][50];

  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (int j = 0; j < M; j++) {
    cin >> b[j];
  }

  for (int i = 0; i <= N - M + 1; i++) {
    for (int j = 0; j <= N - M + 1; j++) {
      int count = 0;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (a[i + k][j + l] == b[k][l])
            count += 1;
        }
      }

      if (count == M * M) {
        cout << "Yes" << endl;
        return 1;
      }
    }
  }
  cout << "No" << endl;
}

Fixed submission:
#include <iostream>
using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  char a[50][50], b[50][50];

  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  for (int j = 0; j < M; j++) {
    cin >> b[j];
  }

  for (int i = 0; i <= N - M + 1; i++) {
    for (int j = 0; j <= N - M + 1; j++) {
      int count = 0;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (a[i + k][j + l] == b[k][l])
            count += 1;
        }
      }

      if (count == M * M) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int divCeil(int A, int B) { return (A + (B - 1)) / B; }
long long divCeil(long long A, int B) { return (A + (B - 1)) / B; }
long long divCeil(int A, long long B) { return (A + (B - 1)) / B; }
long long divCeil(long long A, long long B) { return (A + (B - 1)) / B; }

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  for (int i = 0; i < M; i++)
    cin >> B.at(i);

  string ans = "No";
  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N; j++) {
      bool flg = true;
      for (int k = 0; k < M; k++) {
        string S = (A.at(j + k).substr(i, M));
        if (S != B.at(k)) {
          flg = false;
          break;
        }
      }
      if (flg) {
        ans = "Yes";
        break;
      }
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int divCeil(int A, int B) { return (A + (B - 1)) / B; }
long long divCeil(long long A, int B) { return (A + (B - 1)) / B; }
long long divCeil(int A, long long B) { return (A + (B - 1)) / B; }
long long divCeil(long long A, long long B) { return (A + (B - 1)) / B; }

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  for (int i = 0; i < M; i++)
    cin >> B.at(i);

  string ans = "No";
  for (int i = 0; i < N - M + 1; i++) {
    for (int j = 0; j < N - M + 1; j++) {
      bool flg = true;
      for (int k = 0; k < M; k++) {
        string S = (A.at(j + k).substr(i, M));
        if (S != B.at(k)) {
          flg = false;
          break;
        }
      }
      if (flg) {
        ans = "Yes";
        break;
      }
    }
  }

  cout << ans << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9 + 7)

int main() {
  int a, b;
  cin >> a >> b;
  string s[a][a], t[b][b];
  rep(i, a) rep(j, a) cin >> s[i][j];
  rep(i, b) rep(j, b) cin >> t[i][j];
  rep(i, a) { // sの左上
    rep(j, a) {
      int c = 0;
      rep(k, b) {
        rep(l, b) {
          if (s[i + k][j + l] == t[k][l])
            c++;
        }
      }
      if (c == b * b) {
        out("Yes");
        return 0;
      }
    }
  }
  out("No");
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9 + 7)

int main() {
  int a, b;
  cin >> a >> b;
  char s[a][a], t[b][b];
  rep(i, a) rep(j, a) cin >> s[i][j];
  rep(i, b) rep(j, b) cin >> t[i][j];
  rep(i, a) { // sの左上
    rep(j, a) {
      int c = 0;
      rep(k, b) {
        rep(l, b) {
          if (s[i + k][j + l] == t[k][l])
            c++;
        }
      }
      if (c == b * b) {
        out("Yes");
        return 0;
      }
    }
  }
  out("No");
}
Problem p03804 (C++)

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

int main() {
  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; i <= n - m; j++) {
      bool contains = true;
      for (int k = 0; k < m; k++) {
        for (int l = 0; l < m; l++) {
          if (a[i + k][j + l] != b[k][l]) {
            contains = false;
          }
        }
      }
      if (contains) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      bool contains = true;
      for (int k = 0; k < m; k++) {
        for (int l = 0; l < m; l++) {
          if (a[i + k][j + l] != b[k][l]) {
            contains = false;
          }
        }
      }
      if (contains) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}
Problem p03804 (C++)

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int char_to_int(char val) { return val - '0'; }
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  } else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  REP(i, N) cin >> A[i];
  vector<string> B(M);
  REP(i, M) cin >> B[i];
  string ans = "No";
  REP(i, N - 1) {
    REP(j, N - 1) {
      bool flag = true;
      REP(k, M) {
        REP(m, M) {
          if (A[i + k][j + m] != B[k][m]) {
            flag = false;
            break;
          }
          if (k == M - 1 && m == M - 1 && flag == true)
            ans = "Yes";
        }
      }
    }
  }
  cout << ans << endl;
}

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int char_to_int(char val) { return val - '0'; }
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  } else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  REP(i, N) cin >> A[i];
  vector<string> B(M);
  REP(i, M) cin >> B[i];
  string ans = "No";
  REP(i, N - M + 1) {
    REP(j, N - M + 1) {
      bool flag = true;
      REP(k, M) {
        REP(m, M) {
          if (A[i + k][j + m] != B[k][m]) {
            flag = false;
            break;
          }
          if (k == M - 1 && m == M - 1 && flag == true)
            ans = "Yes";
        }
      }
    }
  }
  cout << ans << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                                             \
  ifstream in("atcoder-problems/abc054_b.txt");                                \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE                                                           \
  cin.tie(0);                                                                  \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  vector<string> a(N);
  vector<string> b(M);
  rep(i, N) { cin >> a[i]; }
  rep(i, M) { cin >> b[i]; }

  rep(i, N - M + 1) {
    rep(j, N - M + 1) {
      bool ok = true;
      rep(l, M) {
        string ai = a[i + l].substr(j, M);
        string bi = b[i + l];
        ok &= ai == bi;
        if (!ok)
          break;
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                                             \
  ifstream in("atcoder-problems/abc054_b.txt");                                \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE                                                           \
  cin.tie(0);                                                                  \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  vector<string> a(N);
  vector<string> b(M);
  rep(i, N) { cin >> a[i]; }
  rep(i, M) { cin >> b[i]; }

  rep(i, N - M + 1) {
    rep(j, N - M + 1) {
      bool ok = true;
      rep(l, M) {
        string ai = a[i + l].substr(j, M);
        string bi = b[l];
        ok &= ai == bi;
        if (!ok)
          break;
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}
Problem p03804 (C++)

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<std::string> A,
           std::vector<std::string> B) {
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      long long cnt = 0;
      for (long long k = 0; k < M; k++) {
        for (long long l = 0; l < M; l++) {
          if (B[k][l] == A[i + k][j + l]) {
            cnt++;
          }
        }
      }
      if (cnt == M * M) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<std::string> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  std::vector<std::string> B(M);
  for (int i = 0; i < M; i++) {
    std::cin >> B[i];
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<std::string> A,
           std::vector<std::string> B) {
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      long long cnt = 0;
      for (long long k = 0; k < M; k++) {
        for (long long l = 0; l < M; l++) {
          if (i + k >= N || j + l >= N) {
            continue;
          }
          if (B[k][l] == A[i + k][j + l]) {
            cnt++;
          }
        }
      }
      if (cnt == M * M) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<std::string> A(N);
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
  }
  std::vector<std::string> B(M);
  for (int i = 0; i < M; i++) {
    std::cin >> B[i];
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  rep(i, N) cin >> A[i];
  vector<string> B(M);
  rep(i, M) cin >> B[i];

  int m = N - M + 1;
  rep(i, m) {
    rep(j, m) {
      bool flag = true;
      rep(k, M) {
        if (A[i + k].substr(j, M) != B[i + k]) {
          flag = false;
        }
      }
      if (flag) {
        yes;
        return 0;
      }
    }
  }

  no;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  rep(i, N) cin >> A[i];
  vector<string> B(M);
  rep(i, M) cin >> B[i];

  int m = N - M + 1;
  rep(i, m) {
    rep(j, m) {
      bool flag = true;
      rep(k, M) {
        if (A[i + k].substr(j, M) != B[k]) {
          flag = false;
        }
      }
      if (flag) {
        yes;
        return 0;
      }
    }
  }

  no;
  return 0;
}
Problem p03804 (C++)

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

int main(void) {
  int N, M;
  cin >> N >> M;
  string A[N], B[M];

  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < M; i++)
    cin >> B[i];
  bool ans = false;

  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      bool eq = true;
      for (int k = 0; k < M; k++) {
        string sub = A[i + k].substr(j, M);
        if (sub != B[i + k]) {
          eq = false;
          break;
        }
      }
      if (eq) {
        ans = true;
        break;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

int main(void) {
  int N, M;
  cin >> N >> M;
  string A[N], B[M];

  for (int i = 0; i < N; i++)
    cin >> A[i];
  for (int i = 0; i < M; i++)
    cin >> B[i];
  bool ans = false;

  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      bool eq = true;
      for (int k = 0; k < M; k++) {
        string sub = A[i + k].substr(j, M);
        if (sub != B[k]) {
          eq = false;
          break;
        }
      }
      if (eq) {
        ans = true;
        break;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  char arr[n][n];
  char arr1[m][m];
  for (int i = 0; i < n; i++)
    scanf("%s", arr[i]);
  for (int i = 0; i < m; i++)
    scanf("%s", arr1[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int cnt = 0;
      for (int a = 0; a < m; a++) {
        for (int b = 0; b < m; b++) {
          if (arr1[a][b] == arr[i + a][j + b])
            cnt++;
        }
      }
      if (cnt == (m * m)) {
        return (cout << "Yes", 0);
      }
    }
  }
  printf("No\n");
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  char arr[n][n];
  char arr1[m][m];
  for (int i = 0; i < n; i++)
    scanf("%s", arr[i]);
  for (int i = 0; i < m; i++)
    scanf("%s", arr1[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int cnt = 0;
      for (int a = 0; a < m; a++) {
        for (int b = 0; b < m; b++) {
          if (arr1[a][b] == arr[i + a][j + b])
            cnt++;
        }
      }
      if (cnt == (m * m)) {
        return (cout << "Yes", 0);
      }
    }
  }
  printf("No\n");
  return 0;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#define ll long long

using namespace std;

bool solve(vector<string> &A, int N, vector<string> &B, int M, int i, int j) {
  for (int k = 0; k < M; k++) {
    for (int g = 0; g < M; g++) {
      if (A[i + k][j + g] == B[k][g]) {
        continue;
      } else {
        return false;
      }
    }
  }
  return true;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  for (auto &a : A) {
    cin >> a;
  }
  vector<string> B(M);
  for (auto &b : B) {
    cin >> b;
  }
  bool ans = false;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[i][j] == B[0][0]) {
        ans = solve(A, N, B, M, i, j);
        if (ans)
          break;
      }
    }
    if (ans)
      break;
  }

  cout << (ans ? "Yes" : "No") << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#define ll long long

using namespace std;

bool solve(vector<string> &A, int N, vector<string> &B, int M, int i, int j) {
  for (int k = 0; k < M; k++) {
    for (int g = 0; g < M; g++) {
      if (i + k >= N || j + g >= N) {
        return false;
      }
      if (A[i + k][j + g] == B[k][g]) {
        continue;
      } else {
        return false;
      }
    }
  }
  return true;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  for (auto &a : A) {
    cin >> a;
  }
  vector<string> B(M);
  for (auto &b : B) {
    cin >> b;
  }
  bool ans = false;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[i][j] == B[0][0]) {
        ans = solve(A, N, B, M, i, j);
        if (ans)
          break;
      }
    }
    if (ans)
      break;
  }

  cout << (ans ? "Yes" : "No") << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL << 60;
const int MOD = (int)1e9 + 7;

signed main() {
  int n, m;
  cin >> n >> m;
  vector<string> va(n);
  vector<string> vb(m);
  for (int i = 0; i < n; i++) {
    cin >> va[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> vb[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (va[i][j] == vb[0][0]) {
        bool flag = true;
        for (int I = 0; I < m; I++) {
          for (int J = 0; J < m; J++) {
            if (i + I >= n || j + J >= n)
              flag = false;
            if (va[i + I][j + J] != vb[I][J])
              flag = false;
          }
        }
        if (flag) {
          cout << "Yes"
               << "\n";
          return 0;
        }
      }
    }
  }
  cout << "No"
       << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL << 60;
const int MOD = (int)1e9 + 7;

signed main() {
  int n, m;
  cin >> n >> m;
  vector<string> va(n);
  vector<string> vb(m);
  for (int i = 0; i < n; i++) {
    cin >> va[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> vb[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (va[i][j] == vb[0][0]) {
        bool flag = true;
        for (int I = 0; I < m; I++) {
          for (int J = 0; J < m; J++) {
            if (i + I >= n || j + J >= n)
              flag = false;
            else if (va[i + I][j + J] != vb[I][J])
              flag = false;
          }
        }
        if (flag) {
          cout << "Yes"
               << "\n";
          return 0;
        }
      }
    }
  }
  cout << "No"
       << "\n";
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

bool IncludeImage(const vector<string> &a, const vector<string> &b) {
  const int n = a.size();
  const int m = b.size();

  for (int i = 0; i + m <= n; ++i) {
    for (int j = 0; j + m <= n; ++j) {
      bool in_image = true;

      for (int k = 0; k < m; ++k) {
        if (a[i + k].substr(j, m) != b[i + k]) {
          in_image = false;
          break;
        }
      }

      if (in_image)
        return true;
    }
  }

  return false;
}

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

  int n, m;

  cin >> n >> m;

  vector<string> a(n), b(m);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  for (int i = 0; i < m; ++i)
    cin >> b[i];

  if (IncludeImage(a, b))
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

bool IncludeImage(const vector<string> &a, const vector<string> &b) {
  const int n = a.size();
  const int m = b.size();

  for (int i = 0; i + m <= n; ++i) {
    for (int j = 0; j + m <= n; ++j) {
      bool in_image = true;

      for (int k = 0; k < m; ++k) {
        if (a[i + k].substr(j, m) != b[k]) {
          in_image = false;
          break;
        }
      }

      if (in_image)
        return true;
    }
  }

  return false;
}

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

  int n, m;

  cin >> n >> m;

  vector<string> a(n), b(m);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  for (int i = 0; i < m; ++i)
    cin >> b[i];

  if (IncludeImage(a, b))
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (i = 0; i < n; i++)
#define loop(i, a, n) for (i = a; i < n; i++)
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)

typedef vector<int> vi;
typedef pair<int, int> pii;

int main(void) {
  int i, j, k;
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  int ans = 0;
  rep(i, n - m + 1) rep(j, n - m + 1) {
    bool tmp = true;
    rep(k, m) if (b[j + k] != a[j + k].substr(i, m)) tmp = false;
    if (tmp)
      ans = 1;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (i = 0; i < n; i++)
#define loop(i, a, n) for (i = a; i < n; i++)
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)

typedef vector<int> vi;
typedef pair<int, int> pii;

int main(void) {
  int i, j, k;
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  int ans = 0;
  rep(i, n - m + 1) rep(j, n - m + 1) {
    bool tmp = true;
    rep(k, m) if (b[k] != a[j + k].substr(i, m)) tmp = false;
    if (tmp)
      ans = 1;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03804 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::string A[N], B[M];
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    std::cin >> B[i];
  }

  bool exist = false;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (j + M - 1 >= N || i + M - 1 >= N)
        continue;
      bool match = true;
      for (int ii = 0; ii < M; ++ii) {
        for (int jj = 0; j < M; ++jj) {
          if (A[i + ii][j + jj] != B[ii][jj])
            match = false;
        }
      }
      if (match)
        exist = true;
    }
  }
  if (exist)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


Fixed submission:
#include <iostream>
#include <string>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::string A[N], B[M];
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    std::cin >> B[i];
  }

  bool exist = false;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (j + M - 1 >= N || i + M - 1 >= N)
        continue;
      bool match = true;
      for (int ii = 0; ii < M; ++ii) {
        for (int jj = 0; jj < M; ++jj) {
          if (A[i + ii][j + jj] != B[ii][jj])
            match = false;
        }
      }
      if (match)
        exist = true;
    }
  }
  if (exist)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}
Problem p03805 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


# See:
# https://atcoder.jp/img/abc054/editorial.pdf
def dfs(v):
    all_visited = True

    if False in visited:
        all_visited = False

    if all_visited:
        return 1

    count = 0

    for i in range(n):
        if graph[v][i] == 0:
            continue

        if visited[i]:
            continue

        visited[i] = True
        count += dfs(i)
        visited[i] = False
    return count


if __name__ == "__main__":
    n, m = list(map(int, input().split()))
    graph = [[0 for __ in range(m)] for _ in range(m)]

    for i in range(m):
        a, b = list(map(lambda x: int(x) - 1, input().split()))
        graph[a][b] = 1
        graph[b][a] = 1

    visited = [False] * n
    visited[0] = True

    print(dfs(0))


Fixed submission:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


# See:
# https://atcoder.jp/img/abc054/editorial.pdf
def dfs(v):
    all_visited = True

    if False in visited:
        all_visited = False

    if all_visited:
        return 1

    count = 0

    for i in range(n):
        if graph[v][i] == 0:
            continue

        if visited[i]:
            continue

        visited[i] = True
        count += dfs(i)
        visited[i] = False
    return count


if __name__ == "__main__":
    n, m = list(map(int, input().split()))
    graph = [[0 for __ in range(n)] for _ in range(n)]

    for i in range(m):
        a, b = list(map(lambda x: int(x) - 1, input().split()))
        graph[a][b] = 1
        graph[b][a] = 1

    visited = [False] * n
    visited[0] = True

    print(dfs(0))