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

from collections import Counter
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, m, r = read_line(int, int, int)

rs = [int(r) for r in input().split()]

cities = Counter()

routes = {}
costs = {}
for _ in range(m):
    a, b, c = read_line(int, int, int)

    cities[a] = 1
    cities[b] = 1

    if a in routes:
        routes[a][b] = c
    else:
        routes[a] = { b : c }

    if b in routes:
        routes[b][a] = c
    else:
        routes[b] = { a : c }

for a in cities.keys():
    for b in cities.keys():
        if a not in costs:
            costs[a] = {}
        if b not in costs[a]:
            if a in routes and b in routes[a]:
                costs[a][b] = routes[a][b]
            else:
                costs[a][b] = 100000 + 1

for k in cities.keys():
    for a in cities.keys():
        for b in cities.keys():
            if costs[a][b] > costs[a][k] + costs[k][b]:
                costs[a][b] = costs[a][k] + costs[k][b]

def cost(selected):
    c = 0
    for i in range(len(selected) - 1):
        a = selected[i]
        b = selected[i + 1]
        c += costs[a][b]
    return c

smallest = 100000 + 1

def passing_all_cities(selected):
    for r in rs:
        if r not in selected:
            return False
    return True

def f(selected, rest):
    global smallest
    if len(rest) == 0 or passing_all_cities(selected):
        c = cost(selected)
        if smallest > c:
            smallest = c
    else:
        for i in range(len(rest)):
            r = rest[i]
            rest_copy = rest[:]
            del rest_copy[i]
            if cost(selected + [r]) < smallest:
                f(selected + [r], rest_copy)

f([], list(cities.keys()))
print(smallest)


### FIXED CODE ###

from itertools import permutations

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, m, r = read_line(int, int, int)

rs = [int(r) for r in input().split()]

costs = {}
for i in range(n + 1):
    costs[i] = {}
    for j in range(n + 1):
        costs[i][j] = float('inf')

for _ in range(m):
    a, b, c = read_line(int, int, int)

    costs[a][b] = costs[b][a] = c

for k in range(n + 1):
    for i in range(n + 1):
        for j in range(n + 1):
            c = costs[i][k] + costs[k][j]
            if costs[i][j] > c:
                costs[i][j] = c

def cost(selected):
    c = 0
    for i in range(len(selected) - 1):
        a = selected[i]
        b = selected[i + 1]
        c += costs[a][b]
    return c

smallest = float('inf')

for p in permutations(rs):
    c = cost(p)
    if smallest > c:
        smallest = c

print(smallest)
### BUGGY CODE ###

A,B,K=map(int,input().split())
for i in range(A,B+1) :
  if i < A+K or B-K < i :
    print(i)

### FIXED CODE ###

A,B,K=map(int,input().split())
if B-A < K :
  for i in range(A,B+1) :
    if i < A+K or B-K < i :
      print(i)
else :
  S=set()
  for i in range(K) :
    S.add(A+i)
    S.add(B-i)
  L=list(S)
  L.sort() 
  for i in L :
    print(i)
### BUGGY CODE ###

k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        for n in range(k + 1):
            if i + j + n == s:
                count += 1

print(count)


### FIXED CODE ###

k, s = map(int, input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            count += 1

print(count)
### BUGGY CODE ###

import math
a,b,n=map(int,input().split())
max=-2
for i in range(1,n+1):

    s=math.floor(a*i/b)-a*math.floor(i/b)
    if s>max:
        max=s
    if max==a/b:
        continue
print(max)

### FIXED CODE ###

import math
a,b,n=map(int,input().split())
max=-2
if n<b:
    max=math.floor(a*n/b)
else:
    #b<=n
    max=math.floor(a*(b-1)/b)
    

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

n = int(input())
t = [0]+[int(i) for i in input().split()]+[0]
v = [int(i) for i in input().split()]+[0]
def f(x,v,t1,t2):
	if x<t1: return v+(t1-x)
	elif t1<=x<=t2: return v
	else: return v+(x-t2)
a,ans = [],0
for i in range(1,n+2): t[i]+=t[i-1]
for i in range(2*t[-1]+1):
	num = i/2
	for j in range(n+1): num = min(num,f(i/2,v[j],t[j],t[j+1]))
	a.append(num)
for i in range(len(a)-1): ans+=(a[i]+a[i+1])/4
print(ans)

### FIXED CODE ###

from bisect import bisect_left
n = int(input())
t = [0]+[int(i) for i in input().split()]+[0]
v = [int(i) for i in input().split()]+[0]
def f(x,v,t1,t2):
	if x<t1: return v+(t1-x)
	elif t1<=x<=t2: return v
	else: return v+(x-t2)
for i in range(1,n+2): t[i]+=t[i-1]
T,ans = t[-1],0
for i in range(2*T+1):
	num = min(i/2,T-i/2)
	for j in range(max(0,bisect_left(t,i/2-100)-1),n+1):
		if i/2<t[j]-100: break
		num = min(num,f(i/2,v[j],t[j],t[j+1]))
	ans+=num/2
print(ans)
### BUGGY CODE ###

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

ans = list()

for i in range(1, N+1):
    k = 0
    while la[k] != i:
        k += 1
    ans.append(k+1)

print(*ans)

### FIXED CODE ###

import numpy as np

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

ans = np.argsort(la) + 1

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

N,K,Q = map(int,input().split())
ps = [K]*N

ac = []
for i in range(Q):
    an = int(input())
    ps[an -1] += 1
    for j in range(len(ps)):
        ps[j] = ps[j] - 1
        
    
for k in ps:
    if k > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n, k, q = map(int, input().split())
n_score = [0] * n
for i in range(q):
    n_score[int(input()) - 1] += 1

for j in n_score:
    if k + j - q > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import sys
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
V = [list(map(int,inputs().split())) for p in [0]*N]

for q in [0]*Q:
	ans = sys.maxsize
	m = int(inputs())
	for v in V:
		if v[0] - v[2] <=m and m <= v[1] - v[2] -1:
			ans = min(v[2],ans)
	if ans < sys.maxsize:
		print(ans)
	else:
		print(-1)

### FIXED CODE ###

import sys
from operator import itemgetter
def main():
	inputs = sys.stdin.readline
	N, Q= map(int,inputs().split())
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while e[0] > d:
			if cont == True:
				print(mini-(mini//1000000001)*1000000002)
			else:
				mini = min(kouho)
				print(mini-(mini//1000000001)*1000000002)
			cont = True
			q = q + 1
			if q > Q-1:
				flag = True
				break
			d = int(inputs())
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			if mini == e[2]:
				cont = False
	for t in [None]*(Q-q):
		print(-1)
main()
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
li.sort()
dp = [1]*n
done = [0]*n

for i in range(n):
    if done[i]==1:
        continue
    for j in range(i+1,n):
        if done[j] == 0:
            if li[j]==li[i]:
                done[i]=1
                done[j]=1
                dp[i]=0
                dp[j]=0
                continue
            elif li[j]%li[i]==0:
                done[j]=1
                dp[j]=0
 
print(sum(dp))

### FIXED CODE ###

n  = int(input())
li = list(map(int,input().split()))
ok = set()
ng = set()
mul = set()

ans = 0

for i in li:
    if i not in ok:
        ok.add(i)
    else:
        ng.add(i)

for i in ok:
    for j in range(2,10**6):
        if i*j > 10**6:
            break
        else:
            mul.add(i*j)

for i in ok:
    if i not in mul:
        if i not in ng:
            ans+=1

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

s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*10*d
    amari[temp%2019] += 1
    d *= 10

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))













### FIXED CODE ###

s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

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

import math

def nCr(n,r):

    if n-r >= 0:
        return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    else:
        return 0

def wantp(n):

    nown = n
    Q = []
    while True:

        if nown != p[nown]:
            Q.append(nown)
            nown = p[nown]

        else:
            #for i in Q:
            #    p[i] = nown
            break

    return nown


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

AB = []
for i in range(M):

    A,B = map(int,input().split())

    AB.append([A-1,B-1])

AB.reverse()


ans = []
ans.append(nCr(N,2))

p = []
c = []
rank = [1] * N

for i in range(N):

    p.append(i)
    c.append(1)

for i in range(M):

    a = AB[i][0]
    b = AB[i][1]

    ap = wantp(a)
    bp = wantp(b)


    now = ans[-1]

    if ap != bp:
        now = now + nCr(c[ap],2) + nCr(c[bp],2) - nCr(c[ap]+c[bp],2)

        if rank[ap] > rank[bp]:

            p[bp] = ap
            c[ap] += c[bp]

        elif rank[ap] < rank[bp]:

            p[ap] = bp
            c[bp] += c[ap]

        else:

            p[ap] = bp
            c[bp] += c[ap]

            rank[bp] += 1

    ans.append(now)

ans.reverse()

for i in range(M):
    print (ans[i+1])


### FIXED CODE ###

import math

def nCr(n,r):

    if n-r >= 0:
        return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    else:
        return 0

def nC2(n):
    if n-2 >= 0:
        return (n*(n-1)) // 2
    else:
        return 0

def wantp(n): #Union-Find木の親の探索

    nown = n
    Q = []
    cnt = 0
    while True:

        if nown != p[nown]:
            Q.append(nown)
            nown = p[nown]

        else:
            for i in Q: #探索した途中にあるノードの親を根に変更
                p[i] = nown
                cnt += 1

            break

        cnt += 1

        if cnt > 10:
            print (n,nown,p[nown])

    return nown


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

AB = []
for i in range(M):

    A,B = map(int,input().split())

    AB.append([A-1,B-1])

AB.reverse()


ans = []
ans.append(nCr(N,2))

p = [] #親
c = [] #子の数
rank = [1] * N #そのノードの子で構成された木の深さ

for i in range(N):

    p.append(i)
    c.append(1)

for i in range(M): #最後の橋から1本ずつ足していく

    #if i % 1000 == 0 or i > 25000:
        #print (i)

    #if i > 25000 : print ("A")

    a = AB[i][0]
    b = AB[i][1]

    #if i > 25000 : print ("B") 

    ap = wantp(a)
    bp = wantp(b)

    #if i > 25000 : print ("C")

    now = ans[-1]

    if ap != bp: #前回の答えから導出、Union-Find木の結合
        now = now + nC2(c[ap]) + nC2(c[bp]) - nC2(c[ap]+c[bp])

        #if i > 25000 : print ("D")

        if rank[ap] > rank[bp]:

            p[bp] = ap
            c[ap] += c[bp]

        elif rank[ap] < rank[bp]:

            p[ap] = bp
            c[bp] += c[ap]

        else:

            p[ap] = bp
            c[bp] += c[ap]

            rank[bp] += 1

        #if i > 25000 : print ("E")

    ans.append(now)
    #if i > 25000 : print ("F")
    #print (now,p)

#print ("test")
ans.reverse()

for i in range(M):
    print (ans[i+1])
### BUGGY CODE ###

n,x=map(int,input().split())
*a,=map(int,input().split())

v=[i if i<x else x for i in a]
b=[v[i]+v[i+1]<=x for i in range(n-1)]     

while not all(b):
    f=True
    for i in range(n-2):
        if not b[i] and not b[i+1]:
            v[i+1]=x-v[i]
            f=False
            break
    if f:
        for i in range(n-1):
            if not b[i]:
                v[i]=min(x-v[i-1],x-v[i+1])
                break
    b=[v[i]+v[i+1]<=x for i in range(n-1)]     
    
print(sum(a)-sum(v))

### FIXED CODE ###

n,x=map(int,input().split())
*a,=map(int,input().split())

v=[i if i<x else x for i in a]

for i in range(n-1):
    if v[i]+v[i+1]>x:
        v[i+1]=x-v[i]

print(sum(a)-sum(v))
### BUGGY CODE ###

#D
N=int(input())
S=str(input())
password_list=[]
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      password_list += [S[i]+S[j]+S[k]]
answer=len(list(set(password_list)))
print(answer)

### FIXED CODE ###

#D
import itertools
N=int(input())
S=str(input())
count=0
for i,j,k in itertools.product(range(10),repeat=3):
  try:
    x = S.index(str(i))
    y = S.index(str(j),x+1)
    z = S.index(str(k),y+1)
    count +=1
  except:
    continue

print(count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
H, W = map(int, input().split())
S = [input() for _ in range(H)]
R = [[0] * W for _ in range(H)]
L = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == '.':
			if j > 0:
				L[i][j] = L[i][j - 1] + 1
			elif j == 0:
				L[i][j] = 1
				
			if i > 0:
				U[i][j] = U[i - 1][j] + 1
			elif i == 0:
				U[i][j] = 1
		
		if S[i][W - j - 1] == '.':
			if j > 0:
				R[i][W - j - 1] = R[i][W - j] + 1
			elif j == 0:
				R[i][W - j - 1] = 1
		
		if S[H - i - 1][j] == '.':
			if i > 0:
				D[H - i - 1][j] = D[H - i][j] + 1
			elif i == 0:
				D[H - i - 1][j] = 1
			
ans = 0
for i in range(H):
	for j in range(W):
		tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
		if tmp > ans:
			ans = tmp
			
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
H, W = map(int, input().split())
S = [input() for _ in range(H)]
R = [[0] * W for _ in range(H)]
L = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == '.':
			if j > 0:
				L[i][j] = L[i][j - 1] + 1
			elif j == 0:
				L[i][j] = 1
				
			if i > 0:
				U[i][j] = U[i - 1][j] + 1
			elif i == 0:
				U[i][j] = 1
		
		if S[i][W - j - 1] == '.':
			if j > 0:
				R[i][W - j - 1] = R[i][W - j] + 1
			elif j == 0:
				R[i][W - j - 1] = 1
		
		if S[H - i - 1][j] == '.':
			if i > 0:
				D[H - i - 1][j] = D[H - i][j] + 1
			elif i == 0:
				D[H - i - 1][j] = 1
			
ans = 0
for i in range(H):
	for j in range(W):
		tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
		if tmp > ans:
			ans = tmp
			
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import math

def main():
    a,b,n = map(int, input().split())

    max_ans = 0

    for x in range(n+1):
        buff = math.floor(a*x/b) - a*math.floor(x/b)
        if buff > max_ans:
            max_ans = buff

    print(max_ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

import math

def main():
    a,b,n = map(int, input().split())

    if b > n:
        print(math.floor(a*n/b) - a*math.floor(n/b))

    else:
        print(math.floor(a*(b-1)/b) - a*math.floor((b-1)/b))

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

k,s = (int(i) for i in input().split())
ans = 0
for i in range(k+1):
 for j in range(k+1):
  for l in range(k+1):
    if i+j+l == s:
      ans += 1
print(ans)

### FIXED CODE ###

k,s = (int(i) for i in input().split())
ans = 0
for i in range(k+1):
 for j in range(k+1):
    if 0<=s-i-j and s-i-j<=k:
      ans += 1
print(ans)
### BUGGY CODE ###

def g(x):
    if len(x)==1:
        return x,0
    y = int(x[0])+int(x[1])
    if y<=9:
        return str(y),1
    else:
        z = int(str(y)[0])+int(str(y)[1])
        return str(z),2
def f(d,c):
    if c==1:
        return str(d),0
    if c==2:
        return g(str(d)+str(d))
    if c%2==0:
        x,n = f(d,c//2)
        return g(x+x)[0],2*n+g(x+x)[1]
    else:
        x,n = f(d,(c-1)//2)
        y,m = g(x+x)
        return g(y+str(d))[0],2*n+m+g(y+str(d))[1]
M = int(input())
x = []
cnt = 0
for _ in range(M):
    d,c = map(int,input().split())
    y,n = f(d,c)
    x.append(y)
    cnt += n
while len(x)>1:
    y0 = x.pop()
    y1 = x.pop()
    y,n = g(y0+y1)
    x.append(y)
    cnt += n
print(cnt)

### FIXED CODE ###

def g(i,j):
    if i+j<10:
        return 1,i+j
    else:
        a = i+j
        b = a%10+a//10
        return 2,b
def f(c,d):
    if d==1:
        return 0,c
    if d==2:
        return g(c,c)
    if d%2==0:
        a,b = f(c,d//2)
        x,y = g(b,b)
        return 2*a+x,y
    else:
        a,b = f(c,(d-1)//2)
        x1,y1 = g(b,b)
        x2,y2 = g(c,y1)
        return 2*a+x1+x2,y2
M = int(input())
A = [list(map(int,input().split())) for _ in range(M)]
cnt = 0
B = []
for i in range(M):
    c,d = A[i][0],A[i][1]
    a,b = f(c,d)
    cnt += a
    B.append(b)
b = B[0]
for i in range(1,M):
    a,b = g(b,B[i])
    cnt += a
print(cnt)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > (10**18):
        ans = -1
        

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):
        ans *= A[i]
        if ans > (10**18):
            ans = -1
            break
            
            

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

import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

heapq.heapify(A)
for b, c in BC:
    for i in range(b):
        a = heapq.heappop(A)
        if a < c:
            heapq.heappush(A, c)
        else:
            heapq.heappush(A, a)

print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
BC = sorted(BC, key = lambda x : x[1], reverse=True)

n = 0
for b, c in BC:
    n += b
    A += [c] * b

    if n >= N:
        break

A = sorted(A, reverse=True)
print(sum(A[:N]))
### BUGGY CODE ###

n,W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
inf = float('INF')
bag = [inf for _ in range(10**5+1)]
bag[0] = 0

ans = 0
for w,v in a:
    left = v if v < 100001 else 100001
    right = left + ans + 1 if left + ans + 1 < 100001 else 100001
    for i in range(left, right)[::-1]:
        mn = bag[i] if bag[i] < W+1 else W + 1
        if bag[i-v] + w < mn:
            bag[i] = bag[i-v] + w
            if i > ans:
                ans = i
print(ans)


### FIXED CODE ###

n,W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
inf = float('INF')
bag = [inf for _ in range(10**5+1)]
bag[0] = 0

ans = 0
for w,v in a:
  for i in range(min(v,10**5+1), 10**5+1)[::-1]:
    if bag[i-v] + w < min(bag[i],W+1):
        bag[i] = bag[i-v] + w
        ans = max(ans, i)
print(ans)
### BUGGY CODE ###

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    
    L = [0 for i in range(n1+1)]
    R = [0 for i in range(n2+1)]

    for i in range(n1):
        L[i] = A[left + i]
        
    for i in range(n2):
        R[i] = A[mid + i]
    
    L[n1]=1000000001
    R[n2]=1000000001

    cnt1 = 0
    cnt2 = 0
    
    for k in range(left, right):
        if L[cnt1] <= R[cnt2]:
            A[k] = L[cnt1]
            cnt1 += 1
        else:
            A[k] = R[cnt2]
            cnt2 +=  1
    
    global cnt
    cnt += cnt1 + cnt2
    
    
def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
        

n = int(input().rstrip())
A = list(map(int,input().split(" ")))
cnt = 0
mergeSort(A, 0 , len(A))
print(" ".join(list(map(str,A))))
print(str(cnt))

### FIXED CODE ###

def merge(A, left, mid, right):
#    n1 = mid - left
#    n2 = right - mid
    
#    L = [0 for i in range(n1+1)]
#    R = [0 for i in range(n2+1)]

#    for i in range(n1):
#        L[i] = A[left + i]
#        
#    for i in range(n2):
#        R[i] = A[mid + i]
    
#    L[n1]=1000000001
#    R[n2]=1000000001

    L = A[left:mid] + [1000000001]
    R = A[mid:right] + [1000000001]

    cnt1 = 0
    cnt2 = 0
    
    for k in range(left, right):
        if L[cnt1] <= R[cnt2]:
            A[k] = L[cnt1]
            cnt1 += 1
        else:
            A[k] = R[cnt2]
            cnt2 +=  1
    
    global cnt
    cnt += cnt1 + cnt2
    
    
def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
        

n = int(input().rstrip())
A = list(map(int,input().split(" ")))
cnt = 0
mergeSort(A, 0 , len(A))
print(" ".join(list(map(str,A))))
print(str(cnt))
### BUGGY CODE ###

n= int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
  b=a.pop(i)
  print(max(a))
  a.insert(i,b)


### FIXED CODE ###

n= int(input())
a = [int(input()) for i in range(n)]
b=sorted(a,reverse=True)
for i in range(n):
  if a[i] == b[0]:
    print(b[1])
  else:
    print(b[0])
### BUGGY CODE ###

import sys
DAYDREAM = ["dream", "dreamer", "erase", "eraser" ]
S = input()

ind = len(S)
res = True

while ind > 0:
	ok = False
	for i in DAYDREAM:
#		print("ind:", ind, "subS: ", S[ind - len(i):ind], file=sys.stderr)
		if S[ind - len(i):ind] == i:
			ind -= len(i)
			ok = True
			break;
	if ok == False:
		res = False

print("YES" if res == True else "NO")

### FIXED CODE ###

import sys
DAYDREAM = ["dream", "dreamer", "erase", "eraser" ]
S = input()

ind = len(S)
res = True

while ind > 0:
	ok = False
	for i in DAYDREAM:
#		print("ind:", ind, "subS: ", S[ind - len(i):ind], file=sys.stderr)
		if S[ind - len(i):ind] == i:
			ind -= len(i)
			ok = True
			break;
	if ok == False:
		res = False
		break

print("YES" if res == True else "NO")
### BUGGY CODE ###

N = int(input())
A = []
rem = N * (N-1) // 2
for _ in range(N):
    *temp, = map(int, input().split())
    A.append(temp)
day = 0
game = [0]*N
while rem:
    day += 1
    impossible = True
    played = {i: False for i in range(N) if game[i] < N-1}
    for i in played.keys():
        if played[i]: continue
        opposite = A[i][game[i]] - 1
        if not played[opposite] and i+1 == A[opposite][game[opposite]]:
            impossible = False
            played[i] = True; played[opposite] = True;
            rem -= 1
            game[i] += 1; game[opposite] += 1
    if impossible: print(-1); break
else:
    print(day)

### FIXED CODE ###

N = int(input())
A = []
rem = N * (N-1) // 2
for _ in range(N):
    *temp, = map(int, input().split())
    A.append(temp[::-1])
day = 0
next_opponent = [-1]*N
played_yesterday = list(range(N))
while rem:
    day += 1
    impossible = True
    for p in played_yesterday:
        if A[p]: next_opponent[p] = A[p].pop() - 1
    played_today = []
    for p in played_yesterday:
        candidate = next_opponent[p]
        if candidate == -1: continue # player p had already finished all the game
        elif next_opponent[candidate] == p: # matched
            impossible = False
            rem -= 1
            played_today += [p, candidate]
            next_opponent[p], next_opponent[candidate] = -1, -1
    if impossible: print(-1); break
    played_yesterday = played_today
else:
    print(day)
### BUGGY CODE ###

while True:
    try:
        n = int(raw_input())
        count = 1
        for i in range(3, n+1):
            #print i
            for j in range(2, i):
                if i == j+1:
                    count += 1
                    #print i
                    #print 111
                    break
                elif i % j ==0:
                    #print 222
                    break
                else:
                    #print 333
                    continue
            #count += 1
            #print 99999999
        print count
    except:
        break

### FIXED CODE ###

n=1000000
pr = [1] * n
pr[0],pr[1]=0,0
for i in range(2, int(n**0.5)+1):
    if pr[i] == 1:
        for j in range(i ** 2, n , i):
                pr[j] =0
for k in range(3, n):
    pr[k] += pr[k-1]
while True:
    try:
        m = int(raw_input())
        print pr[m]
    except:
        break