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

import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[0]]
for i in range(1, N):
  if A[i] <= B[0]:
    B.insert(0, A[i])
  else:
    index = bisect.bisect_left(B, A[i]) - 1
    B[index] = A[i]
print(len(B))


### FIXED CODE ###

import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[N - 1]]
for i in reversed(range(0, N - 1)):
  if A[i] >= B[-1]:
    B.append(A[i])
  else:
    index = bisect.bisect_right(B, A[i])
    B[index] = A[i]
print(len(B))
### BUGGY CODE ###

import string
def main():
    a = string.ascii_lowercase
    list = []
    num = int(input())

    while(num >= 0):
        list.append(num % 26)
        num = num // 26

    ans = []
    for i in range(1,len(list)+1):
        ans.append(a[list[len(list) - i] - 1])

    print(''.join(ans))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    a = [chr(ord('a') + i) for i in range(26)]
    a.insert(0,"a")
    list = []
    num = int(input()) 

    while(num > 0):
        if(num % 26 == 0):
            list.append(26)
            num = num // 26 -1
            continue
        else:
            list.append(num % 26)
        num = num // 26

    list.reverse()

    ans = []
    for i in range(0,len(list)):
        ans.append(a[list[i]])
    print(''.join(ans))
    


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

#n: id card
#m: gate
n, m = map(int, input().split())
data = [0 for i in range(n+1)]
ans = 0

for i in range(m):
    l, r = map(int, input().split())
    for j in range(l, r+1):
        data[j] += 1
        if data[j] == m:
            ans += 1

print(ans)

### FIXED CODE ###

#n: id card
#m: gate
n, m = map(int, input().split())
data = [0 for i in range(n+1)]

for i in range(m):
    l, r = map(int, input().split())
    data[l-1] += 1
    data[r] -= 1

for i in range(n):
    data[i+1] += data[i]

print(data.count(m))
### BUGGY CODE ###

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

ans = 1
if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans > 10 ** 18:
            ans = -1   
        else:
            pass
    print(ans)

### FIXED CODE ###

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

ans = 1
if 0 in A:
    print(0)
else:
    for i in range(n):
        if ans > 10 ** 9:
            if A[i] >= 10 ** 9:
                ans = -1
                break
            else:
                pass
        else:
            pass
        ans *= A[i]
        if ans > 10 ** 18:
            ans = -1
            break
        else:
            pass
    print(ans)
### BUGGY CODE ###

def sarch(listd, num, i):
    if listd[i - 2] == num:
        return 1
    return 0

N, M = map(int, input().split())
data = []
brige = []
for i in range(M):
    A, B = map(int, input().split())
    data.append(B)
    listdata = [0 for j in range(1, A)]
    for j in range(A, B):
        listdata.append(j)
    listdata.extend([0 for j in range(B, N)])
    brige.append(listdata)


ans = []


keylist = [0 for i in range(M)]

for i in range(1, N + 1):
    for j in range(M):
        if keylist[j] != 1 and sarch(brige[j], i, data[j]) == 1:
            ans.append(i)
            for k in range(M):
                if brige[k][i - 1] == i:
                    keylist[k] = 1
            keylist[j] = 1


print(len(ans))


### FIXED CODE ###

N, M = map(int, input().split())
AB = []
for i in range(M):
    a, b = map(int, input().split())
    AB.append([b, a])
AB.sort()
for i in range(M):
    if i == 0:
       j = AB[i][0] - 1
       ans = 1
    else:
        if AB[i][1] <= j and j < AB[i][0]:
            1
        else:
            j = AB[i][0] - 1
            ans += 1

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

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

    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        g[A[i]-1].append(B[i]-1)
        g[B[i]-1].append(A[i]-1)

    ans_list = [-1] * N

    queue = [0]
    seen = [False]*N

    while queue:
        qi = queue.pop(0)
        # qi から 1 遠い頂点が gi
        for gi in g[qi]:
            if seen[gi] == False:
                queue.append(gi)
                if ans_list[gi] == -1:
                    ans_list[gi] = qi
                    seen[gi] = True

    print("Yes")
    for ans in ans_list[1:]:
        print(ans+1)  # 1-index に直す

if __name__ == "__main__":
    main()


### FIXED CODE ###

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

    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        g[A[i]-1].append(B[i]-1)
        g[B[i]-1].append(A[i]-1)

    ans_list = [-1] * N

    queue = [0]
    seen = [False]*N

    while queue:
        qi = queue.pop(0)
        # qi から 1 遠い頂点が gi
        for gi in g[qi]:
            if seen[gi] == False:
                queue.append(gi)
                if ans_list[gi] == -1:
                    ans_list[gi] = qi
                    seen[gi] = True

    print("Yes")
    for ans in ans_list[1:]:
        print(ans+1)  # 1-index に直す

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

mod = 998244353
size = 1 << 20
dat = [-mod] * (size * 2 - 1)
def seg_max(a, b, k = 0, l = 0, r = size):
    if r <= a or b <= l:
        return -mod
    if a <= l and r <= b:
        return dat[k]
    vl = seg_max(a, b, k * 2 + 1, l, (l + r) // 2)
    vr = seg_max(a, b, k * 2 + 2, (l + r) // 2, r)
    return max(vl, vr)

def seg_update(i, x):
    i += size - 1
    dat[i] = x
    while i > 0:
        i = (i - 1) // 2
        dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);

N = int(input())
tmpX = []
for i in range(N):
    x, d = list(map(int, input().split()))
    tmpX.append((x, d))
tmpX.sort()


X, D = [0] * N, [0] * N
for i in range(N):
    X[i] = tmpX[i][0]
    D[i] = tmpX[i][1]

to = [0] * N
for i in range(N):
    seg_update(i, i)

for i in range(N-1, -1, -1):
    ok = i
    ng = N
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if X[i] + D[i] > X[mid]:
            ok = mid
        else :
            ng = mid
    to[i] = seg_max(i, ok+1)
    seg_update(i, to[i])

dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
    dp[i+1] += dp[i]
    dp[i+1] %= mod
    dp[to[i]+1] += dp[i]
    dp[to[i]+1] %= mod
print(dp[N])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

mod = 998244353

# segment tree
def init_max(init_max_val, n):
    #set_val
    for i in range(n):
        seg_max[i+num_max-1]=init_max_val[i]
    #built
    for i in range(num_max-2,-1,-1) :
        seg_max[i]=max(seg_max[2*i+1],seg_max[2*i+2])

def update_max(k,x):
    k += num_max-1
    seg_max[k] = x
    while k:
        k = (k-1)//2
        seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])

def query_max(p,q):
    if q<=p:
        return ide_ele_max
    p += num_max-1
    q += num_max-2
    res=ide_ele_max
    while q-p>1:
        if p&1 == 0:
            res = max(res,seg_max[p])
        if q&1 == 1:
            res = max(res,seg_max[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = max(res,seg_max[p])
    else:
        res = max(max(res,seg_max[p]),seg_max[q])
    return res

#####単位元######
ide_ele_max = -1

#num_max:n以上の最小の2のべき乗
num_max = 1 << 18
seg_max=[ide_ele_max]*2*num_max



N = int(input())
tmpX = []
for i in range(N):
    x, d = list(map(int, input().split()))
    tmpX.append((x, d))
tmpX.sort()


X, D = [0] * N, [0] * N
for i in range(N):
    X[i] = tmpX[i][0]
    D[i] = tmpX[i][1]

to = [0] * N
for i in range(N):
    to[i] = i
init_max(to, N)

for i in range(N-1, -1, -1):
    ok = i
    ng = N
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if X[i] + D[i] > X[mid]:
            ok = mid
        else :
            ng = mid
    to[i] = query_max(i, ok+1)
    update_max(i, to[i])

dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
    dp[i+1] += dp[i]
    dp[i+1] %= mod
    dp[to[i]+1] += dp[i]
    dp[to[i]+1] %= mod
print(dp[N])
### BUGGY CODE ###

import bisect
n,m=map(int, input().split())
pl=[0]*100000
yl=[0]*100000
ol=[[] for i in range(100001)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(1,n+1):
    ol[i].sort()
for i in range(m):
    print("%06d%06d" % (pl[i], ol[pl[i]].index(yl[i])+1))

### FIXED CODE ###

import bisect
n,m=map(int, input().split())
pl=[0]*100000
yl=[0]*100000
ol=[[] for i in range(100001)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(1,n+1):
    ol[i].sort()
for i in range(m):
    print("%06d%06d" % (pl[i], bisect.bisect_right(ol[pl[i]], yl[i])))
### BUGGY CODE ###

from collections import deque
S = input()
Q = int(input())
add_left = ""
add_right = ""
not_reversed = True
for _ in range(Q):
    query = list(input().split())
    if query[0] == "1":
        not_reversed = not not_reversed 
        continue
    
    else:
        if not_reversed == 1 and query[1] == "1":
            add_left = query[2] + add_left

        elif not not_reversed == -1 and query[1] == "1":
            add_right = add_right + query[2]

        if not_reversed == 1 and query[1] == "2":
            add_right = add_right + query[2]
            
        elif not not_reversed == -1 and query[1] == "2":
            add_left = query[2] + add_left

if not_reversed == False:
    ans = list(add_left) + list(S) + list(add_right)
    ans.reverse()
    print("".join(map(str, ans)))
else:
    ans = add_left + S + add_right
    print(ans)

### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())
is_reversed = 1
for _ in range(Q):
    query = list(input().split())
    if query[0] == "1":
        is_reversed *= -1
    
    else:
        if is_reversed == 1:
            if query[1] == "1":
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if query[1] == "2":
                S.appendleft(query[2])
            else:
                S.append(query[2])

S = "".join(S)
print(S[::is_reversed])
### BUGGY CODE ###


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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
 
def lcm(x, y):
    return (x * y) // gcd(x, y)

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

success = False
ans = 0
fans = ans

_lcm = lcm(len(S), len(T))
for k in list(reversed(range(1, (len(S) * len(T))//_lcm + 1))):
    ans = k * _lcm
    s = [(i * ans)//len(S) + 1 for i in range(len(S))]
    t = [(i * ans)//len(T) + 1 for i in range(len(T))]
    pool = s + t
    double_st = []
    
    for i in range(len(S)):
        if (len(T)*i)%len(S) == 0 and (len(T) * i)//len(S) <len(T):
            double_st += [(i * ans)//len(S) + 1]
    isImpossible = False

    for st in double_st:
        s_i = ((st-1) * len(S))//ans
        t_i = ((st-1) * len(T))//ans
        if s_i == -1 or t_i == -1:
            continue
        if S[s_i] != T[t_i]:
            isImpossible = True
            break

            
    if isImpossible:
        break
    else:
        success = True
        fans = ans

if not success:
    print(-1)
else:
    print(ans)

### FIXED CODE ###


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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
 
def lcm(x, y):
    return (x * y) // gcd(x, y)

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

success = False
fans = 0

_lcm = lcm(len(S), len(T))

def isImpble(k, _lcm):
    global success
    global S
    global T
    global fans
    
    ans = k * _lcm
    double_st = []
    
    for i in range(len(S)):
        if (len(T)*i)%len(S) == 0 and (len(T) * i)//len(S) <len(T):
            double_st += [(i * ans)//len(S) + 1]
    isImpossible = False

    for st in double_st:
        s_i = ((st-1) * len(S))//ans
        t_i = ((st-1) * len(T))//ans
        if S[s_i] != T[t_i]:
            isImpossible = True
            break

            
    if isImpossible:
        return True
    else:
        success = True
        fans = k*_lcm
        return False
        

imp = isImpble((len(S) * len(T))//_lcm, _lcm)

if not imp:
    for k in range(1, (len(S) * len(T))//_lcm ):
        imp = isImpble(k, _lcm)
        if success:
            break
    

if not success:
    print(-1)
else:
    print(fans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = []
sumcost = 0
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
k = 0
A.sort()
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)

### FIXED CODE ###

N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)
### BUGGY CODE ###


n,k=map(int, input().split())
x=n
min=n

while True:
  if abs(x-k)>=min:
    break
  else:
    min=abs(x-k)
    x=abs(x-k)

print(min)

### FIXED CODE ###


n,k=map(int, input().split())
min=n%k

while True:
  if abs(min-k)>=min:
    break
  else:
    min=abs(min-k)

print(min)
### BUGGY CODE ###

N, K = map(int, input().split())
A = [int(x) for x in input().split()]

res = 0
for d in range(50, -2, -1):
    # (d + 1)桁目のKの値が 0 ならスキップ
    # 1桁目（d == -1）のときはスキップしない
    if d != -1 and not (K & (1 << d)):
        continue

    tmp = 0
    for e in range(50, -1, -1):
        mask = 1 << e

        # (e + 1)桁目のAの値が 1 であるものをカウント
        num = 0
        for i in range(N):
            if A[i] & mask:
                num += 1

        if e > d:
            if K & mask:
                tmp += mask * (N - num)
            else:
                tmp += mask * num
        elif e == d:
            tmp += mask * num
        else:
            tmp += mask * max(num, N - num)
    res = max(res, tmp)
print(res)


### FIXED CODE ###

N, K = map(int, input().split())
A = [int(x) for x in input().split()]

# (e + 1)桁目のAの値が 1 であるものをカウント
num = [0] * 41
for e in range(40, -1, -1):
    mask = 1 << e
    for a in A:
        if a & mask:
            num[e] += 1

res = 0
for d in range(40, -2, -1):
    # (d + 1)桁目のKの値が 0 ならスキップ
    # 1桁目（d == -1）のときはスキップしない
    if d != -1 and not (K & (1 << d)):
        continue

    tmp = 0
    for e in range(40, -1, -1):
        mask = 1 << e
        if e > d:
            if K & mask:
                tmp += mask * (N - num[e])
            else:
                tmp += mask * num[e]
        elif e == d:
            tmp += mask * num[e]
        else:
            tmp += mask * max(num[e], N - num[e])
    res = max(res, tmp)
print(res)
### BUGGY CODE ###

n=int(input())
l=[list(input()) for _ in range(n)]
v=0

for a in range(n):
    for b in range(n):
        m=[[0]*n for _ in range(n)]
        for i in range(n):
            for j in range(n):
                m[(i+a)%n][(j+b)%n]=l[i][j]

        f=True
        for i in range(n):
            for j in range(n):
                if m[j][i]!=m[i][j]:
                    f=False
                    break
            if not f:
                break
        else:
            v+=1

print(v)


### FIXED CODE ###

import numpy as np
n=int(input())
l=np.array([list(input()) for _ in range(n)])
ans=0

for _ in range(n):
    l=np.roll(l,1,axis=1)
    if (l==l.T).all():ans+=n

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

k,a,b=map(int,input().split())
ans=1
m=0
for i in range(k):
    if i==k-1 and m==0:
        ans+=1
    elif m==1:
        m=0
        ans+=b
    elif ans<a:
        ans+=1
    elif ans>=a:
        ans-=a
        m=1
print(max(ans,k+1))

### FIXED CODE ###

k,a,b=map(int,input().split())
t=k-(a-1)
print(max(k+1,(t//2)*(b-a)+t%2+a))
### BUGGY CODE ###

s = str(input())
k = int(input())

n = len(s)
S = set()
for i in range(n):
    for j in range(i+1, n+1):
        t = s[i:j]
        S.add(t)
S = list(S)
S.sort()
print(S[k-1])


### FIXED CODE ###

s = str(input())
k = int(input())
s = list(s)

n = len(s)

import copy
l = copy.copy(s)
l = set(l)
l = list(l)
l.sort()
#print(l)

ans = set()
for i in range(len(l)):
    for j in range(n):
        if s[j] == l[i]:
            p = j
            temp = []
            while p < n and p-j+1 <= k:
                temp.append(s[p])
                ans.add(''.join(temp))
                p += 1
    if len(ans) >= k:
        break
#print(ans)
ans = list(ans)
ans.sort()
print(ans[k-1])
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
Slist = [0 for x in range(0,N)]
L = list()
R = list()

for x in range(0,N-1):
    if S[x] is 'A' and S[x+1] is 'C':
        Slist[x] = 1

for x in range(0,Q):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

for x in range(0,Q):
    Sumple = Slist[L[x]-1:R[x]]
    answer = sum(Sumple) - Sumple[-1]
    print(answer)

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
Slist = [0 for x in range(0,N)]
L = list()
R = list()
number = 0

for x in range(0,N-1):
    if S[x] is 'A' and S[x+1] is 'C':
        number += 1
    Slist[x+1] = number

for x in range(0,Q):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

for x in range(0,Q):
    answer = Slist[R[x]-1] - Slist[L[x]-1]
    print(answer)
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path

n, x, y = map(int, input().split())

matrix = [[0]*n for _ in range(n)]

for i in range(n-1):
    matrix[i][i+1] = 1
    matrix[i+1][i] = 1

matrix[x-1][y-1] = 1
matrix[y-1][x-1] = 1

matrix = np.array(matrix)
result = shortest_path(matrix, method='D')

for k in range(1, n):
    answer = np.sum(result==k) // 2
    print(answer)

### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix

n, x, y = map(int, input().split())

v = [x-1]
u = [y-1]
for i in range(n-1):
    v.append(i)
    u.append(i+1)

csr = csr_matrix(([1]*n, (v, u)), shape=(n, n))
result = shortest_path(csr, method='D', directed=False).astype(int)
ans = np.bincount(result.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')
### BUGGY CODE ###

#coding utf-8
N,M=map(int,input().split())
a =[int(input()) for i in range(M)]
mod =10**9+7
dp = [1]
for i in range(1,N+1):
  if i in a:
    dp.append(0)
  else:
    if i ==1:
      dp.append(dp[i-1])
    else:
      dp.append((dp[i-1]+dp[i-2])%mod)

print(dp[N])

### FIXED CODE ###

#coding utf-8
N,M=map(int,input().split())
a =[int(input()) for i in range(M)]
a.append(0)
mod =10**9+7
dp = [1]
j = 0
for i in range(1,N+1):
  if i != a[j]:
    if i ==1:
      dp.append(dp[-1])
    else:
      dp.append((dp[-1]+dp[-2])%mod)
  else:
    dp.append(0)
    j +=1 

print(dp[-1])
### BUGGY CODE ###

from itertools import accumulate
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(k):
    c = [0]*n
    for i,j in enumerate(A):
        l = max(0,i-j)
        r = min(n-1,i+j)
        c[l] += 1
        if r+1 < n:
            c[r+1] -= 1
    if A != list(accumulate(c)):
        A = list(accumulate(c))
    else:
        break
print(" ".join(map(str,A)))

### FIXED CODE ###

from itertools import accumulate
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(min(k,50)):
    c = [0]*n
    for i,j in enumerate(A):
        l = max(0,i-j)
        r = min(n-1,i+j)
        c[l] += 1
        if r+1 < n:
            c[r+1] -= 1
    A = list(accumulate(c))
print(" ".join(map(str,A)))
### BUGGY CODE ###

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

  d = 60
  to = [[0] * N for _ in range(d)]

  for i in range(N):
    #テレポート距離が2^0のデータを入れる
    #これは入力A1〜ANと同じ
    to[0][i] = A[i] - 1 #0-indexedにする

  for i in range(1, d):
    for j in range(N):
      to[i][j] = to[i-1][to[i-1][j]]

  v = 0
  for i in range(d-1, -1, -1):
    l = 1 << i

    if(K >= l):
      v = to[i][v]
      K -= l

  print(v + 1)

if __name__ == "__main__":
  main()

### FIXED CODE ###

from queue import Queue

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

    visited = [False] * N
    visited[0] = True
    p = [1]
    l = []
    r = []

    while(len(p) < N):
        v = p[-1] - 1
        n = A[v] - 1

        if(visited[n]):
            d = p.index(n+1)
            l = p[0:d]
            r = p[d:]
            break

        p.append(A[v])
        visited[n] = True

    if(len(l) == 0 and len(r) == 0):
        print(p[K%len(p)])
    else:
        if(K < len(p)):
            print(p[K])
        else:
            k = K - len(l)
            k %= len(r)
            print(r[k])
        

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

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

a=[]

a=map(int,raw_input().split())

b=[map(int,raw_input().split() )for i in range(m)]
b=sorted(b,key=lambda x: -x[1])
for i in range(m):
    a.sort()
    if a[0]>b[i][1]:
        break
    for j in range(b[i][0]):
        if a[j] < b[i][1]:
                a[j] = b[i][1]
        else:
           break
print(sum(a))

### FIXED CODE ###

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

a=[]

a=map(int,raw_input().split())
a.sort()
b=[map(int,raw_input().split() )for i in range(m)]
b=sorted(b,key=lambda x: -x[1])
k=0
l=0
for i in range(m):
    if a[k]>b[i][1]:
        break
    for j in range(k,min(n,k+b[i][0])):
        if a[j] < b[i][1]:
                a[j] = b[i][1]
                l=j+1
        else:
           break
    k=l
    if k==n:
        k=n-1
print(sum(a))
### BUGGY CODE ###

from collections import deque
INF = int(1e9) + 7
n, x, y = map(int, input().split())
x -= 1
y -= 1
d = [[INF] * n for i in range(n)]
ans = [0] * (n+1)
def bfs(i):
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([i])
    d[i][i] = 0

    while len(que) != 0:
        val = que.popleft()
        #print(val)
        if val-1 >= 0 and d[i][val-1] == INF:
            que.append(val-1)
            d[i][val-1] = d[i][val] + 1
        if val+1 < n and d[i][val+1] == INF:
            que.append(val+1)
            d[i][val+1] = d[i][val] + 1
        if val == x and d[i][y] == INF:
            que.append(y)
            d[i][y] = d[i][val] + 1
        if val == y and d[i][x] == INF:
            que.append(x)
            d[i][x] = d[i][val] + 1
    return d[i]

for i in range(n-1):
    val = bfs(i)
    #print(val)
    for j in range(i+1,n):
        ans[val[j]] += 1
for i in range(1, n):
    print(ans[i])


### FIXED CODE ###

from collections import deque
INF = int(1e9) + 7
n, x, y = map(int, input().split())
x -= 1
y -= 1
d = [[INF] * n for i in range(n)]
ans = [0] * (n+1)
def bfs(i):
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([i])
    d[i][i] = 0

    while len(que) != 0:
        val = que.popleft()
        #print(val)
        if val-1 >= 0 and d[i][val-1] == INF:
            que.append(val-1)
            d[i][val-1] = d[i][val] + 1
        if val+1 < n and d[i][val+1] == INF:
            que.append(val+1)
            d[i][val+1] = d[i][val] + 1
        if val == x and d[i][y] == INF:
            que.append(y)
            d[i][y] = d[i][val] + 1
        if val == y and d[i][x] == INF:
            que.append(x)
            d[i][x] = d[i][val] + 1
    return d[i]

for i in range(n-1):
    val = bfs(i)
    #print(val)
    for j in range(i+1,n):
        ans[val[j]] += 1
for i in range(1, n):
    print(ans[i])
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
s = max(a)
if a.count(s) >= 2:
  for i in range(n):  
    print(s)
else:
  for i in range(n):
    l = a.copy()
    l[i] = 0
    print(max(l))

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
s = max(a)
if a.count(s) >= 2:
  for i in range(n):  
    print(s)
else:
  for i in range(n):
    if a[i] == s:
      l = a.copy()
      l.sort()
      print(l[-2])
    else:
      print(s)