Problem p03637 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define REP(i, n) FOR(i, 0, (n))
#define REPS(i, n) FOR(i, 1, (n) + 1)
#define RREP(i, n) RFOR(i, 0, (n))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x), 0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1 << x) - 1)
#define DUP(x, y) (((x) + (y)-1) / (y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9 + 7;
const int INF = (1 << 30) - 1;
const ll INFLL = (1LL << 62) - 1;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// cout << fixed << setprecision(10);

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int cnt_div2(int a) {
  int cnt = 0;
  while (a % 2 == 0) {
    a /= 2;
    cnt++;
  }
  return cnt;
}

int main() {
  int N;
  cin >> N;
  vi a(N);
  REP(i, N) printf("%d", &a[i]);

  int cnt_2 = 0;
  int cnt_4 = 0;
  REP(i, N) {
    if (cnt_div2(a[i]) == 1) {
      cnt_2++;
    } else if (cnt_div2(a[i]) >= 2) {
      cnt_4++;
    }
  }

  cout << (cnt_4 >= (N - max(0, cnt_2 - 1)) / 2 ? "Yes" : "No") << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define REP(i, n) FOR(i, 0, (n))
#define REPS(i, n) FOR(i, 1, (n) + 1)
#define RREP(i, n) RFOR(i, 0, (n))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x), 0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1 << x) - 1)
#define DUP(x, y) (((x) + (y)-1) / (y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9 + 7;
const int INF = (1 << 30) - 1;
const ll INFLL = (1LL << 62) - 1;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
// cout << fixed << setprecision(10);

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int cnt_div2(int a) {
  int cnt = 0;
  while (a % 2 == 0) {
    a /= 2;
    cnt++;
  }
  return cnt;
}

int main() {
  int N;
  cin >> N;
  vi a(N);
  REP(i, N) scanf("%d", &a[i]);

  int cnt_2 = 0;
  int cnt_4 = 0;
  REP(i, N) {
    if (cnt_div2(a[i]) == 1) {
      cnt_2++;
    } else if (cnt_div2(a[i]) >= 2) {
      cnt_4++;
    }
  }

  cout << (cnt_4 >= (N - max(0, cnt_2 - 1)) / 2 ? "Yes" : "No") << endl;
}