peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
[n,m] = list(map(int,input().split(" ")))

if m%2 == 0:
    t = int(m/2)
    for i in range (t):
        print(i+1,2*t-i)
    for i in range (t):
        print(2*t+1+i,4*t+1-i)
else:
    t = int(m/2)+1
    for i in range (t):
        print(i+1,2*t-i)
    for i in range (t-1):
        print(2*t+1+i,4*t-1-i)
# Judge status: Accepted
a,b,c = map(int, input().split())
ans = a**2 + b**2 + c**2 - 2*(a*b + b*c + a*c)
if(c-a-b < 0):
    print('No')
    exit()

if(ans > 0):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import numpy as np
import itertools


n,m,q = map(int, input().split())
l = [list(map(int,input().split())) for _ in range(q)]
a,b,c,d = zip(*l)

temp = np.arange(1,m+1)
A = list(itertools.combinations(temp,n))
ans=0

for L in A:
  ans_temp = 0
  for j in range(q):
    if L[b[j]-1]-L[a[j]-1]==c[j]:
      ans_temp += d[j]
  ans = max(ans, ans_temp)
print(ans)
# Judge status: Accepted
s = input()

cnt = 0
ans = 0
tmp = 0
check = 0
for x in s:
    cnt += 1
    if x == '<':
        if check != cnt - 1:
            ans -= tmp * (cnt - check - 1)
            tmp = 0
        tmp += 1
        ans += tmp
        check = cnt
    else:
        tmp -= 1
        ans += tmp
        if tmp < 0:
            ans += (cnt -  check + 1)
            tmp += 1

print(ans)
# Judge status: Wrong Answer
s=input()
for i in range(1,len(s),1):
	if s[i]==s[i-1]:
		print(str(i)+" "+str(i+1))
		exit()
	try:
		if s[i-1]==s[i+1]:
			print(str(i)+" "+str(i+2))
			exit()
	except:
		pass
print(str(-1)+" "+str(-1))
# Judge status: Accepted
from collections import deque

X = input()
n = len(X) # even

stack = deque([])

for char in X:
	if char == 'S':
		stack.append(char)
	elif char == 'T' and len(stack) == 0:
		stack.append('T')
	elif char == 'T' and stack[-1] == 'S':
		stack.pop()
	elif char == 'T' and stack[-1] == 'T':
		stack.append('T')

print(len(stack))
# Judge status: Accepted
a, b = map(int,input().split())
if a <= 9 and b <= 9:
  print(a*b)
else:
  print(-1)
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy

print('R' * dx + 'U' * dy + 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U' + 'U' * dy + 'R' * dx + 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R')
# Judge status: Accepted
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n - 1)]

for i in range(n):
    t = 0
    for j in range(i, n - 1):
        if t < csf[j][1]:
            t = csf[j][1]
        else:
            if t % csf[j][2] != 0:
                t = (t // csf[j][2] + 1) * csf[j][2]
        t += csf[j][0]
    print(t)
# Judge status: Accepted
x,y=map(int,input().split())
if x%y==0:
  print(-1)
else:
  i=2
  while True:
    if x*i%y!=0:
      print(x*i)
      break
    else:
      i=i+1
# Judge status: Accepted
N=int(input())
AB=[list(map(int,input().split())) for i in range(N)][::-1]
count=0
for i in range(N):
    AB[i][0]+=count
    if AB[i][0]%AB[i][1]!=0:
        count+=AB[i][1]-(AB[i][0]%AB[i][1])
print(count)
# Judge status: Accepted
import sys
N,M=map(int,input().split())
dp=[1]*N
listA=[]
for i in range(M):
  a=int(input())
  listA+=[a]
  dp[a-1]=0
for i in range(1,M):
  if listA[i]==listA[i-1]:
    print(0)
    sys.exit()
setA=set(listA)    
if (1 not in setA) and (2 not in setA) and N!=1:
  dp[1]=2
for i in range(2,N):
  if i+1 not in setA:
    dp[i]=dp[i-1]+dp[i-2]
ans=dp[-1]%(10**9+7)
print(ans)
# Judge status: Accepted
x, n = list(map(int, input().split()))
p_list = list(map(int, input().split()))

candidates= {}
for i in range(203):
    a = x-101+i
    candidates[a] = abs(x-a)

for p in p_list:
    del candidates[p]
    
min_diff = None
ans = []
for k, v in sorted(candidates.items(), key=lambda x:x[1]):
    if min_diff is None:
        min_diff = v
        ans.append(k)
    elif min_diff == v:
        ans.append(k)
    else:
        break
print(min(ans))
# Judge status: Accepted
n = int(input())
ans = [0]*(n+1)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            ni = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if ni <= n:
                ans[ni] += 1
for i in range(1, n+1):
    print(ans[i])
# Judge status: Wrong Answer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc132_b

n = int(input())
d = list(map(int, input().strip().split()))

for i in range(n):
    for j in range(i):
        if d[j] > d[j+1]:
            tmp = d[j]
            d[j] = d[j+1]
            d[j+1] = tmp

res = d[n//2] - d[n//2-1] 
print(res)
# Judge status: Wrong Answer
S = input()

ans = 0
ans_lis = [0]

for i in range(len(S)):
    if S[i] in "ACGT":
        ans = ans + 1
    else:
        ans_lis.append(ans)
        ans = 0
        ans_lis.append(ans)

print(max(ans_lis))
# Judge status: Wrong Answer
nn = int(input())
dd = list(map(int,input().split()))
nof_op = 0
finish = 1
while True:
    for ind in range(nn):
        if (dd[ind] % 2) == 1:
            finish = 1
            break
        else:
            dd[ind] = dd[ind] / 2
    if finish == 1:
        break
    else:
        nof_op += 1
print(nof_op)
# Judge status: Accepted
a,b,c = map(int,input().split())
k = int(input())

tmp = max(a,b,c)
for i in range(k):
    tmp *= 2
    
ans = a + b + c + tmp - max(a,b,c)
print(ans)
# Judge status: Wrong Answer
#coding:utf-8

n = int(input())

dic = {}
for _ in range(n):
    key = input()
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
        

max_key = max(dic)
max_v = dic[max_key]
li = []
for key in dic:
    if max_v == dic[key]:
        li.append(key)
        
li.sort()
for v in li:
    print(v)
# Judge status: Accepted
def main():
    abc = list(map(int, input().split()))
    abc.sort(reverse=True)
    ans = int(str(abc[0]) + str(abc[1])) + abc[2]
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    s=input()
    al = list(chr(ord('A') + i) for i in range(26))
    l=[]
    for j in s:
        l.append(al[(al.index(j)+n)%26])
    print(''.join(l))
resolve()
# Judge status: Accepted
n = int(input())
a = int(input())

print('Yes' if (n % 500) <= a else 'No')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
l = [a[i]-i-1 for i in range(n)] # ai - iのリスト
b = sorted(l)[n//2] # bは中央値になる
ans = 0
for i in range(n):
    ans += abs(l[i]-b)
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
d = max(a,b,c)
p = (d-a)+(d-b)+(d-c)
if p % 2 != 0:
    p += 3
print(p // 2)
# Judge status: Accepted
x, y = map(int, input().split())

if x==y or x%y==0:
    print(-1)
else:
    for i in range(2, 10**9):
        if (x*i)%y!=0:
            print(x*i)
            import sys
            sys.exit()
    print(-1)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, m = map(int, input().split())
    if n == 1 and m == 1: ans = 0
    elif m == 1: ans = n - 2
    elif n == 1: ans = m - 2
    else: ans = (m - 2) * (n - 2)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, n-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        count += 1

print(count)
# Judge status: Accepted
#import collections
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
#import copy
#import numpy as np

n, k, s = map(int, input().split())
ans = [s+1 if s != 10**9 else 1 for i in range(n)]
#print(ans)
for i in range(k):
    ans[i]=s
for i in ans:
    print(i)
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B = map(int, input().split())
    print('Yay!'if A <= 8 and B <= 8 else ':(')


if __name__ == "__main__":
    main()
# Judge status: Accepted

N = int(input())
h = list(map(int,input().split()))
DP = [10**9]*N
DP[0] = 0
DP[1] = abs(h[1]-h[0])
for i in range(2,N):
    DP[i] = min(DP[i],DP[i-2]+abs(h[i]-h[i-2]))    
    DP[i] = min(DP[i],DP[i-1]+abs(h[i]-h[i-1])) 
    
print(DP[-1])
# Judge status: Accepted
N=int(input())
ans=0
for b in range(1,N):
    ans+=(N-1)//b
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
cnt = 100000
for i in a:
    j = 0
    k = i
    while k % 2 == 0:
        j += 1
        k /= 2
    cnt = min(cnt, j)
print(cnt)
# Judge status: Wrong Answer
import math

a,b,h,m = [int(x) for x in input().split(' ')]

rad_hour = math.pi * 2 * (h/12)
rad_min = math.pi * 2 * (m/60)

rad = max(rad_hour, rad_min) - min(rad_hour, rad_min)

x = (math.pow(a,2) + math.pow(b,2) - (2*a*b*math.cos(2*math.pi - rad)))
print(math.sqrt(x))
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if p[i - 1]  < p[i] < p[i + 1] or p[i - 1]  > p[i] > p[i + 1]:
        ans += 1
print(ans)
# Judge status: Accepted
X = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
Y = make_divisors(X)

for i in Y:
    for j in range(-1000,1000):
        A = j
        B = A - i
        if A**5 - B**5 == X:
            print(A,B)
            exit()
# Judge status: Accepted
N = int(input())

ans = 1
for i in range(1,N+1):
    ans = ((ans%(1000000007)) * i) % 1000000007

print(ans)
# Judge status: Accepted
import sys

N, M = map(int, input().split())
AB = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(N)]

AB.sort()

res = 0
for a, b in AB:
    if M > b:
        M -= b
        res += a * b
    else:
        res += a * M
        break
print(res)
# Judge status: Accepted
a, b = map(int, input().split())

for n in range(999):
  if n*(n+1)/2 - a == (n+1)*(n+2)/2 - b:
    print(int(n*(n+1)/2 - a))
# Judge status: Wrong Answer
from math import floor
D, N = map(int, input().split())

print((N-floor((N-1)/99))*100**D)
# Judge status: Wrong Answer
n = int(input())
s = list(input())
x = 0
ans = []
for i in s:
    if i == 'I':
        x += 1
    if i == 'D':
        x -= 1
    ans.append(x)

print(max(ans))
# Judge status: Accepted
def main():
    alice, bob = map(int, input().split())
    answer = ""
    if alice == bob:
        answer = "Draw"
    elif alice == 1 or (alice > bob and not bob == 1):
        answer = "Alice"
    else:
        answer = "Bob"
    print(answer)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))

ave = sum(x)/n
p = round(ave)
res = 0
for i in x:
  res += (i -p )**2
print(res)
# Judge status: Accepted
S= str(input())
S=list(S)
for i in range(len(S)):
    if i%2==0:
        if S[i] not in ('R','U','D'):
            print('No')
            exit()
    if i%2!=0:
        if S[i] not in ('L','U','D'):
            print('No')
            exit()
print('Yes')
# Judge status: Wrong Answer
import sys
N, M, X=map(int, sys.stdin.readline().rstrip().split())
A = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(N)]
cost=[]
for i in range(1<<N):	#Bit All Search
	l=[0]*(M+1)
	for j in range(N):
		if((i>>j)&1)==1:
			l=[l[k]+A[j][k] for k in range(M+1)]
	for k in range(M):
		if l[k+1]<X:break
		else:cost.append(l[0])
cost.sort()
print(-1 if cost==[] else cost[0])
# Judge status: Accepted
N = int(input())
a = 0
b = 0
while N > 0:
    if N < 10:
        c = N
        break
    if N % 10 != 9:
        b = 1
    N //= 10
    a += 1
if b == 1:
    c -= 1
ans = c + a * 9
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
if a == b and b == c and c == a:
    print('No')
elif a != b and b != c and c != a:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
n = int(input())
l=[]
for i in range(n):
  l.append(list(map(int,list(input().split()))))
l.sort()
m = sorted(l,key = lambda y:y[1])
x,y=0,0
for i in range(1,n):
  p = abs(l[i][0]-l[0][0])+abs(l[i][1]-l[0][0])
  if p>x:
    x=p
  q = abs(m[i][0]-m[0][0])+abs(m[i][1]-m[0][0])
  if q>y:
    y=q  
    
print(max(x,y))
# Judge status: Accepted
x=int(input())

f=0
for i in range(1000):
  for j in range(-1000,1000):
    if (i**5-j**5)==x:
      print(i,j)
      f=1
  if f==1:
    break
# Judge status: Wrong Answer
A,B,N = map(int,input().split(" "))
max_floor = 0
for x in range(N+1):
  floor_x = int(A*x/B) -A*int(x/B)
  if max_floor < floor_x:
    max_floor = floor_x
print(floor_x)
# Judge status: Wrong Answer
S=input()
L=("a","b","c","d","e","f","g","h","i","j","k","l","m","n",
    "o","p","q","r","s","t","u","v","w","x","y","z")
for l in L:
    if S.count(l)>0:
        pass
    else:
        print(l)
else:
    print("None")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int, input().split()))

from collections import Counter
c=Counter(a)

ans_1=0
ans_2=0
for key in c:
    if c[key]>=4 and key>ans_1:
        ans_1,ans_2=key,key
    elif c[key]>=4 and key>ans_2:
        ans_2=key
    elif c[key]>=2 and key>ans_2:
        ans_1,ans_2=key,ans_1

print(ans_1*ans_2)
# Judge status: Accepted
N,X=map(int,input().split())
L=list(map(int,input().split()))
cum,count=0,1
for l in L:
    cum+=l
    if cum<=X:count+=1
print(count)
# Judge status: Accepted
N, L = map(int, input().split())
t = sorted(list(range(L, L+N)), key=abs)
print(sum(t[1:]))
# Judge status: Accepted
x, a, b = map(int, input().split())
da = abs(x-a)
db = abs(x-b)
print("A" if da < db else "B")
# Judge status: Wrong Answer
from itertools import accumulate
N = int(input())
S = input()
SS = [1 if S[i]=='(' else -1 for i in range(N)]
SSS = list(accumulate(SS))
m = -min(SSS)
M = max(SSS)

print('('*m+S+')'*(M-m))
# Judge status: Accepted
k=int(input())
a,b=map(int,input().split())

i=1
while k*i<=b:
  if a<=k*i:
    print('OK')
    exit(0)
  i+=1
print('NG')
# Judge status: Accepted
val1 = input().split()
val2 = input().split()
total = 0
for votes in val2:
  total += int(votes)
thres = total * 1/4 / int(val1[1]) 
i = 0
for votes in val2:
  if int(votes) >= thres:
    i += 1
if i >= int(val1[1]):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N=input()

if N[0]=='7' or N[1]=='7' or N[2]=="7":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N, M = map(int, input().split())
ans = 0
#最後にNoneを消す。あとはsetで重複を消す。
roads_memo = [[None] for i in range(N)]

for _ in range(M):
    ai, bi = map(int, input().split())
    roads_memo[ai-1].append(bi)
    roads_memo[bi-1].append(ai)

for memo in roads_memo:
    del memo[0]
    memo = set(memo)
    print(len(memo))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

buka = [0] * N
for i in A:
    buka[i-1] += 1

for j in range(N):
    print(buka[j])
# Judge status: Accepted
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    money = 1000
    have = 0
    for i in range(len(a)-1):
        if a[i] < a[i+1]:
            have += money // a[i]
            money -= a[i] * (money // a[i])
        elif a[i] > a[i+1]:
            money += a[i] * have
            have = 0
    money += have * a[-1]
    print(money)
   
    
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s = input()
t = input()

if s == t[:-1]:
    print('yes')
else:
    print('no')
# Judge status: Accepted
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [1000000000 for i in range(n)]
dp[0] = 0

for i in range(n):
    for j in range(k+1):
        if i+j<n:
            dp[i + j] = min(dp[i] + abs(h[i] - h[i + j]), dp[i + j])
print(dp[n-1])
# Judge status: Wrong Answer
x = int(input())
c = 2 * (x // 11)
if x - 11 * (x // 11) > 5:
    c += 2
else:
    c += 1
print(c)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1

# print(num_four, num_two, num_odd)

v = num_four * 3
if num_two in [2, 3]:
    v += num_two
if num_two >= 4:
    v += num_two + (num_two - 2) // 2
ans = 'Yes' if v >= N else 'No'
print(ans)

# 2 2 o 2 2 o 2 2 o 2 2
# o 4 o o 4 o o 4 o  2 2 o 2 2
# Judge status: Accepted
n, k = map(int, input().split())
h = list(map(int, input().split()))
monster = sorted(h, reverse=True)
surviver = monster[k:len(monster)]
print(sum(surviver))
# Judge status: Wrong Answer
n = int(input())
time=0
alist=[]
ans='Yes'
for i in range(n):
  a,b=map(int, input().split())
  alist.append([a,b-a])
  if b<a:
    ans='No'
alist.sort(key=lambda x: x[1])
time=0
for i in range(n):
  if time>alist[i][1]:
    ans='No'
  time+=alist[i][0]
print(ans)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

l= []
while(len(l)<=a):
    for _ in range(b):
        l.append(1)
    for _ in range(c):
        l.append(0)
        
print(l[:8].count(1))
# Judge status: Accepted
import sys
readline = sys.stdin.readline

X = int(readline())

limit = 600
rank = 8
for i in range(8):
  if X < limit:
    print(rank)
    break
  limit += 200
  rank -= 1
# Judge status: Accepted
x, y = map(int, input().split())
l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]

if (x in l1 and y in l1) or (x in l2 and y in l2):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split())) # 横入力

x = [0]
aaa = 0
for i in range(n):
    aaa += a[i]
    x.append(aaa)
aa = sum(a)
y = [aa]
for i in range(n):
    aa -= a[i]
    y.append(aa)

ans = 202020202020
for i in range(n+1):
    ans = min(ans, abs(x[i] - y[i]))

print(ans)
# Judge status: Wrong Answer
n,m = list(map(int,input().strip().split()))

# 2次元配列
student = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    student.append(array)

cp = []
for i in range(m):
    array = list(map(int, input().strip().split()))
    cp.append(array)

result = [0] * n
for i in range(n):
  dis_min = 10**8
  for j in range(m):
    dis = abs(student[i][0]-cp[j][0]) + abs(student[i][1] - cp[j][1])
    if dis < dis_min:
      dis_min = dis
      result[i] = j+1

for i in result:
  print(i)
# Judge status: Accepted
def main():
    S = int(input())
    x1, y1 = (0, 0)
    x2, y2 = (10**9, 1)

    x3 = (x2 - S%x2)%x2
    y3 = (S+x3)//x2

    print(x1, y1, x2, y2, x3, y3)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
x = int(input())
c = x // 11
m = x % 11
cnt = 2 * (c + 1)
if m == 0:
    cnt -= 2
elif m < 6:
    cnt -= 1
print(cnt)
# Judge status: Accepted
N=int(input())
L=[2,1]
ans=0

for i in range(N):
    ans=L[i]+L[i+1]
    L.append(ans)
    
print(L[N])
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
cnt = 0

for i in range(N):
    cnt += B[A[i]-1]
    if i > 0 and ( A[i-1] + 1 ) == A[i]:
        cnt += C[A[i-1]-1]
print(cnt)
# Judge status: Accepted
x = int(input())
if x <= 6:
    print(1)
    exit()
a = x // 11
sum = 11 * a
i = 2 * a
if sum < x:
    if x - sum > 6:
        i += 1
    i += 1
    
print(i)
# Judge status: Wrong Answer
import fractions
num = int(input())
numarray = [int(i) for i in input().split(" ")]
num_gcd_max = 1

result_f = numarray[:] + [0]
result_t = [0] + numarray[:]
for i in range(num):
    result_f[num-i-1] = fractions.gcd(result_f[num-i], result_t[num-i])
    result_t[i+1] = fractions.gcd(result_t[i], result_t[i+1])

gcd_result = [0 for i in range(num)]
for i in range(num):
    gcd_result[i] = fractions.gcd(result_t[i], result_f[i+1])

print(max(gcd_result))
# Judge status: Accepted
s = list(input())
k = int(input())

for i, c in enumerate(s):
    t = (ord("z") - ord(c) + 1) % 26
    if k >= t:
        s[i] = "a"
        k -= t

t = k % 26
s[-1] = chr(ord(s[-1]) + t)

print("".join(s))
# Judge status: Accepted
n, k = map(int, input().split())
d = set(input().split())
for i in range(n, 10*n):
    for c in str(i):
        if c in d:
            break
    else:
        print(i)
        break
# Judge status: Accepted
import numpy as np

n = int(input())

a1 = np.array(list(map(int, input().split())))
a2 = np.array(list(map(int, input().split())))

a1_cumsum = np.cumsum(a1)
a2_cumsum = np.cumsum(a2)

#print(a1)
#print(a1_cumsum)
#print(a2)
#print(a2_cumsum)

ans = 0
for i in range(n) :
    sum = a1_cumsum[i] + a2_cumsum[n-1]
    if i != 0 :
        sum = sum - a2_cumsum[i-1]

    if sum > ans :
        ans = sum

print(ans)
# Judge status: Accepted
a,b,_=sorted(map(int,input().split()))
print(a*b//2)
# Judge status: Accepted
(N,K)= map(int,input().split())
p = list(map(int,input().split()))
p.sort()
total = 0
for i in range(K):
    total += p[i]
print(total)
# Judge status: Accepted
S = input()
s_cnt =0
t_cnt =0

for s in S:
    if s == 'S':
        s_cnt += 1
    else:
        if s_cnt >0:
            s_cnt -= 1
        else:
            t_cnt += 1
            
print(t_cnt + s_cnt)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()
K = 0

for i in range(N):
  if d[i] < N / 2:
    K += 1
    
print(K)
# Judge status: Accepted
x=int(input())
ans=0
cnt=1
while 1:
    ans+=1
    x-=cnt
    if x<=0:
        print(ans)
        exit()
    else:
        cnt+=1
# Judge status: Accepted
n = int(input())
l = {int(i) for i in input().split() if int(i)%2 == 0}
cnt = 0
for i in l:
    if (i%3 == 0) or (i%5 == 0):
        pass
    else:
         cnt += 1
if cnt == 0:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Wrong Answer
A, B, C = map (int, input().split())

if A * C < B:
    print(C)
elif A * C > B:
    print(B // A)
# Judge status: Wrong Answer
n=int(input())
c=list(range(1,n+1))
p=list(map(int,input().split()))
cnt=0

for i in range(n):
  cnt += 1 if c[i]!=p[i] else 0
  
print('Yes' if cnt==2 or cnt==0 else 'No')
# Judge status: Accepted
n = int(input())
for i in range(1, n+1):
    if n <= (i+1)*i//2:
        x = (i+1)*i//2 - n
        for j in range(1, i+1):
            if j != x:
                print(j)
        exit()
# Judge status: Accepted
n = int(input())
s = input()

r = 0
g = 0
b = 0

for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1
ans = r * g * b

for i in range(n):
    for j in range(min(i, n - 1 - i)):
        if s[i]!=s[i+j+1] and s[i]!=s[i-j-1] and s[i+j+1]!=s[i-j-1]:
            ans -= 1

print(ans)
# Judge status: Wrong Answer

S=input()
for i in range(len(S)-1):
  if S[i]==S[i+1]:
    flag=1
  else:
    flag=0

if flag==0:
  print("Good")
else:
  print("Bad")
# Judge status: Wrong Answer
s=int(input())
s=0
x=s
list=[]
for i in range(1000000000000000000):
    y=x%(-2)
    if y == -1:
        x = (x-1)//(-2)
        y = 1
    else:
        x=x//(-2)
    list.insert(0, y)
    if x == 0:
        print(*list, sep="")
        break
# Judge status: Accepted
a = int(input())
for i in range(1,361):
    if i * a % 360 == 0:
        print(int(i))
        break
# Judge status: Accepted
def resolve():
  s = input()
  t = input()
  s += s
  if t in s:
    print("Yes")
  else:
    print("No")
  return

if __name__ == "__main__":
  resolve()
# Judge status: Accepted
s = input()
if s[2:3] == s[3:4] and s[4:5] == s[5:6]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = list(input())
a = 0
for i in s:
    a += int(i)
if a%9==0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
li = list(map(int, input().split()))
ans = 0
for i in range(li[0]):
  i += 1
  s = sum(list(map(int, str(i))))
  if s >= li[1] and s <= li[2]: ans += s
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]==i+1:
        a[i],a[i+1]=a[i+1],a[i]
        ans+=1
print(ans)