Problem p02772 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
#define lim 1000000007
#define MAX 10001
#define uomap unordered_map
#define uoset unordered_set
#define pb push_back
#define vec vector
#define mkp make_pair
#define fir first
#define sec second
#define LOG(fmt, args...) fprintf(stdout, fmt, ##args);
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const ll inf = 1e18 + 10;
using namespace std;

static int max_points = 200;
ll dis(ll a, ll b, ll c, ll d) { return abs(a - c) + abs(b - d); }

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    ll temp;
    cin >> temp;
    if (temp % 2 == 0 && temp % 3 != 0 && temp % 5 != 0) {
      flag = true;
    }
  }
  if (flag) {
    cout << "DENIED" << endl;
  } else {
    cout << "APPROVED" << endl;
  }

  return 0;
}

/*
 * akina.cpp
 * Copyright 2019 Karan Kanojia <karankanojia@Karans-MacBook-Air.local>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */


Fixed submission:
#include "bits/stdc++.h"
#define lim 1000000007
#define MAX 10001
#define uomap unordered_map
#define uoset unordered_set
#define pb push_back
#define vec vector
#define mkp make_pair
#define fir first
#define sec second
#define LOG(fmt, args...) fprintf(stdout, fmt, ##args);
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const ll inf = 1e18 + 10;
using namespace std;

static int max_points = 200;
ll dis(ll a, ll b, ll c, ll d) { return abs(a - c) + abs(b - d); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    ll temp;
    cin >> temp;
    if (temp % 2 == 0 && temp % 3 != 0 && temp % 5 != 0) {
      flag = true;
    }
  }
  if (flag) {
    cout << "DENIED" << endl;
  } else {
    cout << "APPROVED" << endl;
  }

  return 0;
}

/*
 * akina.cpp
 * Copyright 2019 Karan Kanojia <karankanojia@Karans-MacBook-Air.local>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */