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

#!/usr/bin/env python3
import sys


def solve(n: int, a: "List[int]"):
    b = list()
    for i in range(n):
        b.append(str(a[i]))
        b.reverse()
    print(" ".join(b))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve_naive(n: int, a: "List[int]"):
    b = list()
    for i in range(n):
        b.append(str(a[i]))
        b.reverse()
    print(" ".join(b))
    return

def solve_(n: int, a: "List[int]"):
    a = list(map(str, a))
    b = list()
    for i in range(n):
        if i % 2 == 0:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    if n % 2 == 0:
        b.reverse()
    print(" ".join(b))
    return

def solve__(n: int, a: "List[int]"):
    a = list(map(str, a))
    b = list()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    print(" ".join(b))
    return

def solve___(n: int, a: "List[int]"):
    b = list()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.insert(0, a[i])
        else:
            # append
            b.append(a[i])
    print(*b)
    return

def solve(n: int, a: "List[int]"):
    import collections
    b = collections.deque()
    for i in range(n):
        if i % 2 == (n-1) % 2:
            # push
            b.appendleft(a[i])
        else:
            # append
            b.append(a[i])
    print(*b)
    return

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

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

def count(S):
    p = 0
    res = 0
    for s in S:
        if s == '0':
            p += 1
        else:
            res += p
    return res

S = input().strip()
a = '0'
b = 1
bc = '1'
x = '2'
T = ''
stack = []
for s in S:
    if s == 'A':
        if stack:
            T += x
        stack = []
        T += a
    elif s == 'B':
        stack.append(b)
    elif s == 'C':
        if stack and stack[-1] == b:
            stack.pop()
            if stack:
                T += x
            T += bc
        else:
            stack.append(x)
ans = 0
for g in T.split(x):
    ans += count(g)
print(ans)

### FIXED CODE ###

def count(S):
    p = 0
    res = 0
    for s in S:
        if s == '0':
            p += 1
        else:
            res += p
    return res

S = input().strip()
a = '0'
b = 1
bc = '1'
x = '2'
T = ''
stack = []
for s in S:
    if s == 'A':
        if stack:
            T += x
        stack = []
        T += a
    elif s == 'B':
        stack.append(b)
    elif s == 'C':
        if stack and stack[-1] == b:
            stack.pop()
            if stack:
                T += x
            T += bc
        else:
            stack.append(x)
ans = 0
for g in T.split(x):
    ans += count(g)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int,input().split()))
print(min(abs(sum(A[0:i+1])-sum(A[i+1:n])) for i in range(n-1)))


### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
Asum = sum(A)
Al = 0
ans = Asum
for a in A:
    Al += a
    Ar = Asum-Al
    ans = min(ans,abs(Ar-Al))
print(ans)
### BUGGY CODE ###

R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

dp0 = [[0]*(C+1) for _ in range(R+1)]
dp1 = [[0]*(C+1) for _ in range(R+1)]
dp2 = [[0]*(C+1) for _ in range(R+1)]
dp3 = [[0]*(C+1) for _ in range(R+1)]
for i in range(R+1):
    for j in range(C+1):
        v = V[i][j]

        la = lb = lc = ld = 0
        if j > 0:
            la = dp0[i][j-1]
            lb = dp1[i][j-1]
            lc = dp2[i][j-1]
            ld = dp3[i][j-1]
            dp2[i][j] = max(dp2[i][j], lc, lb + v)
            dp3[i][j] = max(dp3[i][j], ld, lc + v)

        if i > 0:
            max_p = max(dp0[i-1][j], dp1[i-1][j], dp2[i-1][j], dp3[i-1][j])
            dp0[i][j] = max(dp0[i][j], max_p, la)
            dp1[i][j] = max(dp0[i][j], max_p + v, lb, la + v)

print(max(dp0[R][C], dp1[R][C], dp2[R][C], dp3[R][C]))


### FIXED CODE ###

R, C, K = map(int, input().split())

V = [[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

pre = [[0]*(3+1) for _ in range(C+1)]
for i in range(R+1):
    now = [[0]*(3+1) for _ in range(C+1)]
    for j in range(C+1):
        for k in range(3+1):
            if i-1 >= 0:
                now[j][0] = max(now[j][0], pre[j][k])
                now[j][1] = max(now[j][1], pre[j][k] + V[i][j])

            if j-1 >= 0:
                now[j][k] = max(now[j][k], now[j-1][k])
                if k-1 >= 0:
                    now[j][k] = max(now[j][k], now[j-1][k-1] + V[i][j])
    pre = now

print(max(now[C]))
### BUGGY CODE ###

n = int(input())
Ls = list(map(int, input().split()))
cnt = 0

def check(a, b, c):
    if a < b+c and b < c + a and c < a + b:
        return True
    else:
        return False


for i in range (n):
    a = Ls[i]
    for j in range(i+1, n):
        b = Ls[j]
        for k in range(j+1, n):
            c = Ls[k]
            if check(a, b, c):
                cnt += 1


print(cnt)


### FIXED CODE ###

import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
from bisect import bisect_right
input = lambda: sys.stdin.readline().rstrip()


def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()
    cnt = 0
    for i in range(0,n-2):
        for j in range(i+1,n-1):
            #k以下なら良い
            k =  Ls[i] + Ls[j] -1
            # bisect_right(Ls, k)個の要素が左にある
            # 答え: bisect_right(Ls, k) - j
            cnt += max(bisect_right(Ls, k) - j-1, 0)
            # print(Ls, Ls[i],Ls[j],k, bisect_right(Ls,k)-j-1)
    print(cnt)
            

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

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

ans =[]

for i in range(n):
  for j in range(a):
    ans.append("b")
    continue
  
  for k in range(b):
    ans.append("r")
    continue
    

num =0   
for l in range(n):
  if ans[l] == "b":
    num += 1
  
  
  
print(num)

### FIXED CODE ###

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

ans = n //(a+b)

if n%(a+b) >= a:
  ans2 = a
elif n%(a+b) <a:
  ans2 = n%(a+b)
  
  
print(ans*a+ans2)
### BUGGY CODE ###

def f():
     n,m = map(int,input().split())
     a = list(map(int,input().split()))
     for i in range(m):
          b,c = map(int,input().split())
          a += [c]*b
     a.sort(reverse=True)
     print(sum(a[:n]))

f()

### FIXED CODE ###

def f(n,m):
     a = list(map(int,input().split()))
     min_a = min(a)
     a = [(1,i) for i in a]
     b_c = [tuple(map(int,input().split())) for i in range(m)]
     a += b_c
     a.sort(key=lambda x:x[1])
     ans = 0
     while True:
          if n>a[-1][0]:
               ans += a[-1][0]*a[-1][1]
               n -= a[-1][0]
               a.pop()
          else:
               ans += a[-1][1]*n
               break
     print(ans)

n,m = map(int,input().split())
f(n,m)
### BUGGY CODE ###

import math
from functools import reduce
K = int(input())
sum = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            nums = [a, b, c]
            gcd = reduce(math.gcd, nums)
            sum += gcd
print(sum)

### FIXED CODE ###

from math import gcd
K = int(input())
sum = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        p = gcd(a, b)
        for c in range(1, K+1):
            sum += gcd(p, c)
print(sum)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

N, M, K = [int(s) for s in input().split()]
n = 0
A = [0]
for s in input().split():
    n = n + int(s)
    A.append(n)

n = 0
B = [0]
for s in input().split():
    n = n + int(s)
    B.append(n)

ans = 0
for i, a_time in enumerate(A):
    if a_time <= K:
        for j, b_time in enumerate(B):
            read_time = a_time + b_time
            if read_time <= K:
                if ans <= i + j:
                    ans = i + j
            else:
                break

print(ans)

### FIXED CODE ###

import sys

N, M, K = [int(s) for s in sys.stdin.readline().split()]
n = 0
A = [0]
for s in sys.stdin.readline().split():
    n = n + int(s)
    A.append(n)

n = 0
B = [0]
for s in sys.stdin.readline().split():
    n = n + int(s)
    B.append(n)

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

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

a, b, q = map(int, input().split())
s = []
t = []
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
    
import numpy as np
s = np.array(s)
t = np.array(t)

for i in x:
    ans_st = 0
    ans_ts = 0
    # s -> t
    ans_st += min(abs(s-i))
    ans_st += min(abs(t - s[list(abs(s-i)).index(min(abs(s-i)))]))
    
    # t->s
    ans_ts += min(abs(t-i))
    ans_ts += min(abs(s - t[list(abs(t-i)).index(min(abs(t-i)))]))
    
    print(min(ans_st, ans_ts))

### FIXED CODE ###

import bisect
import math

a, b, q = map(int, input().split())
s = [-math.inf]
t = [-math.inf]
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
s.append(math.inf)
t.append(math.inf)

for i in x:
    ws = abs(s[bisect.bisect(s, i) - 1] - i)
    if ws != math.inf:
        ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]))
    else:
        ws = math.inf
    
    es = abs(s[bisect.bisect(s, i)] - i)
    if es != math.inf:
        es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]))
    else:
        es = math.inf
    
    wt = abs(t[bisect.bisect(t, i) - 1] - i)
    if wt != math.inf:
        wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]))
    else:
        wt = math.inf
    
    et = abs(t[bisect.bisect(t, i)] - i)
    if et != math.inf:
        et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]))
    else:
        et = math.inf
        
    print(min(ws, es, wt, et))
### BUGGY CODE ###

from math import gcd


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

l = (n * m) // gcd(n, m)
ln, lm = l // n, l // m
for i in range(l):
    if i % ln == i % lm == 0:
        if s[i // ln] != t[i // lm]:
            print(-1)
            break
else:
    print(l)


### FIXED CODE ###

from math import gcd


def lcm(X, Y):  # 最小公倍数
    return (X * Y) // gcd(X, Y)

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

l = lcm(n,m)
ln, lm = l // n, l // m
for i in range(0, l, lcm(ln, lm)):
    if s[i // ln] != t[i // lm]:
        print(-1)
        break
else:
    print(l)
### BUGGY CODE ###

n=int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return len(lower_divisors) + len(upper_divisors[::-1])


d=[0]*(n+1)

for i in range(n+1):
    d[i]+=make_divisors(i)


ans=0
for i in range(n+1):
    ans+=i*d[i]

print(ans)

### FIXED CODE ###

n=int(input())

def sum_k(n):
    return n*(n+1)//2

ans=0
for i in range(1,n+1):
    ans+=i*sum_k(n//i)

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

from collections import deque
import sys
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

maze = []
for i in range(H):
    maze.append(list(input()))

cnt = 0

def bfs():
    global cnt
    reached = [[False]*W for _ in range(H)]

    d = deque()
    d.append((Ch, Cw))
    #reached[Ch][Cw] = True
    while d:
        while d:
            h, w = d.popleft()
            dh = [-1, 0, 1, 0]
            dw = [0, -1, 0, 1]
            reached[h][w] = True
            for i in range(4):
                next_h = h + dh[i]
                next_w = w + dw[i]
                if 0 <= next_h <= H-1 and 0 <= next_w <= W-1 and maze[next_h][next_w] != "#" and not reached[next_h][next_w]:
                    d.append((next_h, next_w))
        if reached[Dh][Dw]:
            print(cnt)
            sys.exit(0)
        for i in range(H):
            for j in range(W):
                if reached[i][j] or maze[i][j] == "#":
                    continue
                for n in range(i-2, i+3):
                    for m in range(j-2, j+3):
                        if 0 <= n <= H-1 and 0 <= m <= W-1 and reached[n][m]:
                            d.append((i, j))
        if d:
            cnt += 1

bfs()
print(-1)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

INF = 1e10
maze = []

dh = [-1,0,1,0]
dw = [0,1,0,-1]

for i in range(H):
    tmp = list(input())
    maze.append(tmp)

reached = [[INF]*W for _ in range(H)]

l = deque()
l.appendleft((Ch, Cw))
reached[Ch][Cw] = 0
while l:
    h, w = l.popleft()
    d = reached[h][w]
    for i in range(4):
        nh = h + dh[i]
        nw = w + dw[i]
        if not (0 <= nh <= H-1 and 0 <= nw <= W-1):
            continue
        if not maze[nh][nw] != "#":
            continue
        if not reached[nh][nw] > d:
            continue
        reached[nh][nw] = d
        l.appendleft((nh, nw))
    for i in range(-2, 3):
        for j in range(-2, 3):
            nh = h + i
            nw = w + j
            if not (0 <= nh <= H-1 and 0 <= nw <= W-1):
                continue
            if not maze[nh][nw] != "#":
                continue
            if not reached[nh][nw] > d + 1:
                continue
            reached[nh][nw] = d + 1
            l.append((nh, nw))

ans = reached[Dh][Dw]
if ans != INF:
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())))

ans = 0

for i in range(N):
    tmp = a.copy()
    tmp = np.abs(tmp - tmp[i])
    ans = max(ans, np.where(tmp<=1)[0].shape[0])

print(ans)

### FIXED CODE ###

from collections import Counter

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

for i in range(N):
    a.append(a[i]+1)
    a.append(a[i]-1)

ans = Counter(a)

print(ans.most_common()[0][1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from collections import deque


class LinkedList:
    def __init__(self, n):
        self.n = n
        self.ll = [[] for _ in range(self.n)]

    def link(self, u, v, direction=False):
        self.ll[u].append(v)
        if not direction:
            self.ll[v].append(u)

    def check(self, start, goal):
        states = [0] * self.n
        queue = deque([start])

        while queue:
            u = queue.popleft()
            if states[u]:
                continue
            else:
                states[u] = 1

            for v in self.ll[u]:
                if v == goal:
                    print('yes')
                    return

                if states[v]:
                    continue
                else:
                    queue.append(v)

        else:
            print('no')
            return


if __name__ == '__main__':
    n, m = map(int, input().split())
    ll = LinkedList(n)

    for _ in range(m):
        u, v = map(int, input().split())
        ll.link(u, v)

    q = int(input())
    for _ in range(q):
        u, v = map(int, input().split())
        ll.check(u, v)



### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)


class LinkedList:
    def __init__(self, n):
        self.n = n
        self.ll = [[] for _ in range(self.n)]

    def link(self, u, v, direction=False):
        self.ll[u].append(v)
        if not direction:
            self.ll[v].append(u)

    def dfs(self):
        self.cc = [None] * self.n

        color = 1
        for u in range(self.n):
            if not self.cc[u]:
                self.dfs_visit(u, color)
                color += 1

    def dfs_visit(self, u, color):
        self.cc[u] = color
        for v in self.ll[u]:
            if not self.cc[v]:
                self.dfs_visit(v, color)

    def check(self, u, v):
        if self.cc[u] == self.cc[v]:
            print('yes')
        else:
            print('no')


if __name__ == '__main__':
    n, m = map(int, input().split())
    ll = LinkedList(n)

    for _ in range(m):
        u, v = map(int, input().split())
        ll.link(u, v)
    ll.dfs()

    q = int(input())
    for _ in range(q):
        u, v = map(int, input().split())
        ll.check(u, v)
### BUGGY CODE ###

from collections import deque

H,W=map(int, input().split())
A=[]
for i in range(H):
  A.append(list(input()))
ds=[]
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      ds.append((i, j))

x=-1
q=deque([(i, j, 0) for i,j in ds])
for i in range(H*W):
  if not q: break
  (i, j, n)=q.popleft()
  x=max(x, n)
  if i > 0 and A[i-1][j] == '.':
    A[i-1][j] = '#'
    q.append((i-1, j, n+1))
  if i < H-1 and A[i+1][j] == '.':
    A[i+1][j] = '#'
    q.append((i+1, j, n+1))
  if j > 0 and A[i][j-1] == '.':
    A[i][j-1] = '#'
    q.append((i, j-1, n+1))
  if j < W-1 and A[i][j+1] == '.':
    A[i][j+1] = '#'
    q.append((i, j+1, n+1))

print(x)

### FIXED CODE ###

def f(h, w):
    dt = [[-1, 0], [0, -1], [0, 1], [1, 0]]
    t = [[True] * (w + 2)]
    for _ in range(h):
        t += [[True] + [(c == "#") for c in input()] + [True]]
    t += [[True] * (w + 2)]
    kuro = []
    for i, ti in enumerate(t[1:-1]):
        for j, tij in enumerate(ti[1:-1]):
            if tij:
                kuro+=[(i + 1, j + 1)]
    cnt = -1
    while kuro:
        cnt += 1
        nxt = []
        for i, j in kuro:
            ti=t[i]
            if not ti[j+1]:
                ti[j + 1]=True
                nxt += [(i, j+1)]
            if not ti[j-1]:
                ti[j - 1]=True
                nxt += [(i, j-1)]
            if not t[i - 1][j]:
                t[i - 1][j]=True
                nxt += [(i - 1, j)]
            if not t[i + 1][j]:
                t[i + 1][j]=True
                nxt += [(i + 1, j)]
        kuro = nxt
    print(cnt)
 
 
h, w = map(int, input().split())
f(h, w)
### BUGGY CODE ###

def main():
    n, W, *wv = map(int, open(0).read().split())
    dp = [0] * (W + 1)
    for i in range(n):
        w = wv[i * 2]
        v = wv[i * 2 + 1]
        for j in range(W, w - 1, -1):
            dp[j] = max(dp[j], dp[j - w] + v)
    print(dp[W])

main()

### FIXED CODE ###

from numpy import zeros, maximum            
                                            
n, W, *wv = map(int, open(0).read().split())
t = zeros(W+1, int)                         
for i in range(n):                          
    w = wv[i * 2]                           
    v = wv[i * 2 + 1]                       
    t[w:] = maximum(t[w:], t[:-w]+v)        
print(t[-1])
### BUGGY CODE ###

import sys
inp = sys.stdin.readline
n = int(inp())
a = list(map(int,inp().split()))
def gcd(a,b):
    if a < b:
        a,b = b,a
    while b:
        a,b = b,a%b
    return a
ans = 1
for i in range(n):
    _a = a[:]
    # _a.pop(i)
    tmp = _a[i+1] if i != n-1 else _a[0]
    for j in range(n):
        if j != i:
            tmp = gcd(tmp,_a[j])
        else:
            pass
    if tmp > ans:
        ans = tmp
print(ans)

### FIXED CODE ###

#EOFERROR
# import math
# import copy
# from functools import reduce
# n = int(input())
# a = list(map(int,input().split()))
# ans = reduce(math.gcd,a)
# if n<=2 or (min(a)==max(a)):
#     print(max(a))
# else:
#     for i in range(n):
#         _a = copy.copy(a)
#         _a.pop(i)
#         tmp = reduce(math.gcd,_a)
#         if tmp > ans:
#             print(tmp)
#             break
#         else:
#             pass

def gcd(a,b):
    if b>a :
        a,b = b,a
    while b:
        a,b = b,a%b
    return a

def cul(n,x):
    l = len(x)
    b = [x[i] for i in range(l)]
    b.pop(n)
    tmp = b[0]
    for i in range(1,l-1):
        tmp = gcd(tmp,b[i])
    return tmp

import sys
p = 50
N = int(input())
if p>N : p=N
a = list(map(int,input().split()))

ans = 0

for i in range(p):
    s = cul(i,a[:p])
    if s>ans : ans=s

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

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

ans=0
X=0
while X<=K:
    Y=0
    while Y<=K:
        Z=S-(X+Y)
        if 0<=Z<=K:
            ans+=1
        Y+=1
    X+=1

print(ans)

### FIXED CODE ###

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

ans=0
for X in range(K+1):
    for Y in range(K+1):
        ans+=1*(0<=S-X-Y<=K)

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

# # Educational DP Contest B
N, K = map(int, input().split())
H = list(map(int, input().split()))

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

dp[0] = 0
for i in range(1, N):
    cost_list = [float("inf")] * K
    for k in range(1, K+1):
        if i - k < 0:
            break
        cost_list[k-1] = dp[i-k] + abs(H[i] - H[i-k])
    dp[i] = min(cost_list)
print(dp[N-1])

### FIXED CODE ###

# # Educational DP Contest B
N, K = map(int, input().split())
H = list(map(int, input().split()))

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

dp[0] = 0
for i in range(1, N):
    cost_list = [float("inf")] * K
    for k in range(1, K+1):
        if i - k < 0:
            break
        cost_list[k-1] = dp[i-k] + abs(H[i] - H[i-k])
    dp[i] = min(cost_list)
print(dp[N-1])
### BUGGY CODE ###

from math import ceil

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

m = 10**6+100
n_map = {}
v_a = []
nn_map = {}
for i in a:
    if i not in n_map:
        n_map[i] = 1
    else:
        n_map[i] += 1
    for j in range(2, ceil(m / i) + 1):
        nn_map[i * j] = True

v_a = [k for k, v in n_map.items() if v <= 1]

v_a.sort()
vv_a = []

for i in v_a:
    if i in nn_map:
        continue
    vv_a.append(i)

print(len(vv_a))

### FIXED CODE ###

from math import ceil

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

m = 10 ** 6
n_map = {}
v_a = []
for i in a:
    if i not in n_map:
        n_map[i] = 1
    else:
        n_map[i] += 1
v_a = [(k,v) for k, v in n_map.items()]

v_a.sort(key=lambda x: x[0])
res = 0
nn_map = {}
for i, v in v_a:
    if i in nn_map:
        continue
    for j in range(1, ceil(m / i) + 1):
        nn_map[i * j] = True
    if v == 1:
        res += 1
print(res)
### BUGGY CODE ###

from collections import Counter
N = int(input())
S = list(input())
m = []
for i in range(N):
    if S[i] == 'E':
        S[i] = 1
    else:
        S[i] = -1
for i in range(1, N):
    l = S[:i-1].count(-1)
    r = S[i+1:].count(1)
    m.append(l+r)
print(min(m))


### FIXED CODE ###

import numpy as np
N = int(input())
S = np.array(list(input()))
n = []
for i in range(N):
    if S[i] == 'E':
        S[i] = 1
    else:
        S[i] = 0
S = np.array(S, dtype=int)
S = np.cumsum(S)
last = S[N-1]
n.append(last-S[0])
for i in range(1, N):
    ls = i - S[i-1]
    rs = last - S[i]
    n.append(ls+rs)
print(min(n))