peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
MOD = 1000000007
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
is_broken = [False for _ in range(N+1)]
for a in A:
  is_broken[a] = True

# dp[i] = (i段目に辿り着くルートの総数)

# init 
dp = [0]*(N+1)
dp[0] = 1

# DP
for i in range(N):
  if not is_broken[i+1]:
    dp[i+1] += dp[i]
    dp[i+1] %= MOD
  if i+2 <= N:
    if not is_broken[i+2]:
      dp[i+2] += dp[i]
      dp[i+2] %= MOD

print(dp[N])
# Judge status: Wrong Answer
N = int(input())

n = N
for i in range(1000):
    n += 1
    if str(n)[0] == str(n)[1] == str(n)[2]:
        ans = n
        break
print(n)
# Judge status: Accepted
a = int(input())
print(a+(a**2)+(a**3))
# Judge status: Accepted
import sys
import math

(a,b)=input().split()
c=a+b
ci=int(c)

s=int(math.sqrt(ci))
ss=s*s

if ss == ci:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int,input().split())
val = 0
if a*b < 0:
    val += 1
elif (a>0 and b==0) or (a==0 and b<0):
    val += 1
elif b < a:
    val += 2
val += abs(abs(a)-abs(b))
print(val)
# Judge status: Wrong Answer
from itertools import combinations

N, K = [int(n) for n in input().split()]
h = [int(input()) for _ in range(N)]
ans = 0
for c in combinations(h, K):
    mc = max(c)-min(c)
    if ans < mc:
      ans = mc
print(ans)
# Judge status: Wrong Answer
n,m  = map(int,input().split())

balls = [1 for _ in range(n)]
red = [1] + [0 for _ in range(1,n)]

for _ in range(m):
  x, y = map(int,input().split())
  x,y = x-1, y-1
  
  if balls[x] ==0:
    continue
    
  balls[x] = x-1
  balls[y] += 1
  if red[x]:
    red[y] = 1
  if balls[x]==0:
    red[x] = 0
print(sum(red))
# Judge status: Accepted
X = int(input())

for i in range(1, 50000):
    n = i * (i + 1) / 2
    if n >= X:
        print(i)
        break
# Judge status: Accepted
a=int(input())

print(a+a**2+a**3)
# Judge status: Accepted
import numpy as np
import sys

def main():
  S = input()
  T = input()
  lenS = len(S)
  lenT = len(T)
  for i in range(lenS-lenT,-1,-1):
    sub = S[i:i+lenT]
    for j in range(lenT):
      if sub[j]!=T[j] and sub[j]!="?":
        break
    else:
      S = S[:i]+T+S[i+lenT:]
      S=S.replace("?","a")
      print(S)
      sys.exit()
      break
    continue
  print("UNRESTORABLE")

main()
# Judge status: Accepted
s,t = input().split()
print(t,end="")
print(s)
# Judge status: Accepted

mod = 1000000007
N = int(input())

ans = (10 ** N) - (9 ** N) - (9 ** N) + (8 ** N)
ans = ans % mod
print(ans)
# Judge status: Accepted
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

import heapq
import collections

N, M = rl()
daytasks = collections.defaultdict(list)
for i in range(N):
	a, b = rl()
	daytasks[a].append(b)

heap = []
ans = 0
for i in range(1, M+1):
	for t in daytasks[i]:
		heapq.heappush(heap, (-t, i))
	if len(heap) > 0:
		b, a = heapq.heappop(heap)
		b = -b
		ans += b
print(ans)
# Judge status: Accepted
S=input()
n=len(S)
c0=0
c1=0
for i in range(n):
    if i%2==0:
        if S[i]=="0":
            c1+=1
        else:
            c0+=1
    else:
        if S[i]=="0":
            c0+=1
        else:
            c1+=1
print(min(c0,c1))
# Judge status: Accepted
X,Y=map(int,input().split())
ans=0
while X<=Y:
  ans+=1
  X*=2
print(ans)
# Judge status: Wrong Answer
from itertools import accumulate
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = list(accumulate(a))
ans = sum([1 for i in c if i <= x])
if not ans:
  print(ans)
else:
  print(ans if x in list(c) else ans - 1)
# Judge status: Accepted
def check(h):
  if h > 1:
    return 2*(check(h//2))+1
  elif h==1:
    return 1
print(check(int(input())))
# Judge status: Accepted
n = int(input())
alst = list(map(int, input().split()))
bef = []
aft = []
for i, a in enumerate(alst):
  if i % 2 == 0:
    bef.append(a)
  else:
    aft.append(a)
if n % 2 == 0:
  ans = aft[::-1] + bef
else:
  ans = bef[::-1] + aft
print(*ans)
# Judge status: Wrong Answer
n,m=[int(i) for i in input().split()]

if n>=2*m:
  print(m//2)
else:
  print(n+(m-2*n)//2)
# Judge status: Accepted
S=str(input())
T=str(input())
count=0
for i in range(len(S)) and range(len(T)):
    if S[i]!=T[i]:
        count+=1 
    else:
        i+=1 
         
        
print(count)
# Judge status: Wrong Answer
import math

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

print('Yes' if math.sqrt(c)-math.sqrt(a)-math.sqrt(b)>0 else 'No')
# Judge status: Accepted
N = int(input())

dp = list(map(int, input().split()))
for i in range(1, N):
    a, b, c = map(int, input().split())
    newDP = [0] * 3
    newDP[0] = max(dp[1], dp[2]) + a
    newDP[1] = max(dp[0], dp[2]) + b
    newDP[2] = max(dp[0], dp[1]) + c

    dp = newDP[::]

ans = max(dp)
print(ans)
# Judge status: Wrong Answer
a,b = input().split()

print(int(a) * b)
# Judge status: Accepted
from decimal import *
a,b = map(Decimal,input().split(' '))
print(int(a*b))
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A = sorted(A)
B = sorted(B)
C = sorted(C)

from bisect import bisect_left,bisect

ans = 0
for i in range(N):
    ans += bisect_left(A,B[i]) * (N-bisect(C,B[i]))

print(ans)
# Judge status: Accepted
#coding:utf-8

import queue



def main():
    a, b, m = map(int, input().split())
    ref = list(map(int, input().split()))
    ren = list(map(int, input().split()))
    minv = min(ref) + min(ren)
    
    for _ in range(m):
        x, y, c = map(int, input().split())
        minv = min(ref[x - 1] + ren[y - 1] - c, minv)
        
    print(minv)
    
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
can=False
for i in range(n//4+2):
    if (n - 4*i)%7==0:
        can=True
        break
if(can):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
ary = sorted(list(map(int, input().split())))
print('Yes' if ary[0] + ary[1] == ary[2] else 'No')
# Judge status: Accepted
# coding: utf-8

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

now_kabu = 0
shoji = 1000
for i in range(N-1):
    if A[i+1] > A[i]:
        now_kabu += shoji // A[i]
        shoji -= shoji // A[i] * A[i]
    if now_kabu != 0:
        shoji += A[i+1] * now_kabu
        now_kabu = 0

print(shoji)
# Judge status: Accepted
n,p = map(int,input().split())
a = list(map(int,input().split()))

odd_n = 0
for i in range(n):
    if a[i] % 2 == 1:
       odd_n += 1
        

if odd_n == 0:
    if p == 0:
        print(2**n)
    else:
        print(0)

else:
    print(2**(n-1))
# Judge status: Wrong Answer
N,A,B = map(int,input().split())
s = 0
j = 0
for i in range(1,N+1):
  j = i
  x0 = j // 10000
  j -= x0 * 10000
  x1 = j // 1000
  j -= x1 * 10000
  x2 = j // 100
  j -= x2 * 10000
  x3 = j // 10
  j -= x3 * 10000
  x4 = j
  if A <= x0 + x1 + x2 + x3 + x4 and B >= x0 + x1 + x2 + x3 + x4:
    s += i
print(s)
# Judge status: Accepted
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    AB = [list(map(int, readline().rstrip().split())) for _ in range(N)]
    AB.sort()
    pro = 0
    cost = 0
    for a, b in AB:
        if pro + b >= M:
            cost += (M - pro) * a
            break
        pro += b
        cost += a * b
    
    print(cost)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))

step = 0
max_num = 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        step += 1
        max_num = max(step, max_num)
    else:
        step = 0
        

print(max_num)
# Judge status: Accepted
n,l=map(int,input().split())
m=[l+i for i in range(n)]
s=sum(m)
t=101
d=0
for i in range(n):
  if t>abs(m[i]):
    t=abs(m[i])
    d=m[i]
print(s-d)
# Judge status: Wrong Answer
n, k = map(int, input().split())
for x in range(n):
    for y in range(n):
        if x + y <= n:
            z = n - x - y
            result = 10000*x + 5000*y + 1000*z
            if result == k:
                print("{} {} {}".format(x, y, z))
                exit()
print("-1 -1 -1")
# Judge status: Wrong Answer
N, Q = map(int, input().split())
S = str(input())
 
#ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]
a = 0
lst = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    a += 1
  lst.append(a)
print(lst)
for _ in range(Q):
  l, r = map(int, input().split())
  print(lst[r-1] - lst[l-1])
# Judge status: Accepted
n = int(input())
s = list(input())

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

# 1つ目の条件を満たす組の数
ans = r * g * b

# 2つ目の条件を満たす組の数
c = 0
for i in range(n):
    for j in range(i+1,n):
        k = 2 * j -i
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c += 1

print(ans - c)
# Judge status: Wrong Answer
n, k = map(int,input().split())
h = list(map(int,input().split()))
dp = [10**6]*n
dp[0] = 0

for i in range(0,n):
    for j in range(1,k+1):
            if i+j > n-1:
                continue
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))

print(dp[n-1])
# Judge status: Accepted
def resolve():
    S = input()
    c = set()
    l = 0
    for s in S:
        c.add(s)
        if l == len(c):
            print("no")
            return
        l += 1
    print("yes")


resolve()
# Judge status: Accepted
s = input()
if '9'in s:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a,b=map(int,input().split())
print('Yay!' if a<=8 and b<=8 else ':(')
# Judge status: Wrong Answer
N = input()
if "9" in N:
    print('Yes')
else:
    print('NO')
# Judge status: Accepted
#最大公約数
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

#最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)

#全ての最小公倍数を求めればいい
n=int(input())
ans=1
for i in range(n):
  ans=lcm(ans,int(input()))
print(ans)
# Judge status: Accepted
A,B,C = map(int,input().split())
K = int(input())

max_num = max(A,B,C)
if A == max_num:
  print(A * (2 ** K) + B + C)
elif B == max_num:
  print(B * (2 ** K) + A + C)
else:
  print(C * (2 ** K) + B + A)
# Judge status: Accepted
n = int(input())
a = []
for i in range(1, n + 1):
    cnt = 0
    flag = True
    j = i
    while flag:
        if i % 2 == 0:
            i //= 2
            cnt += 1
        else:
            flag = False
    a.append([j, cnt])
print(sorted(a,key=lambda x: x[1])[-1][0])
# Judge status: Wrong Answer
import sys

input = sys.stdin.readline

def main():
    ans = 0
    N = int(input())
    B = list(map(int, input().split()))
    if N == 2:
        ans = B[0]*2
    else:
        ans += min(B[0], B[1])
        for i in range(N-2):
            ans += min(B[i], B[i+1])
        ans += B[-1]
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, A, B = list(map(int,input().split()))
if (B * (N-1) + A) - (B + (N-1) * A) <= 0:
  print(0)
elif A == B:
  print(1)
else:
  print((B * (N-1) + A) - (B + (N-1) * A))
# Judge status: Accepted
a,b,ab,x,y=map(int,input().split())
total=0
if a+b>2*ab:
    total+=min(x,y)*2*ab
    if x>y:
        x-=y
        if a>=2*ab:
            total+=2*ab*x
        else:
            total+=a*x
    elif x<y:
        y-=x
        if b>=2*ab:
            total+=2*ab*y
        else:
            total+=b*y
else:
    total+=a*x+b*y
print(total)
# Judge status: Accepted
H, N = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H + 1):
    for a, b in AB:
        h_new = min(h + a, H)
        dp[h_new] = min(dp[h] + b, dp[h_new])
print(dp[-1])
# Judge status: Accepted
input()
xs=[int(x) for x in input().split(' ')]
for x in xs:
  if x%2==0:
    if x%3!=0 and x%5!=0:
      print('DENIED')
      exit(0)
print('APPROVED')
# Judge status: Accepted
n = int(input())
s = [0]*n
import collections
t = [0]*n
for i in range(n):
    s[i] = input()
    t[i] = collections.Counter(s[i])
m = [100]*26
ans = []
for A in t:
    for i in range(26):
        m[i] = min(m[i],A[chr(97+i)])
for i in range(26):
    if m[i] != 100 and m[i] != 0:
        ans.append([chr(97+i)]*m[i])
for A in ans:
    print("".join(A),end="")
print("")
# Judge status: Wrong Answer
a, b = input().split()
a = int(a)
b = int(b.replace(".", ""))
print(a*b//100)
# Judge status: Accepted
import math
x = int(input())
tol = 1e-6
ans = 1
cur = [0,1]
unit = x/180*math.pi
while cur[0]**2 + cur[1]**2 > tol:
    cur[0] += math.sin(ans*unit)
    cur[1] += math.cos(ans*unit)
    ans += 1
print(ans)
# Judge status: Accepted

def solve():
    X, Y = map(int, input().split())
    print(X+(Y//2))


if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
a,b,c,k=map(int,input().split())
if k<=a+b:
    print(a)
else:
    print(a-(k-(a+b)))
# Judge status: Accepted
# -*- coding: utf-8 -*-

# N円の支払い (1 ≤ N ≤ 50000)
N = int(input())#入力

count = 0
for x in range(50000):
    if(N == int(x*1.08)):
        without_tax = x #税抜き価格
    else: count = count + 1

if(count == 50000): print(':(')
else: print(without_tax)
# Judge status: Accepted
import collections
N = int(input())
A = list(map(int,input().split()))

c = collections.Counter(A)
cc = c.items()

f_ans = 0
for m,n in cc:
  f_ans += n*(n-1)/2

for i in range(N):
  a = A[i]
  b = c[a]
  sa = b*(b-1)/2 - (b-1)*(b-2)/2

  print(int(f_ans - sa))
# Judge status: Wrong Answer
from queue import Queue

K = int(input())

# 1 2 3 4 5 6 7 8 9 10 11 12 21 22 23 32 33 34 ... 98 99 100

q = Queue()
for i in range(1, 10):
    q.put(i)

# print(q.queue)

for i in range(K):
    r = q.get()
    
    if r % 10 != 0:
        q.put(r * 10 + r % 10 - 1)

    q.put(r * 10)

    if r % 10 != 9:
        q.put(r * 10 + r % 10 + 1)
        
print(r)
# Judge status: Wrong Answer
import math

S = int(input())
if S < 3:
    print(0)
    exit()


def check(s, i):
    re = ((i ** s) // math.factorial(s)) % (10 ** 9 + 7)
    return re


n = S // 3

ans = 0
for i in range(n):
    S_i = S - (3 * (i + 1))
    ans += check(S_i, i + 1)
print(ans % (10 ** 9 + 7))
# Judge status: Accepted
l=[2,1]
n=int(input())
for i in range(2,n+1):
    l.append(l[-1]+l[-2])
print(l[-1])
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
if n == 1 or m == 1:
    if n == 1 and m == 1:
        print(1)
    else:
        print(n * m - 2)
else:
    print(n * m - (n + m - 2) * 2)
# Judge status: Accepted
k = int(input())

import queue

que = queue.Queue()

for i in range(1, 10):
    que.put(i)

for i in range(1, k + 1):
    ans = que.get()
    keta1 = ans % 10
    if keta1 == 0:
        append_list = [ans * 10, ans * 10 + 1]
    elif keta1 == 9:
        append_list = [ans * 10 + 8, ans * 10 + 9]
    else:
        append_list = [ans * 10 + keta1 - 1, ans * 10 + keta1, ans * 10 + keta1 + 1]
    for ite in append_list:
        que.put(ite)
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
h = list(map(int,input().split()))
g = [0]*n
co = 0
for _ in range(m):
    a,b = map(int,input().split())
    g[a-1] = -1 if h[a-1]<=h[b-1] or g[a-1]==-1 else 1
    g[b-1] = -1 if h[b-1]<=h[a-1] or g[b-1]==-1 else 1


for i in range(n):
    if g[i] < 0:
        continue
    co+=1

print(co)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
import bisect
def main():
    n,m=map(int,input().split())
    div=make_divisors(m)
    print(div[bisect.bisect(div,m//n)-1])
    

if __name__=='__main__':
    main()
# Judge status: Accepted
n = int(input())

def sum_seq(d):
    return 0.5*(n//d)*(2*d+(n//d-1)*d)

print(int(sum_seq(1) - sum_seq(3) - sum_seq(5) + sum_seq(15)))
# Judge status: Wrong Answer
C = [list(map(int,input().split())) for _ in range(3)]
if C[1][0]-C[0][0]==C[1][1]-C[0][1]==C[1][2]-C[0][2] and C[2][0]-C[0][0]==C[2][1]-C[0][1]==C[2][2]-C[0][2] \
and C[0][1]-C[0][0]==C[1][1]-C[1][0]==C[2][1]-C[2][0] and C[0][2]-C[0][0]==C[1][2]-C[1][0]==C[2][2]-C[2][0]:
    print("Yes")
# Judge status: Accepted
N=int(input())
S=input()
RS=S[::-1]

west=[0]
east=[0]

for i in range(N):
  if S[i]=="W":
    west.append(west[-1]+1)
  else:
    west.append(west[-1])
west.append(0)

for i in range(N):
  if RS[i]=="E":
    east.append(east[-1]+1)
  else:
    east.append(east[-1])
east.append(0)
east=east[::-1]

ans=10**9
for i in range(1,N+1):
  ans=min(ans,west[i-1]+east[i+1])

print(ans)
# Judge status: Accepted
n,a,b = map(int,input().split())
print(b*(n-2)-a*(n-2)+1 if b*(n-2)-a*(n-2)+1 > 0 else 0)
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))
S = sum(W)
m = S
for i in range(1, N):
  T = sum(W[:i])
  m = min(m, abs(T-(S-T)))
print(m)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
s = list(input())
for i in s:
  if i == "a" and a != 0:
    a -= 1
    print("Yes")
  elif i == b and b != 0:
    b -=1
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]
 
for i in range(1000):
    s = str(i)
    if len(s) != n:
      continue
    if all(s[a - 1] == str(b) for a, b in sc):
        print(i)
        exit()
 
print(-1)
# Judge status: Accepted
N = int(input())
if N<=26:
    print(chr(N+96))
else:
    s = ''
    tmp = N
    while True:
        ttmp = tmp%26
        if ttmp==0:
            ttmp = 26
        s = chr(ttmp+96)+s
        if tmp<=26:
            break
        tmp = (tmp-ttmp)//26
    print(s)
# Judge status: Accepted
def route_num(stairs):
    if stairs <= 1:
        return 1
    else:
        return route_num(stairs - 1) + route_num(stairs - 2)

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

broken = {i:False for i in range(n + 1)}
for a_i in a:
    broken[a_i] = True

route_num = {}
for i in range(n + 1):
    if broken[i]:
        route_num[i] = 0
    elif i <= 1:
        route_num[i] = 1
    else:
        route_num[i] = route_num[i-1] + route_num[i-2]

print(route_num[n] % 1000000007)
# Judge status: Accepted
n = int(input())

i = 1
result = 10 ** 18
while i*i <= n:
  if n % i == 0:
    result = min(result, (i - 1) + (n//i - 1))
  i += 1

print(int(result))
# Judge status: Accepted
from heapq import heappush, heappop, heapify


def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    hq = [(-1) * i for i in A]
    heapify(hq)
    cnt = 0
    while cnt < m:
        a = (-1) * heappop(hq)
        a //= 2
        heappush(hq, (-1) * a)
        cnt += 1
    print((-1) * sum(hq))


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, M= map(int,input().split())
numbers = list(map(int, input().split()))

amount = 0
for i in range(M):
    amount = amount + numbers[i]

if N - amount >=  0:
    print(N - amount)
else:
    print(-1)
# Judge status: Accepted
import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
if count==5:
  print(sum(list))
else:
  a=list[count]
  del list[count]
  ans=[]
  for t in list:
    ans.append(math.ceil(t/10)*10)
  print(sum(ans)+a)
# Judge status: Wrong Answer
n = int(input())
li = list(map(int,input().split()))
lis = []
x = 0
y = 0
z = 0
for i in range(n):
    if li[i] % 4 == 0:
        x += 1
    elif li[i] % 2 == 0:
        y = 1
    else:
        z += 1
if y == 0:
    if x >= z + 1:
        print("Yes")
    else:
        print("No")
else:
    if x >= z:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
a.append(0)
money = 1000
stock = 0
for i in range(n):
    if a[i] < a[i+1] and stock == 0:
        stock,money = money//a[i],money%a[i]
    elif a[i] > a[i+1]:
        stock,money = 0,money+stock*a[i]
print(money)
# Judge status: Accepted
t = input()

print(t.replace('?', 'D'))
# Judge status: Accepted
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
	S = deque(SI())
	T = deque(SI())
	for i in range(len(S)):
		S.rotate(1)
		if T == S:
			print('Yes')
			exit()
	print('No')



if __name__ == "__main__":
	main()
# Judge status: Accepted
x,y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
if (x in a and y in a) or (x in b and y in b):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
o=list(input())
e=list(input())
p=[]
for a in range(len(o)-1):
    p.append(o.pop(0))
    p.append(e.pop(0))
if len(o):
    p.append(o.pop(0))
print("".join(p))
# Judge status: Accepted
import math
N = int(input())
print(math.factorial(N) % (10**9 + 7))
# Judge status: Wrong Answer
n = int(input())
v = list(map(int,input().split()))
v.sort()
asa = 0
for i in range(1,n):
     v[n-i-1] = (v[n-i-1] + v[n-i])/2
print(v[0])
# Judge status: Accepted
N, A, B = map(int, input().split())

if (B-A) % 2 == 0:
    ans = (B-A+2)//2-1
else:
    if min(A-1, N-B) == A-1:
        ans = B-1
        plus=A
        B -= A
        A = 1
    else:
        ans = N-A
        plus=N-B+1
        A += N-B+1
        B = N
    if A != B:
        ans = (B-A+2)//2-1+plus

print(ans)
# Judge status: Accepted
n = int(input())
l = input().split()
l = list(map(int,l))
c=0

for i in range(n):
  for j in range(i+1,n):
    for h in range(j+1,n):
      if l[i]!=l[j] and l[h]!=l[j] and l[i]!=l[h]:
        a = [l[i],l[j],l[h]]
        #print(a)
        a.sort()
        if a[0]+a[1]>a[2]:
          #print(c,a)
          c+=1
        
print(c)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
from math import gcd
ans=0
def main(n):
    e=n//c+n//d-n//((c*d)//gcd(c,d))
    return n-e

print(main(b)-main(a-1))
# Judge status: Wrong Answer
n = int(input())

if n < 10:
  print(n)
elif n < 100:
  print(9)
elif n < 1000:
  print(9+(n-99))
elif n < 10000:
  print(9+900+(n-999))
elif n <= 100000:
  print(9+900+(n-9999))
# Judge status: Wrong Answer
N = int(input())
alst = list(map(int, input().split()))

now = 'E'
cnt = 1
for i in range(1, N):
    if alst[i] > alst[i-1]:
        new = 'U' #up
    elif alst[i] < alst[i-1]:
        new = 'D' #down
    else:
        new = 'E'

    if now == new or now == 'E':
        now = new
    elif now != new :
        cnt += 1
        now = 'E'
print(cnt)
# Judge status: Accepted
sx,sy,tx,ty = map(int,input().split())
print("U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)+"L"+"U"*(ty-sy+1)+"R"*(1+tx-sx)+"D"+"R"+"D"*(ty-sy+1)+"L"*(1+tx-sx)+"U")
# Judge status: Accepted
import fractions
a,b=map(int,input().split())
ab_gcd=fractions.gcd(a,b)
cd=[1]
tmp=int(ab_gcd**0.5)+1
if ab_gcd==1:
    print(1)
    exit()

for i in range(2,tmp+1):
   while ab_gcd%i==0:
        ab_gcd//=i
        cd.append(i)
if ab_gcd!=1:
    cd.append(ab_gcd)
cd=set(cd)
print(len(cd) if len(cd)!=1 else 2)
# Judge status: Accepted
n = int(input())
b = [int(_) for _ in input().split()]
ans = b[0]+b[-1]
for i in range(1, n-1):
    ans+=min(b[i],b[i-1])
print(ans)
# Judge status: Accepted
import collections

n = int(input())
ans_list = []
for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
        ans_list.append(x*x+y*y+z*z+x*y+y*z+z*x)

counter = collections.Counter(ans_list)
for i in range(1,n+1):
  print(counter[i])
# Judge status: Wrong Answer
n = int(input())
a = sorted(map(int, input().split()))
ans = a[0]
for i in range(1,n):
  x = a[i] % ans
  if x > 0:
    ans = min(ans, x)
print(ans)