Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

dp = [float('inf')]*N

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

for i in range(2, N):
    dp[i] = min([dp[i-v]+abs(H[i]-H[i-v]) for v in range(1, min(i, K)+1)])
print(dp[-1])


### FIXED CODE ###

# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

dp = [float('inf')]*N

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

for i in range(2, N):
    dp[i] = min([dp[i-v]+abs(H[i]-H[i-v]) for v in range(1, min(i, K)+1)])
print(dp[-1])
### BUGGY CODE ###

def inpl(): return [int(i) for i in input().split()]
def next(v):
    for i in edge[v].copy():
        if i in path:
            edge[i].remove(v)
            edge[v].remove(i)
            continue
        elif i in path1:
            edge[i].remove(v)
            edge[v].remove(i)
            continue
        edge[i].remove(v)
        edge[v].remove(i)
        return i
    return -1

from collections import defaultdict
edge = defaultdict(lambda: [])
N, M = inpl()
for _ in range(M):
    A,B = inpl()
    edge[A].append(B)
    edge[B].append(A)

flag = True
v = 1
nv = 1
path = [1]
path1 = [1]
while nv >= 0:
    nv = next(v)
    flag = nv
    path.append(nv)
    v = nv
path.pop()
flag = True
v = 1
nv = 1
while nv >= 0:
    nv = next(v)
    flag = nv
    path1.append(nv)
    v = nv
path1=list(reversed(path1))
path1.pop(0)
path1.pop()
path = path1 + path
print(len(path))

print(*path)

### FIXED CODE ###

def inpl(): return [int(i) for i in input().split()]
def next(v):
    for i in edge[v]:
        if visited[i]:
            continue
        visited[i] = True
        return i
    return -1

from collections import defaultdict
edge = defaultdict(lambda: [])
N, M = inpl()
visited = [False for _ in range(N+1)]
visited[1] = True
for _ in range(M):
    A,B = inpl()
    edge[A].append(B)
    edge[B].append(A)
v = 1
nv = 1
path = [1]
while nv >= 0:
    nv = next(v)
    path.append(nv)
    v = nv
path.pop()
path = list(reversed(path))
v = 1
nv = 1
while nv >= 0:
    nv = next(v)
    path.append(nv)
    v = nv
path.pop()
print(len(path))
print(*path)
### BUGGY CODE ###


url = "https://atcoder.jp//contests/abc094/tasks/arc095_a"

def main():
    N = int(input())
    Xs = list(map(int, input().split()))
    all_num = sum(Xs)
    for i in range(len(Xs)):
        tmp = Xs[::]
        tmp.pop(i)
        tmp.sort()
        print(tmp[(len(tmp)) // 2])

if __name__ == '__main__':
    main()


### FIXED CODE ###


url = "https://atcoder.jp//contests/abc094/tasks/arc095_a"

def main():
    N = int(input())
    Xs = list(map(int, input().split()))
    sort_Xs = sorted(Xs)
    front = len(sort_Xs) // 2 - 1
    rear = len(sort_Xs) // 2
    for X in Xs:
        if sort_Xs[rear] > X:
            print(sort_Xs[rear])
        else:
            print(sort_Xs[front])



if __name__ == '__main__':
    main()
### BUGGY CODE ###

def prime(p):
    memo = 0
    for i in range(1,(int(p**0.5)+1)):
        if p%i==0:
            memo += 2
            if i == p//i:
                memo -= 1
        #print(memo,i,p)
    return memo      

N = int(input())

ans = 0
for i in range(1,N):
    ans += prime(i)
print(ans)

### FIXED CODE ###

N = int(input())
memo = [1]*(N)
memo[0] = 0
ans = 0
for i in range(2,N):
    tmp = i
    while tmp < N:
        memo[tmp] += 1
        tmp += i
print(sum(memo))
### BUGGY CODE ###

n = int(input())
ans = 0
l = len(str(n))

N = [0 for i in range(l)]

for i in range(l):
    N[i] = int(str(n)[-i-1])
N.append(0)

for i in range(l+1):
    if N[i]<5:
        ans += N[i]
    elif N[i]>5:
        ans += 10-N[i]
        N[i+1] += 1
    elif N[i+1]>4:
        ans += 10-N[i]
        N[i+1] += 1
    else:
        ans += N[i]

print(ans)


### FIXED CODE ###


ans = 0
s = input()
l = len(s)

N = [0 for i in range(l)]

for i in range(l):
    N[i] = int(s[-i-1])
N.append(0)

for i in range(l+1):
    if N[i]<5:
        ans += N[i]
    elif N[i]>5:
        ans += 10-N[i]
        N[i+1] += 1
    elif N[i+1]>4:
        ans += 10-N[i]
        N[i+1] += 1
    else:
        ans += N[i]

print(ans)
### BUGGY CODE ###

N, W = [int(i) for i in input().split()]
wv = []
for i in range(N):
  wv.append([int(i) for i in input().split()])
dp = [[0 for i in range(W+1)] for j in range(N+1)]
#print(wv)

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


### FIXED CODE ###

N, W = [int(i) for i in input().split()]
wv = []
for i in range(N):
  wv.append([int(i) for i in input().split()])
dp = [[0 for i in range(W+1)] for j in range(N+1)]
#print(wv)

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

L, R = [int(n) for n in input().split()]

if L - R >= 2019:
    print(0)
else:
    min_mod = 2019
    for a in range(L, R):
        for b in range(a+1, R+1):
            min_mod = min(min_mod, (a * b) % 2019)

    print(min_mod)

### FIXED CODE ###

L, R = [int(n) for n in input().split()]

if R - L >= 2019:
    print(0)
else:
    min_mod = 2019
    for a in range(L, R):
        for b in range(a+1, R+1):
            min_mod = min(min_mod, (a * b) % 2019)

    print(min_mod)
### BUGGY CODE ###

S = input()
list(S)

K=0
for i in range(4,len(S)+1):
    for j in range(len(S)-i+1):
        S_num=int(S[j:j+i])
        if S_num % 2019 == 0:
            K+=1
print(K)

### FIXED CODE ###

from operator import mul
from functools import reduce
import numpy as np
#def ConZ(i):
    #z_num = i+int(i*(i-1)/2)
    #return z_num
#def ConN(i):
    #n_num = int(i*(i-1)/2)
    #return n_num

def cmb(n):
    over = reduce(mul, range(n, n - 2, -1))
    under = reduce(mul, range(1,2 + 1))
    return over // under


S = input()[::-1]
keta = 1
A_num = 0
x = 0
mod = np.array([0]*2019)
mod[0] += 1
for i in range(len(S)):
    A_num += (int(S[i:i+1])*keta)%2019
    if A_num >= 2019:
        A_num = A_num%2019
    mod[A_num] +=1
    #keta*=10
    keta = keta * 10 % 2019
#print(mod)
#x += ConZ(mod[0])
#del mod[0]

#for j in range(len(mod)):
    #x+=cmb(mod[j])
#print(x)
print(int(np.sum(mod* (mod - 1) /2)))
### BUGGY CODE ###

import sys
from collections import deque
N, M = map(int, input().split())
Edge = [[] for _ in range(N+1)]
comp = set()
mod = 10**9+7
for _ in range(M):
    p, q, c = map(int, sys.stdin.readline().split())
    Edge[p].append(mod*q+c)
    Edge[q].append(mod*p+c)
    comp.add(c)
dist = {mod: 0}
Q = deque()
Q.append(mod)
visited = set()
while Q:
    vn, cp = divmod(Q.pop(), mod)
    if mod*vn+cp in visited:
        continue
    visited.add(mod*vn+cp)
    for t in Edge[vn]:
        vf, cf = divmod(t, mod)
        if mod*vf+cp in visited:
            continue
        if cp == cf:
            dist[mod*vf+cf] = min(dist.get(mod*vf+cf, 10**9), dist.get(mod*vn+cp, 10**9))
            Q.append(mod*vf+cf)
        else:
            dist[mod*vf+cf] = min(dist.get(mod*vf+cf, 10**9), 1 + dist.get(mod*vn+cp, 10**9))
            Q.appendleft(mod*vf+cf)
L = [dist.get(N*mod+c, 10**9) for c in comp]
if not L or min(L) == 10**9:
    print(-1)
else:
    print(min(L))


### FIXED CODE ###

import sys
readline = sys.stdin.readline

from heapq import heappop as hpp, heappush as hp
inf = 10**9+7
def dijkstra(N, s, Edge):    
    dist = [inf] * N
    dist[s] = 0
    Q = [(0, s)]
    while Q:
        dn, vn = hpp(Q)
        if dn > dist[vn]:
            continue
        for df, vf in Edge[vn]:
            if dn + df < dist[vf]:
                dist[vf] = dn + df
                hp(Q, (dn + df,vf))
    return dist

def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2)}
    return L2, C


N, M = map(int, readline().split())

Edge = []
VS = set(range(N))
geta = 20
Edge = [tuple(map(int, readline().split())) for _ in range(M)]
for a, b, c in Edge:
    a -= 1
    b -= 1
    VS |= {(c<<geta) | a, (c<<geta) | b}
   
_, Cv = compress(list(VS))

Vnum = len(Cv)

nEdge = [[] for _ in range(Vnum)]

for a, b, c in Edge:
    a -= 1
    b -= 1
    ca = Cv[(c<<geta) | a]
    cb = Cv[(c<<geta) | b]
    nEdge[ca].append((0, cb))
    nEdge[cb].append((0, ca))
    nEdge[a].append((1, ca))
    nEdge[ca].append((0, a))
    nEdge[b].append((1, cb))
    nEdge[cb].append((0, b))

dist = dijkstra(Vnum, 0, nEdge)
if dist[N-1] >= inf:
    dist[N-1] = -1
print(dist[N-1])
### BUGGY CODE ###

mi = lambda: map(int, input().split())
e = enumerate
n,k = mi()
a = list(mi())
g = [None]*n

d = dict()
for i,x in e(a):
  d[x] = i
for i,x in e(a):
  g[d[x]] = ((i+1)%n,int(d[x]>=i)+int(i+1==n))
  d[x] = i
db = [g]
for _ in range(100):
  old = db[-1]
  new = [None]*n
  for i in range(n):
    p,q = old[i]
    r,s = old[p]
    new[i] = (r,q+s)
  db.append(new)
cur = 0
st = 100
cs = 0
while st>=0:
  p,q = db[st][cur]
  if cs+q < k:
    cs += q
    cur = p
  else:
    st -= 1
q = list()
for x in a[cur:]:
  if x in q:
    t = x-1
    while t != x:
      t = q.pop()
  else:
    q.append(x)
print(' '.join(map(str,q)))
    

### FIXED CODE ###

mi = lambda: map(int, input().split())
e = enumerate
n,k = mi()
m = (n+k).bit_length()
a = list(mi())
g = [None]*n

d = dict()
for i,x in e(a):
  d[x] = i
for i,x in e(a):
  g[d[x]] = ((i+1)%n,int(d[x]>=i)+int(i+1==n))
  d[x] = i
db = [g]
for _ in range(m):
  old = db[-1]
  new = [None]*n
  for i in range(n):
    p,q = old[i]
    r,s = old[p]
    new[i] = (r,q+s)
  db.append(new)
cur = 0
st = m
cs = 0
while st>=0:
  p,q = db[st][cur]
  if cs+q < k:
    cs += q
    cur = p
  else:
    st -= 1
    
q = list()
while cur < n:
  if g[cur][1] == 0:
    cur = g[cur][0]
  elif g[cur] == (0,1):
    break
  else:
    q.append(a[cur])
    cur += 1
  
print(' '.join(map(str,q)))
### BUGGY CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
e=[[] for i in range(10**5)]
ee=[[] for i in range(10**5)]
[n,m]=i2()
for i in range(m):
 [u,v]=i2()
 e[u-1].append(v-1)
 
[s,t]=i2()

d=[-1 for i in range(n)]
import sys
sys.setrecursionlimit(10**6)
d=[-1 for i in range(n)]
def dfs(v,u,uv):
   d[v]=u
   if u==3:
      ee[uv].append(v)
      return 0
   for i in e[v]:
         dfs(i,u+1,uv)
for i in range(n):
 d=[-1 for j in range(n)]
 dfs(i,0,i)
for i in range(n):
   ee[i]=list(set(ee[i]))

d=[-1 for i in range(n)]
def bfs(v):
   d[v]=0
   q=[v]
   while len(q):
    v=q.pop(0)
    for i in ee[v]:
      if d[i]<0:
         d[i]=d[v]+1
         q.append(i)
   print(d[t-1])
bfs(s-1)

### FIXED CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
e=[[] for i in range(3*10**5+10)]

[n,m]=i2()
for i in range(m):
 [u,v]=i2()
 u-=1
 v-=1
 e[3*u].append(3*v+1)
 e[3*u+1].append(3*v+2)
 e[3*u+2].append(3*v)
 
[s,t]=i2()
s-=1
t-=1
from collections import deque
d=[-1 for i in range(3*10**5+10)]
def bfs(v):
   d[v]=0
   q=deque([v])
   while len(q):
    v=q.popleft()
    for i in e[v]:
      if d[i]<0:
         d[i]=d[v]+1
         q.append(i)
   if d[3*t]>-1:
     return d[3*t]//3
   return d[3*t]  
print(bfs(3*s))
### BUGGY CODE ###

N, K = map(int, input().split())
A = tuple(map(int, input().split()))
F = tuple(map(int, input().split()))

if sum(A) <= K:
    print(0)
else:
    A = sorted(A)
    F = sorted(F, reverse=True)
    l = -1
    r = 10**12
    while (r - l) > 1:
        mid = (r + l) // 2
        # 成績がmidだったとして、修行しなければならない回数を算出
        fmid = sum([max(0, a - (mid // f)) for a, f in zip(A, F)])
        if fmid <= K:
            r = mid
        else:
            l = mid
    print(r)


### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
A = np.array(tuple(map(int, input().split())))
F = np.array(tuple(map(int, input().split())))

if sum(A) <= K:
    print(0)
else:
    def solve(N, K, A, F):
        A = np.sort(A)
        F = np.sort(F)[::-1]
        l = -1
        r = 10**12
        while (r - l) > 1:
            mid = (r + l) // 2
            # 成績がmidだったとして、修行しなければならない回数を算出
            fmid = (np.fmax([0]*N, A - (mid // F))).sum()
            if fmid <= K:
                r = mid
            else:
                l = mid
        return(r)
    print(solve(N, K, A, F))
### BUGGY CODE ###

def popcount(x):
    return bin(x).count("1")

N,X = open(0).read().split()
N = int(N)
X = int(X, 2)

p = popcount(X)

for i in range(0, N):
    x = X ^ (1 << (N - 1 - i))
    if x == 0:
        print(0)
        continue

    if x > X:
        x %= (p + 1)
    else:
        x %= (p - 1)
    ans = 1
    while x != 0:
        x %= popcount(x)
        ans += 1
    print(ans)

### FIXED CODE ###

def popcount(x):
    return bin(x).count("1")

N, X = open(0).read().split()
N = int(N)
XS = list(X)
X = int(X, 2)

p = popcount(X)
xi = X % (p + 1)
if p == 1:
    xd = 0
else:
    xd = X % (p - 1)

for i in range(N):
    if XS[i] == "1":
        if p == 1:
            print(0)
            continue
        else:
            k = pow(2, N - 1 - i, p - 1)
            x = (xd - k) % (p - 1)
    else:
        k = pow(2, N - 1 - i, p + 1)
        x = (xi + k) % (p + 1)
    ans = 1
    while x != 0:
        x %= popcount(x)
        ans += 1
    print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
dp=[[0]*n for i in range(n)]
for i in range(n):
    if n%2==0:
        dp[i][i]=-a[i]
    else:
        dp[i][i]=a[i]
for l in range(1,n):
    if n%2==l%2:
        for right in range(l,n):
            left=right-l
            dp[left][right]=min(dp[left+1][right]-a[left],dp[left][right-1]-a[right])
    else:
        for right in range(l,n):
            left=right-l
            dp[left][right]=max(dp[left+1][right]+a[left],dp[left][right-1]+a[right])
print(dp[0][n-1])

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
dp=[[0]*n for i in range(n)]
for i in range(n):
    if n%2==0:
        dp[i][i]=-a[i]
    else:
        dp[i][i]=a[i]
for l in range(1,n):
    if n%2==l%2:
        for right in range(l,n):
            left=right-l
            dp[left][right]=min(dp[left+1][right]-a[left],dp[left][right-1]-a[right])
    else:
        for right in range(l,n):
            left=right-l
            dp[left][right]=max(dp[left+1][right]+a[left],dp[left][right-1]+a[right])
print(dp[0][n-1])
### BUGGY CODE ###

import sys #追加
sys.setrecursionlimit(500*500)

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

time = 0
cnt = 0
ans = 0

def dfs(time, cnt):
    global ans
    # print(time)
    if time > K:
        # print(cnt)
        ans = max(ans, cnt-1)
        return
    if A:
        dfs(time+A.pop(0), cnt+1)
    if B:
        dfs(time+B.pop(0), cnt+1)
    if len(A)==0==len(B):
        return cnt

if sum(A)+sum(B)<=K:
    print(N+M)
else:
    dfs(0, 0)
    print(ans)

### FIXED CODE ###

from itertools import accumulate

N, M, K = map(int, input().split())
A = list(accumulate([0] + list(map(int, input().split()))))
B = list(accumulate([0] + list(map(int, input().split()))))


ans, j = 0, M

for i in range(N+1):
    if A[i] > K:
        break
    while B[j] > K-A[i]:
        j -= 1
    ans = max(ans, i+j)


print(ans)
### BUGGY CODE ###

#D - Lucky PIN
n=int(input())
s=list(str(input()))
password_list=[]
password_unique_list = []
for i in range(0,n-2):
    for j in range (i+1, n-1):
        for k in range  (j+1, n):
            password_i = s[i]
            password_j = s[j]
            password_k = s[k]
            password = password_i + password_j + password_k
            password_list.append(password)
password_unique_list = set(password_list)
print(len(password_unique_list))

### FIXED CODE ###

#D - Lucky PIN
#000～999までそれぞれ作成できるかをチェックする
n=int(input())
s=str(input())
ans = 0
for i in range (10):
    for j in range (10):
        for k in range (10):
            check_i = (s.find(str(i)))
            check_j = (s.find(str(j),check_i+1))
            check_k = (s.find(str(k),check_j+1))
            if(check_i >= 0 and check_j >= 0 and check_k >= 0):
                ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
# BITの定義
import math
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    # index 1からiの値の和を返す
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    # index iの値にxを加算する
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

#######################
# 開始
p_list = XY[:]

# y座標の圧縮
from operator import itemgetter
p_list = sorted(p_list, key=itemgetter(1))
p_list = [ (x, y, i+1) for i, (x, y) in enumerate(p_list)]

# xでソート
p_list= sorted(p_list)

a = [0] * N # 左下
b = [0] * N# 左上
c = [0] * N# 右下
d = [0] * N# 右上

# a,bを求める
bit = Bit(N)
for i, (x, y, r) in enumerate(p_list):
    tmp = bit.sum(r)
    a[i] = tmp
    b[i] = i-tmp
    bit.add(r, 1)

# c,dを求める
bit = Bit(N)
for i, (x, y, r) in enumerate(reversed(p_list)):
    tmp = bit.sum(r)
    c[i] = tmp
    d[i] = i-tmp
    bit.add(r, 1)
c = c[::-1]
d = d[::-1]

# ある点が四角に含まれる場合の総数を求めるメソッド
power = [1] * N
for i in range(1, N):
    power[i] = power[i-1] * 2 % 998244353
 
ans = 0
for _a,_b,_c,_d in zip(a,b,c,d):
    _a = power[_a] - 1
    _b = power[_b] - 1
    _c = power[_c] - 1
    _d = power[_d] - 1
    
    ret = (_a+1) * (_d+1) * _c * _b
    ret += (_b+1) * (_c+1) * _a * _d
    ret -= _a*_b*_c*_d
    ret += power[N-1]
    ans += ret % 998244353
    
print(ans % 998244353)   


### FIXED CODE ###

N = int(input())

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
# BITの定義
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    # index 1からiの値の和を返す
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    # index iの値にxを加算する
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

#######################
# 開始
from operator import itemgetter
def solve():
    p_list = XY[:]

    # y座標の圧縮
    p_list = sorted(p_list, key=itemgetter(1))
    p_list = [ (x, y, i+1) for i, (x, y) in enumerate(p_list)]

    # xでソート
    p_list= sorted(p_list)

    # ある点が四角に含まれる場合の総数を求めるメソッド
    power = [1] * N
    for i in range(1, N):
        power[i] = power[i-1] * 2 % 998244353

    # a,bを求める
    bit = Bit(N)
    ans = 0
    for i, (x, y, r) in enumerate(p_list):
        tmp = bit.sum(r)
        a = tmp
        b = i-tmp
        c = r-tmp-1
        d = (N-r+1)-(i-tmp)-1
        bit.add(r, 1)
        _a = power[a] - 1
        _b = power[b] - 1
        _c = power[c] - 1
        _d = power[d] - 1

        ret = (_a+1) * (_d+1) * _c * _b
        ret += (_b+1) * (_c+1) * _a * _d
        ret -= _a*_b*_c*_d
        ret += power[N-1]
        ans += ret % 998244353

    print(ans % 998244353)
    
solve()
### BUGGY CODE ###

n = int(input())

alist = list(map(int, input().split()))
for _ in range(n):
  print(sum(1 for x in alist if x==_+1))

### FIXED CODE ###

from collections import Counter
 
n = int(input())
a = list(map(int, input().split()))
 
c = Counter(a)
 
for _ in range(1, n+1):
  print(c[_])
### BUGGY CODE ###

import functools
import operator

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

prod = functools.partial(functools.reduce, operator.mul)
ans = prod(A_list)

if 10 ** 18 < ans:
    print('-1')
else:
    print(ans)




### FIXED CODE ###

def main():
    N = int(input())
    A_list = list(map(int, input().split()))

    if 0 in set(A_list):
        print(0)
        exit()

    ans = 1
    for i in A_list:
        ans *= i
        if 1000000000000000000 < ans:
            print('-1')
            exit()
    else:
        print(ans)


main()
### BUGGY CODE ###

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

def P(n):
  return n * (n + 1) / 2 / n
  
ans = []
for i in range(N - (K - 1)):
  a = []
  for j in range(K):
    a.append(p[i+j])
  if sum(a) > sum(ans):
    ans = a

A = 0
for x in range(K):
  A += P(ans[x])

print(A)

### FIXED CODE ###

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

a = 0
for i in range(N - K + 1):
  if i == 0:
    b = sum(p[0:K])
  else:
    b = b - p[i-1] + p[i + K - 1]
  
  if b > a:
    a = b
    f = i

ans = 0
for j in range(K):
  ans += (p[f + j] + 1) / 2

print(ans)
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect


def solve():
    n, m, q = map(int, input().split())
    nl = [[] for j in range(n + 1)]
    for i in range(m):
        l, r = map(int, input().split())
        bisect.insort_left(nl[l], r)
    table = [[0 for i in range(n + 1)] for j in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            table[i][j] = bisect.bisect_right(nl[i], j)

    for i in range(q):
        l, r = map(int, input().split())
        ans = 0
        for j in range(l, r + 1):
            ans += table[j][r] - table[j][l - 1]
        print(ans)


if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect
import array


def solve():
    n, m, q = map(int, input().split())
    nl = [[0 for i in range(n + 1)] for j in range(n + 1)]
    for e in [input().split() for _ in range(m)]:
        l, r = int(e[0]), int(e[1])
        nl[l][r] += 1
    table = [array.array("i", [0] * (n + 2)) for j in range(n + 2)]
    ran = array.array("i", range(n + 1))
    for i in ran:
        for j in ran:
            table[i][j + 1] = table[i][j] + nl[i][j]

    for i, e in enumerate([input().split() for _ in range(q)]):
        l, r = int(e[0]), int(e[1])
        ans = 0
        for j in range(l, r + 1):
            ans += table[j][r + 1] - table[j][l]
        print(ans)


if __name__ == "__main__":
    solve()
### BUGGY CODE ###

n,m = map(int, input().split())
l=[]
for _ in range (0,m):
    l.append(input())
if m == 0:
    print ("0 0")
    exit (0)

wa_total=0
ac_total=0
ac_list=[]

for i in range(0,m):
    if str(l[i].split()[1]) == "AC":
        if not str(l[i].split()[0]) in ac_list:
            ac_list.append(str(l[i].split()[0]))
            ac_total+=1
            for j in range(0,i):
                if int(l[j].split()[0]) == int(l[i].split()[0]):
                    if str(l[j].split()[1]) == "WA":
                        wa_total+=1

print (ac_total, wa_total)

### FIXED CODE ###

n,m = map(int,input().split())
ac = 0
wa = 0
wa_d = {}
ac_d = {}
for i in range(1,n+1):
    ac_d[str(i)] = False
    wa_d[str(i)] = 0

for _ in range(m):
    p,s = input().split()
    if s == "AC":
        if ac_d[p]:
            pass
        else:
            wa += wa_d[p]
            ac += 1
            ac_d[p] = True 
    else:
        wa_d[p] += 1

print (ac,wa)