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

inp = input()
m = 0
n = 0
li = ['dream','dreamer','erase','eraser']
while True:
    for i in li:
        if inp.startswith(i):
    	    inpp = inp.replace(i,'',1)
    	    if inpp == '':
    		    m = 1
    		    break
    	    for k in li:
    	    	if inpp.startswith(k):
    		        inp = inpp
    		        n = 1
    		        break
    	    else:

    	    	continue
    	    break
    if m == 1:
    	print('YES')
    	break
    if n != 1:
    	print('NO')
    	break

### FIXED CODE ###

inp = input()
inp = inp[::-1]
li = ['dream','dreamer','erase','eraser']
li = [k[::-1] for k in li]
m = 0
while True:
    for i in li:
        if inp.startswith(i):
    	    inp = inp.replace(i,'',1)
    	    m = 0
    else:
    	if m == 1:
    		break
    	else:
    		m = 1
    		continue
    break
if inp == '':
	print("YES")
else:
	print("NO")
### BUGGY CODE ###

l, n = [int(x) for x in input().split()]
s = input()
for i in range(n):
  q = [int(x) for x in input().split()]
  ans = 0
  for j in range(q[0]-1, q[1]-1):
    if s[j:j+2] == 'AC':
      ans += 1
  print(ans)

### FIXED CODE ###

l, n = [int(x) for x in input().split()]
s = input()
up = [0]
for i in range(l-1):
  if s[i:i+2] == 'AC':
    up.append(up[-1] + 1)
  else:
    up.append(up[-1])
ans = []
for i in range(n):
  d, u = map(int, input().split())
  ans.append(up[u-1] - up[d-1])
for i in range(n):
  print(ans[i])
### BUGGY CODE ###

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
count = 0
for t in T:
    if t in D:
        D.remove(t)
        count += 1
if count == M:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
d_dict = {}
for d in D:
    if d not in d_dict:
        d_dict[d] = 0
    d_dict[d] += 1

count = 0
for t in T:
    if t in d_dict and d_dict[t] > 0:
        d_dict[t] -= 1
        count += 1
if count == M:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

import sys
import Queue

n = int(raw_input())

graph = [[-1 for i in range(0, n)] for j in range(0, n)]
color = [-1 for i in range(0, n)]
for i in range(0, n - 1):
    u, v, w = map(int, raw_input().split(" "))
    # print("%d %d %d" % (u, v, w))
    graph[u-1][v-1] = w
    graph[v-1][u-1] = w

# for i in range(0, n):
#     for j in range(0, n):
#         sys.stdout.write(str(graph[j][i]) + "\t")
#
#     print("")

queue = Queue.Queue()
sum = 0

while True:
    if sum >= n:
        break

    for i in range(0, n):
        if color[i] < 0:
            queue.put(i)
            color[i] = 0
            sum += 1
            break

    while True:
        if queue.empty():
            break

        current_node = queue.get()
        for end in range(0, n):
            if graph[current_node][end] > 0 and color[end] < 0:
                color[end] = (color[current_node] + graph[current_node][end] % 2) % 2
                queue.put(end)
                sum += 1

for node in range(0, n):
    print(color[node])


### FIXED CODE ###

import sys
import Queue

n = int(raw_input())

graph = dict()
color = [-1 for i in range(0, n)]
for i in range(0, n - 1):
    u, v, w = map(int, raw_input().split(" "))
    if (u - 1) in graph:
        graph[u - 1].append((v-1, w))
    else:
        graph[u - 1] = [(v-1, w)]

    if (v - 1) in graph:
        graph[v - 1].append((u - 1, w))
    else:
        graph[v - 1] = [(u - 1, w)]

# for start, value_list in graph.items():
#     for end, weight in value_list:
#         print("%s -> %d (%d)" % (start, end, weight))

queue = Queue.Queue()
sum = 0
next_check = 0

while True:
    if sum >= n:
        break

    for i in range(next_check, n):
        if color[i] < 0:
            queue.put(i)
            color[i] = 0
            sum += 1
            next_check = i
            break

    while True:
        if queue.empty():
            break

        current_node = queue.get()
        if current_node in graph:
            for end, weight in graph[current_node]:
                if color[end] < 0:
                    color[end] = (color[current_node] + weight % 2) % 2
                    queue.put(end)
                    sum += 1

for node in range(0, n):
    print(color[node])
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    uni[cnt].append(x)
    seen[x-1]=1
    for i in fri[x-1]:
        if seen[i-1]==0:
            dfs(i)
    

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

fri=[[] for i in range(n)]
blk=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].append(d)
    blk[d-1].append(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append([])
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(set(unii)&set(blk[j-1]))-1
        seq[j-1]=cj

print(*seq)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].add(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

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

fri=[[] for i in range(n)]
blk=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].append(d)
    blk[d-1].append(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append(set())
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(unii&set(blk[j-1]))-1
        seq[j-1]=cj

print(*seq)
### BUGGY CODE ###

def main():
    N, Q = map(int, input().split())
    C = list(map(int, input().split()))
    E = []

    D = {C[i]: -1 for i in range(N)}
    for i in range(N):
        if D[C[i]] == -1:
            D[C[i]] = i
        else:
            E.append((D[C[i]], i, -1))
            D[C[i]] = i

    for i in range(Q):
        l, r = map(int, input().split())
        E.append((l - 1, r - 1, i))

    def f(tup):
        return tup[0]
    E.sort(key=f, reverse=True)

    # Binary Indexed Tree (Fenwick Tree)
    class BIT:
        def __init__(self, n):
            self.n = n
            self.data = [0] * (n + 1)
            self.el = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.data[i]
                i -= i & -i
            return s

        def add(self, i, x):
            # assert i > 0
            self.el[i] += x
            while i <= self.n:
                self.data[i] += x
                i += i & -i

        def get(self, i, j=None):
            if j is None:
                return self.el[i]
            return self.sum(j) - self.sum(i)

    ANS = [0] * Q
    d = BIT(N)
    for e in E:
        if e[2] == -1:
            d.add(e[1], 1)
        else:
            ANS[e[2]] = e[1] - e[0] + 1 - d.sum(e[1])

    for i in range(Q):
        print(ANS[i])

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict
import sys
def read():
    return sys.stdin.readline().rstrip()
def main():
    N, Q = map(int, read().split())
    C = list(map(int, read().split()))
    E = defaultdict(list)

    D = [-1] * (N + 1)
    for i in range(N):
        D_i = D[C[i]]
        if D_i != -1:
            E[D_i].append((D_i, i))
        D[C[i]] = i

    F = defaultdict(list)
    for i in range(Q):
        l, r = map(int, input().split())
        F[l-1].append((r - 1, i))



    # Binary Indexed Tree (Fenwick Tree)
    class BIT:
        def __init__(self, n):
            self.n = n
            self.data = [0] * (n + 1)
            self.el = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.data[i]
                i -= i & -i
            return s

        def add(self, i, x):
            # assert i > 0
            self.el[i] += x
            while i <= self.n:
                self.data[i] += x
                i += i & -i

        def get(self, i, j=None):
            if j is None:
                return self.el[i]
            return self.sum(j) - self.sum(i)

    ANS = [0] * Q
    d = BIT(N)
    for x in range(N - 1, -1, -1):
        for e in E[x]:
            d.add(e[1], 1)
        for f in F[x]:
            ANS[f[1]] = f[0] - x + 1 - d.sum(f[0])

    for i in range(Q):
        print(ANS[i])

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

N,A,B=map(int,input().split())
ans=0
count=0
Flag=False
for i in range (10**100):
    for j in range(A):
        ans+=1
        count+=1
        if count==N:
            Flag=True
            break
    for k in range(B):
        if Flag:
            break
        count+=1
        if count==N:
            Flag=True
            break
    if Flag:
        break
print(ans)

### FIXED CODE ###

N,A,B=map(int,input().split())
ans=0
count=0
Flag=False
waru=N//(A+B)
amari=N%(A+B)
if amari>A:
    print(waru*A+A)
else:
    print(waru*A+amari)
### BUGGY CODE ###

n,k=map(int, input().split())
ds=list(map(str, input().split()))
while (i in str(n) for i in ds):
  n+=1
print(str(n))


### FIXED CODE ###

n,k=map(int, input().split())
ds=list(map(str, input().split()))
while any(i in str(n) for i in ds):
  n+=1
print(str(n))
### BUGGY CODE ###

# ABC93, B - small and large integers
a, b, k = map(int, input().split(' '))

X = [i for i in range(a, b+1)]

if k >= len(X)/2:
    [print(x) for x in X]
else:
    for i in range(k):
        print(X[i])
    for i in range(k, 0, -1):
        print(X[len(X)-i])


### FIXED CODE ###

# ABC93, B - small and large integers
a, b, k = map(int, input().split(' '))


if k >= (b-a+1)/2:
    [print(x) for x in range(a, b+1)]
else:
    [print(x) for x in range(a, a+k)]
    [print(x) for x in range(b-k+1, b+1)]
### BUGGY CODE ###

import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = sorted(list(map(int,input().split())))
    cnt = 0

    for i in range(a[0],a[N-1]+1):
        cnt = max(a.count(i-1)+a.count(i)+a.count(i+1),cnt)
    print(cnt)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N = int(input())
    a = list(map(int,input().split()))
    cnt = [0] * (max(a) + 2)

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

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

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
d[~w+a*w+b]=1
q=[(a-1,b-1)]
for s,t in q:
 if s==f-1and t==g-1:break
 p=d[s*w+t]+1
 for y,x in(-1,0),(0,-1),(0,1),(1,0):
  for z in range(k):
   i,j=s+y*~z,t+x*~z
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[i*w+j]<p:break
   q+=(i,j),;d[i*w+j]=p
print(d[~w+f*w+g]%I-1)

### FIXED CODE ###

I=9**9
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I]*h*w
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   if d[t]==I:q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)
### BUGGY CODE ###

n=int(input())
s=[""]*n
st=set()
r=0
for ii in range(n):
  ss=list(input())
  ss.sort()
  ss="".join(ss)
  s[ii]=ss
  st.add(ss)

for sss in st:
  ls=[]
  r2=0
  for ii in range(len(s)):
    if s[ii]==sss:
      ls.append(ii)
      r2+=1
  """print(st)
  print(ls)
  print(r2)"""
  m=len(ls)
  for ii in range(m):
    del s[ls[m-1-ii]]
  if r2>1:
    r+=(r2*(r2-1))//2      
  #print(ii)
"""  
import numpy as np
for ii in range(n-1):
  for jj in np.arange(ii+1,n):
    #print(ii,jj)
    if s[ii]==s[jj]:
      #print(s[ii],s[jj])
      r+=1
"""
print(r)


### FIXED CODE ###

n=int(input())
s=[""]*n
st=set()
d={}
for ii in range(n):
  ss=list(input())
  ss.sort()
  ss="".join(ss)
  if ss in st:
    d[ss]+=1
  else:
    d[ss]=1
    st.add(ss)

if len(st)==n:
  print(0)
  exit()
if len(st)==1:
  print((n*(n-1))//2)
  exit()

r=0
for sss in st:
  c=d[sss]
  if c>1:
    r+=(c*(c-1))//2
    
print(r)
### BUGGY CODE ###

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

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
  w, v = map(int, input().split())
  for j in range(W+1):
    if j - w < 0:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v)

print(dp[-1][-1])

### FIXED CODE ###

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

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
  w, v = map(int, input().split())
  for j in range(W+1):
    if j - w < 0:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v)

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

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

count = 0
for i in range(a,b+1):
    if i%c == 0:
        count += 1

print(count)

### FIXED CODE ###

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

d = a//c
e = a%c
f = b//c

if e == 0:
    print(f-d+1)
else:
    print(f-d)
### BUGGY CODE ###

import functools

n=int(input())
a=list(map(int,input().split()))
m=10**9+7

def euclid(a, b):
    while b:
        a, b = b, a%b
    return a

def multiple(a, b):
    return a*b // euclid(a, b)

def lcm(nums):
        return functools.reduce(multiple, nums)

x=lcm(a)
ans=0

for i in range(n):
    ans+=(x//a[i])%m
    ans%=m

print(ans)

### FIXED CODE ###

import functools
MOD=10**9+7
def euclid(a, b):
  if b == 0:
    return a
  else:
    return euclid(b, a%b)

def multiple(a, b):
  return a*b // euclid(a, b)

def lcm(nums):
  return functools.reduce(multiple, nums)
n=int(input())
a=list(map(int,input().split()))
x=lcm(a)
sum=0
for i in range(n):
    sum+=x//a[i]
print(sum%MOD)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000000)

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

if k == 1:
    print(0)
elif n < k / 2:
    print(n)
else:
    while n >= k / 2:
        n = abs(k - n)
        
    print(n)
    


### FIXED CODE ###

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

if k > n:
    tmp = n
else:
    tmp = n % k

if tmp > k / 2:
    tmp = k - tmp

print(tmp)
### BUGGY CODE ###

k=int(input())
if k%2==0:
    ans=-1
else:
    cnt=1
    cur=7
    while True:
        if cur%k==0:
            ans=cnt
            break
        if cnt>k:
            ans=-1
            break
        cnt+=1
        cur=(7*(10**cnt))//9
print(ans)


### FIXED CODE ###

k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
cnt, yep = 0, 0
while True:
    yep = (yep * 10 + 7) % k
    cnt += 1
    if yep == 0:
        break
print(cnt)
### BUGGY CODE ###

from collections import Counter
from math import factorial
n = int(input())
print(n)
a = [int(i) for i in input().split()]
twice = Counter(a).most_common(1)[0][0]
x,y = (i for i,j in enumerate(a) if j == twice)
num,y = n+1,n-y
X,Y,numx,numy = [1],[1],1,1
for i in range(1,x+1):
	numx = numx*(x-i+1)//i
	X.append(numx)
for i in range(1,y+1):
	numy = numy*(y-i+1)//i
	Y.append(numy)
for i in range(2,x+y+2):
	num = num*(n+2-i)//i
	ans = num
	for j in range(max(0,i-y-1),min(i,x+1)):
		ans -= X[j]*Y[i-j-1]
	print(ans%(10**9+7))
for i in range(x+y+2,n+2):
	num = num*(n+2-i)//i
	print(num%(10**9+7))

### FIXED CODE ###

def comb(n,k):
	if n<k or n==0: return 0
	elif k==0: return 1
	else: return f[n]*p[k]*p[n-k]%(10**9+7)
from collections import Counter
n = int(input())
print(n)
a = [int(i) for i in input().split()]
twice = Counter(a).most_common(1)[0][0]
x,y = (i for i,j in enumerate(a) if j == twice)
num,y,f,p = 1,n-y,[1],[1]
for i in range(1,n+2):
	f.append(f[-1]*i%(10**9+7))
	p.append(pow(f[-1],10**9+5,10**9+7))
for i in range(2,x+y+2): print((comb(n+1,i)-comb(x+y,i-1))%(10**9+7))
for i in range(x+y+2,n+2): print(comb(n+1,i))
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))

if n<=k+1:
    print(abs(h[-1]-h[0]))
    exit()

dp=[0]*n
for i in range(k+1):
    dp[i]=abs(h[i]-h[0])

for g in range(k+1,n):
    _min = 10**10
    for l in range(g-k,g):
        _min = min(_min,dp[l]+abs(h[g]-h[l]))
    dp[g]=_min
print(dp[-1])

### FIXED CODE ###

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

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()
### BUGGY CODE ###

n,q = map(int, input().split())
tree = [[int(i) for i in input().split()] for i in range(n-1)] 
px = [[int(i) for i in input().split()] for i in range(q)] 
calc_tree = []

for i in range(n):
  tmp = [i+1]
  for j in range(n-1):
    if tree[j][0] in tmp:
      tmp.append(tree[j][1])
  calc_tree.append(tmp)
#print(calc_tree)
ans = [0] * n
  
for i in range(q):
  order = px[i][0] -1
  for j in calc_tree[order]:
    ans[j-1] += px[i][1]
    
for i in ans:
  print(i,end=' ')


### FIXED CODE ###

from collections import deque
import sys
def input():
   return sys.stdin.readline()[:-1]
  
n,q = map(int, input().split())
tree = [[int(i) for i in input().split()] for i in range(n-1)] 
px = [[int(i) for i in input().split()] for i in range(q)] 
A = [set() for i in range(n)]
B = [set() for i in range(n)]
C = [set() for i in range(n)]
flag = [False] * n

for i,a in enumerate(tree):
  A[a[1]-1].add(tree[i][0])
  B[a[0]-1].add(tree[i][1])

for i in range(n):
  C[i] = A[i] | B[i]

ans = [0] * n

for i in px:

  ans[i[0]-1] += i[1]
  
cr = deque()
cr.append(1)
flag[0] = True

while cr:
  c = cr.popleft()
  flag[c-1] = True
  for i in C[c-1]:
    if flag[i-1]:
      continue
    else:
      cr.append(i)
      ans[i-1] += ans[c-1]
print(*ans)
### BUGGY CODE ###

K = int(input())
cal = 0
for i in range(30000):
    cal += 7*(10**i)
    if cal % K == 0:
        print(len(str(cal)))
        exit()
print("-1")

### FIXED CODE ###

k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

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

import copy
from collections import deque


def bfs(s1,s2):
    que = deque()
    que.append([0, 0])
    cs = copy.deepcopy(s)
    if cs[s1][s2] == '#':
        cs[s1][s2] = 1
    else:
        cs[s1][s2] = 0
    while len(que) != 0:
        p = que.popleft()
        for i in range(2):
            nextX = p[0] + moveR[i]
            nextY = p[1] + moveC[i]
            if 0 <= nextX and nextX < H\
                and 0 <= nextY and nextY < W:
                if cs[nextX][nextY] == '#':
                    cs[nextX][nextY] = cs[p[0]][p[1]] + 1
                elif cs[nextX][nextY] == '.':
                    cs[nextX][nextY] = cs[p[0]][p[1]]
                else:
                    tmp = 0
                    if s[nextX][nextY] == '#':
                        tmp = 1
                    cs[nextX][nextY] = min(cs[p[0]][p[1]] + tmp, cs[nextX][nextY])
                que.append([nextX, nextY])
    print(cs[-1][-1])

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
ans = 10 ** 9
moveR = [0, 1]
moveC = [1, 0]
bfs(0,0)

### FIXED CODE ###


INF = 10 ** 9
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
dp = [[INF for _ in range(W)] for _ in range(H)]
if s[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(H):
    for j in range(W):
        if j != 0:
            cnt = 0
            if s[i][j] == '#' and s[i][j - 1] == '.':
                cnt += 1
            dp[i][j] = min(dp[i][j], dp[i][j - 1] + cnt)

        if i != 0:
            cnt = 0
            if s[i][j] == '#' and s[i - 1][j] == '.':
                cnt += 1
            dp[i][j] = min(dp[i][j], dp[i - 1][j] + cnt)

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


def main():
  n=int(input())
  s=input()
  ans=0
  for i in range(n):
    if ans>n-i:
      break
    Z=[0]*n
    j=i+1
    while j<n:
      k=0
      while i+k<j and j+k<n and s[i+k]==s[j+k]:
        k+=1
      Z[j]=k
      j+=1
    t=max(Z)
    if t>ans:
      ans=t
  print(ans)


if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  n=int(input())
  s=input()
  dp=[[0]*(n+1) for i in range(n+1)]
  for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
      if s[i]==s[j]:
        dp[i][j]=dp[i+1][j+1]+1
  #for i in dp:
  #  print(i)
  
  ans=0
  for i in range(n-1):
    for j in range(i+1,n):
      ans=max(ans,min(j-i,dp[i][j]))
  print(ans)      
        

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

N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

for i in range(N):
    m = max(A[:i] + A[(i+1):])
    print(m)


### FIXED CODE ###

N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

m1, m2, *_ = sorted(A, reverse=True)
for i in range(N):
    if A[i] == m1:
        print(m2)
    else:
        print(m1)
### BUGGY CODE ###

N, K = map(int, input().split())
*V, = map(int, input().split())
V.sort()
A = [0]*(N+1)
B = [0]*(N+1)
MASK = 2**(K+1)-1
A[0] = 1
for i in range(N):
    if K <= V[i]:
        A[i+1] = A[i]
    else:
        A[i+1] = (A[i] | ((A[i] << V[i]) & MASK))
B[N] = 1 << K
for i in range(N-1, -1, -1):
    if K <= V[i]:
        B[i] = B[i+1]
    else:
        B[i] = (B[i+1] | (B[i+1] >> V[i]))

ans = N
for i in range(N):
    if K <= V[i]:
        ans -= 1
        continue
    a = A[i]; b = B[i+1]
    K0 = K-V[i]
    VM = 2**(V[i]+1)-2
    while a and b:
        if a & 1:
            if b & VM:
                ans -= 1
                break
        a >>= 1
        b >>= 1
print(ans)


### FIXED CODE ###

import random
N, K = map(int, input().split())
*V, = map(int, input().split())
A = [0]*(N+1)
B = [0]*(N+1)
MASK = 2**(K+1)-1
A[0] = 1
for i in range(N):
    if K <= V[i]:
        A[i+1] = A[i]
    else:
        A[i+1] = (A[i] | ((A[i] << V[i]) & MASK))
B[N] = 1 << K
for i in range(N-1, -1, -1):
    if K <= V[i]:
        B[i] = B[i+1]
    else:
        B[i] = (B[i+1] | (B[i+1] >> V[i]))

ans = N
for i in range(N):
    if K <= V[i]:
        ans -= 1
        continue
    a = A[i]; b = B[i+1]
    VM = 2**(V[i]+1)-2
    l = 1
    while a and b and l:
        if a & 1 and b & VM:
            ans -= 1
            break
        l = max((a & -a).bit_length()-1, (b & -b).bit_length()-V[i]-1)
        a >>= l; b >>= l
print(ans)
### BUGGY CODE ###

n,s=map(int,input().split())
dp=[0]*(s+1)
mod=998244353
dp[0]=pow(2,n,mod)
for i in list(map(int,input().split())):
  for j in range(s,i-1,-1):
    dp[j]=(dp[j]+dp[j-i]*pow(2,mod-2,mod))%mod
print(dp[s])


### FIXED CODE ###

n,s=map(int,input().split())
dp=[0]*(s+1)
mod=998244353
inv=pow(2,mod-2,mod)
dp[0]=pow(2,n,mod)
for i in list(map(int,input().split())):
  for j in range(s,i-1,-1):
    dp[j]=(dp[j]+dp[j-i]*inv)%mod
print(dp[s])
### BUGGY CODE ###

# 未完成
import numpy as np
N = int(input())
x = np.zeros(N)
y = np.zeros(N)
kouholist = []
ans = []
if N == 1:
    print(1)
else:
    for i in range(N):
        x[i], y[i] = map(int, input().split())
    for m in range(N):
        for p in range(N):
            if m == p:
                continue
            diff_x = x[m] - x[p]
            diff_y = y[m] - y[p]
            if (diff_x, diff_y) not in kouholist:
                kouholist.append((diff_x, diff_y))

    for list_i in kouholist:
        ans_kari = 0
        for r in range(N):
            for q in range(N):
                if r == q:
                    continue
                if x[q] - x[r] == list_i[0] and y[q] - y[r] == list_i[1]:
                    ans_kari += 1
        ans.append(ans_kari)

    print("{}".format(N-max(ans)))


### FIXED CODE ###

# 未完成

import sys
N = int(input())
x = [0]*N
y = [0]*N
kouholist = []
ans = N
if N == 1:
    print(1)
    sys.exit()

for i in range(N):
    x[i], y[i] = map(int, input().split())
for m in range(N):
    for p in range(N):
        if m == p:
            continue
        diff_x = x[m] - x[p]
        diff_y = y[m] - y[p]
        ans_kari = N
        for r in range(N):
            for q in range(N):
                if x[q] - x[r] == diff_x and y[q] - y[r] == diff_y:
                    ans_kari -= 1
        if ans_kari < ans:
            ans = ans_kari

print("{}".format(ans))