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

from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
p = [0]+readInts()
c = [0]+readInts()

past = [False]*(n+1)
ans = -1-float("inf")
for i in range(1,n+1):
	j = p[i]
	if past[j]: continue
	past[j] = True
	t = [0]
	al = []
	while j not in al:
		t.append(t[-1]+c[j])
		al.append(j)
		j = p[j]
	if t[-1]<0:
		ans = max(ans, max(t[1:k+1]))
	else:
		kuri = k//(len(t)-1)
		s = kuri*t[-1]
		ans = max(ans, max(s,s+max(t[:k-kuri*(len(t)-1)+1])))

print(ans)


### FIXED CODE ###

from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
p = [0]+readInts()
c = [0]+readInts()

ans = -1*float("inf")
for i in range(1,n+1):
	j = p[i]
	t = [0]
	al = set()
	while j not in al:
		t.append(t[-1]+c[j])
		al.add(j)
		j = p[j]
	if t[-1]<=0:
		ans = max(ans, max(t[1:k+1]))
	else:
		kuri =(k-1)//(len(t)-1)
		s = kuri*t[-1]
		re = k -kuri*(len(t)-1)
		ans = max(ans, max(s,s+max(t[:re+1])))

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

n = int(input())
data_input = []
dlList = []
for i in range(n):
    x = input().split()
    if x[0] == 'insert':
        dlList.insert(0,x[1])
    elif x[0] == 'delete':
        if x[1] in dlList:
            dlList.remove(x[1])
        else :
            pass
    elif x[0] == 'deleteFirst':
        dlList.pop(0)
    elif x[0] == 'deleteLast':
        dlList.pop()
    else:
        pass
print(' '.join(dlList))

### FIXED CODE ###

import sys
from collections import deque
input_lines = sys.stdin.readlines()

doublyLinkedList = deque()


for x in input_lines[1:]:
    oneLine = x.split()
    if 'insert' in oneLine[0]:
        doublyLinkedList.appendleft((int)(oneLine[1]))
    elif 'delete' == oneLine[0]:
        remove_value = (int)(oneLine[1])
        if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
    elif 'deleteFirst'in oneLine[0]:
        doublyLinkedList.popleft()
    elif 'deleteLast' in oneLine[0]:
        doublyLinkedList.pop()

print(*doublyLinkedList)
### BUGGY CODE ###

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

ans1 = 0 #偶数インデックスが正
for i in range(n):
    s1 = sum(a[:i+1])
    if i % 2 == 0:
        if s1 <= 0:
            x = abs(s1) + 1
            ans1 += x
            a[i] += x
        else:
            continue
    else:
        if s1 >= 0:
            x = abs(s1) + 1
            ans1 += x
            a[i] -= x
ans2 = 0 #偶数インデックスが負
for i in range(n):
    s2 = sum(a2[:i+1])
    if i % 2 == 1:
        if s2 <= 0:
            x = abs(s2) + 1
            ans2 += x
            a2[i] += x
        else:
            continue
    else:
        if s2 >= 0:
            x = abs(s2) + 1
            ans2 += x
            a2[i] -= x

print(min(ans1, ans2))

### FIXED CODE ###

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

def f(a, sgn):
    cnt = 0
    s = 0
    for i in range(n):
        s += a[i]
        sgn *= (-1) #判定する符号は交互に変わる
        if s * sgn <= 0: #sgn一致しなければその積は負
            x = s + sgn*(-1)
            s -= x
            cnt += abs(x)
        
    return cnt
ans = min(f(a, 1), f(a, -1))
print(ans)
### BUGGY CODE ###

def doritto(vrijednost):
    global kameni
    global memo
    if vrijednost == len(kameni) -2:
        if memo[vrijednost][vrijednost+1] == -1:
            memo[vrijednost][vrijednost+1] = abs(kameni[vrijednost] - kameni[vrijednost+1])
        return memo[vrijednost][vrijednost+1]
    elif vrijednost == len(kameni) -1:
        return 0
    else:
        if memo[vrijednost][vrijednost+1] == -1:
            if memo[vrijednost][vrijednost+2] == -1:
                memo[vrijednost][vrijednost+2] = doritto(vrijednost+2)
            memo[vrijednost][vrijednost+1] = doritto(vrijednost+1)
        elif memo[vrijednost][vrijednost+2] == -1:
            memo[vrijednost][vrijednost + 2] = doritto(vrijednost + 2)
        return min(abs(kameni[vrijednost] - kameni[vrijednost+1]) + memo[vrijednost][vrijednost+1],abs(kameni[vrijednost] - kameni[vrijednost+2]) + memo[vrijednost][vrijednost + 2])
N = int(input())
kameni = list(map(int,input().split()))
memo = []
for i in range(N):
    memo.append([])
    for j in range(N):
        memo[i].append(-1)
print(doritto(0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
def doritto(vrijednost):
    global kameni
    global memo
    if memo[vrijednost] != -1:
        return memo[vrijednost]
    if vrijednost == len(kameni) -2:
        return abs(kameni[vrijednost] - kameni[vrijednost+1])
    elif vrijednost == len(kameni) -1:
        return 0
    a = abs(kameni[vrijednost] - kameni[vrijednost+1]) + doritto(vrijednost+1)
    b = abs(kameni[vrijednost] - kameni[vrijednost+2]) + doritto(vrijednost+2)
    memo[vrijednost] = min(a,b)
    return memo[vrijednost]
N = int(input())
kameni = list(map(int,input().split()))
memo = []
for i in range(N):
    memo.append(-1)
print(doritto(0))
### BUGGY CODE ###

from collections import Counter

N = int(input())
A_list = [int(e) for e in input().split()]

#約数を列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

divisors_list = [make_divisors(n) for n in A_list]
all_divisors_list = []
for i in divisors_list:
  all_divisors_list += i
  
#print(all_divisors_list)
collected_adl = Counter(all_divisors_list)

ans = 1
for a in collected_adl.most_common():
  #print(a)
  if a[1] <= N-2:
    break
  elif a[0]>ans:
    ans=a[0]
    
print(ans)

### FIXED CODE ###

from collections import Counter
from functools import lru_cache

N = int(input())

#約数を列挙
@lru_cache(maxsize=1000)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

A_list = [make_divisors(int(e)) for e in input().split()]

all_divisors_list=[]

for i in A_list:
  all_divisors_list += i

collected_adl = Counter(all_divisors_list)

ans = 1
for a in collected_adl.most_common():
  if a[1] <= N-2:
    break
  elif a[0]>ans:
    ans=a[0]
    
print(ans)
### BUGGY CODE ###

from functools import reduce
from itertools import combinations
import fractions

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


def gcd(data):
    if len(data) < 2:
        return data[0]
    return reduce(lambda x, y: fractions.gcd(x, y), data)

result = max(gcd(x) for x in combinations(A, n-1))

print(result)


### FIXED CODE ###

# coding: utf-8

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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

L = [0]
R = [0]

for i in range(n):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[n-1-i]))
R.reverse()

result = []

for i in range(n):
    result.append(gcd(L[i], R[i+1])) 

print(max(result))
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())
    Query = [input().split() for _ in range(Q)] 

    for q in Query:
        if q[0] == '1':
            S[int(q[1])-1] = q[2]
        else:
            print(len(set(S[int(q[1])-1:int(q[2])])))

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():

    class BinaryIndexedTree():
        def __init__(self, n):
            self.n = n
            self.bit = [0]*(n+1)

        def add(self, item, pos):
            index = pos
            while index < self.n+1:
                self.bit[index] += item
                index += index & (-index)

        def sum(self, pos):
            ret = 0
            index = pos
            while index > 0:
                ret += self.bit[index]
                index -= index & -index
            return ret

    N = int(input())
    S = list(input())
    Q = int(input())
    Query = [input().split() for _ in range(Q)] 

    pos_bit_list = [BinaryIndexedTree(len(S)) for _ in range(26)]

    for i, c in enumerate(S):
        pos_bit_list[ord(c)-ord('a')].add(1, i+1)

    for q in Query:
        if q[0] == '1':
            pos_bit_list[ord(S[int(q[1])-1])-ord('a')].add(-1, int(q[1]))
            pos_bit_list[ord(q[2])-ord('a')].add(1, int(q[1]))
            S[int(q[1])-1] = q[2]
        else:
            print(len([p for p in pos_bit_list if p.sum(int(q[2])) - p.sum(int(q[1])-1) > 0]))

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

h, w = map(int, input().split())
mat = []
for i in range(h):
  a = list(map(int, input().split()))
  mat.append(a)
for i in range(h):
  b = list(map(int, input().split()))
  for j in range(w):
    mat[i][j] = abs(mat[i][j]-b[j])

dp = [[[False]*(80*(h+w)) for i in range(w)] for k in range(h)]
dp[0][0][mat[0][0]] = True
for y in range(h):
  for x in range(w):
      for k in range(80*(h+w)):
        if x > 0 and dp[y][x-1][k] or y > 0 and dp[y-1][x][k]:
          dp[y][x][k+mat[y][x]] = True
          dp[y][x][abs(k-mat[y][x])] = True

for k in range(80*(h+w)):
  if dp[h-1][w-1][k]:
    print(k)
    exit()


### FIXED CODE ###

h, w = map(int, input().split())
mat = []
for i in range(h):
  a = list(map(int, input().split()))
  mat.append(a)
for i in range(h):
  b = list(map(int, input().split()))
  for j in range(w):
    mat[i][j] = abs(mat[i][j]-b[j])
m = max(map(max, mat))
dp = [[0b0 for i in range(w)] for k in range(h)]
dp[0][0] |= 0b1 << mat[0][0]
for y in range(h):
  for x in range(w):
        if x > 0:
          dp[y][x] |= dp[y][x-1] << mat[y][x]
          dp[y][x] |= dp[y][x-1] >> mat[y][x]
          anded = dp[y][x-1] & int('1'*(mat[y][x]+1), 2)
          reverse = format(anded, "0"+str(mat[y][x]+1)+"b")[::-1]

          dp[y][x] |= int(reverse, 2)
        if y > 0:
          dp[y][x] |= dp[y-1][x] << mat[y][x]
          dp[y][x] |= dp[y-1][x] >> mat[y][x]
          anded = dp[y-1][x] & int('1'*(mat[y][x]+1), 2)
          reverse = format(anded, "0"+str(mat[y][x]+1)+"b")[::-1]

          dp[y][x] |= int(reverse, 2)
        #print(bin(dp[y][x]))

keta = 0
while dp[h-1][w-1] % 2 == 0:
  keta += 1
  dp[h-1][w-1] //= 2
print(keta)
### BUGGY CODE ###

K = int(input())
cnt = 0
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):

            cnt += gcd_list([i,j,k])
print(cnt)

### FIXED CODE ###

K = int(input())
cnt = 0
import math
from functools import reduce
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
 
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
 
            cnt += gcd_list([i,j,k])
print(cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
 
num_product, num_coupon = [int(s) for s in input().split()]
price_list = [int(s) for s in input().split()]

for i in range(num_coupon):
  price_list.sort()
  price_list.reverse()
  price_list[0] //= 2

sum = 0
for price in price_list:
  sum += price
  
print(sum)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq

num_product, num_coupon = [int(s) for s in input().split()]
price_list = []
for s in input().split():
  heapq.heappush(price_list, int(s)*-1)

for i in range(num_coupon):
  min = price_list[0]
  heapq.heapreplace(price_list, (min*-1//2)*-1)

sum = 0
for price in price_list:
  sum -= price

print(sum)
### BUGGY CODE ###

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


Ap = list(map(lambda x: x+1, A))
Am = list(map(lambda x: x-1, A))

ans = 0
for a in set(A):
    tmp = A.count(a) + Am.count(a) + Ap.count(a)
    ans = max(ans, tmp)

print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))

c = Counter(A)

ans = 0
for k in c.keys():
    tmp = c[k-1] + c[k] + c[k+1]
    ans = max(ans, tmp)

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

N, A, B = map(int, input().split())
ans = 0
while N > 0 :
    for b in range(A) :
        ans += 1
        N -= 1
        if N == 0 :
            break
    for r in range(B):
        N -= 1
        if N == 0 :
            break
print(ans)

### FIXED CODE ###

N, A, B = map(int, input().split())
ans1 = A * (N // (A+B)) 
ans2 = min((N % (A+B)), A)
print(ans1 + ans2)
### BUGGY CODE ###

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

def terasu(a):
    new_a = []
    for i in range(n):
        count = 1
        for j,l in enumerate(a):
            if l > 0 and i != j:
                if abs(j-i)<=l:
                    count+=1
        new_a.append(count)
    return(new_a)

for x in range(k):
    a = terasu(a)
print(" ".join([str(x) for x in a]))

### FIXED CODE ###

import math
import numpy as np

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


for _ in range(k):
    new_a = np.zeros(n+1,dtype=int)
    np.add.at(new_a, np.maximum(0,np.arange(0, n)-a), 1)
    np.add.at(new_a, np.minimum(n,np.arange(0, n)+a+1), -1)
    a = new_a.cumsum()[:-1]
    if np.all(a==n):
        break

print(" ".join([str(x) for x in a]))
### BUGGY CODE ###

from collections import deque
s = deque(input())
q = int(input())
work = deque()
workappendleft = work.appendleft
appendleft=s.appendleft
append=s.append
flag = False
for i in range(q):
    temp = input().split()
    if temp[0] == "1":
        flag = not flag
    else:
        if flag:
            for el in s:
                workappendleft(el)
            s.clear()
            for el in work:
                append(el)
            work.clear()
            flag = False
        if temp[1] == "1":
            appendleft(temp[2])
        else:
            append(temp[2])
if flag:
    for el in s:
        workappendleft(el)
    s.clear()
    for el in work:
        append(el)
print("".join(list(s)))


### FIXED CODE ###

from collections import deque
def main():
    s = deque(input())
    q = int(input())
    appendleft=s.appendleft
    append=s.append
    flag = False
    for i in range(q):
        temp = input().split()
        if temp[0] == "1":
            flag = not flag
        else:
            if temp[1] == "1":
                if flag:
                    append(temp[2])
                else:
                    appendleft(temp[2])
            else:
                if flag:
                    appendleft(temp[2])
                else:
                    append(temp[2])
    if flag:
        s.reverse()
    print("".join(list(s)))
if __name__=="__main__":
    main()
### BUGGY CODE ###

import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

H, W = MAP()
M = [input().rstrip() for _ in range(H)]
# for m in M:
# 	print(m)

O = []
for i in range(H):
	for j in range(W):
		if M[i][j] == '#': O.append([i, j])

# print(O)

ans = 0
for i in range(H):
	for j in range(W):
		if M[i][j] == '#': continue
		u = i
		d = H-i-1
		l = j
		r = W-j-1
		# print(u,d,l,r, " / i, j:", i,j)
		for o in O:
			oh, ow = o
			if oh==i:
				# 障害物が同じ行の右側にある場合
				if ow > j:
					r = min(r, ow-j-1)
				# 障害物が同じ行の左側にある場合
				else:
					l = min(l, j-ow-1)
			if ow==j:
				# 障害物が同じ列の上側にある場合
				if oh < i:
					u = min(u, i-oh-1)
				# 障害物が同じ列の下側にある場合
				else:
					d = min(d, oh-i-1)
		# print(u,d,l,r)
		ans = max(ans, sum([u, d, l, r])+1)
	
print(ans)

### FIXED CODE ###

import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	H, W = MAP()
	M = [input().rstrip() for _ in range(H)]

	DU = tuple([-1,1])
	LR = tuple([-1,1])
	memo = [[-1]*W for _ in range(H)]
	ans = 0
	for i in range(H):
		for j in range(W):
			if M[i][j] == '#': continue
			tmp = [0,0]
			
			skip = -1
			if memo[i-1][j] != -1:
				tmp[0] = memo[i-1][j][0]
				skip = 1
			if memo[i][j-1] != -1:
				tmp[1] = memo[i][j-1][1]
				skip = 5 if skip == 1 else 2
			
			if skip == 1 or skip == -1:
				lr = 0
				for move in LR:
					nw = j
					dw = move
					while True:
						nw += dw
						# print(i, j, nh, nw)
						if nw>W-1 or nw<0 or M[i][nw] == '#': break
						lr += 1
					tmp[1] = lr

			if skip == 2 or skip == -1:
				du = 0
				for move in DU:
					nh = i
					dh = move
					while True:
						nh += dh
						# print(i, j, nh, nw)
						if nh>H-1 or nh<0 or M[nh][j] == '#': break
						du += 1
					tmp[0] = du
			
			memo[i][j] = tuple(tmp)
			ans = max(ans, sum(tmp)+1)
		
	# for mem in memo:
	# 	print(mem)
	# for m in M:
	# 	print(m)
	print(ans)

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

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
n = int(input())
s = str(n)
l = len(s)

INF = float('inf')
dp = [[INF,INF] for _ in range(l+1)]
dp[0][0]=0
dp[0][1]=1
for i in range(l):
    num = int(s[i])
    dp0 = dp[i][0]
    dp1 = dp[i][1]
    dp[i+1][0] = min(dp0+num, dp1+min(10-num,num+1))
    dp[i+1][1] = min(dp0+num+1,dp1+10-num-1)

print(dp[-1][0])

### FIXED CODE ###

s = input()
l = len(s)

INF = float('inf')
dp = [[INF]*2 for _ in range(l+1)]
dp[0][0]=0
dp[0][1]=1
for i in range(l):
    num = int(s[i])
    dp0 = dp[i][0]
    dp1 = dp[i][1]
    dp[i+1][0] = min(dp0+num, dp1+min(10-num,num+1))
    dp[i+1][1] = min(dp0+num+1,dp1+10-num-1)

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

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_a

"""
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
input = stdin.readline


def main(args):
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    A.sort()
    B.sort()
    C.sort()

    lut_A = {a:bisect_right(B, a) for a in A}
    lut_B = {b:bisect_right(C, b) for b in B}

    ans = 0
    old_i = -1
    for a in A:
        i = lut_A[a]

        if i == old_i:
            ans += temp
            continue
        else:
            temp = 0
            for b in B[i:]:
                j = lut_B[b]
                temp += (N - j)
        ans += temp
        old_i = i

    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_a

"""
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
input = stdin.readline


def main(args):
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    A.sort()
    B.sort()
    C.sort()

    lut_A = {}
    lut_C = {}
    for b in B:
        i = bisect_left(A, b)
        lut_A[b] = i
        j = bisect_right(C, b)
        lut_C[b] = N - j


    ans = 0
    for b in B:
        i = lut_A[b]
        j = lut_C[b]
        ans += i * j

    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0
# for i in range(n):
#     count=0
#     for j in range(i+1):
#         if p[i]>p[j]:
#             break
#         else:
#             count+=1
#     if count==i+1:
#         ans+=1
# print(ans)

for i in range(n):
    l = p[:i+1]
    #print(min(l),p[i])
    if min(l)>=p[i]:
        ans+=1

print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0
ps=[]
p_min = p[0]
for i in p:
    if p_min>i:
        p_min=i
    
    if p_min>=i:
        ans+=1
print(ans)
### BUGGY CODE ###

import re
S = input()
l = len(S)
while True:
  if re.sub('01|10','',S) == S:
  	break
  else:
    S = re.sub('01|10','',S)
print(l-len(S))

### FIXED CODE ###

S = input()
print(min(S.count('0'),S.count('1'))*2)
### BUGGY CODE ###

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

cnt=0
for i in range(N):
    cnt= cnt + sum([(L[i:][x]+L[i])==x for x in range(N-i) if (L[i:][x]+L[i])<=x])
    
print(cnt)

### FIXED CODE ###

def main():
    N=int(input())
    L=list(map(int,input().split()))
    L_i,L_j=[],[]
    L_memo = [0]*N
    cnt=0
    for i, j in enumerate(L):
        if i+j<N:
            L_memo[i+j]+=1
        if i-j>0:
            cnt+=L_memo[i-j]        
    print(cnt)
main()
### BUGGY CODE ###

import sys

N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    m=A.index(max(A))
    A[m]=A[m]//2
print(sum(A))

### FIXED CODE ###

import heapq

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

for i in range(N):
    A[i]*=-1
#print(A)
heapq.heapify(A)
for i in range(M):
    temp=heapq.heappop(A)
#    print(temp)
    heapq.heappush(A,temp//2+temp%2)
    
print(-sum(A))
### BUGGY CODE ###

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    A=LIST()
    #flg=True
    Ave=[0]*(n-k+1)
    for i in range(n-k+1):
        Ave[i]=float(sum(A[i:i+k])/k)
    for i in range(n-k):
        if Ave[i+1]>Ave[i]:
            print('Yes')
        else:
            print('No')
        
    
    
if __name__ == '__main__':
    do()

### FIXED CODE ###

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    A=LIST()
    for i in range(n-k):
        #print(A[i],A[i+k])
        if A[i]<A[i+k]:
            print('Yes')
        else:
            print('No')
        
    
    
if __name__ == '__main__':
    do()
### BUGGY CODE ###

n = int(input())
s = list(map(int,input().split()))
count = 0
while len(set([i % 2 for i in s])) == 1:
    count += 1
    s = [i / 2 for i in s]
print(count)

### FIXED CODE ###

input()
s=list(map(int,input().split()))
bl = 0
for i in s:
  bl |= i
print(len(bin(bl&-bl))-3)
### BUGGY CODE ###

import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

from bisect import bisect_left, bisect_right  # 二分探索

def main():
    N = i2n()
    A = ii2nn(N)
    B = [-1]
    for a in A:
        t = bisect_left(B, a)
        if t > 0:
            B[t-1] = a
        else:
            B = [a] + B
    print(len(B))

main()


### FIXED CODE ###

import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

from bisect import bisect_left, bisect_right  # 二分探索
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー

def main():
    N = i2n()
    A = ii2nn(N)
    B = [1]
    for a in A:
        t = bisect_right(B, -a)
        if t < len(B):
            B[t] = -a
        else:
            B.append(-a)
    print(len(B))

main()