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

import sys
input = sys.stdin.readline
def main():
    N,K = list(map(int, input().split()))
    p = list(map(int, input().split()))
    n = N-K+1
    kitai = [None] * n
    for i in range(N-K+1):
        kitai[i] = ((sum((p[i:i+K]))+K)*0.5)
    print('{:.12f}'.format(max(kitai)))
main()


### FIXED CODE ###

N,K = list(map(int, input().split()))
p = list(map(int, input().split()))
p2 = [p[i]*0.5 + 0.5 for i in range(N)]
size = N + 1
cusum = [0] * size
max = 0

for i in range(N):
    cusum[i+1] = cusum[i] + p2[i]

for i in range(N-K+1):
    tmp = cusum[i+K] - cusum[i]
    if max < tmp:
        max = tmp
print(max)
### BUGGY CODE ###

N, M = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(M)]
cnt = 0
for i in range(1, N+1):
  isOk = True
  for start, end in l:
    if i < start or i > end:
      isOk = False
      break
  if isOk == True:
    cnt = cnt + 1

print(cnt)

### FIXED CODE ###

from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(M)]

sMax = 0
eMin = 0
for s, e in l:
  if sMax < s or sMax == 0:
    sMax = s
  if eMin > e or eMin == 0:
    eMin = e

if eMin - sMax >= 0:
  print(eMin - sMax + 1)
else:
  print(0)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    N,x = map(int,input().split())
    count = N
    N *= 2
    a = list(map(int,input().split()))
    ans = sum(a)
    a += a
    
    def segfunc(x,y):
        return min(x,y)
        
    def init(init_val):
        for i in range(N):
            seg[i+num-1] = init_val[i]
        for i in range(num-2,-1,-1):
            seg[i] = segfunc(seg[2*i+1],seg[2*i+2])
                
    def update(k,x):
        k += num-1
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[2*k+1],seg[2*k+2])
            
    def query(p,q):
        if q <= p:
            return ide_ele
        p += num-1
        q += num-2
        ret = ide_ele
        while q-p > 1:
            if p&1 == 0:
                ret = segfunc(ret,seg[p])
            if q&1 == 1:
                ret = segfunc(ret,seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        ret = segfunc(segfunc(ret,seg[p]),seg[q])
        return ret
        
    ide_ele = 10**15
    num = 2**(N-1).bit_length()
    seg = [ide_ele]*2*num
    init(a)
    
    for i in range(count-1):
        i += 1
        time = i*x
        for now in range(count):
            ret = query(now+count-i,now+count+1)
            time += ret
        ans = min(ans,time)
        
    print(ans)

if __name__ == "__main__":
    main()
    


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    N,x = map(int,input().split())
    a = list(map(int,input().split()))
    b = a.copy()
    
    ans = 10**15
    for i in range(N):
        time = i*x+sum(b)
        ans = min(ans,time)
        for now in range(N):
            b[now] = min(b[now],a[(now-i-1+N)%N])

    print(ans)

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

import sys
n,m = map(int, sys.stdin.readline().rstrip("\n").split())
cage = {}
for i in range (2,n+1):
    cage[i] = None
ab = [map(int, line.rstrip("\n").split()) for line in sys.stdin]
a,b = [list(i) for i in zip(*ab)]
room = [1]
nroom = []
while None in cage.values():
    for i in range(len(room)):
        j = 0
        while j < (len(a)):
            if a[j] == room[i]:
                if cage[b[j]] == None:
                    cage[b[j]] = a[j]
                nroom.append(b[j])
                a.pop(j)
                b.pop(j)
            elif b[j] == room[i]:
                if cage[a[j]] == None:
                    cage[a[j]] = b[j]
                nroom.append(a[j])
                a.pop(j)
                b.pop(j)
            else:
                j += 1
    if room == nroom:
        print('No')
        break
    room = nroom[:]
    nroom.clear()
else:
    print('Yes')
    for i in range (2,n+1):
        print(cage[i])

### FIXED CODE ###

import sys
import queue
n,m = map(int, sys.stdin.readline().rstrip("\n").split())
adj = [[]for i in range(n+1)]
parent = [-1] * (n+1)
for line in sys.stdin:
    a,b = map(int, line.rstrip("\n").split())
    adj[a].append(b)
    adj[b].append(a)
q = queue.Queue()
q.put((1,0))
while(not q.empty()):
    x, p = q.get()
    if parent[x] != -1: # 訪問済み
        continue
    parent[x] = p
    for next in adj[x]:
        if parent[next] == -1: # 未訪問なら
            q.put((next,x))
print ('Yes') # 必ず目標は達成できる
for p in parent[2:]: # 部屋2以降の親（前の部屋）
    print(p)
### BUGGY CODE ###

k=int(input())
ans=1
mod=7%k
mod1=7%k
if k%2==0:
  print(-1)
  
else:
  
  while mod1!=0:
    mod=(mod*10)%k
    mod1=mod1+mod
    if mod1>=k:
      mod1=mod1%k
    ans+=1
  
  print(ans)
    



### FIXED CODE ###

import sys
k=int(input())
d={}
ans=1
mod=7%k
mod1=7%k
d[mod1]=1
ch=0
  
while mod1!=0:
  mod=(mod*10)%k
  mod1=mod1+mod
  if mod1>=k:
    mod1=mod1%k
  if mod1 in d:
    ch+=1
    break
  if mod1 not in d:
    d[mod1]=1
  ans+=1
  
if ch==0:
  print(ans)
else:
  print(-1)
### BUGGY CODE ###

def main():
    n = int(input())
    v = [int(v) for v in input().split()]
    c = [int(c) for c in input().split()]

    max_total = 0
    for i in range(2 ** n):
        total = 0
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                total += v[j]
                total -= c[j]
        if total > max_total:
            max_total = total
    print(max_total)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    v = [int(v) for v in input().split()]
    c = [int(c) for c in input().split()]

    total = 0
    for nn in range(n):
        if v[nn] > c[nn]:
            total += v[nn]
            total -= c[nn]
    print(total)

    # max_total = 0
    # for i in range(2 ** n):
    #     total = 0
    #     for j in range(n):  # このループが一番のポイント
    #         if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
    #             total += v[j]
    #             total -= c[j]
    #     if total > max_total:
    #         max_total = total
    # print(max_total)

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

from collections import defaultdict
import copy


mod = 10 ** 9 + 7
primes = []
for i in range(2,1002):
  for prime in primes:
    if not i % prime:
      break
  else:
    primes.append(i)

def factorize(n):
  now = n
  fct = dict()
  for prime in primes:
    cnt = 0
    if prime ** 2 > n:
      break
    while not now % prime:
      now //= prime
      cnt += 1
    if cnt:
      fct[prime] = cnt
  if now > 1:
    fct[now] = 1
  return fct


n = int(input())
a = list(map(int, input().split()))
fct_a = list()
for i in a:
  fct_a.append(factorize(i))
lcm = defaultdict(int)
for i in fct_a:
  for k,v in i.items():
    lcm[k] = max(lcm[k], v)
ans = 0
for i in fct_a:
  bi = copy.copy(lcm)
  for k,v in i.items():
    bi[k] -= v
  b = 1
  for k,v in bi.items():
    b *= k ** v
    b %= mod
  ans += b
ans %= mod
print(ans)

### FIXED CODE ###

import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

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

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)
### BUGGY CODE ###

import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import coo_matrix


def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])


def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and pred_row[i] > 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]


read = sys.stdin.read
N, u, v, *AB = map(int, read().split())

a = AB[::2]
b = AB[1::2]
d = [1] * (N - 1)

graph = coo_matrix((d, (a, b)), shape=(N + 1, N + 1))
takahashi, aoki = dijkstra(graph, directed=False, indices=[u, v])
n = np.where(takahashi < aoki)
print(int(aoki[n].max()) - 1)


### FIXED CODE ###

import sys

read = sys.stdin.read
N, u, v, *AB = map(int, read().split())

graph = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    graph[a].append(b)
    graph[b].append(a)


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


DU, DV = dfs(u), dfs(v)

answer = 0
for u, v in zip(DU[1:], DV[1:]):
    if u < v:
        tmp = v - 1
        if answer < tmp:
            answer = tmp

print(answer)
### BUGGY CODE ###

from itertools import product
import operator

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

value, cost, ans = [0, 0, 0]
for x in product([0, 1], repeat=n):
    value = sum(map(operator.mul, v, x))
    cost = sum(map(operator.mul, c, x))
    ans = max(ans, value - cost)

print(ans)

### FIXED CODE ###

from itertools import product
import operator

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

value, cost, ans = [0, 0, 0]
for x in product([0, 1], repeat=n):
    value = sum(map(operator.mul, v, x))
    cost = sum(map(operator.mul, c, x))
    ans = max(ans, value - cost)

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

import sys
input = sys.stdin.readline

from collections import defaultdict

def prime_factors(d,N): #素因数 1を含まないことに注意
    ret = []
    middle = int( N**(1/2))
    tmp = N
    for i in range(2, middle+1):
        if tmp%i == 0:
            c = 0
            while tmp%i == 0:
                tmp //= i
                c += 1
            if d[i] < c:
                d[i] = c
    if tmp != 1:
        if d[tmp] == 0:
            d[tmp] = 1

Q = 10**9+7
def main():
    N = int( input())
    A = list( map( int, input().split()))
    d = defaultdict( int)
    for a in A:
        prime_factors(d, a)
    s = 1

    for key, value in d.items():
        s *= pow( key, value)
    ans = 0
    for a in A:
        ans += s//a
        ans %= Q
    print(ans)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

from collections import defaultdict

def prime_factors(d,N): #素因数 1を含まないことに注意
    ret = []
    middle = int( N**(1/2))
    tmp = N
    for i in range(2, middle+1):
        if tmp%i == 0:
            c = 0
            while tmp%i == 0:
                tmp //= i
                c += 1
            if d[i] < c:
                d[i] = c
    if tmp != 1:
        if d[tmp] == 0:
            d[tmp] = 1

Q = 10**9+7
def main():
    N = int( input())
    A = list( map( int, input().split()))
    d = defaultdict( int)
    for a in A:
        prime_factors(d, a)
    s = 1

    for key, value in d.items():
        s *= pow( key, value)
    ans = 0
    for a in A:
        ans += s*pow(a,Q-2,Q)
    print(ans%Q)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

x, k, d = map(int, input().split())
for i in range(k):
  if x > 0:
    x -= d
  else:
    x += d
print(abs(x))

### FIXED CODE ###

x, k, d = map(int, input().split())
r = x % d
q = (x - r) // d
if abs(x) >= k*d:
  if x>0:
    ans = x-k*d
  else:
    ans = abs(x+k*d)
elif k%2 == q%2:
  ans = r
else:
  ans = d - r
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def func(x, nn):
    value = 0
    for i in range(nn - 1):
        for j in range(i + 1, nn):
            value += x[i] ^ x[j]
    ans = value % (10 ** 9 + 7)
    return ans

n = int(input())
li = list(map(int, input().split()))
print(func(li, n))


### FIXED CODE ###

import numpy as np
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
s = 0

for i in range(60):
    t = arr & 1
    c1 = np.count_nonzero((arr & 1))
    s += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(s % mod)
### BUGGY CODE ###

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


for gakki in range(k+1,n+1):
    pre = A[gakki-k-1:gakki-1]
    #pre_ = 1
    #for p in pre:
        #pre_ *= p

    
    k_gakki = A[gakki-k:gakki]
    #k_gakki_ = 1
    #for ga in k_gakki:
        #k_gakki_ *= ga
    
    #if pre_ < k_gakki_:
    if pre[0] < k_gakki[-1]:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

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


for gakki in range(k+1,n+1):
    #pre = A[gakki-k-1:gakki-1]
    pre = A[gakki-k-1]
    #pre_ = 1
    #for p in pre:
        #pre_ *= p

    
    #k_gakki = A[gakki-k:gakki]
    k_gakki = A[gakki-1]
    #print(k_gakki)
    #k_gakki_ = 1
    #for ga in k_gakki:
        #k_gakki_ *= ga
    
    #if pre_ < k_gakki_:
    if pre < k_gakki:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n=int(input())

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

if n==2:
  print(abs(r[0]-r[1]))
  exit()

border=sum(r)//2+1
result="INF"
for i in range(1,n):
  #print(r[:i],r[i:])
  if result=="INF":
    result=abs(sum(r[:i])-sum(r[i:]))
  else:
    result=min(result,abs(sum(r[:i])-sum(r[i:])))
  
  if sum(r[:i])>=border:
    print(result)
    exit()
print(result)
  





### FIXED CODE ###

n=int(input())

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

if n==2:
  print(abs(r[0]-r[1]))
  exit()
 

#print(r)

temp=sum(r)

goukei=0
for item in r:
  if goukei+item>=temp/2.0:
    
    if abs(temp-goukei-goukei)<=abs((temp-(goukei+item))-(goukei+item)):
      print(abs(temp-goukei-goukei))
    else:
      print(abs((temp-(goukei+item))-(goukei+item)))
    exit()
  goukei=goukei+item
  
goukei=goukei-item
  
print(abs(temp-(goukei-item)))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
#%%
def dfs(gr,li):
    st = []
    seen = set()
    st.append([0,-1])
    while(st):
        x,fr = st.pop()
        if(x in seen):continue
        if(fr != -1):
            li[x]+=li[fr]
        for i in gr[x]:
            if(i==fr):continue
            st[0:0] = [[i,x]]
        seen.add(x)

#%%
def main():
    N,Q = [int(x) for x in input().split()]
    li = [0]*N
    gp = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = input().split()
        a = int(a)
        b = int(b)
        gp[a-1].append(b-1)
        gp[b-1].append(a-1)

    for _ in range(Q):
        p,x = input().split()
        li[int(p)-1] += int(x)

    dfs(gp,li)
    print(*li)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N,Q = [int(x) for x in input().split()]
    li = [0]*N
    gp = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = input().split()
        a = int(a)
        b = int(b)
        gp[a-1].append(b-1)
        gp[b-1].append(a-1)

    for _ in range(Q):
        p,x = input().split()
        li[int(p)-1] += int(x)

    st = []
    seen = set()
    st.append(0)
    while(st):
        x = st.pop()
        if(x in seen):continue
        seen.add(x)
        for i in gp[x]:
            if(i in seen):continue
            li[i]+=li[x]
            st.append(i)
    print(*li)

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

n = int(input())
for i in range(1, n+1):
    a = 0
    for x in range(1, int(i**(1/2))):
        for y in range(x, int((i-x**2)**(1/2))):
            for z in range(y, int((i-x**2-y**2)**(1/2))):
                if x**2+y**2+z**2+x*y+y*z+z*x == i:
                    if x == y and y == z and z == y:
                        a += 1
                    elif x ==y or y == z or z == y:
                        a += 3
                    else:
                        a += 6
    print(a)

### FIXED CODE ###

n = int(input())
a = [0]*n
s = int(n**(1/2))+1
for i in range(1, s):
    for j in range(1, s):
        for k in range(1, s):
            b = i*i+j*j+k*k+i*j+j*k+k*i-1
            if b < n:
                a[b] += 1
for i in range(n):
    print(a[i])
### BUGGY CODE ###

N = int(input())
l = []
for i in map(int, input().split()):
    if i in l:
        print("NO")
        exit()
    l.append(i)
print("YES")

### FIXED CODE ###

N = int(input())
A = set(map(int, input().split()))
print("YES" if len(A) == N else "NO")
### BUGGY CODE ###

n, x, m = map(int, input().split())
def am(a, b):
    return (a * a) % b
l = [x]
u = []
now = x
for i in range(n):
    s = am(now, m)
    if(s in l):
        break
    l.append(s)
    now = s
c = l.index(s)
k = 0
if(0 in l):
    print(sum(l))
else:
    for i in range(c):
        u.append(l.pop(0))
    a = (n-len(u)) // len(l)
    b = (n-len(u)) % len(l)
    print(sum(u) + a * sum(l) + sum(l[:b]))

### FIXED CODE ###

n, x, m = map(int, input().split())
def am(a, b):
    return (a * a) % b
l = [x]
u = []
now = x
for i in range(n):
    s = am(now, m)
    if(s in l):
        break
    l.append(s)
    now = s
c = l.index(s)
k = 0
if(0 in l):
    print(sum(l))
else:
    for i in range(c):
        u.append(l.pop(0))
    a = (n-len(u)) // len(l)
    b = (n-len(u)) % len(l)
    print(sum(u) + a * sum(l) + sum(l[:b]))
### BUGGY CODE ###

n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max(d)+1):
        dc = d.count(i)
        if dc == 0:
            print(0)
            exit()
        if dc == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dc)
        b = dc
    print(ans % 998244353)
else:
    print(0)

### FIXED CODE ###

n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
max = 0
dd=[0]*10**5
for i in d:
    dd[i]+=1
    if(max<i):
        max=i
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max+1):
        if dd[i] == 0:
            print(0)
            exit()
        if dd[i] == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dd[i], 998244353)
        b = dd[i]
    print(ans % 998244353)
else:
    print(0)
### BUGGY CODE ###

from collections import defaultdict

S = input()

ans = 0

kTarget = 2019

carries = {0:1}

ord_z = ord('0')
for d in S[::-1]:
    d = ord(d) - ord_z
    next_carries = defaultdict(int)
    for carry, cnt in carries.items():
        x = carry - d
        mult = x%10
        x += mult*kTarget
        if carry != 0 and x == 0:
            ans += cnt
        x //= 10
        x %= kTarget
        next_carries[x] += cnt
    next_carries[0] += 1
    carries = next_carries
print(ans)



### FIXED CODE ###

from collections import defaultdict

S = input()
kTarget = 2019

mod2cnt = defaultdict(int)
mod2cnt[0] += 1

ord_z = ord('0')
res = 0
for i in range(len(S)-1, -1, -1):
    d = ord(S[i]) - ord_z
    res = (res+d*pow(10, len(S)-1-i, kTarget))%kTarget
    mod2cnt[res] += 1

ans = 0
for cnt in mod2cnt.values():
    ans += cnt*(cnt-1)
print(ans//2)
### BUGGY CODE ###

import numpy as np
n = int(input())

k = np.array(range(n))
print(sum(k))

### FIXED CODE ###

n = int(input())
print(round(n*(n-1)//2))
### BUGGY CODE ###

import math
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass
N,M = map(int,input().split())
L = prime_factor(M)
L.append(0)
K = []
cur = L[0]
cnt = 0
for i in range(len(L)):
  if cur == L[i]:
    cnt += 1
  else:
    K.append(cnt)
    cnt = 1
    cur = L[i]
ans = 1
for i in range(len(K)):
  ans *= math.factorial(K[i]+N-1)//((math.factorial(N-1))*(math.factorial(K[i])))
  ans = ans%(10**9+7)
print(ans)

### FIXED CODE ###

import math
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass
N,M = map(int,input().split())
L = prime_factor(M)
L.append(0)
K = []
cur = L[0]
cnt = 0
for i in range(len(L)):
  if cur == L[i]:
    cnt += 1
  else:
    K.append(cnt)
    cnt = 1
    cur = L[i]
ans = 1
for i in range(len(K)):
  n = K[i]+N-1
  k = N-1
  cur = 1
  for i in range(k+1,n+1):
    cur *= i
  for j in range(1,n-k+1):
    cur = cur//j
  ans *= cur%(10**9+7)
print(ans%(10**9+7))
### BUGGY CODE ###

#coding:utf-8
def dbg(*something):
    if DEBUG:
        print(*something)






#正の宝石を戻すことはない
#負の宝石を戻すのは後半

from math import ceil,floor
DEBUG = False
N,K = list(map(int,input().split()))
V = list(map(int,input().split()))


#残りk回のとき深さk以下の場所に正の宝石がない→終了
#i回の操作で取れる石>それまでにとるi-1個の石の和
#深さiにある石vの価値：v - (それまでにとるi-1個の石の和　except (k-i)個の負の石)
'''
'''




def tansaku(V,rK):
    if rK == 0:
        return 0


    max_v = 0
    LV = V[:ceil(len(V)/2)]
    RV = V[ceil(len(V)/2):][::-1]


    for i in range(min(rK,len(LV))):
        if LV[i] <= 0:
            continue
        tmpL = LV[:i]
        tmpL.sort()
        j = 0 #捨てる石の数
        for _ in range(min(rK - 1 - i,len(tmpL)) ):
            if tmpL[j] >= 0:
                break
            j += 1
        dbg("dbg= ",tmpL)
        v_tmp = sum(tmpL[j:]) + LV[i]

        if v_tmp > 0:
            next_V = V[i+1:]
            next_rK = rK - 1 - i - j
            max_v = max(tansaku(next_V,next_rK) + v_tmp, max_v)
            # break


    for i in range(min(rK,len(RV))):
        if RV[i] <= 0:
            continue
        tmpL = RV[:i]
        tmpL.sort()
        j = 0 #捨てる石の数
        for _ in range(min(rK - 1 - i,len(tmpL)) ):
            if tmpL[j] >= 0:
                break
            j += 1
        dbg("dbg= ",tmpL)
        v_tmp = sum(tmpL[j:]) + RV[i]

        if v_tmp > 0:
            next_V = V[::-1][i+1:]
            next_rK = rK - 1 - i - j
            max_v = max(tansaku(next_V,next_rK) + v_tmp,max_v)
            # break

    return max_v


print(tansaku(V,K))

    






### FIXED CODE ###

#coding:utf-8



def main():
    
    def dbg(*something):
        if DEBUG:
            print(*something)


    #正の宝石を戻すことはない
    #負の宝石を戻すのは後半
    from sys import stdin
    from math import ceil,floor
    DEBUG = False
    N,K = list(map(int,stdin.readline().split()))
    V = list(map(int,stdin.readline().split()))
    
    max_value = 0
    dbg([i for i in range(3,-1,-1)])
    for getnum in range(1,min(N+1,K+1)):  #取る宝石の総数
        for a in range(getnum + 1):  #左から石を取る回数
            J = [0] * getnum #石
            b = getnum - a #右から石を取る回数
            for i in range(a):
                J[i] = V[i]
            for i in range(b):
                J[a+i] = V[-i-1]
            J.sort()
            #dbg(J,a,b)
            t = min(K-getnum,getnum) #捨てる石
           
            for i in range(t): 
                if J[i] >= 0:
                    t = i
                    break
            #dbg(J,i,t,a,b,J[t:])
            tmp_max = sum(J[t:])

            max_value = max(max_value,tmp_max)
    print(max_value)



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

N = int(input())
A = list(map(int,input().split()))
B = [None for i in range(N)]
for i in range(N):
    B[i] = A.count(i+1)
for i in range(N):
    print(B[i])

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
counter = np.bincount(A)
for i in range(1, N+1):
    if i < len(counter):
        print(counter[i])
    else:
        print(0)
### BUGGY CODE ###

import itertools
N,A = map(int,input().split())
x = list(map(int,input().split()))
# k個選んだとき k*A == sum(choise)
count = 0
for k in range(1,N+1):
    for ch in itertools.combinations(x,k):
        if sum(ch) == k * A:
            count += 1
print(count)

### FIXED CODE ###

N,A = map(int,input().split())
X = [int(e)-A for e in input().split()]
# dp[i][s]: i番目まで見て部分和がsとなるような場合の数
# 初期条件: dp[0][0] = 1
# 遷移: dp[i][s] += dp[i-1][s-X[i]] + dp[i-1][s]
# 答え: dp[N][0]
s_max = 5001
dp = [[0]*(s_max+1) for i in range(N+1)]
dp[0][2500] = 1
for i in range(1,N+1):
    for s in range(s_max+1):
        if 0 <= s-X[i-1] <= s_max:
            dp[i][s] += dp[i-1][s-X[i-1]]
        dp[i][s] += dp[i-1][s]
# 全てを選ばなかった1通りは除外
ans = dp[N][2500] - 1
print(ans)