Problem p03720 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>

#define REP(i, x) for (int i{0}; i < (int)(x); i++)
#define REPC(i, x) for (int i{0}; i <= (int)(x); i++)
#define RREP(i, x) for (int i{(int)(x)-1}; i >= 0; i--)
#define RREPC(i, x) for (int i{(int)(x)}; i >= 0; i--)
#define REP1O(i, x) for (int i{1}; i < (int)(x); i++)
#define REP1C(i, x) for (int i{1}; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
inline void swap(ll &a, ll &b) {
  a ^= b;
  b ^= a;
  a ^= b;
}
inline void swap(int &a, int &b) {
  a ^= b;
  b ^= a;
  a ^= b;
}

vi c;
int n, m;

int main() {
  cin >> n >> m;
  c.resize(n, 0);

  REP(i, n) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    ++c[a];
    ++c[b];
  }

  REP(i, n)
  cout << c[i] << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>

#define REP(i, x) for (int i{0}; i < (int)(x); i++)
#define REPC(i, x) for (int i{0}; i <= (int)(x); i++)
#define RREP(i, x) for (int i{(int)(x)-1}; i >= 0; i--)
#define RREPC(i, x) for (int i{(int)(x)}; i >= 0; i--)
#define REP1O(i, x) for (int i{1}; i < (int)(x); i++)
#define REP1C(i, x) for (int i{1}; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
inline void swap(ll &a, ll &b) {
  a ^= b;
  b ^= a;
  a ^= b;
}
inline void swap(int &a, int &b) {
  a ^= b;
  b ^= a;
  a ^= b;
}

vi c;
int n, m;

int main() {
  cin >> n >> m;
  c.resize(n, 0);

  REP(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    ++c[a];
    ++c[b];
  }

  REP(i, n)
  cout << c[i] << endl;
}