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

S=input()
K=int(input())
while True:
    if S[0]!="1":
        print(S[0])
        break
    else:
        continue

### FIXED CODE ###

S=input()
K=int(input())
t=0
for i in range(len(S)):
    if S[i]!="1":
        print(S[i])
        break
    else:
        t+=1
        if t>=K:
            print("1")
            break
        else:
            continue
### BUGGY CODE ###

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

ans=1
for a in A_list:
    ans=ans*a
if ans>10**18:
    ans=-1
print(ans)

### FIXED CODE ###

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

ans=1
if 0 in A_list:
    ans=0
else:
    for a in A_list:
        ans=ans*a
        if ans>10**18:
            ans=-1
            break
print(ans)
### BUGGY CODE ###

from itertools import combinations
N = int(input())
S = list(input())
print(len(set(tuple(combinations(S, 3)))))


### FIXED CODE ###

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

ans = 0

for i in range(10):
    if str(i) not in S:
        continue
    ind_i = S.index(str(i))
    for j in range(10):
        if str(j) not in S[ind_i+1:]:
            continue
        ind_j = S[ind_i+1:].index(str(j)) + ind_i+1
        for k in range(10):
            if str(k) in S[ind_j+1:]:
                ans += 1

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

N,K = (int(i) for i in input().split())


MAX = int(2*N/K+1)

ans1=0
ans2=0
ans3=0

for alpha in range(1,MAX):
    for beta in range(alpha,MAX):
        for gamma in range(beta,MAX):
            a = K*(alpha-beta+gamma)
            b = K*(alpha+beta-gamma)
            c = K*(-alpha+beta+gamma)
            if(all([a>0,b>0,c>0]) and
            all([a<=N*2,b<=N*2,c<=N*2]) and
            all([a%2==0,b%2==0,c%2==0])
            ):
                if a==b and b==c:
                    ans1+=1
                elif a==b or b==c or c==a:
                    ans2+=1
                else:
                    ans3+=1

print(ans1+ans2*3+ans3*6)

### FIXED CODE ###

N,K = (int(i) for i in input().split())

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

import sys
sys.setrecursionlimit(1000000000)
from functools import lru_cache

S = input()

DEVIDER = 10**9 + 7


def add(a, b):
    return (a + b) % DEVIDER

def mul(a, b):
    return (a % DEVIDER) * (b % DEVIDER) % DEVIDER

cache_size = len(S) * 4

@lru_cache(maxsize=32)
def check(s, j):
    if j == 0 and s == 'A':
        return True
    if j == 1 and s == 'B':
        return True
    if j == 2 and s == 'C':
        return True
    return False

@lru_cache(maxsize=cache_size)
def dp(i, j):
    if i == len(S) and j == 3:
        # end of task
        return 1
    elif i == len(S) and j < 3:
        # fail
        return 0
    elif i < len(S) and j == 3:
        # next
        if S[i] == "?":
            return mul(3,  dp(i + 1, 3))
        else:
            return dp(i + 1, 3)
    else:
        # i < len(S) and j < 3
        if S[i] == "?":
            return add(mul(3, dp(i + 1, j)),  dp(i + 1, j + 1))
        if check(S[i], j):
            return add(dp(i + 1, j), dp( i + 1, j + 1))
        return dp(i + 1, j)


ret = dp(0, 0)
print(ret)





### FIXED CODE ###

import sys

S = input()

DEVIDER = 10**9 + 7


def add(a, b):
    return (a + b) % DEVIDER

def mul(a, b):
    return (a % DEVIDER) * (b % DEVIDER) % DEVIDER

cache = [[0 for _ in range(4)] for _ in range(len(S) + 1)]
cache[0][0] = 1


def check(s, j):
    if j == 0 and s == 'A':
        return True
    if j == 1 and s == 'B':
        return True
    if j == 2 and s == 'C':
        return True
    return False


for i in range(len(S)):
    for j in range(4):
        if S[i] == '?':
            cache[i + 1][j] += 3 * cache[i][j]
        else:
            cache[i + 1][j] += cache[i][j]
        if j > 0:
            if check(S[i], j-1) or S[i] == '?':
                cache[i+1][j] += cache[i][j - 1]
        cache[i+1][j] %= DEVIDER

print(cache[len(S)][3])
### BUGGY CODE ###

H, W, M = map(int, input().split())
bombs = [list(map(lambda x:int(x) - 1, input().split())) for _ in range(M)]
field = [[False] * W for _ in range(H)]

max_hw = max(H, W)
H_count = {i:0 for i in range(max_hw)}
W_count = {i:0 for i in range(max_hw)}

for i in range(M):
    h, w = bombs[i]
    field[h][w] = True
    H_count[h] += 1
    W_count[w] += 1


A = max(H_count.values())
B = max(W_count.values())
Ah = []
Bw = []

for i in range(max_hw):
    if H_count[i] == A:
        Ah.append(i)
    if W_count[i] == B:
        Bw.append(i)

ans = A + B
FLG = True
for h in Ah:
    for w in Bw:
        if not field[h][w]:
            FLG = False
            break
    if not FLG:
        break

print(ans - FLG)


### FIXED CODE ###

H, W, M = map(int, input().split())
bombs = set()

H_count = [0 for i in range(H)]
W_count = [0 for i in range(W)]

for i in range(M):
    h, w = map(lambda x:int(x) - 1, input().split())
    bombs.add((h, w))
    H_count[h] += 1
    W_count[w] += 1


A = max(H_count)
B = max(W_count)
Ah = []
Bw = []

for i, count in enumerate(H_count):
    if count == A:
        Ah.append(i)

for i, count in enumerate(W_count):
    if count == B:
        Bw.append(i)

ans = A + B
for h in Ah:
    for w in Bw:
        if (h, w) not in bombs:
            print(ans)
            exit()

print(ans - 1)
### BUGGY CODE ###

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

import sys
from collections import defaultdict

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,Q=MAP()
S=input()

D=defaultdict(lambda: [])
golems=[INF]+[1]*N+[INF]

for i in range(N):
    D[S[i]].append(i)

for i in range(Q):
    t,d=input().split()
    if d=='L':
        for j in D[t]:
            if j!=0:
                golems[j]+=golems[j+1]
            golems[j+1]=0
            
    elif d=='R':
        for j in reversed(D[t]):
            if j!=N+2:
                golems[j+2]+=golems[j+1]
            golems[j+1]=0

print(sum(golems[1:N+1]))


### FIXED CODE ###

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

"""
参考：https://img.atcoder.jp/exawizards2019/editorial.pdf
・二分探索
"""

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,Q=MAP()
S=input()
TD=[input().split() for i in range(Q)]

# ある位置にいるゴーレムを動かして、左端から外に出ないか判定する
def calc1(m):
    if m==-1:
        return False
    if m==N:
        return True
    idx=m
    s=S[idx]
    for i in range(Q):
        t,d=TD[i]
        if t==s:
            if d=='L':
                idx-=1
            elif d=='R':
                idx+=1
        if idx<0:
            return False
        if idx>=N:
            return True
        s=S[idx]
    return True

# ある位置にいるゴーレムを動かして、右端から外に出ないか判定する
def calc2(m):
    if m==-1:
        return True
    if m==N:
        return False
    idx=m
    s=S[idx]
    for i in range(Q):
        t,d=TD[i]
        if t==s:
            if d=='L':
                idx-=1
            elif d=='R':
                idx+=1
        if idx>=N:
            return False
        if idx<0:
            return True
        s=S[idx]
    return True

low=-1
hi=N
while low+1<hi:
    mid=(hi+low)//2
    if calc1(mid):
        hi=mid
    else:
        low=mid
# 左端にたどり着かない(生き残る)ゴーレムのうち、初期位置が最も左のもの
lowest=hi

low=-1
hi=N
while low+1<hi:
    mid=(hi+low)//2
    if calc2(mid):
        low=mid
    else:
        hi=mid
# 右端にたどり着かない(生き残る)ゴーレムのうち、初期位置が最も右のもの
highest=low

print(max(highest-lowest+1, 0))
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop,heappush

class BIT():
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size

    def get_sum(self,i):
        s = 0
        while i:
            s += self.tree[i]
            i -= i & -i
        return s

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

n,q = map(int,readline().split())
c = list(map(int,readline().split()))
lr = list(map(int,read().split()))
it = iter(lr)
hq = []
for i,l,r in zip(range(q),it,it):
    heappush(hq, (r-1,l-1,i))

st = BIT(n+1)
ans = [0] * q
before = [-1] * (n+1)
c_ind = 0
while(hq):
    r,l,i = heappop(hq)
    while(c_ind <= r):
        st.add(c_ind+1,1)
        bef = before[c[c_ind]]
        if(bef!=-1):
            st.add(bef+1,-1)
        before[c[c_ind]] = c_ind
        c_ind += 1

    ans[i] = st.get_sum(r+1) - st.get_sum(l)

print('\n'.join(map(str,ans)))

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class Seg_sum():
    def __init__(self,x):
        #####単位元######
        self.ide_ele_min = 0
        self.func = lambda a,b : a+b

        self.n = len(x)

        #num_max:n以上の最小の2のべき乗
        self.num_max =2**(self.n-1).bit_length()
        self.x = [self.ide_ele_min]*2*self.num_max

        for i,num in enumerate(x, self.num_max):
            self.x[i] = num
        for i in range(self.num_max-1,0,-1):
            self.x[i] = self.func(self.x[i<<1],self.x[(i<<1) + 1])

    def update(self,i,x):
        i += self.num_max
        self.x[i] = x
        while(i>0):
            i = i//2
            self.x[i] = self.func(self.x[i<<1],self.x[(i<<1) + 1])

    def query(self,i,j):
        res = self.ide_ele_min
        if i>=j:
            return res
        i += self.num_max
        j += self.num_max -1
        while(i<=j):
            if(i==j):
                res = self.func(res,self.x[i])
                break
            if(i&1):
                res = self.func(res,self.x[i])
                i += 1
            if(not j&1):
                res = self.func(res,self.x[j])
                j -= 1
            i = i>>1
            j = j>>1
        return res

n,q = map(int,readline().split())
c = tuple(map(int,readline().split()))
lr = tuple(map(int,read().split()))
it = iter(lr)
lrq = [[] for _ in range(n)]
for i,l,r in zip(range(q),it,it):
    lrq[r-1].append((l-1,i))

st = Seg_sum([1]*(n+1))
ans = [0] * q
before = [-1] * (n+1)
c_ind = 0
for r in range(n):
    for l,i in lrq[r]:
        while(c_ind <= r):
            bef = before[c[c_ind]]
            if(bef!=-1):
                st.update(bef,0)
            before[c[c_ind]] = c_ind
            c_ind += 1

        ans[i] = st.query(l,r+1)

print('\n'.join(map(str,ans)))
### BUGGY CODE ###

from collections import defaultdict
from heapq import heapify, heappop
import heapq
n,m,s,t =list(map(int,input().split()))

MAX_VAL = 10**20
uvab =  [list(map(int,input().split())) for _ in range(m)]
jpy_cost = defaultdict(lambda :defaultdict(lambda :MAX_VAL))
snuke_cost = defaultdict(lambda :defaultdict(lambda :MAX_VAL))


for u,v,a,b in uvab:
    u=u-1
    v=v-1
    jpy_cost[u][v] = a
    jpy_cost[v][u] =a
    snuke_cost[u][v]=b
    snuke_cost[v][u]=b


# Dijktra's shortest path algorithm. Prints the path from source to target.


def dijkstra(adj, source):
    INF = MAX_VAL
    dist = [INF for x in range(n)]
    dist[source] = 0
    PQ = []
    heapq.heappush(PQ, [dist[source], source])

    while (PQ):
        u_dist,u_id = heapq.heappop(PQ)  # u is a tuple [u_dist, u_id]
        if u_dist == dist[u_id]:
            for v in adj[u_id]:
                w_uv = adj[u_id][v]
                if dist[u_id] + w_uv < dist[v]:
                    dist[v] = dist[u_id] + w_uv
                    heapq.heappush(PQ, [dist[v], v])
    return dist


jpy_dijk =  dijkstra(jpy_cost,s-1)
snuke_dijk = dijkstra(snuke_cost,t-1)
#
# print(s,t)
# print(jpy_dijk)
# print(snuke_dijk)
# print([jpy_dijk[i]+snuke_dijk[i] for i in range(n)])

#ord n
res = []
min_val = MAX_VAL
for i in reversed(range(n)):
    #都市  i で両替
    val = jpy_dijk[i]+ snuke_dijk[i]
    assert val < MAX_VAL
    min_val=min(min_val,val)
    res.append(min_val)
#ord n
for x in reversed(res):
    print(10**15-  x)


### FIXED CODE ###

from collections import defaultdict
from heapq import heapify, heappop
import heapq
n,m,s,t =list(map(int,input().split()))

MAX_VAL = 10**20
uvab =  [list(map(int,input().split())) for _ in range(m)]
jpy_cost = defaultdict(dict)
snuke_cost = defaultdict(dict)


for u,v,a,b in uvab:
    u=u-1
    v=v-1
    jpy_cost[u][v] = a
    jpy_cost[v][u] =a
    snuke_cost[u][v]=b
    snuke_cost[v][u]=b


# Dijktra's shortest path algorithm. Prints the path from source to target.


def dijkstra(adj, source):
    INF = MAX_VAL
    dist = [INF for x in range(n)]
    dist[source] = 0
    PQ = []
    heapq.heappush(PQ, [dist[source], source])

    while (PQ):
        u_dist,u_id = heapq.heappop(PQ)  # u is a tuple [u_dist, u_id]
        if u_dist == dist[u_id]:
            for v in adj[u_id]:
                w_uv = adj[u_id][v]
                if dist[u_id] + w_uv < dist[v]:
                    dist[v] = dist[u_id] + w_uv
                    heapq.heappush(PQ, [dist[v], v])
    return dist


jpy_dijk =  dijkstra(jpy_cost,s-1)
snuke_dijk = dijkstra(snuke_cost,t-1)
#
# print(s,t)
# print(jpy_dijk)
# print(snuke_dijk)
# print([jpy_dijk[i]+snuke_dijk[i] for i in range(n)])

#ord n
res = []
min_val = MAX_VAL
for i in reversed(range(n)):
    #都市  i で両替
    val = jpy_dijk[i]+ snuke_dijk[i]
    assert val < MAX_VAL
    min_val=min(min_val,val)
    res.append(min_val)
#ord n
for x in reversed(res):
    print(10**15-  x)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ans=ans*a[i]
if ans>10**18:
    print("-1")
    exit()
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print("0")
    exit()
else:
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            print("-1")
            exit()
    print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
def cal(x):
    divisors = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            divisors.append(i)
            if i != x // i:
                divisors.append(x//i)
    return divisors
num=[0 for _ in range(n+1)]
cnt=0
ans=[]
for k in range(n):
    if (num[n-k]+1)%2==a[-1-k]:
        ans.append(n-k)
        cnt+=1
        l=cal(n-k)
        for p in l:
            num[p]+=1
ans1=[]
for j in range(cnt):
    if j<cnt-1:
        ans1.append(str(ans[j]))
        ans1.append(" ")
    else:
        ans1.append(str(ans[j]))
print(cnt)
if len(ans1)>0:
    result=''.join(ans1)
    print(result)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
def cal(x):
    divisors = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            divisors.append(i)
            if i != x // i:
                divisors.append(x//i)
    return divisors
num=[0 for _ in range(n+1)]
cnt=0
ans=[]
for k in range(n):
    if (num[n-k]+1)%2==a[-1-k]:
        ans.append(n-k)
        cnt+=1
        l=cal(n-k)
        for p in l:
            num[p]+=1
ans1=[]
for j in range(cnt):
    if j<cnt-1:
        ans1.append(str(ans[j]))
        ans1.append(" ")
    else:
        ans1.append(str(ans[j]))
print(cnt)
if len(ans1)>0:
    result=''.join(ans1)
    print(result)
### BUGGY CODE ###

import sys
from collections import deque
import copy
def main():
    N = int(input())
    S = input()
    ans = 0
    for i in range(10):
            for j in range(10):
                    for k in range(10):
                        flag_i = False
                        flag_j = False
                        flag_k = False
                        for t in range(N):
                            if not flag_i and S[t] == str(i):
                                flag_i = True
                            elif flag_i and not flag_j and S[t] == str(j):
                                flag_j = True                           
                            elif flag_i and flag_j and not flag_k  and S[t] == str(k):
                                flag_k = True
                        if flag_i and flag_j and flag_k:
                            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    S = input()
    ans = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                flag_i = False
                flag_j = False
                flag_k = False
                for t in range(N):
                    if not flag_i and S[t] == str(i):
                        flag_i = True
                    elif flag_i and not flag_j and S[t] == str(j):
                        flag_j = True                           
                    elif flag_i and flag_j and not flag_k and S[t] == str(k):
                        flag_k = True
                if flag_i and flag_j and flag_k:
                    ans += 1
    print(ans)


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

N = int(input())
lst = []
dic = {}
for i in range(0,N):
  lst.append(input())

for i in list(set(lst)):
  dic[i] = lst.count(i)

keys = [k for k,v in dic.items() if v == max(dic.values())]

keys.sort()

for i in range(0,len(keys)):
  print(keys[i])


### FIXED CODE ###

N = int(input())
dic = {}
for i in range(0,N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] +=1

m = max(dic.values())

keys = [k for k,v in dic.items() if v == m]

keys.sort()

for i in range(0,len(keys)):
  print(keys[i])
### BUGGY CODE ###

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

def gcd(a, b):
  while b != 0:
    a, b = b, a%b
  return a

def lcm(a, b):
  return (a* b) // gcd(a, b)

t = 1
for i in range(n):
  t = lcm(t, l[i])

ans = 0
for i in range(n):
  ans += t//l[i]
ans %= 10**9+7

print(ans)

### FIXED CODE ###

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

def gcd(a, b):
  while b != 0:
    a, b = b, a%b
  return a

def lcm(a, b):
  return (a* b) // gcd(a, b)

t = 1
for i in range(n):
  t = lcm(t, l[i])

ans = 0
for i in range(n):
  ans += t//l[i]
ans %= 10**9+7

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

L, R = list(map(int, input().split()))

min_mod = 2018
for key, i in enumerate(range(L, R+1)):
    t = R - key
    for j in range(L, t):
        mod = (t * j) % 2019
        if mod < min_mod:
            min_mod = mod
        
        if min_mod == 0:
            break

print(min_mod)

### FIXED CODE ###

l, r = list(map(int,input().split()))

if r - l >= 2019:
  print(0)
  
else:
  ll = l % 2019
  rr = r % 2019
  if rr < ll:
    print(0)
    
  else:
    keep = 2020
    for i in range(ll, rr+1):
      for j in range(i+1, rr+1):
        keep = min((i*j)%2019, keep)
    print(keep)
### BUGGY CODE ###

def gca(x, y):
    if x == 0:
        return y
    return gca(y % x, x)

N = int(input())
A = [int(i) for i in input().split()]

maxg = 0
for ignore in  range(N):
    g = A[0]
    if ignore == 0:
        g = A[1]
    for i in range(N):
        if i == ignore:
            continue
        g = gca(g, A[i])

    maxg = max(g, maxg)

print(maxg)

### FIXED CODE ###

def gca(x, y):
    if x == 0:
        return y
    return gca(y % x, x)

N = int(input())
A = [int(i) for i in input().split()]

L = [0] * N
R = [0] * N
L[0] = A[0]
R[N - 1] = A[N - 1]

for i in range(1, N):
    L[i] = gca(A[i], L[i - 1])
for i in range(N - 2, -1, -1):
    R[i] = gca(A[i], R[i + 1])
maxg = 0
for i in range(1, N - 1):
    maxg = max(maxg, gca(L[i - 1], R[i + 1]))

print(max(L[N - 2], R[1], maxg))
### BUGGY CODE ###

import numpy as np
import math

# input

N = int(input())
s = [str(input()) for _ in range(N)]

# sort
for i in range(0,N):
    s[i] = sorted(s[i])
    
def Number_Each_Element(group):
    group = sorted(group)
    discrepancy = np.array([])
    
    for i in range(len(group)-1):
        if group[i] != group[i+1]:
            discrepancy = np.append(discrepancy,i)
    discrepancy = np.append(discrepancy,len(group)-1)
    
    
    result = np.ones(len(discrepancy))
    for i in range(len(result)):
        if i == 0:
            result[i] = int(discrepancy[i]+1)
        else:
            result[i] = int(discrepancy[i]-discrepancy[i-1])
            
            
    return result

result = Number_Each_Element(s)

count = 0
for i in result:
    count += i*(i-1)/2

print(int(count))

### FIXED CODE ###

import numpy as np

def Speed_Anag_Count(String):
    count = {}
    for i in String:
        i = sorted(i)
        i = str(''.join(i))
        if count.get(i) is None:
            count[i] = 0
        count[i] += 1
    
    return count

N = int(input())

S = [str(input()) for _ in range(N)]

count = Speed_Anag_Count(S)

ans=0
for i in count.values():
    ans += (i*(i-1)/2)
    
print(int(ans))
### BUGGY CODE ###

n, q = map(int,input().split())
s = input()

l = [0] * q
r = [0] * q

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

s_list = list(s)

ac_list = [0] * (n-1)

for i in range(0,n-1):
    if s_list[i] == "A" and s_list[i+1] == "C":
        ac_list[i] = 1

for i in range(0,q):
    print(sum(ac_list[l[i]:r[i]]))

### FIXED CODE ###

n, q = map(int,input().split())
s = input()

l = [0] * q
r = [0] * q

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

s_list = list(s)

ac_list = [0] * (n-1)

for i in range(0,n-1):
    if s_list[i] == "A" and s_list[i+1] == "C":
        ac_list[i] = 1

#print(ac_list)

w = [0] * (n-1)

w[0] = ac_list[0]

for i in range(1,n-1):
    w[i] = w[i-1] + ac_list[i]

#print(w)

for i in range(0,q):
    if l[i] == 0:
        print(w[r[i]-1])
    else:
        print(w[r[i]-1]-w[l[i]-1])
### BUGGY CODE ###

import sys

n = int(input())

list1 = []

for i in range (n):
    s = input()
    if s not in list1:
        list1.append(s)

ans = len(list1)
print(ans)

### FIXED CODE ###

N = int(input())
S = list()
for i in range(N):
  S.append(input())
S1 = set(S)
print(len(S1))
### BUGGY CODE ###

N, K = map(int, input().split())
*h, = map(int, input().split())
dp = [0] + [float('inf')]*(N-1)
for j in range(1,N):
    for i in range(max(0,j-K),j):
        dp[j] = min(dp[j],dp[i] + abs(h[j]-h[i]))
        # print("j -> {} || i -> {} || dp -> {} || h[j] -> {} || h[i] -> {}".format(j, i, dp, h[j], h[i]))
print(dp[-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, K = map(int, input().rstrip().split())
*h, = map(int, input().rstrip().split())
dp = [0] + [float('inf')]*(N-1)
for j in range(1,N):
    for i in range(max(0,j-K),j):
        dp[j] = min(dp[j],dp[i] + abs(h[j]-h[i]))
        # print("j -> {} || i -> {} || dp -> {} || h[j] -> {} || h[i] -> {}".format(j, i, dp, h[j], h[i]))
print(dp[-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import copy
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    Am = max(A)
    for i in range(N):
        if i != A.index(Am) or A.count(Am)>1:
            print(Am)
            continue
        Ap = []
        Ap = copy.copy(A)
        del Ap[i]
        print(max(Ap))
if __name__ == '__main__':
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*-
import copy
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    Am = max(A)
    if A.count(Am)>1:
        for j in range(N):
            print(Am)
        return
    Ap = copy.copy(A)
    set(Ap)
    Ap.sort(reverse=True)
    for i in range(N):
        if  A[i] != Am:
            print(Am)
        else:
            print(Ap[1])
if __name__ == '__main__':
    main()