Problem p03639 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LOCAL 0

#define length(a) (sizeof(a) / sizeof(a[0]))
#define print(v, i, x)                                                         \
  for (int j = i; j <= x; j++) {                                               \
    cout << v[j] << " ";                                                       \
  }                                                                            \
  cout << endl;
#define pb push_back
#define mp make_pair
#define lli long long int
#define ulli unsigned long long int
#define all(x) x.begin(), x.end()
#define f first
#define s second

#define si(x) scanf("%d", &x);
#define sli(x) scanf("%ld", &x);
#define slli(x) scanf("%lld", &x);
#define si2(x, y) scanf("%d %d", &x, &y);
#define si3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define slli2(x, y) scanf("%lld %lld", &x, &y);
#define slli3(x, y, z) scanf("%lld %lld %lld", &x, &y, &z);

#define pi(x) printf("%d", x);
#define pi2(x, y) printf("%d %d", x, y);
#define pi3(x, y, z) printf("%d %d %d", x, y, z);
#define pli(x) printf("%ld", x);
#define plli(x) printf("%lld", x);
#define plli2(x, y) printf("%lld %lld", x, y);
#define plli3(x, y, z) printf("%lld %lld %lld", x, y, z);
#define pn printf("\n");
#define ps printf(" ");
#define pc(c) printf("%c", c);

#define FOR(n) for (int i = 0; i < n; i++)
#define FORi(x, n) for (int i = x; i <= n; i++)
#define FORj(x, n) for (int j = x; j <= n; j++)
#define FORk(x, n) for (int k = x; k <= n; k++)
#define FORl(x, n) for (int l = x; l <= n; l++)
#define ROFi(x, n) for (int i = x; i >= n; i--)
#define ROFj(x, n) for (int j = x; j >= n; j--)
#define ROFk(x, n) for (int k = x; k >= n; k--)
#define ROFl(x, n) for (int l = x; l >= n; l--)

#define debug(x) cout << "  - " << #x << ": " << x << endl;
#define debugs(x, y)                                                           \
  cout << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
#define debugss(x, y, z)                                                       \
  cout << "  - " << #x << ": " << x << "         " << #y << ": " << y          \
       << "         " << #z << ": " << z << endl;
#define fastIO                                                                 \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);

typedef vector<int> vi;
typedef vector<long> vli;
typedef vector<long long> vlli;
typedef vector<string> vstr;

typedef pair<int, int> prii;
typedef pair<int, lli> prilli;
typedef pair<lli, int> prllii;
typedef pair<lli, lli> prllilli;

template <class T> T max3(T a, T b, T c) { return max(max(a, b), c); }
template <class T> T min3(T a, T b, T c) { return min(min(a, b), c); }
template <class T> T max4(T a, T b, T c, T d) {
  return max(max(a, b), max(c, d));
}
template <class T> T min4(T a, T b, T c, T d) {
  return min(min(a, b), max(c, d));
}

const lli mod = 1000000007ll;
const lli MOD = 1000000009ll;
const lli INF = LLONG_MAX / 10;
const int inf = INT_MAX / 2;

lli count_bit(lli _x) {
  lli _ret = 0;
  while (_x) {
    if (_x % 2 == 1)
      _ret++;
    _x /= 2;
  }
  return _ret;
}
lli check_bit(lli _mask, lli _i) {
  lli x = 1;
  return (_mask & (x << _i)) == 0 ? 0 : 1;
}
lli set_bit(lli _mask, lli _i) {
  lli x = 1;
  _mask = _mask | (x << _i);
  return _mask;
}
lli powermod(lli _a, lli _b, lli _m = mod) {
  lli _r = 1;
  while (_b) {
    if (_b % 2 == 1)
      _r = (_r * _a) % _m;
    _b /= 2;
    _a = (_a * _a) % _m;
  }
  return _r;
}
lli power(lli _a, lli _b) {
  lli _r = 1;
  while (_b) {
    if (_b % 2 == 1)
      _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
lli add(lli a, lli b, lli m = mod) {
  lli x = a + b;
  while (x >= m)
    x -= m;
  return x;
}
lli sub(lli a, lli b, lli m = mod) {
  lli x = a - b;
  while (x < 0)
    x += m;
  return x;
}
lli mul(lli a, lli b, lli m = mod) {
  lli x = a * b;
  x %= m;
  return x;
}
lli gcd(lli a, lli b) {
  while (a && b)
    a > b ? a %= b : b %= a;
  return a + b;
}
lli lcm(lli a, lli b) { return (a * b) / gcd(a, b); }

vector<string> _split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c))
    v.emplace_back(x);
  return v;
}

// int dx[]={-1,-1,0,1,1,1,0,-1};
// int dy[]={0,1,1,1,0,-1,-1,-1};

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
/*

    bool prime[1000010];
    lli pf[1000010];
    void sieve(){
        FOR(1000010){prime[i]=true;pf[i]=-1;}
        prime[0]=prime[1]=false;
        for(lli i=2;i<1000010;i++){
            if(prime[i]){
                pf[i]=i;
                for(lli j=i*i;j<1000010;j+=i)
                {prime[j]=false;if(pf[j]==-1)pf[j]=i;}
            }
        }
    }
*/

prii operator+(const prii &l, const prii &r) {
  prii ret;
  ret.f = l.f + r.f;
  ret.s = l.s + r.s;
  return ret;
}

struct cmp {
  bool operator()(int const &l, int const &r) { return true; }
} myobject;

int main() {

  if (LOCAL) {
    freopen("C:\\Users\\Smit Patel\\Downloads\\3.in", "r", stdin);
    freopen("C:\\Users\\Smit Patel\\Downloads\\4.txt", "w", stdout);
  }

  int a[] = {0, 0, 0};
  int n, x;

  si(n);

  FOR(n) {
    int cnt = 0;
    si(x);
    while (x % 2 == 0) {
      x /= 2;
      cnt++;
    }
    cnt = max(cnt, 2);
    a[cnt]++;
  }

  if (a[2] < a[0] - 1 || (a[2] == a[0] - 1 && a[1] > 0))
    cout << "No";
  else
    cout << "Yes";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LOCAL 0

#define length(a) (sizeof(a) / sizeof(a[0]))
#define print(v, i, x)                                                         \
  for (int j = i; j <= x; j++) {                                               \
    cout << v[j] << " ";                                                       \
  }                                                                            \
  cout << endl;
#define pb push_back
#define mp make_pair
#define lli long long int
#define ulli unsigned long long int
#define all(x) x.begin(), x.end()
#define f first
#define s second

#define si(x) scanf("%d", &x);
#define sli(x) scanf("%ld", &x);
#define slli(x) scanf("%lld", &x);
#define si2(x, y) scanf("%d %d", &x, &y);
#define si3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define slli2(x, y) scanf("%lld %lld", &x, &y);
#define slli3(x, y, z) scanf("%lld %lld %lld", &x, &y, &z);

#define pi(x) printf("%d", x);
#define pi2(x, y) printf("%d %d", x, y);
#define pi3(x, y, z) printf("%d %d %d", x, y, z);
#define pli(x) printf("%ld", x);
#define plli(x) printf("%lld", x);
#define plli2(x, y) printf("%lld %lld", x, y);
#define plli3(x, y, z) printf("%lld %lld %lld", x, y, z);
#define pn printf("\n");
#define ps printf(" ");
#define pc(c) printf("%c", c);

#define FOR(n) for (int i = 0; i < n; i++)
#define FORi(x, n) for (int i = x; i <= n; i++)
#define FORj(x, n) for (int j = x; j <= n; j++)
#define FORk(x, n) for (int k = x; k <= n; k++)
#define FORl(x, n) for (int l = x; l <= n; l++)
#define ROFi(x, n) for (int i = x; i >= n; i--)
#define ROFj(x, n) for (int j = x; j >= n; j--)
#define ROFk(x, n) for (int k = x; k >= n; k--)
#define ROFl(x, n) for (int l = x; l >= n; l--)

#define debug(x) cout << "  - " << #x << ": " << x << endl;
#define debugs(x, y)                                                           \
  cout << "  - " << #x << ": " << x << "         " << #y << ": " << y << endl;
#define debugss(x, y, z)                                                       \
  cout << "  - " << #x << ": " << x << "         " << #y << ": " << y          \
       << "         " << #z << ": " << z << endl;
#define fastIO                                                                 \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);

typedef vector<int> vi;
typedef vector<long> vli;
typedef vector<long long> vlli;
typedef vector<string> vstr;

typedef pair<int, int> prii;
typedef pair<int, lli> prilli;
typedef pair<lli, int> prllii;
typedef pair<lli, lli> prllilli;

template <class T> T max3(T a, T b, T c) { return max(max(a, b), c); }
template <class T> T min3(T a, T b, T c) { return min(min(a, b), c); }
template <class T> T max4(T a, T b, T c, T d) {
  return max(max(a, b), max(c, d));
}
template <class T> T min4(T a, T b, T c, T d) {
  return min(min(a, b), max(c, d));
}

const lli mod = 1000000007ll;
const lli MOD = 1000000009ll;
const lli INF = LLONG_MAX / 10;
const int inf = INT_MAX / 2;

lli count_bit(lli _x) {
  lli _ret = 0;
  while (_x) {
    if (_x % 2 == 1)
      _ret++;
    _x /= 2;
  }
  return _ret;
}
lli check_bit(lli _mask, lli _i) {
  lli x = 1;
  return (_mask & (x << _i)) == 0 ? 0 : 1;
}
lli set_bit(lli _mask, lli _i) {
  lli x = 1;
  _mask = _mask | (x << _i);
  return _mask;
}
lli powermod(lli _a, lli _b, lli _m = mod) {
  lli _r = 1;
  while (_b) {
    if (_b % 2 == 1)
      _r = (_r * _a) % _m;
    _b /= 2;
    _a = (_a * _a) % _m;
  }
  return _r;
}
lli power(lli _a, lli _b) {
  lli _r = 1;
  while (_b) {
    if (_b % 2 == 1)
      _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
lli add(lli a, lli b, lli m = mod) {
  lli x = a + b;
  while (x >= m)
    x -= m;
  return x;
}
lli sub(lli a, lli b, lli m = mod) {
  lli x = a - b;
  while (x < 0)
    x += m;
  return x;
}
lli mul(lli a, lli b, lli m = mod) {
  lli x = a * b;
  x %= m;
  return x;
}
lli gcd(lli a, lli b) {
  while (a && b)
    a > b ? a %= b : b %= a;
  return a + b;
}
lli lcm(lli a, lli b) { return (a * b) / gcd(a, b); }

vector<string> _split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c))
    v.emplace_back(x);
  return v;
}

// int dx[]={-1,-1,0,1,1,1,0,-1};
// int dy[]={0,1,1,1,0,-1,-1,-1};

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
/*

    bool prime[1000010];
    lli pf[1000010];
    void sieve(){
        FOR(1000010){prime[i]=true;pf[i]=-1;}
        prime[0]=prime[1]=false;
        for(lli i=2;i<1000010;i++){
            if(prime[i]){
                pf[i]=i;
                for(lli j=i*i;j<1000010;j+=i)
                {prime[j]=false;if(pf[j]==-1)pf[j]=i;}
            }
        }
    }
*/

prii operator+(const prii &l, const prii &r) {
  prii ret;
  ret.f = l.f + r.f;
  ret.s = l.s + r.s;
  return ret;
}

struct cmp {
  bool operator()(int const &l, int const &r) { return true; }
} myobject;

int main() {

  if (LOCAL) {
    freopen("C:\\Users\\Smit Patel\\Downloads\\3.in", "r", stdin);
    freopen("C:\\Users\\Smit Patel\\Downloads\\4.txt", "w", stdout);
  }

  int a[] = {0, 0, 0};
  int n, x;

  si(n);

  FOR(n) {
    int cnt = 0;
    si(x);
    while (x % 2 == 0) {
      x /= 2;
      cnt++;
    }
    cnt = min(cnt, 2);
    a[cnt]++;
  }

  if (a[2] < a[0] - 1 || (a[2] == a[0] - 1 && a[1] > 0))
    cout << "No";
  else
    cout << "Yes";

  return 0;
}