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

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

def check(lst):
    for i in range(N):
        if lst[i] != N:
            return False
    return True

def move(lst):
    tmp = [0] * (N + 1)
    for i in range(N):
        a = lst[i]
        left = max(0, i - a)
        right = min(N, i + a + 1)
        tmp[left] += 1
        tmp[right] -= 1
    for i in range(N):
        tmp[i + 1] += tmp[i]
    return tmp

for i in range(K):
    A = move(A)
    if check(A):
        # print (i)
        break

print (*A[:-1])


### FIXED CODE ###

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

def check(lst):
    for i in range(N):
        if lst[i] != N:
            return False
    return True

def move(lst):
    tmp = [0] * (N + 1)
    for i in range(N):
        a = lst[i]
        left = max(0, i - a)
        right = min(N, i + a + 1)
        tmp[left] += 1
        tmp[right] -= 1
    for i in range(N):
        tmp[i + 1] += tmp[i]
    return tmp

for i in range(K):
    A = move(A)
    if check(A):
        # print (i)
        break

print (*A[:-1])
### BUGGY CODE ###

import itertools

N,X,Y = map(int,input().split())
n = list(range(1,N+1))
l = []
for v in itertools.combinations(n,2):
  l.append(min(abs(Y-v[1]) + abs(X-v[0]) + 1,abs(X-v[1]) + abs(Y-v[0]) + 1,v[1] - v[0]))
for k in range(1,N):
  print(l.count(k))

### FIXED CODE ###

import itertools

N,X,Y = map(int,input().split())
n = list(range(1,N+1))
l = [0]*N
for v in itertools.combinations(n,2):
  l[min(abs(Y-v[1]) + abs(X-v[0]) + 1,v[1] - v[0])] += 1
for k in range(1,N):
  print(l[k])
### BUGGY CODE ###

n = int(input())
a = sorted(list(map(int,input().split())))
arr = [0]*(max(a)+1)

for i in a:
  arr[i]+=1
  tmp = i
  if arr[i]<=1:
      while (tmp+i)<=max(a):
        tmp += i
        if arr[tmp] !=0:
          arr[tmp] =2
        else:
          arr[tmp] +=1

cnt = 0
for i in a:
  if arr[i] ==1:
    cnt += 1
print(cnt)
      

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=max(a)
alist=[0]*(m+1)
for i in a:
  for j in range(i,m+1,i):
    alist[j]+=1
cnt=0
for i in a:
  if alist[i]==1:
    cnt+=1
print(cnt)
### BUGGY CODE ###

def main():
    from math import ceil

    N, K = map(int, input().split())
    *A, = map(int, input().split())

    def binary_search(*, ok, ng, func):
        for _ in range(80):
            mid = (ok + ng) / 2
            if func(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def is_ok(mid):
        cnt = 0
        for x in A:
            cnt += x // mid
            if x % mid == 0:
                cnt -= 1
        return cnt <= K

    ma = max(A)
    res = binary_search(ok=ma, ng=0, func=is_ok)

    print(ceil(res))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from math import ceil

    N, K = map(int, input().split())
    *A, = map(int, input().split())

    def binary_search(*, ok, ng, func):
        for _ in range(60):
            mid = (ok + ng) / 2
            if func(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def is_ok(mid):
        cnt = 0
        for x in A:
            q, r = divmod(x, mid)
            cnt += q
            if r == 0:
                cnt -= 1
        return cnt <= K

    ma = max(A)
    res = binary_search(ok=ma, ng=0, func=is_ok)

    print(ceil(res))


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

import sys, os, math

def get_cd(n):
    cd = []
    for i in range(1, int(n/2)+1):
        if n % i == 0:
            cd.append(i)
        else:
            continue
    cd.append(n)
    return cd

def get_gcd(a, b, c, cd_d):
    if 1 in [a, b, c]:
        return 1
    else:
        min_v = min([a,b,c])
        cds_min = cd_d[min_v]
        gcd = 1
        cd = sorted(list(set(cd_d[a]) & set(cd_d[b]) & set(cd_d[c])))
        return cd[-1]

if __name__ == '__main__':
    k = int(input())
    cc_d = {}
    for i in range(1, k+1):
        cc_d[i] = get_cd(i)

    computed_d = {}
    s = 0
    for a in range(1, k+1):
        for b in range(a, k+1):
            for c in range(b, k+1):
                if a == b == c:
                    s += a
                else:
                    gcd = get_gcd(a, b, c, cc_d)
                    if a != b != c:
                        s += gcd*6
                    else:
                        s += gcd*3
    print(s)

### FIXED CODE ###

import sys, os, math

def get_cd(n):
    cd = []
    for i in range(1, int(n/2)+1):
        if n % i == 0:
            cd.append(i)
        else:
            continue
    cd.append(n)
    return cd

def get_gcd(a, b, c, cd_d):
    if 1 in [a, b, c]:
        return 1
    else:
        cd = sorted(list(set(cd_d[a]) & set(cd_d[b]) & set(cd_d[c])))
        return cd[-1]

if __name__ == '__main__':
    k = int(input())
    cc_d = {}
    for i in range(1, k+1):
        cc_d[i] = get_cd(i)

    computed_d = {}
    s = 0
    for a in range(1, k+1):
        for b in range(a, k+1):
            for c in range(b, k+1):
                if a == b == c:
                    s += a
                else:
                    gcd = get_gcd(a, b, c, cc_d)
                    if a != b != c:
                        s += gcd*6
                    else:
                        s += gcd*3
    print(s)
### BUGGY CODE ###

N,Q = list(map(int,input().split()))
S = input()

for _ in range(Q):
    l,r = list(map(int,input().split()))
    print(S[l-1:r].count("AC"))


### FIXED CODE ###

# -*- coding: utf-8 -*-
n,q = list(map(int,input().split()))
s = input()
s2 = s[1::]
d = [list(map(int,input().split())) for i in range(q)]

#AC開始位置を記録する
ac_idx = []

aci_append = ac_idx.append
for i,v in enumerate(zip(s,s2)):
    if v == ("A","C"):
        aci_append(i)

#2分探索, nibuntansaku,二分探索
from bisect import bisect_left

for l,r in d:
    print(bisect_left(ac_idx,r-1) - bisect_left(ac_idx,l-1))
### BUGGY CODE ###

N = int(input())
S = str(input())

Z = [0 for _ in range(N)]
Z[0] = N

def momokuroz(s):
  Max = 0
  n = len(s)
  z = [0 for _ in range(n)]
  z[0] = n
  i = 1; j = 0
  while i < n: #iは基準の位置。
    while i+j < n and s[i+j] == s[j]:
      j += 1 #何文字一致してるかなー？
    z[i] = min(i,j) #jが一致している文字数。
    Max = max(Max,z[i])
    if j == 0:
      i += 1
      continue
    
    k = 1 #途中でjを超えていたらその先は別途見る必要がある。
    #kが一致してる文字数ぴったしだとその先は不明。k<j
    #j文字一致しているところを参照したいが飛び出していたらそこは不明。k+Z[k]<j
    while k<j and k+z[k] <j:
      z[i+k] = z[k]
      k += 1
    
    i += k #基準位置を動かす
    j -= k #このjまでは一致しているのは確定なので上のWhileに戻ってチェック。
  #MAX = max(z[1:])
  #print(Max,s,z)
  return Max

ans = 0    
for i in range(N-1):
  temp = S[i:]
  a = momokuroz(temp)
  ans = max(ans,a)


print(ans)

### FIXED CODE ###

class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + ord(s[i])) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod
    def get(self, l, r): #S[l:r]indexでいうl文字目からr-l文字目。r-l文字。
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

    def check(self, d):
        ma = {}
        for i in range(N-d+1): #0からN-dまで
            p = self.get(i,i+d)
            if p in ma:
                if i - ma[p] >= d: #d文字以上離れているか
                  return True
            else:
                ma[p] = i
        return False
            
              
N =int(input())
S = str(input())

base1 = 1007
mod1 = 10**9+7

RH = RollingHash(S,base1,mod1)

left = 0
right = N//2+1
while right - left >1:
  mid = (left+right)//2
  if RH.check(mid): #こちらがokの方
    left = mid
  else:
    right = mid

print(left)
### 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()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

A = A[:K+1]
B = B[:K+1]
C = C[:K+1]

E = []
for a in range(len(A)):
    for b in range(len(B)):
        E.append(A[a]+B[b])

E.sort(reverse=True)
E = E[:K+1]

ans = []
for c in range(len(C)):
    for e in range(len(E)):
        ans.append(C[c]+E[e])
        
ans.sort(reverse=True)

for i in range(K):
    print(ans[i])

### FIXED 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()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

sum = []
for x in range(X):
    for y in range(Y):
        for z in range(Z):
            if (x+1)*(y+1)*(z+1) <= K:
                sum.append(A[x] + B[y] + C[z])
            else:
                break

sum.sort(reverse=True)
for i in range(K):
    print(sum[i])
### BUGGY CODE ###

N=int(input())
S=input()

arr=[]
for i in range(N):
    cnt=0
    cnt+=S[0:i].count('W')
    cnt+=S[i+1:N].count('E')
    arr.append(cnt)
print(min(arr))

### FIXED CODE ###

N=int(input())
S=input()
cnt_W=0
cnt_E=0
arr_W=[]
arr_E=[]
for s in S:
    if s=='W':
        cnt_W+=1
    arr_W.append(cnt_W)

for s in S[::-1]:
    if s=='E':
        cnt_E+=1
    arr_E.append(cnt_E)

import numpy as np

print((np.array(arr_W)+np.array(arr_E[::-1])).min()-1)
### BUGGY CODE ###

import itertools
n = int(input())
l = [int(input()) for i in range(n)]
combo = [list(itertools.combinations(l, i)) for i in range(1, n+1)]
ans = 0
for i in combo:
  for j in i:
    temp = sum(list(j))
    if temp > ans and not temp % 10 == 0:
      ans = temp

print(ans)

### FIXED CODE ###

n = int(input())
l = [int(input()) for i in range(n)]
def f():
  ans = sum(l)
  if ans % 10 == 0:
    for i in sorted(l):
      if not (ans - i) % 10 == 0:
        return ans-i
    return 0
  else:
    return ans

print(f())
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a.sort(reverse=True),b.sort(reverse=True),c.sort(reverse=True)
ab = []
for i in range(x):
  for j in range(y):
    ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab = ab[0:k]
abc = []
for i in ab:
  for j in c:
    abc.append(i+j)
abc.sort(reverse=True)
abc = abc[0:k]
for i in abc:
  print(i)

### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a.sort(reverse=True),b.sort(reverse=True),c.sort(reverse=True)
ab = []
for i in range(x):
  for j in range(y):
    ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab = ab[0:k]
abc = []
for i in ab:
  for j in c:
    abc.append(i+j)
abc.sort(reverse=True)
abc = abc[0:k]
for i in abc:
  print(i)
### BUGGY CODE ###

import re
S = input()
work=S
while(len(work)>=0):
    if('01' in work):
        work = re.sub('01','',work)
    elif('10' in work):
        work = re.sub('10','',work)
    else:#01 or 10 の羅列も見つけることができなかった
        break

print(len(S)-len(work))

### FIXED CODE ###


S = input()
work=list(S)
i=0
o_cout=0
z_cout=0
for x in work:
    if(x=='1'):
        o_cout+=1
    else:
        z_cout+=1
    
if(o_cout>z_cout):
    cout=z_cout
else:
    cout=o_cout
    

print(cout*2)
### BUGGY CODE ###

N,M = map(int,input().split())
to = [[] for _ in range(N*3)]
for i in range(M):
  a,b = map(int,input().split())
  a-=1;b-=1
  to[a*3].append(b*3+1)
  to[a*3+1].append(b*3+2)
  to[a*3+2].append(b*3)
start,end = map(int,input().split())
start -= 1;end -= 1
#print(to)
INF = float("inf")
Stack = [start*3]
visit = [INF for _ in range(N*3)]
visit[start*3] = 0
while Stack:
  v = Stack.pop()
  for w in to[v]:
    if visit[w] <= visit[v]+1:
      continue
    visit[w] = min(visit[w],visit[v]+1) 
    Stack.append(w) #step歩目でwにいて次vへ行く。

#print(visit)
if visit[end*3] == INF:
  ans = -1
else:
  ans = visit[end*3]//3
print(ans)

### FIXED CODE ###

from collections import deque
N,M = map(int,input().split())
to = [[] for _ in range(N*3)]
for i in range(M):
  a,b = map(int,input().split())
  a-=1;b-=1
  to[a*3].append(b*3+1)
  to[a*3+1].append(b*3+2)
  to[a*3+2].append(b*3)
start,end = map(int,input().split())
start -= 1;end -= 1
#print(to)
INF = float("inf")
Q = deque([start*3])
visit = [INF for _ in range(N*3)]
visit[start*3] = 0
while Q:
  v = Q.popleft()
  for w in to[v]:
    if visit[w] != INF:
      continue
    visit[w] = visit[v]+1
    if w == end*3:
      print(visit[w]//3)
      exit()
    Q.append(w) #step歩目でwにいて次vへ行く。

#print(visit)
if visit[end*3] == INF:
  ans = -1
else:
  ans = visit[end*3]//3
print(ans)
### BUGGY CODE ###

from itertools import permutations
 
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    n=len(d[0])
    for k in range(n):
        for i in range(n):
            for j in range(n):
              s = d[i][k] + d[k][j]
              d[i][j] = min(d[i][j],s)
    return d
 
N,M,R=[int(x) for x in input().split()]
r=[int(x)-1 for x in input().split()]
 
#INF = float("inf")
route_list=[[10**8]*N for _ in range(N)]
 
for i in range(M):
    a,b,c=[int(x) for x in input().split()]
    route_list[a-1][b-1]=c
    route_list[b-1][a-1]=c
 
wa_list=warshall_floyd(route_list)
ans=30**9
 
for perm in permutations(r):
    #print(perm)
    cur = sum(wa_list[v][u] for v, u in zip(perm, perm[1:]))
    ans = min(ans, cur)
 
print(ans)


### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import dijkstra
import itertools
from scipy.sparse import csr_matrix
inf = 1 + 10**8
n, m, r = list(map(int, input().split()))
r = list(map(int, input().split()))
graph = np.full((n+1,n+1), inf)
for i in range(m):
    a,b,c = list(map(int, input().split()))
    graph[a][b] = c
    graph[b][a] = c
p_list = list(itertools.permutations(r,len(r)))
graph = dijkstra(csr_matrix(graph))
min_cost = inf * 200
for i in p_list:
    candidate = 0
    for j in range(len(i) - 1):
        candidate += graph[i[j]][i[j + 1]]
    if min_cost > candidate:
        min_cost = candidate
print(int(min_cost))
### BUGGY CODE ###

#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=list(input())
c=Counter(s)
c=c.values()
ans=len(s)
mod=10**9+7
for i in range(2,len(c)+1):
    for l in itertools.combinations(c,i):
        res=1
        for j in l:
            res*=j
            res%=mod
        ans+=res
        ans%=mod
print(ans)

### FIXED CODE ###

#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=list(input())
c=Counter(s)
c=c.values()
ans=1
mod=10**9+7
for i in c:
    ans*=(i+1)
    ans%=mod
print(ans-1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

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

dp = [[None] * len(a) for _ in a]


def solve(i, j):
    if dp[i][j]:
        return dp[i][j]

    if i == j:
        return a[i]

    dp[i][j] = max(a[j] - solve(i, j-1), a[i] - solve(i+1, j))
    return dp[i][j]


print(solve(0, len(a) - 1))


### FIXED CODE ###

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

dp = [[None] * len(a) for _ in a]

for i in range(len(a)-1, -1, -1):
    for j in range(i, len(a)):
        if i == j:
            dp[i][j] = a[i]
            continue

        dp[i][j] = max(a[j] - dp[i][j-1], a[i] - dp[i+1][j])

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

n,m = map(int,input().split())
As = list(map(int,input().split()))
for i in range(m):
  As.sort(reverse = True)
  As[0] = int(As[0]/2)
print(sum(As))
  




### FIXED CODE ###

import heapq

n,m = map(int,input().split())
As = [-i for i in list(map(int,input().split()))]
heapq.heapify(As)
for i in range(m):
  a = -heapq.heappop(As)
  heapq.heappush(As,-int(a/2))
print(-sum(As))
### BUGGY CODE ###

N, M = map(int,raw_input().split())
gra = [set() for n in range(N)]

start = set(range(N))
for m in range(M) :
  x, y = map(int,raw_input().split())
  gra[x-1].add(y-1)
  start.discard(y-1)

mem = [None for n in range(N)]
q = list(start)
for i in q : mem[i] = 0

longest = 0
while q :
  cur = q.pop()
  for nxt in gra[cur] :
    mem[nxt] = mem[cur] + 1
    longest = max(longest, mem[nxt])
    q.append(nxt)

print longest

### FIXED CODE ###

N, M = map(int,raw_input().split())
gra = [set() for n in range(N)]
ins = [0] * N

start = set(range(N))
for m in range(M) :
  x, y = map(int,raw_input().split())
  gra[x-1].add(y-1)
  ins[y-1] += 1
  start.discard(y-1)

mem = [None for n in range(N)]
q = list(start)
for i in q : mem[i] = 0

longest = 0
while q :
  cur = q.pop(0)
  for nxt in gra[cur] :
    ins[nxt] -= 1
    if ins[nxt] == 0 :
      mem[nxt] = mem[cur] + 1
      longest = max(longest, mem[nxt])
      q.append(nxt)

print longest
### BUGGY CODE ###

def resolve():
    import numpy as np
    from scipy.sparse.csgraph import shortest_path
    from scipy.sparse import csr_matrix
    n, x, y = map(int, input().split())
    netw = [[0]*n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if abs(j-i) == 1:
                netw[i][j] = 1
    netw[x-1][y-1] = 1
    netw[y-1][x-1] = 1
    netw = np.array(netw)
    ans = {}
    a = shortest_path(netw)
    for i in range(n-1):
        for j in range(i+1, n):
            if a[i][j] in ans:
                ans[a[i][j]] += 1
            else:
                ans[a[i][j]] = 1
    for i in range(1, n):
        if i in ans:
            continue
        else:
            ans[i] =0
    for i in range(1, n):
        print(ans[i])
resolve()

### FIXED CODE ###

def resolve():
    n,x,y = map(int, input().split())
    ans = {}
    for i in range(1, n):
        for j in range(i+1, n+1):
            dist1 = j-i
            dist2 = abs(x-i)+1+abs(y-j)
            dist =min (dist1, dist2)
            if dist in ans:
                ans[dist] += 1
            else:
                ans[dist] = 1
    for i in range(1,n):
        if i not in ans:
            ans[i] =0
        print(ans[i])
resolve()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
H, W = map(int, input().split())
map = [list(input()) for i in range(H)]
queue = list()
for x in range(H):
    for y in range(W):
        if map[x][y]=="#":
            queue.append([x, y])
def check_all_black():
    global map
    for x in range(H):
        for y in range(W):
            if map[x][y]==".":
                break
        else:
            continue
        break
    else:
        return True
    return False
count = 0
if check_all_black():
    print(count)
    exit()
while queue:
    next_queue = list()
    for x, y in queue:
        for nx, ny in [[x-1, y], [x+1, y], [x, y-1], [x, y+1]]:
            if 0<=nx<H and 0<=ny<W:
                if map[nx][ny]==".":
                    map[nx][ny] = "#"
                    next_queue.append([nx, ny])
    queue = next_queue
    count += 1
    if check_all_black():
        break
print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque
H, W = map(int, input().split())
map = [list(input()) for i in range(H)]
checked = list()
queue = deque()
for x in range(H):
    checked.append(list())
    for y in range(W):
        if map[x][y]=="#":
            checked[x].append(True)
            queue.append((x, y, 0))
        else:
            checked[x].append(False)
neighbors = [(1,0), (0,1), (-1,0), (0,-1)]
while queue:
    x, y, res = queue.popleft()
    for dx, dy in neighbors:
        nx, ny = x+dx, y+dy
        if 0<=nx<H and 0<=ny<W:
            if not checked[nx][ny]:
                queue.append((nx, ny, res+1))
                checked[nx][ny] = True
print(res)
### BUGGY CODE ###

import numpy as np
from math import factorial

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

dic = {}
after = {}

newdata = np.unique(A)
for i in range(len(newdata)):
	x = np.sum(A == newdata[i])
	dic[newdata[i]] = x * (x - 1) // 2
	after[newdata[i]] = (x - 1) * (x - 2) // 2

numsum = sum(dic.values())

ans = {}
for key in dic.keys():
	ans[key] = numsum - dic[key] + after[key]

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



### FIXED CODE ###

import numpy as np
import collections

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

dic = {}
after = {}

l = collections.Counter(A)

for key, val in l.items():
	dic[key] = val * (val - 1) // 2
	after[key] = (val - 1) * (val - 2) // 2

numsum = sum(dic.values())

ans = {}
for key in dic.keys():
	ans[key] = numsum - dic[key] + after[key]

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

x=input().replace("ST","")
while "ST" in x:
    x=x.replace("ST","")
print(len(x))

### FIXED CODE ###

x=list(input())
stack=[]
for i in range(len(x)):
    if x[i]=="S":
        stack.append(x[i])
    elif x[i]=="T" and len(stack)==0:
        stack.append(x[i])
    elif x[i]=="T" and stack[-1]=="T":
        stack.append(x[i])
    elif x[i]=="T" and stack[-1]=="S":
        stack.pop()
print(len(stack))
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
maxa = max(A)
for i in range(N):
    if maxa == A[i]:
        tmp = A[i]
        A[i] = 0
        print(max(A))
        A[i] = tmp
    else:
        print(maxa)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
maxind = A.index(max(A))
maxa = max(A)
A = sorted(A)
ans = [maxa]*maxind
ans.append(A[-2])
[ans.append(i) for i in [maxa]*(N-maxind-1)]
print(*ans,sep="\n")
### BUGGY CODE ###

def maxHeapify(H, A, i):
    left = 2*i
    right = left + 1
 
    if left <= H and A[left] > A[i]:
        largest = left
    else: largest = i
    if right <= H and A[right] > A[largest]:
        largest = right
    if largest != i:
        A[i], A[largest] = A[largest],A[i]
        maxHeapify(H,A,largest)
 
def buildmaxHeap(H,A):
    for i in range(H//2,0,-1):
        maxHeapify(H,A,i)

A = [None]
L = input()
while L !="end":
    L = L.split()
    if L[0] == "insert":
        A.append(int(L[1]))
        buildmaxHeap(len(A) - 1, A)
    else:
        print(str(A[1]))
        A = [None] + A[2:]
        buildmaxHeap(len(A) - 1, A)
    L = input()

### FIXED CODE ###

import heapq
pq = []

def insert(S,k):
    heapq.heappush(pq, - k)

def extractMax(S):
    a = - heapq.heappop(S)
    print(str(a))

L = input()
while L != "end":
    if L =="extract":
        extractMax(pq)
    else:
        L = L.split()
        insert(pq, int(L[1]))
    L = input()
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
dp = [1]*(max(a)+1)
his = []
for i in range(n):
    if a[i] in his:
        dp[a[i]] = 0
    else:
        his.append(a[i])
        for j in range(a[i]*2,len(dp),a[i]):
            dp[j] = 0

sum = 0
for i in range(n):
    if dp[a[i]] == 1:
        sum += 1
print(sum)

### FIXED CODE ###

import collections

n = int(input())
a = list(map(int,input().split()))
cnt = collections.Counter(a)
#print(cnt)
a.sort()
dp = [1]*(max(a)+1)

sum = 0
for i in range(n):
    for j in range(a[i]*2,len(dp),a[i]):
            dp[j] = 0
    if dp[a[i]] == 1 and cnt[a[i]]==1:
        sum += 1

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

import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)
print(ans)


### FIXED CODE ###

import math
from functools import reduce

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

k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)
print(ans)
### BUGGY CODE ###

import math
N = int(input())
ans = 10
for A in range(1, N+1):
  if N % A == 0:
    B = N//A
    F = max(len(str(A)), len(str(B)))
    if ans > F:
      ans = F 
print(ans)

### FIXED CODE ###

import math
N = int(input())
ans = 10
for A in range(1, int(math.sqrt(N))+1):
  if N % A == 0:
    B = N//A
    F = max(len(str(A)), len(str(B)))
    if ans > F:
      ans = F 
print(ans)