Harryxun/stf_run huggingface dataset:
n = int(input())
m = list(map(int, input().split()))
m = set(m)

for i int range(len(m))
    if i % 2 == 0:
        if i % 5 == 0 or i % 3 == 0:
            ans = 'APPROVED'
        else:
            ans = 'DENIED'

print(ans)

### FIXED CODE ###

n = int(input())
m = list(map(int, input().split()))

ans = "APPROVED"

for i in range(len(m)):
    if ans == "DENIED":
        break;
    if m[i] % 2 == 0:
        if m[i] % 5 == 0 or m[i] % 3 == 0:
            ans = 'APPROVED'
        else:
            ans = 'DENIED'
            break;

print(ans)
from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
m = int(data[0].split()[1])

k = int(data[0].split()[2])

A = [int(s) for s in data[1].split()]
B = [int(s) for s in data[2].split()]

a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
a.pop(0)
b.pop(0)

ans = 0
j = m-1
for i in range(n):
    if a[i] > k:
        break
    while a[i]+b[j] > k:
        j -= 1
    ans = max(ans, i+j+2)
print(ans)

### FIXED CODE ###

from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
m = int(data[0].split()[1])

k = int(data[0].split()[2])

A = [int(s) for s in data[1].split()]
B = [int(s) for s in data[2].split()]

a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    else:
        while a[i]+b[j] > k:
            j -= 1
        ans = max(ans, i+j)
print(ans)
N = int(input())
D = list(map(int, input().split()))

diff = [0]*13
D.sort()
for i in range(N):
    diff[D[i]] += 1

if diff[0] > 0:
    print(0)
    exit(0)
else:
    diff2 = [diff[12 - i] for i in range(1, N-1)]

for i in range(13):
    if diff[i] > 2:
      print(0)
      exit(0)

ans = [0]
for i in range(N):
    if i % 2 == 0:
        ans.append(D[i])
    else:
        ans.append(24 - D[i])

ans = [abs(ans[i+1] - ans[i]) for i in range(N-1)]

print(min(ans))


### FIXED CODE ###

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


D.sort()
ans = [0]
ans = [D[i]
       for i in range(N) if i % 2 == 0] + [24 - D[i] for i in reversed(range(N)) if i % 2 == 1]

ans = [0] + ans + [0]

ans = [abs(ans[i+1] - ans[i]) for i in range(N+1)]

print(min(ans))
x = raw_input()
a = int(x[0:1])
b = int(x[2:3])
print a*b + " " + ((a*2)+(b*2))

### FIXED CODE ###

x = map(int,raw_input().split())
aa = x[0] * x[1]
bb = x[0]*2 + x[1]*2
print aa,bb
A, B = map(int(input().sprit())

if (A * B) % 2 == 0 :
  print('no')
else :
  print('yes')


### FIXED CODE ###

A, B = map(int, input().split())
 
if (A * B) % 2 == 0 :
  print('No')
else :
  print('Yes')
N = int(input())
N2 = [64,32,16,8,4,2]
for i in range(len(N)):
  if N2[i] <=N:
    print(N2[i])
	break

### FIXED CODE ###

N = int(input())
N2 = [64,32,16,8,4,2,1]
for i in range(len(N2)):
	if N2[i] <=N:
		print(N2[i])
		break
a = int(input())
b = int(input())
print(a + b)


### FIXED CODE ###

print(sum(map(int, input().split())))
s=input()

op_n=len(s) - 1

ans=0

for i in range(1 << len(s)):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j)==1):
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op-n] 
  ans = eval(formula)
print(ans)  
    
      
       

### FIXED CODE ###

s = input()

op_n = len(s) - 1

ans = 0

for i in range(1 << op_n):
  sign = [""] * op_n
  for j in range(op_n):
    if ((i>>j)&1):
      sign[j] = "+"
  formula = ""
  for k in range(op_n):
    formula += s[k] + sign[k]
  formula += s[op_n] 
  ans += eval(formula)
print(ans)
// D - Water Bottle
#include <bits/stdc++.h>
using namespace std;
using dbl = double;
#define PI (M_PI)
#define DEG(rad) ((rad)*180/PI)
#define EPS (0.000000001) // 誤差範囲

dbl f(dbl a, dbl b, dbl rad){//rad 傾けたとき a*a*b の容器にあふれずに入れられる水の量は？
	if(PI/2 - rad < EPS) return 0.0;//誤差範囲で90°といえるなら0を返す
	dbl c = tan(rad);//rad 傾けてみる
	//入れられる水の量: b/a(45°)以下？ yes:容器の体積-空き容量(横から見て、奥行き*△) no:奥行き*△
	return c<=b/a? a*a*b - a*(a*(a*c)/2): a*(b*(b/c)/2);
}

dbl solve(dbl a, dbl b, dbl x){
	dbl ok = PI/2;
	dbl ng = 0;
	dbl volume = 0;
	while(abs(x - volume) >= EPS){
		dbl mid = (ok+ng)/2;// mid: この角度でどれだけ水を入れられるか？
		volume = f(a,b,mid);
		if(volume <= x) ok = mid;// 角度を小さくして、もっと多く入るようにする
		else ng = mid;// 角度を大きくして、もっと少なく入るようにする
	}
	return ok;
}

int main(){
	dbl a,b,x; cin>>a>>b>>x;
	printf("%.10f\n", DEG(solve(a, b, x)));
}

### FIXED CODE ###

# D - Water Bottle
from math import atan, degrees
a,b,x = map(float, input().split())
s = x/a
print( degrees( atan( b/(s/b*2) if s<a*b/2 else (b-s/a)*2/a ) ) )
c = input()
if 'a' in 'aeiuo'.split(''):
    print('vowel')
else:
    print('consonant')

### FIXED CODE ###

c = input()
if c in 'aeiuo':
    print('vowel')
else:
    print('consonant')
x = input()
y = x * x * X
print(y)

### FIXED CODE ###

x = int(input())
y = x * x * x
print(y)
n,q=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
val=[0 for _ in range(n)]
ans=[0 for _ in range(n)]
def dfs(u,par):
    if par!=-1:
        ans[u]=val[u]+ans[par]
    else:
        ans[u]=val[u]
    for v in g[u]:
        if v==par:
            continue
        dfs(v,u)
for _ in range(q):
    p,x=map(int,input().split())
    p-=1
    val[p]+=x
dfs(0,-1)
print(' '.join(map(str,ans)))


### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
n,q=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
ans=[0 for _ in range(n)]
def dfs(u,par):
    if par!=-1:
        ans[u]+=ans[par]
    for v in g[u]:
        if v==par:
            continue
        dfs(v,u)
for _ in range(q):
    p,x=map(int,input().split())
    p-=1
    ans[p]+=x
dfs(0,-1)
print(*ans)
import bisect

N,K = map(int,input().split())
N = [int(n) for n in str(N)]
D = set(map(int,input().split()))
nums = []
for i in range(10):
  if i not in D:nums.append(i)

if len(nums) == 0:
  print(''.join([str(n) for n in N]))
  exit()

nums.sort()

i = len(N)-1
while i>=0:
  if N[i] not in nums:
    if nums[-1] < N[i]:
      prv_len = len(N)
      tmp_N = [int(s) for s in str(int(''.join([str(n) for n in N[:i]])) + 1)]
      N = tmp_N + [nums[0]]
      if len(N) > prv_len: i += 1
    else:
      j = bisect.bisect(nums,N[i])
      j = j if j != -1 else 0
      N[i] = nums[j]
  i -= 1
print(''.join([str(n) for n in N]))

### FIXED CODE ###

import bisect

N,K = map(int,input().split())
N = [int(n) for n in str(N)]
D = set(map(int,input().split()))
nums = []
for i in range(10):
  if i not in D:nums.append(i)
nums.sort()

i = len(N)-1
while i>=0:
  if N[i] not in nums:
    if nums[-1] < N[i]:
      prv_len = len(N)
      tmp_N = [int(s) for s in str(int(''.join([str(n) for n in N[:i]])) + 1)] if len(N[:i])>0 else [1]
      N = tmp_N + [nums[0] for _ in range(prv_len-i)]
      if len(N) > prv_len: i += 1
    else:
      j = bisect.bisect(nums,N[i])
      N[i:] = [nums[j]] + [nums[0] for _ in range(len(N)-i-1)]
  #print(i,N)
  i -= 1
print(''.join([str(n) for n in N]))
#print(N)
H,W,N = map(int,input().split())
count = [[0]*(W-2) for i in range(H-2)]
for i in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0,a-2),min(a+1,H-2)):
        for j in range(max(0,b-2),min(b+1,W-2)):
            count[i][j] += 1
ans = [0]*10
for i in range(H-2):
    for j in range(W-2):
        ans[count[i][j]] += 1
for i in range(10):
    print(ans[i])

### FIXED CODE ###

H,W,N = map(int,input().split())
count = []
L = 0
for i in range(N):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(max(0,a-2),min(a+1,H-2)):
        for j in range(max(0,b-2),min(b+1,W-2)):
            count.append((i,j))
            L += 1
count.sort()
ans = [0]*10
tmp = 1
for i in range(L-1):
    if count[i] == count[i+1]:
        tmp += 1
    else:
        ans[tmp] += 1
        tmp = 1
if L>=1:
  ans[tmp] += 1
ans[0] = (H-2)*(W-2)-sum(ans)
for i in range(10):
    print(ans[i])
import math
A,B,H,M=map(int, input.split())
a=math.pi
b=math.cos(a*((48H+M)/360))
Z=A**2+B**2-2ABb
print(Z**(1/2))

### FIXED CODE ###

import math
A,B,H,M=map(int, input().split())
a=math.pi
b=math.cos(a*((60*H-11*M)/360))
Z=A**2+B**2-2*A*B*b
print(Z**(1/2))
from itertools import product
import numpy as np

h, w, k = list(map(int, input().split()))
s = [list(map(int, list(input()))) for i in range(h)]
INF = float("inf")
ans = INF
for bits in product([0, 1], repeat=h-1):
    cnt = sum(bits)
    cuts = [0]+[i + 1 for i, x in enumerate(bits) if x == 1]+[h]
    data = [[0]*w for _ in range(len(cuts)-1)]
    for i in range(len(cuts)-1):
        target = s[cuts[i]:cuts[i+1]]
        for tt in target:
            for j, t in enumerate(tt):
                data[i][j] += t
    check = [[0]*(w+1) for _ in range(len(data))]
    flag = False
    for j in range(w):
        if flag:
            continue
        change = False
        for i in range(len(data)):
            if check[i][j] + data[i][j] > k:
                change = True
                break
        if change:
            for i in range(len(data)):
                if data[i][j] <= k:
                    check[i][j+1] = data[i][j]
                else:
                    flag = True
                    break
            cnt += 1
        else:
            for i in range(len(data)):
                check[i][j+1] = check[i][j] + data[i][j]
    if flag:
        continue
    ans = min(ans, cnt)
print(ans)


### FIXED CODE ###

from itertools import product

h, w, k = list(map(int, input().split()))
s = [list(map(int, list(input()))) for i in range(h)]
INF = float("inf")
ans = INF
for bits in product([0, 1], repeat=h-1):
    cnt = sum(bits)
    cuts = [0]+[i + 1 for i, x in enumerate(bits) if x == 1]+[h]
    data = [[0]*w for _ in range(len(cuts)-1)]
    for i in range(len(cuts)-1):
        target = s[cuts[i]:cuts[i+1]]
        for tt in target:
            for j, t in enumerate(tt):
                data[i][j] += t
    check = [[0]*(w+1) for _ in range(len(data))]
    flag = False
    for j in range(w):
        if flag:
            continue
        change = False
        for i in range(len(data)):
            if check[i][j] + data[i][j] > k:
                change = True
                break
        if change:
            for i in range(len(data)):
                if data[i][j] <= k:
                    check[i][j+1] = data[i][j]
                else:
                    flag = True
                    break
            cnt += 1
        else:
            for i in range(len(data)):
                check[i][j+1] = check[i][j] + data[i][j]
    if flag:
        continue
    ans = min(ans, cnt)
print(ans)
n=int(input())
if n%2==0 or n%5==0:
    print(-1)
else:
    count=1
    flag=0
    num=7
    while flag==0:
        if num%n==0:
            flag=1
        else:
            num=num*10+7
            count=count+1
print(count)



### FIXED CODE ###

n=int(input())
if n%2==0 or n%5==0:
    print(-1)
else:
    count=1
    flag=0
    num=7
    mod=7%n
    while flag==0:
        if mod==0:
            flag=1
        else:
            mod=(mod*10+7)%n
            count=count+1
    print(count)
from sys import stdin

s = stdin.readline().rstrip()

ans = "Yes"
for i in range(0, 9, 2):
    if s[i] + s[i+1] != "hi":
        ans = "No"
        break

print(ans)


### FIXED CODE ###

from sys import stdin

s = stdin.readline().rstrip()

ans = "Yes"
if len(s)%2 != 0:
    ans = "No"
else:
    for i in range(0, len(s), 2):
        if s[i] + s[i+1] != "hi":
            ans = "No"
print(ans)
h, w = map(int, input().split())
s_input = []
for i in range(h):
    s_input.append(input())

can_draw = True

for i in range(h):
    for j in range(w):
        if s_input[i][j] == '#':
            if i - 1 >= 0:
                if s_input[i-1][j] == '#':
                    #ok
                    continue
            if j - 1 >= 0:
                if s_input[i][j - 1] == '#':
                    #ok
                    continue
            if j + 1 <= w:
                if s_input[i][j + 1] == '#':
                    #ok
                    continue
            if i + 1 <= h:
                if s_input[i + 1][j] == '#':
                    #ok
                    continue
            can_draw = False
            break
    if not can_draw:
        break

print('Yes' if can_draw else 'No')

### FIXED CODE ###

h, w = map(int, input().split())
s_input = []
for i in range(h):
    s_input.append(input())

can_draw = True

for i in range(h):
    for j in range(w):
        if s_input[i][j] == '#':
            if i - 1 >= 0:
                if s_input[i - 1][j] == '#':
                    #ok
                    continue
            if j - 1 >= 0:
                if s_input[i][j - 1] == '#':
                    #ok
                    continue
            if j + 1 < w:
                if s_input[i][j + 1] == '#':
                    #ok
                    continue
            if i + 1 < h:
                if s_input[i + 1][j] == '#':
                    #ok
                    continue
            can_draw = False
            break
    if not can_draw:
        break

print('Yes' if can_draw else 'No')
abc = input()
x = 0
for i range(0,3):
  if abc[i] == "1":
  	x += 1
print(x)

### FIXED CODE ###

abc = input()
x = 0
for i in range(0,3):
  if abc[i] == "1":
  	x += 1
print(x)
s = input().strip()
x,y = map(int,input().split())
AX = []
AY = []
flag = 0
cnt = 0
for i in range(len(s)):
    if s[i]=="F":
        cnt += 1
    else:
        if flag==0:
            AX.append(cnt)
            cnt = 0
            flag = 1
        else:
            AY.append(cnt)
            cnt = 0
            flag = 0
if cnt>0 and flag==0:
    AX.append(cnt)
if cnt>0 and flag==1:
    AY.append(cnt)
Nx = sum(AX)
dpX = [[0 for _ in range(2*Nx+1)] for _ in range(len(AX)+1)]
if s[0]=="F":
    dpX[1][Nx+AX[0]] = 1
    for i in range(1,len(AX)):
        for j in range(2*Nx+1):
            if 0<=j+AX[i]<=2*Nx:
                dpX[i+1][j+AX[i]] = dpX[i+1][j+AX[i]] or dpX[i][j]
            if 0<=j-AX[i]<=2*Nx:
                dpX[i+1][j-AX[i]] = dpX[i+1][j-AX[i]] or dpX[i][j]
else:
    dpX[0][Nx] = 1
    for i in range(len(AX)):
        for j in range(2*Nx+1):
            if 0<=j+AX[i]<=2*Nx:
                dpX[i+1][j+AX[i]] = dpX[i+1][j+AX[i]] or dpX[i][j]
            if 0<=j-AX[i]<=2*Nx:
                dpX[i+1][j-AX[i]] = dpX[i+1][j-AX[i]] or dpX[i][j]
dpY = [[0 for _ in range(2*N+1)] for _ in range(len(AY)+1)]
Ny = sum(AY)
dpY[0][Ny] = 1
for i in range(len(AY)):
    for j in range(2*Ny+1):
        if 0<=j+AY[i]<=2*Ny:
            dpY[i+1][j+AY[i]] = dpY[i+1][j+AY[i]] or dpY[i][j]
        if 0<=j-AY[i]<=2*Ny:
            dpY[i+1][j-AY[i]] = dpY[i+1][j-AY[i]] or dpY[i][j]
if dpX[len(AX)][Ny+x]==1 and dpY[len(AY)][Ny+y]==1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input().strip()
x,y = map(int,input().split())
C = {}
cur = 0
cnt = 0
for i in range(len(s)):
    if s[i]=="F":
        cnt += 1
    else:
        C[cur] = cnt
        cur += 1
        cnt = 0
C[cur] = cnt
AX = []
AY = []
for a in C:
    if a>0 and a%2==0 and C[a]>0:
        AX.append(C[a])
    elif a%2==1 and C[a]>0:
        AY.append(C[a])
cntx = sum(AX)
dpx = [[0 for _ in range(2*cntx+1)] for _ in range(len(AX)+1)]
dpx[0][cntx] = 1
if cntx>0:
    dpx[1][cntx-AX[0]] = 1
    dpx[1][cntx+AX[0]] = 1
    for i in range(2,len(AX)+1):
        for j in range(-cntx,cntx+1):
            if -cntx<=j-AX[i-1]:
                dpx[i][j+cntx] = dpx[i-1][j-AX[i-1]+cntx]
                if j+AX[i-1]<=cntx:
                    dpx[i][j+cntx] = max(dpx[i][j+cntx],dpx[i-1][j+AX[i-1]+cntx])
            elif j+AX[i-1]<=cntx:
                dpx[i][j+cntx] = dpx[i-1][j+AX[i-1]+cntx]
cnty = sum(AY)
dpy = [[0 for _ in range(2*cnty+1)] for _ in range(len(AY)+1)]
dpy[0][cnty] = 1
if cnty>0:
    dpy[1][cnty-AY[0]] = 1
    dpy[1][cnty+AY[0]] = 1
    for i in range(2,len(AY)+1):
        for j in range(-cnty,cnty+1):
            if -cnty<=j-AY[i-1]:
                dpy[i][j+cnty] = dpy[i-1][j-AY[i-1]+cnty]
                if j+AY[i-1]<=cnty:
                    dpy[i][j+cnty] = max(dpy[i][j+cnty],dpy[i-1][j+AY[i-1]+cnty])
            elif j+AY[i-1]<=cnty:
                dpy[i][j+cnty] = dpy[i-1][j+AY[i-1]+cnty]
if C[0]-cntx<=x<=C[0]+cntx and dpx[len(AX)][x-C[0]+cntx]==1 and -cnty<=y<=cnty and dpy[len(AY)][y+cnty]==1:
    print("Yes")
else:
    print("No")
N = int(input())
S = input()
 
lE = [0] * N 
lW = [0] * N 
le = lw = 0 
for i in range(N):
    if S[i] == "E":
        le += 1
    else:
        lw += 1
    lE[i] = le
    lW[i] = lw
 
rtn = lE[-1] - lE[0] 
 
for i in range(1, N - 1): 
    tmp = lW[i-1] + lE[-1] - lE[i]
    if tmp <= rtn:
        rtn = tmp 
 
most_east = lW[-2] 
if most_east <= rtn:
    rtn = count
 
print(rtn)

### FIXED CODE ###

N = int(input())
S = input()

lE = [0] * N
lW = [0] * N
le = lw = 0
for i in range(N):
    if S[i] == "E":
        le += 1
    else:
        lw += 1
    lE[i] = le
    lW[i] = lw

rtn = lE[-1] - lE[0]

for i in range(1, N):
    tmp = lW[i-1] + lE[-1] - lE[i]
    if tmp <= rtn:
        rtn = tmp


print(rtn)
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)


N = int(input())
T = []

for _ in range(N):
    T.append(int(input()))


ans = T[0]
for t in T:
    ans = lcm(ans, t)

print(ans)

### FIXED CODE ###

import math


def gcd(x, y):
    while (y):
        x, y = y, x % y
    return x


def lcm(x, y):
    return (x * y) // gcd(x, y)


N = int(input())
T = []

for _ in range(N):
    T.append(int(input()))

ans = T[0]

for t in T:
    ans = lcm(ans, t)

print(ans)
n = int(input())
s = list(input())

A_index = [i for i, x in enumerate(s) if x == 'A']
print(A_index)

count = 0
for j in A_index :
  print(j)
  if j != n-2 :
    if s[j+1] == 'B' :
      if s[j+2] == 'C' :
        count += 1

print(count)

### FIXED CODE ###

n = int(input())
s = list(input())

A_index = [i for i, x in enumerate(s) if x == 'A']

count = 0
for j in A_index :
  if j != n-1 :
    if s[j+1] == 'B' :
      if j != n-2 :
        if s[j+2] == 'C' :
          count += 1

print(count)
N=int(input())
A=[0]*10**5
b=input().split()
numbers=[int(a) for a in b]
for a in numbers:
    A[a-1]+=1
list=[]
for z in range(10**5-1):
    y=A[z]+A[z+1]+A[z+2]
    list.append(y)
print(max(list))


### FIXED CODE ###

N=int(input())
A=[0]*(10**5+1)
b=input().split()
numbers=[int(a) for a in b]
for a in numbers:
    A[a]+=1
list=[]
for z in range(10**5-1):
    y=A[z]+A[z+1]+A[z+2]
    list.append(y)
print(max(list))
if __name__=="__main__":
    [s]	= map(int, input().split())
    q =	int(s / 11)
    r =	s % 11
    if(r != 0):
	r = int((r-1)/6 + 1)

    print(2*q + r)

### FIXED CODE ###

if __name__=="__main__":
    [s] = map(int, input().split())
    q = int(s / 11)
    r = s % 11
    if(r!=0):
        r = int((r-1)/6 + 1)
    print(2*q + r)
n, m = map(int, input().split())

a = [0] * n
b = [0] * m

for i in range(n):
    a[i] = list(map(int, input().split()))

for i in range(n):
    b[i] = int(input())

for i in range(m):
    ret = 0
    for j in range(n):
        ret += a[i][j] * b[j]    
    print(ret)
    



### FIXED CODE ###

#
# 6d
#


def main():
    n, m = map(int, input().split())
    A = [[0 for i in range(m)] for j in range(n)]
    B = [0 for i in range(m)]
    C = [0 for i in range(n)]
    for i in range(n):
        A[i] = list(map(int, input().split()))
    for i in range(m):
        B[i] = int(input())

    for i in range(n):
        for j in range(m):
            C[i] += A[i][j] * B[j]
        print(C[i])


if __name__ == '__main__':
    main()
N, W = map(int, input().split())
item = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*(N+1) for w in range(W+1)]
for w in range(1, W+1):
    for i in range(N):
        if w - item[i][0] >= 0:
            dp[w][i+1] = max(
                dp[w][i],
                dp[w-item[i][0]][i] + item[i][1]
            )
        else:
            dp[w][i+1] = dp[w][i]
print((dp[N][W]))




### FIXED CODE ###

n, w = map(int, input().split())

inf = 10 ** 10
dp = [[inf] * (10**5+3) for _ in range(n+1)]
dp[0][0] = 0
for i in range(n):
    weight, value = map(int, input().split())
    for j in range(10**5 + 3):
        if j - value >= 0:
            dp[i+1][j] = min(
                dp[i][j - value] + weight,
                dp[i][j]
            )
        else:
            dp[i+1][j] = dp[i][j]
for i in reversed(range(10**5+3)):
    if dp[n][i] <= w:
        print(i)
        break
N=input()
j_count=0
for i in range(0,3):
    if N[i]==N[i+1]:
        j_count+=1

if j_count>=2　and N[1]==N[2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N=input()
j_count=0
for i in range(0,3):
    if N[i]==N[i+1]:
        j_count+=1
if j_count>=2 and N[1]==N[2]:
    print("Yes")
else:
    print("No")
def dfs(node, paths, visited, n):
  # 全て訪問済みだったら全部を訪問できる経路として1を返す
  if not False in visited:
    return 1

  count = 0

  for nn in paths[node]:
    # 既に訪問済みなら処理をしない
    if(visited[nn]):
      continue

    visited[nn] = True
    count += dfs(nn, paths, visited, n)
    visited[nn] = False

  return count

def main():
  N, M = list(map(int, input().split()))
  paths = [[] for i in range(N)]
  visited = [False] * N

  for i in range(M):
    a, b = list(map(int, input().split()))
    paths[a-1].append(b-1)
    paths[b-1].append(a-1)

  visited[0] = True
  print(dfs(0, paths, visited, N))


if __name__ == "__main__":
    main()

### FIXED CODE ###

import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

patterns = list(itertools.permutations(list(range(1,N+1))))

pi = 0
qi = 0

for index, pattern in enumerate(patterns):
  if P == pattern:
    pi = index
  if Q == pattern:
    qi = index

print(abs(pi - qi))
# スペース区切りの整数の入力
bit = map(str, input().split())
length = len(bit)

num0 = 0
num1 = 0

for i in range(length):
    if bit[i] == '0':
        num0 += 1
    else:
        num1 += 1

K = max(num0, num1)
        
print(K)

### FIXED CODE ###

S = input()
n = len(S)

prev = None
cand = []
for i in range(n):
    if i != 0:
        if S[i] != prev:
            cand.append(max(i, n-i))
    prev = S[i]    
if cand:
    print(min(cand))
else:
    print(n)
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(revese = True)
sum_l=0
for i in range(0,k):
    sum_l+=l[i]

print(sum_l)

### FIXED CODE ###

n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse = True)
sum_l=0
for i in range(0,k):
    sum_l+=l[i]

print(sum_l)
N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = []
for i in range(M):
    b,c = map(int,input().split())
    BC.append([b,c])
BC.sort(key=lambda x:x[1], reverse=True)

A.sort()

i = 0
j = 0
while i < N and j < M:
    while BC[j][1] > A[i]:
        if BC[j][0] < 1:
            j += 1
            continue
        A[i] = BC[j][1]
        BC[j][0] -= 1
        i += 1
    break

print(sum(A))

### FIXED CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
BC = []
for i in range(M):
    b,c = map(int,input().split())
    BC.append([b,c])
BC.sort(key=lambda x:x[1], reverse=True)
# print(BC)

A.sort()

i = 0
j = 0
while i < N and j < M and BC[j][1] > A[i]:
    if BC[j][0] < 1:
        j += 1
        continue
    A[i] = BC[j][1]
    BC[j][0] -= 1
    i += 1

print(sum(A))
import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
else:
    gcd = fractions.gcd(a[0],a[1])
    for i in range(2,n):
        gcd = fractions.gcd(gcd,a[i])
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)

### FIXED CODE ###

import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
elif n == 1:
    if a[0] == k:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
else:
    gcd = fractions.gcd(a[0],a[1])
    for i in range(0,n):
        gcd = fractions.gcd(gcd,a[i])
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)