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

mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True,key=lambda x:abs(x))
if k==n:
  ans=1
  for i in range(n):
    ans*=arr[i]
    ans%=mod
  print(ans)
else:
  if k%2==1 and max(arr)<0:
    ans=1
    for i in range(k):
      ans*=arr[n-1-i]
      ans%=mod
    print(ans)
  else:
    ans=1
    cnt=0
    for i in range(k):
      if arr[i]<0:
        cnt+=1
      ans*=arr[i]
      ans%=mod
    if cnt%2==0:
      print(ans)
    else:
      min_plus=-1
      min_minus=1
      for i in range(k):
        if arr[i]>=0:
          min_plus=arr[i]
        else:
          min_minus=arr[i]
      max_plus=-1
      max_minus=1
      for i in range(k,n):
        if arr[i]>=0 and max_plus==-1:
          max_plus=arr[i]
        if arr[i]<0 and max_minus==1:
          max_minus=arr[i]
      if min_plus==-1:        
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      elif min_minus==1:        
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%-mod
        ans*=max_minus
        ans%=mod
      elif min_plus*max_plus>=min_minus*max_minus:
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      else:
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%-mod
        ans*=max_minus
        ans%=mod
      print(ans)

### FIXED CODE ###

import heapq
 
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
q=[]
cnt_plus=0
for i in range(n):
  if arr[i]>0:
    cnt_plus+=1
    heapq.heappush(q,(-arr[i],1))
  elif arr[i]<0:
    heapq.heappush(q,(arr[i],-1))
  else:
    heapq.heappush(q,(0,0))
pick=[]
prev_plus=0
prev_minus=0
cnt=0
for i in range(k):
  tmp,flag=heapq.heappop(q)
  tmp*=-1
  if flag==0:
    print(0)
    exit()
  if flag==1:
    pick.append(tmp)
    prev_plus=tmp
  if flag==-1:
    if cnt==0:
      prev_minus=tmp
      cnt+=1
    else:
      cnt=0
      pick.append(prev_minus)
      pick.append(tmp)
if cnt==0:
  ans=1
  for i in range(k):
    ans*=pick[i]
    ans%=mod
  print(ans%mod)
else:
  cand_plus=0
  cand_minus=0
  while len(q)!=0:
    tmp,flag=heapq.heappop(q)
    tmp*=-1
    if flag==1 and cand_plus==0:
      cand_plus=tmp
    if flag==-1 and cand_minus==0:
      cand_minus=tmp
  if (k%2==1 and cnt_plus==0) or (cand_plus==0 and cand_minus==0):
    if arr.count(0)!=0:
      print(0)
      exit()
    else:
      q=[]
      for i in range(n):
        heapq.heappush(q,abs(arr[i]))
      ans=1
      for _ in range(k):
        ans*=heapq.heappop(q)
        ans%=mod
      print((-ans)%mod)
  else:
    if prev_plus*cand_plus>=prev_minus*cand_minus:
      pick.append(cand_plus)
    else:
      if prev_plus!=0:
        pick.remove(prev_plus)
        pick.append(prev_minus)
        pick.append(cand_minus)
      else:
        pick.append(cand_plus)
    ans=1
    for i in range(k):
      ans*=pick[i]
      ans%=mod
    print(ans%mod)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)

def find(idx, c, arr, tb):

    if c == 0:
        return 0

    if idx <= 0:
        return -100000

    if (idx, c) in tb:
        return tb[(idx, c)]

    rs = find(idx - 2, c - 1, arr, tb) + arr[idx - 1]
    rs = max(rs, find(idx - 1, c, arr, tb))

    tb[(idx, c)] = rs
    return rs


def main():

    n = int(input())
    arr = [int(e) for e in input().split(' ')]
    print(find(n, n // 2, arr, {}))
    return 0


main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)

def find(idx, c, arr, tb):

    if c == 0:
        return 0

    if idx <= 0 or idx < 2 * c - 1:
        return float('-inf')

    if (idx, c) in tb:
        return tb[(idx, c)]

    rs = find(idx - 2, c - 1, arr, tb) + arr[idx - 1]
    rs = max(rs, find(idx - 1, c, arr, tb))

    tb[(idx, c)] = rs
    return rs

def main():

    n = int(input())
    arr = [int(e) for e in input().split(' ')]
    print(find(n, n // 2, arr, {}))
    return 0


main()
### BUGGY CODE ###

N = int(input())
s = []
cnt = 0

for i in range(N):
    s.append(input())

for i in range(N):
    for j in range(i+1, N):
        a = sorted(s[i])
        b = sorted(s[j])
        for x in range(len(a)):
            if a[x] != b[x]:
                break
            elif x == len(a)-1:
                cnt += 1

print(cnt)



### FIXED CODE ###

N = int(input())
dic = {}
count = 0


for i in range(N):
    s = input()
    s_sorted = "".join(sorted(s))
    count += dic.get(s_sorted, 0)
    dic[s_sorted] = dic.get(s_sorted, 0) + 1

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

H,W=map(int,input().split())
S=[[i for i in list(input())]for _ in range(H)]
L=[[1]*W for _ in range(H)]
for i in range(H):
    count=1
    for j in range(W):
        if S[i][j]=="#":
            L[i][j]=0
            count=0
        elif 0<j:
            count=count+1
            L[i][j]=count
R=[[1]*W for _ in range(H)]
for i in range(H):
    count=1
    for j in range(W)[::-1]:
        if S[i][j]=="#":
            R[i][j]=0
            count=0
        elif j<W-1:
            count=count+1
            R[i][j]=count
U=[[1]*W for _ in range(H)]
for i in range(W):
    count=1
    for j in range(H):
        if S[j][i]=="#":
            U[j][i]=0
            count=0
        elif 0!=j:
            count=count+1
            U[j][i]=count
D=[[1]*W for _ in range(H)]
for i in range(W):
    count=1
    for j in range(H)[::-1]:
        if S[j][i]=="#":
            D[j][i]=0
            count=0
        elif j!=H-1:
            count=count+1
            D[j][i]=D[j+1][i]+1
ans=0
for i in range(H):
    for j in range(W):
        count=L[i][j]+R[i][j]+U[i][j]+D[i][j]-3
        ans=max(ans,count)
print(ans)

### FIXED CODE ###

H,W=map(int,input().split())
S=[[i for i in list(input())]for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
for i in range(H):
    count=0
    for j in range(W):
        if S[i][j]=="#":
            count=0
        else:
            count=count+1
        L[i][j]=count
for i in range(H):
    count=0
    for j in range(W)[::-1]:
        if S[i][j]=="#":
            count=0
        else:
            count=count+1
        R[i][j]=count
for i in range(W):
    count=0
    for j in range(H):
        if S[j][i]=="#":
            count=0
        else:
            count=count+1
        U[j][i]=count
for i in range(W):
    count=0
    for j in range(H)[::-1]:
        if S[j][i]=="#":
            count=0
        else:
            count=count+1
        D[j][i]=count
ans=0
for i in range(H):
    for j in range(W):
        ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 21:45:38 2020

@author: H_Hoshigi
"""

import math

K = 200#int(input())

answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            answer += math.gcd(math.gcd(a, b), c)
print(answer)



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 22:01:05 2020

@author: H_Hoshigi
"""

import math

K = int(input())
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        gcd_a_b = math.gcd(a, b)
        for c in range(1, K+1):
            answer += math.gcd(gcd_a_b, c)
print(answer)
### BUGGY CODE ###

import sys
import  math
import fractions
from collections import defaultdict
import copy
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

K=int(input())
mod=7%K
mod_k=7%K
ans=1
while(1):
    if(mod==0):
        print(ans)
        sys.exit(0)
    mod_k=(mod_k*10)%K   
    if(mod_k==0):
        print(-1)
        sys.exit(0)
    mod=(mod+mod_k)%K
    ans+=1

print(ans)

### FIXED CODE ###

import sys
import  math
import fractions
from collections import defaultdict
import copy
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

K=int(input())
mod_l=[0]*(K*10)
mod_l[0]=7%K
mod_k=7%K
ans=1
for i in range(10*K-1):
    if(mod_l[i]==0):
        print(ans)
        sys.exit(0)
    mod_k=(mod_k*10)%K  
    if(mod_k==0):
        print("-1")
        sys.exit(0)
    mod_l[i+1]=(mod_l[i]+mod_k)%K
    ans+=1

print("-1")
### BUGGY CODE ###

N = int(input())
array = list(map(int, input().split()))
array.sort()
ans = 0
# print(array)
for i in range(N):
    for k in range(i+1,N):
        for j in range(k+1,N):
            if (array[i] < array[k] + array[j]) and (array[j] < array[i] + array[k]) and (array[k] < array[i] + array[j]):
                ans += 1
                # print(array[i],array[k],array[j])
            else:
                break
print(ans)

### FIXED CODE ###

import bisect
N = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(N):
    for k in range(i+1,N):
        tmp = bisect.bisect_left(a,a[i]+a[k])
        ans += tmp - k - 1
print(ans)
### BUGGY CODE ###

import itertools
N = int(input())
value_list = list(map(int, input().split()))
cost_list = list(map(int, input().split()))

value_result = []
for i in range(1,len(value_list)+1):
    for conb in itertools.combinations(value_list, i):
        value_result.append(list(conb)) 

cost_result = []
for i in range(1,len(cost_list)+1):
    for conb in itertools.combinations(cost_list, i):
        cost_result.append(list(conb)) 

ans_list = []
for i in range(len(value_result)):
    ans = sum(value_result[i]) - sum(cost_result[i])
    ans_list.append(ans)

if max(ans_list) > 0:
    print(max(ans_list))
else:
    print(0)

### FIXED CODE ###

N = int(input())
value_list = list(map(int, input().split()))
cost_list = list(map(int, input().split()))
total = 0
for i in range(N):
    ans = value_list[i] - cost_list[i]
    if ans > 0:
        total += ans
print(total)
### BUGGY CODE ###

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

S = list(input())

# print(int(''.join(S)) / 2019)
# print(int(''.join(S)) % 2019)

cnt = 0

# for i in range(0,len(S)-3) :
#     for j in range(i+3, len(S)) :
#         # print(int(''.join(S[i:j+1])))
#         res = int(''.join(S[i:j+1]))
#         if res % 2019 == 0 :
#             cnt += 1
#             print(S[i:j+1])

for i in range(0,len(S)-3) :
    amari = int(''.join(S[i:i+3]))
    for j in range(i+3, len(S)) :
        amari = ((amari * 10) + int(S[j])) % 2019
        if amari == 0 :
            cnt += 1

print(cnt)

### FIXED CODE ###

S = input()
P =2019
ans = 0

count = [0] * P
count[0] = 1
u = 0
for i, s in enumerate(reversed(S)):
    u = (int(s) * pow(10, i, P) + u) % P
    ans += count[u]
    count[u] += 1
print(ans)
### BUGGY CODE ###

mod = 10 ** 9 + 7
S = input()
abc = 0
bc = 0
c = 0
q = 0

for i in range(len(S)-1, -1, -1):
    if S[i] == 'C':
        c = ((3 ** q) % mod + c) % mod
    if S[i] == 'B':
        bc = (bc + c) % mod
    if S[i] == 'A':
        abc = (abc + bc) % mod
    if S[i] == '?':
        abc = (abc * 3 + bc) % mod
        bc = (bc * 3 + c) % mod
        c = (c * 3 + (3 ** q) %mod) % mod
        q += 1
        
print(abc)

### FIXED CODE ###

S = input()
mod = 10 ** 9 + 7
abc = 0
bc = 0
c = 0
q = 0

for i in S[::-1]:
    if i == 'A':
        abc = (bc + abc) % mod
    if i == 'B':
        bc = (c + bc) % mod
    if i == 'C':
        c = (pow(3, q, mod) + c ) % mod
    if i == '?':
        abc = (abc * 3 + bc) % mod
        bc = (bc * 3 + c) % mod
        c = (pow(3, q, mod) + c * 3) % mod
        q += 1
        
print(int(abc))
### BUGGY CODE ###

# coding: utf-8
n=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(n):
    if n%2==0:
        if i%2==0:
            B.append(str(A[i]))
        else:
            B.insert(0,str(A[i]))
    else:
        if i%2!=0:
            B.append(str(A[i]))
        else:
            B.insert(0,str(A[i]))
print(' '.join(B))

### FIXED CODE ###

# coding: utf-8
n=int(input())
A=list(map(int,input().split()))
B=[0]*n
l=n//2
if n%2==0:
    for i in range(n):
        if i%2==0:
            B[l+i]=str(A[i])
            l=l+i
        else:
            B[l-i]=str(A[i])
            l=l-i
else:
    for i in range(n):
        if i%2==0:
            B[l-i]=str(A[i])
            l=l-i
        else:
            B[l+i]=str(A[i])
            l=l+i
print(' '.join(B))
### BUGGY CODE ###

import itertools

def warshall_floyd(d):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j] = min(d[i][j],d[i][k] + d[k][j])
  return d


n, m, r = map(int, input().split())
list_r = list(map(int, input().split()))
list_cand = list(itertools.permutations(list_r))

dist = [[float("inf") if i != j else 0 for j in range(n)] for i in range(n)]
for i in range(m):
  a, b, c = map(int, input().split())
  dist[a-1][b-1] = c
  dist[b-1][a-1] = c
min_dist = warshall_floyd(dist)

result = 10**100
for one_cand in list_cand:
  temp = 0
  idx = 0
  while idx < r-1:
    temp += min_dist[one_cand[idx]-1][one_cand[idx+1]-1]
    idx += 1
  if temp < result:
    result = temp
print(result)

### FIXED CODE ###

from itertools import permutations
import sys

def main():
    
    N, M, R = map(int, sys.stdin.readline().split())
    r = [i - 1 for i in map(int, sys.stdin.readline().split())]
    
    d = [[float('inf')] * N for _ in range(N)]
    
    for i in range(N):
        d[i][i] = 0
        
    for i in range(M):
        a, b, c = map(int,sys.stdin.readline().split())
        d[a-1][b-1] = c
        d[b-1][a-1] = c
        
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    
    ans = 10**12
    
    for each in permutations(r):
        t_dis = 0
        for i in range(R-1):
            t_dis += d[each[i]][each[i+1]]  
        
        ans = min(ans, t_dis)
    
    print(ans)

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

N = int(input())
f = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    f[a-1].append([b-1,c])
    f[b-1].append([a-1,c])
from collections import deque
d = deque()
s = [-1]*N
Q,K = map(int,input().split())
for i in range(N):
    t = [-1]*N
    d.append(i)
    t[i] = 0
    if i == K-1:
        Flag = False
        z = d.clear()
    else:
        Flag = True
    while Flag:
        z = d.popleft()
        for j,c in f[z]:
            if t[j] == -1:
                t[j] = c+t[z]
                d.append(j)
            if j == K-1:
                Flag = False
                d.clear()
                break
    s[i] = t[K-1]
for i in range(Q):
    x,y = map(int,input().split())
    print(s[x-1]+s[y-1])

### FIXED CODE ###

N = int(input())
f = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    f[a-1].append([b-1,c])
    f[b-1].append([a-1,c])
from collections import deque
d = deque()
s = [-1]*N
Q,K = map(int,input().split())
d.append(K-1)
s[K-1] = 0
while len(d) > 0:
    z = d.popleft()
    for i,j in f[z]:
        if s[i] == -1:
            s[i] = j+s[z]
            d.append(i)
for i in range(Q):
    x,y = map(int,input().split())
    print(s[x-1]+s[y-1])
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

if(N == 1):
    print(1)
else:
    color = 1
    right = A[N-1]
    left_list = [-1]
    for i in range(1, N):
        num = N-i-1
        if(A[num] >= right):
            max_left = max(left_list)
            if(A[num] >= max_left):
                color += 1
                left_list.append(right)
            else:
                left_list.pop(left_list.index(max_left))
                left_list.append(A[num])
        right = A[num]
    print(color)


### FIXED CODE ###

from bisect import *

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

r = [10**10] * N
index = -1
for i in range(N):
    j = bisect_right(r, -A[i])
    r[j] = -A[i]
    if j > index:
        index = j
print(index + 1)
### BUGGY CODE ###

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

INF=float("inf")

dp=[INF]*N
dp[0]=0

for i in range(0, N-1):
  for k in range(1, K+1):
    if i+k <= N-1:
      dp[i+k]=min(dp[i+k],dp[i]+abs(A[i]-A[i+k]))
    else:
      break
print(dp[N-1])


### FIXED CODE ###

# -*- coding:utf-8 -*-

def solve():
    """ dp[i+k]を求める方法
    TLE 
    """
    N,K=list(map(int,input().split()))
    A=list(map(int,input().split()))
    
    INF=float("inf")
    
    dp=[INF]*N
    dp[0]=0
    
    for i in range(0, N-1):
        for k in range(1, K+1):
            if i+k <= N-1:
                dp[i+k]=min(dp[i+k],dp[i]+abs(A[i]-A[i+k]))
            else:
                break
    print(dp[N-1])


def solve2():
    """dp[i]を求める方法
    """
    N,K=list(map(int,input().split()))
    A=list(map(int,input().split()))
    
    INF=float("inf")
    
    dp=[INF]*N
    dp[0]=0
    for i in range(1, N):
        for k in range(1, K+1):
            if i-k >= 0:
                dp[i] = min(dp[i], dp[i-k]+abs(A[i]-A[i-k]))
            else:
                break
    print(dp[N-1])


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

N = int(input())
Xs = [0] + list(map(int, input().split()))
mod = 10**9 + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

NNN = (10**6)
g1 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

mxx = Xs[-1]
r = 0
for i in range(N):
    i += 1
    for j in range(1, N-i):
        ue = mul(g1[N-1], Xs[i+j] - Xs[i])
        ff = mul(mul(ue, inverse[j+1]), inverse[j])
        r = (r + ff) % mod
    ue = mul(g1[N-1], Xs[N]-Xs[i])
    ff = mul(ue,inverse[N-i])
    r = (r+ff)%mod

print(r)


### FIXED CODE ###

N = int(input())
Xs = list(map(int, input().split()))
mod = 10**9 + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
NNN = (10**6)
g1 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

mxx = Xs[-1]
r = 0
r2 = 0
for i in range(N-1):
    r = (r+mul(mul(g1[N-1],inverse[i+1]),Xs[N-1]-Xs[i]))%mod
print(r)
### BUGGY CODE ###

L = [int(input()) for _ in range(int(input()))]
r = 0
for s in set(L):
    C = L.count(s)
    if C == 1:
        r+=1
    else:
        if C % 2 != 0:
            r+=1
print(r)

### FIXED CODE ###

S = set()
for _ in range(int(input())):
    A = int(input())
    if A not in S:
        S.add(A)
    else:
        S.remove(A)
print(len(S))
### BUGGY CODE ###

n=int(input())
s=str(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=0
for l in r:
  for m in g:
    for k in b:
      if abs(m-l)!=abs(k-m) and abs(k-l)!=abs(k-m) and abs(k-l)!=abs(l-m):
        ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
s=str(input())
if n<=2:
    print(0)
    exit()
r=s.count('R')
g=s.count('G')
b=s.count('B')
ans=r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i>n-1:
            break
        if s[i]!=s[j] and s[j]!=s[2*j-i] and s[i]!=s[2*j-i]:
            ans-=1
print(ans)
### BUGGY CODE ###

from collections import deque
import copy

def main():
  H, W = map(int, input().split())
  M = [['#' == x for x in input()] for _ in range(H)]
  que = deque([[i, j] for i in range(H) for j in range(W) if M[i][j]])
  ans = 0
  while que:
    qq = []
    ans += 1
    for nh, nw in que:
      if nw+1<=W-1 and not M[nh][nw+1]:
        qq.append([nh,nw+1])
        M[nh][nw+1] = True
      if  0<=nw-1 and not M[nh][nw-1]:
        qq.append([nh,nw-1])
        M[nh][nw-1] = True
      if nh+1<=H-1 and not M[nh+1][nw]:
        qq.append([nh+1,nw])
        M[nh+1][nw] = True
      if 0<=nh-1 and not M[nh-1][nw]:
        qq.append([nh-1,nw])
        M[nh-1][nw] = True
    if qq:
      que = copy.copy(qq)
    else:
      break
  print(ans-1)

if __name__ == "__main__":
  main()

### FIXED CODE ###

import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  G = [['#' == x for x in input()] for _ in range(H)]
 
  black = deque([(i, j) for i in range(H) for j in range(W) if G[i][j]])
 
  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not G[bi - 1][bj]:
        G[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not G[bi][bj - 1]:
        G[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not G[bi + 1][bj]:
        G[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not G[bi][bj + 1]:
        G[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):

    result = 0
    for i in range(N):
        if P[i] == min(P[: i + 1]):
            result += 1
        else:
            pass
    print(result)

    return


# Generated by 1.1.6 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
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):

    result = 1
    min_num = P[0]
    for i in range(N):
        if P[i] < min_num:
            result += 1
            min_num = P[i]
        else:
            pass
    print(result)

    return


# Generated by 1.1.6 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
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)


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

from collections import Counter
n = int(input())
A = Counter(list(map(int, input().split())))
A_keys = list(A.keys())
A_keys.sort()
for key in A_keys:
    if A[key] == 0:
        continue
    for x in A_keys:
        if x != key and x % key == 0:
            A[x] = 0
ans = 0
for key in A_keys:
    if A[key] > 1 or A[key] == 0:
        continue
    ans += 1
print(ans)

### FIXED CODE ###

n = input()
*A, = map(int, input().split())
max_A = max(A)
count = {a:0 for a in A}
for a in A:
    count[a] += 1
is_OK = {a:True for a in A}
for a in A:
    i = 2
    if not is_OK[a]:
        continue
    while a * i < max_A + 1:
        is_OK[a * i] = False
        i += 1
ans = 0
for a in A:
    if count[a] == 1 and is_OK[a]:
        ans += 1
print(ans)
### BUGGY CODE ###

n, k=map(int, input().split())
plist = list(map(int, input().split()))
last = 0
point = 1
ans = []
while k <= len(plist):
  for i in range(k):
    point = point * plist[i]
  if last > 0:
    if point > last:
      print("Yes")
    else:
      print("No")
  last = point
  point = 1
  del plist[0]

### FIXED CODE ###

import numpy as np
n, k=map(int, input().split())
plist = list(map(int, input().split()))
for i in range(n - k):
  if plist[i] < plist[k+i]:
    print("Yes")
  else:
    print("No")