Problem p03578 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, s, n) for (int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(), v.end())
#define so(v) sort(v.begin(), v.end())
#define cov(v)                                                                 \
  for (auto i : v)                                                             \
    cout << i << " ";                                                          \
  cout << endl
#define in(n, v)                                                               \
  for (int i = 0; i < (n); i++) {                                              \
    cin >> v[i];                                                               \
  }
#define po(n) cout << (n) << endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<vector<pair<int, int>>> vvp;

int main() {
  int N;
  cin >> N;
  vl D(N);
  in(N, D);
  map<ll, int> A;
  rep(i, N) A[D[i]]++;
  int M;
  cin >> M;
  vl F(N);
  in(M, F);
  bool yes = true;
  rep(i, M) {
    if (A.count(F[i])) {
      if (A[F[i]] > 0)
        A[F[i]]--;
      else {
        yes = false;
        break;
      }
    } else {
      yes = false;
      break;
    }
  }

  if (yes)
    po("YES");
  else
    po("NO");

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, s, n) for (int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(), v.end())
#define so(v) sort(v.begin(), v.end())
#define cov(v)                                                                 \
  for (auto i : v)                                                             \
    cout << i << " ";                                                          \
  cout << endl
#define in(n, v)                                                               \
  for (int i = 0; i < (n); i++) {                                              \
    cin >> v[i];                                                               \
  }
#define po(n) cout << (n) << endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<vector<pair<int, int>>> vvp;

int main() {
  int N;
  cin >> N;
  vl D(N);
  in(N, D);
  map<ll, int> A;
  rep(i, N) A[D[i]]++;
  int M;
  cin >> M;
  vl F(M);
  in(M, F);
  bool yes = true;
  rep(i, M) {
    if (A.count(F[i])) {
      if (A[F[i]] > 0)
        A[F[i]]--;
      else {
        yes = false;
        break;
      }
    } else {
      yes = false;
      break;
    }
  }

  if (yes)
    po("YES");
  else
    po("NO");

  return 0;
}