#K54027. Cyclic Rotation Checker

    ID: 29662 Type: Default 1000ms 256MiB

Cyclic Rotation Checker

Cyclic Rotation Checker

Given two strings s1 and s2, determine if s2 is a cyclic rotation of s1. A string s2 is considered a cyclic rotation of s1 if it can be obtained by taking a prefix of s1 and appending it to the end of the remaining string. Formally, if s1 can be split into two parts, a and b, such that:

s1=a+bs1 = a + b

then s2 must be:

s2=b+as2 = b + a

If the lengths of s1 and s2 differ, i.e., $$|s1| \neq |s2|$$, then s2 cannot be a cyclic rotation of s1.

inputFormat

The input consists of two lines: the first line contains the string s1 and the second line contains the string s2.

outputFormat

Output a single line: "YES" if s2 is a cyclic rotation of s1, otherwise "NO".## sample

abcde
cdeab
YES