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

n = input()

n = int(n)
s = [0]*n
sm = []

for i in range(0,n):
  s[i] = input()

for i in range(0,n):
  c = 1
  sm.insert(0,s[i])
  for j in range(1,len(sm)):
    if(sm.count(s[i]) > 1):
      del sm[0]

print(len(sm))

### FIXED CODE ###

n = int(input())
s = [0]*n

for i in range(n):
  s[i] = input()
ans = 0
s.sort()
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
    
print(ans+1)
### BUGGY CODE ###

n = int(input())
a,b,c,d,e,v,w,x,y,z = [],[],[],[],[],[],[],[],[],[]
for i in range(0,n):
    s = str(input())
    t = len(s)
    if t == 1:
        m = 0
        for j in range(0,len(a)):
            if s == a[j]:
                m = 1
                break
        if m == 0:
            a.append(s)
    elif t == 2:
        m = 0
        for j in range(0,len(b)):
            if s == b[j]:
                m = 1
                break
        if m == 0:
            b.append(s)
    elif t == 3:
        m = 0
        for j in range(0,len(c)):
            if s == c[j]:
                m = 1
                break
        if m == 0:
            c.append(s)
    elif t == 4:
        m = 0
        for j in range(0,len(d)):
            if s == d[j]:
                m = 1
                break
        if m == 0:
            d.append(s)
    elif t == 5:
        m = 0
        for j in range(0,len(e)):
            if s == e[j]:
                m = 1
                break
        if m == 0:
            e.append(s)
    elif t == 6:
        m = 0
        for j in range(0,len(v)):
            if s == v[j]:
                m = 1
                break
        if m == 0:
            v.append(s)
    elif t == 7:
        m = 0
        for j in range(0,len(w)):
            if s == w[j]:
                m = 1
                break
        if m == 0:
            w.append(s)
    elif t == 8:
        m = 0
        for j in range(0,len(x)):
            if s == x[j]:
                m = 1
                break
        if m == 0:
            x.append(s)
    elif t == 9:
        m = 0
        for j in range(0,len(y)):
            if s == y[j]:
                m = 1
                break
        if m == 0:
            y.append(s)
    else:
        m = 0
        for j in range(0,len(z)):
            if s == z[j]:
                m = 1
                break
        if m == 0:
            z.append(s)
ans = len(a)+len(b)+len(c)+len(d)+len(e)+len(v)+len(w)+len(x)+len(y)+len(z)
print(ans)

### FIXED CODE ###

n = int(input())
a = []
for i in range(0,n):
    s = str(input())
    a.append(s)
ans = set(a)
print(len(ans))
### BUGGY CODE ###

#!/usr/bin/env python3
# B - Sum of Three Integers

K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                count += 1
print(count)


### FIXED CODE ###

#!/usr/bin/env python3
# B - Sum of Three Integers

K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z <= K:
            count += 1

print(count)
### BUGGY CODE ###

from heapq import heappop, heappush, heapify
import sys
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    f = list(map(int, input().split()))
    a.sort()
    f.sort(reverse=True)
    q = [None] * n
    for i in range(n):
        q[i] = (-a[i]*f[i], -f[i])
    heapify(q)

    for i in range(k):
        t, g = heappop(q)
        heappush(q, (t-g, g))

    ans, _ = heappop(q)
    print(-ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

left, right = -1, a[-1] * f[0]

while right - left > 1:
    mid = (left + right) // 2
    ck = 0
    for i in range(n): ck += max(0, a[i] - mid // f[i])
    if ck <= k: right = mid
    else: left = mid

print(right)
### BUGGY CODE ###

# 解説を参考に作成

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(H, W, C, D, Ss):
    cost_map = [[-1] * (W + 4) for _ in range(H + 4)]
    Ss = ['#' * (W + 4)] * 2 + ['##' + S + '##' for S in Ss] + ['#' * (W + 4)] * 2
    C = [c + 1 for c in C]
    D = [d + 1 for d in D]
    cost = 0
    ans = -1
    dq = deque()
    dq.append(C)
    while dq:
        next_dq = deque()
        flg = False
        while dq:
            h, w = dq.popleft()
            if h == D[0] and w == D[1]:
                ans = cost
                flg = True
                break
            if cost_map[h][w] >= 0:
                continue
            cost_map[h][w] = cost
            for i in range(h - 2, h + 2 + 1):
                for j in range(w - 2, w + 2 + 1):
                    if Ss[i][j] == '#':
                        continue
                    if cost_map[i][j] >= 0:
                        continue
                    if abs(h - i) + abs(w - j) == 1:
                        dq.append([i, j])
                    else:
                        next_dq.append([i, j])
        if flg:
            break
        dq = next_dq
        cost += 1
    print(ans)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    H, W = map(int, input().split())
    C = [int(i) for i in input().split()]
    D = [int(i) for i in input().split()]
    Ss = [input() for _ in range(H)]
    # Bs = [int(i) for i in input().split()]
    solve(H, W, C, D, Ss)


### FIXED CODE ###

# 解説を参考に作成

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(H, W, C, D, Ss):
    cost_map = [[-1] * (W + 4) for _ in range(H + 4)]
    Ss = ['#' * (W + 4)] * 2 + ['##' + S + '##' for S in Ss] + ['#' * (W + 4)] * 2
    C = [c + 1 for c in C]
    D = [d + 1 for d in D]
    cost = 0
    ans = -1
    dq = deque()
    dq.append(C)
    while dq:
        next_dq = deque()
        flg = False
        while dq:
            h, w = dq.popleft()
            if h == D[0] and w == D[1]:
                ans = cost
                flg = True
                break
            if cost_map[h][w] >= 0:
                continue
            cost_map[h][w] = cost
            for i in range(h - 2, h + 2 + 1):
                for j in range(w - 2, w + 2 + 1):
                    if Ss[i][j] == '#':
                        continue
                    if cost_map[i][j] >= 0:
                        continue
                    if abs(h - i) + abs(w - j) == 1:
                        dq.append([i, j])
                    else:
                        next_dq.append([i, j])
        if flg:
            break
        dq = next_dq
        cost += 1
    print(ans)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    H, W = map(int, input().split())
    C = [int(i) for i in input().split()]
    D = [int(i) for i in input().split()]
    Ss = [input() for _ in range(H)]
    # Bs = [int(i) for i in input().split()]
    solve(H, W, C, D, Ss)
### BUGGY CODE ###

n = int(input())
s = input()
lis = list(s)

#index 0
ans = lis[1:n].count("E")

#index 1~n-2
for i in range(n):
    tmp = 0
    tmp = lis[0:i+1].count("W") + lis[i+1:n].count("E")
    ans = min(ans,tmp)

#index n-1
ans = min(ans,lis[0:n].count("W"))

print(ans)


### FIXED CODE ###

n = int(input())
s = input()
lis = list(s)

left_w_count = 0
right_e_count = lis[1:].count("E")
ans = right_e_count
for i in range(1,n):
    if lis[i-1] == "W":
        left_w_count += 1
    if lis[i] == "E":
        right_e_count -= 1
    ans = min(ans, left_w_count + right_e_count)

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

n=int(input())
a=list(map(int,input().split()))
l=set(a)
li=[]

for i in l:
    cnt_i=a.count(i)
    li.append(cnt_i*(cnt_i -1)/2)
s=sum(li)

for i in a:
    cnt=a.count(i)
    print(int(s-cnt+1))

### FIXED CODE ###

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

c=collections.Counter(a)
s=0
for i in c.values():
    s+=i*(i-1)//2

for i in a:
    cnt=c[i]
    print(int(s-cnt+1))
### BUGGY CODE ###

from math import ceil
from bisect import bisect
from operator import itemgetter
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key=itemgetter(0))
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

bit0 = BIT(N)
bit1 = BIT(N)

ans = 0
for i in range(N):
    x = H[i]
    bit0.add(i,-x*i)
    bit1.add(i,x)
    bit0.add(i+1,x*(i+1))
    bit1.add(i+1,-x)
    h = bit1.sum(i)*(i+1)+bit0.sum(i)
    if i != 0:
        h -= bit1.sum(i-1)*i+bit0.sum(i-1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)-1
        bit0.add(i,-x*i)
        bit1.add(i,x)
        bit0.add(j+1,x*(j+1))
        bit1.add(j+1,-x)

print(ans)

### FIXED CODE ###

from math import ceil
from bisect import bisect
from operator import itemgetter
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key=itemgetter(0))
X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

bit = BIT(N)
ans = 0
for i in range(N):
    bit.add(i+1,H[i])
    bit.add(i+2,-H[i])
    h = bit.sum(i+1)
    if h>0:
        ans += ceil(h/A)
        x = -ceil(h/A)*A
        j = bisect(X,X[i]+2*D)
        bit.add(i+1,x)
        bit.add(j+1,-x)

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

import sys

sys.setrecursionlimit(10**6)

def solve(n,a):
    wa=0
    for i in range(n):
        if(i%2==0):
            wa+=a[i]
    kotae=wa
    for i in range(n//2):
        wa+=a[(n//2-i-1)*2+1]
        wa-=a[(n//2-i-1)*2]
        if(wa>kotae):
            kotae=wa
    return kotae

def dfs(n,a,k):
    if(k==1):
        return max(a)
    ari=a[n-1]+dfs(n-2,a[:n-2],k-1)
    if(n==k*2-1):
        return ari
    nasi=dfs(n-1,a[:n-1],k)
    return max(ari,nasi)

n=int(input())

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

if(n%2==0):
    print(solve(n,a))
else:
    print(dfs(n,a,n//2))


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)

def solve(n,a):
    wa=0
    for i in range(n):
        if(i%2==0):
            wa+=a[i]
    kotae=wa
    for i in range(n//2):
        wa+=a[(n//2-i-1)*2+1]
        wa-=a[(n//2-i-1)*2]
        if(wa>kotae):
            kotae=wa
    return kotae

def dfs(n,a,k):
    global zen
    zen.append([n,k])
    if(k==1):
        return max(a)
    ari=a[n-1]+dfs(n-2,a[:n-2],k-1)
    if(n==k*2-1):
        return ari
    nasi=dfs(n-1,a[:n-1],k)
    return max(ari,nasi)

n=int(input())

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

if(n%2==0):
    print(solve(n,a))
else:
    data=[[a[0],a[0]],[max(a[:2]),max(a[:2])]]
    #data.append([max(a[:3]),sum(a[:3])-min(a[:3])])
    data.append([max(a[:3]),a[0]+a[2]])
    for i in range(3,n):
        if(i%2==1):
            ari=a[i]+data[i-2][0]
            nasi=data[i-1][1]
            saiyo=max(ari,nasi)
            data.append([saiyo,saiyo])
        else:
            ooi=a[i]+data[i-2][1]
            nasi=data[i-1][1]
            ari=a[i]+data[i-2][0]
            sukunai=max(ari,nasi)
            data.append([sukunai,ooi])
    print(data[n-1][0])
### BUGGY CODE ###

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

su = s.count('1')
sun = int(s,2)


table = [0]*200001
table[1] = 1
for i in range(2,200001):
    table[i] = 1 + table[i % bin(i).count('1')]

def pow(n,e,mod):
    ret=1
    b=n
    while e > 0:
        if e % 2 == 1:
            ret = ret * b % mod
        b = b * b % mod
        e = e//2
    return ret

for i in range(n):
    if s[i] == '0':
        print(1+table[(sun+pow(2,n-1-i,su+1))%(su+1)])
    else:
        if su-1 == 0:
            print(0)
        else:
            print(1+table[(sun-pow(2,n-1-i,su-1)+su-1)%(su-1)])



### FIXED CODE ###

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

su = s.count('1')
sun = int(s,2)

sun_plus = sun % (su + 1)
sun_minus = 0 if su - 1 == 0 else sun % (su - 1)


table = [0]*200001
table[1] = 1
for i in range(2,200001):
    table[i] = 1 + table[i % bin(i).count('1')]

def pow(n,e,mod):
    ret=1
    b=n
    while e > 0:
        if e % 2 == 1:
            ret = ret * b % mod
        b = b * b % mod
        e = e//2
    return ret

for i in range(n):
    if s[i] == '0':
        print(1+table[(sun_plus+pow(2,n-1-i,su+1))%(su+1)])
    else:
        if su-1 == 0:
            print(0)
        else:
            print(1+table[(sun_minus-pow(2,n-1-i,su-1)+su-1)%(su-1)])
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
dp=[0]*(k+1)
for i in range(a[0]+1):
    dp[i]=1
for i in range(1,n):
    u=a[i]
    h=dp[:]
    for j in range(u+1,k+1):
        h[j]=(dp[j]-dp[j-u-1])%mod
    for j in range(1,k+1):
        h[j]=(h[j]+h[j-1])%mod
    dp=h
print(dp[k])

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
dp=[0]*(k+1)
for i in range(a[0]+1):
    dp[i]=1
for i in range(1,n):
    u=a[i]
    h=dp[:]
    for j in range(u+1,k+1):
        h[j]=(dp[j]-dp[j-u-1])%mod
    for j in range(1,k+1):
        h[j]=(h[j]+h[j-1])%mod
    dp=h
print(dp[k])
### BUGGY CODE ###

h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
def t(s):
  return [[s[i][j] for i in range(len(s))] for j in range(len(s[0]))]
def calc(s):
  res = []
  for v in s:
    v.append('-')
    tmp = []
    nc = ''
    nn = 0
    for c in v:
      if nc == '':
        nc = c
        nn += 1
        continue
      if nc == c:
        nn += 1
        continue
      else:
        if nc == '#':
          tmp = tmp + [0 for _ in range(nn)]
        else:
          tmp = tmp + [nn for _ in range(nn)]
        nc = c
        nn = 1
    res.append(tmp)
  return res

tate = calc(t(S))
yoko = calc(S)
print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0])-1)


### FIXED CODE ###

h, w = map(int, input().split())
S = [input() for _ in range(h)]

def calc(s):
    res = []
    for v in s:
        v = v + '-'
        tmp = []
        nc = v[0]
        nn = 0
        for c in v:
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

def calc2(s):
    res = []
    for j in range(w):
        tmp = []
        nc = s[0][j]
        nn = 0
        for i in range(h):
            c = s[i][j]
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        if nc == '#':
            tmp.extend([0 for _ in range(nn)])
        else:
            tmp.extend( [nn for _ in range(nn)])
        res.append(tmp)
    return res

tate = calc2(S)
yoko = calc(S)

print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0]) - 1)
### BUGGY CODE ###

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

h,w,k = map(int, input().split())
x1,y1,x2,y2 = map(int, input().split())
x1,y1,x2,y2 = x1-1,y1-1, x2-1,y2-1
board = [list(map(lambda x: int(x=="."), input())) for i in range(h)]

def make_array(dims, fill):
    if len(dims) == 1:
        return [fill]*dims[0]
    nxt = dims[1:]
    ret = [make_array(nxt,fill) for i in range(dims[0])]
    return ret

inf = 1<<30

DP = make_array((h,w,4), inf)

from collections import deque
que = deque()
for i in range(4):
    que.append((x1,y1,i,0))

dxdy = [(-1,0),(1,0),(0,1),(0,-1)]
while que:
    x,y,prev,cost = que.popleft()
    if DP[x][y][prev] <= cost:
        continue
    DP[x][y][prev] = cost
    for i in range(4):
        if i == prev:
            continue
        nprev = i^1
        ddx, ddy = dxdy[i]
        for j in range(1,k+1):
            nx, ny = x+j*ddx, y+j*ddy
            if not (0<=nx<h and 0<=ny<w and board[nx][ny] and DP[nx][ny][nprev] > cost+1):
                break
            que.append((nx,ny,nprev,cost+1))

ans = min(DP[x2][y2])
if ans == inf:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

h,w,k = map(int, input().split())
sx,sy,gx,gy = map(lambda x: int(x)-1, input().split())
board = [list(map(lambda x: int(x=="."), input())) for i in range(h)]
inf = 1<<30
DP = [[inf for j in range(w)] for i in range(h)]
DP[sx][sy] = 0

from collections import deque
que = deque([(sx,sy)])

dxdy = [(0,1),(1,0),(0,-1),(-1,0)]
while que:
    x,y = que.popleft()
    for dx,dy in dxdy:
        nx,ny = x,y
        for i in range(k):
            nx += dx
            ny += dy
            if not(0<=nx<h and 0<=ny<w and board[nx][ny] and DP[nx][ny] >= DP[x][y]+1):
                break
            # コストが変わらない場合は無視か...
            if DP[nx][ny] == DP[x][y]+1:
                continue
            DP[nx][ny] = DP[x][y]+1
            que.append((nx,ny))
ans = DP[gx][gy]
if ans == inf:
    ans = -1
print(ans)
### BUGGY CODE ###

from collections import deque


def main():
    N = int(input())
    A = [deque(map(lambda x: int(x)-1, input().split())) for _ in range(N)]
    ans = 0
    while True:
        empty = 0
        used = set()
        for i in range(N):
            if len(A[i]) == 0:
                empty += 1
                continue
            j = A[i][0]
            if len(A[j]) and A[j][0] == i and i not in used and j not in used:
                used.add(i)
                used.add(j)
                A[i].popleft()
                A[j].popleft()
        if empty == N:
            break
        if len(used) == 0:
            ans = -1
            break
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def main():
    N = int(input())
    A = [deque(map(lambda x: int(x)-1, input().split())) for _ in range(N)]
    ans = 1
    empty = 0
    candidates = set(range(N))
    while True:
        used = set()
        for i in candidates:
            if len(A[i]) == 0 or i in used:
                continue
            j = A[i][0]
            if len(A[j]) and A[j][0] == i and j not in used:
                used.add(i)
                used.add(j)
                A[i].popleft()
                A[j].popleft()
                if len(A[i]) == 0:
                    empty += 1
                if len(A[j]) == 0:
                    empty += 1
        if empty == N:
            break
        if len(used) == 0:
            ans = -1
            break
        ans += 1
        candidates = used
    print(ans)


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

k, s = map(int, input().split())
count = 0
for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            x = i
            y = j
            z = l
            if i + j + l == s:
                count += 1
print(count)


### FIXED CODE ###

k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
            if 0 <= s - x - y <=k:
                ans += 1
print(ans)
### BUGGY CODE ###

n,c = map(int, input().split())
x = [0]
xr = [0]
v = [0]
for _ in range(n):
    xi,vi = map(int, input().split())
    x.append(xi)
    xr.append(c - xi)
    v.append(vi)
clockmax = -1
reclockmax = -1
score = 0
for i in range(n+1):
    for j in range(n+1-i):
        for k in range(i+1):
            score += v[k]
        for k in range(j+1):
            score += v[-k]
        score2 = score
        score -= 2*x[i] + xr[-j]
        score2 -= x[i] + 2*xr[-j]
        if clockmax < score: clockmax = score
        if reclockmax < score2: reclockmax = score2
        score = 0
        score2 = 0

print(max(clockmax,reclockmax))

### FIXED CODE ###

n,c = map(int, input().split())
x = []
x_r = []
v = []
for i in range(n):
    xi,vi = map(int, input().split())
    x.append(xi)
    x_r.append(c - xi)
    v.append(vi)
x_r.reverse()
x.insert(0, 0)
x_r.insert(0, 0)

score = [0]
score_r = [0]
tmp = 0
for i, vi in enumerate(v):
    tmp += vi
    score.append(tmp - x[i+1])
tmp = 0
for i, vi in enumerate(v[::-1]):
    tmp += vi
    score_r.append(tmp - x_r[i+1])

maxscore = []
maxscore_r = []
tmp = 0
for i, si in enumerate(score):
    tmp = max(tmp, si)
    maxscore.append(tmp)
tmp = 0
for i, si in enumerate(score_r):
    tmp = max(tmp, si)
    maxscore_r.append(tmp)

ans = 0
for i, si in enumerate(score):
    ans = max(si + maxscore_r[n-i] - x[i], ans)
for i, si in enumerate(score_r):
    ans = max(si + maxscore[n-i] - x_r[i], ans)

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

n=int(input())
a=list(map(int,input().split()))
if n%2==0 and a.count(0)!=0:
    print(0)
    exit()
f=1
for i in range(n-1,-1,-2):
    if i==0:
        if a.count(0)!=1:
            f=0
            break
    elif a.count(i)!=2:
        f=0
        break
if f: 
    print(2**(n//2))
else: 
    print(0)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*(10**5)
mod=10**9+7
for i in range(n):
    b[a[i]]+=1
if n%2==0 and a.count(0)!=0:
    print(0)
    exit()
f=1
for i in range(n-1,-1,-2):
    if i==0:
        if b[i]!=1:
            f=0
            break
    elif b[i]!=2:
        f=0
        break
if f: 
    print(2**(n//2)%mod)
else: 
    print(0)
### BUGGY CODE ###

import numpy as np

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

dp = np.ones([N]) * np.inf
dp[0] = 0

for i in range(1, N):
  left = max(0, i-K)
  dp[i] = np.min(dp[left:i] + abs(H[left:i]-H[i]))

print(int(dp[N-1]))

### FIXED CODE ###

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

dp = [0] + [10**9]*(N-1)

for i in range(1, N):
  k = min(i, K)
  for j in range(1, k+1):
    cost = abs(H[i-j] - H[i])
    dp[i] = min(dp[i], dp[i-j]+cost)
    if cost == 0:
      break

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

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

if N>M:
    print(0)
else:
    ans=M//N
    while True:
        if (M-(N-1)*ans)%ans==0:
            break
        ans-=1
    print(ans)

### FIXED CODE ###

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

ans=M//N
while True:
    if (M-(N-1)*ans)%ans==0:
        break
    ans-=1
print(ans)
### BUGGY CODE ###

# @oj:atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-04-20 10:31
# @url:https://atcoder.jp/contests/dp/tasks/dp_b
import sys
def input():
    return sys.stdin.readline().strip()

def main():
    nk=list(map(int,input().split()))
    h=list(map(int,input().split()))
    n=nk[0]
    k=nk[1]
    dp=[10**9]*n
    dp[0]=0
    dp[1]=abs(h[1]-h[0])
    i=2
    while i<n:
        dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i))
        i+=1
    # for i in range(2,n):
    #     dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i))
        # for j in range(max(0,i-k),i):
        #     dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i])

    print (dp[-1])

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()