Harryxun/stf_run huggingface dataset:
def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    right,left = 0,1
    cnt = 0
    flg = 0
    while 1:
        now = ls[left]
        nex = ls[right]   
        if now<nex:
            if flg ==-1:
                cnt +=1
                flg = 0
            else:
                flg = 1
            left +=1
            right +=1
        elif nex==now:
            left +=1
            right +=1         

        else:
            if flg ==1:
                cnt += 1
                flg = 0
            else:
                flg = -1
            left +=1
            right +=1
        if right==n-1:
            cnt +=1
            break
    print(cnt)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    if n==1:
        print(1)
    else:
        right,left = 0,1
        cnt = 0
        flg = 0
        while 1:
            now = ls[left]
            nex = ls[right]   
            if now<nex:
                if flg ==-1:
                    cnt +=1
                    flg = 0
                else:
                    flg = 1
                left +=1
                right +=1
            elif nex==now:
                left +=1
                right +=1         

            else:
                if flg ==1:
                    cnt += 1
                    flg = 0
                else:
                    flg = -1
                left +=1
                right +=1

            if right==n-1:
                cnt +=1
                break
        print(cnt)

if __name__ == '__main__':
    main()
n = int(input())
if n == 1:
    print("Hello World")
else:
    a,b = map(int,input().split())
    print(a+b)

### FIXED CODE ###

from sys import stdin
import bisect

n = int(stdin.readline().rstrip())

if n == 1:
    print("Hello World")
    exit()

li = [int(stdin.readline().rstrip()) for _ in range(n)]

print(sum(li))
N = int(input())
 
x = N // 1.08
 
if x*1.08 < N or x*1.08 > N+1:
  print(":(")
else:
  for y in range(x-1, x+1):
    if N+!> y*1.08 > N:
      print(y)
      break
    else:
      print(":(")

### FIXED CODE ###

N = int(input())
 
ans = ":("
 
for X in range(N+1):
  if int(X * 1.08) == N:
    ans = X
    break
    
print(ans)
N=int(input())
r=[0]
inp=input().split()
for k in range(N):
  r.append(int(inp[k]))
def rec(x,y,i,N):
    if len(x)==1:
        for k in range(len(y)):
            print(y[k])
        return(y)
    if i==N+1:
        if len(y)==0:
            print(-1)
            return -1
        else:
            m=y[0]
            del y[0]
            x.insert(m,m)
            rec(x,y,m+1,N)     
    if x[i]==i:
        x.pop(i)
        y.insert(0,i)
        rec(x,y,1,N)
        
    else:
        if x[i] < i:
            rec(x,y,i+1,N)
        else:
            if len(y)>0:
                m=y[0]
                del y[0]
                x.insert(m,m)
                rec(x,y,m+1,N)  
            else:
                print(-1)
                return -1
                
                
            
        
    
rec(r,[],1,N)      
  

### FIXED CODE ###

N=int(input())
x=[0]
inp=input().split()
for k in range(N):
  x.append(int(inp[k]))
y=[]
OK=True
for k in range(N):
  ok=False
  for i in range(len(x)-1,0,-1):
    if x[i]==i:
      y.insert(0,i)
      del x[i]
      ok=True
      break
  if ok==False:
    print(-1)
    OK=False
    break
if OK==True:
  for k in range(len(y)):
    print(y[k])
X=int(input())

if X==X.lower():
    print("a")
else:
    print("A")




### FIXED CODE ###

X=input()
if X==X.lower():
    print("a")
else:
    print("A")
n,a,b = map(int,input().split())
c = n//(a+b)
d = (n%(a+b))
if a ==0:
    print(0)
elif n%(a+b)==0:
    print(c*a)
elif n%(a+b)!== 0 and d <=a :
    print((c*a)+d)
else:
    print((c*a)+a)


### FIXED CODE ###

n,a,b = map(int,input().split())
c = n//(a+b)
d = (n%(a+b))
if a ==0:
    print(0)
elif n%(a+b)==0:
    print(c*a)
elif n%(a+b)!= 0 and d <=a :
    print((c*a)+d)
else:
    print((c*a)+a)
n,m=map(int,input().splt())
ans=((n*(n-1))/2)+(m*(m-1))/2
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
ans=((n*(n-1))/2)+(m*(m-1))/2
print(int(ans))
a,b=list(map(int,input().split())
if a<b:
	print('a < b')
elsif a==b:
	print('a > b')
else:
	print('a == b')

### FIXED CODE ###

a,b=list(map(int,input().split()))
if a<b:
	print('a < b')
elif a==b:
	print('a == b')
else:
	print('a > b')
n=int(input())
a=list(map(int,input().split()))
for i in range(m):
  if a[i]%2==0:
    if a[i]%3!=0 and a[i]%5!=0:
      print('DENIED')
      exit()
print('APPROVED')

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if a[i]%2==0:
        if a[i]%3!=0 and a[i]%5!=0:
            print('DENIED')
            exit()
print('APPROVED')
N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(i+1,N):
        a=x[i]-x[j]
        b=y[i]-y[j]
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        l1.append(str(a)+str(b))
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common())    
print(N-max(c))



### FIXED CODE ###

N=int(input())

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

x=[]
y=[]

for X,Y in XY:
    x.append(X)
    y.append(Y)
    
l1=[]
c=0
for i in range(N):
    for j in range(N):
        if i==j:
            continue;
        a=x[i]-x[j]
        b=y[i]-y[j]
        """
        if a<=0 and b>=0:
            a=-a
            b=-b
        elif a<=0 and b<=0:
            a=-a
            b=-b
        """
        l1.append(str(a)+"_"+str(b))
        #l1.append([a,b])
v=set(l1)
c=[]
for i in v:
    c.append(l1.count(i))
#c = collections.Counter(l1)      
#values, counts = zip(*c.most_common()) 
if c==[]:
    print(1)   
else:
    print(N-max(c))
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""

def naive_simulation(N, A_list):
    next_A_list = [0 for i in range(N)]
    for i in range(N):
        d = A_list[i]
        for j in range(i-d, i+d+1):
            if j >= 0 and j <= N-1:
                next_A_list[j] += 1
    A_list = next_A_list[:]
    return A_list

def imos_simulation(N, A_list):
        imos_list = [0 for i in range(N)]
        for i in range(N):
            d = A_list[i]
            imos_list[max(i-d, 0)] += 1
            if i+d+1 <= N-1:
                imos_list[i+d+1] -= 1
        for i in range(1, N):
            imos_list[i] += imos_list[i-1]
        A_list = imos_list[:]
    return A_list

def whole_simulation(N, K, A_list):
    for k in range(min(K, 42)):
        #A_list = naive_simulation(N, A_list)
        A_list = imos_simulation(N, A_list)
        #print(" ".join([ str(i).zfill(2) for i in A_list]))
    return A_list

def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    print(" ".join([ str(i) for i in simulation(N, K, A_list)]))

if __name__ == "__main__":
    main()



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""

def simulation(N, K, A_list):
    for k in range(min(K, 42)):
        #next_A_list = [0 for i in range(N)]
        imos_list = [0 for i in range(N)]
        for i in range(N):
            d = A_list[i]
            imos_list[max(i-d, 0)] += 1
            if i+d+1 <= N-1:
                imos_list[i+d+1] -= 1
            #for j in range(i-d, i+d+1):
            #    if j >= 0 and j <= N-1:
            #        next_A_list[j] += 1
        for i in range(1, N):
            imos_list[i] += imos_list[i-1]
        A_list = imos_list[:]
        #print(" ".join([ str(i).zfill(2) for i in A_list]))
    return A_list

def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    print(" ".join([ str(i) for i in simulation(N, K, A_list)]))

if __name__ == "__main__":
    main()
from fractions import gcd
from functools import reduce
import math
import sys
sys.setrecursionlimit(2000000)
n = input()
a = list(map(int, input().split()))
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
b = lcm_list(a)-1
f = 0
for i in a:
    f += b % i

print(f)


### FIXED CODE ###

from fractions import gcd
from functools import reduce
#from collections import deque
# from math import factorial
# import collections
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
n = input()
#n, m = list(map(int, input().split()))
a = list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


b = lcm_list(a)-1
f = 0
for i in a:
    f += b % i

print(f)
N, M = map(int, input().split())
am = [int(input()) for i in range(M)]
dp = [0]*(N+1)
if not 1 in am:
	dp[1]=1
if not 2 in am:
	dp[2]=1
for i in range(1,N):
    if not (i+1) in am:
        dp[i+1] += dp[i]
    if not (i+2) in am:
        if i+2<=N:
            dp[i+2] += dp[i]
print(dp[N]%(10**9+7))

### FIXED CODE ###

N, M = map(int, input().split())
am = [int(input()) for i in range(M)]
safe = [True]*(N+1)
for i in am:
    safe[i] = False
dp = [0]*(N+1)
dp[0]=1
for i in range(N):
    if safe[i+1]:
        dp[i+1] += dp[i]
    if i+2<=N:
        if safe[i+2]:
            dp[i+2] += dp[i]
print(dp[N]%(10**9+7))
N=int(input())
n=list(str(N))
n=[int(n) for i in n]
summer=sum(n)
if N%summer==0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N=input()
wa=0
for i in N:
  wa+=int(i)
if (int(N)%wa)==0:
  print("Yes")
else:
  print("No")
N = int(input())
 
ans = -1
for i in range(N):
	if math.floor(float(i)*1.08) == N:
    	ans = i
      
if ans == -1:
  print(':(')
  
else:
  print(ans)

### FIXED CODE ###

import math

N = int(input())
ans = -1
for i in range(N+1):
	if math.floor(i*1.08) == N:
		ans = i
if ans == -1:
	print(':(')
else:
	print(ans)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

INF = 10**12
N, M, L = map(int, readline().split())

ABCQST = np.array(read().split(), dtype=np.int64)
ABC = ABCQST[:3*M]
A = ABC[::3]; B = ABC[1::3]; C = ABC[2::3]

Q = ABCQST[3*M]

ST = ABCST[3*M + 1:]
S = ST[::2]; T = ST[1::2]

graph = csr_matrix((C, (A, B)), (N, N))
d = floyd_warshall(graph, directed=False)

d[d <= L] = 1
d[d > L] = INF

d = floyd_warshall(d, directed=False).astype(int)
d[d == INF] = 0

d -= 1
print('\n'.join(d.astype(str)[S, T]))


### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
INF = 10**12
N, M, L = map(int, input().split())

A = []; B = []; C = []
for i in range(M):
    a, b, c = map(int, input().split())
    A.append(a - 1); B.append(b - 1); C.append(c)
A = np.array(A); B = np.array(B); C = np.array(C)

graph = csr_matrix((C, (A, B)), (N, N))
d = floyd_warshall(graph, directed=False)

d[d <= L] = 1
d[d > L] = INF

d = floyd_warshall(d, directed=False)

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    if d[s - 1][t - 1] != INF:
        print(int(d[s - 1][t - 1]) - 1)
    else:
        print(- 1)
num=input().split()
a=int(num[0])
b=int(num[1])
if a!=0&&b!=0:
  print(max([a+b,a-b,a*b]))
else:
  print(max([a+b,a-b,a*b,a/b]))

### FIXED CODE ###

num=input().split()
a=int(num[0])
b=int(num[1])
print(max([a+b,a-b,a*b]))
a,b,c = map(int, input().split())

if a<c<b or b<c<a:
 print('Yes)
else:
 print('No)


### FIXED CODE ###

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

if a<c<b or b<c<a:
  print('Yes')
else:
  print('No')
import heapq
N = int(input())
A = list(map(int,input().split()))
B1 = []
for i in range(N):
    heapq.heappush(B1,(A[i],i))
C = []
for i in range(N,3*N):
    heapq.heappush(C,(A[i],i))
B2 = []
for _ in range(N):
    a,i = heapq.heappop(C)
    B2.append((-a,i))
dmax = 0
for i in range(N):
    dmax += B1[i][0]+B2[i][0]
C = []
for i in range(N,2*N):
    heapq.heappush(C,(A[i],i))
d = dmax
for i in range(N,2*N):
    a = A[i]
    if B1[0][0]<a:
        d += a-B1[0][0]
        heapq.heappop(B1)
        heapq.heappush(B1,(a,i))
    while C[0][1]<=i:
        heapq.heappop(C)
    while B2[0][i]<=i:
        b,i = heapq.heappop(B2)
        b = -b
        d += b
        a,i = heapq.heappop(C)
        heapq.heappush(B2,(-a,i))
        d -= a
    dmax = max(dmax,d)
print(dmax)        

### FIXED CODE ###

import heapq
N = int(input())
A = list(map(int,input().split()))
B1 = []
for i in range(N):
    heapq.heappush(B1,(A[i],i))
C = []
for i in range(N,3*N):
    heapq.heappush(C,(A[i],i))
B2 = []
for _ in range(N):
    a,i = heapq.heappop(C)
    heapq.heappush(B2,(i,a))
dmax = 0
for i in range(N):
    dmax += B1[i][0]-B2[i][1]
d = dmax
for i in range(N,2*N):
    a = A[i]
    if B1[0][0]<a:
        d += a-B1[0][0]
        heapq.heappop(B1)
        heapq.heappush(B1,(a,i))
    while C and B2[0][0]<=i:
        _,b = heapq.heappop(B2)
        d += b
        a,j = heapq.heappop(C)
        heapq.heappush(B2,(j,a))
        d -= a
    dmax = max(dmax,d)
print(dmax)
A,B=map(int, input().split()) 
N=max(A,B)
M=min(A,B)
for i in range(1,M+1):
    if M%(M-i)==0 and N%(M-i)==0:
        Max=i
        break
print(N*M//Max)

### FIXED CODE ###

A,B=map(int, input().split()) 
N=max(A,B)
M=min(A,B)
for i in range(0,M):
    if M%(M-i)==0 and N%(M-i)==0:
        Max=M-i
        break
print(A*B//Max)
A = int(input())
B = int(input())
C = int(input())

if A == 5 and B == 7 and C == 5:
    print("YES")

elif A == 7 and B == 5 and C == 5:
    print("YES")

elif A == 5 and B == 5 and C == 7:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

a=input().split()
if a.count('5')==2 and a.count('7')==1:
    print('YES')
else:
    print('NO')
n = int(input())
a = [int(i) for i in input().split()] 
out = 0

out = a[0] + a[n - 2]
for i in range(n - 2):
	out += min(a[i], a[i+1])  
    
print(out)
  

### FIXED CODE ###

n, k, q = map(int, input().split())
scores = [0] * n
out = []

for i in range(q):
  x = int(input())
  scores[x-1] += 1
  
for x in scores:
  out = 'Yes' if q - x < k else 'No'
  print(out)
N,K = map(int,input().split())
if(N<=K):
    print('unsafe')
else:
    print('safe'

### FIXED CODE ###

N,K = map(int,input().split())
if(N<=K):
    print('unsafe')
else:
    print('safe')
n = int(input())

s = [input() for i in range(n)]

def shiritori(s):
  if len(s) != len(set(s)):
    return "No"
  
  for i in range(n-1):
    if s[i][-1] != s[i+1][0]:
      return "No"
  
  return "Yes"

shiritori()

### FIXED CODE ###

n = int(input())

s = [input() for i in range(n)]

def shiritori(s):
  if len(s) != len(set(s)):
    return False
  
  for i in range(n-1):
    if s[i][-1] != s[i+1][0]:
      return False
  
  return True

if __name__ == '__main__':
  if shiritori(s):
    print("Yes")
  else:
    print("No")
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
cnt = 0
cost = 0
for i, x in enumerate(a):
    cost += x
    if cost > k:
        cnt = i
        cost -= x
        break
else:
    for j, y in enumerate(b):
        cost += y
        if cost > k:
            cnt = n + j
            cost -= y
            break
    else:
        ans = n + m

if cnt <= n:
    i, j = cnt - 1, 0
else:
    i, j = n - 1, cnt - n + 1

while True:
    if cost == 0: break
    cost += - a[i] + b[j]
    i, j = i - 1, j + 1
    while cost + b[j] <= k:
        j += 1
        cnt += 1
    if cost > k: break
if ans != 0:
    print(ans)
else:
    print(cnt)

### FIXED CODE ###

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

cnt = 0
cost = 0
for i, x in enumerate(a):
    cost += x
    if cost > k:
        cnt = i
        cost -= x
        break
else:
    for j, y in enumerate(b):
        cost += y
        if cost > k:
            cnt = n + j
            cost -= y
            break
    else:
        cnt = n + m

if cnt <= n:
    i_max, j = cnt - 1, 0
else:
    i_max, j = n - 1, cnt - n

while j < m and cost + b[j] <= k:
    cost += b[j]
    j += 1
    cnt += 1

ans = cnt
for i in range(i_max, -1, -1):
    if j == m: break
    cost -= a[i]
    cnt -= 1
    while j < m and cost + b[j] <= k:
        cost += b[j]
        j += 1
        cnt += 1

    ans = max(cnt, ans)

print(ans)
from collections import defaultdict
 
n = int(input())
raw_numbers = list(map(int, input().split()))
Q = int(input())
 
total = sum(raw_numbers)
 
numbers = defaultdict(int)
 
for num in raw_numbers:
    numbers[num] += 1
 
for i in range(q):
    b, c = map(int, input().split())
    taken = numbers[b]
    total -= numbers[b]*b
    numbers[c] += numbers[b]
    numbers[b] = 0
    total += taken*c
    print(total)

### FIXED CODE ###

class Counter(dict):
    def __missing__(self, i):
        return 0

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

total = sum(a)

bucket = Counter()

for item in a:
    bucket[item] += 1

for i in range(q):
    b, c = map(int, input().split())
    taken = bucket[b]
    total -= bucket[b]*b
    bucket[c] += bucket[b]
    bucket[b] = 0
    total += taken*c
    print(total)
n = int(input())
k = [[[0 for x in range(10)] for x in range(3)] for x in range(4)]
for i in range(n):
    b,f,r,v = map(int(raw_input().split())
    k[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, k[b][f])))
    if b != 3:
        print("#"*20)

### FIXED CODE ###

n = int(input())
k = [[[0 for x in range(10)] for x in range(3)] for x in range(4)]
for i in range(n):
    b,f,r,v = map(int,raw_input().split())
    k[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, k[b][f])))
    if b != 3:
        print("#"*20)
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
 
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
    elif total < 50 and r < 50:
        print('D')
    elif total < 65:
        print('C')
    elif total < 80:
        print('B')
    else:
        print('A')
~                 

### FIXED CODE ###

while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
 
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
    elif total < 50 and r < 50:
        print('D')
    elif total < 65:
        print('C')
    elif total < 80:
        print('B')
    else:
        print('A')
import numpy as np


def is_prime(n):
    return n != 1 and not np.any(n % np.arange(2, n) == 0)


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

N = np.arange(1, min(A, B) + 1)

cd = np.argwhere((A % N == 0) & (B % N == 0)).ravel() + 1
primes = [n for n in cd if is_prime(n)]

print(len(primes) + 1)


### FIXED CODE ###

from fractions import gcd


def prime_factors(n):
    i = 2

    factors = []

    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)

    return factors


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

print(len(set(prime_factors(gcd(A, B)))) + 1)
n=int(input())
from collections import Counter
v=list(map(int,input().split()))
from collections import Counter
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(b[0][1]+a[1][1],n-(a[0][1]+b[1][1])))

### FIXED CODE ###

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

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
    print(n - (a[0][1] + b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]), n-(a[0][1]+b[1][1])))
H, W = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
Diff = [[0] * (W + 1) for _ in range(H + 1)]
M = 0
for i in range(H):
    for j in range(W):
        m = abs(A[i][j] - B[i][j])
        Diff[i][j] = m
        M = max(M, m)

M = M * H * W

dp = [[[0] * (M + 1) for _ in range(W + 1)] for _ in range(H + 1)]
dp[0][0][Diff[0][0]] = 1

for i in range(0, H):
    for j in range(0, W):
        for k in range(M + 1):
            if dp[i][j][k]:
                dp[i + 1][j][k + Diff[i + 1][j]] = 1
                dp[i + 1][j][abs(k - Diff[i + 1][j])] = 1
                dp[i][j + 1][k + Diff[i][j + 1]] = 1
                dp[i][j + 1][abs(k - Diff[i][j + 1])] = 1

for k in range(M + 1):
    if dp[H - 1][W - 1][k] == 1:
        ans = k
        break

print(ans)


### FIXED CODE ###

H, W = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
Diff = [[0] * (W + 1) for _ in range(H + 1)]
M = 0
for i in range(H):
    for j in range(W):
        m = abs(A[i][j] - B[i][j])
        Diff[i][j] = m
        M += m

dp = [[0] * (W + 1) for _ in range(H + 1)]
dp[0][0] |= (1 << Diff[i][j])

for i in range(0, H):
    for j in range(0, W):
        here = dp[i][j]
        s = Diff[i][j]
        ni = 0
        nj = 0
        ni |= (here << s)
        nj |= (here << s)
        ni |= (here >> s)
        nj |= (here >> s)
        ex = 0
        for k in range(1, s + 1):
            if (here >> k) & 1:
                ex |= (1 << (s - k))
        ni |= ex
        nj |= ex
        dp[i + 1][j] |= ni
        dp[i][j + 1] |= nj

a = dp[H - 1][W - 1]
ans = 0
for k in range(M + 1):
    if (a >> k) & 1:
        ans = k
        break

print(k)
l,r=list(map(int, input().split()))
c=[0]*(r-l+1)
for i in range(l,r+1):
	c[i-l]=i%2019
minc=min(c)
print(minc*(minc+1))

### FIXED CODE ###

l,r=list(map(int, input().split()))
minmod=2018
if r-l>=2018:
	print(0)
else:
	for i in range(l,r+1):
		for j in range(i+1,r+1):
			minmod=min(minmod,(i*j)%2019)
	print(minmod)
x = input()
y = input()
count = 0
for i in range(int(x), int(y)):
    if(str(i) == str(i)[::-1]):
        count += 1

print(count)

### FIXED CODE ###

x = input().split(" ")
count = 0
for i in range(int(x[0]), int(x[1])+1):
    if(str(i) == str(i)[::-1]):
        count += 1

print(count)
import fractions

N, X = int(input())
cities = list(map(int, input().split()))
gcds = 0
for city in cities:
  if gcd == 0:
    gcds = fractions.gcd(abs(city-X))
  else:
    gcds = fractions.gcd(gcds, abs(city-X))
print(gcds)

### FIXED CODE ###

import fractions

N, X = map(int, input().split())
cities = list(map(int, input().split()))
gcds = abs(cities[0]-X)
for city in cities[1:]:
  gcds = fractions.gcd(gcds, abs(city-X))
print(gcds)
from collections import deque
INF = 10000000
N, M = map(int, input().split())
# 隣接リストを作成する
dist = [INF for _ in range(M)]
pre = [-1 for _ in range(M)]
to = [[] for _ in range(100005)] 

# 隣接リスト：to[v]の中にはvに隣接している要素が入っている
for i in range(M):
    a, b = map(int, input().split())
    a = a - 1
    b = b - 1
    to[a].append(b)
    to[b].append(a)

queue = deque()
dist[0] = 0
queue.append(0)
while(len(queue) != 0):
    v = queue.popleft()
    for u in to[v]:
        # もう値が設定されていれば更新しない
        if (dist[u] != INF):
            continue
        dist[u] = dist[v] + 1
        pre[u] = v
        queue.append(u)

print("Yes")
for i in range(N):
    if (i == 0):
        continue
    ans = pre[i]
    ans += 1
    print(ans)

### FIXED CODE ###

from collections import deque
 
N,M=map(int,input().split())
 
graph=[[]for _ in range(N+1)]
 
for _ in range(M):
    A,B=map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)
 
dist=[-1]*(N+1)
dist[0]=0
dist[1]=0
 
D=deque()
D.append(1)
 
while D:
    V=D.popleft()
    for i in graph[V]:
        if dist[i]!=-1:
            continue
        dist[i]=V
        D.append(i)
 
print('Yes')
for j in dist[2:]:
    print(j)