Harryxun/stf_run huggingface dataset:
from bisect import bisect_left
X, N = map(int, input().split())
P = sorted(list(map(int, input().split())))
i = 0
if N == 0:
  print(X)
else:
  while True:
    x = X-i
    idx = bisect_left(P, x)
    if idx < 0 or idx >= N or P[idx] != x:
      print(x)
      break
    else:
      x = X+i
      idx = bisect_left(P, x)
      if idx < 0 and idx >= N or P[idx] != x:
        print(x)
        break
    i += 1



### FIXED CODE ###

from bisect import bisect_left
X, N = map(int, input().split())
P = sorted(list(map(int, input().split())))
i = 0
if N == 0:
  print(X)
else:
  while True:
    x = X-i
    idx = bisect_left(P, x)
    if idx < 0 or idx >= N or P[idx] != x:
      print(x)
      break
    else:
      x = X+i
      idx = bisect_left(P, x)
      if idx < 0 or idx >= N or P[idx] != x:
        print(x)
        break
    i += 1
N, Ma, Mb = map(int, input().split())
items = []
for i in range(N):
    a, b, c = map(int, input().split())
    items.append((a, b, c))

a_sum = sum([item[0] for item in items])
b_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [[[inf for _ in range(a_sum + 20)] for _ in range(b_sum + 20)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for a in range(a_sum + 1):
        for b in range(b_sum + 1):
            dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
            dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],
                                                              dp[i][a][b] + items[i][2])
ans = inf
for a in range(1, a_sum + 1):
    for b in range(1, b_sum + 1):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

N, Ma, Mb = map(int, input().split())
items = []
for i in range(N):
    a, b, c = map(int, input().split())
    items.append((a, b, c))

a_sum = sum([item[0] for item in items])
b_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [[[inf for _ in range(a_sum + 100)] for _ in range(b_sum + 100)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for a in range(a_sum + 1):
        for b in range(b_sum + 1):
            dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
            dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],
                                                              dp[i][a][b] + items[i][2])
ans = inf
for a in range(1, a_sum + 1):
    for b in range(1, b_sum + 1):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)
N, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

left = 0
right = A[0]

while right - left > 1:
    mid = (left + right) // 2
    jk = 0
    for i in range(N):
        jk += math.ceil( A[i] / mid)
    if jk < K:
        right = mid
    else:
        left = mid

print(right)

### FIXED CODE ###

import math

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

left = 0
right = max(A)

while right - left > 1:
    mid = (left + right) // 2
    jk = 0
    for i in range(N):
        jk += A[i] // mid - 1
        if A[i] % mid != 0: jk += 1
    if jk <= K:
        right = mid
    else:
        left = mid

print(right)
import math
a, b, x = map(int, input().split())
tmp = 0
for i in range(10, 0, -1):
  if a * (10**(i-1)) + b * i <= x:
    tmp = i
    break
if tmp >= 10:
  print(1000000000)
  exit()
if tmp == 0:
  print(0)
  exit()
ans = 0
ans = math.floor((x-b*tmp)/a)
if ans > 10**(tmp):
  ans = 10**(tmp)-1
print(ans)

### FIXED CODE ###

dic = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
print(dic[input()])
# import itertools
# import math

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

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_p[P] == 0:
        ans_p[P] += 1

for i in range(ans_p):
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0


print(str(sum(ans_s)) + " " + str(sum(ans_p)))


### FIXED CODE ###

# import itertools
# import math

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

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_s[P] == 0:
        ans_p[P] += 1

for i in range(len(ans_p)):
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0

print(str(sum(ans_s)) + " " + str(sum(ans_p)))
A = [0] * 5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
ans = 0
min1 = 10
for i in range(0,5):
    m = A[i] % 10
    if ((m > 0) and (m < min1)):
        min1 = m        
    ans += math.ceil(A[i] / 10) * 10
print(ans - (10 - min1))


### FIXED CODE ###

import math
A = [0] * 5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
ans = 0
min1 = 10
for i in range(0,5):
    m = A[i] % 10
    if ((m > 0) and (m < min1)):
        min1 = m        
    ans += math.ceil(A[i] / 10) * 10
print(ans - (10 - min1))
A, B = map(int, split())
num = B / A

if B == 0 or B == 1:
  print(int(0))
elif B % A == 0:
  print(int(num))
else:
  print(int(num + 1))

### FIXED CODE ###

A, B = map(int,input().split())
num = B / A
i = 0
if B == 1:
  print(int(0))
else:
  while True:
    if B == 1:
        print(0)
        break
    if A * i - (i - 1) >= B:
        print(i)
        break
    i += 1
A op B=map(str,input().split())
if op=="+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
  

### FIXED CODE ###

A,op,B=map(str,input().split())
if op=="+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
H,W,M = map(int, input().split())
bombmat = [[0]*(W+1) for _ in range(H+1)]
bomb_row = [0]*M; bomb_col = [0]*M
for i in range(M):
    h,w = map(lambda x: int(x)-1, input().split())
    bombmat[h][w] = 1
    bombmat[H][w] += 1
    bombmat[h][W] += 1
    
    bomb_row[i] = h
    bomb_col[i] = w

row_H = bombmat[H]
maxcol = 0
for col in range(W):
    maxcol = max(maxcol, row_H[col])

maxcollist = [False]*W
for col in range(W):
    if row_H[col] == maxcol:
        maxcollist[col] = True

maxrow = 0
for row in range(H):
    maxrow = max(maxrow, bombmat[row][W])

maxrowlist = [False]*H
for row in range(H):
    if bombmat[row][W] == maxrow:
        maxrowlist[row] = True

#最高行または最高列上にあり、
#かつ最高行と最高列の交点にない爆弾があるかをチェック
cross_cnt = sum(maxrowlist) * sum(maxcollist)
for i in range(M):
    h,w = bomb_row[i], bomb_col[i]
    if maxrowlist[h] and maxcollist[w]:
        cross_cnt -= 1

if cross_cnt > 0:
    print(maxcol + maxrow)
else:
    print(maxcol + maxrow - 1)

### FIXED CODE ###

from sys import stdin
input = stdin.readline

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

sum_row = [0]*H; sum_col = [0]*W
bomb_row = [0]*M; bomb_col = [0]*M
for i in range(M):
    h,w = map(int, input().split())
    sum_row[h-1] += 1
    sum_col[w-1] += 1
    
    bomb_row[i] = h-1
    bomb_col[i] = w-1

maxcol = max(sum_col)
maxcollist = [False]*W
for col in range(W):
    if sum_col[col] == maxcol:
        maxcollist[col] = True

maxrow = max(sum_row)
maxrowlist = [False]*H
for row in range(H):
    if sum_row[row] == maxrow:
        maxrowlist[row] = True

#最高行または最高列上にあり、
#かつ最高行と最高列の交点にない爆弾があるかをチェック
cross_cnt = sum(maxrowlist) * sum(maxcollist)
for i in range(M):
    h,w = bomb_row[i], bomb_col[i]
    if maxrowlist[h] and maxcollist[w]:
        cross_cnt -= 1

if cross_cnt > 0:
    print(maxcol + maxrow)
else:
    print(maxcol + maxrow - 1)
def main():
	n, q = map(int, input().split())
	s = input()
	acs = [0]*(n+1)
	for i in range(1, n+1):
		if s[i-1] == "A" and s[i] == "C":
			acs[i] = acs[i-1] + 1
		else:
			acs[i] = acs[i-1]
	results = [0]*q
	for i in range(q):
		l, r = map(int, input().split())
		if l == r:
			continue

		results[i] = acs[r] - acs[l]
		if s[r-1] == "A":
			results[i] -= 1
		if s[l-1] == "A" and s[l] == "C":
			results[i] += 1
	for result in results:
		print(result)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
	n, q = map(int, input().split())
	s = input()
	acs = [0]*(n)
	for i in range(1, n):
		if s[i-1] == "A" and s[i] == "C":
			acs[i] = acs[i-1] + 1
		else:
			acs[i] = acs[i-1]
	results = [0]*q
	for i in range(q):
		l, r = map(int, input().split())
		if l == r:
			continue
		results[i] = acs[r-1] - acs[l-1]
	for result in results:
		print(result)

if __name__ == '__main__':
    main()
import collections
N = int(input()) 
S = [0]*N
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
print(X)
for i in range(0,len(c.most_common())):
    if c.most_common()[i][1] == X:
        list.append(c.most_common()[i][0])
list.sort()
print(list)
for i in range(len(list)):
    print(list[i])

### FIXED CODE ###

import collections
N = int(input()) 
S = [0]*N
m = 0
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if counts[i] == X:
        list.append(values[i])
        m+=1
    else:
        break
list.sort()
for i in range(0,m):
    print(list[i])
def fizzbuzz(n):
	if n%15==0: return "FizzBuzz"
	if n%5==0: return "Buzz"
	if n%3==0: return "Fizz"
	return str(n)

while 1:
	m,n=map(int,raw_input().split())
	if m==0:break
	player=[i+1 for i in range(m)]
	for i in range(n):
		if fizzbuzz(i+1)!=raw_input():
			player.pop((i-(m-len(player)))%len(player))
			if len(player)==1:
				break
	print " ".join(map(str,player))
		

### FIXED CODE ###

def fizzbuzz(n):
	if n%15==0: return "FizzBuzz"
	if n%3==0: return "Fizz"
	if n%5==0: return "Buzz"
	return str(n)
while 1:
	try:
		m,n=map(int,raw_input().split())
		if m==0:break
		player=range(1,m+1)
		p=0
		for i in range(n):
			if fizzbuzz(i+1)!=raw_input():
				del player[p]
				m=len(player)
				if m==1:
					break
				p%=m
			else:
				p=(p+1)%m
		print " ".join(map(str,player))
	except:
		pass
D, n = map(int,input().split())
l = list(map(int,input().spliy()))
print(D-sum(l))

### FIXED CODE ###

D, n = map(int,input().split())
l = list(map(int,input().split()))
a = D - sum(l)
if a >-1:
    print(a)
else:
    print(-1)
import heapq
N,Q = map(int,input().split(" "))
querys = []
START = 1
GOAL = 0
GO = 2

for _ in range(N):
    s,t,x = list(map(int,input().split(" ")))
    s -=(x + 0.5)
    t -= (x + 0.5)
    querys.append( (START,s,x) )
    querys.append( (GOAL,t,x) )

for _ in range(Q):
    d = int(input())
    querys.append( (GO,d,-1)  )
koji_place = []
koji_um = set()
heapq.heapify(koji_place)
querys = sorted(querys,key = lambda x:x[1])
for query in querys:
    qtype,time,place = query
    if qtype == START:
        heapq.heappush(koji_place,place)
        koji_um.add(place)
    elif qtype == GOAL:
        koji_um.remove(place)
    elif qtype == GO:
        while len(koji_place) != 0  and koji_place[0] not in koji_um: #更新と最近の場所のチェックを同時に行う
            heapq.heappop(koji_place) #koji place のpopは最大で place分，つまり合計で10 ** 5回行われるため ここのwhile
            # はOに影響を与えない
        if not koji_place:
            print(-1)
        else:
            print(koji_place[0])





### FIXED CODE ###

import bisect
import heapq
import sys
N,Q = [int(x) for x in sys.stdin.readline().split()]

hitos = []
ans = [-1] * Q
queries =[]
jump = [-1] * Q



queries = [[int(x) for x in sys.stdin.readline().split()] for i in range(N)]
hitos = [int(sys.stdin.readline()) for i in range(Q)]


# for i in range(N):
    # S,T,X =list(map(int,input().split(" ")))
    # lt = S -X -0.5
    # rt = T -X -0.5
    # queries.append([lt,rt,X]) #-1 → 挿入クエリ lが時間、-1がクエリの種類、Xが場所


queries.sort(key=lambda x:x[2])





for l,r,x in queries:
     lind  = bisect.bisect_left(hitos,l-x - 0.5)
     rind  = bisect.bisect_left(hitos,r -x - 0.5)
     while lind < rind:
         if ans[lind] == -1:
            ans[lind] = x
            jump[lind] = rind
            lind += 1
         else:
             temp = jump[lind]
             jump[lind] = rind
             lind = temp

for i  in ans:
    print(i)
import math
from queue import Queue

h, w = map(int, input().split(" "))
li = [list(input()) for _ in range(h)]

q = Queue()
#     [x, y]
q.put([0, h - 1])
li[h - 1][0] = 0

while not q.empty():
    c = q.get()
    # 上(0, -1) 右(1, 0) 下(0, 1) 左(-1, 0)
    for dr in [[0, -1], [1, 0], [0, 1], [-1, 0]]:
        if li[c[1]][c[0]] == "#": break

        nX = c[0] + dr[0]
        nY = c[1] + dr[1]

        if not (0 <= nX <= w - 1): continue
        if not (0 <= nY <= h - 1): continue

        if li[nY][nX] == ".":
            li[nY][nX] = li[c[1]][c[0]] + 1
            q.put([nX, nY])

li = list(map(lambda item: 0 if item == "#" else item, sum(li, [])))
print(max(li))


### FIXED CODE ###

import math
from queue import Queue
import copy

h, w = map(int, input().split(" "))
ili = [list(input()) for _ in range(h)]

q = Queue()
ans = 0

for y in range(h):
    for x in range(w):
        li = copy.deepcopy(ili)
        if li[y][x] == "#": continue
        q.put([x, y])
        li[y][x] = 0
        while not q.empty():
            c = q.get()
            # 上(0, -1) 右(1, 0) 下(0, 1) 左(-1, 0)
            for dr in [[0, -1], [1, 0], [0, 1], [-1, 0]]:
                nX = c[0] + dr[0]
                nY = c[1] + dr[1]

                if not (0 <= nX <= w - 1): continue
                if not (0 <= nY <= h - 1): continue

                if li[nY][nX] == ".":
                    li[nY][nX] = li[c[1]][c[0]] + 1
                    q.put([nX, nY])

        li = list(
            map(lambda item: 0 if item == "#" or item == "." else item,
                sum(li, [])))
        ans = max(li + [ans])

print(ans)
from collections import *
sys.setrecursionlimit(10**6)

H, W = map(int, input().split())
mas = []
for i in range(H):
    line = input()
    temp = []
    for j in range(W):
        temp.append(line[j])
    mas.append(temp)

color = []
for i in range(H):
    color.append([-1] * W)

def DFS(node, c_color):
    x = node[0]
    y = node[1]
    nb = [[x, y-1], [x, y+1], [x+1, y], [x-1, y]]
    deq = deque()
    for i in range(4):
        if(nb[i][0] >= 0 and nb[i][0] < H and nb[i][1] >= 0 and nb[i][1] < W):
            if(color[nb[i][0]][nb[i][1]] == -1):
                deq.append(nb[i])

    deq_ = deque()
    while(deq):
        next_node = deq.popleft()
        if(mas[next_node[0]][next_node[1]] != mas[node[0]][node[1]]):
            color[next_node[0]][next_node[1]] = c_color
            deq_.append(next_node)
            
    while(deq_):
        next_node = deq_.popleft()
        DFS(next_node, c_color)
    return
        
current_color = 0
for i in range(H):
    for j in range(W):
        if(color[i][j] >= 0):
            continue
        else:
            color[i][j] = current_color
            DFS([i, j], current_color)
            current_color += 1

color_num = []
for i in range(current_color):
    color_num.append([0, 0])


for i in range(H):
    for j in range(W):
        if(mas[i][j] == '#'):
            color_num[color[i][j]][0] += 1
        else:
            color_num[color[i][j]][1] += 1

ans = 0
for i in range(len(color_num)):
    ans += color_num[i][0] * color_num[i][1]

print(ans)


### FIXED CODE ###

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

H, W = map(int, input().split())
mas = []
for i in range(H):
    line = input()
    temp = []
    for j in range(W):
        temp.append(line[j])
    mas.append(temp)

color = []
for i in range(H):
    color.append([-1] * W)

def DFS(node, c_color):
    x = node[0]
    y = node[1]
    nb = [[x, y-1], [x, y+1], [x+1, y], [x-1, y]]
    deq = deque()
    for i in range(4):
        if(nb[i][0] >= 0 and nb[i][0] < H and nb[i][1] >= 0 and nb[i][1] < W):
            if(color[nb[i][0]][nb[i][1]] == -1):
                deq.append(nb[i])

    deq_ = deque()
    while(deq):
        next_node = deq.popleft()
        if(mas[next_node[0]][next_node[1]] != mas[node[0]][node[1]]):
            color[next_node[0]][next_node[1]] = c_color
            deq_.append(next_node)
            
    while(deq_):
        next_node = deq_.popleft()
        DFS(next_node, c_color)
    return
        
current_color = 0
for i in range(H):
    for j in range(W):
        if(color[i][j] >= 0):
            continue
        else:
            color[i][j] = current_color
            DFS([i, j], current_color)
            current_color += 1

color_num = []
for i in range(current_color):
    color_num.append([0, 0])


for i in range(H):
    for j in range(W):
        if(mas[i][j] == '#'):
            color_num[color[i][j]][0] += 1
        else:
            color_num[color[i][j]][1] += 1

ans = 0
for i in range(len(color_num)):
    ans += color_num[i][0] * color_num[i][1]

print(ans)
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r,reverse=True)
answer=p[:X]+q[:Y]
sum=0
answer=sorted(answer,reverse=True)
i=0

while answer[-i-1]<r[i]:
    answer[-i-1]=r[i]
    i+=1

for a in answer:
    sum+=a

print(sum)

### FIXED CODE ###

X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r,reverse=True)
answer=p[:X]+q[:Y]
sum=0
answer=sorted(answer)
i=0

while i<=min(X+Y-1,C-1) and answer[i]<r[i]:
    answer[i]=r[i]
    i+=1

for a in answer:
    sum+=a

print(sum)
S = str(input())
K = int(input())
L = []

count = 0
for s in S:
    count += 1
    if s != '1':
        t = s
        break

if K < count:
    print(1)
else:
    print(int(t)) 



### FIXED CODE ###

S = str(input())
K = int(input())
L = []

count = 0
for s in S:
    count += 1
    if s != '1':
        t = s
        break
    t = s

if K < count:
    print(1)
else:
    print(int(t))
s=input()

#長さ2
#xx
#長さ3
#xxy←長さ2に内包,yxx,xyx
#長さ5:xyxzx　←長さ３に内包

if len(s)==2:
    if s[i]+s[i+1]:
        print(1,2)
        exit()

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        print(i+1,i+1+1)
        exit()
    elif s[i]==s[i+2]:
        print(i+1,i+2+1)
        exit()

print(-1,-1)

    



### FIXED CODE ###

s=input()

#長さ2
#xx
#長さ3
#xxy←長さ2に内包,yxx,xyx
#長さ5:xyxzx　←長さ３に内包

if len(s)==2:
    if s[0]==s[1]:
        print(1,2)
        exit()

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        print(i+1,i+1+1)
        exit()
    elif s[i]==s[i+2]:
        print(i+1,i+2+1)
        exit()

print(-1,-1)
A*B

### FIXED CODE ###

A,B=map(int,input().split())
print(A*B)
A, P = input()
P += A*3
pi = int(P/3)
print (pi)

### FIXED CODE ###

A, P = map(int, input().split())
P += A*3
pi = int(P/2)
print (pi)
n = int(input())
a = map(int, input().split())
b = a.sorted()
c = list(filter(a[i]!=b[i], range(len(a)))
print('YES' if len(c)==2 else 'NO')

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
c = list(filter(lambda i: a[i]!=b[i], range(n)))
print('YES' if len(c) in [0,2] else 'NO')
#####################
#複数の最小公倍数lcm
#####################
from fractions import gcd
def Lcm(list):
  for a in list:
    L = (a // gcd(a, L))*L
  return L
n= int(input())
A = [int(input()) for i in range(n)]
# A = [2,6,8]
print(Lcm(A))



### FIXED CODE ###

#####################
#複数の最小公倍数lcm
#####################
from fractions import gcd
def Lcm(list):
  L = 1
  for a in list:
    L = (a // gcd(a, L))*L
  return L
n= int(input())
A = [int(input()) for i in range(n)]
print(Lcm(A))
n=int(input())
d=list(map(int,input().split()))
mod=998244353
d.sort()

if n==1:
	if d[0]==0:
		print(1)
		exit()
	else:
		print(0)
		exit()
elif n==2:
	if d==[0,1]:
		print(1)
		exit()
	else:
		print(0)
		exit()
if d[0]!=0 or d[1]==0:
	print(0)
	exit()
for i in range(n-1):
	if d[i+1]>d[i]+1:
		print(0)
		exit()
p=[]
cnt=1
for i in range(1,n-1):
	if d[i]==d[i+1]:
		cnt+=1
	elif d[i+1]>=d[i]+1:
		p.append(cnt)
		cnt=1
p.append(cnt)
ans=1
for i in range(len(p)-1):
	ans*=p[i]**p[i+1]
	ans%=mod
print(ans,2/0)

### FIXED CODE ###

from collections import Counter
mod=998244353
n=int(input())
d=list(map(int,input().split()))
q=Counter(d)
if q[0]!=1 or d[0]!=0:
	print(0)
	exit()
ans=1
for i in range(1,max(d)+1):
    ans*=pow(q[i-1],q[i],mod)
    ans%=mod
print(ans)
def main():
    n = int(input())
    result = True
    used = {str(input()): 0}
    for order in range(1,n):
        word = str(input())
        if word in used or sorted(used.keys())[order - 1][-1] != word[0]:
            print('NO')
            result = False
            break
        else:
            used.setdefault(word,0)
    if result:
        print('Yes')
        
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
  A, B = map(int, input().split())
  print('Yes'if (A * B)**2 % 2 == 1 else 'No')
 
 
if __name__ == "__main__":
  main()
# -*- coding: utf-8 -*-

S = input()
s = S[::]
T = ['dream', 'dreamer', 'erase', 'eraser']


def saiki(_s):
    if len(_s) == 0:
        return True

    for strng in T:
        if _s.endswith(strng):
            _s = _s[:len(_s)-len(strng):]
            return saiki(_s)

    return False


ret = False
if len(s) > 0:
    ret = saiki(s)

if ret:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

# -*- coding: utf-8 -*-
import re

S = input()

pattern = '^(dream|dreamer|erase|eraser)+$'
result = re.match(pattern, S)
if result:
    print('YES')
else:
    print('NO')
N, P = map(int, input().split())
S = input()
ans = 0
rui = [0] * (N + 1)
if 10 % P == 0:
    for i in range(len(S)):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    exit()

t = 1
for i in reversed(range(N)):
    tmp = int(S[i]) * t % P
    rui[i] = (rui[i + 1] + tmp) % P
    t *= 10
    t %= P

cnt = [0] * N
for i in reversed(range(N + 1)):
    ans += cnt[rui[i]]
    cnt[rui[i]] += 1
print(ans)

### FIXED CODE ###

N, P = map(int, input().split())
S = input()
ans = 0
rui = [0] * (N + 1)
if 10 % P == 0:
    for i in range(len(S)):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    exit()

t = 1
for i in reversed(range(N)):
    tmp = int(S[i]) * t % P
    rui[i] = (rui[i + 1] + tmp) % P
    t *= 10
    t %= P

cnt = [0] * P
for i in reversed(range(N + 1)):
    ans += cnt[rui[i]]
    cnt[rui[i]] += 1
print(ans)
k = int(input())
lunlun = [1,2,3,4,5,6,7,8,9]
i = 0
while len(lunlun) < k:
  p = lunlun[i]
  if str(p)[-1] == 0:
    lunlun.append(int(str(p)+'0'))
    lunlun.append(int(str(p)+'1'))
  elif str(p)[-1] == 9:
    lunlun.append(int(str(p)+'8'))
    lunlun.append(int(str(p)+'9'))
  else:
    lunlun.append(int(str(p)+str(int(str(p)[-1])-1)))
    lunlun.append(int(str(p)+str(int(str(p)[-1]))))
    lunlun.append(int(str(p)+str(int(str(p)[-1])+1)))
  i += 1

print(lunlun[k-1])

### FIXED CODE ###

k = int(input())
lunlun = [1,2,3,4,5,6,7,8,9]
i = 0
while len(lunlun) < k:
  p = lunlun[i]
  if str(p)[-1] == '0':
    lunlun.append(p*10)
    lunlun.append(p*10+1)
  elif str(p)[-1] == '9':
    lunlun.append(p*10+8)
    lunlun.append(p*10+9)
  else:
    lunlun.append(p*10+p%10-1)
    lunlun.append(p*10+p%10)
    lunlun.append(p*10+p%10+1)
  i += 1

print(lunlun[k-1])
N,X=map(int,input().split())
L=list(map(int,input().split()))
d,cnt=0,0
for i in range(1,N+2):
    if d<=X:
        d=d+L[i-1]
        cnt+=1
print(cnt)


### FIXED CODE ###

import sys
read=sys.stdin.buffer.readline

N,X=map(int,read().split())
L=list(map(int,read().split()))

ans=1
res=0
for l in L:
    res+=l
    if res<=X:
        ans+=1
    else:
        break
print(ans)