peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
h, n = (int(x) for x in input().split())
A = list(map(int, input().split()))

if n == len(A):
    if sum(A) >= h:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
N,M=map(int,input().split(' '))
ans = 0
for i in range(1,int(pow(M,0.5)+2)):
    if M%i==0 and M//i >=N:
        ans=i
    elif M%i==0:
        break
print(ans)
# Judge status: Accepted
q, h, s, d = list(map(int, input().split()))
n = int(input())
qpl = 4 * q
hpl = 2 * h
spl = s
dpl = d / 2
s_min = min(qpl, hpl, spl)
if dpl >= s_min:
    print(s_min * n)
elif n % 2 == 0:
    print(d * (n // 2))
else:
    print(d * (n // 2) + s_min)
# Judge status: Accepted
q,h,s,d = map(int, input().split())
n = int(input())

if q*2 < h: h = q*2
if h*2 < s: s = h*2
if s*2 < d: d = s*2
print(n//2*d + n%2*s)
# Judge status: Accepted
n,a,b = map(int,input().split())
s = list(input())
x = a + b
xb = b
for i in range(n):
    if s[i] == "c" or x == 0:
        print("No")
    else:
        if s[i] == "b":
            if xb == 0:
                print("No")
            else:
                print("Yes")
                x -= 1
                xb -= 1
        else:
            print("Yes")
            x -= 1
# Judge status: Wrong Answer
K=int(input())
lunlun=[1,2,3,4,5,6,7,8,9]
a=10
b=0
if K<10:
  print(lunlun[K-1])
else:
  while True:
    for i in str(a):
      if abs(int(i)-b)>1:
        break
      else:
        b=int(i)
    else:
      lunlun.append(int(i))
    if len(lunlun)>=K:
    	break
    a += 1
print(a)
# Judge status: Wrong Answer
#!/usr/bin/env python3
import sys
import math

def main():
    N = int(input())
    digit = math.floor(math.log10(N))
    c = int(str(N)[0])
    if N == (1 + c) * 10 ** digit - 1:
        print(9 * digit + c)
    else:
        print(9 * digit + c -1)


if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B, K = map(int, input().split())
def split_A_K_B(A, B, K):
    if K >= A:
        K -= A
        A = 0
    else:
        A -= K
        return A, B
    if K >= B:
        K -= B
        B = 0
    else:
        B -= K
    return A, B
A, B = split_A_K_B(A, B, K)
print("{} {}".format(A, B))
# Judge status: Wrong Answer
import sys
A, B, C = list(map(int, input().split()))

i = 1
tmp = A

if A%2 == 0 and C%2 ==1:
  print("NO")
  sys.exit()

while i<101:
  if tmp%B != C:
    i = i + 1
    tmp = tmp +  i * A
  else:
    print("YES")
    sys.exit()
print("NO")
# Judge status: Wrong Answer
a,b,c,d=0,0,0,0
N=int(input())
S=[input() for _ in range(N)]
for i in range(N):
    if S[i]=='AC':
        a=a+1
    elif S[i]=='WA':
        b=b+1
    elif S[i]=='TLE':
        c=c+1
    elif S[i]=='RE':
        d=d+1
print('AC x　{}'.format(a))        
print('WA ×　{}'.format(b))       
print('TLE ×　{}'.format(c))       
print('RE ×　{}'.format(d))
# Judge status: Accepted
#!/usr/bin/env python3

def main():
    N, A, B, C, D = map(int, input().split())
    S = input()
    ans = 'Yes'
    if C <D:
        if '##' in S[B-1:D] or '##' in S[A-1:C]:
            ans = 'No'
    else:
        if '##' in S[A-1:C] or '...' not in S[B-2:D+1]:
            ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
r=int(input())
a=r*r*(math.pi)
b=1*1*(math.pi)
print(int(a/b))
# Judge status: Accepted
l,r = map(int,input().split())
if r-l >= 673:
    print(0)
else:
    ans = 2018
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = min(ans,i*j%2019)
    print(ans)
# Judge status: Accepted
n, k = map(int,input().split())
print(min(n%k, abs((n%k)-k)))
# Judge status: Accepted
import bisect

N = int(input())
a = set(map(int,input().split()))
A = sorted(list(a))
M = max(A)
num = M//2

index = bisect.bisect_right(A,num)

if index > 0 and abs(num - A[index]) > abs(num - A[index-1]):
    index = index-1
#print(index)

if M != A[index]:
    print(M,A[index])
else:
    print(M,A[index-1])
# Judge status: Accepted
import heapq

N,M = (int(x) for x in input().split())
AB = []
sum = 0

for i in range(N):
    a,b = (int(x) for x in input().split())
    AB.append([a,b])

AB = sorted(AB , key = lambda x : x[0])
heap = []
j = 0

for i in range(M+1):
    while j<N and AB[j][0] < i+1:
        heapq.heappush(heap,-AB[j][1])
        j += 1

    if len(heap):
        sum += -heapq.heappop(heap)
                           
print(sum)
# Judge status: Accepted
a = int(input())
b = int(input())

ans_list = [1, 2, 3]

ans_list.remove(a)
ans_list.remove(b)
print(ans_list[-1])
# Judge status: Accepted
N, K = map(int,input().split())
sunuke_dict = dict()

for _ in range(K):
    d = input()
    s_list = input().split()

    for s_id in s_list:
        if s_id not in sunuke_dict:
            sunuke_dict[s_id] = [d]
        else:
            sunuke_dict[s_id].append(d)

print(N - len(sunuke_dict))
# Judge status: Accepted
s = input()
ans,cnt = 0,0
for l in s:
  if l=='R':
    cnt += 1
    ans = max(ans,cnt)
  else:
    ans = max(cnt,ans)
    cnt = 0
print(ans)
# Judge status: Wrong Answer
import numpy as np
a, b, x = map(int, input().split())
print(np.degrees(np.arctan(\
2.0*(np.power(a, 2.0)*b-x)*np.power(a,-3.0)\
)))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

ok = []
no_and_no_even = []
no_and_even = []
for i in range(N):
    if (A[i] % 4 == 0):
        ok.append(A[i])
    elif (A[i] % 4 != 0 and A[i] % 2 == 0):
        no_and_even.append(A[i])
    else:
        no_and_no_even.append(A[i])

if (len(ok) == 0 and len(no_and_no_even) != 0):
    print('No')
    exit()


if (len(ok) == len(no_and_no_even) or len(ok) == len(no_and_no_even) - 1):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
x = int(input())
#n, m = map(int, sys.stdin.readline().split())
#s = input()
#h = list(map(int, sys.stdin.readline().split()))

for i in range(1, 1000):
    for j in range(-1000, 1000):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            sys.exit()
# Judge status: Wrong Answer
N=int(input())
a=[]
I=[]
A=[]
for i in range(N):
    I.append(i+1)
    a.append(int(input()))
for i in range(N):
    A.append([I[i],a[i]])
B=A[0]
C=0
D=[]
for i in range(N):
    for j in range(N):
        if B[1]==A[j][0]:
            C+=1
            B=A[j]
            D.append(B[1])
        if B[1]==2:
            break
if 2 not in D:
    print('-1')
else:
    print(C+1)
# Judge status: Accepted
S = input().split()
print("A"+S[1][0]+"C")
# Judge status: Wrong Answer
N = int(input())
A =list(map(int, input().split()))
minus = [i for i in A if i < 0]
if len(minus) % 2 == 0:
  max_num = [abs(i) for i in A]
else:
  max_num = [abs(i) for i in A]
  if min(max_num) in A:
    print(sum(max_num) - 2*min(max_num))
  else:
    print(sum(max_num) + min(max_num))
# Judge status: Accepted
from collections import Counter

w = list(input())
c = Counter(w)
for v in c.values():
    if v % 2 != 0:
        print('No')
        break
else:
    print('Yes')
# Judge status: Accepted
B = [0] * 8
n = int(input())
A = list(map(int, input().split()))
t = 0
for i in A:
    if i < 3200:
        a = i//400
        B[a] += 1
    else:
        t += 1

c = 0
for i in B:
    if i!= 0:
        c += 1

print(max(c, 1),c+t)
# Judge status: Wrong Answer
#整数の入力
N = int(input())

ans = 1


for i in range(N):
  ans = ans * (i+1)
  
print(ans)
# Judge status: Accepted
n = int(input())
ans = ''
while n != 0:
    if n % (-2) == 0:
        ans = '0' + ans
    else:
        ans = '1' + ans
        n -= 1
    n /= -2
if ans == '':
    ans = '0'
print(ans)
# Judge status: Accepted
N = int(input())
S = list(str(input()))
WH = S.count(".")
ans = WH
for i in range(N):
  if S[i] == "#":
    WH += 1
  else:
    WH -= 1
  ans = min(ans, WH)

print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

ans = 0

if d > a:
    ans += a
else:
    ans += d

if d-a-b > c:
    ans -= c
else:
    ans -= d-a-b

print(ans)
# Judge status: Accepted
a , b =(map(int , input().split()))

if a==1:
  a=a+13

if b==1:
  b=b+13
  
if a>b :
  print("Alice")

elif a<b:
  print("Bob")

else:
  print("Draw")
# Judge status: Wrong Answer
a =int( input())
_number=0;_kaerichi="No"
for i in range(a):
    b, c = map(int, input().split())
    if(b==c):
        _number+=1
    if(_number==3):
        _kaerichi="Yes"
print(_kaerichi)
# Judge status: Accepted
def is_month(x):
  if 1 <= x <= 12:
    return True
  else:
    return False

S = input()
first, latter = is_month(int(S[:2])), is_month(int(S[2:]))
if first and latter:
  ans = "AMBIGUOUS"
elif not first and not latter:
  ans = "NA"
elif first:
  ans = "MMYY"
else:
  ans = "YYMM"
print(ans)
# Judge status: Wrong Answer
N = input()
P = input().split(' ')

for i, Pi in enumerate(P):
    if i == 0:
        count = 1
    elif Pi<= min(P[0:i]):
        count = count +1
print(count)
# Judge status: Wrong Answer
s = input()

if s == "ABC" :
  print("ARC")

else :
  print("ARC")
# Judge status: Wrong Answer
N = int(input())
c = list(input())
count = 0

def getLeftR(c, currentIndex):
    for i in range(currentIndex+1, N):
        if c[i] == 'W':
            return i
    return -1

for i in range(N-1):
    if c[i] == 'W' and c[i+1] == 'R':
        leftWindex = getLeftR(c, i+1)
        if leftWindex > 0:
            c[leftWindex], c[i+1] = c[i+1], c[leftWindex]
            count += 1
        else:
            break
print(count)
# Judge status: Accepted
D = int(input())
print("Christmas", "Eve "*(25-D), sep=" ")
# Judge status: Accepted
N = int(input())
List=list(map(int,input().split()))

cnt4 = 0
for i in range(N):
  a = List[i]
  if a%4 == 0:
    cnt4 += 1

cnt2 = 0
for i in range(N):
  a = List[i]
  if a%2 == 0:
    cnt2 += 1
cnt2 = int(cnt2 - cnt4)

if cnt2 == 0:
  if cnt4 >= N -cnt4 -1:
    print("Yes")
  else:
    print("No")
else:
  if cnt4-1 >= (N-cnt2) -cnt4-1:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
n,m=list(map(int,input().split()))
print(str(int(n*(n-1)/2+m*(m-1)/2)))
# Judge status: Wrong Answer
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
f = int(s[:2])
l = int(s[2:])

if 1 <= f <= 12 and 1 <= l <= 12:
    print('AMBIGUOUS')

elif 1 <= l <= 12 and f > 12:
    print('YYMM')

elif 1 <= f <= 12 and l > 12:
    print('MMYY')

else:
    print('NA')
# Judge status: Accepted
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
ans = 0

for n in sorted(ab, key=lambda x: x[0]):
    cnt += n[1]
    if cnt >= K:
        ans = n[0]
        break

print(ans)
# Judge status: Accepted

def FindPrime(X):
    while(True):
        if isPrime(X):
            break
        else:
            X += 1

    print(X)

def isPrime(X):
    ans = True
    for i in range(2, X//2):
        if(X % i == 0):
            ans = False
            break
    return ans

if __name__ == '__main__':
    X = int(input())
    FindPrime(X)
# Judge status: Accepted
f=lambda:[*map(int,input().split())]
n,m=f()
p=sorted((f()) for _ in range(n))
c=0
for a,b in p:
  if m>b:
    c+=a*b
    m-=b
  else:
    c+=a*m
    break
print(c)
# Judge status: Accepted
N = int(input())
L = list(map(int,input().split()))
M = set(L)
if len(L) == len(M):
    print('YES')
else:
    print('NO')
# Judge status: Accepted
# -*- coding: utf-8 -*-
import math

a,b = map(int, input().split())
x = 0

for n in range(25):
  l = (25 * a + n) % 2
  m = 25 * a + n
  if(l == 0):
    if((m/2 - 10 * b) == int(m/2 - 10 * b) and (m/2 - 10 * b) < 10 and (m/2 - 10 * b) >= 0):
      x = int(m/2)
      break
  if(n == 24):
    x = -1
    break
    
print("{}".format(x))
# Judge status: Accepted
a = list(map(int,input().split()))
M = max(a)
if (3 * M - sum(a))%2 == 0:
    print((3 * M - sum(a))//2)
else:
    print((3 * (M+1) - sum(a))//2)
# Judge status: Wrong Answer
l=input().split()
print(l.count('1'))
# Judge status: Accepted
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
dp=[0]*N
data={'r':P,'s':R,'p':S}
ans=0
for i in range(N):
  if 0<=i-K:
    if T[i-K]==T[i]:
      if dp[i-K]==0:
        ans+=data[T[i]]
        dp[i]=1
    else:
      ans+=data[T[i]]
      dp[i]=1
  else:
    dp[i]=1
    ans+=data[T[i]]
print(ans)
# Judge status: Accepted
def main():
    n,k,s = map(int,input().split())
    ans = []
    if s<10**9:
        for i in range(k):
            ans.append(str(s))
        for i in range(k,n):
            ans.append(str(s+1))
        print(' '.join(ans))
    else:
        for i in range(k):
            ans.append(str(s))
        for i in range(k,n):
            ans.append(str(1))
        print(' '.join(ans))


if __name__=='__main__':
    main()
# Judge status: Accepted
def resolve():
    X, A, B = map(int, input().split())
    print("delicious" if A>=B else "dangerous" if A+X<B else "safe")
resolve()
# Judge status: Accepted
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    X = LI()

    ans = 10 ** 9

    for i in range(1, 101):
        sum_temp = 0
        for x in X:
            sum_temp += (x - i) ** 2

        if sum_temp <= ans:
            ans = sum_temp
    print(ans)


main()
# Judge status: Wrong Answer
N = int(input())
S = input()
m = N - 1
n = int(N / 2)
n0 = n - 1
if len(S) % 2 == 1:
  print('No')
else:
  for i in range(n):
    if S[i] == S[i + n0]:
      print('Yes')
      exit(0)
  print('No')
# Judge status: Wrong Answer
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

X.sort(key=lambda x: (-x[1], -x[0]))
ans = 0
t = 0
for i in range(N):
    if t + X[i][0] <= M:
        ans += X[i][1]
    t += 1

print(ans)
# Judge status: Accepted
k = int(input())
s = str(input())
if len(s) <= k:
    print(s)
else:
    ans = s[0:k]+'...'
    print(ans)
# Judge status: Wrong Answer
n  = int(input())
 
count = 1
for i in range(0,n):
  count += count
print(count)
# Judge status: Accepted
a, b, x = map(int, input().split())
n = 'YES'
if a > x:
  n = 'NO'
elif a+b < x:
  n = 'NO'
print(n)
# Judge status: Accepted
s = input()
k = int(input())
ans = ""
for i in range(len(s)-1):
    cost = ord("z")+1-ord(s[i])
    if s[i] == "a" or k < cost:
        ans += s[i]
    else:
        ans += "a"
        k -= cost
c = s[-1]
k %= 26
for _ in range(k):
    if c == "z": c = "a"
    else: c = chr(ord(c)+1)
ans += c
print(ans)
# Judge status: Accepted
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
for s in ["AC","WA","TLE","RE"]:
	print("{} x {}".format(s,cnt[s]))
# Judge status: Accepted
a, b, c = map(int, input().split())
for i in range(100):
    if (b*i+c)%a == 0:
        print('YES')
        exit(0)
print('NO')
# Judge status: Accepted
import sys
N = int(input())
c = str(input())

if "W" not in c or "R" not in c:
  print("0")
  sys.exit()

red = c.count("R")
stay_red = c.count("R", 0, red)
print(red - stay_red)
# Judge status: Wrong Answer
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

ans = A[0][0] + A[1][-1]

for i in range(N - 1):
    if sum(A[0][i + 1:]) > sum(A[1][i:-1]):
        ans += A[0][i + 1]
    else:
        ans += A[1][i]

print(ans)
# Judge status: Accepted
a,b=input()
if a=="9" or b=="9":
    print("Yes")
else:
    print("No")
# Judge status: Accepted
count = 0
for i in range(int(input())):
    l = list(map(int, input().split()))
    if l[0] == l[1]:
        count += 1
    elif l[0] != l[1]:
        count = 0
    if count >= 3:
        print("Yes")
        break
if count < 3:
    print("No")
# Judge status: Wrong Answer
n=int(input())
s=input()
accum=[0]*n
if s[0]=="#":
    accum[0]=1
for i in range(n-1):
    accum[i+1]+=accum[i]+(s[i+1]=="#")
ans=10**18
for i in range(n):
    ans=min(ans,accum[i]+n-i-1-accum[n-1]+accum[i])
#print(accum)
if accum[n-1]==n:
    ans-=1
print(ans)
# Judge status: Accepted
y,m,d = input().split('/')
if int(m) > 4:
  print("TBD")
else:
  print("Heisei")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=[]
if n%2==1:
    i=n
    while i>=1:
        ans.append(str(a[i-1]))
        i-=2
    i=2
    while i<=n:
        ans.append(str(a[i-1]))
        i+=2
    print(" ".join(ans))
else:
    i = n
    while i >= 1:
        ans.append(str(a[i - 1]))
        i -= 2
    i = 1
    while i <= n:
        ans.append(str(a[i - 1]))
        i += 2
    print(" ".join(ans))
# Judge status: Accepted
N = input()

print("Yes" if N.count("7") >= 1 else "No")
# Judge status: Accepted
a=int(input())
s=str(input())
if a>=3200:
    print(s)
else:
    print('red')
# Judge status: Accepted
S = input()
if S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
elif S == 'SAT':
  print(1)
else:
  print(7)
# Judge status: Accepted
X,Y,Z=[int(s) for s in input().split()]
count=0
while(X>=Y+2*Z):
  count+=1
  X-=Y+Z
print(count)
# Judge status: Wrong Answer
import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0
for i in range(K-1,N):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)
# Judge status: Accepted
from math import gcd

n, m = map(int, input().split())
A = list(map(int, input().split()))
A = [a//2 for a in  A]
lcm = 1

for i in range(n):
    lcm = lcm * A[i] // gcd(lcm, A[i])
    if lcm > m:
        print(0)
        exit()
        
for a in A:
    if lcm // a % 2 == 0:
        print(0)
        exit()

print((m//lcm + 1) // 2)
# Judge status: Wrong Answer
A, B = map(int, input().split())
if max(A,B)<=8 :
    print("Yay!")
else :
    print(":()")
# Judge status: Accepted
n, b = map(int, input().split())
xlist = [list(map(int, input().split())) for _ in range(n)]

from itertools import combinations
import numpy as np
xnumpy = np.array(xlist)
ans = 0
for y, z in combinations(xnumpy, 2):
    distance = ((y -z)**2).sum()
    for i in range((40**2)*10):
        if distance == i*i:
            ans += 1
print(ans)
# Judge status: Accepted
n,t = map(int,input().split())
cost = []
time = []
ncost = []
f = 0
e = 0
for i in range(n):
    c,T = input().split()
    cost.append(int(c))
    time.append(int(T))

for i in time:
    if i > t:
        e += 1
    
if e == n:
    print('TLE')
    
for i in range(n):
    if time[i] <= t:
        ncost.append(cost[i])
        f = 1
    else:
        pass
if  f == 1:
    print(min(ncost))
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt1=[0]*n
cnt2=[0]*n
for i in range(n):
    if a[i]>b[i]:
        cnt2[i]=a[i]-b[i]
    else:
        num4=b[i]-a[i]
        cnt1[i]=num4//2
        cnt2[i]=num4%2
num5=abs(sum(a)-sum(b))
if sum(cnt1)<=num5 and sum(cnt2)<=num5 and (sum(cnt2)-sum(cnt1))%2==0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())

ans = [0]*N
for i in range(N-1):
    c,s,f = map(int,input().split())
    ans[i] += s+c
    for j in range(i):
        ans[j] = max((ans[j]+f-1)//f*f, s)+c
for a in ans:
    print(a)
# Judge status: Accepted
s=list(input())
#print(s)
count=0
for i in range(len(s)//2):
    if s[i]!=s[-(i+1)]:
        #print(s[i],s[-(i+1)])
        s[-(i+1)]=s[i]
        count+=1
#print("".join(s))
print(count)
# Judge status: Wrong Answer
c = str(input())

if c == 'a' and c == 'e' and c == 'i' and c == 'o' and c == 'u':
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import itertools
import math
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

maxR = [0] * n
maxL = [0] * n
maximum = 0
for i in range(n):
    maximum = max(maximum,a[i])
    maxL[i] = maximum
maximum = 0
for i in range(n):
    maximum = max(maximum,a[n-i-1])
    maxR[n-i-1] = maximum


print(maxR[0])
for i in range(1,n-1):
    print(max(maxL[i-1],maxR[i+1]))
print(maxL[n-1])
# Judge status: Accepted
N = int(input())

s = set()
a = 1
while a <= 100000:
    s.add(a)
    a *= 6
a = 1
while a <= 100000:
    s.add(a)
    a *= 9
s = sorted(s)

INF = float('inf')
dp = [INF] * (N+1)
dp[0] = 0
for i in range(N):
    for a in s:
        if i+a > N: break
        dp[i+a] = min(dp[i+a], dp[i] + 1)
print(dp[N])
# Judge status: Wrong Answer
N = int(input())
x = list(map(int, input().split(' ')))
y = list(map(int, input().split(' ')))

def down_count():
    count = x[0]
    for i in range(N):
        count += y[i]
    return count

def switch_count(count):
    global down_sum
    for i in range(N - 1):
        count = count + x[i + 1] - y[i]
        if down_sum < count:
            down_sum = count
        else:
            continue

    return count


down_sum = down_count()
switch_sum = switch_count(down_sum)
print(switch_sum)
# Judge status: Accepted
a,b=map(int,input().split())
ab=a+b
if ab>=24:
    print(ab-24)
else:
    print(ab)
# Judge status: Accepted
A,B,T=map(int, input().split())
print(T//A*B)
# Judge status: Accepted
n,a,b=map(int,input().split())
if a>b:a,b=b,a
if (a+b)%2:
  print(min(a+b-1,(n-a)+(n-b)+1)//2)
else:print((b-a)//2)
# Judge status: Accepted
a,b=map(int,input().split())

for n in range(0,20):
    if n*(a-1)>=b-1:
        break

print(n)
# Judge status: Wrong Answer
k = int(input())

if k % 2 == 0:
    num = k / 2 ** 2
else:
    base = (k-1) / 2
    num = base * (base + 1)

print(int(num))
# Judge status: Accepted
a,b,k = map(int,input().split())

if (b - a + 1) >= 2*k:
    for i in range(a,a+k):
        print(i)
    for j in range(b-k+1,b+1):
        print(j)
    
else:
    for i in range(a,b+1):
        print(i)
# Judge status: Wrong Answer
n = int(input())

l0 = 2
l1 = 1
l2 = 3
for i in range(n-1):
    l2 = l0 + l1
    l0, l1 = l1, l2

print(l2)
# Judge status: Accepted
n,x,t=map(int, input().split())

a=(n+x-1)//x
ans=a*t

print(ans)
# Judge status: Accepted
from collections import defaultdict
N = int(input())
dic = defaultdict(int)
for i in range(N):
    s = input()
    dic[s] += 1
M = int(input())
for i in range(M):
    t = input()
    dic[t] -= 1
ans = max(dic.values())
print(max(0,ans))
# Judge status: Accepted
N,K = map(int,input().split())
S = input()

ans = 0
dif = 0
for i in range(1,N):
    if S[i] != S[i-1]: dif += 1
    else: ans += 1

if K <= dif//2:
    ans += 2*K
else:
    ans = N-1

print(ans)
# Judge status: Wrong Answer
n = input()
a = list(map(int, input().split()))

ok = 0
ng = 0
even = []
for i in a:
    if i % 2 == 0:
        even.append(i)

if len(even) == 0:
    print("DENIED")
    exit()

for i in even:
    if i % 3 != 0 and i % 5 != 0:
        print("DENIED")
        exit()

print("APPROVED")
# Judge status: Wrong Answer
a = list(map(int,input().split()))
a.sort()
b = a[2] - a[1]
c = a[1] - a[0]

ans = 0

ans += b

if c % 2 == 0:
    ans += c//2
elif c % 2 == 1:
    ans += c//2 + 2
# Judge status: Wrong Answer
N = str(input())

if N in '9':
  print("Yes")
  
else:
  print('N0')
# Judge status: Accepted
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
N = int(input())
B = [int(input()) for _ in range(N)]

tate = [[a11, a21, a31], [a12, a22, a32], [a13, a23, a33]]
yoko = [[a11, a12, a13], [a21, a22, a23], [a31, a32, a33]]
naname = [[a11, a22, a33], [a13, a22, a31]]

for tripe in tate + yoko + naname:
    a, b, c = tripe
    if a in B and b in B and c in B:
        print("Yes")
        break
else:
    print("No")
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  N, M = map(int, input().split())
  acs = [0] * N
  was = [0] * N

  for _ in range(M):
    p, s = input().split()
    p = int(p) - 1

    if s == 'AC':
      acs[p] = 1
    elif acs[p] == 0:
      was[p] += 1

  s = 0
  p = 0

  for a, w in zip(acs, was):
    if a == 0:
      continue

    s += 1
    p += w

  print(s, p)


if __name__ == '__main__':
  main()