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

import sys
sys.setrecursionlimit(400000000)
n,k=map(int,input().split())
h=list(map(int,input().split()))
flog=[-1]*n
#初期値は0
def Num(dest):
    q=dest-1
    if flog[q]>0:
        return flog[q]
    if dest<k+2:
        res=abs(h[q]-h[0])
        flog[q]=res
        return res
    
    min=Num(q)+abs(h[q]-h[q-1])
    for i in range(2,k+1):
        tmp=Num(dest-i)+abs(h[q]-h[q-i])
        if min>tmp:
            min=tmp
    flog[q]=min
    return min   
print(Num(n))

### FIXED CODE ###

import sys
sys.setrecursionlimit(400000000)
def main():
    n,k=map(int,input().split())
    h=tuple(map(int,input().split()))
    flog=[-1]*n
    for i in range(n):#dest=i 0が１
        if i<k+1:#0~k
            flog[i]=abs(h[i]-h[0])
        else:
            min=10**9
            for j in range(1,k+1):#1~k
                tmp=flog[i-j]+abs(h[i]-h[i-j])
                if tmp<min:
                    min=tmp
            flog[i]=min
    print(flog[n-1])
   # print(flog)
if __name__=="__main__":
    main()
### BUGGY CODE ###

n=int(input())
list1=list(map(int, input().split()))
list2=[0]*n
for i in list1:
      list2[i-1]=list1.count(i)
for j in list2:
      print(j,"\n")

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
c=[]
for q in range(a):
    c.append(0)
x=int(1)
for x in b:
    c[x-1]=c[x-1]+1
for t in range(a):
    print(c[t])
### BUGGY CODE ###

from sys import stdin
from collections import defaultdict
from math import isinf

readline = stdin.readline

min_cost = float('inf')

def main():
    v, e = map(int, readline().split())
    g = [[float('inf')] * v for _ in range(v)]
    for _ in range(e):
        s, t, d = map(int, readline().split())
        g[s][t] = d
    dfs(g, 0, 0, set(range(1, v)))
    global min_cost
    print(-1 if isinf(min_cost) else min_cost)


def dfs(g, cost, last, vs):
    global min_cost
    if min_cost < cost:
        return
    if vs:
        for v in vs:
            dfs(g, cost + g[last][v], v, vs - {v})
    elif min_cost > cost + g[last][0]:
        min_cost = cost + g[last][0]

main()

### FIXED CODE ###

# http://www.geocities.jp/m_hiroi/light/pyalgo65.html

def memoize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func

@memoize
def tsp(p, v):
    if (1 << point_size) - 1 == v:
        return distance_table[p][0]
    else:
        return min(distance_table[p][x] + tsp(x, v | (1 << x)) for x in range(point_size) if not (v & (1 << x)))

from sys import stdin
from collections import defaultdict
from math import isinf

readline = stdin.readline

point_size, e = map(int, readline().split())
distance_table = [[float('inf')] * point_size for _ in range(point_size)]
for _ in range(e):
    s, t, d = map(int, readline().split())
    distance_table[s][t] = d
ans = tsp(0,1)
print(-1 if isinf(ans) else ans)
### BUGGY CODE ###

if __name__ == '__main__':
    text = input()
    number = int(input())
    set = set()

    for text_len in range(1, len(text) + 1):
        for ss_len in range(len(text) - text_len + 1):
            set.add(text[ss_len:text_len + ss_len])

    print(sorted(set)[number - 1])

### FIXED CODE ###

if __name__ == '__main__':
    text = input()
    number = int(input())
    dic = []

    for text_len in range(1, min(len(text),number) + 1):
        for ss_len in range(0, len(text) - text_len + 1):
            word = text[ss_len:text_len + ss_len]
            if word not in dic:
                dic.append(word)

    dic = sorted(dic)

    print(dic[number - 1])
### BUGGY CODE ###

N = int(input())
S = []
for _ in range(N):
    keihin = input()
    if keihin not in S:S.append(keihin)

print(len(S))

### FIXED CODE ###

N = int(input())
S = []
for _ in range(N):
    S.append(input())

print(len(set(S)))
### BUGGY CODE ###

count=0
n=int(input())
for i in range(1,n+1):
    for j in range(1,n+1):
        if i%j==0:
            count+=i
print(count)

### FIXED CODE ###


n=int(input())
g=0
for i in range(1,n+1):
    g+= 0.5*i*(n//i)*((n//i)+1)
print(int(g))
### BUGGY CODE ###

from math import gcd

k = int(input())

res = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            g1 = gcd(a, b)
            g2 = gcd(g1, c)
            res += g2
print(res)


### FIXED CODE ###

from math import gcd

k = int(input())

res = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        g1 = gcd(a, b)
        for c in range(1, k + 1):
            g2 = gcd(g1, c)
            res += g2
print(res)
### BUGGY CODE ###

n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
kore = []
for i in range(0, n):
    b = a.pop(i)
    kore.append(max(a))
    a.insert(i, b)
for i in kore:
    print(i)

### FIXED CODE ###

n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)
### BUGGY CODE ###

N = int(input())
S = input()
r = []
g = []
b = []
for i in range(N):
  if S[i] == 'R':
    r.append(i)
  elif S[i] == 'G':
    g.append(i)
  else:
    b.append(i)
ans = len(r) * len(g) * len(b)
for a in r:
  for k in g:
    for l in b:
      ze = abs(a-k)
      m = abs(k-l)
      n = abs(l-a)
      if ze == m or m == n or n == ze:
        ans -= 1
print(ans)
  

### FIXED CODE ###

N = int(input())
S = input()
r = []
g = []
b = []
for i in range(N):
  if S[i] == 'R':
    r.append(i)
  elif S[i] == 'G':
    g.append(i)
  else:
    b.append(i)
ans = len(r) * len(g) * len(b)
sub = 0
for i in range(1,N//2+1):
  if 2 * i == N:
    break
  for k in range(N):
    if S[sub] != S[sub + i] and S[sub + i] != S[sub + 2 * i] and S[sub + 2 * i] != S[sub]:
      ans -= 1
    if sub + 2 * i + 1< N:
      sub += 1
    else:
      sub = 0
      break
print(ans)
### BUGGY CODE ###

import math

N = int(input())
S = [0]*N
kaisuu = [0]*N
solution = []
index = 0

for i in range(N):
  tmp = input()
  
  if (tmp in S) == False:
    S[index] = tmp
    kaisuu[index] = 1
    index += 1
  
  if (tmp in S) == True:
    index_tmp = S.index(tmp)
    kaisuu[index_tmp] += 1
  
max_ = max(kaisuu)

for i in range(N):
  if kaisuu[i] == max_:
    solution.append(S[i])

solution.sort()

for i in solution:
  print(i)
  
  

### FIXED CODE ###

import collections

N = int(input())
solution = []
S = []

for i in range(N):
  tmp = input()
  S.append(tmp)
  
c = collections.Counter(S)

d = c.most_common()

max_ = d[0][1]

for i,k in enumerate(d):
  if d[i][1] == max_:
    solution.append(d[i][0])
    
solution.sort()

for i in solution:
  print(i)
### BUGGY CODE ###

n, t = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(n)]

ab.sort()

dp = [[0] * t for i in range(n+1)]
ans = 0
for i in range(n):
    for j in range(t):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j - ab[i][0] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j - ab[i][0]] + ab[i][1])
    now = dp[i][t-1] + ab[i][1]
    ans = max(ans, now)

print(ans)

### FIXED CODE ###

n, t = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(n)]

ab.sort()

dp = [[0] * t for i in range(n+1)]
ans = 0
for i in range(n):
    for j in range(t):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j - ab[i][0] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j - ab[i][0]] + ab[i][1])
    now = dp[i][t-1] + ab[i][1]
    ans = max(ans, now)

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

N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

for i in range(0, N - 1):
  while (a[i] + a[i + 1]) > x:
    a[i + 1] -= 1
    ans += 1
print(ans)

### FIXED CODE ###

N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

for i in range(N - 1):
  total = a[i] + a[i + 1]
  if total > x:
    a[i + 1] = max(0, a[i + 1] - (total - x))
    ans += (total - x)
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main():
    n = int(stdin.readline())

    for _ in range(n):
        x = stdin.readline().rstrip()
        y = stdin.readline().rstrip()

        m = len(x)
        n = len(y)
        #assert 1 <= m <= 1000
        #assert 1 <= n <= 1000

        c = [[0]*(n+1) for _ in range(m+1)]

        for i in range(1, m+1):
            for j in range(1, n+1):
                if x[i-1] == y[j-1]:
                    c[i][j] = c[i-1][j-1] + 1
                elif c[i-1][j] >= c[i][j-1]:
                    c[i][j] = c[i-1][j]
                else:
                    c[i][j] = c[i][j-1]

        print(c[-1][-1])


main()

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin


def main():
    num = int(stdin.readline())

    for _ in xrange(num):
        x = stdin.readline().rstrip()
        y = stdin.readline().rstrip()

        n = len(y) + 1

        cim1 = [0] * n
        for i, xi in enumerate(x, start=1):
            ci = [0] * n
            for j, yj in enumerate(y, start=1):
                if xi == yj:
                    ci[j] = cim1[j-1] + 1
                elif cim1[j] >= ci[j-1]:
                    ci[j] = cim1[j]
                else:
                    ci[j] = ci[j-1]
            cim1 = ci

        print(ci[j])


main()
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split(" ")))
 
counter = 0
 
for num_1, i in enumerate(L):
  for num_2, j in enumerate(L):
    if num_1 <= num_2:
      break
    else:
      for num_3, k in enumerate(L):
        if num_2 <= num_3:
          break
        else:
          if i+j >k and j+k>i and k+i>j:
            counter += 1
print(counter)

### FIXED CODE ###

import bisect

N = int(input())
L = list(map(int, input().split(" ")))
L.sort() #小さい順
counter = 0

for i in range(N-2):
  for j in range(i+1, N-1):
    index = bisect.bisect_left(L, L[i]+L[j], 0, N)
    counter = counter + index - j - 1
       
print(counter)
### BUGGY CODE ###

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

ans = [[0,0]] 

for i in range(n):
    ans2 = []
    for x in ans:
        ans2.append([x[0]+X[i],x[1]+1])
        ans2.append([x[0],x[1]])
    ans = ans2

cnt = 0
for a in ans:
    if a[1] == 0:
        continue
    elif a[0]/a[1] == v:
        cnt += 1

print(cnt)


### FIXED CODE ###

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

X = [int(i)-a for i in input().split()]
dp = [[0]*(100*n+1) for i in range(n+1)]
dp[0][50*n] = 1

for i in range(n):
    for j in range(50,100*n+1-50):
        dp[i+1][j] = dp[i][j]+dp[i][j-X[i]]

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

n,m=map(int,input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
c=[[] for i in range(m)]
for i in range(m):
  a[i],b[i]=map(int,input().split())
  c[i]=list(map(int,input().split()))
  
dp=[float("inf") for i in range(2**n)]
dp[0]=0
for i in range(m):
  now=0
  for j in c[i]:
    jj=1<<j-1
    now=now|jj
  for k in range(2**n):
    kk=k|now
    dp[kk]=min(dp[kk],dp[k]+a[i])
    

if dp[-1]==float("inf"):
  print(-1)
else:
  print(dp[-1])

### FIXED CODE ###

import sys
input=sys.stdin.readline
def main():
  n,m=map(int,input().split())
  a=[0 for i in range(m)]
  b=[0 for i in range(m)]
  c=[[] for i in range(m)]
  for i in range(m):
    a[i],b[i]=map(int,input().split())
    c[i]=list(map(int,input().split()))
  
  dp=[float("inf") for i in range(2**n)]
  dp[0]=0
  for i in range(m):
    now=0
    for j in c[i]:
      jj=1<<j-1
      now=now|jj
    for k in range(2**n):
      kk=k|now
      dp[kk]=min(dp[kk],dp[k]+a[i])
    

  if dp[-1]==float("inf"):
    print(-1)
  else:
    print(dp[-1])
    
if __name__ == '__main__':  
  main()
### BUGGY CODE ###

n = int(input())
x_bin = input()
x = int(x_bin, 2)

pc = x_bin.count('1')
pc_p = pc + 1
pc_m = pc - 1

rest = {0: 0}
for i in range(1, pc + 1):
    rest[i] = rest[i % bin(i).count('1')] + 1

for i in range(n, 0, -1):
    if x_bin[n-i] == '1':
        if pc_m != 0:
            a = (x - pow(2, (i - 1))) % pc_m
            print(rest[a] + 1)
        else:
            print(0)
    else:
        a = (x + pow(2, (i - 1))) % pc_p
        print(rest[a] + 1)


### FIXED CODE ###

n = int(input())
x_bin = input()
x = int(x_bin, 2)

pc = x_bin.count('1')
pc_p = pc + 1
pc_m = pc - 1

if pc == 1:
    for i, v in enumerate(x_bin):
        if v == '1':
            print(0)
        else:
            if i != n-1:
                if x_bin[-1] == '0':
                    print(1)
                else:
                    print(2)
            else:
                print(2)
    exit()

p = {0: 1}
m = {0: 1}
for i in range(1, n):
    p[i] = p[i-1]*2 % pc_p
    m[i] = m[i-1]*2 % pc_m

rest = {0: 0}
for i in range(1, pc + 1):
    rest[i] = rest[i % bin(i).count('1')] + 1

x_p = x % pc_p
x_m = x % pc_m

for i in range(n, 0, -1):
    if x_bin[n-i] == '1':
        a = (x_m - m[i-1]) % pc_m
        print(rest[a] + 1)
    else:
        a = (x_p + p[i-1]) % pc_p
        print(rest[a] + 1)
### BUGGY CODE ###

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

ans = 1
for a in A:
    ans *= a
if ans > 1e18:
    ans = -1
print(ans)

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
def main():
    if c[0] >0:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > 1e18:
            ans = -1
            break
    if ans > 1e18:
        ans = -1
    print(ans)
main()
### BUGGY CODE ###

n = int(input())
boss_num = input().split()

for i in range(1, n+1):
	print (boss_num.count(str(i)))

### FIXED CODE ###

n = int(input())
l = [0]*n
boss_num = list(map(int, input().split()))

for num in boss_num:
	l[num-1] += 1	
for m in l: print(m)
### BUGGY CODE ###

import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue

sys.setrecursionlimit(10000)

def solve(n, start):
    if n == 1:
        return 0

    for i in range(start, n+1):
        if n % i == 0:
            # 素因数を枯らす
            sys.stderr.write('hit: n = {}, i = {}^1\n'.format(n, i))
            sys.stderr.write('hit: {}^1\n'.format(i))
            cnt = 1
            tmp = n // i
            while(tmp % (i ** (cnt+1)) == 0):
                sys.stderr.write('hit: {}^{}\n'.format(i, cnt+1))
                tmp = tmp // (i ** (cnt+1))
                cnt += 1

            while(tmp % i == 0):
                tmp = tmp // i

            return solve(tmp, i+1) + cnt

    return 0

def main():
    N = int(input())

    ans = solve(N, 2)
    print(ans)

    # N, M = [int(s) for s in input().split()]

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())


### FIXED CODE ###

import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

sys.setrecursionlimit(10000)

def solve(n, start):
    if n == 1:
        return 0

    for i in range(start, int(math.sqrt(n+1))):
        sys.stderr.write('i = {}\n'.format(i))

        if n % i == 0:
            # 素因数を枯らす
            sys.stderr.write('hit: n = {}, i = {}^1\n'.format(n, i))
            sys.stderr.write('hit: {}^1\n'.format(i))
            cnt = 1
            tmp = n // i
            while(tmp % (i ** (cnt+1)) == 0):
                sys.stderr.write('hit: {}^{}\n'.format(i, cnt+1))
                tmp = tmp // (i ** (cnt+1))
                cnt += 1

            while(tmp % i == 0):
                tmp = tmp // i

            return solve(tmp, i+1) + cnt

    return 1

def main():
    N = int(input())

    ans = solve(N, 2)
    print(ans)

    # N, M = [int(s) for s in input().split()]

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

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

import numpy as np
n, k = map(int, input().split())
hlis = np.array(list(map(int, input().split())))
dp = np.zeros(n, dtype=int)
dp[0] = 0
for i in range(1,n):
    dp[i] = min(dp[j] + abs(hlis[i] - hlis[j]) for j in range(max(0, i-k), i))
print(dp[-1])

### FIXED CODE ###

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

N = int(input())

A = [int(input()) for n in range(N)]

for n in range(N):
  a = A[n]
  A[n] = 0
  print(max(A))
  A[n] = a

### FIXED CODE ###

N = int(input())
A = [int(input()) for n in range(N)]
 
max_A = max(A)
max_index = A.index(max(A))

A[max_index] = 0
max_A2 = max(A)
A[max_index] = max_A

for n in range(N):
  if A[n] != max_A:
    print(max_A)
  else:
    print(max_A2)
### BUGGY CODE ###

# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Nの制約が1000,円の中心を飛び石→dijkstra
sx, sy, gx, gy = lr()
N = ir()
XYR = [[sx, sy, 0]] + [lr() for _ in range(N)] + [[gx, gy, 0]]
graph = [[] for _ in range(N+2)]  # 0がstart,N+1がgoal
for i in range(N+2):
    for j in range(i+1, N+2):
        sp = XYR[i]; ep = XYR[j]
        length = max(0, ((sp[0]-ep[0]) ** 2 + (sp[1]-ep[1]) ** 2) ** .5 - sp[2] - ep[2])
        graph[i].append((j, length))
        graph[j].append((i, length))

def dijkstra(start):
    INF = 10 ** 15
    dist = [INF] * (N+2)
    dist[start] = 0
    que = [(0, start)]
    visited = set()
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next, l in graph[prev]:
            if next == prev or next in visited:
                continue
            d1 = d + l
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
        visited.add(prev)
    return dist

dist = dijkstra(0)
answer = dist[N+1]
print(answer)
# 46


### FIXED CODE ###

# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Nの制約が1000,円の中心を飛び石→dijkstra
sx, sy, gx, gy = lr()
N = ir()
XYR = [[sx, sy, 0]] + [lr() for _ in range(N)] + [[gx, gy, 0]]
graph = [[] for _ in range(N+2)]  # 0がstart,N+1がgoal
for i in range(N+2):
    for j in range(i+1, N+2):
        sp = XYR[i]; ep = XYR[j]
        length = max(0, ((sp[0]-ep[0]) ** 2 + (sp[1]-ep[1]) ** 2) ** .5 - sp[2] - ep[2])
        graph[i].append((j, length))
        graph[j].append((i, length))

def dijkstra(start):
    INF = 10 ** 15
    dist = [INF] * (N+2)
    dist[start] = 0
    que = [(0, start)]
    visited = set()
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next, l in graph[prev]:
            if next == prev or next in visited:
                continue
            d1 = d + l
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
        visited.add(prev)
    return dist

dist = dijkstra(0)
answer = dist[N+1]
print(answer)
# 46
### BUGGY CODE ###


n, k = [int(i) for i in input().split()]

cnt = 0
for i in range(1,2*n//k+1):
    for j in range(1, min(k*i, n+1)):
        a = j
        b = k*i-a
        if b <= n:
            for m in range(a//k+1,(a+n)//k+1):
                c = m*k - a
                if (c + b)%k == 0:
                    cnt += 1
print(cnt)


### FIXED CODE ###

N, K = [int(i) for i in input().split()]
cnt = 0
if K % 2 == 0:
    for i in range(1, 2*N//K+1):
        cnt += 1 + (2*N//K-i)//2 * 6 + (2*N//K-i)//2 * ((2*N//K-i)//2 - 1) * 3
else:
    for i in range(1, N//K+1):
        cnt += 1 + (N//K-i) * 6 + (N//K-i) * ((N//K-i) - 1) * 3

print(cnt)
### BUGGY CODE ###

n = int(input())
s = input()

res = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        tt = res
        mx = min(j - i, n - j)
        if tt >= mx:
            continue
        while tt <= mx:
            tt += 1
            if s[i:i + tt] != s[j:j + tt]:
                break
        _res = tt - 1
        res = max(res, _res)

print(res)

### FIXED CODE ###

n = int(input())
s = input()

dp = [[0 for i in range(5005)] for j in range(5005)]

for i in range(n - 1, -1, -1):
    for j in range(n - 1, -1, -1):
        dp[i][j] = 0 if s[i] != s[j] else dp[i + 1][j + 1] + 1

res = 0
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        curr = min(dp[i][j], j - i)
        res = max(res, curr)

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

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

maxnum = m//n

for i in range(maxnum,0,-1):
  if m%i==0:
    print(i)
    break
  

### FIXED CODE ###

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

maxnum = m//n

for i in range(maxnum,0,-1):
  if m%i==0:
    print(i)
    break
### BUGGY CODE ###

N, M = map(int, input().split())
A = set(i//2 for i in map(int, input().split()))
m = max(A)
A.remove(m)
base = 0
for i in range(m,M+1,2*m):
	semi = True
	for j in A:
		if i % j != 0 or (i // j) % 2 == 0:
			semi = False
			break
	if semi:
		base = i
		break
if base == 0:
	print(0)
else:
	print(((M // base) + 1)//2)

### FIXED CODE ###

N, M = map(int, input().split())
A = set(i//2 for i in map(int, input().split()))
B = []
for i in A:
	B = B + [0]
	while i % 2 == 0:
		i //= 2
		B[-1] += 1
if len(set(B)) == 1:
	m = max(A)
	A.remove(m)
	base = 0
	for i in range(m,M+1,2*m):
		semi = True
		for j in A:
			if i % j != 0 or (i // j) % 2 == 0:
				semi = False
				break
		if semi:
			base = i
			break
	if base == 0:
		print(0)
	else:
		print(((M // base) + 1)//2)
else:
	print(0)
### BUGGY CODE ###

N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
src.sort(key=lambda x:x[0]+x[1])

dp = [None] * (20001)
dp[0] = 0
for w,s,v in src:
    for s0 in range(s,-1,-1):
        if dp[s0] is None: continue
        if dp[s0+w] is None:
            dp[s0+w] = dp[s0] + v
        else:
            dp[s0+w] = max(dp[s0+w], dp[s0] + v)
print(max(v for v in dp if v is not None))

### FIXED CODE ###

N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
src.sort(key=lambda x:x[0]+x[1])

dp = [None] * (20001)
dp[0] = 0
for w,s,v in src:
    for s0 in range(s,-1,-1):
        if dp[s0] is None: continue
        if dp[s0+w] is None:
            dp[s0+w] = dp[s0] + v
        else:
            dp[s0+w] = max(dp[s0+w], dp[s0] + v)
print(max(v for v in dp if v is not None))
### BUGGY CODE ###

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

for i in range(N-1):
  moving = 0
  for j in range(i, N-1):
    if H[j] >= H[j+1]:
      moving += 1
    else:
      i = j + 1
      break
      
    if moving > count:
      count = moving
      
print(count)

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
count = 0
i = 0

while i < N-1:
  moving = 0
  for j in range(i, N-1):
    if H[j] >= H[j+1]:
      moving += 1
    else:
      i = j + 1
      break
      
    if moving > count:
      count = moving
      
    i += 1
      
print(count)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for pi in p:
    Sum = 0
    for i in range(pi+1):
        Sum += i
    ev.append(Sum / pi)

ans = 0
for i in range(n-k+1):
    cost = sum(ev[i:i+k])
    if ans < cost:
        ans = cost

print(ans)
# print(ev)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for pi in p:
    ev.append((pi + 1) / 2)

ans = 0
cost = sum(ev[:k])
for i in range(k, n+1):
    if ans < cost:
        ans = cost
    if i == n:
        continue
    cost -= ev[i-k]
    cost += ev[i]
    # print(i)

print(ans)
# print(ev)