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

S=input()
T=input()
s=len(S)
t=len(T)
dp=[['' for i in range(t+1)] for j in range(s+1)]
for i in range(s):
    for j in range(t):
        if S[i]==T[j]:
            dp[i+1][j+1]=dp[i][j]+S[i]
        else:
            dp[i+1][j+1]=dp[i+1][j]
            if len(dp[i][j+1])>len(dp[i+1][j]):
                dp[i+1][j+1]=dp[i][j+1]
print(dp[s][t])


### FIXED CODE ###

S=input()
T=input()
dp=[[0 for j in range(len(T)+1)] for i in range(len(S)+1)]
for i in range(len(S)):
    for j in range(len(T)):
        if S[i]==T[j]:
            dp[i+1][j+1]=dp[i][j]+1
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j])
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1])
i=len(S)
j=len(T)
ans=""
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans=S[i-1]+ans
        i-=1
        j-=1
print(ans)
### BUGGY CODE ###

A,B = list(map(int,input().split()))
C = input()
for i in range(B):
    M,R = list(map(int,input().split()))
    print(C[M-1:R].count("AC"))

### FIXED CODE ###

N,M = list(map(int,input().split()))
l_n = input()
l_a = [0] * (N+1)
for i in range(N):
    l_a[i+1] = l_a[i] + (1 if l_n[i:i+2] == 'AC' else 0)
for i in range(M):
    l,r = map(int,input().split())
    print(l_a[r-1]-l_a[l-1])
### BUGGY CODE ###


def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    # 最大値は多くともM/N
    limit = int(M / N)
    max = 1
    for i in range(2, limit+1):
        # Mがiで割り切れる、かつ割ったときの値がN以上なら可能なはず
        if M % i == 0 and M / i >= N:
            max = i
    print(max)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    max = 1
    for i in get_divisor_list(M):
        # Mがiで割り切れる、かつ割ったときの値がN以上なら可能なはず
        if M % i == 0 and M / i >= N:
            max = i
    print(max)

# 約数のリストを取得
def get_divisor_list(num):
    div_list = [1, num]
    limit = int(math.sqrt(num))
    for i in range(2, limit+1):
        if num % i == 0:
            div_list.append(i)
            div_list.append(int(num / i))
    return sorted(div_list)

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

k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        for z in range(y, k + 1):
            if z > s:
                break
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)


### FIXED CODE ###

k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        z = s - x - y
        if y <= z and z <= k:
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)
### BUGGY CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]

B = []
import bisect
for i, a in enumerate(A):
    if len(B) == 0:
        B.append(a)
    else:
        j = bisect.bisect_left(B, a)
        if j == 0:
            B = [a]+B
        elif j == len(B):
            B[-1] = a
        else:
            B[j-1] = a
print(len(B))

### FIXED CODE ###

import bisect
from collections import deque

n = int(input())
l = deque([int(input())])

for i in range(1, n):
  a = int(input())
  p = bisect.bisect_left(l,a)
  if p == 0:
    l.appendleft(a)
  else:
    l[p-1] = a

print(len(l))
### BUGGY CODE ###

INF = 10 ** 12

N = int(input())
X = [0] * N
Y = [0] * N
P = [0] * N
for i in range(N):
    X[i], Y[i], P[i] = map(int,input().split())

score_X = []

for i in range(2 ** N):
    x = []
    I = i
    for j in range(N):
        i = I
        score = abs(X[j]) * P[j]
        for k in range(N):
            if i & 1:
                score = min(score, abs(X[j] - X[k]) * P[j])
            i >>= 1
        x.append(score)
    score_X.append(x)

score_Y = []

for i in range(2 ** N):
    y = []
    I = i
    for j in range(N):
        i = I
        score = abs(Y[j]) * P[j]
        for k in range(N):
            if i & 1:
                score = min(score, abs(Y[j] - Y[k]) * P[j])
            i >>= 1
        y.append(score)
    score_Y.append(y)

ans = [INF] * (N + 1)

for i in range(3 ** N):
    cnt = N
    index_X = 0
    index_Y = 0
    for j in range(N):
        index_X <<= 1
        index_Y <<= 1
        if i % 3 == 1:
            index_X += 1
        elif i % 3 == 2:
            index_Y += 1
        else:
            cnt -= 1
        i //= 3
    
    score = 0
    for j in range(N):
        score += min(score_X[index_X][j], score_Y[index_Y][j])
    
    ans[cnt] = min(ans[cnt], score)

for i in range(N + 1):
    print(ans[i])

### FIXED CODE ###

INF = 10 ** 12

N = int(input())
X = [0] * N
Y = [0] * N
P = [0] * N
for i in range(N):
    X[i], Y[i], P[i] = map(int,input().split())

score_X = []

for i in range(2 ** N):
    x = []
    I = i
    for j in range(N):
        i = I
        score = abs(X[j]) * P[j]
        for k in range(N):
            if i & 1:
                score = min(score, abs(X[j] - X[k]) * P[j])
            i >>= 1
        x.append(score)
    score_X.append(x)

score_Y = []

for i in range(2 ** N):
    y = []
    I = i
    for j in range(N):
        i = I
        score = abs(Y[j]) * P[j]
        for k in range(N):
            if i & 1:
                score = min(score, abs(Y[j] - Y[k]) * P[j])
            i >>= 1
        y.append(score)
    score_Y.append(y)

ans = [INF] * (N + 1)

for i in range(2 ** N):
    cnt = 0
    for j in range(N):
        if (i >> j) & 1:
            cnt += 1
    
    j = i
    
    while True:
        score = 0
        for k in range(N):
            if not (i >> k) & 1:
                score += min(score_X[j][k], score_Y[i - j][k])
        ans[cnt] = min(ans[cnt], score)
        if j == 0:
            break
        j = (j - 1) & i

for i in range(N + 1):
    print(ans[i])
### BUGGY CODE ###

import copy
import numpy as np

def f(X):
    count = 0
    while np.sum(X)>0:
        X = popcount(X)
        count += 1
    return count

def popcount(X):
    a = np.sum(X)
    x_10 = 0
    for i in range(len(X)):
        x_10 += X[-(i+1)]*2**i
    n = x_10 % a
    k=2
    bi=''
    while n!=0:
        bi+=str(n%abs(k))
        if k<0:n=-(-n//k)
        else:n=n//k
    bi[::-1]
    return list(map(int,list(bi[::-1])))


N = int(input())
X = list(map(int,list(input())))

for i in range(N):
    X_i = copy.copy(X)
    if X_i[i] == 0:
        X_i[i] =1
    else:
        X_i[i] = 0
    print(f(X_i))

### FIXED CODE ###

N = int(input())
X = input()

pop_X = sum(map(int,list(X)))
X_10 = int('0b'+X,2)

r_0 = X_10%(pop_X+1)
diff_0 = 1%(pop_X+1)

zero_flag = False
if pop_X == 1:
    zero_flag = True
else:
    r_1 = X_10%(pop_X-1)
    diff_1 = 1%(pop_X-1)

answer = []


for i in range(N)[::-1]:
    if X[i]=='0':
        r = (r_0+diff_0)%(pop_X+1)
    else:
        if zero_flag:
            answer.append(0)
            diff_0 = (diff_0*2)%(pop_X+1)
            continue
        else:
            r = (r_1-diff_1)%(pop_X-1)
    count = 1
    while True:
        if r == 0:
            break
        pop = sum(map(int,list(bin(r)[2:])))
        r = r % pop
        count += 1
        
    answer.append(count)
    diff_0 = (diff_0*2)%(pop_X+1)
    if zero_flag:
        continue
    diff_1 = (diff_1*2)%(pop_X-1)

for i in answer[::-1]:
    print(i)
### BUGGY CODE ###

import bisect
import sys
input = sys.stdin.readline

Q = int(input())

a = []
a_new = []
b_sum = 0
minima = 0
argmin = 10**10
shift = 0
for i in range(Q):
    ipt = list(map(int, input().split()))
    if len(ipt) == 3:
        if len(a) == 0:
            a.append(ipt[1])
        else:
            a.insert(bisect.bisect_left(a, ipt[1]), ipt[1])
        argmin_new = a[(len(a) - 1) // 2]
        if argmin == 10**10:
            argmin = argmin_new
        minima += abs(ipt[1] - argmin_new) + (abs(argmin - argmin_new)) * ((len(a) + 1) % 2)
        b_sum += ipt[2]
        argmin = argmin_new
    else:
        print(argmin, minima + b_sum)

### FIXED CODE ###

def main():
    import sys
    from heapq import heappop, heappush, heappushpop
    input = sys.stdin.readline

    Q = int(input())
    R = [10**9+1]
    L = [10**9+1]
    Rsum = 0
    Lsum = 0
    NL = 0
    NR = 0
    B = 0
    for _ in range(Q):
        query = input().rstrip('\n')
        if query == '2':
            Lmax = -L[0]
            print(Lmax, Lmax * NL - Lsum + Rsum - Lmax * NR + B)
        else:
            _, a, b = query.split()
            a = int(a)
            b = int(b)
            B += b
            if NL != NR:
                Lmax = -L[0]
                Rmin = R[0]
                if a >= Lmax:
                    heappush(R, a)
                    Rsum += a
                    NR += 1
                else:
                    newR = -heappushpop(L, -a)
                    heappush(R, newR)
                    Rsum += newR
                    Lsum += a - newR
                    NR += 1
                    Lmax = -L[0]
            else:
                Rmin = R[0]
                if a <= Rmin:
                    heappush(L, -a)
                    Lsum += a
                    NL += 1
                else:
                    newL = heappushpop(R, a)
                    heappush(L, -newL)
                    Lsum += newL
                    Rsum += a - newL
                    NL += 1


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

k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y==s-z:
                cnt += 1
                break
print(cnt)

### FIXED CODE ###

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

N = int(input())
count = 0


if N % 2 == 0:
    n = N
    sho = n // 10
    #print(sho)
    for i in range(1, sho+1):
        k = i * 10
        #print(k)
        while(k % 5 == 0 and k > 0):
            #print(k)
            k = k // 5
            count += 1

print(count)

### FIXED CODE ###

N = int(input())
count = 0
k = 5

if N % 2 == 0:
    n = (N // 2 // 5) * 5
    while(n >= k):
        count += n // k
        k *= 5

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

N = int(input())
A = list(map(int,input().split()))
S = 1
ans=0

for i in range(N):
  S = S*A[i]
  
while S%2 == 0:
  ans += 1
  S = S//2
  
print(ans)

### FIXED CODE ###

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

for i in range(N):
  while A[i]%2 == 0:
    ans += 1
    A[i] = A[i]//2
    
print(ans)
### BUGGY CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
tmp = 0
r = 0
for a in A:
    if maxA == a:
        continue
    combA = cmb(maxA, a)
    if tmp < combA:
        tmp = combA
        r = a

print(maxA, r)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
halfA = maxA // 2
tmp = 10 ** 9
r = 0
for a in A:
    if a == maxA:
        continue
    half = abs(halfA - a)
    if tmp > half:
        tmp = half
        r = a

print(maxA, r)
### BUGGY CODE ###

N = int(input())

ARR = [int(s) for s in input().split(" ")]

import math
import numpy as np

def calculate(n,arr):
    srr = np.array([arr - index - 1 for index,arr in enumerate(arr)])

    maxValue = max(srr)
    minValue = min(srr)

    if maxValue * minValue < 0:
        if math.fabs(maxValue) > math.fabs(minValue):
            pinyizuidaxiang =  int(math.fabs(maxValue))
        else:
            pinyizuidaxiang = int(math.fabs(minValue))
    elif maxValue * minValue > 0:
        pinyizuidaxiang = int(math.fabs(maxValue))
    else:
        if math.fabs(maxValue) != 0:
            pinyizuidaxiang = int(math.fabs(maxValue))
        if math.fabs(minValue) != 0:
            pinyizuidaxiang = int(math.fabs(minValue))
        if (math.fabs(maxValue) == 0)  and (math.fabs(minValue) == 0):
            pinyizuidaxiang = 0


    minest = []

    if pinyizuidaxiang == 0:
        return sum(srr)

    for i in range(-pinyizuidaxiang,pinyizuidaxiang):
        minest.append(sum(np.fabs(srr - i)))

    return int(min(minest))

result = calculate(N,ARR)
print(result)


### FIXED CODE ###


N = int(input())

ARR = [int(s) for s in input().split(" ")]

import numpy as np
def calculate(n,arr):
    srr = np.array([arr - index - 1 for index,arr in enumerate(arr)])

    srr = sorted(srr)

    if len(srr) % 2 == 0:
        centerIndex = len(srr)//2
        b = (srr[centerIndex] + srr[centerIndex-1])//2
    else:
        centerIndex = (len(srr) -1) //2
        b = srr[centerIndex]



    return sum(np.fabs(srr - b))

result = int(calculate(N,ARR))

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

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

l = [0] * (n + 1)
s = 0

for i in range(m):
    L, R = map(int, input().split())
    for j in range(L, R+1):
        l[j] += 1

for k in range(n + 1):
    if l[k] == m:
        s += 1
print(s)


### FIXED CODE ###

n, m = map(int, input().split())
l, r = map(int, input().split())
li = []


for _ in range(m - 1):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)


print(max(r - l + 1, 0))
### BUGGY CODE ###

MOD = 10**9 + 7
class SegTree():
    def segfunc(self, x, y):
        return (x + y) % MOD

    def __init__(self, ide, n, init_val):
        self.ide_ele = ide
        self.num = 2**(n-1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        for i in range(n):
            self.seg[i+self.num-1] = init_val[i]    
        for i in range(self.num-2,-1,-1):
            self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res

def main():
    n, m = map(int, input().split())
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    a = [0]*m
    seg = SegTree(0, m, a)
    for i in range(n):
        x = s[i]
        for j in reversed(range(m)):
            if x == t[j]:
                y = seg.query(0, j+1)
                seg.update(j, y+1)
#        for j in range(m):
#            print(seg.query(j, j+1), end=" ")
#        print("")
    print((seg.query(0, m) + 1) % MOD)

if __name__ == "__main__":
    main()

### FIXED CODE ###

MOD = 10**9 + 7
def main():
    n, m = map(int, input().split())
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    dp = [[0]*(m+1) for _ in range(n+1)]
    for si in range(1, n+1):
        for ti in range(1, m+1):
            if s[si-1] == t[ti-1]:
                dp[si][ti] += 1
                dp[si][ti] += dp[si-1][ti-1]
            dp[si][ti] += dp[si-1][ti] + dp[si][ti-1]
            dp[si][ti] -= dp[si-1][ti-1]
            dp[si][ti] %= MOD
    print(dp[n][m] + 1)
#    for i in range(n+1):
#        print(dp[i])

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

n,m=map(int,input().split())
d={}
for i in range(m):
	x,y=map(int,input().split())
	if x in d:
		d[x].append(y)
	else:
		d[x]=[y]
	if y in d:
		d[y].append(x)
	else:
		d[y]=[x]

parent=[0]*(n+1)
bfs=[1]
visited=set([1])
while len(bfs)!=0:
	x=bfs.pop(0)
	visited.add(x)
	for i in d[x]:
		if i not in visited:
			bfs.append(i)
			parent[i]=x
			visited.add(i)


if len(visited)==n:
	print('Yes')
	for i in range(2,n+1):
		print(parent[i])
else:
	print('No')




### FIXED CODE ###

n,m=map(int,input().split())
d={}
for i in range(m):
	x,y=map(int,input().split())
	if x in d:
		d[x].append(y)
	else:
		d[x]=[y]
	if y in d:
		d[y].append(x)
	else:
		d[y]=[x]

parent=[0]*(n+1)
bfs=[1]
visited=set([1])
while len(bfs)!=0:
	x=bfs.pop(0)
	visited.add(x)
	for i in d[x]:
		if i not in visited:
			bfs.append(i)
			parent[i]=x
			visited.add(i)


if len(visited)==n:
	print('Yes')
	for i in range(2,n+1):
		print(parent[i])
else:
	print('No')
### BUGGY CODE ###

import sys

n = int(input())

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

ans = 1

for i in range(n):
    ans *= a[i]


if ans > 10**18:
    print(-1)
    sys.exit()

print(ans)


### FIXED CODE ###

import sys

n = int(input())

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

ans = 1

if 0 in a:
    print(0)
    sys.exit()

for i in a:
    ans *= i
    
    if ans > 10**18:
        print(-1)
        sys.exit()

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

import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

import numpy as np

def F2_GaussJordan(A, is_extended = False):
    rank = 0
    for col in range(len(A[0])):
        if (is_extended and col == len(A[0])-1):
            break
        pivot = -1
        for row in range(rank,len(A)):
            if A[row][col]:
                pivot = row
                break
        if pivot == -1: 
            continue
        A[[pivot,rank]] = A[[rank,pivot]]
        for row in range(len(A)):
            if (row != rank and A[row][col]):
                A[row] ^= A[rank]
        rank += 1
    return A

N = I()
A = III()

xor = 0
for i in range(N):
    xor ^= A[i]
xor = format(xor,'b').zfill(60)

use_digit = []
ans = 0
for j in range(60)[::-1]:
    if xor[60-j-1] == '1':
        ans += 2**j
    else:
        use_digit.append(j)

a = np.zeros((N,len(use_digit)), dtype=int)
for i in range(N):
    binary = format(A[i], 'b').zfill(60)
    k = 0
    for j in use_digit:
        if binary[60-j-1] == '1':
            a[i][k] = 1
        else:
            a[i][k] = 0
        k += 1

g = F2_GaussJordan(a,False)

s = np.zeros(len(use_digit),dtype=int)
for i in range(N):
    for j in range(len(use_digit)):
        if g[i][j]==1:
            s ^= g[i]
            break

for k in range(len(s)):
    ans += s[k]*2**(use_digit[k]+1)

print(ans)

### FIXED CODE ###

import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
A = III()

xor = 0
for i in range(N):
    xor ^= A[i]

for i in range(N):
    A[i] &= ~xor

max_digit = len(format(max(A), 'b'))
rank = 0
for col in range(max_digit)[::-1]:
    pivot = -1
    for row in range(rank,N):
        if A[row]>>col & 1:
            pivot = row
            break
    if pivot == -1: 
        continue
    A[pivot],A[rank] = A[rank],A[pivot]
    for row in range(rank+1,N):
        if A[row]>>col & 1:
            A[row] ^= A[rank]
    rank += 1

val = 0
for i in range(N):
    val = max(val,val^A[i])

print(2*val + xor)
### BUGGY CODE ###

# ABC177E

def GCD(m, n):
    while n != 0:
        m, n = n, m % n
    return m

def f(a):
    n = len(a)
    pairwise_coprime = True
    for i in range(n - 1):
        for j in range(i + 1, n):
            if GCD(a[i], a[j]) != 1:
                pairwise_coprime = False
                break
        if pairwise_coprime == False:
            break
    gcd = a[0]
    for i in range(1, n):
        gcd = GCD(gcd, a[i])
    if pairwise_coprime == False and gcd == 1:
        return 'setwise coprime'
    elif pairwise_coprime:
        return 'pairwise coprime'
    else:
        return 'not coprime'

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


### FIXED CODE ###

def GCD(m, n):
    while n != 0:
        m, n = n, m % n
    return m

def gcd_all(a):
    n = len(a)
    gcd = a[0]
    for i in range(1, n):
        gcd = GCD(gcd, a[i])
    return gcd

def f(a):
    mx = 10**6
    p = set([])
    sieve = [i for i in range(mx + 1)]
    for i in range(2, int(mx**0.5 + 1)):
        for j in range(2 * i, mx + 1, i):
            if sieve[j] > i:
                sieve[j] = i
    pairwise_coprime = True
    for i in a:
        p2 = set([])
        while i > 1:
            p2.add(sieve[i])
            i //= sieve[i]
        for j in p2:
            if j in p:
                pairwise_coprime = False
                break
            p.add(j)
        if pairwise_coprime == False:
            break
    gcd = gcd_all(a)
    if pairwise_coprime == False and gcd == 1:
        return 'setwise coprime'
    elif pairwise_coprime:
        return 'pairwise coprime'
    else:
        return 'not coprime'

n = int(input())
a = list(map(int, input().split()))
print(f(a))
### BUGGY CODE ###

import heapq
def SME(start,end):
    A = []
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * 0.9977 : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

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

ans=0
value=[0]*len(B)
#Bより小さい値
B_s=[]
for i in B:
  tmp=0
  for j in A:
    if i > j:
      tmp+=1
  if tmp!=0:
    B_s.append(tmp)

k=0
for i in B:
  tmp=0
  for j in C:
    if j>i:
      tmp+=1
  if k<len(B_s):
    ans+=tmp*B_s[k]
    k+=1
print(ans)


### FIXED CODE ###

from bisect import bisect_left,bisect_right
n=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=0

for i in B:
  sml_B = bisect_left(A,i)
  # print(i,"sml_B",sml_B)
  big_B = len(C)-bisect_right(C,i)
  # print(i,"big_B",big_B)
  ans+=sml_B*big_B
print(ans)