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.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    internal static class Program
    {
        public static void Main(string[] args)
        {
            Solve(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        internal static void Solve(Stream inputStream, Stream outputStream)
        {
            // ABC 103 B - String Rotation
            var scanner = new StreamScanner(inputStream);
            var writer = new StreamWriter(outputStream)
            {
                AutoFlush = false
            };
            
            Action<string> Write = (string str) => writer.Write(str);
            Action<string> WriteLine = (string str) => writer.WriteLine(str);
            Action Flush = () => writer.Flush();

            var s = scanner.Scan();
            var t = scanner.Scan();
            
            if (s.Equals(t))
            {
                WriteLine("Yes");
                Flush();
                return;
            }
            
            for (var i = 0; i < s.Length; i++)
            {
                //swap
                s = new string(s.Skip(1).ToArray()) + s.First().ToString();
                if (s.Equals(t))
                {
                    WriteLine("Yes");
                    Flush();
                    return;   
                }
            }
            
            WriteLine("No");
            Flush();
        }
    }
    
    // https://qiita.com/Camypaper/items/de6d576fe5513743a50e
    public class StreamScanner
    {   
        private readonly Stream stream;
        private readonly byte[] buf = new byte[1024];
        private int len, pos;
        private bool isEof = false;
        public bool IsEndOfStream => isEof;

        public StreamScanner(Stream stream) { this.stream = stream; }
        
        private byte Read()
        {
            if (isEof) throw new EndOfStreamException();
            if (pos >= len) {
                pos = 0;
                if ((len = stream.Read(buf, 0, 1024)) <= 0)
                {
                    isEof = true;
                    return 0;
                }
            }
            return buf[pos++];
        }
        
        public char Char() 
        {
            byte b = 0;
            do b = Read();
            while (b < 33 || 126 < b);
            return (char)b; 
        }
        
        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)Read())
                sb.Append(b);
            return sb.ToString();
        }
        
        public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = Read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = Read(); }
            for (; true; b = Read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        
        public int Integer() { return (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
}