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

import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())) + [0]*(k+1))
dp = np.array([0] + [float("inf")] * (n+k+1))

for i in range(1, n):
    s = max(0, i-k)
    dp[i] = min(dp[s:i] + abs(h[i] - h[s:i]))

print(int(dp[n-1]))

### FIXED CODE ###

import numpy as np

n,k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

dp = np.array([0] * n)

for i in range(1,n):
    s = max(i-k,0)
    dp[i] = min(dp[s : i] + abs(h[i] - h[s:i]))

print(dp[n-1])
### BUGGY CODE ###

from collections import deque


def cnt():
    n, q = map(int, input().split())
    s = input()
    qs = []
    for i in range(q):
        qs.append(list(map(int, input().split())))
    for i in range(q):
        que = deque(maxlen = 2)
        cnt = 0
        l = qs[i][0]
        r = qs[i][1]
        for a in s[l-1: r]:
            que.append(a)
            if que == deque(['A', 'C']):
                cnt += 1
        print(cnt)
        
cnt()

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
qs = [list(map(int, input().split())) for i in range(Q)]
t =[0] * N
for i in range(N-1):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)
def ans(l, r):
    return t[r-1] - t[l-1]
for l, r in qs:
    print(ans(l,r))
### BUGGY CODE ###

# n次元バーガーの[全段数,パティ枚数]
def burger(n):
    if n == 0:
        return [1,1]
    return [burger(n-1)[0]*2+3,burger(n-1)[1]*2+1]

# レベルn, 下からx段, 食べるパティp枚
def eat(n,x):
    if n==0:
        if x>0:
            return 1
        else:
            return 0
    if x < 1:
        return 0
    if 1 <= x <= 1+burger(n-1)[0]:
        return eat(n-1,x-1)
    if x == 2 + burger(n-1)[0]:
        return burger(n-1)[1]+1
    if x>2+burger(n-1)[0]:
        return eat(n-1,x-2-burger(n-1)[0])+burger(n-1)[1]+1

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

print(eat(n,x))

### FIXED CODE ###

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

b = [[1,1]]

for i in range(n):
    b.append([b[-1][0]*2+3, b[-1][1]*2+1])

ans = 0
for i in range(len(b)):
    if x >= b[-1-i][0]:
        x -= b[-1-i][0]
        ans += b[-1-i][1]
        if x > 0:
            x-=1
            ans += 1
        if x>=b[-1-i][0]:
            x -= b[-1 - i][0]
            ans += b[-1 - i][1]
            break
    x-=1
    if x<=0:
        break

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

import sys
input=sys.stdin.readline

s=int(input())

#0<= x,y <=10**9
#s/2

if s<=10**9:
    print(0,0,1,0,0,s)
    exit()

hoge=int(s**0.5)

import math
def isPrime(num):
    if num < 2: return False
    elif num == 2: return True
    elif num % 2 == 0: return False
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False
    return True
def callIsPrime(input_num):
    numbers = []
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)
    return numbers
test=(callIsPrime(10**9))

for i in test:
    ss=i
    #print(ss)
    if s%ss==0 and s//ss<=10**9:
        print(0,0,ss,0,0,s//ss)
        exit()



### FIXED CODE ###

import sys
input=sys.stdin.readline

s=int(input())

#0<= x,y <=10**9
#s/2

if s<=10**9:
    print(0,0,1,0,0,s)
    exit()

y=(-1*s//(10**9))*(-1)
x=10**9*y-s

print(0,0,10**9,1,x,y)
### BUGGY CODE ###

lenght = int(input())

x = list(map(int,input().split()))

first_val = x[0]
for i in range(lenght-1):
  first_val *= x[i+1]

if first_val > 1e18:
  first_val = -1

print(first_val)

### FIXED CODE ###

lenght = int(input())
 
x = list(map(int,input().split()))
x.sort(reverse=True)
check = False

if x[-1]==0:
  print(0)
else:
  first_value = 1
  for val in x:
    first_value *= val
    if first_value > 1e18:
      check=True
      break
  if check:
    print(-1)
  else:
  	print(first_value)
### BUGGY CODE ###

N = int(input())
M = [input() for i in range(N)]

M_sorted = [''.join(sorted(m)) for m in M]
M_setlist = list(set(M_sorted))
ans = 0

for m in M_setlist :
    c =M_sorted.count(m)
    if c == 2 :
        ans += 1
    elif 3 <= c :
        ans += (c**2 -c*3)/2 + c

print(int(ans))

### FIXED CODE ###

N = int(input())
M = [input() for i in range(N)]
 
M_sorted = [''.join(sorted(m)) for m in M]
d = {}
ans = 0
 
for m in M_sorted :
    d.setdefault(m,0)
    ans += d[m]
    d[m] += 1
 
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    A = input().split()
    
    ans = []
    ans_str = ""
    hafe = N // 2
    for i in range(N, 0, -1):
        if i >= hafe:
            if A[i-1] == "1":
                ans.append(i)
                ans_str = ans_str + str(i) + " "
            continue
            
        cons = 0
        for j in range(i, N+1, i):
            if j in ans:
                cons += 1
        if A[i-1] == "1" and cons % 2 == 0:
            ans.append(i)
            ans_str = ans_str + str(i) + " "
            continue
        if A[i-1] == "0" and cons % 2 == 1:
            ans.append(i)
            ans_str = ans_str + str(i) + " "
            continue
            
    print(len(ans))
    print(ans_str)
            	
if __name__ == "__main__":
	main()


### FIXED CODE ###

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=INT()
A=LIST()
 
# その位置にボールを入れるかを保持するA2
A2=[0]*N
B=[]
# 後ろから決めていく
for i in range(N-1, -1, -1):
    cur=i+1
    cnt=0
    # curの倍数を全部見に行く
    for j in range(cur*2, N+1, cur):
        cnt^=A2[j-1]
    # ボールを入れるべきかどうか
    if A[i]!=cnt:
        B.append(cur)
        A2[i]=1
 
print(len(B))
print(*B)
### BUGGY CODE ###

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



a=list(map(int,input().split()))
for i in range(m):
	a.sort()
	a[-1]=a[-1]//2
	#print(a)
print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[-_ for _ in a]
import heapq
heapq.heapify(a)
for i in range(m):
  temp=-heapq.heappop(a)
  heapq.heappush(a,-(temp//2))
  
print(-sum(a))
### BUGGY CODE ###

from sys import stdin
def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
 
def main():
    n = I()
    s = list(S())
    ans = 0
    for i in range(n-2):
        color = {s[i]}
        for j in range(i+1,n-1):
            if not s[j] in color:
                color.add(s[j])
                for k in range(j+1,n):
                    if not s[k] in color:
                        if k-j != j-i:
                            ans += 1
                color = {s[i]}
    
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from sys import stdin
def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
 
n = I()
s = list(S())

r = s.count('R')
g = s.count('G')
b = s.count('B')
 
ans = r*g*b
for i in range(n-1):
    for j in range(1,n):
        if i-j<0 or n<=i+j:
            break
        else:
            if s[i-j]!=s[i] and s[i]!=s[i+j] and s[i-j]!=s[i+j]:
                ans-=1
 
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
    H, N = map( int, input().split())
    AB = [ list( map( int, input().split())) for _ in range(N)]
    dp = [10**9]*H + [0]*(10**4+1)
    T = H+10**4
    for a, b in AB:
        for i in range(T,a-1,-1):
            if dp[i-a] > dp[i]+b:
                dp[i-a] = dp[i]+b
    print(dp[0])
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    H, N = map( int, input().split())
    AB = [ list( map( int, input().split())) for _ in range(N)]
    dp = [10**9]*H + [0]*(10**4+1)
    T = H+10**4
    for a, b in AB:
        for i in range(T,a-1,-1):
            if dp[i-a] > dp[i]+b:
                dp[i-a] = dp[i]+b
    print(dp[0])
if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

ans = [0]*(n+1)
for i in range(0, a[0]*2+1, 2):
    ans[0] = i
    for j in range(n):
        ans[j+1] = (a[j] - ans[j]//2) *2
    if ans[0] == ans[n]:
        print(' '.join(map(str, ans[0:len(ans)-1])))
        exit(0)


### FIXED CODE ###

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

ans = [0]*(n+1)
#for i in range(0, a[0]*2+1, 2):
#    ans[0] = i
while True:
    for j in range(n):
        ans[j+1] = (a[j] - ans[j]//2) *2
    if ans[0] == ans[n]:
        print(' '.join(map(str, ans[0:len(ans)-1])))
        exit(0)
    else:
        ans[0] += ans[n]//2
### BUGGY CODE ###

N = int(input())
S = input()
s = set()

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            s.add(S[i] + S[j] + S[k])

print(len(s))

### FIXED CODE ###

N = int(input())
S = input()
count = 0

# s = set()
# for i in range(N - 2):
#     for j in range(i + 1, N - 1):
#         for k in range(j + 1, N):
#             s.add(S[i] + S[j] + S[k])

# print(len(s))

def get_idx(array, val, tmp):
    for i in range(tmp + 1, len(array)):
        if val == array[i]:
            return i
    return -1

V = []
for i in range(1000):
    if i < 10: V.append("00" + str(i))
    elif i < 100: V.append("0" + str(i))
    else: V.append(str(i))

for v in V:
    tmp = -1
    flag = True
    for i in range(3):
        if v[i] in S:
            idx = get_idx(S, v[i], tmp)
            if idx != -1:
                tmp = idx
            else:
                flag = False
                break
        else:
            flag = False
            break
    if flag:
        count += 1

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

import sys

sys.setrecursionlimit(1000000)
N, Q = map(int, input().split())
A, B = [], []

edges = [[] for _ in range(N + 1)]
nums = [0 for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    nums[p] += x


def dfs(now, parent):
    for i in edges[now]:
        if i != parent:
            nums[i] += nums[now]
            dfs(i, now)


dfs(1, 0)
for n in nums[1:]:
    print(n)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, Q = map(int, input().split())

    edges = [[] for _ in range(N + 1)]
    nums = [0 for _ in range(N + 1)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        edges[a].append(b)
        edges[b].append(a)

    for _ in range(Q):
        p, x = map(int, input().split())
        nums[p] += x

    def dfs(now, parent):
        for i in edges[now]:
            if i != parent:
                nums[i] += nums[now]
                dfs(i, now)

    dfs(1, 0)
    for n in nums[1:]:
        print(n)


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

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

for i in range(1,n+1):
    b = a.count(i)
    print(b)


### FIXED CODE ###

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

for i in range(n):
    print(a[i+1])
### BUGGY CODE ###

N ,M = list(map(int,input().split()))
A = [int(x) for x in input().split()]
for i in range(M):
  A[A.index(max(A))] //= 2
print(sum(A))

### FIXED CODE ###

import heapq
N, M = list(map(int,input().split()))
h = []
for x in input().split():
  heapq.heappush(h, -int(x))
for i in range(M):
  x = -heapq.heappop(h)
  x //= 2
  heapq.heappush(h,-x)
print(-sum(h))
### BUGGY CODE ###

import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    N = sc.intarr()[0]
    S = sc.strarr()[0]

    count = 0

    for i in range(1000):
        # print("--------")
        lucky = "000"
        Flag_j = -1
        Flag_m = -1
        Flag_n = -1
        # print("check001")
        if i < 10:
            lucky = "00" + str(i)
        elif i < 100:
            lucky = "0" + str(i)
        else:
            lucky = str(i)

        for j in range(N):
            if S[j] == lucky[0]:
                Flag_j = j
                break
        # print("check002")
        if Flag_j == -1:
            continue
        # print("check003")

        for m in range(Flag_j+1, N):
            if S[m] == lucky[1]:
                Flag_m = m
                break
        # print("check004")
        if Flag_m == -1:
            continue
        # print("check005")

        for n in range(Flag_m+1, N):
            if S[n] == lucky[2]:
                Flag_n = n
                break
        # print("check006")
        if Flag_n == -1:
            continue
        # print("check007")
        count += 1

    print(count)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()


### FIXED CODE ###

import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    _ = sc.intarr()[0]
    S = sc.strarr()[0]

    count = 0

    for i in range(1000):
        # print("--------")
        lucky = format_str(i)
        first = S.find(lucky[0])
        third = S.rfind(lucky[2])

        if first == -1 or third == -1:
            continue
        elif first < third:
            if lucky[1] in S[first + 1:third]:
                count += 1
    print(count)


def format_str(num):
    if num < 10:
        return "00" + str(num)
    elif num < 100:
        return "0" + str(num)
    else:
        return str(num)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()
### BUGGY CODE ###

def main():
  k, q = map(int, input().split())
  d = list(map(int, input().split()))
  from collections import deque
  for i in range(q):
    n, x, m = map(int, input().split())
    x %= m
    d_mod = deque()
    for i in d:
      i_mod = i % m
      if i_mod == 0:
        d_mod.append(m)
      else:
        d_mod.append(i_mod)
    d_mod_sum = sum(d_mod)
    rep = (n-1) // k
    rem = (n-1) % k
    d_mod = list(d_mod)
    rem_sum = sum(d_mod[:rem])
    ans = n - 1 - (x + d_mod_sum * rep + rem_sum) // m
    print(ans)
if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  import numpy as np
  k, q = map(int, input().split())
  d = np.array(list(map(int, input().split())))
  for i in range(q):
    n, x, m = map(int, input().split())
    x %= m
    d_mod = d % m
    zero_d = k - np.count_nonzero(d_mod)
    d_mod_sum = np.sum(d_mod) + m * zero_d
    rep = (n-1) // k
    rem = (n-1) % k
    zero_rem = len(d_mod[:rem]) - np.count_nonzero(d_mod[:rem])
    rem_sum = np.sum(d_mod[:rem]) + m * zero_rem
    ans = n - 1 - (x + d_mod_sum * rep + rem_sum) // m
    print(ans)
if __name__ == '__main__':
  main()
### BUGGY CODE ###

n = int(input())
q = [int(x) for x in input().split(' ')]

contradiction = False
if (n%2 == 1):
    count = 2**((n-1)//2)
    for i in range(0,n,2):
        if(i == 0):
            contradiction = (q.count(i) != 1)
        else:
            contradiction = (q.count(i) != 2)
else:
    count = 2**(n//2)
    for i in range(1,n,2):
        contradiction = (q.count(i) != 2)
    
if (contradiction):
    print(0)
else:
    print(count%(10**9+7))

### FIXED CODE ###

n = int(input())
q = [int(x) for x in input().split(' ')]
q_set = set(q)

if (n%2 == 1):
    count = 2**((n-1)//2)
else:
    count = 2**(n//2)
    
    
if (sum(q) == 2*sum(q_set)):
    print(count%(10**9+7))
else:
    print(0)
### BUGGY CODE ###

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

n,q=map(int,input().split())
AB=[[int(x) for x in input().split()] for _ in range(n-1)]
PX=[[int(x) for x in input().split()] for _ in range(q)]

graph=[[] for _ in range(n+1)]
values=[0]*(n+1)

for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

for p,x in PX:
    values[p]+=x

#print(graph)

def dfs(x,parent,add):
    values[x]+=add
    for i in graph[x]:
        if i==parent:
            continue
        dfs(i,x,values[x])

dfs(1,0,0)

print(' '.join(map(str,values[1:])))


### FIXED CODE ###

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

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
a_list.sort(reverse=True)
b_list.sort(reverse=True)
c_list.sort(reverse=True)
ans = []
candidates = [(0, 0, 0)]
used = set()
while len(ans) < K:
    max_x, max_y, max_z = candidates[0]
    max_sum = a_list[max_x] + b_list[max_y] + c_list[max_z]
    for x, y, z in candidates:
        s = a_list[x] + b_list[y] + c_list[z]
        if s > max_sum:
            max_x, max_y, max_z = x, y, z
            max_sum = s
    if not (max_x, max_y, max_z) in used:
        ans.append(max_sum)
    candidates.remove((max_x, max_y, max_z))
    used.add((max_x, max_y, max_z))
    if max_x < X - 1:
        candidates.append((max_x + 1, max_y, max_z))
    if max_y < Y - 1:
        candidates.append((max_x, max_y + 1, max_z))
    if max_z < Z - 1:
        candidates.append((max_x, max_y, max_z + 1))
for a in ans:
    print(a)


### FIXED CODE ###

import heapq

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

candidates = []
heapq.heappush(candidates, (-(A[0] + B[0] + C[0]), 0, 0, 0))
used = {(0, 0, 0)}
for _ in range(K):
    s, i, j, k = heapq.heappop(candidates)
    print(-s)
    if i < X - 1 and (i+1, j, k) not in used:
        heapq.heappush(candidates, (-(A[i+1] + B[j] + C[k]), i+1, j, k))
        used.add((i+1, j, k))
    if j < Y - 1 and (i, j+1, k) not in used:
        heapq.heappush(candidates, (-(A[i] + B[j+1] + C[k]), i, j+1, k))
        used.add((i, j+1, k))
    if k < Z - 1 and (i, j, k+1) not in used:
        heapq.heappush(candidates, (-(A[i] + B[j] + C[k+1]), i, j, k+1))
        used.add((i, j, k+1))
### BUGGY CODE ###

import sys
import os
from collections import deque

def file_input():
    f = open('ABC168/input.txt', 'r')
    sys.stdin = f

def main():
    if os.getenv("ENV")=='LOCAL':
        file_input()

    N,M=map(int, input().split())
    r={}
    for i in range(M):
        A,B=map(int, input().split())
        # print("A:"+str(A[i])+" B:"+str(B[i]))
        if A not in r:
            r[A]=[B]
        else:
            r[A].append(B)
        if B not in r:
            r[B]=[A]
        else:
            r[B].append(A)
        # print(tmp[A[i]-1])
    # print(r)

    q=deque()
    q.append(1)
    visited=set()
    out=[0]*(N-1)
    while len(q)>0:
        # print("q="+str(q))
        position=q.popleft()
        # print("p="+str(position))
        visited.add(position)
        for des in r[position]: #今いる場所から行ける場所を探索
            if des in visited:  #すでに訪問済み
                continue
            if des in q:    #ループよけ 2→2みたいな
                continue
            q.append(des)   #行ける場所だった場合キューに追加
            # print("destination="+str(des)+" p="+str(position)+" q="+str(q))
            out[des-2]=position
    # print(visited)



    print('Yes')
    [print(x) for x in out]

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os
from collections import deque

def file_input():
    f = open('ABC168/input.txt', 'r')
    sys.stdin = f

def main():
    if os.getenv("ENV")=='LOCAL':
        file_input()

    N,M=map(int, input().split())
    r={}
    for i in range(M):
        A,B=map(int, input().split())
        # print("A:"+str(A[i])+" B:"+str(B[i]))
        if A not in r:
            r[A]=[B]
        else:
            r[A].append(B)
        if B not in r:
            r[B]=[A]
        else:
            r[B].append(A)
        # print(tmp[A[i]-1])
    # print(r)

    q=deque()
    q.append(1)
    visited=set()
    visited.add(1)
    out=[0]*(N-1)
    while len(q)>0:
        # print("q="+str(q))
        position=q.popleft()
        # print("p="+str(position))
        for des in r[position]: #今いる場所から行ける場所を探索
            if des not in visited:  #訪問済みでないなら
                q.append(des)   #行ける場所だった場合キューに追加
                visited.add(des)   #訪問済みにする
                out[des-2]=position
                # print("destination="+str(des)+" p="+str(position)+" q="+str(q))
    # print(visited)



    print('Yes')
    [print(x) for x in out]

if __name__ == '__main__':
    main()