Harryxun/stf_run huggingface dataset:
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

n, k = map(int, rl().split())

li = list(map(int, rl().split()))

dp = np.zeros(n, dtype=int)

dp[0] = 0
dp[1] = abs(li[0] - li[1])

for i in range(2, k):
    temp = float('inf')
    for j in range(i):
        a = dp[j] + abs(li[j] - li[i])
        if temp > a:
            temp = a
    dp[i] = temp
for i in range(k, n):
    temp = float('inf')
    for j in range(i-k, i):
        a = dp[j] + abs(li[j] - li[i])
        if temp > a:
            temp = a
    dp[i] = temp
        
print(int(dp[n-1]))




### FIXED CODE ###

import sys

rl = sys.stdin.readline

n, k = map(int, rl().split())

li = list(map(int, rl().split()))

dp = [1<<60]*n

dp[0] = 0
dp[1] = abs(li[0] - li[1])

if k < n:    
    for i in range(2, k):
        for j in range(i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
    for i in range(k, n):
        for j in range(i-k, i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
else:
    for i in range(n):
        for j in range(i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
        
print(int(dp[-1]))
import math

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

a = (n[0] * n[1]) // math.gcd(n[0], n[1])

print(a)

### FIXED CODE ###

import fractions

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

a = (n[0] * n[1]) // fractions.gcd(n[0], n[1])
print(a)
S=list(input())

K="Yes"

for i in range (0,len(S)):
	if i%2=0
	    if S[i]=="L" :
        	K="No"
        	break
        else:
        	continue
    else :
		if S[i]=="R" :
        	K="No"
        	break
    	else:
        	continue
print(K)

### FIXED CODE ###

S=list(input())
K="Yes"
for i in range (0,len(S)):
	if i%2==0:
		if S[i]=="L" :
			K="No"
			break
		else:
			continue
	else :
		if S[i]=="R" :
			K="No"
			break
		else:
			continue
print(K)
N = int(input())
ans = 1
d = []
for i in range(N):
  d.append(int(input()))
sorted(d,reverse=True)
print(set(d))


### FIXED CODE ###

S=str(input())
 
k=S.replace("2017","2018")
 
print(k)
input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

### FIXED CODE ###

s=input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)
from typing import List

n, u, v = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def dfs(v: int) -> List[int]:
    dist = [-1] * n
    dist[v] = 0
    stack = [v]
    while stack:
        now = stack.pop()
        dw = dist[now] + 1
        for ne in graph[now]:
            if dist[ne] < 0:
                continue
            dist[ne] = dw
            stack.append(ne)
    return dist

Takahashi = dfs(u-1)
Aoki = dfs(v-1)

ans = 0
for t, a in zip(Takahashi, Aoki):
    if t < a:
        ans = max(ans, a - 1)

print(ans)

### FIXED CODE ###

import sys

n, u, v = map(int, sys.stdin.readline().split())
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    graph[a].append(b)
    graph[b].append(a)

def dfs(v):
    dist = [-1] * (n+1)
    dist[v] = 0
    stack = [v]
    while stack:
        now = stack.pop()
        dw = dist[now] + 1
        for ne in graph[now]:
            if dist[ne] >= 0:
                continue
            dist[ne] = dw
            stack.append(ne)
    return dist

Takahashi = dfs(u)
Aoki = dfs(v)

ans = 0
for t, a in zip(Takahashi[1:], Aoki[1:]):
    if t < a:
        ans = max(ans, a - 1)

print(ans)
import sympy
N=int(input())
count=0
for i in range(1,N)
  count=count+sympy.divisor_count(i)
print (count)

### FIXED CODE ###

N=int(input())
a=1
count=0
while a<N:
  count=count+(N-1)//a
  a=a+1
else:
  print(count)
N, Q = map(int, input().split())
S = input()
for i in range(Q):
    l, r = map(int, input().split())
    print(S[l-1, r].count("AC"))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
acc = [0] * (N+1)
for i in range(0, N):
    acc[i+1] = acc[i] + (i+1 < N and S[i+1] == "C" and S[i] == "A")
for i in range(Q):
    l, r = map(int, input().split())
    print(acc[r-1] - acc[l-1])
from time import time

start = time()
D = int(input())
C = [int(i) for i in input().split()]
scores = [[int(i) for i in input().split()] for j in range(D)]
t = []
for i in scores:
    t.append(i.index(max(i))+1)
DC = [0]*26

def calcScore(t):
    score = []
    S = 0
    last = [0]*26
    for d in range(1,D+1):
        S += scores[d-1][t[d-1]-1]
        last[t[d-1]-1] = d
        for i in range(26):
            S -= C[i] * (d - last[i])
            DC[i] += (d - last[i])
        score.append(S)
    return score[-1]

ts = calcScore(t)
i = D
j = 1
while time() - start < 1.95:
    d,q = i, j
    temp = [t[i] if d-1 != i else q for i in range(D)]
    j += 1
    if calcScore(temp) > ts:
        t = temp
        i -= 1
        j = 0

print("\n".join(map(str, t)))

### FIXED CODE ###

D = int(input())
C = [int(i) for i in input().split()]
scores = [[int(i) for i in input().split()] for j in range(D)]

for i in scores:
    print(i.index(max(i))+1)
n = [str(i) for i in range(10)]
flag = False
for i in range(A):
    if S[i] not in n:
        flag = True
        
if S[A] != '-':
    flag = True
    
for i in range(A+1, A+B+1):
    if S[i] not in n:
        flag = True
        
if flag:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

A, B = map(int, input().split())
S = input()

n = [str(i) for i in range(10)]
flag = False
for i in range(A):
    if S[i] not in n:
        flag = True
        
if S[A] != '-':
    flag = True
    
for i in range(A+1, A+B+1):
    if S[i] not in n:
        flag = True
        
if flag:
    print('No')
else:
    print('Yes')
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 1
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

def facto(n):
    arr = []
    temp = n
    for i in range(int(math.sqrt(n))+1):
        if temp%i==0:
            cnt = 0
            while temp%i==0:
                cnt +=1
                temp //= i
            arr.append([cnt, i])
    if temp != 1:
        arr.append([1, temp])
    
    if arr == []:
        arr.append([1, n])
    
    return arr

n, p=I()

for i in facto(p):
    if i[0] >= n:
        ans *= i[1]

if n == 1:
    print(p)
elif p == 1:
    print(1)
else:
    print(ans)


### FIXED CODE ###

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 1
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

def facto(n):
    arr = []
    temp = n
    for i in range(2, int(math.sqrt(n))+1):
        if temp%i==0:
            cnt = 0
            while temp%i==0:
                cnt +=1
                temp //= i
            arr.append([cnt, i])
    if temp != 1:
        arr.append([1, temp])
    
    if arr == []:
        arr.append([1, n])
    
    return arr

k, p=I()

for i in facto(p):
    if i[0] >= k:
        ans *= i[1]**(i[0]//k)

if k == 1:
    print(p)
elif p == 1:
    print(1)
else:
    print(ans)
def f():
    _ = int(input())
    nums = np.array(list(map(int, input().split())))
    # nums = [int(x) for x in input().split()]
    c = 0
    while True:
        if any(nums % 2 == 1):
            break
        c += 1
        nums = nums / 2
    print(c)


f()

### FIXED CODE ###

import numpy as np
# Me


def f():
    i = int(input())
    nums = np.array(list(map(int, input().split())))
    # nums = [int(x) for x in input().split()]
    c = 0
    while True:
        if any(nums % 2 == 1):
            break
        c += 1
        nums = nums / 2
    print(c)


f()


# Other
import sys
ifprime = [1]*(1000000)
ifprime[0] = ifprime[1] = 0
a = 2
while a <= num:
  if ifprime[a]:
    ans += 1
    b = a*a
    while b <= num:
      ifprime[b] = 0
      b += a
  a += 1
for n in sys.stdin:
  print sum(ifprime[:int(n)])

### FIXED CODE ###

import sys
ifprime = [1]*(1000000)
ifprime[0] = ifprime[1] = 0
a = 2
while a < 1000000:
  if ifprime[a]:
    b = a*a
    while b < 1000000:
      ifprime[b] = 0
      b += a
  a += 1
for n in sys.stdin:
  print sum(ifprime[:int(n)+1])
import math


def prime_factorization(n):
    result = []

    N = n
    x = 2
    while x <= math.sqrt(N):
        if n % x == 0:
            result.append(x)
            n = n / x

        x += 1

    if n != 1:
       result.append(n)

    if result[-1] == result[-2]:
      result.pop(-1)
        
    return result


N = int(input())

result = prime_factorization(N)

print(len(result))



### FIXED CODE ###

import math
from collections import Counter



def prime_factorization(num):
    """
    素因数分解
    ;param num 素因数分解したい数字
    ;return result {素因数: 回数, ・・・}
    """

    result = dict()

    N = num

    x = 2
    while x <= int(math.sqrt(num)) + 1:
        if (num % x) == 0:
            count = 0
            while (num % x) == 0:
                count += 1
                num = num / x

            result[x] = count

        x += 1

    if num != 1:
        result[num] = 1

    if result == []:
        result[N] = 1

    return result


N = int(input())

# 素因数分解
result = prime_factorization(N)

# 操作の回数を求める
ans = 0
for value in result.values():
    c = 1
    while (value - c) >= 0:
        ans += 1
        value -= c
        c += 1

print(ans)
i=input()
j=i[0]
k=0

for n in range(2):
  if i[n+1]!=j:
	print('Yes')
	k=1
  
if k=0:
  print('No')

### FIXED CODE ###

i=input()
j=i[0]
k=0

for n in range(2):
	if i[n+1]!=i[0]:
		k=1
if k==0:
	print('No')
else:
	print('Yes')
N=int(input())
A=[list(map(int, input().split()))]

temp1=cp.deepcopy(A[0])
temp2=cp.deepcopy(A[0])
for i in range(N-1):
    f=0
    x,y=map(int, input().split())
    if abs(temp1[0]-x)+abs(temp1[1]-y):
        temp2[0]=x
        temp2[1]=y
        f=1
    if f==1:
        for i,j in A:
           if max(abs(temp2[0]-i)+abs(temp2[1]-j),abs(temp2[0]-temp1[0])+abs(temp2[1]-temp1[1])):
               temp1[0]=i
               temp2[1]=j
    A.append([x,y])


print(abs(temp2[0]-temp1[0])+abs(temp2[1]-temp1[1]))

### FIXED CODE ###

N=int(input())
A=[]
B=[]
for _ in range(N):
    x,y=map(int, input().split())
    A.append(x+y)
    B.append(x-y)

A=sorted(A)
B=sorted(B)

print(max(A[-1]-A[0],B[-1]-A[0],A[-1]-A[0],B[-1]-B[0]))
N = int(input())
S = list(input())
Q = int(input())
set_dic = {}

for i, s in enumerate(S):
    if s not in set_dic.keys():
        set_dic[s] = {i+1}
    else:
        set_dic[s].add(i+1)

anslist = []
count = 0

for _ in range(Q):
    query1,query2,query3 = input().split()
    if query1 == "1":
        i = int(query2)
        c = query3
        for l in set_dic.values():
            l.discard(i)
        if c not in set_dic.keys():
            set_dic[c] = {i}
        else:
            set_dic[c].add(i)
    else:
        l = int(query2)
        r = int(query4)
        ansset = set()
        for i in range(l, r + 1):
            for key, eachset in set_dic.items():
                if i in eachset:
                    ansset.add(key)
                    break
        ans = len(ansset)
        anslist.append(ans)
        count += 1

for i in anslist:
    print(i)

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline

def solve():
    N = int(input())
    S = list(input())
    Q = int(input())
    set_dic = {}

    for i, s in enumerate(S):
        if s not in set_dic:
            set_dic[s] = [i+1]
        else:
            bisect.insort_left(set_dic[s], i+1)

    anslist = []

    for _ in range(Q):
        query1, query2, query3 = input().split()
        if query1 == "1":
            i = int(query2)
            c = query3
            cap = S[i-1]
            if cap == c:
                continue
            set_dic[cap].remove(i)
            if c not in set_dic:
                set_dic[c] = [i]
            else:
                bisect.insort_left(set_dic[c], i)
            S[i-1] = c
        else:
            l = int(query2)
            r = int(query3)
            ansset = set()
            ans = 0
            for eachlist in set_dic.values():
                li = bisect.bisect_left(eachlist, l)
                ri = bisect.bisect_right(eachlist, r)
                if li != ri:
                    ans += 1
            anslist.append(ans)

    for i in anslist:
        print(i)

if __name__ == '__main__':
    solve()
8 3
7 3 1 8 4 6 2 5

### FIXED CODE ###

n,k=map(int,input().split())
a=(n-1)/(k-1)
if a!=int(a):
    print(int(a)+1)
else:
    print(int(a))
N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))
A=list(set(A))

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

l1=[]
l2=[]
l3=[]


if len(A)==2:
    ans=max(A)

else:
    a=A[0]
    b=A[1]
    if gcd(a,b)==1:
        a=A[2]
        b=A[4]
    
    for x in A:
        l1.append(gcd(gcd(x,a),b))

print(max(l1))

### FIXED CODE ###

N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))


def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

list1=[0]
L=0
for a in A:
    L=gcd(L,a)
    list1.append(L)

list2=[0]
R=0
for a in reversed(A):
    R=gcd(R,a)
    list2.append(R)

list2.reverse()

ans=[]

for i in range(N):
    ans.append(gcd(list1[i],list2[i+1]))

print(max(ans))
n = input()
    
S = range(1, 14)
H = range(1, 14)
C = range(1, 14)
D = range(1, 14)
    
for i in range(0, n):
   mk = raw_input()split()
   num = int, raw_input()split()
      if mk == 'S':
         S[num-1] = 0
      elif mk == 'H':
         S[num-1] = 0
      elif mk == 'C':
         S[num-1] = 0
      elif mk == 'D':
         S[num-1] = 0
    
for i in S:
   if S[i] != 0:
      print 'S'+str(S[i])
   
for i in H:
   if S[i] != 0:
      print 'H'+ str(H[i])
   
for i in C:
   if S[i] != 0:
      print 'C'+str(C[i])
   
for i in D:
   if S[i] != 0:
      print 'D'+str(D[i])

### FIXED CODE ###

n=input()
  
s=range(1,14)
h=range(1,14)
c=range(1,14)
d=range(1,14)
   
for i in range(n):
   m, k=raw_input().split()
   if m == 'S':
      s[int(k)-1] = 0
   elif m == 'H':
      h[int(k)-1] = 0
   elif m == 'C':
      c[int(k)-1] = 0
   elif m == 'D':
      d[int(k)-1] = 0
  
for i in range(0, 13):
   if s[i] != 0:
      print 'S '+str(s[i])
  
for i in range(0, 13):
   if h[i] != 0:
      print 'H '+str(h[i])
  
for i in range(0, 13):
   if c[i] != 0:
      print 'C '+str(c[i])
  
for i in range(0, 13):
   if d[i] != 0:
      print 'D '+str(d[i])
# -*- coding: utf-8 -*-
def check(t, n, idx):
    if t == n + idx or t == n - idx:
        return idx
    if idx >= t:
        return t
    return min(check(t, n + idx, idx + 1), check(t, n - idx, idx + 1), check(t, n, idx + 1))

X = int(raw_input())
print(check(X, 0, 1))

### FIXED CODE ###

N = int(input())
 
for i in range(1, N + 1):
    if N <= (i * (i + 1) / 2):
        print (str(i))
        break
n = int(input())
h = list(map(int, input().split()))
if n==1:
    print('Yes')
    exit()
for i in range(n-2):
    print(n)
    print(i)
    if h[n-i-1] == (h[n-i-2]-1):
        h[n-i-1] -= 1
    elif h[n-i] < (h[n-i-1]-1):
        print('No')
        exit()
print('Yes')

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
if n==1:
    print('Yes')
    exit()
ht = h[-1]
for i in reversed(range(n-1)):
    if ht == h[i]-1:
        h[i]-=1
    elif ht < h[i]-1:
        print('No')
        exit()
    ht = h[i]
print('Yes')
from itertools import product
N, M = map(int, input().split(" "))
s = []
for i in range(M):
    s.append(list(map(int, input().split(" ")))[1:])

p = list(map(int, input().split(" ")))
ans = 0
for tup in product(range(2), repeat=M):
    for i in range(M):
        flg = True
        cnt = 0
        for d in s[i]:
            cnt += tup[d - 1]
        if cnt % 2 != p[i]:
            flg = False
            break

    if flg:
        ans += 1

print(ans)

### FIXED CODE ###

from itertools import product
N, M = map(int, input().split(" "))
s = []
for i in range(M):
    s.append(list(map(int, input().split(" ")))[1:])

p = list(map(int, input().split(" ")))
ans = 0
for tup in product(range(2), repeat=N):
    for i in range(M):
        flg = True
        cnt = 0
        for d in s[i]:
            cnt += tup[d - 1]
        if cnt % 2 != p[i]:
            flg = False
            break

    if flg:
        ans += 1

print(ans)
n=int(input())
a=[int(i) for i in input().split(" ")]
x=0
for i in range(n):
    mi=i
    for j in range(i,n):
        if a[j] < a[mi]:
            mi = j
    if i != mi:
        x+=1
        a[i],a[mi]=a[mi],[i]

print(" ".join([str(i) for i in a]))
print(x)

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split(" ")]
x=0

for i in range(n):
    mi = i
    for j in range(i, n):
        if a[j] < a[mi]:
            mi = j
    
    if i != mi:
        x += 1
        a[i], a[mi] = a[mi] , a[i]

print(" ".join([str(i) for i in a]))
print(x)
a = input()
if a[2] == a[3] && a[4] == a[5]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = input()
if a[2] == a[3] and a[4] == a[5]:
    print("Yes")
else:
    print("No")
import sys
n, k = map(int, input().split())

while True:
    if ((n-k) > 10000):
        n = n // 10000
    else:
        an = abs(n-k)
    if n <= an:
        break
    else:
        n = min(n, an)
print(n)




### FIXED CODE ###

import sys
N, K = map(int, input().split())

ans = N % K
ans = min(ans, abs(K-ans))
print(ans)
n = int(input())
t = [list(map(int, input().split())) for _ in range(n-1)]



hands = [0 for _ in range(n+1)]
for a, b in t:
    hands[a] += 1
    hands[b] += 1

number_of_colors = max(*hands)

def next_color(i):
    return i+1 if i < number_of_colors else 1



class edge():
    def __init__(self, en):
        self.ends = en
        self.color = 0

    def set_color(self, co):
        self.color = co

class nord():
    def __init__(self, tr):
        self.parent = tr
        self.edges = []

    def add(self, ed):
        self.edges.append(ed)

    def set_color(self, previous_color):
        co = next_color(previous_color)
        for ed in self.edges:
            if ed.color == 0:
                ed.set_color(co)
                for i in ed.ends:
                    no = self.parent.nords[i-1]
                    if self is not no:
                        no.set_color(co)
                co = next_color(co)

class tree():
    def __init__(self):
        self.nords = []

    def add_nord(self, no):
        self.nords.append(no)

    def add_edge(self, ed):
        for i in ed.ends:
            self.nords[i-1].add(ed)

    def set_color(self):
        self.nords[0].set_color(0)


tr = tree()
for _ in range(n):
    no = nord(tr)
    tr.add_nord(no)

e_tree = []
for en in t:
    ed = edge(en)
    e_tree.append(ed)
    tr.add_edge(ed)

tr.set_color()

print(number_of_colors)
for e in e_tree:
    print(e.color)

### FIXED CODE ###

from sys import setrecursionlimit


setrecursionlimit(10**6)



n = int(input())
t = [list(map(int, input().split())) for _ in range(n-1)]



hands = [0 for _ in range(n+1)]
for a, b in t:
    hands[a] += 1
    hands[b] += 1

number_of_colors = max(*hands)

def next_color(i):
    return i+1 if i < number_of_colors else 1



class edge():
    def __init__(self, en):
        self.ends = en
        self.color = 0

    def set_color(self, co):
        self.color = co

class nord():
    def __init__(self, tr):
        self.parent = tr
        self.edges = []

    def add(self, ed):
        self.edges.append(ed)

    def set_color(self, previous_color):
        co = next_color(previous_color)
        for ed in self.edges:
            if ed.color == 0:
                ed.set_color(co)
                for i in ed.ends:
                    no = self.parent.nords[i-1]
                    if self is not no:
                        no.set_color(co)
                co = next_color(co)

class tree():
    def __init__(self):
        self.nords = []

    def add_nord(self, no):
        self.nords.append(no)

    def add_edge(self, ed):
        for i in ed.ends:
            self.nords[i-1].add(ed)

    def set_color(self):
        self.nords[0].set_color(0)


tr = tree()
for _ in range(n):
    no = nord(tr)
    tr.add_nord(no)

e_tree = []
for en in t:
    ed = edge(en)
    e_tree.append(ed)
    tr.add_edge(ed)

tr.set_color()

print(number_of_colors)
for e in e_tree:
    print(e.color)
import math
n, x, y = map(int,input().split())
num = [0 for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        num[min([j-i,math.fabs(j-y)+1+math.fabs(i-x))] += 1

for i in range(n):
    print(num[i])


### FIXED CODE ###

n, x, y = map(int,input().split())
num = [0 for i in range(n)]

for i in range(1,n+1):
    for j in range(i+1,n+1):
        ban = min([j-i,abs(x-i)+1+abs(y-j)])
        num[ban] += 1

for i in range(1,n):
    print(num[i])
a,b,c = map(int, input().split())
if c-d<=0:
  print("delicious")
elif c-d>0 and c-d<=x:
  print("safe")
elif c-d>0 and c-d>x:
  print("dangerous")

### FIXED CODE ###

a,b,c = map(int, input().split())
if c-b<=0:
  print("delicious")
elif c-b>0 and c-b<=a:
  print("safe")
elif c-b>0 and c-b>a:
  print("dangerous")
S = input()

ans = 'NO'
def func(T):
    global ans
    if len(T) > len(S):
        return
    if S == T:
        ans = 'YES'
        return

    func(T+'dream')
    func(T+'dreamer')
    func(T+'erase')
    func(T+'eraser')

func('')

print(ans)



### FIXED CODE ###

S = input()

ans = 'YES'

while S:
    if S.endswith('eraser'):
        S = S[:-6]
    elif S.endswith('erase'):
        S = S[:-5]
    elif S.endswith('dreamer'):
        S = S[:-7]
    elif S.endswith('dream'):
        S = S[:-5]
    else:
        ans = 'NO'
        break

print(ans)
s=str(input())
x=''
list=[]
for i in range(len(s)):
    if s[i]=='1':
        list.append('1')
    elif s[i]=='0':
        list.append('0')
    elif s[i]=='B' and len(list)!=0:
        del list[i-1]

for i in range(len(list)):
    x += list[i]

print(x)


### FIXED CODE ###

s=str(input())
x=''
list=[]
for i in range(len(s)):
    if s[i]=='1':
        list.append('1')
    elif s[i]=='0':
        list.append('0')
    elif s[i]=='B' and len(list)!=0:
        del list[len(list)-1]

for i in range(len(list)):
    x += list[i]

print(x)
if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = input()
if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")
n,m = map(int,input().split())
ps = [input().split() for i in range(m)]

ans =[]
for i in range(m):
  if not(ps[i][0] in ans) :
    ans += ps[i][0]
    

print(ps[0][0])
wa = 0
ac = 0
for i in ans:
  for j in range(m):
    #問題番号の確認
    w = 0
    if ps[j][0] == str(i):
      if ps[j][1] =="WA":
        w += 1
      elif ps[j][1] == "AC":
        ac += 1
        wa +=w
        break

    else:
      continue
      
      
print(ac,wa)

### FIXED CODE ###

N,M = map(int, input().split())
ps = []
AC = [0]*N
WA = [0]*N
WA_sum = 0
for _ in range(M):
  ps.append(list(input().split()))
for i in range(M):
  if ps[i][1] == 'AC' and AC[int(ps[i][0])-1] == 0:
    AC[int(ps[i][0])-1] = 1
  if ps[i][1] == 'WA' and AC[int(ps[i][0])-1] == 0:
    WA[int(ps[i][0])-1] += 1
for i in range(N):
  if AC[i] == 1:
    WA_sum += int(WA[i])
print(sum(AC), WA_sum)