peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def solve():
    def min2(x, y): return x if x <= y else y

    strN = '0' + input()

    Ns = list(map(int, strN))

    dp = [0, float('inf')]
    for Ni in reversed(Ns):
        dp2 = [0, 0]
        if Ni == 9:
            dp2[0] = dp[0] + Ni
        else:
            dp2[0] = min2(dp[0] + Ni, dp[1] + Ni + 1)
        dp2[1] = min2(dp[0] + 10 - Ni, dp[1] + 9 - Ni)
        dp = dp2

    print(dp[0])


solve()
# Judge status: Accepted
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    num = 0
    while num <= n:
        if (n - num) % 7 == 0:
            print('Yes')
            sys.exit()
        num += 4
    print('No')


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
N = list(str(n))
ans = str()
res = N[0]
mn = True
bl = True
for x in N:
    if int(res) < int(x):
        mn = False
    if x != res:
        bl = False
if bl:
    print(n)
else:
    if not mn:
        for i in range(len(N)):
            ans += str(int(res) + 1)
        print(ans)
    else:
        for i in range(len(N)):
            ans += str(res)
        print(ans)
# Judge status: Accepted
import collections
N = int(input())
ans = [0] * N

for i in range(N):
  ans[i] = int(input())
  
C = collections.Counter(ans)
count = 0
for i in C.values():
  if i % 2 == 1:
    count += 1
  
print(count)
# Judge status: Accepted
H,n=map(int,input().split())
List=map(int,input().split())
A=sum(List)

if H <= A:
    print("Yes")

else:
    print("No")
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
def main():
    S = list(input().rstrip())
    A, B, C = 0, 0, 0
    for s in S:
        if s == 'a':
            A += 1
        if s == 'b':
            B += 1
        if s == 'c':
            C += 1
    if len(S) == 1:
        print("NO")
    elif abs(A-B) <= 1 and abs(B-C) <= 1 and abs(C-A) <= 1:
        print("YES")
    else:
        print('NO')

if __name__ == '__main__':
    main()
# Judge status: Accepted
n,r=map(int,input().split())
b=1
while n//r!=0:
    n//=r
    b+=1
print(b)
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if k<=a:
  ans=k
elif k<=a+b:
  ans=a
else:
  ans=a-(k-a-b)
print(ans)
# Judge status: Accepted
x, y = map(int, input().split())


ans = 10**10
if x <= y:
    ans = min(ans, y - x)

if -x <= y:
    ans = min(ans, 1 + y + x)

if x <= -y:
    ans = min(ans, 1 - y - x)

if -x <= -y:
    ans = min(ans, 2 - y + x)

print(ans)
# Judge status: Accepted
s = input()
N = len(s)
a = 0
for x in range(0,N,2):
    if s[x] == "L":
        a = 1
for x in range(1,N,2):
    if s[x] == "R":
        a = 1
if a == 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
a_lst = list(map(int,input().split()))

d = {}

for i in range(n):
    d[a_lst[i]] = i+1

d_sort = sorted(d.items(), key=lambda x : x[0])

ans_lst = []
for item in d_sort:
    ans_lst.append(item[1])

print(ans_lst)
# Judge status: Wrong Answer
A,B,X = list(map(int,input().split()))
print('YES' if X-A <= B else 'NO')
# Judge status: Accepted
print(8-(int(input())-400)//200)
# Judge status: Accepted
N = int(input())

if 1000 - N % 1000 == 1000:
  print(0)
else:
  print(1000 - N % 1000)
# Judge status: Accepted
N = int(input())
print(N // 2) if N % 2 == 0 else print(N // 2 + 1)
# Judge status: Accepted
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
W = [input() for _ in range(N)]

s = W[0][-1]

ok = True
used = set()
used.add(W[0])
for w in W[1:]:
    if s != w[0] or w in used:
        ok = False

    s = w[-1]
    used.add(w)

print("Yes" if ok else "No")
# Judge status: Wrong Answer
N,L = map(int,input().split())

s = 0
for i in range(1,N+1):
    s += L+i-1

if L >= 0:
    eat = L
elif L-N < 0:
    eat =  L+N-1
else:
    eat = 0

print(s-eat)
# Judge status: Accepted
import sys
import itertools

def main():
  x, y, a, b, c = map(int, sys.stdin.buffer.readline().split())
  red = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True)
  green = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True)
  colorless = sorted(map(int, sys.stdin.buffer.readline().split()), reverse=True)
  
  apples = sorted(itertools.chain(red[:x], green[:y], colorless), reverse=True)
  print(sum(apples[:x + y]))

main()
# Judge status: Accepted
from bisect import bisect_right
n=int(input())
A=[int(input()) for _ in range(n)][::-1]

DP=[A[0]]
for i in range(1,n):
    num=A[i]
    if DP[-1]<=num:
        DP.append(num)
    else:
        index=bisect_right(DP,num)
        DP[index]=num
print(len(DP))
# Judge status: Wrong Answer
x,y=map(int,input().split())
print(x*(y/2))
# Judge status: Accepted
# -*- coding: utf-8 -*-

X, Y = map(int, input().split())

if X % Y == 0:
    print(-1)
else:
    print(X)
# Judge status: Accepted
S=input()
if S[-1]=='s':
  print(S+'es')
else:
  print(S+'s')
# Judge status: Wrong Answer
n, m = map(int, input().split())
ans1 = 1
ans2 = 1
mod = 10**9 + 7

if abs(n-m) > 2:
    print(0)
    exit()


for i in range(1, n+1):
    ans1 *= i
    ans1 %= mod
for j in range(1, m+1):
    ans2 *= j
    ans2 %= mod

if abs(m-n) == 1:
    print(ans1 * ans2 % mod)
else:
    print(2 * ans1 * ans2 % mod)
# Judge status: Accepted
L, R = map(int, input().split())
MOD = 2019
INF = 10**5
ans = INF


if 2019 <= R-L:
    print(0)
else:
    x = L % MOD
    y = R % MOD
    if x < y:
        for i in range(x, y):
            for j in range(i+1, y+1):
                ans = min(ans, (i*j) % MOD)
            if ans == 0:
                break
        print(ans)
    else:
        print(0)
# Judge status: Accepted
n = int(input())
l = []

for i in range(n):
    l.append(int(input()))

l.sort()
ans = sum(l)

if ans%10 == 0:
    for i in range(n):
        if l[i]%10 != 0:
            ans -= l[i]
            break

    else:
        ans = 0

print(ans)
# Judge status: Accepted
s = input()
k = int(input())
for i in range(k):
    if s[i] != "1":
        print(s[i])
        exit()
print(1)
# Judge status: Wrong Answer
a1 = [1,3,5,7,8,10,12]
a2 = [4,6,9,11]
a3 = [2]

x,y = list(map(int,input().strip().split()))

if x in a1:
  _x = 0
elif x in a1:
  _x = 1
else:
  _x = 2
if y in a1:
  _y = 0
elif y in a1:
  _y = 1
else:
  _y = 2
  
if _x == _y:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(n-2):
        if s[j] == "." and s[j+1] == "." and s[j+2] == ".":
            print("Yes")
            quit()
    print("No")
# Judge status: Wrong Answer
A, B = map(int, input().split())
if A + B <= 23:
  print(A + B)
else:
  print(24 - A + B)
# Judge status: Accepted
n=int(input())
a=[int(input()) for i in range(n)]
ans=1
res=1
for i in range(n):
  if a[res-1]==2:
    print(ans)
    exit()
  else:
    ans+=1
    res=a[res-1]
print(-1)
# Judge status: Accepted
n,r = map(int,input().split())
if n>=10:
  print(r)
else:
  print(r+100*(10-n))
# Judge status: Accepted
n = int(input())
a = [0]+list(map(int,input().split()))
x = [0]*(n+1)
for i in range(n,0,-1):
    buf = 0
    for j in range(1,n//i+1):
        buf += x[i*j]
    if buf%2!=a[i]:x[i]=1
x = x[1:]
m = 0
b = []
for i in range(n):
    if x[i]==1:
        b.append(i+1)
        m+=1
print(m)
print(*b)
# Judge status: Wrong Answer
N, X = map(int, input().split())
L = list(map(int, input().split()))

d = 0
c = 0
while d <= X:
    c += 1
    d += L[c-1]
    if c >= N:
        break
print(c)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
x=sorted(l)
m=(x[n//2]+x[n//2-1])/2
for y in l:
  if y<m:
    print(x[n//2])
  else:
    print(x[n//2-1])
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n+1):
	if i % 3 == 0 or i % 5 == 0:
		continue
	else:
		ans += i
print(ans)
# Judge status: Wrong Answer
import numpy as np
import itertools
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


k = int(input())
a = np.array(range(1, k+1))
#print(a)

comb = list(itertools.combinations_with_replacement(a, 3))
#print(comb)


ans = 0
for elm in comb:
    if elm[0] == elm[1] == elm[2]:
        #print(elm)
        ans += gcd(elm[0], elm[1], elm[2])
    else:
        ans += gcd(elm[0], elm[1], elm[2]) * 3
print(ans)
# Judge status: Accepted
from collections import deque

s = {}

s = {
    "a": deque(list(input())),
    "b": deque(list(input())),
    "c": deque(list(input())),
}

t = "a"

while s[t]:
    t = s[t].popleft()

print(t.upper())
# Judge status: Accepted
n,k = map(int, input().split())

al = list(map(int, input().split())) 

if n==k:
    print(1)
    exit()
    
x = 1+(n-k)//(k-1)
y = (n-k)%(k-1)

if y >0:
    print(x+1)
else:
    print(x)
# Judge status: Accepted
N = int(input())

# import time
# start = time.time()

import math
from functools import reduce



def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
for a in range(1,N+1):
    for b in range(1,N+1):
        for c in range(1,N+1):
            ans+=gcd(a,b,c)
print(ans)
# Judge status: Accepted
a,b,k=map(int,input().split())
if a+k-1>=b-k+1:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
# Judge status: Wrong Answer
n = int(input())
ans = []
if n == 1:
    ans.append(1)
elif n == 2:
    ans.append(2)
else:
    c = n // 2 + 1
    ans.append(c)
    ans.append(n-c)

print("\n".join(list(map(str, ans))))
# Judge status: Wrong Answer
from math import sqrt

person = int(input())
longs = list(map(int, input().split(" ")))

sum = 0
for i in range(person):
    for j in range(i, min(i + longs[i], person)):
        if (j - i) == longs[i] + longs[j]:
            sum += 1
print(sum)
# Judge status: Accepted
K, S = [int(i) for i in input().split()]

count = 0
for i in range(0, K+1):
    for j in range(0, K+1):
        k = S - i -j
        if 0 <= k <= K:
            count += 1
print(count)
# Judge status: Wrong Answer

a=int(input())
b=int(input())
h=int(input())

print((a+b)*h/2)
# Judge status: Accepted
n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]

ans = 'No'
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if all([A[i + k][j:j + m] == B[k] for k in range(m)]):
            ans = 'Yes'
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
print(a*b if 1 <= a <=9 and 1 <= b <= 9 else '-1')
# Judge status: Wrong Answer
a,b = map(int,input().split())
s = list(input())
if len(s)==a+b+1 and s[a]=='-':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
# 2020/01/23
# AtCoder Beginner Contest 144 - C

# Input
n = int(input())

nsq = int(n ** (1/2)) + 1

x = nsq
y = nsq

while x >= 1:
    if n % x == 0:
        ans = (x - 1) + int( (n / x) - 1)
        break
    else:
        x = x - 1

# Output
print(ans)
# Judge status: Wrong Answer
import math
n, k = map(int, input().split())
aas = list(map(int, input().split()))
diff = pow(10,-6)
left = 1
right = 10**9
def judge(mid):
    cut = 0
    for i in aas:
        cut += math.ceil(i / mid) - 1
    if cut <= k:
        return True
    else:
        return False
while left < right:
    mid = (left + right) / 2
    if (left <= right <= left + diff) or (right <= left <= right + diff):
        break
    elif judge(mid):
        right = mid
    else:
        left = mid
print(int(right))
# Judge status: Accepted
n, a, b = map(int, input().split())
if (b-a)%2 == 0 :
    print((b-a)//2)
else :
    print((b-a)//2 + min(a-1,n-b) + 1)
# Judge status: Accepted
candy = list(map(int, input().split()))

if candy.count(sum(candy)/2) == 1:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n,h=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
c=[0]*2
c[0]=h
c[1]=len(a)
for k in range(0,min(c)):
  a[k]=0
print(sum(a))
# Judge status: Accepted
n = int(input())
a = sorted(map(int, input().split()))
print(sum(map(lambda a, b: abs(a + b), a[::2], a[1::2])) + (a[-1] if n % 2 == 1 else 0))
# Judge status: Accepted
a, b, x = map(int, input().split())
if a%x == 0:
    print(b//x-a//x+1)
else:
    print(b//x-a//x)
# Judge status: Wrong Answer
n = int(input())
a = list( map(int,input().split()) )
a.sort()

ans = a[0]
for i in range(1,n):
  x = a[i] % ans
  if x == 0 :
    continue
  else :
    ans = min( x , ans )

print(ans)
# Judge status: Wrong Answer
a, b = input().split()
if a<=b:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

ans = sum(a[1:2*n+1:2])
print(ans)
# Judge status: Wrong Answer
def main():
    n = int(input())
    s = input()
    black = s.count("#")
    ans, white = black, 0
    for i in range(n):
        if s[i] == ".":
            white += 1
        else:
            black -= 1
        tmp = n - black - white
        if tmp < ans:
            ans = tmp
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
from collections import Counter
s = sorted(list(Counter(list(input())).values()))[::-1]
if len(s)==1:
  print("NO")
  exit()
a = s[0]
for i in s:
  if a==i or a==i+1:
    continue
  else:
    print('NO')
else:
  print("YES")
# Judge status: Wrong Answer
n,m = map(int,input().split())
ma = [[False]*n for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    ma[a-1][b-1] = True
    ma[b-1][a-1] = True
flag = False
for row in ma:
    for i,r in enumerate(row):
        if r:
            if ma[i][n-1]:
                flag = True
if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
K = int(input())
S = input()
s = len(S)

if s <= K:
  print(S)
else:
  print(S[:K+1] + "...")
# Judge status: Wrong Answer
import math
N,M = map(int,input().split())
if(N == 1 or M == 1):
  print("0")
else:
  print(str(((math.factorial(N) * math.factorial(M)) % (10 ** 9 + 7))))
# Judge status: Accepted
N, X = map(int, input().split())
L = list(map(int, input().split()))

tmp = 0
count = 0
for l in L:
    if tmp <= X:
        count += 1
    tmp += l

if tmp <= X:
    count += 1

print (count)
# Judge status: Accepted
S,T=input().split()
A,B=map(int,input().split())
U=input()
if U==S:
  A-=1
elif U==T:
  B-=1
print(A,B)
# Judge status: Accepted
def main():
    k = int(input())
    s = input()
    s_len = len(s)
    
    if s_len <= k:
        print(s)
    else:
        s = s[0:k] + '...'
        print(s)
    
main()
# Judge status: Accepted
def main():
    S=int(input())

    mod=10**9+7

    resList=[1,0,0,1,1,1]
    n=6
    if S>=n:
        for i in range(n,S+1):
            resList.append(resList[i-1]+resList[i-3])
        print(resList[len(resList)-1]%mod)
    else:
        print(resList[S])




if __name__=="__main__":
    main()
# Judge status: Wrong Answer
A = sorted(list(map(int,input().split())))
N = int(input())
A[-1] = A[-1]**N
print(sum(A))
# Judge status: Wrong Answer
s = list(input())
if len(s) == len(set(s)):
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))+[float('inf')]
ans = 0
for i in range(N-1):
  ans+=min(A[i],A[i+1])
print(ans)
# Judge status: Accepted
N = input()
l = len(N)-1
print(N if l == 0 else int(N[0]) + 9*l if N[1:] == '9'*l else int(N[0]) - 1 + 9*l)
# Judge status: Wrong Answer
S = list(input())
c = [0, 0]
n = 0
s = ""
for i in range(len(S)):
  if s == "":
    s = S[i]
    n = 1
  elif s == S[i]:
    n += 1
  else:
    if n > 1:
      if S[i] == "<": c[0] += n
      else: c[1] += n
    n = 1
    s = S[i]

if n > 1:
  if S[i] == "<": c[0] += n
  else: c[1] += n
c = max(c)
print(c * (c + 1) // 2)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
total = sum(A)
print('Yes' if M <= len(list(filter(lambda x: x, map(lambda x: x * 4 * M >= total, A)))) else 'No')
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

ans = 0
hist = []
for _t in t:
    h = ""
    if len(hist) >= k:
        h = hist.pop(0)

    if _t == "r" and h != "p":
        ans += p
        hist.append("p")
    elif _t == "s" and h != "r":
        ans += r
        hist.append("r")
    elif _t == "p" and h != "s":
        ans += s
        hist.append("s")
    else:
        hist.append("")

print(ans)
# Judge status: Wrong Answer
N=int(input())
D=list(map(int,input().split()))
mod=998244353

if D[0]!=0:
    print(0)
    exit()


B=[0]*N
for d in D:
    B[d]+=1
if B[0]!=1:
    print(0)
    exit()

ans=1
total=1
for i in range(1,N):
    if B[i]==0:
        if total!=N:
            print(0)
            exit()
        else:break
    total+=B[i]
    ans*=(B[i-1]**B[i])%mod

print(ans)
# Judge status: Accepted
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n=int(input())
A=list(map(int,input().split()))
A.sort()
cur=(A[0]+A[1])/2

for i in range(2,n):
    cur=(cur+A[i])/2
print(cur)
# Judge status: Accepted
s = list(map(str, input()))
n = len(s) - 1
for i in range(2**n):
    ans = s[0]
    for j in range(n):
        if ( i >> j ) & 1 :
            ans += "+" + s[j+1]
        else:
             ans += "-" + s[j+1]   
        if j == n-1:
            if eval(ans) == 7:
                print(ans+"=7")
                exit()
# Judge status: Wrong Answer
N = int(input())

dots = []
for _ in range(N):
    dots.append(list(map(int,input().split())))

max = 0
for i in range(N):
    for j in range(i+1,N):
        dist = abs(dots[i][0]-dots[j][0])+abs(dots[i][0]-dots[j][0])
        if dist > max:
            max = dist

print(max)
# Judge status: Accepted
N = int(input())
S = input()

maxv = 0
tmp = 0

for i in S:
    if i == 'I':
        tmp += 1
    else:
        tmp -= 1

    if maxv < tmp:
        maxv = tmp

print(maxv)
# Judge status: Wrong Answer
*ABC, = map(int, input().split())
K = int(input())
print(sum(ABC) - max(ABC) + (max(ABC) * 2 * K))
# Judge status: Wrong Answer
A= [int(input()) for i in range(6)]
answer = "Yay!"
for u in range(4):
  for s in range(u,4):
    if A[s] - A[u] > A[5]:
      answer = ":("
print(answer)
# Judge status: Wrong Answer
import math
x,y = map(int,input().split())
print(math.floor(math.log2(y/x))+1)
# Judge status: Wrong Answer

a,b = map(int,input().split())

if a > 0:
    print("Pssitive")
elif a <= 0 and 0 <= b:
    print("Zero")
elif b < 0:
    if abs(b-a) % 2 == 1:
        print("Positive")
    else:
        print("Negative")
# Judge status: Wrong Answer
number=[]
a=input().split()
b=input().split()
c=input().split()
lista=[int(d) for d in a]
listb=[int(e) for e in b]
listc=[int(f) for f in c]
if (sum(lista)+sum(listb)+sum(listc))%3==0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from math import atan,pi
A,B,X=map(int,input().split())

if 2*X>=A*A*B:
    P=atan(2*(A*A*B-X)/(A*A*A))*180/pi
    print(P)
else:
    Q=atan((A*B*B)/(2*X))*180/pi
    print(Q)
# Judge status: Accepted
c = []
for i in range(3):
    c.append(list(map(int, input().split(" "))))

f = "No"
for a1 in range(101):
    for a2 in range(101):
         for a3 in range(101):
            if (c[0][0] - a1 == c[0][1] - a2 == c[0][2] - a3
                and c[1][0] - a1 == c[1][1] - a2 == c[1][2] - a3
                and c[2][0] - a1 == c[2][1] - a2 == c[2][2] - a3):
                f = "Yes"

print(f)
# Judge status: Accepted
#!/usr/bin/env python3
import bisect
import math

n, h = map(int, input().split())
a, b = [0] * n, [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
max_a = max(a)
b.sort()
idx = bisect.bisect_right(b, max_a)
ans = 0
tmp = 0
for i in range(n - 1, -1, -1):
    tmp += b[i]
    if tmp >= h:
        print(n - i)
        exit()
    if i <= idx:
        break

print(n - idx + math.ceil((h - sum(b[idx:])) / max_a))
# Judge status: Accepted
a,b,x=map(int,input().split())

print("YES"if a<=x and a+b>=x else"NO")
# Judge status: Accepted
a=int(input())
list=map(int,input().split())
list2=[]
list3=[]
for x in list:
    if x%2==0:
        list2.append(x)
for y in list2:
    if y%3!=0 and y%5!=0:
        list3.append(y)
s=len(list3)
if s==0:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Accepted
N,L = map(int,input().split())
A = []

for i in range(N):
  s = input()
  A.append(s)
A.sort()
print("".join(A))
# Judge status: Wrong Answer
n, m = map(int, input().split())
array = [None] * n
for i in range(m):
  keta, num = map(int, input().split())
  if n >= 2 and keta == 1 and num == 0:
    print(-1)
    break
  if array[keta-1] != None and array[keta-1] != num:
    print(-1)
    break
  array[keta-1] = num
  
  if i == m-1:
    ans = 0
    for k in range(n):
      if array[k] != None:
        ans += 10**(n-1-k)*array[k]
    print(ans)
# Judge status: Wrong Answer
s=input()
t=input()
ss=s+s
if t in s:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
K,X=map(int,input().split())
k=[]
for i in range ((X-K+1),(X+K),1):
    k.append(i)
print(k)
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h_list = list(map(int, input().split()))
ans = 0
for i in range(n):
    if abs(a - (t - h_list[i] * 0.006)) < abs(a - (t - h_list[ans] * 0.006)):
        ans = i
print(ans + 1)
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))

ans = 'Yes'
for i in range(1, N):
  if H[N-i-1]-1 == H[N-i]:
    H[N-i-1] -= 1
  elif H[N-i-1]-1 > H[N-i]:
    ans = 'No'
    break
    
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
x=1
ans=0
for i in a:
  if i!=x:
    ans+=1
  else:
    x+=1
print(ans)
# Judge status: Wrong Answer
def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	return lst3

def resolve():
	n = int(input())
	h = []
	for i in range(n):
		h.append(input())
	sec = h[0]
	for i in range(1, n):
		sec = intersection(sec, h[i])
	print("".join(sorted(sec)))
resolve()
# Judge status: Wrong Answer
import numpy as np

a, b, c, d = map(int, input().split())

print(max(np.abs([(a*c), (a*d), (b*c), (b*d)])))
# Judge status: Accepted
import sys
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x = 0
y = 0
t = 0
for i in range(n):
    if abs(a[i][1] - x) + abs(a[i][2] - y) > abs(a[i][0] - t) or (a[i][1] - x + a[i][2] - y) % 2 != (a[i][0] - t) % 2:
        print('No')
        sys.exit()
    else:
        x = a[i][1]
        y = a[i][2]
        t = a[i][0]
print('Yes')
# Judge status: Accepted
s,w = map(int,input().split())
print("safe" if s > w else "unsafe")
# Judge status: Wrong Answer
S = input()

S = list(S)

from collections import Counter
c = Counter(S)
keys, values = zip(*c.most_common())

print(2*min(values))
# Judge status: Accepted
N = int(input())
S = input()
T = input()
for i in range(N, 0, -1):
    if S[-i:] == T[:i]:
        print(2 * N - i)
        break
else:
    print(2 * N)
# Judge status: Wrong Answer
N = int(input())
A = int(input())

ans = 0


while ans<(N-500):
    ans += 500

while A>0:
    ans += 1
    A -= 1
    if ans==N:
        print('Yes')
        break

if ans!=N:
    print('No')
# Judge status: Accepted
n = int(input())

s = 0
i = 0
while s < n:
    s += i
    i += 1

if i == 1:
    print(1)
else:
    ans = list(range(1,i))
    if s - n != 0: ans.remove(s-n)
    print('\n'.join(map(str,ans)))
# Judge status: Accepted
N, M = map(int, input().split())
l = [False]*N
for _ in range(M):
    a = list(map(int, input().split()))
    j = [1,N]
    for i in [0,1]:
        if a[i] == j[i]:
            if l[a[1-i]-1]:
                print('POSSIBLE')
                exit()
            else:
                l[a[1-i]-1] = True
print('IMPOSSIBLE')
# Judge status: Wrong Answer
N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

A.sort(key=lambda x:x[0])

money = 0
cnt = 0
for i in range(N):
    for j in range(A[i][1]):
        money += A[i][0]
        if cnt == N:
            print(money)
            break