Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int // ranges from (0 - twice of long long int)
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll, ll>
#define INF 1000000000000000000ll
#define np next_permutation
// ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES
// WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template <typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v) {
  if (v.size() > 0) {
    v.erase(v.begin());
  }
}
template <
    typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
  if (v.size() > 0) {
    v.erase(v.begin() + v.size() - 1);
  }
}

bool isprime(ll n) // IN  O(sqrt(n))
{
  if (n <= 1)
    return false;
  for (ll i = 2; i * i <= n; i++)
    if (n % i == 0)
      return false;

  return true;
}

vector<ll> factors(ll n) { // IN  O(sqrt(n))

  vll v;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.pb(i);
      if ((n / i) != i)
        v.pb(n / i);
    }
  }
  return v;
}

ll power(ll a, ll n) // using Binary Exponential in TC O(logn)
{                    // Self Written By </ME> :)
  ll res = 1;
  while (1) {
    if (n % 2) {
      res = res * a;
      n--;
    }
    if (n == 0)
      break;
    a = a * a;
    n /= 2;
  }
  return res;
}

int main() {

  fio;
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
  ll t = 1;
  // cin>>t;
  while (t--) {
    ll n;
    cin >> n;
    ll arr[n];
    rep(i, 0, n) cin >> arr[i];
    int flag = 1;
    rep(i, 0, n) {
      if (arr[i] % 2 == 0) {
        if (arr[i] % 3 != 0 && arr[i] % 5 != 0) {
          flag = 0;
          break;
        }
      }
    }

    if (flag == 0)
      cout << "DENIED"
           << "\n";
    else
      cout << "APPROVED"
           << "\n";
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int // ranges from (0 - twice of long long int)
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll, ll>
#define INF 1000000000000000000ll
#define np next_permutation
// ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES
// WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template <typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v) {
  if (v.size() > 0) {
    v.erase(v.begin());
  }
}
template <
    typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
  if (v.size() > 0) {
    v.erase(v.begin() + v.size() - 1);
  }
}

bool isprime(ll n) // IN  O(sqrt(n))
{
  if (n <= 1)
    return false;
  for (ll i = 2; i * i <= n; i++)
    if (n % i == 0)
      return false;

  return true;
}

vector<ll> factors(ll n) { // IN  O(sqrt(n))

  vll v;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.pb(i);
      if ((n / i) != i)
        v.pb(n / i);
    }
  }
  return v;
}

ll power(ll a, ll n) // using Binary Exponential in TC O(logn)
{                    // Self Written By </ME> :)
  ll res = 1;
  while (1) {
    if (n % 2) {
      res = res * a;
      n--;
    }
    if (n == 0)
      break;
    a = a * a;
    n /= 2;
  }
  return res;
}

int main() {

  fio;
  ll t = 1;
  // cin>>t;
  while (t--) {
    ll n;
    cin >> n;
    ll arr[n];
    rep(i, 0, n) cin >> arr[i];
    int flag = 1;
    rep(i, 0, n) {
      if (arr[i] % 2 == 0) {
        if (arr[i] % 3 != 0 && arr[i] % 5 != 0) {
          flag = 0;
          break;
        }
      }
    }

    if (flag == 0)
      cout << "DENIED"
           << "\n";
    else
      cout << "APPROVED"
           << "\n";
  }

  return 0;
}