Harryxun/stf_run huggingface dataset:
import sys
import numpy as np

from numba import njit, int64


@njit(int64(int64, int64[:]), cache=True)
def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = np.zeros(nsq, dtype=np.int64)
    is_seated = np.zeros(nsq, dtype=np.int8)
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = np.array([-n2, -1, 1, n2], dtype=np.int64)

    ans = 0

    for p in ppp:
        i, j = divmod(p - 1, n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        deque = [(0, 0)] * nsq
        deque[0] = (res, i)
        l, r = 0, 1

        while l != r:
            val, j = deque[l]
            # print(val, j, deque[l:r] if l >= 0 else deque[l:] + deque[:r])
            l += 1
            seats[j] = val

            if is_seated[j]:
                val += 1
                for dj in MOVES:
                    nj = j + dj
                    if seats[nj] > val:
                        deque[r] = (val, nj)
                        r = (r + 1) % nsq
            else:
                for dj in MOVES:
                    nj = j + dj
                    if seats[nj] > val:
                        l = (l - 1) % nsq
                        deque[l] = (val, nj)

    return ans


n = int(sys.stdin.buffer.readline())
ppp = np.array(list(map(int, sys.stdin.buffer.read().split())), dtype=np.int64)
print(solve(n, ppp))

# solve.inspect_types()
# bfs.inspect_types()


### FIXED CODE ###

import sys
import numpy as np

from numba import njit


@njit('i4(i4,i4[:])', cache=True)
def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = np.zeros(nsq, dtype=np.int16)
    is_seated = np.zeros(nsq, dtype=np.int8)
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = np.array([-n2, -1, 1, n2], dtype=np.int32)

    ans = 0

    for pi in range(n * n):
        i, j = divmod(ppp[pi], n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        q = []
        for mi in range(4):
            ni = i + MOVES[mi]
            if seats[ni] > res:
                seats[ni] = res
                q.append(ni)

        while q:
            j = q.pop()
            # print(val, j, seats[j], l, r)
            val = seats[j]

            if is_seated[j]:
                val += 1
            for mi in range(4):
                nj = j + MOVES[mi]
                if seats[nj] > val:
                    seats[nj] = val
                    q.append(nj)

        # print(ppp[pi] + 1, i, ans)
        # print(seats.reshape((n2, n2)))
        # print(is_seated.reshape((n2, n2)))

    return ans


n = int(sys.stdin.buffer.readline())
ppp = np.array(list(map(int, sys.stdin.buffer.read().split())), dtype=np.int32) - 1

# n = 20
# np.random.seed(seed=32)
# ppp = np.random.permutation(n * n).astype(np.int32)
# print(ppp)

print(solve(n, ppp))
print("NO" if int(input())[::2]%4 else "YES")

### FIXED CODE ###

print("NO" if int(input()[::2])%4 else "YES")
inpt = map(int, raw_input().split())
n = inpt[0]
m = inpt[1]

ans = long(0)

if abs(n-m) < 2:
	ans = fct(n)*fct(m)
	if n == m:
		ans = 2 * ans

print ans % 1000000007L

### FIXED CODE ###

def fct(x):
	t = 1L
	for i in range(1, x+1):
		t = (t * long(i)) % 1000000007L
	return t

inpt = map(int, raw_input().split())
n = inpt[0]
m = inpt[1]

ans = 0L

if abs(n-m) < 2:
	ans = (fct(n)*fct(m)) % 1000000007L
	if n == m:
		ans = (2L * ans) % 1000000007L

print ans
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for j in range(1,M,int(M/100)):
    for i in range(0,M):
      if p[i][0]==j or p[i][1]==j:
        count+=1
    if count%2==1:
      print("NO")
      sys.exit()
  else: 
    print("YES")

### FIXED CODE ###

import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
for i in range(0,N):
  p.append(0)
for i in range(0,M):
  count=list(map(int, input().split()))
  p[count[0]-1]+=1
  p[count[1]-1]+=1
for i in range(0,M):
  if p[i]%2==1:
    print("NO")
    sys.exit()
print("YES")
def run(N):
    ret = []
    if N < 3:
        ret.append('No')
    else:
        for i in range(3, N+1):
            if N * 2 < i * (i-1):
                ret.append('No')
            elif N * 2 == i * (i-1):
                ret.append('Yes')
                ret.append(i)
                S = []
                for j in range(1, i+1):
                    '''
                    j列の1行目は、1列目のj行目
                    j列の2行目は、2列目のj行目
                    j列のk行目は、k列目のj行目
                    j列のj行目以降は、j-1列目の最後の行の数+1から1ずつ増加
                    '''
                    tmp = [i-1]
                    for k in range(1, i):
                        if k < j:
                            tmp.append(S[k-1][j-1])
                        else:
                            if j < 2:
                                tmp.append(k-j+1)
                            else:
                                tmp.append(S[j-2][i-1]+k-j+1)
                    S.append(tmp)
                ret.append(S)
    return ret


def main():
    N = int(input())
    ret = run(N)
    print(ret)
    print(ret[0])
    if len(ret) > 1:
        k = ret[1]
        print(k)
        for s in ret[2]:
            s = [str(si) for si in s]
            print(' '.join(s))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def run(N):
    ret = []
    if N == 1:
        ret.append('Yes')
        ret.append(2)
        ret.append([[1, 1], [1, 1]])
    elif N < 3:
        ret.append('No')
    else:
        for i in range(3, N+1):
            if N * 2 < i * (i-1):
                ret.append('No')
                break
            elif N * 2 == i * (i-1):
                ret.append('Yes')
                ret.append(i)
                S = []
                for j in range(1, i+1):
                    '''
                    j列の1行目は、1列目のj行目
                    j列の2行目は、2列目のj行目
                    j列のk行目は、k列目のj行目
                    j列のj行目以降は、j-1列目の最後の行の数+1から1ずつ増加
                    '''
                    tmp = [i-1]
                    for k in range(1, i):
                        if k < j:
                            tmp.append(S[k-1][j-1])
                        else:
                            if j < 2:
                                tmp.append(k-j+1)
                            else:
                                tmp.append(S[j-2][i-1]+k-j+1)
                    S.append(tmp)
                ret.append(S)
    return ret


def main():
    N = int(input())
    ret = run(N)
    print(ret[0])
    if len(ret) > 1:
        k = ret[1]
        print(k)
        for s in ret[2]:
            s = [str(si) for si in s]
            print(' '.join(s))


if __name__ == '__main__':
    main()
from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(n):
    if memo[n] >= 0:
        rst = memo[n]
    else:
        tmp = n
        one = 0
        while tmp > 0:
            one += tmp & 1
            tmp >>= 1
        m = n % one
        rst = 1 if m == 0 else 1 + dfs(m)
        memo[n] = rst
    return rst


N = int(input())
# X = input()
X = list(map(int, list(input())))
one = Counter(X)[1]

Sm = 0
mm = one - 1
Sp = 0
mp = one + 1
tp = 1
tm = 1
for i in range(N - 1, -1, -1):
    tm %= mm
    tp %= mp
    if X[i] == 1:
        Sp += tp
        Sm += tm
        Sm %= mm
        Sp %= mp
    tm *= 2
    tp *= 2


memo = [-1] * (2 * (10 ** 5) + 1)
memo[0] = 0

# x = int(X, 2)
# for i in range(N):
#     ans = dfs(x ^ (1 << ((N - 1) - i)))
#     print(ans)
for i in range(N):
    if X[i] == 0:
        m = (Sp + pow(2, N - 1 - i, mp)) % mp
    else:
        m = (Sm - pow(2, N - 1 - i, mm)) % mm
    
    if m == 0:
        print(1)
    else:
        print(1 + dfs(m))


### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(n):
    if memo[n] >= 0:
        rst = memo[n]
    else:
        tmp = n
        one = 0
        while tmp > 0:
            one += tmp & 1
            tmp >>= 1
        m = n % one
        rst = 1 if m == 0 else 1 + dfs(m)
        memo[n] = rst
    return rst


N = int(input())
# X = input()
X = list(map(int, list(input())))
one = Counter(X)[1]


if one > 1:
    Sm = 0
    mm = one - 1
    tm = 1
    for i in range(N - 1, -1, -1):
        tm %= mm
        if X[i] == 1:
            Sm += tm
            Sm %= mm
        tm *= 2

Sp = 0
mp = one + 1
tp = 1
for i in range(N - 1, -1, -1):
    tp %= mp
    if X[i] == 1:
        Sp += tp
        Sp %= mp
    tp *= 2


memo = [-1] * (2 * (10 ** 5) + 10)
memo[0] = 0

# x = int(X, 2)
# for i in range(N):
#     ans = dfs(x ^ (1 << ((N - 1) - i)))
#     print(ans)
for i in range(N):
    if one == 1:
        if X[i] == 0:
            m = (Sp + pow(2, N - 1 - i, mp)) % mp
            if m == 0:
                print(1)
            else:
                print(1 + dfs(m))
        else:
            print(0)
        continue

    if X[i] == 0:
        m = (Sp + pow(2, N - 1 - i, mp)) % mp
    else:
        m = (Sm - pow(2, N - 1 - i, mm)) % mm
    
    if m == 0:
        print(1)
    else:
        print(1 + dfs(m))
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=n-1
res=1
z=10**18
for i in a:
    if(i==0):
        res=0
        break
while(i>=0):
    if(res>z/a[i]):
        res=z+1
        break
    res*=a[i]
    if(a[i]>z):
        break
    i-=1
if(res>z):
    res=-1
print(res)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
res=1
z=10**18
for i in a:
    if(i==0):
        res=0
        break
i=n-1
while(i>=0):
    if(a[i]==0):
        res=0
        break
    if(res>z/a[i]):
        res=z+1
        break
    res*=a[i]
    if(a[i]>z):
        break
    i-=1
if(res>z):
    res=-1
print(res)
import bisect

A, B, Q = [int(i) for i in input().split()]

s = [-10**12] + [int(input()) for i in range(A)] + [10**12]
t = [-10**12] + [int(input()) for i in range(B)] + [10**12]
x = [int(input()) for i in range(Q)]

for item in x:
    b, d = bisect.bisect_left(s, item), bisect.bisect_left(t, item)
    min_value = 10**12
    for item_a in [s[a], s[a+1]]:
        for item_c in [t[c], t[c+1]]:
            pata = abs(item_a - item) + abs(item_a - item_c)
            patb = abs(item_c - item) + abs(item_a - item_c)
            min_value = min(min_value, pata, patb)
    print(min_value)


### FIXED CODE ###

import bisect

A, B, Q = [int(i) for i in input().split()]

s = [-10**12] + [int(input()) for i in range(A)] + [10**12]
t = [-10**12] + [int(input()) for i in range(B)] + [10**12]
x = [int(input()) for i in range(Q)]

for item in x:
    a, c = bisect.bisect_left(s, item), bisect.bisect_left(t, item)
    min_value = 10**12
    for item_a in [s[a-1], s[a]]:
        for item_c in [t[c-1], t[c]]:
            pata = abs(item_a - item) + abs(item_a - item_c)
            patb = abs(item_c - item) + abs(item_a - item_c)
            min_value = min(min_value, pata, patb)
    print(min_value)
def main():
  N = int(input())
  S = input()
  R = 0
  G = 0
  B = 0
  nsum = 0
  for s in S:
      if s == "R":
          R += 1
      elif s == "G":
          G += 1
      else:
          B += 1
  count = 0
  for i in range(N):
      for k in range(i+1,N):
          if not S[i] == S[k]:
              if 2*k - i <= N - 1:
                  if S[i] != S[2*k - i] and S[k] != S[2*k - i]:
                      count += 1
  print(R*G*B - count)

if __name__ == '__main__':
    main()

### FIXED CODE ###

N = input()
if N[0] == "7" or N[1] == "7" or N[2] == "7":
    print("Yes")
else:
    print("No")
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    Z=10**18
    flag=True
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        if flag:
          H=abs(x-cx)+abs(y-cy)+h
        else:
          if H!=abs(x-cx)+abs(y-cy)+h:
            H=10**18+1
            break
      else:
        Z=min(Z,abs(x-cx)+abs(y-cy))
    if H<=Z:
      print(cx,cy,H[0])
      exit()

### FIXED CODE ###

import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    H=[]
    Z=[]
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        H.append(abs(x-cx)+abs(y-cy)+h)
      else:
        Z.append(abs(x-cx)+abs(y-cy))
    if len(Z)==0:
      Z.append(10**18)
    if H.count(H[0])==len(H) and min(Z)>=H[0]:
      print(cx,cy,H[0])
      exit()
m=5**6
exec(f'i,j=m%128,m>>7;m-=i**5-j**5!={input()}or print(i,j);'*2*m)

### FIXED CODE ###

x,r=int(input()),range(-99,120);[i**5-x-j**5or exit(print(i,j))for i in r for j in r]
N, K = map(int, input().split())
S = input()
intS = int(S)

calc_list = [1 if S[0] == '0' else 0]
for i in range(1, len(S)):
    if S[i] == '0':
        if S[i-1] == '1':
            calc_list.append(1)
        elif S[i-1] == '0':
            calc_list.append(calc_list[i-1] + 1)
    else:
        calc_list.append(0)

print(calc_list)

def zeros(calc_list):
    zero_list = [1 if calc_list[0] == 0 else 0]
    for i in range(1, len(calc_list)):
        if calc_list[i] == 0:
            zero_list.append(zero_list[i-1] + 1)
        else:
            zero_list.append(0)

    return zero_list


max_times = max(calc_list)
for _ in range(K):
    for i in range(len(calc_list)):
        if calc_list.count(max_times) == 1:
            if calc_list[i] == max_times:
                for j in range(max_times):
                    calc_list[i-j] = 0
                break
        else:
            zero_list = zeros(calc_list))
            index = zero_list.index(max(zero_list))

    print('calc', calc_list)
    print('zeros', zeros(calc_list))
    max_times = max(calc_list)


### FIXED CODE ###

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

# 累積和で実装

now = 1
cnt = 0
nums = []
for i in range(N):
    if int(S[i]) == now:
        cnt += 1
    else:
        nums.append(cnt)
        cnt = 1
        now = 1 - now
nums.append(cnt)
if int(S[-1]) == 0:
    nums.append(0)

# print(nums)

cumulative_sum = []
M = len(nums)
sum = 0
for i in range(M):
    sum += nums[i]
    cumulative_sum.append(sum)

# print(cumulative_sum)

ans = 0
start = 0
final = 2 * K
answers = []

# M = len(nums) = len(cumulative_sum)
if M < 2 * K + 1:
    print(len(S))
    exit()
if final <= M-1:
    while(final <= M-1):
        if start == 0:
            answers.append(cumulative_sum[final])
        else:
            ans = cumulative_sum[final] - cumulative_sum[start-1]
            answers.append(ans)

        # print(start, final, ans)
        start += 2
        final += 2
    print(max(answers))
else:
    print(cumulative_sum[0])

# print(answers)
N, Q = map(int, input().split())		# 5 7
S = "_" + input()

#print(N,Q,S)

a=[0]*N

for i in range(1,N+1):
	s = S[i:i+2]
	a[i] = a[i-1] + (1 if s=="AC" else 0)


for q in range(1,Q+1):
	l, r = map(int, input().split())		# 5 7
	print(a[r]-a[l])
	

### FIXED CODE ###

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

C=[0]*(N)
c=0
for i in range(len(S)-1):
  if S[i:i+2]=="AC": c += 1
  C[i] = c

#print(C)

for q in range(Q):
  l, r = map(int, input().split())
  l, r = l-1, r-1

  ans = C[r-1] - C[l-1]
  print(ans)
def topologicalSortBfs(n):
    for i in range(n):
        color[i] = WHITE

    for i in range(0, n):
        if indeg[i] == 0 and color[i] == WHITE:
            bfs(i)


def bfs(s):
    Q.appendleft(s)
    color[s] = GRAY
    while Q:
        u = Q.popleft()

        out.append(u)

        for v in G[u]:
            indeg[v] -= 1
            if indeg[v] == 0 and color[v] == WHITE:
                color[v] = GRAY
                Q.append(v)


def topologicalSortDfs(n):
    for i in range(n):
        color[i] = WHITE

    for s in range(0, n):
        if color[s] == WHITE:
            dfs(s)


def dfs(u):
    color[u] = GRAY
    for v in G[u]:
        if color[v] == WHITE:
            dfs(v)
    out.appendleft(u)


n, e = map(int, input().split())
G = {}
for i in range(n):
    G[i] = []
indeg = [0] * n
for i in range(e):
    s, t = map(int, input().split())
    indeg[t] += 1
    G[s].append(t)
color = [None] * n
out = deque([])
WHITE = 0
GRAY = 1
Q = deque([])

topologicalSortDfs(n)
print(*out)


### FIXED CODE ###

from collections import deque


# 幅優先と深さ優先でトポロジカルソート


def topologicalSortBfs(n):
    for i in range(n):
        color[i] = WHITE

    for i in range(0, n):
        if indeg[i] == 0 and color[i] == WHITE:
            bfs(i)


def bfs(s):
    Q.appendleft(s)
    color[s] = GRAY
    while Q:
        u = Q.popleft()

        out.append(u)

        for v in G[u]:
            indeg[v] -= 1
            if indeg[v] == 0 and color[v] == WHITE:
                color[v] = GRAY
                Q.append(v)


def topologicalSortDfs(n):
    for i in range(n):
        color[i] = WHITE

    for s in range(0, n):
        if color[s] == WHITE:
            dfs(s)


def dfs(u):
    color[u] = GRAY
    for v in G[u]:
        if color[v] == WHITE:
            dfs(v)
    out.appendleft(u)


n, e = map(int, input().split())
G = {}
for i in range(n):
    G[i] = []
indeg = [0] * n
for i in range(e):
    s, t = map(int, input().split())
    indeg[t] += 1
    G[s].append(t)
color = [None] * n
out = deque([])
WHITE = 0
GRAY = 1
Q = deque([])

topologicalSortDfs(n)
print(*out)
# 031452
# dfsがおかしい
import fractions
a,b=map(int,input().split())
g=fractions.gcd(a,b)

def make_eratosthenes(n):
    A=[0]*n
    A[0],A[1]=-1,-1 #0と1は対象外
    for i in range(2,n):
        if A[i]==0:
            j=i
            while j<n:
                A[j]=i
                j+=i
    return A

E=make_eratosthenes(g+100)
l={}
now=g
f=[] #素因数格納配列
while now>1:
    f.append(E[now])
    now//=E[now]

f=set(f)
print(len(f)+1)

### FIXED CODE ###

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

import math
def findFactors(n):
    now=n
    f=[]
    while now%2==0:
        now//=2
        f.append(2)
    p=3
    while p<=math.sqrt(n):
        while now%p==0:
            now//=p
            f.append(p)
        p+=2
        if now==1:
            break
    if now>math.sqrt(n):
        f.append(now)
    return f

if g==1:
    print(1)
else:
    f=set(findFactors(g))
    print(len(f)+1)
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10050:
				ans[v]+=1
                
for i in range(n):
	print(ans[i+1])

### FIXED CODE ###

l, r, d = map(int, input().split())
print(r//d - (l-1)//d)
N = int(input())
arr = map(input().split(' '))
ans = []
for i, num in enumerate(arr)
	if num != 0:
    	ans.append(i+1)
print(''.join(ans))

### FIXED CODE ###

def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    for i in range(n // 2, 0, -1):  # second half: no multiples
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))  # all cells: [1] -> len() (much faster than sum())
    print(*ans)


if __name__ == "__main__":
    main()
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n, q = LI()
point = [0]*n
graph = [[] for i in range(n)]

for i in range(n - 1):
    a, b = LI()
    graph[a - 1].append(b)
    graph[b - 1].append(a)


for i in range(q):
    p, x = LI()
    point[p - 1] += x

visited = [False]*n


def dfs(n):
    visited[n-1] = True
    for child in graph[n-1]:
        if visited[child-1]:
            continue
        point[child-1] += point[n-1]
        dfs(child)

dfs(1)


print(*point)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
 
N, Q = map(int, input().split())
root = [[] for _ in range(N)]
ans = [0]*N
 
for _ in range(N-1):
  a,b=map(int, input().split())
  a,b=a-1,b-1
  root[a].append(b)
  root[b].append(a)

for _ in range(Q):
  p,x=map(int, input().split())
  ans[p-1]+=x
  
visited=[False]*N
def dfs(v):
  visited[v] = True
  for go in root[v]:
    if visited[go]:
      continue
    ans[go] += ans[v]
    dfs(go)

dfs(0)
print(*ans)
n = int(input())
P = [int(input()) for a in range(n)]
sorted = sorted(P)
count = 0

for i in range(n):
  if P[i] == sorted[i]:
    count += 1

if count == n or count == n-2:
  print("YES")
else:
  print("NO")
  


### FIXED CODE ###

n = int(input())
P = list(map(int, input().split()))
sorted = sorted(P)
count = 0

for i in range(n):
  if P[i] == sorted[i]:
    count += 1

if count == n or count == n-2:
  print("YES")
else:
  print("NO")
S = input()
Weeks = ["MON","TUE","WED","THU","FRI","SAT","SUN"]
ind = Weeks.index(S)
if S != "SUN"
    print(6-ind)
else:
    print(7)

### FIXED CODE ###

S = input()
Weeks = ["MON","TUE","WED","THU","FRI","SAT","SUN"]
ind = Weeks.index(S)
if S != "SUN":
    print(6-ind)
else:
    print(7)
import sys
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
s = []
for _ in range(n):
    s.append(input())

A = []

for i, j in enumerate(s):
    min_val = 10**10
    val = 0
   
    for k in j:
        if k == "(":
            val += 1
        else:
            val -= 1
        min_val = min(min_val, val)
    A.append([min_val, i])
A.sort()
A = A[::-1]
val = 0
for i, j in A:
    for k in list(s[j]):
        if k == "(":
            val += 1
        else:
            val -= 1
            if val < 0:
                print("No")
                sys.exit()
ans = "Yes" if val == 0 else "No"
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

s = input().rstrip()
t = input().rstrip()

if s == t[:len(t) - 1]:
    print("Yes")
else:
    print("No")
n,m=map(int,input().split())
a=[]
b=[]
C=[]
s=[0 for i in range(n)]
s[0] = "Yes"
 
for i in range(m):
  c,d=map(int,input().split())
  a.append(c)
  b.append(d)
 
def Next(be):
  C.clear()
  for j in be:
    for i in range(len(a)):
      if a[i] == j:
        if s[b[i]-1]==0 and 0 == be.count(b[i]):
          C.append(b[i])
          s[b[i]-1]=j
        continue

      if b[i] == j: 
        if s[a[i]-1]==0 and 0 == be.count(a[i]):
          C.append(a[i])
          s[a[i]-1]=j
        continue
    Dele(j)
  return C

def Dele(be):
  for j in range(a.count(be)):
    a.remove(be)
  for j in range(b.count(be)):
    b.remove(be)

co=[1]
while True:
  if s.count(0) == 0:
    break
  co = Next(list(co))
 
for i in s:
  print(i)

### FIXED CODE ###

from collections import deque

N, M=map(int,input().split())
a=[]
b=[]
for i in range(M):
  A,B=map(int,input().split())
  a.append(A)
  b.append(B)

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

    # bfs
queue = deque([1])
signposts = [0] * (N + 1)
signposts[1] = 1
while queue:#キューが空になるまで
  u = queue.popleft()
  for v in graph[u]:
    if not signposts[v]:
      signposts[v] = u
      queue.append(v)
 
if all(signposts[2:]):
  print("Yes")
  print("\n".join(map(str, signposts[2:])))
else:
  print("No")