Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Ring

  Write a program which finds a pattern $p$ in a ring shaped text $s$.

Input

  In the first line, the text $s$ is given.

  In the second line, the pattern $p$ is given.

Output

  If $p$ is in $s$, print Yes in a line, otherwise No.

Constraints

$1 \leq $ length of $p \leq $ length of $s \leq 100$

$s$ and $p$ consists of lower-case letters

Sample Input 1

vanceknowledgetoad
advance

Sample Output 1

Yes

Sample Input 2

vanceknowledgetoad
advanced

Sample Output 2

No



Sample input:
vanceknowledgetoad
advance


Sample output:
Yes

Submission status: Accepted

Solution code:
s = input()
p = input()
  
s += s[:len(p)]
if p in s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()

if (s * 2).find(p) >= 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
p=input()
print("Yes" if p in s+s else "No")

Submission status: Accepted

Solution code:
s = input() * 2
t = input()
if t in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()
for i in range(len(s)):
    if i + len(p) <= len(s):
        t = s[i:i + len(p)]
    else:
        t = s[i:] + s[:i + len(p) - len(s)]
    if t == p:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = raw_input() * 2
p = raw_input()
print "Yes" if p in s else "No"

Submission status: Accepted

Solution code:
s,p = [input(),input()]
if p in s+s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
k = input()

if k in (s*2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def check(s, p):
    for i in range(len(s)):
        count = 0
        for j in range(len(p)):
            if s[(i+j) % len(s)] != p[j]:
                break
            count += 1
        if count == len(p):
            return True
    return False

s = raw_input()
p = raw_input()
flag = check(s, p)
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
given = input()
target = given*2

keyword = input()

if keyword in target:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = str(raw_input())
p = str(raw_input())

i = 0
while(1):
    if i == len(s):
        print "No"
        break
    if i+len(p) >= len(s):
        str = s[i:len(s)] + s[0:len(p)-len(s[i:len(s)])]
    else:
        str = s[i:i+len(p)]
    if str == p:
        print "Yes"
        break
    else:
        i += 1

Submission status: Accepted

Solution code:
wor = raw_input()
word = raw_input()
a = [[wor]for i in range(10)]
b = ""
for i in a:
    b = b + "".join(i)


if b.count(word) > 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()*2
print('Yes') if input() in s else print('No')

Submission status: Accepted

Solution code:
s = input()*2
print('Yes' if input() in s else 'No')

Submission status: Accepted

Solution code:
s = input()
p = input()
s += s[0:len(p) - 1]
if s.find(p) >= 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
s = s*2
if p in s:
 print('Yes')
else:
 print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()
if p in s*2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
ring = raw_input() * 2
word = raw_input()

flag = 0
counter = 0
while counter < len(ring)/2:
    if ring[counter:(counter + len(word))] == word:
        flag = 1
        break
    counter += 1

if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ring = raw_input() * 2
word = raw_input()

if ring.find(word) != -1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ring = raw_input() * 2
word = raw_input()

if word in ring:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ring = raw_input() * 2

if raw_input() in ring:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s_txt = input()
    p_txt = input()

    base_txt = s_txt * 2
    base_txt = base_txt[:-1]  # s_txt=='hoge', p_txt=='hogehoge' ??????????????´???????????£??????????????????????????????????????????????????????

    if p_txt in base_txt:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()
s += s
if s.find(p) == -1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()
p = input()

s += s[:len(p)-1]
if s.find(p) >= 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline().strip()
p = sys.stdin.readline().strip()

if (p in s+s):
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
s=input()*2
p=input()
print("Yes" if p in s else "No")

Submission status: Accepted

Solution code:
s=input()
p=input()
print('Yes' if p in s*2 else 'No')

Submission status: Accepted

Solution code:
s=input()
s+=s
s=list(s)
p=list(input())
def solve(s,p):
	i=0
	while i<len(s):
		if s[i:i+len(p)]==p:
			return("Yes")
		i+=1
	return("No")
print(solve(s,p))

Submission status: Accepted

Solution code:
s=raw_input()
p=raw_input()
s=s*2
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s=input()
p=input()
s=s*2
if p in s:print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
s = input() * 2
p = input()
if s.find(p) >= 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
found = False
for i in range(len(s)):
    ring = s[i:] + s[:i]
    if p in ring:
        print('Yes')
        found = True
        break
if not found:
    print('No')

Submission status: Accepted

Solution code:
s = input()
if input() in s*2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()

if p in s + s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s1 = input()
s2 = input()

if s2 in s1+s1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#coding:utf-8

s=input()*2
target = input()
print("Yes" if target in s else "No")

Submission status: Accepted

Solution code:
a = input()
print('Yes' if input() in a+a else 'No')

Submission status: Accepted

Solution code:
s = raw_input()
p = raw_input()

slen = len(s)
plen = len(p)
flag = False

for i in xrange(len(s)):
    j = 0
    while(j < plen and s[(i+j)%slen] == p[j]):
        j += 1
    if (j == plen):
        flag = True

if(flag):
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
x = str(input())
y = str(input())

s = []
for i in x:
    s.append(i)
p = []
for i in y:
    p.append(i)

n = len(p)
flag = 0
for i in range(len(s)):
    if i+n > len(s):
        if s[i:]+s[0:(i+n)%len(s)] == p:
            print('Yes')
            flag = 1
            break
    else:
        if s[i:i+n] == p:
            print('Yes')
            flag = 1
            break

if flag == 0:
    print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()

s += s

if s.count(p):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
'''
ITP-1_8-D
 ????????°
???????????????????????°??¶???????????? ss ???????????????????????????????¨????????????£?¶????????????????????????????????????§???
????????? pp ??????????????????????????????????????°????????????????????????????????????
???Input
????????????????????? ss ????????????????????????
????????????????????? pp ????????????????????????
???Output
pp  ??????????????´?????? Yes ??¨?????????????????´?????? No ??¨????????????????????????????????????
'''
# inputData
x = str(input())
y = str(input())

xString = []
for i in x:
    xString.append(i)
yString = []
for i in y:
    yString.append(i)

n = len(yString)
flag = 0
for i in range(len(xString)):
    if xString[i:i+n] == yString:
        flag = 1
        break

    if i+n > len(xString):
        if xString[i:]+xString[0:(i+n)%len(xString)] == yString:
            flag = 1
            break

# outputCheck 
if flag == 0:
    print('No')
elif flag == 1:
    print('Yes')

Submission status: Accepted

Solution code:
import sys

lines = [line.strip() for line in sys.stdin]
s = lines[0] + lines[0]
p = lines[1].strip()

if s.find(p) != -1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys
import re


def main():
    s = sys.stdin.readline()  # haystack
    p = sys.stdin.readline()  # needle

    s = s.strip('\n') * 2
    p = p.strip('\n')

    if len(re.findall((p), s)) > 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = input()
n += n
if input() in n:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()

s = s + s

if p in s:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
I=input;s=I()*2;print(['No','Yes'][I()in s])

Submission status: Accepted

Solution code:
s2 = list(input()*2)
p = list(input())
for i in range(len(s2)-len(p)):
    a = [ s2[i+j] for j in range(len(p))]
    if a == p:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
s=raw_input()
p=raw_input()

if p in s*2:
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
s=input()
p=input()
if p in s*2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
str_list = input().rstrip()
str_search = input().rstrip()

str_list = str_list + str_list

if str_search in str_list:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import re
s = input()
p = input()
s_loop = s + s
match = re.search(p, s_loop)
if not(match is None):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()

if p in s*2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
s += s
key = input()
if s.find(key) != -1: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
s = list(input())
p = list(input())
#print(len(p))
import sys

for i in range(len(s)):
	t=0
	for j in range(len(p)):
		if p[j] == s[(i+j)%len(s)]:
			t = t+1
			#print(p[j], s[(i+j)%len(s)])
		else:
			t = 0
		if t == len(p):
			print('Yes')
			sys.exit()

if t < len(p):
	print('No')

Submission status: Accepted

Solution code:
guruguru,line = (input() for i in range(2))
atama = []
target = line[0]
index = -1
saa = True
while True:
    index = guruguru.find(target, index + 1)
    atama.append(index)
    if index == -1:
        break
for i in range(len(atama)):
    stt = ""
    for i2 in range(len(guruguru)):
        if len(guruguru) <= atama[i]+i2:
            index += 1
            stt += guruguru[index]
        else:
            stt += guruguru[atama[i]+i2]
    if line in stt:
        print("Yes")
        saa = False
        break
    index = -1
if saa:
    print("No")

Submission status: Accepted

Solution code:
s = input() * 2
p = input()
 
if p in (s):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
tmp_s = s
flag = False
for i in range(len(s)):
    tmp_s = tmp_s[-1]+tmp_s[0:-1]
    if tmp_s.count(p)>0:
        flag = True
        break
    else:
        pass
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ring = input()*2
words = input()

if words in ring:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os


s = input().strip()
q = input().strip()

s = s + s
if q in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
str_in = input()
str_val = input()

for i in range(len(str_in),-1,-1):
    flag = str_val in str_in  # check if input value is in string
    if flag:
        break
    if str_val[:i] == str_in[0-i:] and str_in.find(str_val[i:]) == 0:  #first, check if substring till i-index is found in the last part of string. If yes, check rest of input value is found in the beginning of string
        flag = True
        break

if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def check(s, p):
    if s == p:
        return 1
    else:
        return 0

s = input()
p = input()

n = 0
answer = 0
while n < len(s) and answer == 0:
    answer = check(s[:len(p)], p)
    s0 = s[0:1]
    s1 = s[1:]
    s = s1 + s0
    n += 1

if answer:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

def func():
    try:
        ringstr=input().rstrip()
        instr=input().rstrip()
    except:
        return inputError()

    while(True):
        ringstr+=ringstr
        if(len(ringstr) >= len(instr)*2):
            break
    
    print("Yes" if (instr in ringstr) else "No")

def inputError():
    print("input Error")
    return -1
 
func()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s = input() * 2
    key = input()

    if key in s[:-1]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()

print("Yes" if p in s+s else "No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python

s = input()
p = input()
exists = False

sRing = []
iArray = []

pLetter = p[0]

for i in range(len(s)):
    if s[i] == pLetter:
        iArray.append(i)

for i in iArray:
    sNew = s[i:] + s[:i]
    sRing.append(sNew)
    
for x in sRing:
    if p in x:
        exists = True

if exists == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()*3
if s.find(input()) == -1 :
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = input()
p = input()
bl = True
if p in s:
    print("Yes")
    bl = False
if bl:
    for i in range(1,len(s)+1):
        if p[0:i] == s[-i:]:
            if p[i:] == s[0:len(p)-i]:
                print("Yes")
                bl = False
                break
if bl:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()

if p in s+s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input() *2
N = input()

if N in S:
 print("Yes")
else:
 print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
s = s * 2
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input() * 2
p = input()
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#coding:utf-8

moji =input().rstrip()
moji +=moji

tukuru = input().rstrip()

if tukuru in moji:
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
P = input()

s = s * 2
if P in s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
flag = 0
for i in range(len(s)):
    if flag == 1:
        break
    if s[i] == p[0]:
        if len(p) == 1:
            print("Yes")
            flag = 1
            break
        for j in range(1, len(p)):
            i = (i + 1) % len(s)
            if s[i] != p[j]:
                break
            if j == len(p)-1:
                print("Yes")
                flag = 1
                break
if flag == 0:
    print("No")

Submission status: Accepted

Solution code:
s,p = input()*2,input()
print('Yes' if p in s else 'No')

Submission status: Accepted

Solution code:
s = input()
p = input()
s = s * 2
if p in s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
r=input()
p=input()
r=r*2
if r.find(p)==-1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
ring = input()
ring += ring

if input() in ring:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()
sen = s+s
if p in sen:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????°?????????????´¢
"""
s = input().strip()
p = input().strip()
ret = "No"
for i in range(len(s)):
    if p in s:
        ret = "Yes"
        break
    # ?????????????????????????????????????????????push pop??????????????£??????
    s = s[1:] + s[0] # ????????????????????°????????????????????????

print(ret)

Submission status: Accepted

Solution code:
s=[ord(i) for i in input()]
n=[ord(i) for i in input()]
flag=0
flack=0
for i in range(len(s)):
    flack=0
    if n[0]==s[i]:
        flack=1
        for j in range(1,len(n)):
            if i+j>=len(s):
                if n[j]==s[i+j-len(s)]:
                    flack=flack+1
                else:
                    break
            else:
                if n[j]==s[i+j]:
                    flack=flack+1
                else:
                    break
    if flack==len(n):
        flag=1
        break
                
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()
ss = s + s
if p in ss:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
from collections import deque

def main():
    S = input()
    P = input()

    s = deque(S)
    n = len(S)
    for _ in range(n):
        s.append(s.popleft())
        if P in ''.join(s):
            ans = 'Yes'
            break
    else:
        ans = 'No'

    print(ans)

main()

Submission status: Accepted

Solution code:
s = input()
p = input()

S = s+s

index = S.find(str(p))

if index != -1:
    print ("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
p=input()

s+=s

if p in s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()

print( "Yes" if p in s*2 else "No" )

Submission status: Accepted

Solution code:
s = input()
p = input()

if p in s + s:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
s = input()
s = s * 2
p = input()

for offset in range(len(s) - len(p) + 1):
    if s[offset:offset+len(p)] == p[:]:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
s += s
if p in s and 2 * len(p) <= len(s):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
s2 = s + s
if(p in s2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
  
if p in (s * 2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
text = input()*2
word = input()
if text.find(word) != -1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()*2
p=input()
if s.find(p) != -1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
p=input()
s=input()

ret = 'Yes'
try: (p+p).index(s)
except : ret = 'No'
print(ret)

Submission status: Accepted

Solution code:
string = 2 * raw_input()
search = raw_input()
print 'Yes' if string.count(search) > 0 else 'No'

Submission status: Accepted

Solution code:
# Aizu Problem ITP_1_8_D: Ring
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


def ring(string, pattern):
    string = string + string
    return string.find(pattern) >= 0

  
string = input().strip()
pattern = input().strip()
print("Yes" if ring(string, pattern) else "No")

Submission status: Accepted

Solution code:
s = input()
p = input()
flg = False

for i in range(len(s)):
    s = s[1:] + s[:1]
    if p in s:
        flg = True
        break

if flg:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x=input()
s=x*2

y=input()

if y in s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
z=input()*2
x=input()
a=z.count(x)

if a>=1:
    print("Yes")
else:
    print('No')

Submission status: Accepted

Solution code:
data = input()
answer = input()

data = data*3

if answer in data:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
string = input()

string *= 3

if string.find(input()) != -1:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
Ans = False
cnt = 0

for i in range(len(s)):
    for j in range(len(p)):
        if i + j >= len(s):
            i = -j
        if s[i + j] != p[j]:
            break
        cnt += 1
    if cnt == len(p):
        Ans = True
        break
    cnt = 0

if Ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

s = input()
s += s
p = input()

if p in s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
sample_string = input()
test_string = input()
if test_string in sample_string * 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from itertools import cycle, islice

s = input()
t = input()
u = "".join(islice(cycle(s), len(s)+len(t)))

print("Yes" if u.find(t) >= 0 else "No")

Submission status: Accepted

Solution code:
s,p=[input() for i in range(2)]
s=s*100
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s,p=[input() for i in range(2)]
s=s*10
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s,p=[input() for i in range(2)]
s=s*5
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s,p=[input() for i in range(2)]
s=s*4
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s,p=[input() for i in range(2)]
s=s*3
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s,p=[input() for i in range(2)]
s=s*2
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
letters=input()
letters=letters+letters
want_find=input()
if want_find in letters:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
word = input()*2
p = input()
if p in word:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s, p = input()*2, input()
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
str = input() *2
pattern = input()

if pattern in str:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = raw_input()
p = raw_input()
s = s + s
if p in s:
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
s = input()
p = input()
for e, i in enumerate(s):
    if i == p[0]:
        temp = s[e:] + s[:e]
        if p in temp:
            print('Yes')
            break
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
    s = input()
    p = input()

    S = list(s)
    P = list(p)

    C = [] #Checker
    f = False
    for x in range(len(S)):
        if P[0] == S[x]:
            C.append(x)
            f = True

    if f == False:
        print("No")
    else:
        Ans = []
        for z in range(len(C)):
            cnt = 0
            for x in range(len(S)):
                if x + C[z] >= len(S):
                    i = x + C[z] - len(S)
                else:
                    i = x + C[z]
                if P[x] == S[i]:
                    cnt += 1
                    if cnt == len(P):
                        break
                else:
                    break

            if cnt == len(P):
                Ans.append(1)
            else:
                Ans.append(0)
        
        if 1 in Ans:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
"""
import codecs
import sys

sys.stdout = codecs.getwriter("shift_jis")(sys.stdout) # ??????
sys.stdin = codecs.getreader("shift_jis")(sys.stdin) # ??\???

# ??\??¬?????????print??????????????´?????? print(u'?????????') ??¨??????
# ??\??¬?????????input??? input(u'?????????') ??§OK
# ??°?¢???????????????????????????´??????6,7???????????????????????¢??????
"""

s = raw_input()
p = raw_input()

#s = "abaabbaabbaaaaaabbaabba"
#p = "aabbaabaabb"

cnt = s.count(p[0]) #????§?????£?????????°
flag = 0
if cnt == -1: #p???????????????????????¨?????????
	print("No")
else: #????§?????£?????????¨??????
	start_search = 0 #????´¢?????????????§???????
	while cnt > 0:
		index = s.find(p[0], start_search) #????§????????????????
		ans = 1
		for i in range(len(p)):
			if index + i >= len(s): #????°?????????????????????´??????????????????????????????????????????
				j = i - len(s)
			else:
				j = i
			if s[index + j] != p[i]: #1????????§????????£????????????????????§??¢?´¢??????
				ans = 0
				break
		if ans == 1:
			print("Yes")
			flag = 1
			break
		start_search = index + 1
		#print(start_search)
		cnt -= 1
	if flag == 0:
		print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
ring = input()
pattern = input()

ring *= 2

if pattern in ring:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def main():

    string_s = input()
    string_p = input()

    print('Yes') if string_p in (string_s + string_s) else print('No')


main()

Submission status: Accepted

Solution code:
s=(input())*2
print('Yes' if input() in s else 'No')

Submission status: Accepted

Solution code:
s = input()
p = input()

s += s
if s.find(p) == -1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_D&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    s = input().strip()
    p = input().strip()

    s = s + s[:-1]
    if p in s:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
s = input() * 2
p = input()

if s.find(p) == -1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
# Belongs to : midandfeed aka asilentvoice
s = str(input())*2
q = str(input())
print(["No", "Yes"][q in s])

Submission status: Accepted

Solution code:
# -*-coding:utf-8

def main():

    s = input()
    p = input()

    if(p in s*2):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
p=input()
ss=s+s
if ss.find(p)==-1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
    s = input()
    p = input()

    # |p| <= |s| ??????
    if p in s + s:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=input()
p=input()
if (s+s).count(p):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
i=input
p=print
x=i()
y=i()
p('Yes') if (x+x).count(y) else p('No')

Submission status: Accepted

Solution code:
s=input()
p=input()
print('Yes'if p in s*2 else'No')

Submission status: Accepted

Solution code:
a=input()
print(['No','Yes'][input() in a*2])

Submission status: Accepted

Solution code:
s,p=input()*2,input()
print(['No','Yes'][p in s])

Submission status: Accepted

Solution code:
s = input()
s += s

key = input()

if s.find(key) != -1: 
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
if input() in s * 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = raw_input()
p = raw_input()
s = s + s
if p in s:
	print 'Yes'
else:
	print 'No'

Submission status: Accepted

Solution code:
s=input();a="";b=input()
for i in range(len(s)):
    a+=s
if b in a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ins = input()
pat = input()

arr = ins + ins

if arr.find(pat) != -1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
s2 = s + s
print("Yes" if s2.find(input()) != -1 else "No")

Submission status: Accepted

Solution code:
s = input() * 2
print("Yes" if input() in s else "No")

Submission status: Accepted

Solution code:
words = input()
makeword = input()
words = words + words
if makeword in words:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=input()
P=input()
I=S*2
if P in I:
 print('Yes')
else:
 print('No')

Submission status: Accepted

Solution code:
a=input()
print(['No','Yes'][input()in a*2])

Submission status: Accepted

Solution code:
s,p=input()*2,input()
print(['No','Yes'][p in s])

Submission status: Accepted

Solution code:
# coding: UTF-8
line = str(raw_input()*2)
word = str(raw_input())
if line.count(word):
    print "Yes"
else: print "No"

Submission status: Accepted

Solution code:
# coding:utf-8
s = raw_input()
p = raw_input()
s += s
if p in s:
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
hoge = list()
for _ in range(2):
    hoge.append(input())
hoge[0] = hoge[0] + hoge[0]
if hoge[0].find(hoge[1]) == -1:
    print ('No')
else:
    print ('Yes')

Submission status: Accepted

Solution code:
str1, str2 = input()*2, input()
if str2 in str1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
text = input().strip('\n') * 2
pattern = input().strip('\n')
if len(pattern) <= len(text) / 2 and pattern in text:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()*2
p = input()
if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline().rstrip('\r\n')
p = sys.stdin.readline().rstrip('\r\n')

s += s
if p in s:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

s = sys.stdin.readline().strip()
p = sys.stdin.readline().strip()

s = s + s

if p in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
p = input()
if p in s*2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
s += s
if p in s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
if (s*2).count(p) == 0 :
    print('No')
else :
    print('Yes')

Submission status: Accepted

Solution code:
def judge(s,p):

    sList = list(s)
    pList = list(p)


    for i in range(len(sList)):
        if sList[i] == pList[0]:
            answerNum = 0
            counter = i

            for j in range(len(pList)):
                if pList[j] == sList[counter]:
                    answerNum += 1

                    if answerNum == len(pList):
                        return True
                else:
                    break

                if counter == len(sList) -1 :
                    counter = 0
                else:
                    counter += 1
    return False

if judge(input(),input()):
    print("Yes")
else:
    print("No")