jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		long N = nextLong();
		TreeMap<Long,Long> map = primeFactorize(N);

		long[][] x = new long[map.size()][2];
		int idx=0;
		for(long key : map.keySet()) {
			long val = map.get(key);
			x[idx][0]=key;
			x[idx][1]=val;
			idx++;
		}
		pw.println(dfs(1,1,0,x));
	}

	public static int dfs(long A , long B ,int idx ,long[][] lst) {
		if(idx==lst.length-1&&lst[idx][1]==0) {
			return A<B?String.valueOf(B).length():String.valueOf(A).length();
		}
		if(lst[idx][1]==0) {
			idx++;
		}

		lst[idx][1]--;
		int ans = Math.min(dfs(A*lst[idx][0],B,idx,lst),dfs(A,B*lst[idx][0],idx,lst));
		lst[idx][1]++;
		return ans ;
	}

	public static TreeMap<Long, Long> primeFactorize(long N) {
		TreeMap<Long, Long> map = new TreeMap<>(Comparator.comparing(Long::longValue,Comparator.reverseOrder()));
		for (long i = 2; i * i <= N; i++) {
			long k = 0;
			while (N % i == 0) {
				k++;
				N /= i;
			}
			if(k!=0)
				map.put(i, k);
		}
		map.put(N, 1L);
		return map;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}
//  [cpp]
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int countDigit(ll num) {
  int count = 0;

  while (num > 0) {
    num /= 10;
    count++;
  }
  return count;
}

bool isPrime(ll num) {
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }

  return true;
}

int main(void) {
  ll n;
  cin >> n;

  int ans = 10;
  double r = sqrt((double)n);
  if ((ll)r * r == n) {
    ans = countDigit((ll)r);
  } else if (isPrime(n)) {
    ans = countDigit(n);
  } else {
    for (ll i = (ll)r - 1; i <= n; ++i) {
      if (n % i == 0) {
        ans = countDigit(i);
        break;
      }
    }
  }

  cout << ans << endl;
  
  return 0;
}
//  [cpp]
#include <iostream>
#include <cmath>

using namespace std;

bool isPrime(long long n, long long root)	{
  for (long long i = 2; i <= root; i++)	{
    if (n % i == 0)
      return false;
  }
  return true;
}

int nDigits(long long n)	{
  int digits = 0;
  while (n > 0)	{
    digits++;
    n /= 10;
  }
  return digits;
}

int main()	{
  long long n;
  cin >> n;
  long long root = sqrt(n);
  //cout << root << endl;
  if (isPrime(n, root))	{
    cout << nDigits(n) << endl;
  }
  else	{
    //find largest factor starting from sqrt(n)
    for (long long i = root; i < n; i++)	{
      if (n % i == 0)	{
        cout << nDigits(i) << endl;
		return 0;
      }
    }
  }
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, k, n) for (int i = k+1; i < int(n); i++)
typedef long long LL;
typedef pair<int, int> PII;

int digit(long n){
	int dig = 1;
  	while(n / 10 > 0){
		n /= 10;
      	dig++;
    }  
  	return dig;
}

long search_mul(long small, long big, long n){
    long a,b;
    int i;
    for(i = small + 1; i < big; i++){
        if(n % i == 0){
            a = i;
            b = n/a;
            if(n % (a * small) == 0 && a*small < n/(a*small)){
                a = a * small;
                b = n/a;
                //cout << a << " * " << b << endl;
                return search_mul(a,b,n);
            }
            //cout << a << " * " << b << endl;
            //return min(digit(b), search_mul(a,b,n));
            return search_mul(a,b,n);
        }
    }
    //cout << small << " * " << big << " ,ans :";
    return big;
}
void f(long n) {
  int ans;
  long temp = sqrt(n)+1;
  long ret;

  ret = search_mul(1,temp,n);
  
  if(ret == temp)
    ans = digit(n);
  else
    ans = digit(ret);
  cout << ans << endl; 
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long n;
  cin >> n;
  f(n);
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  long long int n;
  int ans = 0;
  int keta = 0;

  scanf("%lld", &n);
  //約数を求める。その時の桁数を求める。一番桁数が小さくなる組合せを求める。

  long long int k = n;
  while(k != 0){
    k /= 10;
    ans++;
  }

  // i = 0から始めると(n%i == 0)のところで落ちている
  for(long int i  = 1; i * i <= n; i++){
    fprintf(stderr, "i = %ld\n", i);
    if(n % i == 0){
      long int j = n / i;
      while(j != 0){
	j /= 10;
	keta++;
      }
      fprintf(stderr, "ans = %d, keta = %d\n", ans, keta);
      if(ans > keta){
	ans = keta;
      }
      keta = 0;
    }
  }
  
  printf("%d\n", ans);
  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <math.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

int main(void){
    long N;
    scanf("%ld",&N);

    int ans=11;
    for(long i=1;i*i<=N;i++){
        if(N%i==0){
            int tmp = log10(N/i)+1;
            ans=MIN(ans,tmp);
        }
    }
    printf("%d\n",ans);

    return 0;
}
//  [c]
#include <stdio.h>
#include<math.h>
int func(long long int a,int b){
    int n=0,m=0;
    while(a>0){
        n++;
        a/=10;
    }
    while(b>0){
        m++;
        b/=10;
    }
    int ans=n;
    if(n<m){ans=m;}
    return ans;
}
int main(void){
    int b,n,m,answ;
    long long int N,a;
    scanf("%lld",&N);
    answ=func(N,1);
    for(int i=2;i<=pow(N,0.5);i++){
        if(N%i==0&&answ>func(N/i,i)){answ=func(N/i,i);}
    }
    printf("%d\n",answ);
    return 0;
}
//  [javascript]
  function Main(input){
	input=input.trim().split("\n");
	var N = parseInt(input,10);
	var array = [];
	var tmp = N;
	var k = 2;
	division_loop:
	while (true) {
		if (tmp % k == 0){
			tmp = tmp / k;
			array.push(k);
		} else {
			if (k > Math.sqrt(tmp)) {
				array.push(tmp);
				break division_loop;
			}
			k++;
		}
	}
	var ans = F(F_Comparison(array,N));
	console.log(ans);
}

function F(x){
	var i = 1;
	var j = 1;
	while(true){
		j *= 10;
		if (x >= j){
			i++;
		} else {
			return i;
			break;
		}
	}
}

function F_Comparison(array, N){
	var nYakusu = array.length;
	var zeroOneArray = [];
	var tmpValue = 1;
	var candidate = 1;
	for (var i = 0; i < Math.pow(2, nYakusu); i++){
		for (var j = 0; j < nYakusu; j++){
			if ((i / (Math.pow(2, j)) | 0) % 2 === 1) {
				tmpValue *= array[j];
			}
		}
		if (tmpValue > candidate && tmpValue <= Math.sqrt(N)){
			candidate = tmpValue;
		}
        tmpValue = 1;
	}
	return N / candidate;
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]

var lines = [];
var readline = require('readline');
var C = [].fill(0);
var result = Infinity;

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var N = Number(lines.shift()); var n = N;
    var counter = [].fill(0);

    for (var i = 2; i <= Math.sqrt(N); i++) {
        if (counter[i] === undefined && n % i === 0) { counter[i] = 0; }
        while (n % i === 0) {
            n = n / i;
            counter[i]++;
        }
    }

    if (counter.length === 0) {console.log(N.toString().length);}
    else {
        
        counter.forEach(function (value, index, array) {
            for (var i = 0; i < value; i++) {
                C.push(index);
            }
        });
        if (n !== 1) C.push(n);
        dfs(0, []);
        console.log(result);
    }
});

function dfs(n, comb) {
    if (n === C.length) { calc(comb); return (0); }

    comb[n] = 0;
    dfs(n + 1, comb);

    comb[n] = 1;
    dfs(n + 1, comb);
}

function calc(comb) {
    var a = 1; var b = 1;

    for (var i = 0; i < comb.length; i++) {
        if (comb[i] === 0) { a *= C[i]; }
        else { b *= C[i]; }
    }
    if (result > b.toString().length && a.toString().length <= b.toString().length) { result = b.toString().length; }
}
//  [javascript]
function main(lines) {
  const N = n();
  
  const nSqrt =  Math.sqrt(N);
  let divisor;
  for (let i = 1; i <= nSqrt; i++) {
    if (N % i != 0) continue;
    divisor = i;
  }
  const ans = Math.max(divisor, N/divisor).toString(10).length;
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var N int

func readVariables() {
	N = nextInt()
}

func main() {
	readVariables()
	answer := 1234567890123
	upperBound := 1000000
	for i := 1; i < upperBound; i++ {
		if N%i == 0 {
			answer = MinInt(f(i, N/i), answer)
		}
	}
	fmt.Println(answer)
}

func f(x, y int) int {
	return MaxInt(len(strconv.Itoa(x)), len(strconv.Itoa(y)))
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}
//  [ruby]
require "prime"
N = gets.to_i
arr = N.prime_division.flat_map { |i,j| [i] * j }
if arr.empty?
  arr = [1]
end

def f(a, b)
  [a,b].max.to_s.length
end
min = 9999
(1..arr.size).each do |n|
  arr.combination(n) do |m|
    a = m.inject(:*)
    b = N / a
    c = f(a, b)
    if min > c
      min = c
    end
  end
end
p min
//  [ruby]
require 'prime'

n = gets.to_i
if n == 1
  puts 1
else
  h = Prime.prime_division(n).to_h
  p = []
  h.each do |k, v|
    while v > 0
      p << k
      v -= 1
    end
  end
  min = Float::INFINITY
  0.upto(2 ** p.size - 1) do |bit|
    a = 1
    b = 1
    p.size.times do |i|
      if bit[i] == 0
        a *= p[i]
      else
        b *= p[i]
      end
    end
    min = [a.to_s.size, b.to_s.size].max if min > [a.to_s.size, b.to_s.size].max
  end
  puts min
end
//  [ruby]
require 'prime'

class Integer
  def my_divisor_list
    divisors = [1]
    primes = []
    Prime.prime_division(self).each do |prime|
      prime[1].times {primes << prime[0]}
    end

    1.upto(primes.size) do |i|
      primes.combination(i) do |prime|
        divisors << prime.inject{|a,b| a *= b}
      end
    end

    divisors.uniq!
    divisors.sort!
    return divisors
  rescue ZeroDivisionError
    return
  end
end

N = gets.to_i
divisiors = N.my_divisor_list.select {|x| x <= Math.sqrt(N)}

ans = Float::INFINITY
f = 0

divisiors.each do |a|
	f = [a.to_s.length, (N/a).to_s.length].max
	ans = f if f < ans
end

p f
//  [rust]
use proconio::input;

fn main() {
	input!(n: usize);

	let nmax: usize = (n as f64).sqrt() as usize + 1;

	let mut ans = 99999999;
	for i in 1..nmax {
		if n % i != 0 {
			continue;
		}
		let j = n / i;
		let si: String = i.to_string();
		let sj: String = j.to_string();
		let dmax = std::cmp::max(si.len(), sj.len());
		if dmax < ans {
			ans = dmax;
		}
	}
	println!("{}", ans);
}
//  [python]
from collections import OrderedDict

temp=input()
n,k=list(map(int,temp.split(" ")))
co=OrderedDict()
ans=[]
temp=input()
nums=list(map(int,temp.split(" ")))
for i in nums:
  if i in co:
	  co[i]+=1
  else:
	  co[i]=1
for i in co:
  ans.append(co[i])
kinds=len(ans)
dif=kinds-k
if dif<=0:
    print(0)
else:
    ans.sort()
    print(sum(ans[:dif]))
//  [python]
import bisect

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))

data = []
i = 0

while i < len(A):
    x = A[i]
    a = bisect.bisect_left(A, x)
    b = bisect.bisect_right(A, x)
    data.append([x, b - a])
    i = b
    
data = sorted(data, key = lambda x: x[1])
m = len(data) - K
ans = 0

for i in range(0, m):
    ans += data[i][1]
    
print(ans)
//  [python]
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=set(a)
a.sort()
if k>=len(set(a)):
    print(0)
else:
    cnt=[a[0]]
    ans=[]
    for i in range(1,n):
        if a[i]!=a[i-1]:
            ans.append(cnt)
            cnt=[]
            cnt.append(a[i])
        else:
            cnt.append(a[i])
        if i==n-1 and cnt!=[]:
            ans.append(cnt)
    for j in range(len(ans)):
        ans[j]=len(ans[j])
    ans.sort()
    answ=0
    for i in range(len(set(s))-k):
        answ+=ans[i]
    print(answ)
//  [java]
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Map<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < N; i++) {
            int e = sc.nextInt();
            if (map.containsKey(e)) {
                map.put(e, map.get(e) + 1);
            } else {
                map.put(e, 1);
            }
        }

        Map<Integer, Integer> sorted = map.entrySet().stream()
                .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
                .collect(Collectors.toMap(s -> s.getKey(), s -> s.getValue(), (s1, s2) -> s2,
                        LinkedHashMap::new));

        int ans = 0;
        for (Entry<Integer, Integer> ent : sorted.entrySet()) {
            if (K <= 0) {
                ans += ent.getValue();
            }

            K--;
        }

        System.out.println(ans);

    }
}
//  [java]
import java.util.*;
import java.util.stream.IntStream;

public class Main {
        static boolean[][] f;
        static  int[][] p;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        Map<Integer, Tama> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int num = scan.nextInt();
            if(map.containsKey(num)) {
                Tama tmp = map.get(num);
                tmp.count++;
            }
            else {
                Tama tmp = new Tama(num, 1);
                map.put(num, tmp);
            }
        }
        if(map.size() - k <= 0) {
            System.out.println(0);
            return;
        }
        System.out.println(map.values().stream().sorted(Comparator.comparingInt(x -> x.count)).limit(map.size() - k).mapToInt(x -> x.count).sum());

    }

    public static class Tama{
        int num;
        int count;

        public Tama(int num, int count) {
            this.num = num;
            this.count = count;
        }
    }
}
//  [java]
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k  = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int count = map.getOrDefault(a,0);
            map.put(a, ++count);
        }

        if (map.size() <= k) {
            System.out.println(0);
            return;
        }

        int diff = map.size() - k ;
        List<Map.Entry<Integer, Integer>> list = new ArrayList<>(map.entrySet());
        list.sort((e1, e2) -> (e1.getValue() - e2.getValue()));
        int count = 0;
        for (int i = 0; i < diff; i++) {
            count += list.get(i).getValue();
        }

        System.out.println(count);
    }
}
//  [cpp]
#include <stdio.h>

int main(){
	int k,n,a,c[200002],ans=0,i,p=0,j;
	scanf("%d%d",&n,&k);
	for(i=0;i<200001;i++)
	c[i]=0;
	for(i=0;i<n;i++){
		scanf("%d",&a);
		c[a]++;
			}
			p=n-k;
			i=1;
			j=0;
			while(p!=0){
				if(c[i]==j){
				p--;
				ans+=j;
				}
				if(i==n){
				i=0;
				j++;
				}
				i++;
			}
			printf("%d",ans);
			return 0;
			}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

const int N_MAX = 200001;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);

    vector<int> species(N_MAX, 0);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        species[a]++;
    }

    for (int i = N_MAX-1; i >= 0; i--) {
        if(species[i]==0) {
            species.erase(species.begin()+i);
        }
    }

    sort(species.begin(), species.end(), 
        [](auto kv1, auto kv2) -> bool {return kv1 < kv2;}
    );

    int ret = 0;
    while ( species.size() > k ) {
        ret += species[0];
        species.erase(species.begin());
    }
    printf("%d\n", ret);
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	map<int, int> mp;
	for( int i = 0; i < N; i++ ) {
		int A;
		cin >> A;
		mp[A]++;
	}

	vector<int> num;
	for( auto it = mp.begin(); it != mp.end(); it++ ) {
		num.push_back( it->second );
	}
	sort( num.begin(), num.end() );
	int ans = 0;
	while( num.size() > K ) {
		ans += num[0];
		num.erase( num.begin() );
	}

	cout << ans << endl;
}
//  [c]
#include<stdio.h>

int main(){
  int N,K,A,ans=0,counter=0;
  scanf("%d%d",&N,&K);
  int ball[N];for (int i = 0; i < N; i++){ball[i]=0;}
  
  for (int i = 0; i < N; i++)
  {
    scanf("%d",&A);
    if (ball[A-1]!=0)
    {
      ball[A-1]++;
    }else{
      ball[A-1]++;
      counter++;
    }
  }

  int del=counter-K;
  if (del<=0)
  {
    puts("0");
  }else{
    int j=0;
    while (del>0)
    {
      j++;
      for (int i = 0; i < N&&del>0; i++)
      {
        if (ball[i]!=0&&ball[i]==j)
        {
          ans+=j;
          ball[i]=0;
          del--;
        }
      }
    }

    printf("%d",ans);
    
  }
  
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#define ms_valtype int

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return a - b;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int max(int a, int b){
	return a >= b ? a : b;
}

int main(){
	int N, K, i, j, sum = 0;
	scanf("%d%d", &N, &K);
	int *A = (int *)malloc(sizeof(int) * N);
	int *B = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
		B[i] = 0;
	}
	sort(A, N);
	for(i = 1, B[0] = 1, j = 0; i < N; i++){
		if(A[i] != A[i - 1]){
			j++;
		}
		B[j]++;
	}
	j++;
	sort(B, j);
	if(j <= K){
		printf("0\n");
	}
	else{
		for(i = 0; i < j - K; i++){
			sum += B[i];
		}
		printf("%d\n", sum);
	}
	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b){
  return *(long*)a - *(long*)b;
}

int main(){
  long n = 0;
  long k = 0;
  long a[200000] = {};
  long i = 0;
  long hoge[200000] = {};
  long hozon = 0; 
  long hogecnt = 0;
  long sum = 0;
  long hogem = 0;
  scanf("%lu %lu",&n,&k);
  for(i=0 ; i < n; i++){
    scanf("%lu",&a[i]);
  }
  qsort(a,n,sizeof(long),compare);
  hozon = a[0];
  for(i=0;i<n;i++){
    if(hozon == a[i]){
      hoge[hogecnt]++;
    }else{
      hozon = a[i];
      hoge[hogecnt+1]++;
      hogecnt++;
    }
  }
  qsort(hoge,n,sizeof(long),compare);
  if((hogecnt+1) <= k){
    sum = 0;
  }else{
    hogem = 0;
    for(i=0;hogem < (hogecnt+1)-k;i++){
      if(hoge[i] != 0){	
      	sum += hoge[i];
      	hogem++;
      }
  	}
  }
  printf("%lu",sum);
  return 0;
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k, total, tmp int
	fmt.Scanf("%d %d\n", &n, &k)
	dic := map[int]int{}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		dic[tmp]++
	}

	var counts []int
	for _, value := range dic {
		counts = append(counts, value)
	}

	sort.IntSlice(counts).Sort()

	for i := 0; i < len(counts)-k; i++ {
		total += counts[i]
	}

	fmt.Println(total)

}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	
	a := make(map[int]int)
	
	tmp := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		a[tmp]++
	}
	if len(a) <= k {
		fmt.Println(0)
		return
	}
	
	cnt := make([]int, len(a))
	idx := 0
	for _,v := range a {
		cnt[idx] = v
		idx++
	}
	sort.Ints(cnt)

	ans := 0
	for i := 0; i < len(a) - k; i++ {
		ans += cnt[i]
	}
	fmt.Println(ans)

}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k, idx, ans int
	fmt.Scan(&n, &k)

	a := make(map[int]int)

	tmp := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		a[tmp]++
	}
	if len(a) <= k {
		fmt.Println(0)
		return
	}

	cnt := make([]int, len(a))
	for _, v := range a {
		cnt[idx] = v
		idx++
	}
	sort.Ints(cnt)

	for i := 0; i < len(a)-k; i++ {
		ans += cnt[i]
	}
	fmt.Println(ans)
}
//  [ruby]
eval"N,K,*A="+`dd`.split*?,;p A.group_by{|a|a}.map{|k,v|v.size}.sort[0...-K].inject 0,:+
//  [ruby]
N, K = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).group_by{|e| e}.map{|k, v| [k, v.length]}.to_a.sort{ |x, y| x[1] <=> y[1] }
ans = 0
while a.size > K
  ans += a[0][1]
  a.shift
end
puts ans
//  [ruby]
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, K = gets_i_list
a_list = gets_i_list

type_count = a_list.uniq.size

# 配列に出現する数値をカウント
# {1=>3, 2=>1, 3=>2}
count_hash = a_list.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

if type_count <= K
  puts 0
  exit
end

count_list = count_hash.values.sort
total = 0
(type_count - K).times do
  total += count_list.shift
end

puts total
//  [rust]
use std::collections::HashMap;
use std::io::{BufRead, StdinLock};
fn main() {
    let stdin = std::io::stdin();
    let mut stdinlock = stdin.lock();
    let nk = read_line(&mut stdinlock);
    let mut balls: HashMap<u32, u32> = HashMap::new();
    for &ak in &read_line(&mut stdinlock) {
        let ball = balls.entry(ak).or_insert(0);
        *ball += 1;
    }
    eprintln!("{:?}", balls);
    println!("{}", solve(nk[0], nk[1], &balls));
}

fn solve(_: u32, k: u32, balls: &HashMap<u32, u32>) -> u32 {
    if balls.len() <= k as usize {
        return 0;
    }
    let diff = balls.len() - k as usize;
    let mut nums: Vec<u32> = balls.values().map(|&n| n).collect();
    nums.sort();
    nums.iter().take(diff).sum()
}

fn read_line(st: &mut StdinLock) -> Vec<u32> {
    let mut s = String::new();
    st.read_line(&mut s).expect("read_line");
    s.trim()
        .split_whitespace()
        .map(|n| n.parse().expect("parse"))
        .collect()
}
//  [rust]
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      k: usize,
      a: [usize; n]
   }

   let mut m = std::collections::BTreeMap::new();
   for a in a {
      let mut flag = false;
      match m.get_mut(&a) {
         Some(v) => *v += 1,
         None => flag = true,
      }
      if flag {
         m.insert(a, 1);
      }
   }
   let mut ap: Vec<_> = m.iter().map(|(_, v)| *v).collect();
   ap.sort();
   let mut ans = 0;
   let mut del = 0;
   while ap.len()-del > k {
      ans += ap[del];
      del += 1;
   }
   println!("{}", ans);
}
//  [rust]
use std::io::*;
fn read<T: std::str::FromStr>() -> T {
    stdin()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
        .parse()
        .ok()
        .unwrap()
}

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut v = vec![0_usize; 200_001];
    for _ in 0..n {
        let i: usize = read();
        v[i] += 1;
    }

    v.sort();
    v.reverse();
    let mut sum = 0_usize;
    for i in 0..k {
        sum += v[i];
    }
    println!("{}", n - sum);
}
//  [python]
def main():
    n = int(input())
    a = list(map(int, input().split()))
    for i in a:
        if i % 2 == 0:
            if i % 3 != 0 and i % 5 != 0:
                print("DENIED")
                return
    print("APPROVED")


main()
//  [python]
n = int(input())
nums = list(map(int, input().split()))
ng = False
for i in nums:
    if i % 2 != 0:continue
    if i % 3 != 0 and i % 5 != 0:ng = True

if ng:
    print("DENIED")
else:
    print("APPROVED")
//  [python]

N = int(input())
A = list(map(int,input().split()))

flag = True

for a in A:
    if a%2 == 0:
        if a%3 == 0 or a%5 == 0:
            None
        else:
            flag = False

if flag:
    print('APPROVED')
else:
    print('DENIED')
//  [python]
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

ok = True
for a in A:
    if a %2 == 0:
        if not ( a % 3 == 0 or a % 5 == 0):
            ok = False
if ok:
    print('APPROVED')
else:
    print('DENIED')
//  [python]
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
A = A[A%2==0].tolist()
bool = True
for a in A:
    if a%3 != 0 and a%5 != 0:
        bool = False

print('APPROVED' if bool else 'DENIED')
//  [python]
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

n = int(input())
a = list(int(i) for i in input().split())

cnt, subcnt = 0, 0
for i in a:
	if i % 2 == 0:
		subcnt += 1
		if i % 3 == 0 or i % 5 == 0:
			cnt += 1

if subcnt == cnt:
	print('APPROVED')
else:
	print('DENIED')
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        String[] a =  input.readLine().split(" ");
        for(String jude1 : a ){
            int jude2 = Integer.parseInt(jude1);
            if(jude2 % 2 == 0){
                if(!(jude2 % 5 == 0 || jude2 % 3 == 0)){
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}
//  [java]
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = saori.saori_hayami();
		}

		boolean flg = false;

		a:for(int i = 0;i < a.length;i++ ){
			if(a[i] % 2 == 0){
				if(a[i] % 3 == 0 || a[i] % 5 == 0){

				} else {
					flg = true;
					break a;
				}
			}
		}

		if(flg){
			System.out.println("DENIED");
		} else{
			System.out.println("APPROVED");
		}
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        scanner.nextLine();

        final int[] evens = Arrays.stream(scanner.nextLine().split(" "))
                .mapToInt(Integer::parseInt)
                .filter(i -> i % 2 == 0)
                .toArray();

        boolean approved = true;
        for (int i: evens) {
            if (i % 3 != 0 && i % 5 != 0) {
                approved = false;
                break;
            }
        }

        System.out.println(approved ? "APPROVED" : "DENIED");
    }
}
//  [java]
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        long cnt = Stream.generate(()->sc.nextInt())
                .limit(N)
                .filter(a -> a%2==0)
                .filter(a -> a % 3 != 0 && a % 5 != 0)
                .count();
        if(cnt == 0)
            System.out.println("APPROVED");
        else
            System.out.println("DENIED");
    }
}
//  [java]
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        scan.nextLine();
        List<Integer> aList = Arrays.stream(scan.nextLine().split(" "))
                .map(Integer::parseInt).collect(Collectors.toList());

        AtomicBoolean bool = new AtomicBoolean(false);
        aList.forEach(a -> {
            if(a % 2 == 0) {
                if(a % 3 != 0 && a % 5 != 0) {
                    System.out.println("DENIED");
                    System.exit(0);
                }
            }
        });
        System.out.println("APPROVED");
    }
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int a[1000];
  int n;
  string ans = "APPROVED";
  cin >> n;

  rep(i,n) {
    cin >> a[i];
    if(a[i]%2 == 0) {
      if(a[i]%3 == 0 || a[i]%5 == 0) {
        ans = "APPROVED";
      } else {
        ans = "DENIED";
        break;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
int n,x;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x%2) continue;
		else if(x%3==0 || x%5==0) continue;
		else{
			cout<<"DENIED";
			return 0;
		} 
	}
	cout<<"APPROVED";
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int c = 0;
    for (int j = 0; j < n; j++)
    {
        if (a[j] % 2 == 0)
        {
            if (a[j] % 3 != 0 && a[j] % 5 != 0)
            {
                cout << "DENIED" << endl;
                c++;
                break;
            }
        }
    }
    if (c == 0)
        cout << "APPROVED" << endl;
    return 0;
}
//  [cpp]
#include<stdio.h>
int main() {
	int n;
  	scanf("%s", &n);
    bool yes = true;
  	for(int i = 0; i < n; i++){
    	int x;
      	scanf("%d", &x);
      	if(x % 2 == 0 && x%3 !=0 && x%5!=0){
        	yes = false;
        }
    }
  	if(yes) {
      	puts("APPROVED");
    }else {
    	puts("DENIED");
    }
}
//  [c]
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		int a;
		scanf("%d", &a);
		if(a%2==0 && a%3!=0 && a%5!=0){
			puts("DENIED");
			return 0;
		}
	}
	puts("APPROVED");
}
//  [c]
#include <stdio.h>
int main(void) {
	int n;
	int a[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				printf("DENIED\n");
				return 0;
			}
		}
	}
	printf("APPROVED\n");
	return 0;
}
//  [c]
#include<stdio.h>
int main(){
  int N,x,i,a;
  x=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a);
    if(a%2==0){
      if(a%3!=0 && a%5!=0){
        x=1;
        break;
      }
    }
  }
  if(x==0)
    printf("APPROVED\n");
  else
    printf("DENIED\n");
  return 0;
}
//  [c]
#include <stdio.h>
int arr[105];
int a;

void solve() {
  scanf("%d",&a);
  for(int i = 1; i <= a; i = i + 1) {
    scanf("%d", &arr[i]);
    if(arr[i] % 2 ==0) {
        if(arr[i] % 3 != 0 && arr[i] % 5 != 0) {
          printf("DENIED\n");
          return;
        }
    }
  }
  printf("APPROVED\n");
  return;
}

int main() {
  solve();
  return 0;
}
//  [c]
#include<stdio.h>
void main(){
   int n;
   scanf("%d",&n);
   int a[n],i,judg;
   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
   }
   judg=0;
   for(i=0;i<n;i++){
     if(a[i]%2==0){
        if(a[i]%3==0||a[i]%5==0){
        }else{
           judg++;
        }
     }
   }
   if(judg==0){
      printf("APPROVED");
   }else{
      printf("DENIED");
   }
}
//  [javascript]
'use strict';

function main(input) {
  const arr = input.trim().split('\n');
  const a = Number(arr[0]);
  const b = arr[1].split(' ').map(x => Number(x));
  let isPass = true;

  for (let i = 0; i < a; i++) {
    if (b[i] % 2 === 0 && b[i] % 3 !== 0 && b[i] % 5 !== 0) {
      isPass = false;
    } else {
      continue;
    }
  }
  console.log(isPass ? 'APPROVED' : 'DENIED');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
    var line = input.split(/\r?\n/g);
    const A = line[1].split(" ").map(Number);
    var flg = true;
    for (var i in A)
        if (!(A[i] % 2) && (A[i] % 3) && (A[i] % 5)) {
            flg = false;
            break;
        }
    console.log(flg ? "APPROVED" : "DENIED");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  let line1 = input[0].split(" ");
  let n = line1[0];

  let A = input[1].split(" ");

  let isOK = true;

  for(let i=0; i<A.length; i++) {
    if(A[i]%2 === 0) {
      if(A[i]%3 !== 0 && A[i]%5 !== 0) {
        isOK = false;
      }
    }
  }

  if(isOK) console.log("APPROVED");
  else console.log("DENIED");

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  const N = input[0];
  const A = input[1].split(' ').map(v => parseInt(v));
  f = false;

  A.forEach(v => {
    if (v % 2 == 0 && v % 3 != 0 && v % 5 != 0) f = true;
  });

  if (f) {
    console.log("DENIED");
  } else {
    console.log("APPROVED");
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function main(inp) {
  inp = inp.trim().split('\n')
  const N = Number(inp.shift())
  inp = inp[0].split(' ').map(n => Number(n));

  let ans = 'APPROVED';
  for (let n of inp) {
    if (n % 2 === 0) {
      if ((n % 3 !== 0) && (n % 5 !== 0)) {
        ans = 'DENIED';
      }
    }
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    const evens = A.filter(n=>n % 2 === 0);
    
    console.log(evens.filter(n=>n % 3 === 0 || n % 5 === 0).length == evens.length ? "APPROVED" : "DENIED");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i, v := range a {
		fmt.Scan(&v)
		a[i] = v
	}
	check := make([]bool, n)
	for i, v := range a {
		if v%2 == 0 && (v%3 == 0 || v%5 == 0) || v%2 != 0 {
			check[i] = true
		}
	}
	result := "APPROVED"
	for _, v := range check {
		if v == false {
			result = "DENIED"
			break
		}
	}
	fmt.Println(result)
}
//  [go]
package main

import "fmt"

func main(){
	var N int;
	fmt.Scan(&N);

	A := make([]int, N);
	B := make([]int, N);
	var ans int;

	for i := 0 ; i < N ; i++{
		fmt.Scan(&A[i]);
	}

	for i:= 0; i < N ; i++{
		if A[i] % 2 == 0 {
			B[i] = 1;
			ans++;
		}
	}
	for i:=0;i < N ; i++{
		if B[i] == 1{
			if A[i] % 3 == 0 || A[i] % 5 == 0{
				ans--;
			}
		}
	}
	if ans == 0{
		fmt.Println("APPROVED");
	}else {
		fmt.Println("DENIED");
	}
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if a%2 == 0 && a%3 != 0 && a%5 != 0 {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}
func main() {
	var N, An int
	N = nextInt()
	for i := 0; i < N; i++ {
		An = nextInt()
		if An%2 == 1 {
			continue
		}
		if An%3 != 0 && An%5 != 0 {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}
func main() {
	var N, An int
	N = nextInt()
	for i := 0; i < N; i++ {
		An = nextInt()
		// if An%2 == 1 {
		// 	continue
		// }
		if An%2 != 1 && An%3 != 0 && An%5 != 0 {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()
	n := io.ScanInt()
	docs := io.ScanInts(n)
	for _, d := range docs {
		if d%2 == 0 && (d%3 != 0 && d%5 != 0) {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}
//  [ruby]
n = gets
puts gets.split.map(&:to_i).select{|i| i % 2 == 0}.all?{|i| i % 3 == 0 || i % 5 == 0} ? 'APPROVED' : 'DENIED'
//  [ruby]
n = gets
numbers = gets.split(" ").map(&:to_i)

evn_numbers = numbers.select(&:even?)

if evn_numbers.map { |n| (n % 3 == 0) || (n % 5 == 0) }.all?
  puts "APPROVED"
else
  puts "DENIED"
end
//  [ruby]
### SNIPPET
  # array = [*1..q].map { |_| gets.split.map(&:to_i) }
  # n = gets.split.map(&:to_i)
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select! { |num| num.even? }  # => [2, 4]
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さh = a * Math.sin(w / 180.0 * Math::PI)
  # 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end
n = gets.to_i
a = gets.split.map(&:to_i)

a.select! {|num| num.even?}

res = a.all? do |d|
  if d % 3 == 0 || d % 5 == 0
    true
  else
    false
  end
end

puts res ? "APPROVED" : "DENIED"
//  [ruby]
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

if a.all?{|a| a.odd? || (a%3==0 || a%5==0)}
  puts 'APPROVED'
else
  puts 'DENIED'
end