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

N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
A = prime_factorize(N)
L = []
for i in range(1<<len(A)):
    tmp = 1
    j = bin(i)[2:]
    leng = len(j)
    for k in range(leng):
        if j[leng-k-1]=="1":
            tmp *= A[k]
    L.append(tmp)
    
ans = []
for i in L:
    j = N//i
    ans.append(i+j-2)
    
print(min(ans))

### FIXED CODE ###

N = int(input())
ans = []
for i in range(1,int(pow(N,0.5))+1):
    j = N//i
    if i*j == N:
        ans.append(i+j)

print(min(ans)-2)
### BUGGY CODE ###

N=int(input())
L=list(map(int,input().split()))
B=-1
A=1
for i in range(N):
  A=A*L[i]
if 10**18>=A:
  print(A)
else:
  print(B)

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
A=1
if 0 in L:
  print(0)
  exit()
for i in range(N):
  A=A*L[i]
  if 10**18<A:
    print(-1)
    exit()
print(A)
### BUGGY CODE ###

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

count = 0
for i in range(n):
  if(min(p[0:i+1]) >= p[i]):
    count += 1
print(count)

### FIXED CODE ###

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

count = 1
min = p[0]
for i in range(1,n):
  if(min >= p[i]):
    min = p[i]
  if(min >= p[i]):
    count += 1
print(count)
### BUGGY CODE ###

def main():
    s = input()
    t = input()

    """
    dp[i][j] := s[1] ... s[i] と t[1] ... t[j] に対するLCSの長さ
    
    s[i+1] == t[i+1]のとき、dp[i+1][j+1]は dp[i][j]+1, dp[i+1][j], dp[i][j+1]のいずれか  
    dp[i+1][j+1] = max(dp[i][j] + 1, dp[i+1][j], dp[i][j+1])

    それ以外の時
    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    """

    dp = [[0] * (len(t) + 1) for _ 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] = max(dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1])
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

    ans = ""
    x = len(s)
    y = len(t)
    while x >= 1 and y >= 1:
        if dp[x][y] == dp[x - 1][y]:
            x -= 1
        elif dp[x][y] == dp[x][y - 1]:
            y -= 1
        else:
            x -= 1
            y -= 1
            ans = s[x] + ans

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    s = input()
    t = input()

    """
    dp[i][j] := s[1] ... s[i] と t[1] ... t[j] に対するLCSの長さ
    
    s[i+1] == t[i+1]のとき、dp[i+1][j+1]は dp[i][j]+1, dp[i+1][j], dp[i][j+1]のいずれか  
    dp[i+1][j+1] = max(dp[i][j] + 1, dp[i+1][j], dp[i][j+1])

    それ以外の時
    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
    """

    dp = [[0] * (len(t) + 1) for _ 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] = max(dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1])
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

    ans = ""
    x = len(s)
    y = len(t)
    while x >= 1 and y >= 1:
        if dp[x][y] == dp[x - 1][y]:
            x -= 1
        elif dp[x][y] == dp[x][y - 1]:
            y -= 1
        else:
            x -= 1
            y -= 1
            ans = s[x] + ans

    print(ans)


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

N=int(input())
power=1
for i in range(1,N+1):
    power=power*i
print(power%(10**9+7))


### FIXED CODE ###

import math

N=int(input())
print(math.factorial(N)%(10**9+7))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
U = n**2
G = [[] for _ in range(U)]
parent = [0]*U
for i in range(n):
  A = list(map(lambda x:int(x)-1, input().split()))
  for j in range(n-2):
    a = A[j]
    b = A[j+1]
    G[min(i, a)*n+max(i, a)].append(min(i, b)*n+max(i, b))
    parent[min(i, b)*n+max(i, b)] += 1

que = deque([(i*n+j, 1) for i in range(n-1) for j in range(i+1, n) if not parent[i*n+j]])
ans = 1
cnt = 0
while que:
  v, t = que.pop()
  ans = max(ans, t)
  cnt += 1
  for nv in G[v]:
    parent[nv] -= 1
    if not parent[nv]:
      que.appendleft((nv, t+1))
if cnt == n*(n-1)//2:
  print(ans)
else:
  print(-1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
U = n**2
G = [[] for _ in range(U)]
parent = [0]*U
for i in range(n):
  A = list(map(lambda x:int(x)-1, input().split()))
  for j in range(n-2):
    a = A[j]
    b = A[j+1]
    G[min(i, a)*n+max(i, a)].append(min(i, b)*n+max(i, b))
    parent[min(i, b)*n+max(i, b)] += 1

que = deque([(i*n+j, 1) for i in range(n-1) for j in range(i+1, n) if not parent[i*n+j]])
ans = 1
cnt = 0
while que:
  v, t = que.pop()
  ans = max(ans, t)
  cnt += 1
  for nv in G[v]:
    parent[nv] -= 1
    if not parent[nv]:
      que.appendleft((nv, t+1))
if cnt == n*(n-1)//2:
  print(ans)
else:
  print(-1)
### BUGGY CODE ###

def resolve():
    s = str(input())
    ans = 0
    while True:
        origin = s
        s = s.replace('BW', 'WB', 1)
        if origin == s:
            break
        ans += 1
    print(ans)

    return
resolve()

### FIXED CODE ###

def resolve():
    s = str(input())
    ans = 0
    ind = []
    for i, char in enumerate(s):
        if char == 'W':
            ind.append(i)
    lst = 0
    # print(ind)
    for i in ind:
        ans += (i - lst)
        lst += 1

    # idx = s.index('W')
    print(ans)
    return


resolve()
### BUGGY CODE ###

sh = int(input())
b = input()

id = [int(n) for n in b.split(" ")]
#id_list = set(id)

for i in range(1,sh+1):
    print(id.count(i))


### FIXED CODE ###

from collections import defaultdict

sh = int(input())
b = input()

id = [int(n) for n in b.split(" ")]
D = defaultdict(int)
for i in id:
    if i not in D:
        D[i] = 1
    else:
        D[i] += 1
#print(D)

for i in range(1,sh+1):
    if i in D:
        print(D[i])
    else:
        print(0)
### BUGGY CODE ###

import heapq
def dijkstra(G, s):
    dist = [float("inf")]*len(G)
    q = []
    dist[s] = 0
    heapq.heapify(q)
    heapq.heappush(q, [0, s])
    while 0 < len(q):
        pre_cost, p = heapq.heappop(q)
        if dist[p] < pre_cost:
            continue
        for v, d in G[p]:
            if dist[v] > dist[p] + d:
                dist[v] = dist[p] + d
                heapq.heappush(q, [dist[v], v])
    return dist
def main():
    n, m, s, t = map(int, input().split())
    s, t = s-1, t-1
    G_y = [[] for _ in range(n)]
    G_s = [[] for _ in range(n)]
    f = [True]*n
    for _ in range(m):
        u, v, a, b = map(int, input().split())
        u, v = u-1, v-1
        G_y[u].append([v, a])
        G_y[v].append([u, a])
        G_s[u].append([v, b])
        G_s[v].append([u, b])
    cost_y = dijkstra(G_y, s)
    cost_s = dijkstra(G_s, t)
    cost = [[cost_y[i] + cost_s[i], i] for i in range(n)]
    cost.sort()
    x = 0
    for i in range(n):
        while not f[cost[x][1]]:
            x += 1
        print(10**15 - cost[x][0])
        f[i] = False

if __name__ == "__main__":
    main()


### FIXED CODE ###

import heapq
def dijkstra(G, s):
    dist = [float("inf")]*len(G)
    q = []
    dist[s] = 0
    heapq.heapify(q)
    heapq.heappush(q, [0, s])
    while 0 < len(q):
        pre_cost, p = heapq.heappop(q)
        if dist[p] < pre_cost:
            continue
        for v, d in G[p]:
            if dist[v] > dist[p] + d:
                dist[v] = dist[p] + d
                heapq.heappush(q, [dist[v], v])
    return dist
import sys
input = sys.stdin.readline
def main():
    n, m, s, t = map(int, input().split())
    s, t = s-1, t-1
    G_y = [[] for _ in range(n)]
    G_s = [[] for _ in range(n)]
    f = [True]*n
    for _ in range(m):
        u, v, a, b = map(int, input().split())
        u, v = u-1, v-1
        G_y[u].append([v, a])
        G_y[v].append([u, a])
        G_s[u].append([v, b])
        G_s[v].append([u, b])
    cost_y = dijkstra(G_y, s)
    cost_s = dijkstra(G_s, t)
    cost = [[cost_y[i] + cost_s[i], i] for i in range(n)]
    cost.sort()
    x = 0
    for i in range(n):
        while not f[cost[x][1]]:
            x += 1
        print(10**15 - cost[x][0])
        f[i] = False

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

m, n = map(int, input().split())
while True:
  if m < n:
    m, n = n, m
  if m%n:
    m, n = n, m%n
  else:
    break

def divisors(m):
    divisors = [1]
    for i in range(2, m+1):
        if m % i == 0:
            divisors.append(i)
        while m % i == 0:
            m //= i
        if m == 1:
            break
    return divisors

print(len(divisors(n)))

### FIXED CODE ###

a, b = map(int, input().split())
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p

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)
    divisors.sort()
    return divisors

divisors = make_divisors(gcd(a, b))
ans = []
while divisors:
    key = divisors[0]
    ans.append(key)
    divisors.remove(key)
    notans = []
    for value in divisors:
        if gcd(key, value) != 1:
            notans.append(value)
    for i in notans:
        divisors.remove(i)
            
print(len(ans))
### BUGGY CODE ###

import sys
input=sys.stdin.readline
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()))
l1=[]
#print(a,end=" a\n")
#print(b,end=" b\n")

l1=list([i+j for i in a for j in b])
l1.sort(reverse=True)
#for i in a:
#  for j in b:
#    # print(i,j)
#    l1.append(i+j)
#l1.sort(reverse=True)
#print(l1)
l1=l1[:min(len(l1),k)]
l2=list([i+j for i in l1 for j in c])
#l2=[]
#for i in l1:
#  for j in c:
#    l2.append(i+j)
l2.sort(reverse=True)
#print(l2)
print("\n".join(map(str,l2[:k])))


### FIXED CODE ###

import sys
input=sys.stdin.readline
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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
l1=sorted([i+j for i in a for j in b],reverse=True)[:k]
l2=sorted([i+j for i in l1 for j in c],reverse=True)[:k]
for i in l2:
  print(i)
### BUGGY CODE ###

#C - Poll
N = int(input())
S = [input() for _ in range(N)]
S_set = list(sorted(set(S)))

counter = [0]*(len(S_set))

for i in S:
    counter[S_set.index(i)] += 1

maxim = max(counter)
ans= [S_set[i] for i in range(len(S_set)) if counter[i] == maxim ]
for j in ans:
    print(j)

### FIXED CODE ###

#C - Poll
N = int(input())
S = [input() for _ in range(N)]
S_set = list(sorted(set(S)))

counter = {}
for k in S_set:
    counter[k] = 0
for i in S:
    counter[i] += 1
    
maxim = max(counter.values())
ans = [i for i in S if counter[i] == maxim]
ans = list(sorted(set(ans))) 

for j in ans:
    print(j)
### BUGGY CODE ###

N, M = map(int,input().split())
list_and = list(range(1,N+1,1))
for i in range(M):
    L, R = list(map(int, input().split()))
    list_temp = list(range(L,R+1,1))
    list_and = list(set(list_and) & set(list_temp))
print(len(list_and))

### FIXED CODE ###

n, m = map(int, input().split())
l = 0
r = n
for _ in range(m):
    nl, nr = map(int, input().split())
    l = max(nl, l)
    r = min(nr, r)
 
print(max(r - l + 1, 0))
### BUGGY CODE ###

n = int(input())
s = input()

dp = [[] for i in range(n)]
for i in range(n):
    r = dp[i]
    prev = s[i]
    r.append(prev)
    for j in range(i + 1, n):
        nxt = prev + s[j]
        r.append(nxt)
        prev = nxt

res = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        tt = res
        mx = min(j - i, n - j)
        if tt >= mx:
            continue
        while tt < mx:
            if dp[i][tt] != dp[j][tt]:
                break
            else:
                tt += 1
        res = max(res, tt)

print(res)

### FIXED CODE ###

n = int(input())
s = input()

dp = [[0 for i in range(5005)] for j in range(5005)]

for i in range(n - 1, -1, -1):
    for j in range(n - 1, -1, -1):
        dp[i][j] = 0 if s[i] != s[j] else dp[i + 1][j + 1] + 1

res = 0
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        curr = min(dp[i][j], j - i)
        res = max(res, curr)

print(res)
### BUGGY CODE ###

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

for i in range(1,n+1):
  print(a.count(i))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for i in a:
  ans[i-1] += 1
for i in ans:
  print(i)
### BUGGY CODE ###

r, g, b, n = map(int, input().split())

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        k = (n - i*r - j*g)//b
        if 0 <= k <= n//b + 1 and i*r + j*g + k*b == n:
            cnt += 1
            # print(i, j, k)

print(cnt)

### FIXED CODE ###

r, g, b, n = map(int, input().split())

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        k = (n - i*r - j*g)
        if k >= 0 and k % b == 0:
            cnt += 1
            # print(i, j, k)

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

import math
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[]
for i in range(1,50):
  b.append(2**i)
ct=0
check=[0]*n
for i in range(n-1,-1,-1):
  if check[i]==0:
    check[i]=1
    x=math.floor(math.log2(a[i]))
    x=b[x]-a[i]
    y=bisect.bisect_left(a,x)
    z=bisect.bisect_right(a,x)
    if a[y]==x:
      if check[y]==0:
        check[y]=1
        ct+=1
      else:
        for j in range(y,z):
          if a[j]==x and check[j]==0:
            check[j]=1
            ct+=1
            break
print(ct)

### FIXED CODE ###

import math
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[]
for i in range(1,50):
  b.append(2**i)
ct=0
check=[1]*n
for i in range(n-1,-1,-1):
  if a[i]==1:
    break
  if check[i]==1 and a[i] not in b:
    check[i]=0
    x=math.floor(math.log2(a[i]))
    x=b[x]-a[i]
    y=bisect.bisect_left(a,x)
    z=bisect.bisect_right(a,x)
    t=bisect.bisect_left(check[y:z],1)+y
    if t!=z:
      check[t]=0
      ct+=1

ctb=0
w=1
for i in range(n):
  if a[i] in b or a[i]==1:
    if a[i]==w:
      if check[i]==1:
        ctb+=1
    else:
      ct+=ctb//2
      w=a[i]
      if check[i]==1:
        ctb=1
      else:
        ctb=0
  else:
    ct+=ctb//2
    ctb=0
ct+=ctb//2

print(ct)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)

def hersCode(L, n):
  #if L[-1] < n:
  #  return len(L)
  ok = 0
  ng = len(L)
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if L[mid] <= n:
      ok = mid
    else:
      ng = mid
  return ok

def answer(T):
  print(len(T))
  for i in T:
    print(i)

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

L = {}
R = {}
for i in range(M):
  a, b = AB[i]
  if a in L:
    L[a].append(b)
  else:
    L[a] = [b]
  if b in R:
    R[b].append(a)
  else:
    R[b] = [a]

def nasu(g, n, r, P):
  if n in R:
    for i in R[n]:
      if i in P and i != r:
        return None
  if n not in L:
    return None
  k = L[n]
  for i in k:
    if i in P and i != g:
      return None
  if g in k:
    return P
  for i in k:
    if i < g:
      continue
    if i in P:
      continue
    T = nasu(g, i, n, P + [i])
    if T:
      return T
  return None

  

for i in range(1, N):
  T = nasu(i, i, 0, [i])
  if T:
    answer(T)
    exit()
else:
  print(-1)




### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

R = {}
for a, b in AB:
  if a in R:
    R[a].append(b)
  else:
    R[a] = [b]

def nasu(x, e):
  D[x] = 1
  if x not in R:
    return []
  for i in R[x]:
    if i == e:
      return [i]
    if D[i] == 0:
      t = nasu(i, e)
      if t != []:
        return [i] + t
  return []

for i in range(1, N + 1):
  D = [0] * (N + 1)
  L = nasu(i, i)
  if L != []:
    break
else:
  print(-1)
  exit()

D = [0] * (N + 1)
for i in L:
  D[i] = 1

LEN = len(L)
L = L + L

i = 0
while i < LEN:
  for j in range(i + LEN - 1, i, -1):
    if D[L[j]] != 0 and L[j] in R[L[i]]:
      for k in range(j - 1, i, -1):
        D[L[k]] = 0
      i = j
      break

A = []
for i in range(LEN):
  if D[L[i]] == 1:
    A.append(L[i])

print(len(A))
for i in A:
  print(i)
### BUGGY CODE ###

def simple_solution(N, A, B):
    ret = 0
    for a in A:
        for b in B:
            ret ^= a + b
    return ret


def solution(N, A, B):
    import bisect
    pow_2_k = 1
    ans = 0
    for k in range(30):
        MA = [a % (2 * pow_2_k) for a in A]
        MB = [b % (2 * pow_2_k) for b in B]
        MB.sort()
        # [2**k, 2 * (2**k)) か [3 * (2**k), 4 * (2**k)) の中に入るとk-bit目が1。
        # この a + b の数をカウントする。
        # → [2**k - a, 2 * (2**k) - a) か [3 * (2**k) - a, 4 * (2**k) - a) の中に入る b の数をカウント。
        cnt = 0
        for a in MA:
            index_1 = bisect.bisect_left(MB, pow_2_k - a)
            index_2 = bisect.bisect_left(MB, 2 * pow_2_k - a)
            index_3 = bisect.bisect_left(MB, 3 * pow_2_k - a)
            cnt += (N - index_1) - (N - index_2) + (N - index_3)
        if cnt % 2 == 1:
            ans += pow_2_k
        pow_2_k *= 2
    return ans


def check():
    import random
    random.seed(0)
    for N in range(1, 101):
        A = random.choices(range(2 ** 28), k=N)
        B = random.choices(range(2 ** 28), k=N)
        print('Checking the case with size: {}'.format(N))
        assert simple_solution(N, A, B) == solution(N, A, B)
    print('OK')


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    print(solution(N, A, B))


if __name__ == '__main__':
    main()
    # check()

### FIXED CODE ###

import numpy as np


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    pow_2_k = 1
    ans = 0
    for k in range(30):
        MA = A % (2 * pow_2_k)
        MB = B % (2 * pow_2_k)
        MB.sort()
        # [2**k, 2 * (2**k)) か [3 * (2**k), 4 * (2**k)) の中に入るとk-bit目が1。
        # この a + b の数をカウントする。
        # → [2**k - a, 2 * (2**k) - a) か [3 * (2**k) - a, 4 * (2**k) - a) の中に入る b の数をカウント。
        cnt = 0
        indices_1 = np.searchsorted(MB, pow_2_k - MA, side='left')
        indices_2 = np.searchsorted(MB, 2 * pow_2_k - MA, side='left')
        indices_3 = np.searchsorted(MB, 3 * pow_2_k - MA, side='left')
        cnt += ((N - indices_1) - (N - indices_2) + (N - indices_3)).sum()
        if cnt % 2 == 1:
            ans += pow_2_k
        pow_2_k *= 2
    print(ans)


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

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

import itertools

n = int(input())
s = [[] for _ in range(n)]
for i in range(n):
    s[i] = list(input())

delete = []

for i in range(n):
    if s[i][0] == "M" or s[i][0] == "A" or s[i][0] == "R" or s[i][0] == "C" or s[i][0] == "H":
        pass
    else:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del s[delete[i] - diff]
    diff += 1

cand = list(itertools.combinations(s,3))

ans = 0
for i in range(len(cand)):
    if cand[i][0][0] != cand[i][1][0] and cand[i][1][0] != cand[i][2][0] and cand[i][2][0] != cand[i][0][0]:
        ans += 1

print(ans)


### FIXED CODE ###

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

import itertools

n = int(input())
s = [[] for _ in range(n)]
for i in range(n):
    s[i] = list(input())

delete = []

for i in range(n):
    if s[i][0] == "M" or s[i][0] == "A" or s[i][0] == "R" or s[i][0] == "C" or s[i][0] == "H":
        pass
    else:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del s[delete[i] - diff]
    diff += 1

cand = [0,0,0,0,0]
for i in range(len(s)):
    if s[i][0] == "M":
        cand[0] += 1
    if s[i][0] == "A":
        cand[1] += 1
    if s[i][0] == "R":
        cand[2] += 1
    if s[i][0] == "C":
        cand[3] += 1
    if s[i][0] == "H":
        cand[4] += 1

ans = 0

for i in range(5):
    for j in range(5):
        if i == j:
            break
        for k in range(5):
            if i == k:
                break
            if j == k:
                break
            ans += int(cand[i] * cand[j] * cand[k])

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

N, A, B = map(int, input().split())
str = ''

if A == 0:
  print(0)
  exit()
  
for _ in range(N):
  for i in range(A):
    if len(str) < N:
      str += 'b'
  for j in range(B):
    if len(str) < N:
      str += 'r'

print(str.count('b'))

### FIXED CODE ###

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

H, W = map(int, input().split())
A = []
q = []
for i in range(H):
  As = list(input())
  A.append(As)
  for j in range(W):
    if A[i][j] == "#":
      q.append((i, j))
r = 0
while q:
  q2 = []
  for i, j in q:
    if i-1 >= 0 and A[i-1][j] == ".":
      A[i-1][j] = "#"
      q2.append((i-1, j))
    if i+1 < H and A[i+1][j] == ".":
      A[i+1][j] = "#"
      q2.append((i+1, j))
    if j-1 >= 0 and A[i][j-1] == ".":
      A[i][j-1] = "#"
      q2.append((i, j-1))
    if j+1 < W and A[i][j+1] == ".":
      A[i][j+1] = "#"
      q2.append((i, j+1))
  q = q2
  r += 1
r -= 1
print(r)


### FIXED CODE ###

H, W = map(int, input().split())
A = []
q = []
for i in range(H):
  As = list(input())
  A.append(As)
  for j in range(W):
    if A[i][j] == "#":
      q.append((i, j))
r = 0
while q:
  q2 = []
  for i, j in q:
    if i-1 >= 0 and A[i-1][j] == ".":
      A[i-1][j] = "#"
      q2.append((i-1, j))
    if i+1 < H and A[i+1][j] == ".":
      A[i+1][j] = "#"
      q2.append((i+1, j))
    if j-1 >= 0 and A[i][j-1] == ".":
      A[i][j-1] = "#"
      q2.append((i, j-1))
    if j+1 < W and A[i][j+1] == ".":
      A[i][j+1] = "#"
      q2.append((i, j+1))
  q = q2
  r += 1
r -= 1
print(r)
### BUGGY CODE ###

INTMAX = (1<<31) - 1

def update():
    for i in range(_N):
        x = i+N-1
        A[x] = arr[i]
        while x > 1:
            x >>= 1
            y = x<<1
            l = A[y]
            r = A[y+1]
            A[x] = l if l < r else r#min(l,r)

def find():
    res = [0]*(_N-k+1)
    for i in range(_N-k+1):
        l = i+N-1
        r = i+k+N-1
        z = INTMAX
        while l < r:
            if l & 1:
                if(A[l] < z):
                    z = A[l]
                l += 1
            if r & 1:
                r -= 1
                if(A[r] < z):
                    z = A[r]
            l >>= 1
            r >>= 1
        res[i] = z
    print(*res)

_N,k = map(int,input().split())
*arr, = map(int,input().split())
N = 1
N = 2**(_N-1).bit_length()
A = [INTMAX]*(N<<1)
update()
find()



### FIXED CODE ###

INTMAX = (1<<31) - 1

def ans():
    for i in range(k):
        x = i + OFS
        A[x] = arr[i]
        while True:
            if(x <= 0):
                break
            x = (x - 1)//2
            l = A[x*2+1]
            r = A[x*2+2]
            A[x] = l if l < r else r#min(tree[left],tree[right])
    res = []
    c = 0
    for i in range(_N-k):
        res.append(A[0])
        x = c + OFS
        A[x] = arr[i+k]
        while True:
            if(x <= 0):
                break
            x = (x - 1)//2
            l = A[x*2+1]
            r = A[x*2+2]
            A[x] = l if l < r else r
        c += 1
        if(c == k):
            c = 0
    res.append(A[0])
    print(*res)

_N,k = map(int, input().split())
*arr, = map(int,input().split())
if(k==1):
    print(*arr)
else:
    N = 2**(_N-1).bit_length()
    A = [INTMAX]*(2*N)
    OFS = N - 1
    ans()