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

Solution in C# (judge verdict: Accepted)

using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;
using System.IO;
using System.Text;

//============================================================================
namespace Sweet
{
    class Program
    {
        static StreamWriter writer = null;
        //============================================================================
        static void setstdio(string[] args)
        {
            if (0 < args.Length)
            {
                // Redirect standard input from the console to the input file.
                Console.SetIn(new StreamReader(args[0]));
                if (args.Length == 2)
                {
                    // Attempt to open output file.
                    writer = new StreamWriter(args[1]);
                    // Redirect standard output from the console to the output file.
                    Console.SetOut(writer);
                }
            }
        }
        //============================================================================
        static int Swing()
        {
            int i;
            string ring = Console.ReadLine();
            string words = Console.ReadLine();
            ring += ring;
            //StringBuilder builder = new StringBuilder(ring.Length*2);
            //builder = ring.ToString;

                for (i = 0; i < ring.Length/2+1; i++)
                    if (words==ring.Substring(i,words.Length))
                        break;

            if (i < ring.Length / 2)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            return 0;
        }

        private static bool isalpha(char v)
        {
            if ('a' <= v && v <= 'z' || 'A' <= v && v <= 'Z')
                return true;
            return false;
        }

        //============================================================================
        static void Main(string[] args)
        {
            setstdio(args);

            while(Swing()!=0);
            if (writer != null)
                writer.Close();
            //Console.ReadLine();
        }
        //============================================================================
    }
}