Problem:
Score : 200 points

Problem Statement

You are given string S and T consisting of lowercase English letters.

Determine if S equals T after rotation.

That is, determine if S equals T after the following operation is performed some number of times:

Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.

Here, |X| denotes the length of the string X.

Constraints

2 \leq |S| \leq 100

|S| = |T|

S and T consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

If S equals T after rotation, print Yes; if it does not, print No.

Sample Input 1

kyoto
tokyo

Sample Output 1

Yes

In the first operation, kyoto becomes okyot.

In the second operation, okyot becomes tokyo.

Sample Input 2

abc
arc

Sample Output 2

No

abc does not equal arc after any number of operations.

Sample Input 3

aaaaaaaaaaaaaaab
aaaaaaaaaaaaaaab

Sample Output 3

Yes

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            //SolveA(args);
            SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        private static void SolveA(string[] args)
        {
            int[] a = ReadAndParseIntArr();
            List<int> cost = new List<int>();
            cost.Add(CalcCost(a[0], a[1], a[2]));
            cost.Add(CalcCost(a[0], a[2], a[1]));
            cost.Add(CalcCost(a[1], a[0], a[2]));
            cost.Add(CalcCost(a[1], a[2], a[0]));
            cost.Add(CalcCost(a[2], a[0], a[1]));
            cost.Add(CalcCost(a[2], a[1], a[0]));

            Console.WriteLine(cost.Min());
        }
        private static int CalcCost(int a, int b, int c)
        {
            int cost = Math.Abs(b - a);
            cost += Math.Abs(c - b);
            return cost;
        }

        private static void SolveB(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            for(int i=0;i<s.Length;++i)
            {
                bool match = true;
                for(int j=0;j<s.Length;++j)
                {
                    int idx = (i + j) % s.Length;
                    if( s[j] != t[idx])
                    {
                        match = false;
                        break;
                    }
                }
                if(match)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
#if false
        public struct Node
        {
            public int loc;
            public int l;
            public int r;
        }
        public struct Point
        {
            public int v;
            public int x;
            public int y;
        }
        static int s_np;
        static List<Point> s_P = new List<Point>();
        static List<Node> s_T = new List<Node>();
        static void SolveB(string[] args)
        {
            int n = ReadAndParseInt();
            //int[][] xy = new int[n][];
            for (int i = 0; i < n; ++i)
            {
                int[] xy = ReadAndParseIntArr();
                s_P.Add(new Point() { v = i, x = xy[0], y = xy[1] });
                s_T.Add(new Node() { l = -1, r = -1});// dummy
            }
            int root = Make2DTree(0, n, 0);


            int q = ReadAndParseInt();
            //int[][] st = new int[q][];
            List<int> ans = new List<int>();
            for (int i = 0; i < q; ++i)
            {
                int[] st = ReadAndParseIntArr();
                ans.Clear();
                    Find(root, st[0], st[1], st[2], st[3], 0, ans);
                ans.Sort();
                for(int j =0;j<ans.Count;++j)
                {
                    Console.WriteLine(ans[j]);
                }
                Console.WriteLine();
            }

        }
        static List<Point> s_tmpList = new List<Point>();
        private static int Make2DTree(int l, int r, int depth)
        {
            if (!(l < r))
            {
                return -1;
            }
            int mid = (l + r) / 2;
            int t = s_np;
            s_np++;

            s_tmpList.Clear();
            for (int i = l; i < l - r; ++i)
            {
                s_tmpList.Add(s_P[i]);
            }
            if (depth % 2 == 0)
            {
                s_tmpList.Sort(SortFuncByX);
            }
            else
            {
                s_tmpList.Sort(SortFuncByY);
            }
            for (int i = l; i < l - r; ++i)
            {
                s_P[i] = s_tmpList[i - l];
            }
            var node = new Node();
            node.loc = mid;
            node.l = Make2DTree(l, mid, depth + 1);
            node.r = Make2DTree(mid + 1, r, depth + 1);
            s_T[t] = node;
            return t;
        }
        static int SortFuncByX(Point a, Point b)
        {
            return a.x.CompareTo(b.x);
        }
        static int SortFuncByY(Point a, Point b)
        {
            return a.y.CompareTo(b.y);
        }
        private static void Find(int v, int sx, int tx, int sy, int ty, int depth, List<int> ans)
        {
            int x = s_P[s_T[v].loc].x;
            int y = s_P[s_T[v].loc].y;
            if (sx <= x && x <= tx && sy <= y && y <= ty)
            {
                ans.Add((s_P[s_T[v].loc].v));
         
            }
            if (depth % 2 == 0)
            {
                if (s_T[v].l != -1 && sx <= x)
                {
                    Find(s_T[v].l, sx, tx, sy, ty, depth + 1, ans);
                }
                if (s_T[v].r != -1 && x <= tx)
                {
                    Find(s_T[v].r, sx, tx, sy, ty, depth + 1, ans);

                }
            }
            else
            {
                if (s_T[v].l != -1 && sy <= y)
                {
                    Find(s_T[v].l, sx, tx, sy, ty, depth + 1, ans);
                }
                if (s_T[v].r != -1 && y <= ty)
                {
                    Find(s_T[v].r, sx, tx, sy, ty, depth + 1, ans);

                }
            }
        }
#endif
    }
}