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

# cook your dish here
h,w,m=map(int,input().split())
a=[0 for i in range(h+1)]
b=[0 for i in range(w+1)]

v=[]
for i in range(m):
    x,y=map(int,input().split())
    v.append([x,y])
    a[x]+=1
    b[y]+=1
    

maxx=max(a)
aa=[]
for i in range(1,len(a)):
    if a[i]==maxx:
        aa.append(i)

maxy=max(b)
bb=[]
for i in range(1,len(b)):
    if b[i]==maxy:
        bb.append(i)

ans=0
for i in range(len(aa)):
    for j in range(len(bb)):
        if [aa[i],bb[j]] in v:
            ans=max(ans,a[aa[i]]+b[bb[j]]-1)
            
        else:
            ans=max(ans,a[aa[i]]+b[bb[j]])
            
print(ans)

### FIXED CODE ###

# cook your dish here
h,w,m=map(int,input().split())
a=[0 for i in range(h+1)]
b=[0 for i in range(w+1)]

v={}
for i in range(m):
    x,y=map(int,input().split())
    # v.append([x,y])
    v[(x,y)]=1
    a[x]+=1
    b[y]+=1
    

maxx=max(a)
aa=[]
for i in range(1,len(a)):
    if a[i]==maxx:
        aa.append(i)

maxy=max(b)
bb=[]
for i in range(1,len(b)):
    if b[i]==maxy:
        bb.append(i)

ans=0
flag=0
for i in range(len(aa)):
    for j in range(len(bb)):
        if (aa[i],bb[j]) in v:
            ans=max(ans,a[aa[i]]+b[bb[j]]-1)
            
        else:
            ans=max(ans,a[aa[i]]+b[bb[j]])
            flag=1
            break
        
    if flag==1:
        break
            
print(ans)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

n,m = map(int,readline().split())
g = [[] * n for i in range(n)]
for i in range(m):
    u, v = map(int,readline().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)
    
ans = [-1]*n
from collections import deque

que = deque()
que.append((0,1))
chk = [False]*n
chk[0] =True
while que:
    now,p = que.popleft()
    if all(chk):
      break
    for i in g[now]:
        if not chk[i]:
          ans[i] = p
          chk[i] = True
          que.append((i,i+1))


for i in ans[1:]:
  if i == -1:
    print('No')
    exit()
print('Yes')
for i in ans[1:]:
  print(i)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque

n,m = map(int,readline().split())
g = [[] * n for i in range(n)]
for i in range(m):
    u, v = map(int,readline().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)
    
ans = [-1]*n
from collections import deque

que = deque()
que.append((0,1))
chk = [False]*n
chk[0] =True
cnt = 1
while que:
    now,p = que.popleft()
    if cnt == n:
      break
    for i in g[now]:
        if not chk[i]:
          ans[i] = p
          chk[i] = True
          cnt += 1
          que.append((i,i+1))

if cnt!=n:
  print('No')
  exit()
  
print('Yes')
for i in ans[1:]:
  print(i)
### BUGGY CODE ###

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

    def bit_add(self, index, num):
        while (index <= self.N):
            self.bit[index] += num
            index += index & -index
        return

    def bit_sum(self,index):
        result = 0
        while (index > 0):
            result += self.bit[index]
            index -= index & -index
        return result

    def bit_sum_range(self, l, r):
        if (l == r):
            return 1
        else:
            return self.bit_sum(r) - self.bit_sum(l - 1)

def main():
    from sys import stdin
    N, Q = list(map(int, input().split()))
    c = list(map(int, input().split()))
    readline = stdin.readline
    query = [list(map(int, readline().split())) + [i] for i in range(Q)]
    query_result = [0 for i in range(Q)]
    collar_pos = [-1] * (N + 1)
    bit = BinaryIndexedTree(N)

    sorted_query = sorted(query, key=lambda query: query[1])

    index = 1
    for query in sorted_query:
        while (index <= query[1]):
            # update BIT
            if (collar_pos[c[index-1]] != -1):
                bit.bit_add(collar_pos[c[index-1]], -1)
            bit.bit_add(index, 1)
            # update collar_pos
            collar_pos[c[index-1]] = index
            index += 1
        query_result[query[2]] = bit.bit_sum_range(query[0], query[1])

    print(*query_result, sep='\n')

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

    def bit_add(self, index, num):
        while (index <= self.N):
            self.bit[index] += num
            index += index & -index
        return

    def bit_sum(self,index):
        result = 0
        while (index > 0):
            result += self.bit[index]
            index -= index & -index
        return result

    def bit_sum_range(self, l, r):
        if (l == r):
            return 1
        else:
            return self.bit_sum(r) - self.bit_sum(l - 1)

def main():
    from sys import stdin
    N, Q = list(map(int, input().split()))
    c = list(map(int, input().split()))
    readline = stdin.readline
    query = [list(map(int, readline().split())) + [i] for i in range(Q)]
    query_result = [0 for i in range(Q)]
    collar_pos = [-1] * (N + 1)
    bit = BinaryIndexedTree(N)

    sorted_query = sorted(query, key=lambda query: query[1])

    index = 1
    for query in sorted_query:
        l, r, q = query
        while (index <= r):
            # update BIT
            if (collar_pos[c[index-1]] != -1):
                bit.bit_add(collar_pos[c[index-1]], -1)
            bit.bit_add(index, 1)
            # update collar_pos
            collar_pos[c[index-1]] = index
            index += 1
        query_result[q] = bit.bit_sum_range(l, r)

    print(*query_result, sep='\n')

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

#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, L: "List[int]"):
    L = np.array(sorted(L))
    ct = 0
    for a in range(len(L)-2):
        a_ = L[a]
        # for b in range(a+1, len(L)-1):
        #     ct+=(L[b+1:] < a_+L[b]).sum() 
        ct += sum([(L[b+1:] < a_+L[b]).sum() for b in range(a+1, len(L)-1)])
    print(ct)

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

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# import numpy as np
import bisect

def solve(N: int, L: "List[int]"):
    L = sorted(L)
    ct = 0
    for a in range(len(L)-2):
        a_ = L[a]
        for b in range(a+1, len(L)-1):
            b_in = bisect.bisect_left(L,a_+L[b]) - b -1
            if b_in > 0:
                ct+=b_in

            # print("L :{} a+Lb :{}  b_in:{}".format(L[b+1:],a_+L[b],ct))
        # ct += sum([bisect.bisect_left(L[b+1:],a_+L[b]) for b in range(a+1, len(L)-1)])
    print(ct)

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

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

X,Y,Z,K = map(int,(input().split()))
A = list(map(int,(input().split())))
B = list(map(int,(input().split())))
C = list(map(int,(input().split())))

D = []
for a in A:
    for b in B:
        D.append(a+b)
D = sorted(D,reverse=True)[:3000]

E = []
for d in D:
    for c in C:
        E.append(c+d)
E = sorted(E,reverse=True)[:K]

for e in E:
    print(e)

### FIXED CODE ###

X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=True)
B = sorted(list(map(int,input().split())),reverse=True)
C = sorted(list(map(int,input().split())),reverse=True)

L = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K:
                L.append(A[i]+B[j]+C[k])
            else:
                break

L = sorted(L,reverse=True)[:K]
for l in L:
    print(l)
### BUGGY CODE ###

def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]


n = int(input())
s = input()
ans = set()

for i in range(0,1000):
    num = str(i)
    if i < 10:
        num = "00"+num
    elif i <100:
        num = "0" + num
    for j in range(n):
        if s[j] == num[0]:
            for k in range(j+1,n):
                if s[k] == num[1]:
                    for l in range(k+1,n):
                        if s[l] == num[2]:
                            ans.add(i)
print(len(ans))
                        

### FIXED CODE ###

n = int(input())
s = input()
ans = 0

for i in range(0,1000):
    num = str(i)
    if i < 10:
        num = "00"+num
    elif i <100:
        num = "0" + num
    f = 0
    for j in range(n):
        if s[j] == num[f]:
            f += 1
        if f == 3:
            break
    if f==3:
        ans +=1
print(ans)
### BUGGY CODE ###

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

for i in range(n):
    for j in range(i + 1):
        if not p[i] <= p[j]:
            m -= 1
            break

print(m)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
m = n
q = 2 * (10 ** 5)

for i in range(n):
    q = min(p[i],q)
    if not p[i] <= q:
        m -= 1

print(m)
### BUGGY CODE ###

N, K=(int(i) for i in input().split())
A=[int(i) for i in input().split()]
A= sorted(A)

from math import factorial

inf=10**9+7
ans=0

for i in range(K, N+1):
    #(N-1)C(K-1)
    ans+=(A[i-1]*factorial(i-1) // factorial(K-1) // factorial(i-1-K+1))%inf
for i in range(1, N-K+2):
    #(N-i)C(K-1)
    ans-=(A[i-1]*factorial(N-i) // factorial(K-1) // factorial(N-i-K+1))%inf
print(ans%inf)



### FIXED CODE ###


N, K=(int(i) for i in input().split())
A=[int(i) for i in input().split()]
A= sorted(A)

from math import factorial

inf=10**9+7
ans=0

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


for i in range(K, N+1):
    #(N-1)C(K-1)
    ans+=(A[i-1]*cmb(i-1, K-1,p))%inf
for i in range(1, N-K+2):
    #(N-i)C(K-1)
    ans-=(A[i-1]*cmb(N-i, K-1,p))%inf
print(ans%inf)
### BUGGY CODE ###

R,G,B,N = map(int, input().split())

ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        check = N - (R*r + G*g)
        if check == 0:
            # print(r, g, check//B, check)
            ans += 1
        elif check > 0 and check%B == 0:
                # print(r, g, check//B, check)
                ans += 1

print(ans)

### FIXED CODE ###

R,G,B,N = list(map(int, input().split()))
ans=0
for r in range(N//R+1):
    x = N-R*r
    for g in range(x//G+1):
        if (x-G*g)%B==0:
            ans+=1
print(ans)
### BUGGY CODE ###

import numpy as np

N = int(input())
A_ = list(map(int, input().split()))
A_ = sorted(A_)

A = np.array(A_)

ans = 0
for X in range(np.min(A),np.max(A)+1):
    tmp = 0
    for a in A:
        if X-1 <= a <= X+1:
            tmp += 1
        elif X+1 < a:
            break
    ans = max(tmp,ans)
print(ans)


### FIXED CODE ###

import collections

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

dic = collections.Counter(A)
tmp = [0 for _ in range(A[-1]+1)]


for X in dic.keys():
    tmp[X] = dic[X]

ans = 0
for i in range(len(tmp)):
    ans = max(ans,sum(tmp[i:i+3]))

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

K = int(input())
AT = list(map(int,input().split()))

A=reversed(AT)
s = 2;b = 1;lis=[]
for i in A:
    b=b-b%i
    ns = i
    if s > ns:
        while s > ns:
            ns += i
    s = ns
    nb = i
    if b > nb:
        while b > nb:
            nb+= i
    b= (nb+i-1)
sn = s
for i in AT:
    sn = sn-sn%i
if sn!=2:
    print(-1)
    exit()
print(s,b)


### FIXED CODE ###

K = int(input())
AT = list(map(int,input().split()))

A=reversed(AT)
s = 2;b = 1;lis=[]
for i in A:
    ns = i
    if s > ns:
        ns +=(((s-ns)//i)*i)
        if s > ns:
            ns+=i
    s = ns
sn = s
for i in AT:
    sn = sn-sn%i

if sn!=2:
    print(-1)
    exit()
b = 1
AT.reverse()
for i in AT:
    b=b-b%i
    nb = i
    if b > nb:
        nb +=(((b-nb)//i)*i)
        if b > nb:
            nb+=i
    b= (nb+i-1)
print(s,b)
### BUGGY CODE ###

N = int(input())
c = input()
li = list(c)
count = li.count('R')
num = 0

for i in range(count):
    if li[i] == 'W':
        for j in range(len(li)-count):
            if li[j*(-1)-1] == 'R':
                li[i] = "R"
                li[j*(-1)-1] = 'W'
                num += 1



print(num)

### FIXED CODE ###

N = int(input())
c = input()
li = list(c)
count = li.count('R')
num = 0

#for i in range(count):
    #if li[i] == 'W':
        #for j in range(len(li)-count):
            #if li[j*(-1)-1] == 'R':
                #li[i] = "R"
                #li[j*(-1)-1] = 'W'
                #num += 1

#for i in range(int(N/2)):
    #if li[i] == 'W' and li[j*(-1)-1] == 'R':
        #li[i] = 'R'
        #li[j*(-1)-1] = 'W'
        #num += 1

#for i in range(count):
    #if li[i] == 'W':
        #li[i] == 

for i in range(count):
    if li[i] == 'W':
        num += 1

print(num)
### BUGGY CODE ###

n, k = map(int, input().split())
mod = 10**9+7
result = 0
memo = [0 for _ in range(k+1)]
for i in range(k, 0, -1):
    z = 1
    y = k//i
    for j in range(n):
        z = (z*y)%mod
    j = 2
    while j*i <= k:
        z -= memo[j*i]
        j += 1
    memo[i] = z
    result = (result+z*i)%mod
print(result)

### FIXED CODE ###

n, k = map(int, input().split())
mod = 10**9+7
result = 0
memo = [0 for _ in range(k+1)]
for i in range(k, 0, -1):
    y = k//i
    z = pow(y, n, mod)
    j = 2
    while j*i<=k:
        z -= memo[j*i]
        z %= mod
        j += 1
    memo[i] = z
    result = (result+z*i)%mod
print(result)
### BUGGY CODE ###

n, Q = list(map(int, input().split()))
ans = [-1 for i in range(Q)]
event = []
for i in range(n):
  s, t, x = list(map(int, input().split()))
  event.append((s-x, 1, x))
  event.append((t-x, 0, x))
for i in range(Q):
  q = int(input())
  event.append((q, 2, i))
event.sort()
stop = set()
min_s = 1e10
for (t, q, x) in event:
  if q==1:
    stop.add(x)
    min_s = min(min_s, x)
  elif q==0:
    stop.remove(x)
    if len(stop):
      min_s = min(stop)
    else:
      min_s = 1e10
  else:
    if min_s != 1e10:
      ans[x] = min_s
for e in ans:
  print(e)

### FIXED CODE ###

from bisect import bisect_left
n, Q = list(map(int, input().split()))
stx = [list(map(int, input().split())) for i in range(n)]
q = [int(input()) for i in range(Q)]
stx.sort(key=lambda x: x[2])
ans = [-1 for i in range(Q)]
skip = [-1 for i in range(Q)]

for (s, t, x) in stx:
  begin = bisect_left(q, s-x)
  end = bisect_left(q, t-x)
  while begin<end:
    if skip[begin]==-1:
      ans[begin] = x
      skip[begin] = end
      begin += 1
    else:
      begin = skip[begin]
for e in ans:
  print(e)
### BUGGY CODE ###

N=int(input())
s=[sorted(list(input())) for i in range(N)]
t=[]
from collections import Counter

for i in s:
  a=Counter(i)
  t.append(a.most_common())

from itertools import permutations, combinations,combinations_with_replacement,product
L = combinations(range(N), 2)   #nCr
cnt = 0
for i in L:
  if t[i[0]]==t[i[1]]:
    cnt +=1
print(cnt)


### FIXED CODE ###

N=int(input())
d={}
for i in range(N):
  a = "".join(sorted(list(input())))
  if a not in d:
    d[a] = 1
  else:
    d[a]=d[a]+1
cnt = 0
for B in d.values():
  cnt += int(B * (B-1) /2)
print(cnt)
### BUGGY CODE ###

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

cnt = 0

for i in range(N-1):
    for j in range(i+A[i]+1,N):
        if j-i == A[i]+A[j]:
            cnt += 1

print(cnt)


### FIXED CODE ###

from collections import defaultdict

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

cnt = 0
L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)

for i in range(N):
    L[i+A[i]] += 1
    R[i-A[i]] += 1

for key in L:
    cnt += L[key] * R[key]


print(cnt)
### BUGGY CODE ###

k, s = [int(i) for i in input().split()]
ans = 0
for x in range(k, -1, -1):
    for y in range(k, -1, -1):
        for z in range(k, -1, -1):
            if x + y + z is s:
                ans += 1
print(ans)


### FIXED CODE ###

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

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

aset = set(a)

ans = 0

for i in aset:
    if a.count(i) < i:
        ans += a.count(i)
    else:
        ans += a.count(i) - i

print(ans)

### FIXED CODE ###

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

d = dict()
for i in a:
    d[i] = d.get(i, 0) + 1


ans = 0
for i in d.items():
    if i[0] > i[1]:
        ans += i[1]
    elif i[0] < i[1]:
        ans += i[1] - i[0]

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

N, M = map(int, input().split())
A_B = []
for _ in range(M):
    a_b = list(map(int, input().split()))
    A_B.append(a_b)

friend_list = [[0] * (N + 1) for _ in range(N + 1)]
call_check = [0] * (N + 1)

for a, b in A_B:
    friend_list[a][b] = 1
    friend_list[b][a] = 1


ans = 0
for friend in friend_list:
    sum_friend = sum(friend)
    ans = max(ans, sum_friend)
print(ans + 1)


### FIXED CODE ###

from collections import Counter


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.par[x] > self.par[y]:
            x, y = y, x

        self.par[y] = x
        self.size[x] += self.size[y]
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)


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

for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a, b)

ans = max(uf.size)

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

H,W = map(int,input().split())

start = tuple(map(lambda x:x - 1, map(int,input().split())))
goal = tuple(map(lambda x:x - 1, map(int,input().split())))

S = [input() for i in range(H)]

from collections import deque
q = deque([])

# 頂点, コスト
q.append([start[0], start[1], 0])
INF = 10 ** 10
cost = [[INF] * W for i in range(H)]

while q:
  y,x,c = q.popleft()
  if S[y][x] == "#":
    continue
  if cost[y][x] <= c:
    continue
  cost[y][x] = c
  for i in range(-2,3):
    for j in range(-2,3):
      if i == 0 and j == 0:
        continue
      if 0 <= y + i < H and 0 <= x + j < W:
        if abs(i) + abs(j) == 1:
          q.appendleft([y + i, x + j, c])
        else:
          q.append([y + i, x + j, c + 1])

if cost[goal[0]][goal[1]] == INF:
  print(-1)
else:
  print(cost[goal[0]][goal[1]])


### FIXED CODE ###

H,W = map(int,input().split())

start = tuple(map(lambda x:x - 1, map(int,input().split())))
goal = tuple(map(lambda x:x - 1, map(int,input().split())))

S = [input() for i in range(H)]

from collections import deque
q = deque([])

# 頂点, コスト
q.append([start[0], start[1], 0])
INF = 10 ** 10
cost = [[INF] * W for i in range(H)]

while q:
  y,x,c = q.popleft()
  if S[y][x] == "#":
    continue
  if cost[y][x] <= c:
    continue
  cost[y][x] = c
  for i in range(-2,3):
    for j in range(-2,3):
      if i == 0 and j == 0:
        continue
      if 0 <= y + i < H and 0 <= x + j < W:
        if abs(i) + abs(j) == 1:
          q.appendleft([y + i, x + j, c])
        else:
          q.append([y + i, x + j, c + 1])

if cost[goal[0]][goal[1]] == INF:
  print(-1)
else:
  print(cost[goal[0]][goal[1]])
### BUGGY CODE ###

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

cnt = 0
for _ in range(n):
    if m >= 2:
        m -= 2
        cnt += 1
for _ in range(m // 4):
    if m >= 4:
        m -= 4
        cnt += 1
print(cnt)


### FIXED CODE ###

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

cnt = min(n, m // 2)
print(cnt + (m - cnt * 2) // 4)
### BUGGY CODE ###

from functools import reduce
import operator
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 not ANS[idx]:
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if not ANS[i] : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if not ANS[i] : 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()]
parameter = 0.9998
INIT = None
ANS = [INIT]*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 ###

def judge():
    four = []
    even = []
    odd = []
    for a in a_list:
        if a % 2 == 1:
            odd.append(a * 3)
        else:
            if a % 4 == 0:
                four.append(a)
            else:
                even.append(a)
    if len(four) > 0:
        odd.append(four.pop() // 2)
        four = [i * 3 for i in four]
        odd.extend(four)
        even = [i * 3 for i in even]
        odd.extend(even)
    else:
        if even:
            odd.append(even.pop() // 2)
            even = [i * 3 for i in even]
            odd.extend(even)
        else:
            return False
    global a_list
    a_list = odd
    return True


N = int(input())
a_list = list(map(int, input().split()))
cnt = 0
while True:
    if judge():
        cnt += 1
    else:
        break
print(cnt)


### FIXED CODE ###

N = int(input())
a_list = list(map(int, input().split()))
cnt = 0
for a in a_list:
    if a % 2 == 0:
        while a % 2 == 0:
            a /= 2
            cnt += 1
print(cnt)
### BUGGY CODE ###

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

number_lis = []
ans = 0

for i in range(0,K+1):
    number_lis.append(i)

for j in number_lis:
    for k in number_lis:
        for l in number_lis:
            if (j + k + l) == S:
                ans = ans + 1
                
print(ans)

### FIXED CODE ###

K, S = map(int, input().split())
ans = 0
for x in range(min(K,S)+1):
	for y in range(min(K,S)+1):
		if 0 <= S - x - y <= K:
			ans += 1
print(ans)