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

N = int(input())
A = list(map(int,input().split()))
if A == sorted(A) and len(A) == len(set(A)):
  print(1)
  exit(0)

def check(X):
  idx = [0]
  ltr = [0]
  for a in A:
    if idx[-1] < a:
      idx.append(a)
      ltr.append(0)
    else:
      while True:
        while idx[-1] > a:
          idx.pop()
          ltr.pop()
        if idx[-1] != a:
          idx.append(a)
          ltr.append(0)
        if idx[-1] == 0:
          return False
        ltr[-1] += 1
        if ltr[-1] < X:
          break
        a = idx[-1] - 1
        idx.pop()
        ltr.pop()
  return ltr[0] == 0

t = [0, N]
while t[1] - t[0] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(t[1])

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
if A == sorted(A) and len(A) == len(set(A)):
  print(1)
  exit(0)

def check(X):
  idx = [0]
  ltr = [0]
  for a in A:
    if idx[-1] < a:
      idx.append(a)
      ltr.append(0)
    else:
      while True:
        while idx[-1] > a:
          idx.pop()
          ltr.pop()
        if idx[-1] != a:
          idx.append(a)
          ltr.append(0)
        if idx[-1] == 0:
          return False
        ltr[-1] += 1
        if ltr[-1] < X:
          break
        a = idx[-1] - 1
        idx.pop()
        ltr.pop()
  return ltr[0] == 0

t = [1, N]
while t[1] - t[0] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(t[1])
### BUGGY CODE ###

S = input()

for i in range(100000):
    S = S.replace("ST","")

print(len(S))


### FIXED CODE ###

X = input()
N = len(X)
S = 0
ans = 0
for i in range(N):
    if X[i] == 'S':
        S += 1
    elif S > 0:
        S -= 1
        ans += 2
        
print(N - ans)
### BUGGY CODE ###

import queue
def cal():
    h, w = map(int, input().split())
    a = [list(input()) for _ in range(h)]
    q = queue.Queue()
    INF = float('inf')
    counts = [[INF]*w for _ in range(h)]
    
    for i in range(w):
        for j in range(h):
            if a[j][i] == '#':
                q.put([i, j])
                counts[j][i] = 0

    while not q.empty():
        x, y = q.get()
        for i, j in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            x0 = x+j
            y0 = y+i
            if 0 <= x0 < w and 0 <= y0 < h:
                if counts[y][x]+1 < counts[y0][x0] and a[y0][x0] == '.':
                    a[y0][x0] = '#'
                    counts[y0][x0] = counts[y][x]+1
                    q.put([x0, y0])
    ans = 0
    for i in counts:
        ans = max(ans, max(i))
    print(ans)

cal()


### FIXED CODE ###

from collections import deque

def cal():
    h, w = map(int, input().split())
    q = deque()
    counts = [[True for _ in range(w+2)]]+[[True]+[False]*w+[True] for _ in range(h)]+[[True for _ in range(w+2)]]
    for i in range(h):
        a = input()
        for j in range(w):
            if a[j] == '#':
                q.append([i+1, j+1, 0])
                counts[i+1][j+1] = True

    while q:
        x, y, z = q.popleft()    
        if not counts[x+1][y]:
            counts[x+1][y] = True
            q.append([x+1, y, z+1])
        if not counts[x-1][y]:
            counts[x-1][y] = True
            q.append([x-1, y, z+1])
        if not counts[x][y+1]:
            counts[x][y+1] = True
            q.append([x, y+1, z+1])
        if not counts[x][y-1]:
            counts[x][y-1] = True
            q.append([x, y-1, z+1])
    print(z)
    

cal()
### BUGGY CODE ###

A = [int(i) for i in input().split()]

prime_num = [[],[]]

prime_num[0].append(1)
prime_num[1].append(1)

for i in range(2):
    a = 2
    n = A[i]
    while A[i] >= a:
        if n%a == 0:
            prime_num[i].append(a)
            n /= a
        else:
            a+=1

print(len(set(prime_num[0])&set(prime_num[1])))


### FIXED CODE ###

A = [int(i) for i in input().split()]

prime_num = [[],[]]

prime_num[0].append(1)
prime_num[1].append(1)

for i in range(2):
    a = 2
    n = A[i]
    while A[i] >= a*a:
        if n%a == 0:
            prime_num[i].append(a)
            n /= a
        else:
            a+=1
    prime_num[i].append(n)
    

#print(prime_num)
print(len(set(prime_num[0])&set(prime_num[1])))
### BUGGY CODE ###

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

# 2 boat
boat = 2
ab = []
for i in range(M):
    a,b = input().split()
    a = int(a)
    b = int(b)
    ab.append((a,b))
import numpy as np
ab = np.array(ab)
ok = "IMPOSSIBLE"
for a1 in ab[ab.T[0]==1]:
    # 1 to target N-> ok
    for abbb in ab[ab.T[0]==a1[1]]:
        if abbb[1] == N:
            ok = "POSSIBLE"
            break
print(ok)

### FIXED CODE ###

import numpy as np
N, M = input().split()
N = int(N)
M = int(M)

# 2 boat
boat = 2
ab = np.zeros(M)
ab1 = []
abN = []
ok = "IMPOSSIBLE"
for i in range(M):
    a,b = input().split()
    a = int(a)
    b = int(b)
    if a == 1:
        ab1.append(b)
    elif b == N:
        abN.append(a)
if len(set(abN) & set(ab1))>=1:
    ok = "POSSIBLE"
print(ok)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

def dfs(v, p, tree, ans):
    for u in tree[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v, tree, ans)

def main():
    N, Q = map(int, input().split())
    tree = [[] for _ in range(N)]

    for i in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)

    ans = [0] * N
    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    dfs(0, -1, tree, ans)

    print(*ans)

main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(v, p, tree, ans):
    for u in tree[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v, tree, ans)

def main():
    N, Q = map(int, input().split())
    tree = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    ans = [0] * N
    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    dfs(0, -1, tree, ans)

    print(*ans)

main()
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    X, Y = [], []
    for _ in range(n):
        x, y = map(int, input().split())
        X.append(x)
        Y.append(y)
    X_s = sorted(X)
    Y_s = sorted(Y)

    res = f_inf
    for x1 in range(n):
        for x2 in range(x1 + 1, n):
            for y1 in range(n):
                for y2 in range(y1 + 1, n):
                    lx, rx = X_s[x1], X_s[x2]
                    by, uy = Y_s[y1], Y_s[y2]
                    cnt = 0
                    for i in range(n):
                        if lx <= X[i] <= rx and by <= Y[i] <= uy:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, (rx - lx) * (uy - by))
    print(res)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    X, Y = [], []
    for _ in range(n):
        x, y = map(int, input().split())
        X.append(x)
        Y.append(y)
    X_s = sorted(X)
    Y_s = sorted(Y)
    f_inf = float("inf")
    res = f_inf

    for x1 in range(n):
        for x2 in range(x1 + 1, n):
            for y1 in range(n):
                for y2 in range(y1 + 1, n):
                    lx, rx = X_s[x1], X_s[x2]
                    by, uy = Y_s[y1], Y_s[y2]
                    cnt = 0
                    for i in range(n):
                        if lx <= X[i] <= rx and by <= Y[i] <= uy:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, abs(rx - lx) * abs(uy - by))
    print(res)


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

n=int(input())
S=input()
dictR=[]
dictG=[]
dictB=[]
r=0
g=0
b=0
r=S.count("R")
g=S.count("G")
b=S.count("B")
sum=r*g*b
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if k-j==j-i and(S[i]!=S[j] and S[j]!=S[k] and S[i]!=S[k]):
                sum-=1



print(sum)

### FIXED CODE ###

n=int(input())
S=input()
R={}
G={}
B={}
r=0
g=0
b=0
for i in range(n):
    if S[i] == 'R':
        R[i] = None
    elif S[i] == 'G':
        G[i] = None
    else:
        B[i] = None
cnt=len(R)*len(G)*len(B)
for b in B:
    for g in G:
        if (b+g)/2 in R:
            cnt-=1
for b in B:
    for r in R:
        if (b+r)/2 in G:
            cnt-=1
for r in R:
    for g in G:
        if (r+g)/2 in B:
            cnt-=1
print(cnt)
### BUGGY CODE ###

from collections import Counter

N, M = map(int, input().split())
keys = []
for i in range(M):
    a, b = map(int, input().split())
    keys.append((a, list(map(int, input().split()))))
C = Counter()
for i in range(1 << N):
    C[format(i, "012b")[::-1]] = 10**9
C["000000000000"] = 0
for a, b in keys:
    for i in range(1 << N):
        now_status = format(i, "012b")[::-1]
        score = C[now_status] + a

        ex_status = list(now_status)
        for j in b:
            ex_status[j-1] = "1"
        now_status = "".join(ex_status)

        if C[now_status] > score:
            C[now_status] = score

if C["1"*N+"0"*(12-N)] == 10**9:
    print(-1)
else:
    print(C["1"*N+"0"*(12-N)])



### FIXED CODE ###


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

C = [float('inf')] * (1 << N)
C[0] = 0
key_v = [float('inf')] * (1 << N)
for j in range(M):
    a, b = map(int, input().split())
    box = list(map(int, input().split()))
    ex_status = 0
    for j in box:
        ex_status += 1 << (j-1)
    key_v[ex_status] = min(a, key_v[ex_status])

for key, val in enumerate(key_v):
    if val == float('inf'):
        continue
    for i in range(1 << N):
        now_status = i
        score = C[now_status] + val
        if score == float("inf"):
            continue

        now_status = i | key

        if C[now_status] > score:
            C[now_status] = score

if C[-1] == float("inf"):
    print(-1)
else:
    print(C[-1])
### BUGGY CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]

for b,c in bc:
  a += [c]*b  
  
print(sum(sorted(a,reverse=True)[:n]))

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]

bc = sorted(bc,key=lambda x:(x[1]),reverse=True)
count=0
for b,c in bc:
  count += b
  a.extend([c]*b)
  if count >= n:
    break
    
print(sum(sorted(a,reverse=True)[:n]))
### BUGGY CODE ###

mod = 10**9+7
S = input()
Q=0
DP=[[0]*3 for i in range(len(S))]#DP[x][y] x+1文字目までの
#y=0,1,2,3 = A,AB,ABC
if S[0] == "A" or S[0]=="?":
    DP[0] = [1,0,0]
    if S[0]=="?":
        Q=1
else:
    DP[0] = [0,0,0]
for i,s in enumerate(S):
    if i==0:continue
    a,b,c = DP[i-1]
    if s=="A":
        DP[i]=[(a+3**Q)%mod,b,c]
    elif s=="B":
        DP[i]=[a,(a+b)%mod,c]
    elif s=="C":
        DP[i]=[a,b,(b+c)%mod]
    else:
        DP[i]=[(3**Q+3*a)%mod,(a+3*b)%mod,(b+3*c)%mod]
        Q+=1
print(DP[len(S)-1][2]%mod)

### FIXED CODE ###

mod = 10**9+7
S = list(input())
Thankyou = 1
DP=[]
#DP[x][y] x+1文字目までを見たときの、
#y=0,1,2 : A,AB,ABCの登場回数
if S[0] == "A" or S[0]=="?":
    DP.append([1,0,0])
    if S[0]=="?":
        Thankyou = 3
else:
    DP.append([0,0,0])
for i,s in enumerate(S):

    if i==0:continue
    a,b,c = DP[i-1]
    if s=="A":
        DP.append([(a+Thankyou)%mod,b,c])
    elif s=="B":
        DP.append([a,(a+b)%mod,c])
    elif s=="C":
        DP.append([a,b,(b+c)%mod])
    else:
        DP.append([(Thankyou+3*a)%mod,(a+3*b)%mod,(b+3*c)%mod])
        Thankyou *= 3
        Thankyou %= mod
print(DP[len(S)-1][2]%mod)
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<3:
  print(abs(h[0]-h[1]))
  exit()
dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
for i in range(1,n):
  dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(dp[-1])


### FIXED CODE ###

n,k=map(int,input().split())
import numpy as np
h=np.array(input().split(),np.int64)
if n<3:
  print(abs(h[0]-h[1]))
  exit()
dp=np.zeros(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
  j=max(0,i-k)
  dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
  #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))
### BUGGY CODE ###

n = int(input())
dat = list(map(int, input().split()))
buf = []
for i in range(n):
    buf.append(i - dat[i])
#print(buf)
res = 0
for i in range(n):
    x = i + dat[i]
    for j in range(i+1, n):
        if x == buf[j]:
            res += 1
print(res)



### FIXED CODE ###

import collections
import bisect
n = int(input())
cnt = collections.defaultdict(list)
dat = list(map(int, input().split()))
buf = []
for i in range(n):
    cnt[i - dat[i]].append(i)
#print(buf)
res = 0
for i in range(n):
    x = i + dat[i]
    if x in cnt:
        res += len(cnt[x]) - bisect.bisect_left(cnt[x], x)
print(res)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

def match(a,b):
    return a == '?' or b== '?' or a == b


def solve(a, b, c):
    a = list(a)
    b = list(b)
    c = list(c)
    ab = [False] * 100000
    ac = [False] * 100000
    bc = [False] * 100000
    for i in range(len(a)):
        for j in range(len(b)):
            if not match(a[i],b[j]):
                ab[i-j+50000] = True
    for i in range(len(b)):
        for j in range(len(c)):
            if not match(b[i],c[j]):
                bc[i-j+50000] = True
    for i in range(len(a)):
        for j in range(len(c)):
            if not match(a[i],c[j]):
                ac[i-j+50000] = True
    M = max(len(a),len(b),len(c))
    ans = M*3
    for i in range(-M*2,M*2+1):
        for j in range(-M*2,M+2+1):
            if not ab[i + 50000] and not ac[j + 50000] and not bc[j-i + 50000]:
                L = min(i,j,0)
                R = max(len(a),len(b)+i,len(c)+j)
                ans = min(ans,R-L)
    print(ans)
    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()
    a = next(tokens)  # type: str
    b = next(tokens)  # type: str
    c = next(tokens)  # type: str
    solve(a, b, c)

if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys

def match(a,b):
    return a == '?' or b== '?' or a == b


def solve(a, b, c):
    a = list(a)
    b = list(b)
    c = list(c)
    ab = [False] * 100000
    ac = [False] * 100000
    bc = [False] * 100000
    for i in range(len(a)):
        for j in range(len(b)):
            if not match(a[i],b[j]):
                ab[i-j+50000] = True
    for i in range(len(b)):
        for j in range(len(c)):
            if not match(b[i],c[j]):
                bc[i-j+50000] = True
    for i in range(len(a)):
        for j in range(len(c)):
            if not match(a[i],c[j]):
                ac[i-j+50000] = True
    M = max(len(a),len(b),len(c))
    ans = M*3
    for i in range(-M*2,M*2+1):
        for j in range(-M*2,M*2+1):
            if not ab[i + 50000] and not ac[j + 50000] and not bc[j-i + 50000]:
                L = min(i,j,0)
                R = max(len(a),len(b)+i,len(c)+j)
                ans = min(ans,R-L)
    print(ans)
    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()
    a = next(tokens)  # type: str
    b = next(tokens)  # type: str
    c = next(tokens)  # type: str
    solve(a, b, c)

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

import numpy as np
a = int(raw_input())
Ali = np.array( map(int,raw_input().split()))
Bli = np.array(map(int,raw_input().split()))
Cli = np.array(map(int,raw_input().split()))
co=0
for A in Ali:
    for B in Bli:
        if A < B:
            for C in Cli:
                if B < C:
                    co +=1 
print(co)


### FIXED CODE ###

import bisect
N = int(input())
Alist = list(map(int,input().split()))
Blist = list(map(int,input().split()))
Clist = list(map(int,input().split()))
Alist.sort()
Clist.sort()
retnum = 0 
for i in Blist:
    Anum = bisect.bisect_left(Alist,i)
    Cnum =  N - bisect.bisect_right(Clist,i)
    retnum +=(Anum * Cnum)
print(retnum)
### BUGGY CODE ###

r,g,b,n = map(int,input().split())
c = 0
for i in range(n//r+1):
  for j in range(n//g+1):
    for k in range(n//b+1):
      if i*r + j*g + k*b == n:
        c += 1
print(c)

### FIXED CODE ###

r,g,b,n = map(int,input().split())
c = 0
for i in range(n//r+1):
  for j in range((n-i*r)//g+1):
    k = (n-i*r-j*g)
    if k%b == 0 and k >= 0:
      c += 1
print(c)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush

def small_dp(N,X):
    if len(X) == 0:
        return N
    if len(X) == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if len(X) == 2:
        return max(X[1][1]*i + small_dp(N-i*X[1][0], X[:-1]) for i in range(N//X[1][0]+1))
    if len(X) == 3:
        return max(X[-1][1]*i + small_dp(N-i*X[-1][0], X[:-1]) for i in range(N//X[-1][0]+1))
        
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    for C in ((A,B), (B,A)):
        *X, = sorted(filter(lambda c: int.__sub__(*c)<0, zip(*C)), reverse=True)
        N = small_dp(N, X)
    res = N

    return str(res)

if __name__ == '__main__':
    print(solve())

### FIXED CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush

def small_dp(N,A,B):
    *X, = filter(lambda c: int.__sub__(*c)<0, zip(A,B))
    k = len(X)
    if k == 0:
        return N
    if k == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if k == 2:
        c = 0
        for i in range(N//X[0][0]+1):
            j = (N-i*X[0][0])//X[1][0]
            c = max(X[0][1]*i + X[1][1]*j + (N-i*X[0][0])%X[1][0], c)
        return c
    if k == 3:
        if (N//X[1][0]+1)*(N//X[0][0]+1) <= 10**6 :
            return max(X[0][1]*i + max(X[1][1]*j + X[2][1]*((N-i*X[0][0]-j*X[1][0])//X[2][0]) + ((N-i*X[0][0]-j*X[1][0])%X[2][0]) for j in range((N-i*X[0][0])//X[1][0]+1)) for i in range(N//X[0][0]+1))
        else:
            import numpy as np
            dp = np.zeros(N+1, dtype=int)
            for w in range(1,N+1):
                dp[w] = max(dp[w-X[i][0]]+X[i][1] if w>=X[i][0] else w for i in range(k))
            N = dp[-1]
            return N

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    res = small_dp(small_dp(N, A, B), B, A)

    return str(res)

if __name__ == '__main__':
    print(solve())
### BUGGY CODE ###

n = int(input())

for k in range(n):
    a = input()
    b = input()
    len_a, len_b = len(a), len(b)
    table = [[0] * (len_b +1) for i in range(len_a + 1)]
    
    for i in range(len_a):
        for j in range(len_b):
            if a[i] == b[j]:
                table[i+1][j+1] = table[i][j] + 1
            else:
                table[i+1][j+1] = max(table[i][j+1],table[i+1][j])
    print(table[len_a][len_b])

### FIXED CODE ###

def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])
 
q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep = "\n")
### BUGGY CODE ###

import numpy as np
N, M, V, P = map(int, input().strip().split())
A = sorted(list(map(int, input().strip().split())),reverse=True)
ans=0

for i in range(N):
    thre=A[i]+M
    if thre < A[P-1]:
        continue

    remain=V-(P-1)-(N-i)
    if remain <=0:
        ans+=1
    elif sum(A[P-1:i])+M*remain <= thre*(i-1-(P-1)+1):
        ans+=1
print(ans)

### FIXED CODE ###

n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = p
c = [0]
cnt = 0
for i in range(n):
  # 累積和
  cnt += a[i]
  c.append(cnt)
  
from bisect import bisect_right
for i in range(p,n):
  h = a[i]+m
  free = v - (p-1) - (n-i)
  if free >= 0 and h >= a[p-1]:
    d = h * (i-p+1) - (c[i]-c[p-1]) # 余裕
    if d >= free*m:
      ans += 1
  else:
    if h >= a[p-1]:
      ans += 1
print(ans)
### BUGGY CODE ###

a = 0
listA = []
N, M = map(int, input().split())
for i in range(N):
    A, B = map(int, input().split())
    for i in range(B):
        listA.append(A)
listA.sort()
for i in range(M):
    a += listA[i]
print(a)

### FIXED CODE ###

a = 0
l = []
f = 0
N, M = map(int, input().split())
for i in range(N):
    A, B = map(int, input().split())
    l.append([A, B])
l_sorted = sorted(l, key=lambda x: x[0])
while True:
    if l_sorted[f][1] < M:
        a += l_sorted[f][1] * l_sorted[f][0]
        M -= l_sorted[f][1]
        f += 1
    else:
        a += M * l_sorted[f][0]
        break
print(a)
### BUGGY CODE ###

n = int(input().strip())

ans = 1

for i in range(1,n+1):
    ans *= i
    
print(ans % (10**9 +7))

### FIXED CODE ###

n = int(input().strip())

ans = 1

for i in range(1,n+1):
    ans *= i
    ans = ans % (10**9 +7)
    
print(ans)
### BUGGY CODE ###

import sys
n=int(raw_input())
ans=[]
while n:
    n-=1
    s=sys.stdin.readline().rstrip().split(' ')
    if s[0][0]=='i':
        ans.insert(0,s[1])
    elif s[0][-3]=='r':
        ans.pop(0)
    elif s[0][-3]=='a':
        ans.pop()
    else:
        for i,j in enumerate(ans):
            if j==s[1]:
                ans.pop(i)
                break
sys.stdout.write(' '.join(ans))
print

### FIXED CODE ###

import sys
import collections
n=int(raw_input())
ans=collections.deque()
while n:
    n-=1
    s=sys.stdin.readline().rstrip().split(' ')
    if s[0][0]=='i':
        ans.appendleft(s[1])
    elif s[0][-3]=='r':
        ans.popleft()
    elif s[0][-3]=='a':
        ans.pop()
    else:
        try:
            ans.remove(s[1])
        except:
            pass
sys.stdout.write(' '.join(ans))
print
### BUGGY CODE ###

from collections import Counter
N=int(input())
count=0
s=[0 for _ in range(N)]
for i in range(N):
    s[i]=input()
n=['a' for t in range(N) for i in range(t+1,N) if Counter(s[t])==Counter(s[i])]
print(len(n))

### FIXED CODE ###

N=int(input())
S=[''.join(sorted((input()))) for i in range(N)]
P={}
for i in range(N):
    if S[i] in P:
        P[S[i]]+=1
    else:
        P[S[i]]=0
for i in P.keys():
    if P[i]>=2:
        P[i]=P[i]*(P[i]+1)/2
print(int(sum(P.values())))
### BUGGY CODE ###

#3

n, k = map(lambda x: int(x), input().split())
list_a =  list(map(lambda x: int(x), input().split()))
list_score = []

for i in range(n):
    if i < k - 1:
        continue
#     print(i-k, i+1)
    list_score.append(sum(list_a[i-k+1:i+1]))
# print(list_score)

score_before = list_score[0]
for score in list_score[1:]:
    if score_before < score:
        print('Yes')
        score_before = score
        continue
    print('No')
    score_before = score

### FIXED CODE ###

n, k = map(lambda x: int(x), input().split())
list_a =  list(map(lambda x: int(x), input().split()))

band_score = 1
    
for i, score in enumerate(list_a[k:]):
    if list_a[i] < score:
        print('Yes')
        continue
    print('No')