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: Wrong Answer

Solution code:
# coding: utf-8

s = raw_input()
p = raw_input()

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
		cnt -= 1
	if flag == 0:
		print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
words = list(input())
makeword = list(input())
count = 0
for i in range(len(makeword)):
    for j in range(len(words)):
        if words[j] == makeword[i]:
            del words[j]
            count = 1
            break
    if count == 0:
        print('No')
        break     
if i == len(makeword)-1:        
    print('Yes')

Submission status: Wrong Answer

Solution code:
words = list(input())
makeword = list(input())
count = 0
for i in range(len(makeword)):
    count = 0
    for j in range(len(words)):
        if words[j] == makeword[i]:
            del words[j]
            count = 1
            break
    if count == 0:
        print('No')
        break     
if i == len(makeword)-1:        
    print('Yes')

Submission status: Wrong Answer

Solution code:
words = input()
makeword = input()
words = words + words
judge = words.find(words)
if judge != -1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
hoge = list()
for line in sys.stdin:
    hoge.append(line)
hoge[0] = hoge[0] + hoge[0]
if hoge[0].find(hoge[1]) == -1:
    print ('No')
else:
    print ('Yes')

Submission status: Wrong Answer

Solution code:
import sys

def rotate(x,n):
    return x[n:]+x[:n]

def tostring(x):
    res = ""
    for i in range(0,len(x)):
        res += x[i]
    return res

def isavail(x,y):
    for i in range(0,len(x)):
        l = list(x)
        l = x[:len(x)-1]
        temp = tostring(rotate(l,i))
        if temp.find(y) != -1:
            return "Yes"
    return "No"

l = []
for i in sys.stdin:
    l.append(i)

print(isavail(l[0],l[1]))

Submission status: Wrong Answer

Solution code:
s = input()
p = input()
s = s*(len(p)//len(s)+2)

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

Submission status: Wrong Answer

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

import sys

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = str(input())
p = str(input())
case = s + s
if p in case == True:
	print('yes')
else:
	print('no')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l=list(input())
m=list(input())

for p in m:
    if p in l:
        a="True"
        pass
    else:
        a="False"
        break

if a=="False":
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
sentence = input().lower()
ans = input().lower()
doublesentence = sentence + sentence 
print("Yes" if  ans in doublesentence else "NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# AOJ ITP1_8_D

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    string = input()
    string += string
    p = input()
    # 文字列を2倍してその中から探す。
    # 1≦pの長さ≦sの長さなのでこれでいい。
    # 文字列含有には「文字列」.find(「探したい文字列」)を使う。
    if string.find(p): print("Yes")
    else: print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# Ring

ring = input()
word = input()

ringCut = (ring * 2).split(word)
# print(ringCut)

if ringCut[0] == ring:
    print('No')
else:
    print('Yes')

Submission status: Time Limit Exceeded

Solution code:
import sys
s1=raw_input()
s2=raw_input()


for idx, s in enumerate(s1):
    if s2[0] != s:
        continue
    
    s1_idx = idx
    s2_idx = 0
    while True:
    
        s1_now = s1[s1_idx:]
        s2_now = s2[s2_idx:]
        if len(s1_now) >= len(s2_now):
            if s2_now in s1_now:
                print "Yes"
                sys.exit(0)
            else:
                break
        else:
            if s2_now.startswith(s1_now):
                s1_idx = 0
                s2_idx += len(s1_now)

print "No"

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():

    sentence = input()
    phrase = input()
    count = 0
    for _ in range(len(sentence)):
        if phrase in sentence:
            count =  1
            break
        else:
            sentence = sentence[1:] + sentence[0]
    
    if count == 1:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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:
print("Yes") if (input()*2).find(input())>-1 else print("No")

Submission status: Accepted

Solution code:
t = input() * 2
if input() in t:
    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:
a = input()
b = input()
a = a+a
if b in a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
s = input() * 2
p = input()

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

Submission status: Accepted

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

if len(p) <= len(s) and (s+s).find(p) > -1:
    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:
s = raw_input()
p = raw_input()
if p in s+s:
    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()*2
p = input()
print("Yes" if p in s else "No")

Submission status: Accepted

Solution code:
ring = str(input())*2
search = str(input())

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

Submission status: Accepted

Solution code:
s = input()
p = input()
Flag = False
for i in range(len(s)):
    if len(s)<len(p):
        print("No")
        break
    for j in range(len(p)):
        if i+j>=len(s):
            if s[i+j-len(s)] != p[j]:break
        elif s[i+j] != p[j]:break
        if j == len(p)-1:
            print("Yes")
            Flag = True
            break
    if Flag:break
    if i == len(s)-1:print("No")

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().rstrip()
p = stdin.readline().rstrip()
ss = s*2
if p in ss:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(s)):
	cmp = ''
	for j in range(len(p)):
		cmp += s[(i+j) % len(s)]
	if p == cmp:
		print('Yes')
		exit(0)
print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
p=input()
sl = [i for i in s]
pl = [i for i in p]
lenp=len(p)
pp=pl[-1]
el=[i for i,x in enumerate(sl) if x==pp]
check=0
for i in el:
    pcheck=-1
    while True:
        if sl[i]==pl[pcheck]:
            i-=1
            pcheck-=1
        else:
            break
        if pcheck+lenp<=0:
            check+=1
            break
    if check==1:
        break
if check==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def judg_unit(ss,pp):
    sss = ss + ss + ss
    result = sss.find(pp)
    if result != -1:
        return "Yes"
    else :
        return "No"

s = str(input())
p = str(input())
print(judg_unit(s,p))

Submission status: Accepted

Solution code:

s1 = input()
s2 = input()

while len(s1) <= 100:
	s1 = s1 + s1

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = input()
b = input()
a = a + a[:-1]
if b in a:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#coding: UTF-8

buf = input()
word = input()
buf_buf = buf + buf

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

Submission status: Accepted

Solution code:
s=[]
p=[]
s=input()
s+=s
p=input()

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

Submission status: Accepted

Solution code:
import sys
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
S = str(input())
P = str(input())
 
is_ok = False
 
for i in range(len(S)):
    FLG = True
    for k in range(len(P)):
        if S[(i+k)%(len(S))] != P[k]:
            FLG = False
            break
 
    if FLG == True:
        is_ok = True
        break
 
if is_ok == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
  
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
  
  
S = str(input())
P = str(input())
  
is_ok = False
  
for i in range(len(S)):
    FLG = True
    for k in range(len(P)):
        if S[(i+k)%(len(S))] != P[k]:
            FLG = False
            break
  
    if FLG == True:
        is_ok = True
        break
  
if is_ok == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=raw_input()*2
print'Yes' if raw_input() in n else'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:
a=input()
b=input()
a=a+a[:-1]
if a.find(b)!=-1:
        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:
I=input;

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

Submission status: Accepted

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

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 = raw_input()
p = raw_input()
ss = s + s
ps = p[0]
ret = 'No'
for i in range(len(s)):
    if s[i] == ps:
        c = 0
        for k in range(len(p)):
            if ss[i+k] == p[k]:
                c = c + 1
        if c == len(p):
            ret = 'Yes'
print ret

Submission status: Accepted

Solution code:
#!/usr/bin/python

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = raw_input()
new_s = s + s

p = raw_input()


if p in new_s:
	print "Yes"
else:
	print "No"

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = raw_input()
p = raw_input()
i = 0
while i<len(s):
	k = 0
	while k < len(p):
		if s[(i+k)%len(s)] == p[k]:
			k += 1
		else:
			break
	if k >= len(p):
		print 'Yes'
		break
	i += 1
if k < len(p):
	print 'No'

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=raw_input()
s+=s
print ['No','Yes'][s.find(raw_input())>=0]

Submission status: Accepted

Solution code:
s=raw_input()*2
print ['No','Yes'][s.find(raw_input())>=0]

Submission status: Accepted

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

s3 = s + s + s

if p in s3:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

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

hits=[]
for j in range(len(s)):
    if p[0] == s[j]:
        hits.append(j)


flg=False
_i = 0
for _j in hits:
    if flg: break
    j=_j
    while True:
        for idx, i in enumerate(range(_i, len(p))):
            if j + i > len(s) -1:
                break 
            if p[i] == s[j+idx]:
                flg=True
            else:
                flg=False
                break
        else:
            break

        if flg:
            j = 0
            _i = i
        else:
            break

if flg:
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
import sys
s1=raw_input()
s2=raw_input()

for idx, s in enumerate(s1):
    if s2[0] != s:
        continue
    
    s1_idx = idx
    s2_idx = 0
    while True:
        s1_now = s1[s1_idx:]
        s2_now = s2[s2_idx:]
        if len(s1_now) >= len(s2_now):
            if s1_now.startswith(s2_now):
                print "Yes"
                sys.exit(0)
            else:
               break
        else:
            if s2_now.startswith(s1_now):
                s1_idx = 0
                s2_idx += len(s1_now)
            else:
                break

print "No"

Submission status: Accepted

Solution code:
import sys
s1=raw_input()
s2=raw_input()

def check(s1_top, s1, s2):
    for s2_idx, c in enumerate(s2):
        if c != s1[(s1_top + s2_idx) % len(s1)]:
            return False
    return True

l=[]    
for i, c in enumerate(s1):
    if c == s2[0]:
        if check(i, s1, s2):
            print "Yes"
            sys.exit(0)

print "No"

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if source.find(target) == -1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
s = sys.stdin.readline().strip()
p = sys.stdin.readline().strip()
if (s + s).find(p) == -1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
#1_8_D 2015.4.9
import re
s = input()
p = input()

if re.search(p , s * 2):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#coding:utf-8
#1_8_D 2015.4.9
s,p = [input() for i in range(2)]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline().rstrip()
s += s
pstr = sys.stdin.readline().rstrip()
if  pstr in s:
	print( "Yes" )
else:
	print( "No" )

Submission status: Accepted

Solution code:
p = raw_input()
print "Yes" if raw_input() in p * 2 else "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 = raw_input()
p = raw_input()
print 'Yes' if p in 2 * s else '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()
ring=s+s
if p in ring :
 print("Yes")
else :
 print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = raw_input()
P = raw_input()
no_flg = True
count = S.count(P[0])
start = 0
for c in range(count):
    i = 1
    if c > 0:
        start = S[(start+1):].index(P[0]) + (start+1)
    else:
        start = S[start:].index(P[0])
    for p in P[1:]:
        if S[(start+i) % len(S)] != p:
            break
        i += 1
    if i == len(P):
        print 'Yes'
        no_flg = False
        break
if no_flg:
    print 'No'

Submission status: Accepted

Solution code:
s = raw_input()
s_2 = ''
judge = 0
p = raw_input()
for i in range(len(s)):
	s_list = list(s)
	if list(s)[i] == list(p)[0]:
		s_list.extend(s_list[0:i])
		del s_list[0:i]
		s_2 = "".join(s_list)
		if p in s_2:
			judge = 1
if judge :
	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()
p_len = len(p)

if p in s:
    print("Yes")
else:
    for i in range(p_len):
        if (p[:i] == s[-i:]) and (p[i:] == s[:p_len - i]):
            print("Yes")
            break
    else:
        print("No")

Submission status: Accepted

Solution code:
s = raw_input()
p = raw_input()
idx = []
for i in range(0,len(s)):
    if s[i] == p[0]:
        idx.append(i)
for i in idx:
    for j in range(0,len(p)):
        if p[j] == s[(i+j)%len(s)]:
            continue
        else:
            break
    else:
        print 'Yes'
        break
else:
    print 'No'

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ringstr = raw_input()
matchstr = raw_input()

ringstrlen = len(ringstr)
matchstrlen = len(matchstr)
x = 0 # match length
y = 0 # ring length
hitflag = False
finflag = False
while True:
    if x == matchstrlen:
        print "Yes"
        break
    if y == ringstrlen:
        y=0
        finflag =True
    if matchstr[x]==ringstr[y]:
        x+=1
        if not hitflag:
            tmpy = y
            hitflag = True
        y+=1
    else:
        if hitflag:
            hitflag = False
            if finflag:
                print "No"
                break
            x=0
            y=tmpy+1
            continue
        else:
            if y == ringstrlen-1:
                print "No"
                break
            y+=1

Submission status: Accepted

Solution code:
def myfindall(s,ps):
    # start = 0
    matchlist =[]
    while True:
        tmp = s.find(ps)
        if tmp < 0 :
            break
        if len(matchlist)>0:
            matchlist.append(tmp+matchlist[-1]+1)
        else:
            matchlist.append(tmp)
        s = s[tmp+1:]
    return matchlist

instr = raw_input()
findstr = raw_input()
matchlist = myfindall(instr,findstr[0])
matchflag = False
y=0
for x in matchlist:
    if matchflag:
        break
    while True:
        if y >= len(findstr):
            print "Yes"
            matchflag = True
            break
        if x >= len(instr):
            x = 0
        if instr[x]==findstr[y]:
            x+=1
            y+=1
        else:
            y=0
            break
if not matchflag:
    print "No"

Submission status: Accepted

Solution code:
# coding: utf-8

# ??\???
s = input()
p = input()

s_length = len(s)
ans = False

# s???????????????????§????????????????????¬?????´¢
for s_index in range(len(s)):
    flag = True
    for p_index in range(len(p)):
        target_index = (s_index + p_index) % len(s)
        if s[target_index] != p[p_index]:
            flag = False
            break
    if flag:
        ans = True
        break

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

Submission status: Accepted

Solution code:
s = raw_input()

p = raw_input()

flag = 0
for i in range (len(s)):
    flag = 0
    for j in range(len(p)):
        if p[j] == s[(i + j) % len(s)]:
            flag += 1

        if flag == len(p):
            break

    if flag == len(p):
        break

if flag == len(p):
    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:
s, p = input() * 2, input()
print('Yes' if p in s else 'No')

Submission status: Accepted

Solution code:
word = []
for i in range(2):
    word.append(raw_input())

num = word[0] + word[0]

if word[1] in num:
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
String = input()
A=input()
String+=String[0:len(A)]
#print(String)
for i in range(len(String)-len(A)+1):
	if String[i:i+len(A)] == A:
		print("Yes")
		break
else: print("No")

Submission status: Accepted

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

Submission status: Accepted

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

s += s

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

Submission status: Accepted

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

s = raw_input()
s += s
p = raw_input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = raw_input()
b = raw_input()
a = a+a
if 0 < a.count(b):
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
a = raw_input()
b = raw_input()
a = a+a
if 0 <= a.find(b):
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
str1 = raw_input()
str2 = raw_input()
n = len(str1)

for i in xrange(n):
    j = i
    s = 0
    for k in xrange(len(str2)):
        if (j+k) > (n-1):
            j = -k
        if str1[j+k] != str2[k]:
            s += 1
    if s == 0:
        print "Yes"
        break
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:
#   ????????°??¶???????????? s ???????????????????????????????¨????????????£?¶????????????????????????????????????§???????????? p ??????????????????????????????????????°??????
#   ????????°??¶????????????s????¨??????\?????????????????????
s = list(input())
#   ??????????±??????????p????¨??????\?????????????????????
p = list(input())
#   ?????????s??????????????????????????????????????????s?????????s?????????
s = s + s
#   print(s)
#   ???????????????????????????????????????????????°
flag = 0
for i in range(len(s) // 2):
    if s[i] == p[0]:
        for j in range(len(p)):
            if s[i + j] != p[j]:
                break
            if j == len(p) - 1:
                flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# 18-Character-Ring.py

# ????????°
# ???????????????????????°??¶???????????? s ???????????????????????????????¨????????????£?¶????????????????????????????????????§???
# ????????? p ??????????????????????????????????????°????????????????????????????????????

# Input
# ????????????????????? s ????????????????????????
# ????????????????????? p ????????????????????????

# Output
# p ??????????????´?????? Yes ??¨?????????????????´?????? No ??¨????????????????????????????????????

# Constraints
# 1???p????????????s????????????100
# ??????????????±?°???????????????????

# Sample Input 1
# vanceknowledgetoad
# advance
# Sample Output 1
# Yes

# Sample Input 2
# vanceknowledgetoad
# advanced
# Sample Output 2
# No

import re

pattern=[]

s=input()
p=input()

s= s+s

# for p2 in list(p):
# 	pattern.append(p2)
# 	pattern.append(".*")

# pattern = "".join(pattern)
# print(pattern)

matchOB = re.search(p, s)

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

Submission status: Accepted

Solution code:
import re
s=input()
p=input()
n=len(s)
pp='.*'.join(list(p))
print('Yes' if any([re.search(p,s[i:n]+s[0:i]) for i in range(0,n)]) else 'No')

Submission status: Accepted

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

#??????????????????
if p in s:
    print("Yes")
#????????°??¶???????????????????????????
else:
    s_list = list(s)
    len_s = len(s)
    len_p = len(p)
    string = ''
    #s???????????¨?§???????p???????????°?????????????????????????????????
    string = string.join(s_list[(len_s - len_p):len_s] + s_list[0:len_p])
    #??????????????????
    if p in string:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
s = input()
p = input()
s = s + s
print("Yes" if p in s else "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()
result="No"
for i in range(len(s)):
    r=s[i:]+s[:i]
    if r[0:len(p)]==p:
        result="Yes"
        break
print(result)

Submission status: Accepted

Solution code:
import sys
import math

S = raw_input()
S = S*2

T = raw_input()

if T in S:
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
import sys
import math

S = raw_input()
if S[len(S)-1] == "\r":
    S = S[:len(S)-1]
S = S*2

T = raw_input()
if T[len(T)-1] == "\r":
    T = T[:len(T)-1]

if T in S:
    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:
string = input()
string = string*2
if string.count(input()):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
s=raw_input()
ring=s*2
target=raw_input()
f=0

for i in range(len(s)):
	if ring[i:i+len(target)]==target:
		f=1
		break
if f==1:
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
s=raw_input()
target=raw_input()
ring=s+s[0:len(target)]
f=0

for i in range(len(s)):
	if ring[i:i+len(target)]==target:
		f=1
		break
if f==1:
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
s=raw_input()
target=raw_input()
ring=s*2
f=0

for i in range(len(s)):
	if ring[i:i+len(target)]==target:
		f=1
		break
if f==1:
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
s=raw_input()
target=raw_input()
ring=s*2

ans="No"
for i in range(len(s)):
	if ring[i:i+len(target)]==target:
		ans="Yes"
		break
print ans

Submission status: Accepted

Solution code:
s = raw_input()
p = raw_input()
s *= 2
 
if str.find(s, p) != -1:
  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()

flag = False
for i in range(len(s)):
    t = s[i:] + s[:i]
    if p in t :
        flag = True
        break

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

Submission status: Accepted

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

str2 = s + s
if str2.find(p) >= 0:
	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:
ring = input()
ring_double = ring *2
test = input()
if test in ring_double:
	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()
e = s + s
x = len(P)
m = 0
count = 0
for i in range(len(s)):
    if P == e[m:x]:
        count += 1
    m += 1
    x += 1
if count >= 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = input()
b = input()
c = "No"
for i in range(0,len(a)):
    if len(b) > len(a[i:i+len(b)]):
        n = len(b) - len(a[i:i+len(b)])
        if a[i:i+len(b)] + a[0:n] == b:
            c = "Yes"
    else:
        if a[i:i+len(b)] == b:
            c ="Yes"
print(c)

Submission status: Accepted

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

s *= 2

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

Submission status: Accepted

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

s *= 2

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

Submission status: Accepted

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

s *=2

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

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()

s *= 2

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

Submission status: Accepted

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

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