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


import heapq

def prime_method():
    start = graph[0]
    not_went = [True] * n  # n個の点に行ったかという話
    edges = []
    for e in start:
        heapq.heappush(edges,e)
    not_went[0] = False
    cost = 0
    while len(edges) != 0:
        minedge = heapq.heappop(edges)
        if not not_went[minedge[1]]:
            continue
        v = minedge[1]
        gv = graph[v]
        not_went[v] = False
        for temp in gv:
            if not_went[temp[1]]:  # その頂点に行ってなければ
                heapq.heappush(edges, temp)
        cost += minedge[0]
    return cost
    # a[1] = [[2,3],[5,11]] → 点1からコスト2で頂点3に行ける辺、点1からコスト5で頂点11に行ける辺がある


n = int(input())
# cities = [(a, b, i) for i, (a, b) in enumerate([tuple(map(int, input().split())) for _ in range(N)])]
cities = []
for i in range(n):
    cities.append(tuple(map(int,input().split()))+tuple([i]))

graph = [[] for i in  range(n)]


citiesX=sorted(cities,key=lambda x:x[0])
citiesY=sorted(cities,key=lambda x:x[1])

for i in range(n-1):
    graph[citiesX[i][2]].append([(citiesX[i+1][0] - citiesX[i][0]),citiesX[i+1][2]])
    graph[citiesX[i+1][2]].append([(citiesX[i+1][0] - citiesX[i][0]),citiesX[i][2]])
    graph[citiesY[i][2]].append([(citiesY[i+1][1] - citiesY[i][1]),citiesY[i+1][2]])
    graph[citiesY[i+1][2]].append([(citiesY[i+1][1] - citiesY[i][1]),citiesY[i][2]])
print(prime_method())

### FIXED CODE ###


import heapq

def prime_method():
    not_went = [True] * n  # n個の点に行ったかという話
    edges = []
    start = graph[0]
    for e in start:
        heapq.heappush(edges,e)
    not_went[0] = False
    cost = 0
    while len(edges) != 0:
        minedge = heapq.heappop(edges)
        if not not_went[minedge[1]]:
            continue
        v = minedge[1]
        gv = graph[v]
        not_went[v] = False
        for temp in gv:
            if not_went[temp[1]]:  # その頂点に行ってなければ
                heapq.heappush(edges, temp)
        cost += minedge[0]
    return cost
    # a[1] = [[2,3],[5,11]] → 点1からコスト2で頂点3に行ける辺、点1からコスト5で頂点11に行ける辺がある


n = int(input())
graph = [[] for i in  range(n)]
cities = []
for i in range(n):
    cities.append(tuple(map(int,input().split()))+tuple([i]))


citiesX=sorted(cities,key=lambda x:x[0])
citiesY=sorted(cities,key=lambda x:x[1])

for i in range(n-1):
    graph[citiesX[i][2]].append(((citiesX[i+1][0] - citiesX[i][0]),citiesX[i+1][2]))
    graph[citiesX[i+1][2]].append(((citiesX[i+1][0] - citiesX[i][0]),citiesX[i][2]))
    graph[citiesY[i][2]].append(((citiesY[i+1][1] - citiesY[i][1]),citiesY[i+1][2]))
    graph[citiesY[i+1][2]].append(((citiesY[i+1][1] - citiesY[i][1]),citiesY[i][2]))
print(prime_method())
### BUGGY CODE ###

N, M = map(int, input().split())
ab = []
for i in range(M):
    a, b = map(int, input().split())
    ab.append((a,b))
check_N = []
check_1 = []
for i in ab:
    if i[1] == N:
        check_N.append(i[0])
    if i[0] == 1:
        check_1.append(i[1])
        
flag = False
for i in sorted(set(check_1)):
    if i in check_N:
        flag = True
        break
        
if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

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

check_1 = []
check_N = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        check_1.append(b)
    if b == N:
        check_N.append(a)
        
if len(list(set(check_1) & set(check_N))) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

from collections import deque

N = int(input())

A = [0 for i in range(N)]
for i in range(N) :
    L = list(map(int,input().split()))
    for j in range(len(L)) :
        L[j] -= 1
    A[i] = deque(L)

#print(A)
ans = 0
flg = 0

zuru = 0

while flg == 0 :
    zuru += 1
    cnt = 0
    cnt2 = 0
    flg = 1

    if zuru >= 10**6 :
        ans = 499500
        print(ans)
        exit()
    
    for i in range(N) :
        if len(A[i]) == 0 :
            cnt += 1
        elif A[i][0] == -1 :
            A[i].popleft()
        elif A[i][0] < i :
            cnt2 += 1
            continue
        elif i == A[A[i][0]][0] :
            a = A[i].popleft()
            A[a][0] = -1
            flg = 0
        else :
            cnt2 += 1
    if cnt == N :
        flg = 1
    elif flg == 0 :
        ans += 1
    elif (N-cnt) == cnt2 :
        ans = -1

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

from collections import deque

N = int(input())

A = [0 for i in range(N)]
for i in range(N) :
    L = list(map(int,input().split()))
    for j in range(len(L)) :
        L[j] -= 1
    A[i] = deque(L)

#print(A)
ans = 0
flg = 0

zuru = 0

while flg == 0 :
    zuru += 1
    cnt = 0
    cnt2 = 0
    flg = 1

    if zuru >= 10**4 :
        ans = 499500
        print(ans)
        exit()
    
    for i in range(N) :
        if len(A[i]) == 0 :
            cnt += 1
        elif A[i][0] == -1 :
            A[i].popleft()
        elif A[i][0] < i :
            cnt2 += 1
            continue
        elif i == A[A[i][0]][0] :
            a = A[i].popleft()
            A[a][0] = -1
            flg = 0
        else :
            cnt2 += 1
    if cnt == N :
        flg = 1
    elif flg == 0 :
        ans += 1
    elif (N-cnt) == cnt2 :
        ans = -1

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

n=int(input())
N=[i for i in range(1,n+1)]

count=0
for a in N:
  for b in N:
    if str(a)[0]==str(b)[-1] and str(a)[-1]==str(b)[0]:
      count+=1

print(count)

### FIXED CODE ###

N=int(input())
d=[[0]*10 for i in range(10)]
#10x10のグリッドを作る

#9x9パターンに分類されるため、各数字をグリッドに振り分ける
for i in range(1,N+1):
  n=str(i)
  d[int(n[0])][int(n[-1])]+=1

#組み合わせの数は[Aの数]x[Bの数] 先頭か語尾に0が付くものはカウントしない
r=0
for i in range(9):
  for j in range(9):
    r+=d[i+1][j+1]*d[j+1][i+1]
print(r)
### BUGGY CODE ###

from collections import deque

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

for k in K:
    res = 0
    D = deque()
    M = deque()
    dm = 0
    for i in range(N):
        if S[i] == 'D':
            D.append(i)
        elif S[i] == 'M':
            dm += len(D)
            if D:
                M.append(i)
        elif S[i] == 'C':
            res += dm
        if D and D[0] + k <= i + 1:
            D.popleft()
            dm -= len(M)
            if D:
                while M and D[0] > M[0]:
                    M.popleft()
            else:
                M = deque()
                dm = 0

    print(res)

### FIXED CODE ###

from collections import deque

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

for k in K:
    res = 0
    d = 0
    m = 0
    dm = 0
    for i in range(N):
        if S[i] == 'D':
            d += 1
        elif S[i] == 'M':
            dm += d
            m += 1
        elif S[i] == 'C':
            res += dm
        if i + 1 - k >= 0:
            if S[i + 1 - k] == 'D':
                d -= 1
                dm -= m
            elif S[i + 1 - k] == 'M':
                m -= 1

    print(res)
### BUGGY CODE ###

n = eval(input())
a = input().split()
prod = 1
for i in range(0, n):
    prod *= int(a[i])
if prod > 1e18:
    print(-1)
else:
    print(prod)

### FIXED CODE ###

n = eval(input())
a = input().split()
prod = 1
for i in range(0, n):
    a[i] = int(a[i])
a = sorted(a)
for i in range(0, n):
    prod *= int(a[i])
    if prod > 1e18:
        break
if prod > 1e18:
    print(-1)
else:
    print(prod)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(n):
    is_divisible = False
    for j in range(n):
        divisible_num = []
        if a[i] % a[j] == 0 and i != j:
            divisible_num.append(a[j])
            is_divisible = True
        if len(divisible_num) >= 1:
            continue
    if is_divisible:
        continue
    else:
        count += 1

print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = sorted(list(map(int, input().split())))

# 探索範囲は数列aの最大値まで
max_a = a[-1]
b = [0] * (max_a + 1)
ans = set()
for i in a:
    if b[i] == 1:
        if i in ans:
            ans.remove(i)
        continue
    # 探索範囲内のiの倍数をチェック
    for j in range(i, max_a+1, i):
            b[j] = 1
    ans.add(i)

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

if __name__ == '__main__':
    n,m = map(int, input().split())
    a_list = list(map(int, input().split()))
    a_list = sorted(a_list, reverse=True)

    while m > 0:
        max_index = a_list.index(max(a_list))
        a_list[max_index] = a_list[max_index] // 2
        m-=1

    answer = sum(a_list)
    print(answer)



### FIXED CODE ###

import heapq


if __name__ == '__main__':
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    q = []
    for x in a:
        heapq.heappush(q, -x)

    for i in range(m):
        x = heapq.heappop(q)
        x /= 2
        heapq.heappush(q,x)

    answer = 0
    for x in q:
        answer += int(-x//1)
    print(answer)
### BUGGY CODE ###

n = int(input())
h = list(map(int,input().split()))
maxc=0
for i in range(n-1,0,-1):
    j = i
    cnt =0
    while((h[j]<=h[j-1])):
        if(j ==0):
            break
        cnt +=1
        j -=1
    
    if maxc < cnt:
        maxc = cnt
print(maxc)


### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
maxc=0
rec=n-1
for i in range(n-1,0,-1):
    if(i >rec):
        continue
        
    j = i
    cnt =0
    while((h[j]<=h[j-1])):
        if(j ==0):
            break
        cnt +=1
        j -=1
    rec= j
    if maxc < cnt:
        maxc = cnt
print(maxc)
### BUGGY CODE ###

import math
a=int(input())
b=input()
R=0
L=0
ans=1
mod=10**9+7
if b[0]=="W" or b[-1]=="W":
  print(0)
  exit()
for i in range(2*a):
  if i==0:
    L+=1
    fr="L"
  else:
    if b[i]==b[i-1]:
      if fr=="L":
        ans=ans*(L-R)
        R+=1
        fr="R"
      else:
        L+=1
        fr="L"
    else:
      if fr=="L":
        L+=1
      else:
        ans=ans*(L-R)
        R+=1
    
if L!=R:
  print(0)
  exit()


  
print(ans*math.factorial(a)%mod)
  
  

### FIXED CODE ###

def main():
  import math
  import sys
  imput=sys.stdin.readline
  a=int(input())
  b=input()
  R=0
  L=0
  ans=1
  mod=10**9+7
  if b[0]=="W" or b[-1]=="W":
    print(0)
    exit()
  for i in range(2*a):
    if i==0:
      L+=1
      fr="L"
    else:
      if b[i]==b[i-1]:
        if fr=="L":
          ans=ans*(L-R)%mod
          R+=1
          fr="R"
        else:
          L+=1
          fr="L"
      else:
        if fr=="L":
          L+=1
        else:
          ans=ans*(L-R)%mod
          R+=1
    
  if L!=R:
    print(0)
    exit()


  
  print(ans*math.factorial(a)%mod)
  

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

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

from_one = []
to_n = [] 

for i in range(M):
    a, b = map(int, input().split())
    if a == 1 or b == 1:
        from_one.append(b)
    elif b == N or a == N:
        to_n.append(a)

pos = "IMPOSSIBLE"

for island in from_one:
    if island in to_n:
        pos = "POSSIBLE"

print(pos)

### FIXED CODE ###

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

f = set()
t = set()

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        f.add(b)
    elif a == N:
        t.add(b)
    if b == 1:
        f.add(a)
    elif b == N:
        t.add(a)

pos = "IMPOSSIBLE"

if f&t:
    pos = "POSSIBLE"

print(pos)
### BUGGY CODE ###

import sys
for i in sys.stdin:
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()
 
    n = 1
    while n <= lst[0]/2:          
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
           print lst[0]/n
           break
        n = n+1
    else:
        print 1
    sys.exit(0)

### FIXED CODE ###

import sys                                               
for i in sys.stdin:
    lst = i.split(' ')
    lst = map(int, lst)
    lst.sort()

    n = 1
    maxn = 1
    while n*n <= lst[0]:
        if lst[0]%n == 0 and lst[1]%(lst[0]/n) == 0:
            print lst[0]/n
            break
        elif lst[0]%n == 0 and lst[1]%n == 0:
            maxn = n
        n = n+1
    else:
        print maxn
    sys.exit(0)
### BUGGY CODE ###

N = input()

ans=[0]*len(N)

for i in range(len(N)):
	if N[i]=="R":
		for g in range(1, len(N)):
			if N[i+g]=="L":
				if g%2==0:
					ans[i+g]+=1
				else:
					ans[i+g-1]+=1
				break
	else:
		for g in range(1, len(N)):
			if N[i-g]=="R":
				if g%2==0:
					ans[i-g]+=1
				else:
					ans[i-g+1]+=1
				break

print(*ans)

### FIXED CODE ###

s=input()+"R"

ans=[0]*(len(s)-1)
r_num=0
l_num=0
r_place=0
l_place=0

for i in range(1,len(s)):
    if s[i-1]=="R" and s[i]=="L":
        r_num+=1
        r_place=i-1
        l_place=i
        ans[r_place]+=r_num-r_num//2
        ans[l_place]+=r_num//2
    elif s[i-1]==s[i] and s[i-1]=="R":
        r_num+=1
    elif s[i-1]==s[i] and s[i-1]=="L":
        l_num+=1
    elif s[i-1]=="L" and s[i]=="R":
        l_num+=1
        ans[r_place]+=l_num//2
        ans[l_place]+=l_num-l_num//2
        r_num=0
        l_num=0
print(*ans)
### BUGGY CODE ###

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

bit_len = 20
memo = [[] for i in range(bit_len)]
ans = 0

for i, ai in enumerate(a):
    li = 0
    for j in range(bit_len):
        if ai & (1 << j):
            if len(memo[j]) >= 1:
                li = max(li, memo[j][-1] + 1)
            memo[j].append(i)
        else:
            if len(memo[j]) >= 2:
                li = max(li, memo[j][-2] + 1)
    ans += i - li + 1

print(ans)


### FIXED CODE ###

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

bit_len = 20
memo = [[] for i in range(bit_len)]
ans = 0

for i, ai in enumerate(a):
    li = 0
    for j in range(bit_len):
        if ai & (1 << j):
            if len(memo[j]) >= 1:
                li = max(li, memo[j][-1] + 1)
            memo[j].append(i)
        else:
            if len(memo[j]) >= 2:
                li = max(li, memo[j][-2] + 1)
    ans += i - li + 1

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

def main():
    n,m=map(int,input().split())
    s=list(map(int,input().split()))
    t=list(map(int,input().split()))
    dp=[[0]*(m+1) for _ in [0]*(n+1)]
    for i in range(n+1):
        dp[i][m]=1
    for i in range(m+1):
        dp[n][i]=1
    for i in range(n-1,-1,-1):
        for j in range(m-1,-1,-1):
            dp[i][j]=(dp[i+1][j]+dp[i][j+1]-(s[i]!=t[j])*dp[i+1][j+1])%(10**9+7)
    print(dp[0][0])
main()


### FIXED CODE ###

def main():
    n,m=map(int,input().split())
    s=list(map(int,input().split()))
    t=list(map(int,input().split()))
    dp=[[0]*(m+1) for _ in [0]*(n+1)]
    for i in range(n+1):
        dp[i][m]=1
    for i in range(m+1):
        dp[n][i]=1
    for i in range(n-1,-1,-1):
        for j in range(m-1,-1,-1):
            dp[i][j]=(dp[i+1][j]+dp[i][j+1]-(s[i]!=t[j])*dp[i+1][j+1])%(10**9+7)
    print(dp[0][0])
main()
### BUGGY CODE ###

import sys

def mink(numk,l):
    x = 1
    for _ in range(k):
        x = a[x-1]
    return x

input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))

# kが小さい時
if k <= 10**5:
    print(mink(k,a))
    sys.exit()

# ans = 0

z = 1
p = [1]
for _ in range(k):
    z = a[z-1]
    if z in p:
        p.append(z)
        break
    p.append(z)

# 周期の来る前の回数
num = p.index(p[-1])

p = p[num:]

# 周期
pn = len(p)-1

k -= num

# 回数/周期のあまり
anum = k%pn
print(p[anum])


### FIXED CODE ###

import sys

input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))

p = [1]
for i in range(n):
    p.append(a[p[i]-1])

if k <= n:
    print(p[k])
else:
    # 周期の来る前の回数
    num = p.index(p[-1])
    p = p[num:]

    # 周期
    pn = len(p)-1
    k -= num

    # 回数/周期のあまり
    ans = k%pn
    print(p[ans])
### BUGGY CODE ###

import fractions
a, b = map(int, input().split())
x = fractions.gcd(a, b)

def check(n):
  d = 2
  count = 1
  last = 0
  while n >= d:
    if (n % d == 0):
      if d != last:
        count += 1; last = d
      n /= d
    else:
      d += 1
  return count

print(check(x))


### FIXED CODE ###

import fractions
a, b = map(int, input().split())
x = fractions.gcd(a, b)
t = x

i = 2
ans = 1;
while i * i <= t:
  if x % i == 0:
    while x % i == 0:
      x /= i
    ans += 1
  i += 1
if x != 1:
  ans += 1

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

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

a=1
for i in range(N):
  if(P[i]==0):
    a=-1
    break
if a!=0:
  for i in range(N):
    a*=P[i]
    if(a>1000000000000000000):
      a=-1
      break
print(a)

### FIXED CODE ###

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

a=1
for i in range(N):
  if(P[i]==0):
    a=0
    break
if a!=0:
  for i in range(N):
    a*=P[i]
    if(a>1000000000000000000):
      a=-1
      break
print(a)
### BUGGY CODE ###

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

rlst, glst, blst = [], [], []

for i, s in enumerate(S):
    if s=='R':rlst.append(i)
    elif s=='G':glst.append(i)
    else: blst.append(i)
rlst.sort()
glst.sort()
blst.sort()
      
ans = 0

for r in rlst:
    for g in glst:
        rg = abs(r - g)
        if min(r, g) - rg in blst: ans += 1
        if max(r, g) + rg in blst: ans += 1
        if rg % 2 == 0 and (r + g) // 2 in blst: ans += 1
print(len(rlst) * len(glst) * len(blst) - ans)
        

### FIXED CODE ###

import numpy as np
from itertools import combinations_with_replacement

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

rgb = 'RGB'

nr = S.count(rgb[0])
ng = S.count(rgb[1])
nb = N - nr - ng
nlst = np.array([nr, ng, nb])

nmax = np.argmax(nlst)
nmin = np.argmin(nlst)
if nmax == nmin:nmin = 2

minlst, midlst = [], []
maxlst = [0]*N

for i, s in enumerate(S):
    if s==rgb[nmax]:maxlst[i] = 1
    elif s==rgb[nmin]:minlst.append(i)
    else: midlst.append(i)
minlst.sort()
midlst.sort()
      
ans = 0

for midl in midlst:
    for minl in minlst:
        mm = abs(midl - minl)
        mmin = min(minl, midl) - mm
        mmax = max(minl, midl) + mm
        if mmin >= 0:
            if maxlst[mmin]: ans += 1
        if mmax <= N-1:
            if maxlst[mmax]: ans += 1
        if mm % 2 == 0 and maxlst[(minl + midl) // 2]: ans += 1
print(nr * ng * nb - ans)
### BUGGY CODE ###

n,q = list(map(int, input().split()))
s = input()
for _ in range(q):
    count = 0
    l,r=list(map(int, input().split()))
    s_part = s[l-1:r+1]
    for i in range(r-l):
        if s_part[i] =='A' and s_part[i+1]=='C':
            count += 1
    print(count)

### FIXED CODE ###


n,q = list(map(int, input().split()))
s = input()
ans = [0]*(n+1)
lr=[list(map(int, input().split())) for _ in range(q)]
for i in range(1,n):
    
    if s[i-1]=='A' and s[i]=='C':
        ans[i+1] = ans[i] + 1
    else:
        ans[i+1]= ans[i]
#print(ans)
for i in range(q):
    print(ans[lr[i][1]]-ans[lr[i][0]])
### BUGGY CODE ###

word = input()
count = int(input())

for i in range(count):
    line = input()
    if len(line) == 1:
        word = word[::-1]
    else:
        t, f, char = map(str, line.split())
        if int(f) == 1:
            word = char + word
        else:
            word = word + char

print(word) 

### FIXED CODE ###

word = input()
count = int(input())
reversed_flg = False
head = ''
tail = ''

for i in range(count):
    line = input()
    if len(line) == 1:
        reversed_flg = not reversed_flg
    else:
        str_t, str_f, char = line.split()
        f = int(str_f)

        if (f == 1 and not reversed_flg) or (f == 2 and reversed_flg):
            # word = char + word
            head = char + head
        else:
            # word = word + char
            tail += char

word = head + word + tail

if reversed_flg:
        word = word[::-1]

print(word)
### BUGGY CODE ###

import sys

input = lambda :sys.stdin.readline().rstrip()

def main():
    n, m, Q = map(int, input().split())
    Train= [[0 for _ in range(n)] for _ in range(n)]
    
    for i in range(m):
        l, r = map(int, input().split())
        l, r = l - 1, r - 1
        Train[l][r] += 1
    
    P_Train = [[0 for _ in range(n + 1)] for _ in range(n)]
    for i in range(n):
        tmp = 0
        for j in range (n):
            tmp += Train[i][j]
            P_Train[i][j + 1] = tmp

    for i in range(Q):
        p, q = map(int, input().split())
        p, q = p - 1, q - 1
        ans = solve(P_Train, n, p, q)
        print(ans)

def solve(P_Train, n, p, q):
    ans = 0
    for i in range(p, q + 1):
        ans += P_Train[i][q + 1] - P_Train[i][p]
    return ans


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, m, Q = map(int, input().split())
    Train= [[0 for _ in range(n)] for _ in range(n)]
    
    for i in range(m):
        l, r = map(int, input().split())
        l, r = l - 1, r - 1
        Train[l][r] += 1
    
    P_Train = [[0 for _ in range(n)] for _ in range(n)]
    for i in range(n):
        tmp = 0
        for j in range(n):
            tmp += Train[i][j]
            P_Train[i][j] = tmp

    for i in range(Q):
        p, q = map(int, input().split())
        p, q = p - 1, q - 1
        ans = solve(P_Train, n, p, q)
        print(ans)

def solve(P_Train, n, p, q):
    ans = 0
    for i in range(p, q + 1):
        if  p - 1 < 0:
            ans += P_Train[i][q]
        else:
            ans += P_Train[i][q] - P_Train[i][p - 1]
    return ans


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

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

### FIXED CODE ###

n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import numpy as np
N, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_num = np.array(a)
x = a_num // 2
count_even = np.count_nonzero(x % 2 == 0)
if count_even != 0 and count_even != N:
    print(0)
    sys.exit()
c = []
from collections import Counter
if count_even == N:
    for i in x:
        cnt = 0
        while i % 2 == 0:
            cnt += 1
            i //= 2
        c.append(cnt)
    c = Counter(c)
    if len(c.keys()) != 1:
        print(0)
        sys.exit()
    
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

minmulti = lcm(* x)
temp = M // minmulti
if temp % 2 == 0:
    print(temp // 2)
else:
    print(1 + temp // 2)



### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
N, M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_num = np.array(a)
x = a_num // 2
count_even = np.count_nonzero(x % 2 == 0)
if count_even != 0 and count_even != N:
    print(0)
    sys.exit()
c = []
from collections import Counter
if count_even == N:
    for i in x:
        cnt = 0
        cnt = format(i, 'b')[::-1].find('1')
        c.append(cnt)
    c = Counter(c)
    if len(c.keys()) != 1:
        print(0)
        sys.exit()
    
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

minmulti = lcm(* x)
temp = M // minmulti
if temp % 2 == 0:
    print(temp // 2)
else:
    print(1 + temp // 2)
### BUGGY CODE ###

N, x, y = map(int, input().split())
x -= 1
y -= 1
dist = [0] * (N-1)

for i in range(N-1):
  for j in range(i+1,N):
    d = min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])
    dist[d-1] += 1

for i in range(N-1):
  print(dist[i])

### FIXED CODE ###

N, x, y = map(int, input().split())
x -= 1
y -= 1
dist = [0] * (N)

for i in range(N-1):
  for j in range(i+1,N):
    d = min([abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)])
    dist[d] += 1

for i in range(1,N):
  print(dist[i])
### BUGGY CODE ###

N=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        if 4*i*j-N*i-N*j<=0:
            continue
        elif (N*i*j)%4*i*j-N*i-N*j==0:
            print(i,j,(N*i*j)//4*i*j-N*i-N*j)
            exit()

### FIXED CODE ###

N=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        bw=4*i*j-N*i-N*j
        if bw<=0:
            continue
        if (N*i*j)%bw==0:
            print(i,j,(N*i*j)//bw)
            exit()