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

import sys
import bisect
input = sys.stdin.readline

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

mc = max(l)[1]

prime = [i for i in range(2, mc + 1)]
c = 0
while True:
    t = prime[c]
    prime = [v for v in prime if v == t or v % t != 0]
    c = c + 1
    if c >= len(prime):
        break

cum = [0 for i in range(mc + 1)]
for i in range(len(cum)):
    prime_index = bisect.bisect_left(prime, i)
    
    n2 = (i + 1) / 2
    prime_index2 = bisect.bisect_left(prime, n2)
    if len(prime) > prime_index and len(prime) > prime_index2 and prime[prime_index] == i and prime[prime_index2] == n2:
        cum[i] = cum[i - 1] + 1
    else:
        cum[i] = cum[i - 1]
      
for x, y in l:
    p = cum[x] - cum[x - 1]
    if x != y:
        p += cum[y] - cum[x]
    print(p)

### FIXED CODE ###

import sys
import bisect
import math
input = sys.stdin.readline

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

mc = 0
for v in l:
    mc = max(mc, v[1])
mc_sqrt = math.sqrt(mc)

prime = [i for i in range(2, mc + 1)]
c = 0
while True:
    if c >= len(prime):
        break
    t = prime[c]
    prime = [v for v in prime if v == t or v % t != 0]
    c = c + 1
    if c >= mc_sqrt:
        break
        
cum = [0 for i in range(mc + 1)]
for i in range(len(cum)):
    prime_index = bisect.bisect_left(prime, i)
    
    n2 = (i + 1) / 2
    prime_index2 = bisect.bisect_left(prime, n2)
    if len(prime) > prime_index and len(prime) > prime_index2 and prime[prime_index] == i and prime[prime_index2] == n2:
        cum[i] = cum[i - 1] + 1
    else:
        if i - 1 < 0:
            cum[i] = 0
        else:
            cum[i] = cum[i - 1]

for t in l:
    x, y = t[0], t[1]
    p = 0
    if 0 <= x - 1:
        p = cum[x] - cum[x - 1]
    if x != y:
        p += cum[y] - cum[x]
    print(p)
### BUGGY CODE ###

def main():
    n = int(input())
    xd = [list(map(int, input().split())) + [i] for i in range(1, n + 1)]
    mod = 998244353
    INF = 10 ** 10

    xd.sort()
    adj = [[] for _ in range(n + 1)]
    stack = [(INF, 0)]
    for x, d, i in xd:
        while stack[-1][0] <= x:
            stack.pop()
        pi = stack[-1][1]
        adj[pi].append(i)
        stack.append((x + d, i))

    stack2 = [0]
    d = [-1] * (n + 1)
    d[0] = 0
    c = [[] for _ in range(n + 1)]
    order = []
    while stack2:
        u = stack2.pop()
        order.append(u)
        for v in adj[u]:
            if d[v] == -1:
                d[v] = d[u] + 1
                c[u].append(v)
                stack2.append(v)

    dp = [1] * (n + 1)
    for u in order[::-1]:
        for v in c[u]:
            dp[u] *= dp[v]
            dp[u] %= mod

        dp[u] += 1
        dp[u] %= mod

    ans = dp[0] - 1
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    xd = [map(int, input().split()) for _ in range(n)]
    mod = 998244353
    INF = 10 ** 10

    xx = [(x, x + d, i) for i, (x, d) in enumerate(xd, 1)]
    xx.sort()
    adj = [[] for _ in range(n + 1)]
    stack = [(INF, 0)]
    for l, r, i in xx:
        while stack[-1][0] <= l:
            stack.pop()

        ip = stack[-1][1]
        adj[ip].append(i)
        stack.append((r, i))

    stack2 = [0]
    d = [-1] * (n + 1)
    d[0] = 0
    c = [[] for _ in range(n + 1)]
    order = []
    while stack2:
        u = stack2.pop()
        order.append(u)
        for v in adj[u]:
            if d[v] == -1:
                d[v] = d[u] + 1
                c[u].append(v)
                stack2.append(v)

    dp = [1] * (n + 1)
    for u in order[::-1]:
        for v in c[u]:
            dp[u] *= dp[v]
            dp[u] %= mod

        dp[u] += 1
        dp[u] %= mod

    ans = dp[0] - 1
    ans %= mod
    print(ans)


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

from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    s = []
    for i in range(N):
        s.append(int(input().rstrip()))
    ans = 0
    for i in range(2 << N):
        sum = 0
        for j in range(N):
            if 2<<j & i:
               sum += s[j] 
        if sum % 10 == 0:
            sum = 0
        ans = max(ans,sum)
    print(ans)
    
if __name__ == '__main__':
    main()


### FIXED CODE ###

from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    s = []
    for i in range(N):
        s.append(int(input().rstrip()))
    dp = []
    for i in range(N):
        dp.append([-1]*(100*100))
    dp[0][s[0]] = 1
    for i in range(1,N):
        for j in range(100*100):
            if(j == s[i] or (j-s[i]>=0 and dp[i-1][j-s[i]]==1)):
                dp[i][j] = 1
            else:
                dp[i][j] = dp[i-1][j]
    ans = 0
    # print('\n'.join(str(_) for _ in(dp[N-1])))
    for i in range(100*100-1,0,-1):
        if(i%10 != 0 and dp[N-1][i]==1):
            ans = i
            break
    print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

def main():
    n = int(input())
    h_li = list(map(int, input().split()))
    i = 0
    count = 0
    f = 0
    discount = max(h_li)
    while True:
        if h_li[i] >= discount:
            count += 1
            h_li[i] -= 1
            while i < len(h_li) - 1:
                if h_li[i + 1] >= discount:
                    i += 1
                    h_li[i] -= 1
                else:
                    break
        if i == len(h_li) - 1:
            i = 0
            discount -= 1
            if max(h_li) == 0:
                f = 1
        else:
            i += 1
        if f == 1:
            break
    print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

n = int(input())
h_li = list(map(int, input().split()))
count = 0
for i in range(100):
    f = 0
    for j in range(n):
        if h_li[j] >= i + 1:
            if f == 0:
                count += 1
                f = 1
        else:
            f = 0
print(count)
### BUGGY CODE ###

def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr

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

cnt=[0]*1000001
for i in range(N):
    cnt[A[i]]+=1
ng=set()
for i in range(N):
    if cnt[A[i]]>1:
        ng.add(A[i])

s=set(A)

ans=0
for i in range(N):
    if A[i] in ng:
        continue
    s.remove(A[i])
    arr=factor(A[i])
    ok=True
    for x in arr:
        if x in s:
            ok=False
            break
    if ok:
        ans+=1
    s.add(A[i])
print(ans)

### FIXED CODE ###

def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr

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

cnt=[0]*1000001
for i in range(N):
    cnt[A[i]]+=1
ng=set()
for i in range(N):
    if cnt[A[i]]>1:
        ng.add(A[i])

s=set(A)
min_=min(A)

ans=0
for i in reversed(range(N)):
    if A[i] in ng:
        continue
    if A[i]<min_*2:
        ans+=1
        continue
    s.remove(A[i])
    arr=factor(A[i])
    ok=True
    for x in arr:
        if x in s:
            ok=False
            break
    if ok:
        ans+=1
    s.add(A[i])
print(ans)
### BUGGY 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
        elif (N*i*j)%bw==0:
            print(i,j,(N*i*j)//bw)
            break

### 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()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

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

e = [list(map(int, input().split())) for _ in range(n-1)]
cm = [list(map(int, input().split())) for _ in range(q)]
parent = [-1]*n
child = [[]]*n
counter = [0]*n

for i, v in cm:
  counter[i-1] += v

parent[0] = 0
for a, b in e:
  parent[b-1] = a-1
  child[a-1] += [b-1]

cum_counter = [0]*n
def check(i, cum_cnt):
  cum_cnt += counter[i]
  cum_counter[i] = cum_cnt
  if len(child[i])>0:
    for c in child[i]:
      check(c, cum_cnt)

check(0, 0)
print(*cum_counter)


### FIXED CODE ###

#138_D
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6)

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

edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x
    
def dfs(frm, cur):
    for to in edges[cur]:
        if to != frm:
            cnt[to] += cnt[cur]
            dfs(cur, to)
dfs(-1, 0)          
print(*cnt)
### BUGGY CODE ###

def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    A.sort()

    D = set()
    prev = -1
    for i in range(n):
        if A[i] == prev:
            if len([d for d in D if A[i] % d == 0]) == 0:
                D.add(A[i])

            A[i - 1] = -1
            A[i] = -1
        else:
            prev = A[i]

    A = [a for a in A if a != -1]
    ans = 0
    for i in range(len(A)):
        if len([d for d in D if A[i] % d == 0]) == 0:
            ans += 1
            D.add(A[i])

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    ma = max(A)
    N = [0] * (10 ** 6 + 1)
    for a in A:
        for i in range(a, ma + 1, a):
            N[i] += 1

    ans = 0
    for a in A:
        if N[a] == 1:
            ans += 1

    print(ans)


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

N = int(input())
Ls = list(map(int, input().split()))
Ls.sort()
# index: 0,...,N-1

ans = 0
for i in range(N-2): # i: 0,...,N-3
    for j in range(i+1, N-1): # j: i+1,...,N-2
        for k in range(j+1, N): # k: j+1,...,N-1
            if Ls[j] - Ls[i] < Ls[k] < Ls[i] + Ls[j]:
                ans += 1

print(ans)


### FIXED CODE ###

import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort() # index: 0,...,N-1

ans = 0
for i in range(N-2): # i: 0,...,N-3
    for j in range(i+1, N-1): # j: i+1,...,N-2
        # k の満たすべき条件:
        # 1. L[k] > L[j] - L[i]
        #     L[k] > L[j] なので自動的に満たす
        # 2. L[k] < L[i] + L[j]
        x = bisect.bisect_left(L, L[i]+L[j])
        # (<L[i]+L[j]), (<L[i]+L[j]), ..., (<L[i]+L[j]) | (L[i]+L[j]<=), (L[i]+L[j]<=), ...
        # | (x) より左側はOK
        # j+1 より右側はOK
        # L[j]<L[i]+L[j] と L[i]+L[j]<=L[x] より L[j]<L[x] つまり j<x
        ans += x - (j + 1)

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

import collections
import sys
n = int(input())
d = list(map(int, input().split()))

m=[1]
p=1


for i in range(1,max(d)+1):
    if collections.Counter(d)[i]==0:
        print(0)
        sys.exit(0)
    elif d[i]==0:
        print(0)
        sys.exit(0)
    else:
        m.append(collections.Counter(d)[i]) 
    
for i in range(1, len(collections.Counter(d))):
    p = ((p%998244353) * ((m[i-1]**m[i])%998244353))%998244353
    
    

if d[0]!=0:
    print(0)
    sys.exit(0)
    
print(p%998244353)

### FIXED CODE ###

import collections
import sys

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

cnt = collections.Counter(d)

if d[0]!=0:
    print(0)
    sys.exit(0)

if cnt[0]!=1:
    print(0)
    sys.exit(0)    
    
p = 1

for i in range(1,max(d)+1):
    if cnt[i] == 0:
        print(0)
        sys.exit(0)  
    else:
        p = (p * pow(cnt[i-1], cnt[i], 998244353))%998244353

print(p)
### BUGGY CODE ###

N = int(input())
S = [input() for _ in range(N)]
ans = 0
for a in range(N):
    fuga = ['M', 'A', 'R', 'C', 'H']
    ch = S[a][0]
    if ch not in fuga:
        continue
    fuga.remove(ch)
    for b in range(a+1, N):
        ch = S[b][0]
        temp = fuga[:]
        if ch not in temp:
            continue
        temp.remove(ch)
        ans += sum(1 * (S[c][0] in temp) for c in range(b+1, N))
print(ans)


### FIXED CODE ###

from collections import Counter
from itertools import combinations
march = list("MARCH")
march = dict(zip(march, march))
N = int(input())
S = [march.get(input()[0], -1) for _ in range(N)]
cnt = Counter(S)
ans = 0
for comb in combinations("MARCH", 3):
    tmp = 1
    for c in comb:
        tmp *= cnt[c]
    ans += tmp
print(ans)
### BUGGY CODE ###

from functools import lru_cache


def popcnt(x):
    return bin(x).count("1")


@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    else:
        return rec(n % popcnt(n)) + 1


ret = [rec(x) for x in range(2 * 10**5 + 1)]


n = int(input())
arr = input()

ALL_ARR = int(arr, 2)

cnt = popcnt(int(arr, 2))
init_big = ALL_ARR % (cnt + 1)
if cnt == 1:
    init_small = 0
else:
    init_small = ALL_ARR % (cnt - 1)


li = [0] * n
for i in range(n):
    if arr[i] == "0":
        li[i] = (init_big + (1 << (n - i - 1))) % (cnt + 1)
    elif ALL_ARR - (1 << (n - i - 1)) == 0 or cnt - 1 == 0:
        li[i] = "flg"
    else:
        li[i] = (init_small - (1 << (n - i - 1))) % (cnt - 1)


ans = []

for x in li:
    if x == "flg":
        ans.append(0)
    else:
        ans.append(ret[x] + 1)

print(*ans, sep="\n")

### FIXED CODE ###

from functools import lru_cache


def popcnt(x):
    return bin(x).count("1")


@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    else:
        return rec(n % popcnt(n)) + 1


ret = [rec(x) for x in range(2 * 10**5 + 1)]


n = int(input())
arr = input()

ALL_ARR = int(arr, 2)

cnt = popcnt(int(arr, 2))
init_big = ALL_ARR % (cnt + 1)
if cnt == 1:
    init_small = 0
else:
    init_small = ALL_ARR % (cnt - 1)


li = [0] * n
for i in range(n):
    if arr[i] == "0":
        li[i] = (init_big + pow(2, n - i - 1, cnt + 1)) % (cnt + 1)
    elif ALL_ARR - (1 << (n - i - 1)) == 0 or cnt - 1 == 0:
        li[i] = "flg"
    else:
        li[i] = (init_small - pow(2, n - i - 1, cnt - 1)) % (cnt - 1)


ans = []

for x in li:
    if x == "flg":
        ans.append(0)
    else:
        ans.append(ret[x] + 1)

print(*ans, sep="\n")
### BUGGY CODE ###

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

ans = [0]*n

for i in range(n):
  s = []
  for j in range(1,k+1):
    if (i - j) >= 0:
      x = abs(h[i] - h[i-j]) + ans[i-j]
      s.append(x)
  if len(s) > 0:
    ans[i] = min(s)


#print(ans)
print(ans[n-1])

### FIXED CODE ###

n,k =map(int,input().split())
h = list(map(int,input().split()))
#print(n,k,h)
 
ans = [0]*n
 
for i in range(n):
  s = float("inf")
  for j in range(1,k+1):
    if i == 0:
      s = 0
    if (i - j) >= 0:
      x = abs(h[i] - h[i-j]) + ans[i-j]
      if s > x:
        s = x
  ans[i] = s
 
 
#print(ans)
print(ans[n-1])
### BUGGY CODE ###

import heapq


def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n  #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist, e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist, [e[0] + d[v], e[1]])
    return d


################################
n, x, y = map(int, input().split())  #n:頂点数
w = n
edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w - 1):
    edge[i + 1].append([1, i])
    edge[i].append([1, i + 1])
edge[x - 1].append([1, y - 1])
edge[y - 1].append([1, x - 1])

dic = {i: 0 for i in range(1, n)}

for i in range(n):
    tmp = dijkstra_heap(i)
    zero = False
    for j in tmp:
        if zero:
            dic[j] += 1
        if j == 0:
            zero = True

for i in range(1, n):
    print(dic[i])


### FIXED CODE ###

n, x, y = map(int, input().split())

dic = {i: 0 for i in range(1, n)}
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        dist = min(j - i, abs(i - x) + abs(j - y) + 1)
        dic[dist] += 1


for i in range(1, n):
    print(dic[i])
### BUGGY CODE ###

N,M = list(map(int, input().split(" ")))
Xs = sorted(list(map(int, input().split(" "))))

if N >= M :
	print(0)
	exit()
	
darr = [Xs[i+1] - Xs[i]for i in range(M-1)]


# ??
for i in range(N-1):
	darr.pop(darr.index(max(darr)))
	
print(sum(darr))

### FIXED CODE ###

import heapq
N,M = list(map(int, input().split(" ")))
Xs = sorted(list(map(int, input().split(" "))))

if N >= M :
	print(0)
	exit()
	
darr = [Xs[i+1] - Xs[i]for i in range(M-1)]

# print(darr)
heapq.heapify(darr)
res = 0

for _ in range(M - N):
	res += heapq.heappop(darr)
	
print(res)
### BUGGY CODE ###

N,M = map(int,input().split())
if M < N * 2:
  print(M // 2)
else:
  while M > N * 2:
    M -= 2
    N += 1
  print(M // 2)

### FIXED CODE ###

N,M = map(int,input().split())
ans = 0
if N > M // 2:
  print(M // 2)
  exit()
print(N + (M - N * 2) // 4)
### BUGGY CODE ###

import itertools as it
N=int(input())
for i in range(1,N+1):
  cnt=0
  for c in list(it.product(range(1,i),repeat=3)):
    if sum(c)<=i:
      x=c[0]
      y=c[1]
      z=c[2]
      if i==x**2+y**2+z**2+x*y+y*z+z*x:
        cnt+=1
  print(cnt)
  
      

### FIXED CODE ###

import sys
input = sys.stdin.readline
import math

N=int(input())
ans=[0]*(N+1)
sn=int(math.sqrt(N)+1)
for x in range(1,sn+1):
  for y in range(1,sn+1):
    for z in range(1,sn+1):
      i=x**2+y**2+z**2+x*y+y*z+z*x
      if 1<=i<=N:
        ans[i]+=1
for h in range(1,N+1):          
  print(ans[h])
### BUGGY CODE ###

from itertools import combinations
import copy

n = int(input())
ls = [int(input()) for _ in range(n)]
p = 200000
ans = 0
if p>n:
    p=n

def cul(n, x):
    l = len(x)
    b = [x[i] for i in range(l)]
    b.pop(n)
    return max(b)
    
for i in range(p):
    s = cul(i,ls[:p])
    print(s)

### FIXED CODE ###

n = int(input())
ls = [int(input()) for _ in range(n)]
ls_sort = sorted(ls,reverse=True)

for i in range(n):
    if ls[i] == ls_sort[0]:
        print(ls_sort[1])
    else:
        print(ls_sort[0])
### BUGGY CODE ###

import math

N = int(input())

if math.floor(math.log(N, 2)) == math.log(N, 2):
    print("No")
    exit()
else:
    print("Yes")

i = 1
print("{} {}".format(N+1, N+2))
while i < N:
    if i+2 <= N:
        print("1 {}".format(i+1))
        print("{} {}".format(i+1, i+2))
        print("1 {}".format(i+2+N))
        print("{} {}".format(i+2+N, i+1+N))
        i += 2
    else:
        print("{} {}".format(i-1, i+1))
        print("{} {}".format(N+3, i+1+N))


### FIXED CODE ###

import math
 
N = int(input())
 
if math.floor(math.log(N, 2)) == math.log(N, 2):
    print("No")
    exit()
else:
    print("Yes")
 
i = 1
print(N+1, N+2)
for i in range(1, N, 2):
    if i+2 <= N:
        print(1, i+1)
        print(i+1, i+2)
        print(1, i+2+N)
        print(i+2+N, i+1+N)
    else:
        print(i-1, i+1)
        tmp = (i+1) ^ (i-1) 
        print(N+tmp+1, i+1+N)
### BUGGY CODE ###

n=int(input())
l=[0]+list(map(int,input().split()))
edge=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
s=1
ans=[0 for i in range(n+1)]

from bisect import bisect_left, bisect_right
INF=float('inf')

import sys
sys.setrecursionlimit(10**6)
dep=[-1 for i in range(n+1)]
def dfs(s,d,c):
    dep[s]=d
    cc=c[:]
    cc[bisect_left(cc,l[s])]=l[s]
    ans[s]=bisect_left(cc,INF)
    for i in edge[s]:
        if dep[i]==-1:
            dfs(i,d+1,cc)
c=[INF]*len(l)
dfs(1,0,c)
for i in range(1,n+1):
    print(ans[i])

### FIXED CODE ###

n=int(input())
l=[0]+list(map(int,input().split()))
edge=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
s=1
ans=[0 for i in range(n+1)]

from bisect import bisect_left, bisect_right
INF=float('inf')

import sys
sys.setrecursionlimit(10**6)
dep=[-1 for i in range(n+1)]
def dfs(s,d,c):
    dep[s]=d
    x=bisect_left(c,l[s])
    c[x],y=l[s],c[x]
    ans[s]=bisect_left(c,INF)
    for i in edge[s]:
        if dep[i]==-1:
            dfs(i,d+1,c)
    c[x]=y
c=[INF]*len(l)
dfs(1,0,c)
for i in range(1,n+1):
    print(ans[i])
### BUGGY CODE ###

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

for i in range(n):
  x*=a[i]
  
print(x if x<=1000000000000000000 else "-1")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
  print("0")
  exit()

for i in range(n):
  x*=a[i]
  if x<=1000000000000000000:
    pass
  else:
    print("-1")
    exit()
  
print(x)
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 1
for i in range(1, N):
  flag = 0
  for j in range(i):
    if P[j] < P[i]:
      flag += 1
      break
  if flag == 0:
    ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 0
minimum = 200001
for p in P:
  if p <= minimum:
    minimum = p
    ans += 1
print(ans)