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

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

k = 0
l = 0
acc = None

def count_up(y1, x1, y2, x2):
    global acc, l
    if y1 > y2 or x1 > x2:
        return 0
    y2 += 1
    x2 += 1
    return  acc[y2][x2] - acc[y1][x2] - acc[y2][x1] + acc[y1][x1]

def main():
    global acc, k, l
    n, k = map(int, sys.stdin.readline().split())
    xycs = (map(lambda x: int(x) if x != 'B' and x != 'W' else x,
                 line.split()) for line in sys.stdin.readlines())

    l = k * 2
    yxs = (((y + k) % l, x % l) if c == 'W' else (y % l, x % l) for x, y, c in xycs)

    acc = [[0] * (l + 1) for _ in range(l + 1)]
    for y, x in yxs:
        acc[y + 1][x + 1] += 1
    for j in range(l):
        for i in range(l):
            acc[j + 1][i + 1] += acc[j + 1][i] + acc[j][i + 1] - acc[j][i]

    max_cnt = 0
    for j in range(k):
        for i in range(k):
            cnt = count_up(0, 0, j - 1, i - 1) + count_up(0, i + k, j - 1, l - 1) + count_up(j, i, j + k - 1, i + k - 1) + count_up(j + k, 0, l - 1, i - 1) + count_up(j + k, i + k, l - 1, l - 1)
            max_cnt = max(max_cnt, max(n - cnt, cnt))

    print(max_cnt)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

k = 0
l = 0
acc = None

def count_up(y1, x1, y2, x2):
    global acc, l
    if y1 > y2 or x1 > x2:
        return 0
    y2 += 1
    x2 += 1
    return  acc[y2][x2] - acc[y1][x2] - acc[y2][x1] + acc[y1][x1]

def main():
    global acc, k, l
    n, k = map(int, sys.stdin.readline().split())
    xycs = (map(lambda x: int(x) if x != 'B' and x != 'W' else x,
                 line.split()) for line in sys.stdin.readlines())

    l = k * 2
    yxs = (((y + k) % l, x % l) if c == 'W' else (y % l, x % l) for x, y, c in xycs)

    acc = [[0] * (l + 1) for _ in range(l + 1)]
    for y, x in yxs:
        acc[y + 1][x + 1] += 1
    for j in range(l):
        for i in range(l):
            acc[j + 1][i + 1] += acc[j + 1][i] + acc[j][i + 1] - acc[j][i]

    max_cnt = 0
    for j in range(k):
        for i in range(k):
            cnt = count_up(0, 0, j - 1, i - 1) + count_up(0, i + k, j - 1, l - 1) + count_up(j, i, j + k - 1, i + k - 1) + count_up(j + k, 0, l - 1, i - 1) + count_up(j + k, i + k, l - 1, l - 1)
            max_cnt = max(max_cnt, max(n - cnt, cnt))

    print(max_cnt)

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

import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def reverse(S):
    return S[::-1]

def main():
    S = _S()
    Q = I()
    Querys = [LS() for _ in range(Q)]
    s = S
    for q in Querys:
        # print(q)
        if q[0]=='1':
            s = reverse(s)
        elif q[0]=='2':
            ti,fi,ci = q
            # print(ti,fi,ci)
            if fi=='1':
                s = ci + s
            elif fi=='2':
                s = s + ci
            else:
                pass
        else:
            pass
    print(s)

main()



### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S = _S()
    Q = I()
    Querys = [LS() for _ in range(Q)]
    rev_flg = -1
    dq = collections.deque(S)
    for q in Querys:
        if q[0]=='1':
            rev_flg *= -1
        else:
            ti,fi,ci = q
            if int(fi)*rev_flg in (1,-2):
                dq.append(ci)
            else:
                dq.appendleft(ci)

    print("".join(dq)[::-1] if rev_flg==1 else "".join(dq))

main()
### BUGGY CODE ###

from collections import Counter
n = int(input())
a = Counter(list(map(int, input().split())))
cnt = 0
for i in range(len(a)):
    k,v=a.most_common()[i][0],a.most_common()[i][1]
    if v-k < 0:
        cnt += v
    else:
        cnt += v-k
print(cnt)


### FIXED CODE ###

from collections import Counter
n = int(input())
a = Counter(list(map(int, input().split())))
cnt = 0
for k, v in Counter(a).items():
    if k > v:
        cnt += v
    else:
        cnt += (v-k)
print(cnt)
### BUGGY CODE ###

import itertools
from heapq import heapify, heappop, heappush, heappushpop
nCr = {}






class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap


heap = []  # ヒープといっても順序を工夫したただのリスト

q = PriorityQueue(heap) #ここでインスタンスを作ってます
n = int(input())
l = list(map(int, input().split()))
mod = 1000000007
result = []
for i in range(len(l)):
    for j in range(i + 1, len(l)):
        result.append([l[i], l[j]])
for a,b in result:
    q.push(((a % mod) * (b % mod)) % mod)
print(sum(heap) % mod)


### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
mod = 1000000007
q = sum(l)
ans = 0
for i in range(len(l)):
    q -= l[i]
    ans += l[i] * q % mod
print(ans % mod)
### BUGGY CODE ###

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

list = [1]*N

for i in range(M):
	L, R = map(int, input().split())
	list[:L-1] = [0]*len(list[:L-1])
	list[R:] = [0]*len(list[R:])

print(list.count(1))
  


### FIXED CODE ###

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

llist = []
rlist = []

for i in range(M):
  L, R = map(int, input().split())
  llist.append(L)
  rlist.append(R)

if min(rlist) >= max(llist):
  print(min(rlist) - max(llist) + 1)
else:
  print(0)
### BUGGY CODE ###

from numba import jit
import numpy as np

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


ansSet = set(A)

for i in range(1, N + 1):
    if i in ansSet:
        print(A.count(i))
    else:
        print(0)


### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))

C = Counter(A)


for i in range(1, N + 1):
    if i in C.keys():
        print(C[i])
    else:
        print(0)
### BUGGY CODE ###

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

ans = []
for i in range(1, len(A) + 1):
    temp = A.index(i)
    ans.append(temp + 1)

print(*ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = [0] * N

for i in range(1, N + 1):
    ans[A[i - 1] - 1] = i

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

n,m=map(int,input().split())
p = [int(i)-1 for i in input().split() ]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

      
uf = UnionFind(n)
for i in range(m):
    x,y = map(int,input().split())
    uf.union(x-1,y-1)

ans=0
groups = uf.all_group_members().values()
for cand in groups:
    ans+=len(set(cand) & set(p[i] for i in cand) )
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
p = [int(i)-1 for i in input().split() ]


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

from collections import deque

groups=[]
been=[0]*n
for i in range(n):
    if been[i]==0:
        group=[i]
        been[i]=1
        q = deque([(i,togo) for togo in tree[i]]) 
        while q:
            parent,x = q.popleft()
            if been[x]==1:
                continue
            been[x]=1
            group.append(x)
            for y in tree[x]:
                if y == parent:#親ノードを飛ばし
                    continue
                q.append((x,y))#子ノードを追加
        groups.append(group)

ans=0
for group in groups:
    ans+= len( set(group) & set(p[g] for g in group) )

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

N = int(input())
s = [input().split() for i in range(N)]
count = 0

s = [sorted(str(i)) for i in s]
for i in range(N):
    for j in range(i+1, N):
        if s[i] == s[j]:
            count += 1
print(count)


### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)
### BUGGY CODE ###

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

has_visited = [False]*N
score_max = -float('inf')

for i in range(N):
    if has_visited[i]:
        continue
    
    loop_val = []

    j = i
    while True:
        loop_val.append(C[j])
        has_visited[j] = True
        j = P[j] - 1
        if loop_val[0] == C[j]:
            break
    
    # sum_arr = [0]
    # loop_length = len(loop_val)

    # for k in range(1, loop_length + K):
    # sum_arr.append(sum_arr[k-1] + loop_val[(k - 1) % loop_length])

    # print(loop_val)

    sm = 0
    for p in range(len(loop_val)):
        sm += loop_val[p]
    
    # print(sm)
    
    loop_length = len(loop_val)

    for l in range(loop_length):
        res = -1
        s = 0
        for k in range(K):
            s = max([s + loop_val[(k+l) % loop_length], loop_val[(k+l) % loop_length]])
            res = max([res, s])
        
        if res == -1:
            res = max(loop_val)
        
        # print(res)

        if score_max < res:
            score_max = res

print(score_max)

### FIXED CODE ###

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

res = -10**10

for i in range(N):
    j = i
    total = 0
    loop_values = []

    while True:
        j = P[j] - 1
        loop_values.append(C[j])
        total += C[j]
        if j == i:
            break
    
    loop_length = len(loop_values)
    point_sum = 0

    for j in range(loop_length):
        point_sum += loop_values[j]
        result_cand = point_sum

        if j+1 > K:
            break

        if total > 0:
            loop_num = (K - j - 1) // loop_length
            result_cand += total * loop_num
        
        if res < result_cand:
            res = result_cand

print(res)
### BUGGY CODE ###

n=int(input())
a=[int(input())for _ in range(n)]

for i in range(n):
  if a[i]==max(a):
    print(sorted(a)[-2])
  else:
    print(max(a))

### FIXED CODE ###

n=int(input())
a=[int(input())for _ in range(n)]
b=sorted(a)

for i in a:
  if i==b[-1]:
    print(b[-2])
  else:
    print(b[-1])
### BUGGY CODE ###

import fractions
A, B = map(int, input().split())
f=fractions.gcd(A,B)

ans = 1
i = 2
while i <= f:
    if f % i == 0:
        ans += 1
    while f % i == 0:
        f = f//i
    i += 1
    
print(ans)

### FIXED CODE ###

import fractions
A, B = map(int, input().split())
f=fractions.gcd(A,B)

ans = 1
i = 2
while i ** 2 <= f:
    if f % i == 0:
        ans += 1
    while f % i == 0:
        f = f//i
    i += 1

ans +=(f>1)
print(ans)
### BUGGY CODE ###

n, q = (int(x) for x in input().split())
s = input()
s = [s[i] for i in range(n)]
lr = []
for i in range(q):
    lr.append([int(x) for x in input().split()])
ac = [0 for _ in range(n)]
i = 0
while i < n:
    if s[i] == "A":
        i += 1
        if s[i] == "C":
            ac[i-1] = 1
            ac[i] = 1
        else: i += 1
    else: i += 1
for p in lr:
    l, r = p[0] - 1, p[1] - 1
    a = sum(ac[l:r]) + ac[r]
    if s[l] == "C" and ac[l] == 1: a -= 1
    if s[r] == "A" and ac[r] == 1: a -= 1
    print(int(a/2))

### FIXED CODE ###

n, q = (int(x) for x in input().split())
s = input()
s = [s[i] for i in range(n)]
lr = []
for i in range(q):
    lr.append([int(x) for x in input().split()])
ac = [0 for _ in range(n)]
i, c = 0, 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        ac[i+1] = ac[i] + 1
    else:
        ac[i+1] = ac[i]
for p in lr:
    l, r = p[0] - 1, p[1] - 1
    print(int(ac[r] - ac[l]))
### BUGGY CODE ###

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

P = 998244353

N, A, B, K = reads()

fact = [1]
for i in range(1, N+1):
  fact.append(fact[i-1] * i % P)

def egcd(a, b):
  if b == 0:
    return a, 1, 0
  else:
    q, r = divmod(a, b)
    g, x, y = egcd(b, r)
    return g, y, x - q * y

def inv(n):
  g, x, _ = egcd(n, P)
  # assert g == 1
  return x

invfact = [inv(fact[i]) for i in range(N+1)]

def comb(n, k):
  # assert 0 <= k <= n
  return fact[n] * invfact[k] * invfact[n-k] % P

result = 0
for x in range(N+1):
  y, r = divmod(K - A * x, B)
  if r == 0 and 0 <= y <= N:
    result = result + comb(N, x) * comb(N, y) % P

print(result % P)

### FIXED CODE ###

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

P = 998244353

N, A, B, K = reads()

def inv(n):
  return pow(n, P-2, P)

fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i % P

invfact = [inv(fact[N])] * (N+1)
for i in range(N, 0, -1):
  invfact[i-1] = invfact[i] * i % P

def comb(n, k):
  # assert 0 <= k <= n
  return fact[n] * invfact[k] * invfact[n-k] % P

result = 0
for x in range(N+1):
  y, r = divmod(K - A * x, B)
  if r == 0 and 0 <= y <= N:
    result = result + comb(N, x) * comb(N, y) % P

print(result % P)
### BUGGY CODE ###

a,b,k = map(int, input().split())
l = [i for i in range(a,b+1)]
l = l[:k] + l[-k:]
for i in sorted(list(set(l))):
    print(i)

### FIXED CODE ###

a,b,k = map(int, input().split())
l=range(a,b+1)
for i in sorted(set(l[:k])|set(l[-k:])):
    print(i)
### BUGGY CODE ###

S = input()
Q = int(input())
reverse = 1
for i in range(Q):
    list = input()
    if list[0] == "1":
        reverse *= -1
    else:
        list = list.split()
        if reverse == 1:
            if list[1] == "2":
                S = S + list[2]
            else:
                S = list[2] + S
        else:
            if list[1] == "2":
                S = list[2] + S
            else:
                S = S + list[2]
if reverse == 1:
    print(S)
else:
    print(S[::-1])

### FIXED CODE ###

S = input()
S2 = ""
Q = int(input())
reverse = 1
for i in range(Q):
    list = input()
    if list[0] == "1":
        reverse *= -1
    else:
        if reverse == 1:
            if list[2] == "2":
                S += list[4]
            else:
                S2 += list[4]
        else:
            if list[2] == "2":
                S2 += list[4]
            else:
                S += list[4]
if reverse == 1:
    print(S2[::-1] + S)
else:
    print(S[::-1] + S2)
### BUGGY CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

for val in range(A, B+1):
    if val<=A+K-1 or B-K+1<=val:
        print(val)


### FIXED CODE ###

def main():
    import sys
    def input(): return sys.stdin.readline()[:-1]
    pl = lambda x: print(*x, sep='\n')

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

    for val in range(A, B+1):
        if val<=A+K-1 or B-K+1<=val:
            print(val)

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

N = int(input())

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

lis.sort()

Ans = 0

p = 0

while(True):
	
	if p >= N:
		break
	
	if lis[p] > lis.count(lis[p]):
		Ans += lis.count(lis[p])
		p += lis.count(lis[p])
		continue
	
	if lis[p] == lis.count(lis[p]):
		p += lis.count(lis[p])
		continue
	
	if lis[p] < lis.count(lis[p]):
		Ans += lis.count(lis[p]) - lis[p]
		p += lis.count(lis[p])
		
print(Ans)

### FIXED CODE ###

from collections import Counter

N = int(input())

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

counter = Counter(numList)

ans = 0

for k, v in counter.items():
	if(k == v):
		continue
	elif(k < v):
		ans += v-k
	elif(k > v):
		ans += v

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

from collections import deque

def solve():
    S = list(input())
    M = int(input())
    Q = [list(input().split()) for _ in range(M)]
    
    s = deque(S)
    for q in Q:
        if q[0] == '1':
            s.reverse()
        else:
            ad = q[2]
            if q[1] == '1':
                s.appendleft(ad)
            else:
                s.append(ad)
    ans = ''.join(s)
    return ans

print(solve())

### FIXED CODE ###

from collections import deque

def solve():
    S = list(input())
    M = int(input())
    Q = [list(input().split()) for _ in range(M)]
    
    bef = deque([])
    s = deque(S)
    aft = deque([])
    c = 0
    
    for q in Q:
        if q[0] == '1':
            c += 1
        else:
            ad = q[2]
            if q[1] == '1':
                # 先頭
                if c % 2 == 0:
                    bef.appendleft(ad)
                else:
                    aft.append(ad)
            else:
                # 末尾
                if c % 2 == 0:
                    aft.append(ad)
                else:
                    bef.appendleft(ad)

    ans = ''.join(bef) + ''.join(s) + ''.join(aft)
    if c % 2 == 1:
        ans = ans[::-1]

    return ans

print(solve())
### BUGGY CODE ###

H, N = map(int, input().split())
AB = [0] * N
damage = [0] * N
for i in range(N):
  AB[i] = list(map(int, input().split()))
  damage[i] = AB[i][0]
  
x = min(AB, key = lambda x:x[1])
x = x[1]
  
DP = [10 ** 10] * (10 ** 4 + 1)#ダメージを与える最小魔力
DP[0] = 0

for i in range(1, 10 ** 4 + 1):
  for j in range(i):
    if j in damage:
      p = damage.index(j)
      DP[i] = min(DP[i], DP[i - j] + AB[p][1])
  if DP[i] == 10 ** 10:
    DP[i] = x
  
print(DP[H])    


### FIXED CODE ###

H, N = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
  a, b = list(map(int, input().split()))
  A[i] = a
  B[i] = b
  
#モンスターの体力を i 減らすため消耗する魔力の最小値  
DP = [float("inf")] * (H + max(A) + 1)
DP[0] = 0  
for i in range(len(DP)):
  for j in range(N):
    if i - A[j] >= 0:
      DP[i] = min(DP[i], DP[i - A[j]] + B[j])
#print(DP) 
print(min(DP[H:H + max(A) + 1]))
### BUGGY CODE ###

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

    S = [0] * N
    S[0] = 0

    for i in range(1, N):
        value = S[i - 1] + abs(h[i] - h[i - 1])
        for step in range(1, K + 1):
            # print("i, k:", i, k)
            if i - step < 0:
                break
            value = min(value, S[i - step] + abs(h[i] - h[i - step]))
            #print("value", value)
        S[i] = value
        # print(S)
    # print(S)
    print(S[N - 1])

if __name__ == "__main__":
    main()


### FIXED CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-K),i))
print(dp[N-1])
### BUGGY CODE ###

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

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

dp = [float("inf") for i in range(n)]

dp[0] = 0
for idx, h in enumerate(hl):
    for i in range(1,k+1):
        if i + idx < n:
            dp[idx+i] = min(dp[idx+i], dp[idx]+ abs(hl[idx]-hl[i+idx]))


print(dp[n-1])

### FIXED CODE ###

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

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

dp = [float("inf") for i in range(n)]

dp[0] = 0
for idx, h in enumerate(hl):
    for i in range(1,k+1):
        if i + idx < n:
            dp[idx+i] = min(dp[idx+i], dp[idx]+ abs(hl[idx]-hl[i+idx]))


print(dp[n-1])
### BUGGY CODE ###

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

ans = 0
from collections import Counter
mods = Counter()
for a in A:
    mods = Counter({(k + a) % M: v for k, v in mods.items()})
    mods[a % M] += 1
    ans += mods[0]

print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
A = [0] + list(map(int, input().split()))
from itertools import accumulate
acc = accumulate(A)

from collections import Counter
cnt_mod = Counter([a % M for a in acc])
ans = 0
for k in cnt_mod.values():
    ans += k * (k - 1) // 2
print(ans)
### BUGGY CODE ###

n,m = map(int,input().split())
a = [int(x) for x in input().split()]
cc = sorted([list(map(int,input().split())) for _ in range(m)], key=lambda x:x[1], reverse=True)

for card in cc:
    for i in range(card[0]):
        if min(a) < card[1]:
            a[a.index(min(a))] = card[1]
        else:
            print(sum(a))
            exit()
print(sum(a))

### FIXED CODE ###

n,m = map(int,input().split())
a = [int(x) for x in input().split()]
cc = sorted([list(map(int,input().split())) for _ in range(m)], key=lambda x:x[1], reverse=True)
t = 0
for b, c in cc:
    a.extend([c] * b)
    t += b
    if t > n:
        break
a.sort(reverse=True)
print(sum(a[:n]))
### BUGGY CODE ###

import math

n, k = map(int, input().split(" "))
pL = list(map(int, input().split(" ")))

mx = 0
for i in range(len(pL) - k + 1):
    sm = 0
    for j in range(k):
        sm += pL[i + j]
    mx = max(sm, mx)

print((mx + k) / 2)

### FIXED CODE ###

import math

n, k = map(int, input().split(" "))
pL = list(map(int, input().split(" ")))

mx = 0
cs = 0
for i in range(k):
    cs += pL[i]
    mx = cs
for i in range(1, len(pL) - k + 1):
    cs = cs - pL[i - 1] + pL[i + k - 1]
    mx = max(mx, cs)
print((mx + k) / 2)
### BUGGY CODE ###

from math import sqrt, ceil, factorial
from collections import Counter

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    return a//factorial(r)

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
ans = 1
for v in c.values():
    ans *= (comb(v + N - 1, v) % m)
print(ans%m)

### FIXED CODE ###

from math import sqrt, ceil, factorial
from collections import Counter

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    return a//factorial(r)

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
ans = 1
for v in c.values():
    ans *= (comb(v + N - 1, v) % m)
print(ans%m)