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

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

dp = [[0]*(N+10) for _ in range(N+10)]
dp[0][0] = 0
for width in range(1, N+1):
    for l in range(1, N+1):
        r = l + width
        if r >= N+2:
            break
        if width % 2 == N % 2:
            dp[l][r] = max(dp[l][r-1]+a_list[r-2], dp[l+1][r]+a_list[l-1])
        else:
            dp[l][r] = min(dp[l][r-1]-a_list[r-2], dp[l+1][r]-a_list[l-1])

print(dp[1][N+1])

### FIXED CODE ###

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

dp = [[0]*(N+10) for _ in range(N+10)]
dp[0][0] = 0
for width in range(1, N+1):
    for l in range(1, N+1):
        r = l + width
        if r >= N+2:
            break
        if width % 2 == N % 2:
            dp[l][r] = max(dp[l][r-1]+a_list[r-2], dp[l+1][r]+a_list[l-1])
        else:
            dp[l][r] = min(dp[l][r-1]-a_list[r-2], dp[l+1][r]-a_list[l-1])

print(dp[1][N+1])
### BUGGY CODE ###

import numpy as np
n,m = list(map(int,input().split()))
d = [[1<<n] for _ in range(m)]
s = 1<<0
for i in range(m):
  a,b = list(map(int,input().split()))
  d[i] = ((1<<a)-1) ^ ((1<<b)-1)

spr = [[False] for _ in range(m)]

ans = float('inf')
for bit in range(1<<n):
  spr = [True for _ in range(m)]
  for k in range(m):
      if (d[k] & bit) > 0:
        spr[k] = False
  if sum(spr) == 0:
      ans = min(ans, sum([1 for i in range(n) if bit & 1<<i]))
      print(ans)
      exit()


### FIXED CODE ###


n,m = list(map(int,input().split()))
d = [0]*m
spr = [True]*m
ma = 0
mi = 0
for i in range(m):
    a,b = list(map(int,input().split()))
    d[i] = [a,b]

d = sorted(d)
pre = d[0][1]
ans = 1
for i,(a,b) in enumerate(d):
  if a < pre:
    if b < pre:
      pre = b
  else:
    ans += 1
    pre = b

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

k, q = map(int, input().split())
d = list(map(int, input().split()))
for i in range(q):
    n, x, m = map(int, input().split())
    d2 = [d[i] % m for i in range(k)]
    sum_d = [0] * (k + 1)
    for i in range(k):
        sum_d[i + 1] = sum_d[i] + d2[i]
    a = (n - 1) // k
    b = (n - 1) % k
    e = d2[:b]
    c = (x + sum_d[k] * a + sum_d[b]) // m - (x // m)
    print(n - 1 - c - d2.count(0) * a - e.count(0))

### FIXED CODE ###

k, q = map(int, input().split())
d = list(map(int, input().split()))
for i in range(q):
    n, x, m = map(int, input().split())
    d2 = [d[i] % m for i in range(k)]
    sum_d = [0] * (k + 1)
    count_d = [0] * (k + 1)
    for i in range(k):
        sum_d[i + 1] = sum_d[i] + d2[i]
        if d2[i] == 0:
            count_d[i + 1] = count_d[i] + 1
        else:
            count_d[i + 1] = count_d[i]
    a = (n - 1) // k
    b = (n - 1) % k
    c = (x + sum_d[k] * a + sum_d[b]) // m - (x // m)
    print(n - 1 - c - count_d[k] * a - count_d[b])
### BUGGY CODE ###

n = int(input())
s = list(map(int,list(input())))


ans_L = []
length = len(s)
count = 0

for i in range(1000):
    i = list(str(i).zfill(3))
    idx = 0
    tmp_L = []

    for j in range(3):
        for k in range(idx,length):
            if str(i[j]) == str(s[k]):
                idx = k+1
                tmp_L.append(str(i[j]))
                break

    if len(tmp_L) == 3:
        ans_L.append("".join(tmp_L))

print(len(set(ans_L)))
#print(set(ans_L))

### FIXED CODE ###

n = int(input())
s = list(map(int,list(input())))


ans_L = []
length = len(s)
count = 0

for i in range(1000):
    i = list(str(i).zfill(3))
    idx = 0
    cnt = 0
    for j in range(3):
        for k in range(idx,length):
            if str(i[j]) == str(s[k]):
                idx = k+1
                cnt += 1
                break
        if cnt ==0:
            break

    #if len(tmp_L) == 3:
    #    ans_L.append("".join(tmp_L))
    if cnt == 3:
        count +=1

print(count)
#print(set(ans_L))
### BUGGY CODE ###

from collections import deque

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

def func1(lst, value):
    return [i for i, x in enumerate(lst) if x == value]
  
temp=1
trace=deque()
trace.append(1)
#trace=[1]
circle=[]
for i in range(K):
  temp=A[temp-1]
  ans=func1(trace,temp)
  if len(ans)==1:
    #print(temp)
    #print(trace.index(temp))
    #start=trace.index(temp)
    for _ in range(ans[0]):
      trace.popleft()
    #circle=trace[ans[0]:]
    circle.append(1)
    #print(circle)
    break
  trace.append(temp)
  #print("temp",temp)
#print((K-i)%len(circle)-1)
if len(circle)!=0:
  amari=(K-i)%len(trace)-1
  print(trace[amari])
else:
  print(temp)

### FIXED CODE ###

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
 
check=[-1 for i in range(N)]
  
temp=1
circle=[]
for i in range(K):
  temp=A[temp-1]
  if check[temp-1]==-1:
    check[temp-1]=i
  else:
    circle.append(i-check[temp-1])
    #print(circle)
    break
  #print("temp",temp)
#print((K-i)%len(circle)-1)
if len(circle)!=0:
  amari=(K-i)%circle[0]
  temp=1
  for j in range(i+amari):
    temp=A[temp-1] 

print(temp)
### BUGGY CODE ###

import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

mod=998244353

N,S=nm()
A=nl()


dp=[[0]*3001  for _ in range(3001)]#i i番目 j和がj
dp[0][A[0]]=1
dp[0][0]=2
for i in range(1,N):
    for j in range(0,3001):
        if(0<=(j-A[i])):
            dp[i][j]=dp[i-1][j-A[i]]+2*dp[i-1][j]
        else:
            dp[i][j]=2*dp[i-1][j]
        dp[i][j]%=mod

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

### FIXED CODE ###

import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

mod=998244353

N,S=nm()
A=nl()


dp=[[0]*3001  for _ in range(3001)]#i i番目 j和がj
dp[0][A[0]]=1
dp[0][0]=2
for i in range(1,N):
    for j in range(0,3001):
        if(0<=(j-A[i])):
            dp[i][j]=dp[i-1][j-A[i]]+2*dp[i-1][j]
        else:
            dp[i][j]=2*dp[i-1][j]
        dp[i][j]%=mod

ans=dp[N-1][S]
print(ans%mod)
### BUGGY CODE ###

import sys

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
nlist=[]

for i in range(1,m):
  if a[i]-a[i-1]==1:
    print(0)
    sys.exit()
if 1 in a:
  nlist.append(0)
  nlist.append(1)
elif 2 in a:
  nlist.append(1)
  nlist.append(0)
else:
  nlist.append(1)
  nlist.append(2)

for i in range(2,n):
  if i+1 in a:
    nlist.append(0)
  else:
    nlist.append(nlist[i-1]+nlist[i-2])
print(nlist[n-1]%1000000007)

### FIXED CODE ###

import sys

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
nlist=[]
analist=[0]*n
#O(N^2)を防ぐために、穴判定用配列作る
for i in range(m):
  analist[a[i]-1]="ana"

for i in range(1,m):
  if a[i]-a[i-1]==1:
    print(0)
    sys.exit()
if 1 in a:
  nlist.append(0)
  nlist.append(1)
elif 2 in a:
  nlist.append(1)
  nlist.append(0)
else:
  nlist.append(1)
  nlist.append(2)

for i in range(2,n):
  if analist[i]=="ana":
    nlist.append(0)
  else:
    nlist.append((nlist[i-1]+nlist[i-2])%1000000007)
print(nlist[n-1]%1000000007)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush
import numpy as np


def small_dp(N,k,X):
    if k == 0:
        return N
    if k == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if k == 2:
        c = 0
        for i in range(N//X[0][0]+1):
            j = (N-i*X[0][0])//X[1][0]
            c = max(X[0][1]*i + X[1][1]*j + (N-i*X[0][0])%X[1][0], c)
        return c
    if k == 3:
        dp = np.zeros(N+1, dtype=int)
        for w in range(1,N+1):
            dp[w] = max(dp[w-X[i][0]]+X[i][1] if w>=X[i][0] else w for i in range(3))
        N = dp[-1]
        return N

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    for C in ((A,B), (B,A)):
        *X, = filter(lambda c: int.__sub__(*c)<0, zip(*C))
        N = small_dp(N, len(X), X)
    res = N

    return str(res)

if __name__ == '__main__':
    print(solve())


### FIXED CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush

def small_dp(N,A,B):
    *X, = filter(lambda c: int.__sub__(*c)<0, zip(A,B))
    k = len(X)
    if k == 0:
        return N
    if k == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if k == 2:
        c = 0
        for i in range(N//X[0][0]+1):
            j = (N-i*X[0][0])//X[1][0]
            c = max(X[0][1]*i + X[1][1]*j + (N-i*X[0][0])%X[1][0], c)
        return c
    if k == 3:
        if (N//X[1][0]+1)*(N//X[0][0]+1) <= 10**6 :
            return max(X[0][1]*i + max(X[1][1]*j + X[2][1]*((N-i*X[0][0]-j*X[1][0])//X[2][0]) + ((N-i*X[0][0]-j*X[1][0])%X[2][0]) for j in range((N-i*X[0][0])//X[1][0]+1)) for i in range(N//X[0][0]+1))
        else:
            import numpy as np
            dp = np.zeros(N+1, dtype=int)
            for w in range(1,N+1):
                dp[w] = max(dp[w-X[i][0]]+X[i][1] if w>=X[i][0] else w for i in range(k))
            N = dp[-1]
            return N

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    res = small_dp(small_dp(N, A, B), B, A)

    return str(res)

if __name__ == '__main__':
    print(solve())
### BUGGY CODE ###

from operator import itemgetter
mod=998244353

def bit_add(i):
    while i<=n:
        tree[i]+=1
        i+=i&(-i)

def bit_sum(i):
    s=0
    while i>0:
        s+=tree[i]
        i-=i&(-i)
    return s

n=int(input())
xy=[[i+1]+list(map(int,input().split())) for i in range(n)]
data=[[] for i in range(n+1)]
for i in [1,2]:
    xy.sort(key=itemgetter(i))
    for j in range(n):
        data[xy[j][0]].append(j+1)
        
lsls=[1]*(n+1)
for i in range(1,n+1):
    lsls[i]=lsls[i-1]*2%mod
for i in range(n+1):
    lsls[i]-=1

data=sorted(data[1:])
lst=[]
for i1,i2 in data:
    lst.append(i2)

s=pow(2,n,mod)-1
tree=[0]*(n+1)
ans=0
for i in range(n):
    y=lst[i]
    num=bit_sum(y)
    bit_add(y)
    a,b,c,d=i-num,num,y-1-num,n-y-i+num
    t=(lsls[i]+lsls[n-i-1]+lsls[n-y]+lsls[y-1]-(lsls[a]+lsls[b]+lsls[c]+lsls[d]))%mod
    ans=(ans+s-t)%mod
print(ans)

### FIXED CODE ###

from operator import itemgetter
import sys
input=sys.stdin.readline
mod=998244353

def bit_add(i):
    while i<=n:
        tree[i]+=1
        i+=i&(-i)
        
def bit_sum(i):
    s=0
    while i>0:
        s+=tree[i]
        i-=i&(-i)
    return s

n=int(input())
xy=[[i+1]+list(map(int,input().split())) for i in range(n)]
data=[[] for i in range(n+1)]
for i in [1,2]:
    xy.sort(key=itemgetter(i))
    for j in range(n):
        data[xy[j][0]].append(j+1)
    
data=sorted(data[1:])
lst=[]
for i1,i2 in data:
    lst.append(i2)

lsls=[1]*(n+1)
for i in range(1,n+1):
    lsls[i]=lsls[i-1]*2%mod
for i in range(n+1):
    lsls[i]-=1
    
s=pow(2,n,mod)-1
tree=[0]*(n+1)
ans=0
for i in range(n):
    y=lst[i]
    num=bit_sum(y)
    bit_add(y)
    a,b,c,d=i-num,num,y-1-num,n-y-i+num
    zzz=lsls[i]+lsls[n-i-1]+lsls[n-y]+lsls[y-1]
    yyy=lsls[a]+lsls[b]+lsls[c]+lsls[d]
    t=(zzz%mod-yyy%mod)%mod
    ans=(ans+s-t)%mod
print(ans)
### BUGGY CODE ###

from sys import stdin
n, m = map(int, stdin.readline().split())
ans = set(range(1, n+1))
for i in range(m):
    l, r = map(int, stdin.readline().split())
    ans = list(filter(lambda x:l<=x<=r, ans))
print(len(ans))

### FIXED CODE ###

from sys import stdin
n, m = map(int, stdin.readline().split())
mn = 1
mx = n

for i in range(m):
    l, r = map(int, stdin.readline().split())
    mn = max(mn, l)
    mx = min(mx, r)
print(max(0, mx-mn+1))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int):
    print(sum([i for i in range(1,N)]))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int):
    print((N-1)*(N)//2)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

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

H,W,D=list(map(int,input().split()))
arr=[0 for i in range(H*W+1)]
for y in range(H):
    for x,n in enumerate(map(int,input().split())):
        arr[n]=[x,y]

dic={}

Q=int(input())
for i in range(Q):
    ans=0
    now,goal= list(map(int,input().split()))
    nx=arr[now][0]
    ny=arr[now][1]
    tmp=now
    for j in range((goal-now)//D):
        if dic.get(tmp*H*W+goal,0)!=0:
            dic[now*H*W+goal]=ans+dic[tmp*H*W+goal]
            print(dic[now*H*W+goal])
            break
        tmp+=D
        x=arr[tmp][0]
        y=arr[tmp][1]
        ans+=abs(x-nx)+abs(y-ny)
        nx=x
        ny=y
    if dic.get(now*H*W+goal,0)==0:
        dic[now*H*W+goal]=ans
        print(ans)

### FIXED CODE ###

H,W,D=list(map(int,input().split()))
map_=[[0,0] for _ in range(H*W+1)]
for y in range(H):
    for x,A in enumerate(map(int,input().split())):
        map_[A]=[x+1,y+1]

cost=[0 for _ in range(H*W+1)]
for i in range(D+1,H*W+1):
    cost[i]+=abs(map_[i][0]-map_[i-D][0])+abs(map_[i][1]-map_[i-D][1])+cost[i-D]
Q=int(input())
for i in range(Q):
    L,R=list(map(int,input().split()))
    print(cost[R]-cost[L])
### BUGGY CODE ###

s=input()
num =int(input())
for i in range(num):
    q=input().rstrip().split()
    if q[0]=="1":
        s=s[::-1]
    else:
        if q[1]=="1":
            s=q[2]+s
        else:
            s=s+q[2]
print(s)

### FIXED CODE ###

s=input()
s1=""
s2=""
count_1=0
l=[]
num =int(input())
 
 
for x in range(num):
    i=input().rstrip().split()
    if i[0]=="1":
        count_1+=1
        
    elif i[1]=="1" and count_1%2==0:
        s1=i[2]+s1
   
    elif i[1]=="1" and count_1%2==1:
        s2=s2+i[2]
 
    elif i[1]=="2" and count_1%2==0:
        s2=s2+i[2]
 
    elif i[1]=="2" and count_1%2==1:
        s1=i[2]+s1
s=s1+s+s2
 
if count_1%2==1:
    s=s[::-1]
print(s)
### BUGGY CODE ###

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

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

for i in range(m):
    l,r=map(int,input().split())
    mylist[l][r]+=1

for i in range(1,n+1):
    for j in range(1,n+1):
        mylist[i][j]+=mylist[i][j-1]

for i in range(q):
    p,q=map(int,input().split())
    tmp=0
    for j in range(p,q+1):
        tmp+=mylist[j][q]
    print(tmp)

### FIXED CODE ###

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

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

for i in range(m):
    l,r=map(int,input().split())
    mylist[l][r]+=1

for i in range(1,n+1):
    for j in range(1,n+1):
        mylist[i][j]+=mylist[i][j-1]

memo=[[-1]*(n+1) for _ in range(n+1)]

for i in range(q):
    P,Q=map(int,input().split())
    if(memo[P][Q]!=-1):
        print(memo[P][Q])
        continue
    tmp=0
    for j in range(Q,P-1,-1):
        tmp+=mylist[j][Q]
        memo[j][Q]=tmp
    print(tmp)
### BUGGY CODE ###

S = input()
Q = int(input())
f = 0
for _ in range(Q):
  a, *b = input().split()
  f += int(a)
  if a == "2":
    if (int(b[0]) + f) % 2 == 1 :
      S = "".join([b[1],S])
    else:
      S = "".join([S,b[1]])
print (S  if f % 2 == 0 else S[::-1])


### FIXED CODE ###

from collections import deque
S = deque(list(input()))
Q = int(input())
f = 0
for _ in range(Q):
  a, *b = input().split()
  f += int(a)
  if a == "2":
    if (int(b[0]) + f) % 2 == 1 :
      S.appendleft(b[1])
    else:
      S.append(b[1])
D = list(S)
print ("".join(D) if f % 2 == 0 else "".join(D[::-1]))
### BUGGY CODE ###

N,M = map(int,input().split(" "))
isbr = []
for i in range(M):
  isbr.append(list(map(int,input().split(" "))))
isbr.sort(key=lambda x:x[1])
rem = []
i = 0
while i < M:
  a = isbr[i][0]
  b = isbr[i][1]
  flag = 0
  while a <= b:
    if b in rem:
      flag = 1
      break
    else:
      b-=1
  if flag == 0:
    rem.append(isbr[i][1]-1)
  i+=1
print(len(rem))

### FIXED CODE ###

#D問題
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
AB=sorted(AB, key=lambda x: x[1])
bridges=[]
for i in range(M):
    if len(bridges) == 0:
        bridges.append(AB[i][1]-1)
    elif max(bridges)>=AB[i][0]:
        pass
    else:
        bridges.append(AB[i][1]-1)
print(len(bridges))
### BUGGY CODE ###

a, b, k = map(int, input().split())

l = [i for i in range(a, b+1)]

if b - a < k*2:
    for i in l:
        print(i)
else:
    for i in l[:k]:
        print(i)
    for i in l[-k:]:
        print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())

if b - a < k*2:
    for j in [i for i in range(a, b+1)]:
        print(j)
else:
    for j in [i for i in range(a, a+k)]:
        print(j)
    for j in [i for i in range(b-k+1, b+1)]:
        print(j)
### BUGGY CODE ###

# 頂点n個 辺iは頂点aiとbiを結ぶ 各頂点には初期値0のカウンターがある
# 操作j: 頂点pjを根とする部分木に含まれるすべてのカウンターにxj足す
# Q回の操作のあと各カウンターの数値を求める

# 方針: 操作の際に最初に部分木の根にだけ点を加え最後に親の点を子に与えていく
import sys
sys.setrecursionlimit(10**6)

n, q = map(int, input().split())
connect = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    connect[a-1].append(b-1)
    connect[b-1].append(a-1)

count = [0 for _ in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    count[p-1] += x


def dfs(now=0, prev=-1):
    for i in range(len(connect[now])):
        kid = connect[now][i]
        if kid == prev:
            continue
        count[kid] += count[now]
        dfs(kid, now)


dfs()

for i in range(n):
    print(count[i])


### FIXED CODE ###

# 頂点n個 辺iは頂点aiとbiを結ぶ 各頂点には初期値0のカウンターがある
# 操作j: 頂点pjを根とする部分木に含まれるすべてのカウンターにxj足す
# Q回の操作のあと各カウンターの数値を求める

# 方針: 操作の際に最初に部分木の根にだけ点を加え最後に親の点を子に与えていく
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n, q = map(int, input().split())
connect = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    connect[a-1].append(b-1)
    connect[b-1].append(a-1)

count = [0 for _ in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    count[p-1] += x


def dfs(now=0, prev=-1):
    kids = connect[now]
    for kid in kids:
        if kid == prev:
            continue
        count[kid] += count[now]
        dfs(kid, now)


dfs()

for i in range(n):
    print(count[i])
### BUGGY CODE ###

from numba import njit, i4, i8


@njit(i4(i8, i4), cache=True)
def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
dp = [[0]*19 for _ in range(19)]

ans = 0
for _ in range(n):
    x = round(float(input())*10**9)
    two = div(x, 2)
    five = div(x, 5)
    ans += dp[18 - two][18 - five]
    for i in range(two + 1):
        for j in range(five + 1):
            dp[i][j] += 1

print(ans)

### FIXED CODE ###

def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
dp = [[0]*19 for _ in range(19)]

ans = 0
for _ in range(n):
    x = round(float(input()) * pow(10, 9))
    two = div(x, 2)
    five = div(x, 5)
    ans += dp[18 - two][18 - five]
    for i in range(two + 1):
        for j in range(five + 1):
            dp[i][j] += 1

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

n,k = map(int,input().split())
alist = list(map(int,input().split()))

prev = 1
curr = 1
prev_a = []
for i in range(n):
    prev_a.append(alist[i])
    prev = curr
    curr *= alist[i]
    if i >= k:
        curr /= prev_a.pop(0)
        curr = int(curr)
        if prev < curr:
            print("Yes")
        else:
            print("No")
        

### FIXED CODE ###

n,k = map(int,input().split())
alist = list(map(int,input().split()))

prev_a = []
for i in range(n):
    prev_a.append(alist[i])
    if i >= k:

        if prev_a.pop(0) < alist[i]:
            print("Yes")
        else:
            print("No")
### BUGGY CODE ###

def power(m, n):
    if n == 1:
        return m
            
    div = 1000000007

    ret = power(m * m, n // 2) % div
    if n % 2:
        ret = (ret * m) % div
    return ret
    

from sys import stdin
readline = stdin.readline


m, n = map(int, readline().split())
print(power(m, n))

### FIXED CODE ###

def power(m, n):
    if n:return power(m * m % 1000000007, n // 2) * (m if n % 2 else 1) % 1000000007
    return 1


from sys import stdin
readline = stdin.readline

m, n = map(int, readline().split())
print(power(m, n))
### BUGGY CODE ###

from itertools import product

k = int(input())
s = input()

temp_dict = {
    "R": [],
    "G": [],
    "B": [],
}
for i, c in enumerate(s):
    temp_dict[c].append(i)

ans = 0
temp_list = list(product(temp_dict["R"], temp_dict["G"], temp_dict["B"]))
for temp in temp_list:
    temp = sorted(list(temp))
    if temp[0] - temp[1] != temp[1] - temp[2]:
        ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r * g * b
for i in range(n - 2):
    for j in range(i + 2, n, 2):
        if s[i] != s[(i + j) >> 1] != s[j] != s[i]:
            ans -= 1
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)

N = int(input())
X = str(input())

def check(n, r):
    if n == 0:
        return print(r)
    d = str(bin(n)).count('1')
    check(n%d, r+1)
    
for i in range(N):
    e = -1
    if X[i] == '0':
        e = 1
    num = int(X, 2) + e * pow(2, N-1-i)
    check(num, 0)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

N = int(input())
X = str(input())
ones = X.count('1')
intX = int(X, 2)
def check(n, r):
    if n == 0:
        return print(r)
    d = str(bin(n)).count('1')
    check(n%d, r+1)

if ones > 1:
    Xplus = intX % (ones + 1)
    Xminus = intX % (ones - 1)
else:
    Xplus = intX % (ones + 1)
    Xminus = intX

for i in range(N):
    e = 1
    if X[i] == '0':
        num = (Xplus + pow(2, N-1-i, ones + 1)) % (ones + 1)
    elif X[i] == '1' and ones > 1:
        num = (Xminus - pow(2, N-1-i, ones - 1)) % (ones - 1)
    else:
        num = (Xminus - pow(2, N-1-i))
        e = 0
    check(num, e)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N, M = nm()
adj = [[] for _ in range(N)]
for i in range(M):
    a, b = nm()
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)


def solve():
    INF = 1 << 62
    q = collections.deque([(0, 0, -1)])
    dist = [INF] * N
    prev = [None] * N
    while q:
        l, node, pnode = q.popleft()
        if dist[node] < l:
            continue
        dist[node] = l
        prev[node] = pnode
        for nxt in adj[node]:
            if nxt != pnode and dist[nxt] > l + 1:
                q.append((l + 1, nxt, node))
    # if any(x is None for x in prev):
    #     print("No")
    #     return
    print("Yes")
    for i in range(1, N):
        print(prev[i] + 1)


if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N, M = nm()
adj = [[] for _ in range(N)]
for i in range(M):
    a, b = nm()
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)


def solve():
    q = collections.deque([(0, 0, -1)])
    visited = [False] * N
    prev = [None] * N
    while q:
        l, node, pnode = q.popleft()
        if visited[node]:
            continue
        visited[node] = True
        prev[node] = pnode
        for nxt in adj[node]:
            if not visited[nxt]:
                q.append((l + 1, nxt, node))
    print("Yes")
    for i in range(1, N):
        print(prev[i] + 1)


if __name__ == "__main__":
    solve()