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

import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for j in range(0,M,200):
    for i in range(0,M):
      if p[i][0]==j or p[i][1]==j:
        count+=1
    if count%2==1:
      print("NO")
      sys.exit()
  else: 
    print("YES")

### FIXED CODE ###

import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
for i in range(0,N):
  p.append(0)
for i in range(0,M):
  count=list(map(int, input().split()))
  p[count[0]-1]+=1
  p[count[1]-1]+=1
for i in range(0,M):
  if p[i]%2==1:
    print("NO")
    sys.exit()
print("YES")
### BUGGY CODE ###

import numpy as np
in1=list(map(int,input().split(" ")))
#print(in1)
arr=np.zeros((in1[0],in1[1]))
for i in range(in1[0]):
    arr[i]=input().split(" ")

#print(arr)
Q=int(input())
test=[]
out=[]
for k in range(Q):
    ans=0
    start,end=list(map(int,input().split(" ")))
    place=np.where(arr==start)
    #print(start,end)
    while start != end:
        #print("ans",ans)
        nextplace=np.where(arr==start+in1[2])#[1][0]
        ans+=abs(nextplace[0][0]-place[0][0])
        ans+=abs(nextplace[1][0]-place[1][0])
        start+=in1[2]
        place=nextplace

    #print(ans)
    out.append(ans)
for i in out:
    print(i)


### FIXED CODE ###

import numpy as np
H, W, D=list(map(int,input().split(" ")))
#print(in1)
#arr=np.zeros((in1[0],in1[1]))
d={}
for i in range(H):
    #arr[i]=input().split(" ")
    for n,k in enumerate(input().split(" ")):
        d[int(k)]=[i,n]
#print(arr)
Q=int(input())
out=[]

cost={}

for i in range(1,D+1):
    now = i + D
    cost[i]=0
    #cost[i]=abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
    while now <= H * W:
        cost[now] = cost[now - D] + abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
        now += D


out=[]
for k in range(Q):
    start,end=list(map(int,input().split(" ")))
    out.append(cost[end]-cost[start])

for i in out:
    print(int(i))
### BUGGY CODE ###

import numpy as np

n = int(input())
arr = np.array([int(input()) for _ in range(n)])

a_max = arr.max()

idx = np.where(arr == a_max)[0]

if len(idx) > 1:
    for i in range(n):
        print(a_max)

    exit()

not_arr = arr[arr != a_max]

if len(not_arr) != 0:
    b_max = not_arr.max()

for i in range(n):
    if i in idx:
        print(b_max)
    else:
        print(a_max)

### FIXED CODE ###

import numpy as np

n = int(input())
arr = np.array([int(input()) for _ in range(n)])

a_max = arr.max()

idx = np.where(arr == a_max)[0]

if len(idx) > 1:
    for i in range(n):
        print(a_max)

    exit()

not_arr = arr[arr != a_max]

b_max = not_arr.max()

t = idx[0]
for i in range(n):
    if i == t:
        print(b_max)
    else:
        print(a_max)
### BUGGY CODE ###

import math
import bisect

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

ans = 0
while(len(A)>1):
  a = A[-1]
  del A[-1]
  b = (1<<(int(math.log(a,2))+1))-a
  #print(a,b)
  r = bisect.bisect_left(A, b)
  if r < len(A) and A[r] == b:
    ans += 1
    del A[r]
print(ans)

### FIXED CODE ###

import math
import bisect
import collections

N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)
A = sorted(list(C.keys()))
#print(C)
#print(A)

ans = 0
for i in range(len(A)-1,-1,-1):
  a = A[i]
  b = (1<<(int(math.log(a,2))+1))-a
  if a == b:
    ans += C[a]//2
    C[a] -= C[a]//2*2
  else:
    r = bisect.bisect_left(A, b)
    if r < i and A[r] == b:
      mn = min(C[a],C[A[r]])
      ans += mn
      C[a] -=  mn
      C[A[r]] -= mn
print(ans)
### BUGGY CODE ###

def LCS(X,Y):
    m,n=len(X),len(Y)
    MAP=[[0 for i in range(m)] for j in range(n)]
    for i in range(1,n):
        for j in range(1,m):
            if Y[i]==X[j]:
                MAP[i][j]=MAP[i-1][j-1]+1
            else:
                MAP[i][j]=max(MAP[i][j-1],MAP[i-1][j])

    i,j=n-1,m-1
    ans=""
    while MAP[i][j]!=0:
        if MAP[i][j]==MAP[i-1][j]:i -=1
        elif MAP[i][j]==MAP[i][j-1]:j -=1
        else:
            ans +=Y[i]
            i -=1
            j -=1
    return ans[::-1]


print(LCS(" "+input()," "+input()))

### FIXED CODE ###

def LCS(X,Y):
    m,n=len(X),len(Y)
    MAP=[[0 for i in range(m)] for j in range(n)]
    for i in range(1,n):
        for j in range(1,m):
            if Y[i]==X[j]:
                MAP[i][j]=MAP[i-1][j-1]+1
            else:
                MAP[i][j]=max(MAP[i][j-1],MAP[i-1][j])

    i,j=n-1,m-1
    ans=""
    while MAP[i][j]!=0:
        if MAP[i][j]==MAP[i-1][j]:i -=1
        elif MAP[i][j]==MAP[i][j-1]:j -=1
        else:
            ans +=Y[i]
            i -=1
            j -=1
    return ans[::-1]

print(LCS(" "+input()," "+input()))
### BUGGY CODE ###

N, K = [int(nk) for nk in input().split()]

ans = 0
# a+b=pK b+c=qK c+a=rK
for p in range(1, ((2*N)//K)+1):#1<=p<=(2*N)//K
  for q in range(1, ((2*N)//K)+1):
    b0 = (( p+q-1)*K)/2
    if b0 < 1:
      continue
    for r in range(1, ((2*N)//K)+1):
      a = (( p-q+r)*K)/2
      b = (( p+q-r)*K)/2
      c = ((-p+q+r)*K)/2
      if b < 1:
        break
      elif a > N or c > N:
        break
      elif b > N:
        continue
      elif a < 1 or c < 1:
        continue
      elif a == int(a) and b == int(b) and c == int(c):
        ans += 1
        
print(ans)

### FIXED CODE ###

N, K = [int(nk) for nk in input().split()]

if K % 2 == 1:
  print((N//K)**3)
else:
  ans1 = (N//K)**3
  ans2 = ((N-(K//2))//K + 1)**3
  print(ans1 + ans2)
### BUGGY CODE ###

import bisect
N, M = map(int, input().split())

cities_prefec = {}
data = []
cities = []
years = []

for i in range(M):
    prefec_id, year = map(int, input().split())

    data.append(
        {
            "pref_id": prefec_id,
            "year": year
        }
    )

    if prefec_id in cities_prefec:
        bisect.insort(cities_prefec[prefec_id], year)
    else:
        cities_prefec[prefec_id] = [year]


for d in data:
    p_id = d["pref_id"]
    cn = cities_prefec[p_id].index(d["year"]) + 1
    print("{p_id:0>6}{cn:0>6}".format(**locals()))


### FIXED CODE ###

if __name__ == "__main__":
    _, M = map(int, input().split())
    
    outputs = [0 for _ in range(M)]
    cities = {}

    for i in range(M):
        pref, year = map(int, input().split())
        
        if pref not in cities:
            cities[pref] = {}

        cities[pref][year] = i

    for p in cities:
        city_years = list(cities[p].keys())
        city_years.sort()

        for i, cy in enumerate(city_years):
            outputs[cities[p][cy]] = "{:06}{:06}".format(p, i + 1)

    for line in outputs:
        print(line)
### BUGGY CODE ###

list = input().split()
N = int(list[0])
K = int(list[1])
i = K
s = 0

def sum(a,b):
    i=0
    for p in range (b-a+1):
        i += a + p
    return i

while i <= N + 1:
    #print(sum(N-i+1,N) + sum(0,i-1))
    s = s + sum(N-i+1,N) - sum(0,i-1) + 1
    i += 1
print(s)

### FIXED CODE ###

list = input().split()
N = int(list[0])
K = int(list[1])
i = K
s = 0

def sum(a,b):
    i=0
    i = (a + b)*(b - a + 1)/2
    return i

while i <= N + 1:
    #print(sum(N-i+1,N) + sum(0,i-1))
    s = s + sum(N-i+1,N) - sum(0,i-1) + 1
    i += 1
print(int(s % (10**9+7)))
### BUGGY CODE ###

n, m = map(int, input().split())
dp = [ [float("inf")]*(2**n) for _ in range(m) ]
dp[0][0] = 0
for i in range(1, m):
  a, b = map(int, input().split())
  k = set(map(int, input().split()))
  c = 0
  for l in k:
    c += 2**(l-1)
  for j in range(2**n):
    dp[i][j] = min(dp[i-1][j&(~c)]+a, dp[i-1][j])

if dp[m-1][2**n-1] == float("inf"):
  print(-1)
else:
  print(dp[m-1][2**n-1])

### FIXED CODE ###

n, m = map(int, input().split())
dp = [ [float("inf")]*(2**n) for _ in range(m) ]
dp[0][0] = 0
for i in range(1, m):
  a, b = map(int, input().split())
  k = set(map(int, input().split()))
  c = 0
  for l in k:
    c += 2**(l-1)
  for j in range(2**n):
    dp[i][j] = min(dp[i-1][j&(~c)]+a, dp[i-1][j])

if dp[m-1][2**n-1] == float("inf"):
  print(-1)
else:
  print(dp[m-1][2**n-1])
### BUGGY CODE ###

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


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

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

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)


BIT = BinaryIndexedTree(max(A))
ans = 0
for j in range(N):
    ans += j - BIT.sum(A[j])
    BIT.add(A[j], 1)
print(ans)


### FIXED CODE ###

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


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

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

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(N)

A_sorted = {a: i for i, a in enumerate(sorted(A), start=1)}
ans = 0
for j, a in enumerate(A):
    ans += j - BIT.sum(A_sorted[a])
    BIT.add(A_sorted[a], 1)

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

from random import randint

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

last = {}
ans = 0;

for _ in range(10**7):
    x = randint(0, n-1)
    y = randint(0, n-1)
    if abs(x-y) == a[x]+a[y] and last.get((x, y), "Hola") == "Hola":
        ans += 1;
        last[(x, y)] = 1;
        last[(y, x)] = 1;

print(ans)


### FIXED CODE ###

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

x = []
y = {}

for i, elem in enumerate(a):
    x.append(i+a[i])
    y[i-a[i]] = y.get(i-a[i], 0) + 1

ans = 0

for i in x:
    ans += y.get(i, 0)

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

def prime_factorize(n: int) -> list:
    ''' nの素因数分解 '''
    arr = []
    while n % 2 == 0:
        arr.append(2)
        n = n // 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            arr.append(f)
            n = n // f
        else:
            f += 2
    if n != 1:
        arr.append(n)
    return arr

from collections import Counter

N = int(input())
ans = 0
for k in range(1, N+1):
    f = 1
    for _, v in Counter(prime_factorize(k)).items():
        f *= (v+1)
    ans += k * f
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for k in range(1, N+1):
    d = N // k
    ans += k * (d+1) * d // 2
print(ans)
### BUGGY CODE ###

def resolve():
    s=list(input())
    cnt=0
    while True:
        flag=True
        for i in range(len(s)-1):
            if s[i]=='B' and s[i+1]=='W':
                cnt+=1
                s[i],s[i+1]='W','B'
                flag=False
        if flag:
            break
    print(cnt)
resolve()

### FIXED CODE ###



def resolve():
    s=list(input())
    ans=[]
    cnt=0
    for i in s:
        if i=='B':
            cnt+=1
        else:
            ans.append(cnt)
    print(sum(ans))
resolve()
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
pre_score = 1
for i in range(k):
  pre_score *= a[i]
for i in range(k, n):
  after_score = pre_score*a[i]/a[i-k]
  if after_score > pre_score:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
pre_score = 1
for i in range(k, n):
  after_score = pre_score*a[i]/a[i-k]
  if after_score > pre_score:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 21:06:06 2020

@author: matanoakihiro
"""


N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*N

sousa=0

while sousa<K:
    for i in range(N):
        ma=i+A[i]+1
        if ma>N:
            ma=N
        mi=i-A[i]
        if mi<0:
            mi=0
        for j in range(mi,ma):
            B[j]+=1
    A=list(B)
    B=[0]*N
    sousa+=1

A=[str(k) for k in A]
print(" ".join(A))

### FIXED CODE ###

import numpy as np

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

B=np.zeros(shape=N+1,dtype=np.int64)
C=np.arange(0,N)

sousa=0
kaisuu=min(K,42)



while sousa<kaisuu:
    np.add.at(B, np.maximum(0,C-A),1)
    np.add.at(B,np.minimum(N,C+A+1),-1)
    A = B.cumsum()[:-1]
    sousa+=1
    
    B *= 0
    
A=[str(k) for k in A]
print(" ".join(A))
### BUGGY CODE ###

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

ans = [0] * (N+1)

for j in range(K):
    ans = [0] * (N+1)
    for i in range(N):
        L = max(0, i-A[i])
        R = min(N, i+A[i]+1)
        ans[L] += 1
        ans[R] -= 1
    for i in range(1, N+1):
        ans[i] += ans[i-1]
    issame = True
    for i in range(N):
        if i != 0:
            if ans[i-1] != N or ans[i-1] != ans[i]:
                issame = False
        A[i] = ans[i]
    if issame:
        break

for i in range(N):
    print(ans[i], end=' ')

### FIXED CODE ###

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

ans = [0] * (N+1)

for j in range(K):
    ans = [0] * (N+1)
    for i in range(N):
        L = max(0, i-A[i])
        R = min(N, i+A[i]+1)
        ans[L] += 1
        ans[R] -= 1
    for i in range(1, N+1):
        ans[i] += ans[i-1]
    issame = True
    for i in range(N):
        if i != 0:
            if ans[i-1] != N or ans[i-1] != ans[i]:
                issame = False
        A[i] = ans[i]
    if issame:
        break

for i in range(N):
    print(ans[i], end=' ')
### BUGGY CODE ###

a, b, c, d = map(int, input().split())
e = []
for i in range(a, b + 1):
    for j in range(c, d + 1):
        e += [i * j]
print(max(e))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
e = []
for i in [a, b]:
    for j in [c, d]:
        e += [i * j]

print(max(e))
### BUGGY CODE ###

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

ans = 0

for i in range(n-k+1):
    tmp = sum(p[i:i+k]) / 2 + k / 2
    if ans < tmp:
        ans = tmp

print(ans)


### FIXED CODE ###

def exp(a):
    return (a + 1) / 2

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

tmp = [0] * (n + 1) 
ans = 0

for i in range(1, n+1):
    if i <= k:
        tmp[i] = tmp[i-1] + exp(p[i-1])
    else:
        tmp[i] = tmp[i-1] - exp(p[i-k-1]) + exp(p[i-1])

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

import os, sys, re, math

(N, Q) = [int(n) for n in input().split()]
S = input()

for i in range(Q):
    (l, r) = [int(n) for n in input().split()]
    substr = S[l - 1:r]
    replaced = re.sub('AC', '', substr)
    print((len(substr) - len(replaced)) // 2)


### FIXED CODE ###

import os, sys, re, math

(N, Q) = [int(n) for n in input().split()]
S = input()

oc = [0]
n = 0
for i in range(len(S) - 1):
    if S[i:i+2] == 'AC':
        n += 1
    oc.append(n)
oc.append(n)

for i in range(Q):
    (l, r) = [int(n) for n in input().split()]
    print(oc[r - 1] - oc[l - 1])
### BUGGY CODE ###

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

# import random
# N = 100
# K = 10**5
# A = [K] * N

if sum(A) < K:
  print(0)
  exit(0)


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret


from operator import add

t0 = [0] * (K+1)
t0[0] = 1

M = 10**9 + 7
for i in range(N):
    a = A[i]
    t1 = [0] * (K+1)
    st = SegmentTree(t0, add, 0)
    for k in range(K+1):
        t1[k] = st.query(max(0, k-a), k+1) % M
    t0 = t1

print(t0[K])


### FIXED CODE ###

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

# import random
# N = 100
# K = 10**5
# A = [K] * N

if sum(A) < K:
  print(0)
  exit(0)

t0 = [0] * (K+1)
t0[0] = 1

M = 10**9 + 7
for i in range(N):
    a = A[i]
    t1 = [0] * (K+1)
    st0 = [0]
    for t in t0:
        st0.append((t + st0[-1]) % M)
    for k in range(K+1):
        l = max(0, k-a)
        t1[k] = (st0[k+1] - st0[l]) % M
    t0 = t1

print(t0[K])
### BUGGY CODE ###

from collections import deque

h , w = map(int,input().split())
ma = [["#"]*(w+2)]
cou = 0
for i in range(h):
    kar = ["#"]
    kar.extend(list(input()))
    cou += kar.count(".")
    kar.append("#")
    ma.append(kar)
ma.append(["#"]*(w+2))

ans = [[-1 for i in range(w+2)] for j in range(h+2)]
ans[1][1] = 1
q = deque([(1,1)])
xy = [(1,0),(-1,0),(0,1),(0,-1)]

while q:
    x , y = q.popleft()
    ma[x][y] = "#"
    for i in range(4):
        nx = x + xy[i][0]
        ny = y + xy[i][1]
        if ma[nx][ny] == ".":
            q.append((nx,ny))
            ans[nx][ny] = ans[x][y] + 1
        if nx == h and ny == w:
            break

if ans[h][w] == -1:
    print(-1)
else:
    print(cou - ans[h][w])

### FIXED CODE ###

from collections import deque
 
h , w = map(int,input().split())
cou = 0
ma = []
for i in range(h):
    kar = list(input())
    cou += kar.count("#")
    ma.append(kar)
 
 
ans = [[-1 for i in range(w)] for j in range(h)]
ans[0][0] = 1
q = deque([(0,0)])
xy = [(1,0),(-1,0),(0,1),(0,-1)]
 
while q:
    x , y = q.popleft()
    for i in range(4):
        nx = x + xy[i][0]
        ny = y + xy[i][1]
        if 0 <= nx <= h-1 and 0 <= ny <= w-1 and ans[nx][ny] == -1:
            if ma[nx][ny] == ".":
                q.append((nx,ny))
                ans[nx][ny] = ans[x][y] + 1
        if nx == h-1 and ny == w-1:
            break
 
if ans[h-1][w-1] == -1:
    print(-1)
else:
    print(h*w - cou - ans[h-1][w-1])
### BUGGY CODE ###

import itertools

n = int(input())
s = input()
c = []
for i in range(n):
    c.append(i)
p_list = list(itertools.combinations(c, 3))
d = []
for i in range(len(p_list)):
    a = p_list[i][0]
    b = p_list[i][1]
    c = p_list[i][2]
    d.append(s[a] + s[b] + s[c])
print(len(set(d)))

### FIXED CODE ###


n = int(input())
s = input()
ans = 0
for i in range(10):
    if str(i) in s:
        t = s[s.index(str(i))+1:]
        for j in range(10):
            if str(j) in t:
                u = t[t.index(str(j))+1:]
                for k in range(10):
                    if str(k) in u:
                        ans +=1
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline


h, w = map(int, input().split())
A = []
B = []

for i in range(h):
    line = list(map(int, input().split()))
    A.append(line)

for i in range(h):
    line = list(map(int, input().split()))
    B.append(line)


def slide_down(y, x, possible):
    new = set()
    delta = abs(A[y+1][x] - B[y+1][x])
    limit = (h+w) * 80
    for num in possible:
        if num + delta <= limit - (y+x)*80:
            new.add(num+delta)
        if abs(num-delta) <= limit - (y+x)*80:
            new.add(abs(num-delta))
    return new


def slide_right(y, x, possible):
    new = set()
    delta = abs(A[y][x+1] - B[y][x+1])
    limit = (h+w) * 80
    for num in possible:
        if num + delta <= limit - (y+x)*80:
            new.add(num+delta)
        if abs(num-delta) <= limit - (y+x)*80:
            new.add(abs(num-delta))
    return new


DP = [[set() for j in range(w)] for i in range(h)]
DP[0][0] = {abs(A[0][0] - B[0][0])}
for row in range(h):
    for col in range(w):
        possible = DP[row][col]
        if col < w-1:
            new = slide_right(row, col, possible)
            DP[row][col+1] |= new
        if row < h-1:
            new = slide_down(row, col, possible)
            DP[row+1][col] |= new

ans = min(DP[h-1][w-1])
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline


h, w = map(int, input().split())
inf = float('INF')
A = []
B = []

for i in range(h):
    line = list(map(int, input().split()))
    A.append(line)

for i in range(h):
    line = list(map(int, input().split()))
    B.append(line)

D = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        D[i][j] = abs(A[i][j] - B[i][j])


def slide_down(y, x, possible):
    new = set()
    delta = D[y+1][x]
    limit = (h+w) * 80
    for num in possible:
        if num + delta <= limit - (y+x)*80:
            new.add(num+delta)
        if abs(num-delta) <= limit - (y+x)*80:
            new.add(abs(num-delta))
    return new


def slide_right(y, x, possible):
    new = set()
    delta = D[y][x+1]
    limit = (h+w) * 80
    for num in possible:
        if num + delta <= limit - (y+x)*80:
            new.add(num+delta)
        if abs(num-delta) <= limit - (y+x)*80:
            new.add(abs(num-delta))
    return new


DP = [[set() for j in range(w)] for i in range(h)]
DP[0][0] = {D[0][0]}
for row in range(h):
    for col in range(w):
        possible = DP[row][col]
        if col < w-1:
            new = slide_right(row, col, possible)
            DP[row][col+1] |= new
        if row < h-1:
            new = slide_down(row, col, possible)
            DP[row+1][col] |= new

ans = min(DP[h-1][w-1])
print(ans)
### BUGGY CODE ###

from itertools import permutations
N,M,R = map(int,input().split())
r = list(map(lambda x:int(x)-1,input().split()))
edges = [[] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    edges[a].append((b,c))
    edges[b].append((a,c))
V = N
INF = float("inf")
dp = [[INF]*V for _ in range(V)]
for i in range(V):
    for j, w in edges[i]:
        dp[i][j] = w
for k in range(V):
    for i in range(V):
        for j in range(V):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])

ans = INF
for p in permutations(r):
    t = 0
    for i in range(1, R):
        t += dp[p[i]][p[i-1]]
    ans = min(ans, t)
print(ans)

### FIXED CODE ###

from itertools import permutations
N,M,R = map(int,input().split())
r = list(map(lambda x:int(x)-1,input().split()))
edges = [[] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    edges[a].append((b,c))
    edges[b].append((a,c))
V = N
INF = float("inf")
dp = [[INF]*V for _ in range(V)]
for i in range(V):
    for j, w in edges[i]:
        dp[i][j] = w
for k in range(V):
    for i in range(V):
        for j in range(V):
            dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j])

ans = INF
for p in permutations(r):
    t = 0
    for i in range(1, R):
        t += dp[p[i]][p[i-1]]
    ans = min(ans, t)
print(ans)
### BUGGY CODE ###

n = int(input())

a = [int(input()) for i in range(n)]

for i in range(n):
    a2 = a[:]
    a2.pop(i)
    print(max(a2))

### FIXED CODE ###

n = int(input())

a = [int(input()) for i in range(n)]
a_max = max(a)
a2 = a[:]
a2.remove(a_max)
a_second_max = max(a2)

for i in range(n):
    if a[i] == a_max:
        print(a_second_max)
    else:
        print(a_max)