peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
L, R = map(int, input().split())
mod = 2019

if R - L >= 2019 or L == 0:
    print(0)
else:
    ans = False
    for i in range(R - L):
        for j in range(i + 1, R - L + 1):
            if ans is not False:
                ans = min(ans, (L + i) * (L + j) % mod)
            else:
                ans = (L + i) * (L + j) % mod
    print(ans)
# Judge status: Accepted
from math import ceil
N, *A= [int(input()) for _ in range(6)]
print(ceil(N/min(A))+4)
# Judge status: Accepted
n, d = map(int, input().split())
x_y = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for x, y in x_y:
    dist = (x*x+y*y)**.5
    if dist <= d:
        ans += 1
print(ans)
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
l=[None]*M
for i in range(M):
    P,Y=map(int,input().split())
    l[i]=(P,Y,i)
l.sort()
a=[None]*M
s=0
t=1
for i in l:
    if i[0]==s:
        t+=1
    else:
        t=1
        s=i[0]
    a[i[2]]="{:06d}".format(i[0]) + "{:06d}".format(t)
print(*a,sep="\n")
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = input()
t = input()
ans = []
for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
        if s[i + j] not in ('?', t[j]):
            break
    else:
        memo = s[:i] + t + s[i + len(t):]
        ans.append(memo.replace('?', 'a'))
if ans:
    print(min(ans))
    exit()
print('UNRESTORABLE')
# Judge status: Wrong Answer
N,W = map(int,input().rstrip().split(" "))
wv = [[0,0,0] for _ in range(N)]
ans = [0,0]
for i in range(N):
  p = list(map(int,input().rstrip().split(" ")))
  wv[i][1] = p[0]
  wv[i][2] = p[1]
  wv[i][0] = p[1] / p[0]
wv.sort()
wv.reverse()
for i in range(N):
  if wv[i][1] + ans[0] < W:
    ans[0] += wv[i][1]
    ans[1] += wv[i][2]
print(ans[1])
# Judge status: Accepted
x, y = map(int, input().split())

a = (2 * x - y) // 3
b = (2 * y - x) // 3
rent_a = (2 * x - y) % 3
rent_b = (2 * y - x) % 3

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

if a < 0 or b < 0:
    ans = 0
elif rent_a != 0 or rent_b != 0:
    ans = 0
else:
    n = a + b
    ans = combination(n, a)

print(ans)
# Judge status: Accepted
S,C=map(int,input().split())
ANS = 0
if S * 2 <= C:
  ANS = S
  C -= (S*2)
  #rint(C)
  ANS += (C//4)
  print(ANS)
else:
  ANS = C // 2
  print(ANS)
# Judge status: Wrong Answer
n,m=map(int,input().split())
for i in range(1,int(m**.5)+2)[::-1]:
    if m%i==0 and m/n>=i:print(i);break
# Judge status: Wrong Answer
d,t,s=map(int,input().split())
if 1000/t>s:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
n,t = map(int, input().split())
a = []
for i in range(n):
    aa = list(map(int, input().split()))
    a.append(aa)

cost = float(10000)
for a in a:
    if a[1] <= t and a[0] < cost:
        cost = a[0]

if cost == 10000:
    cost = 'TLE'
print(cost)
# Judge status: Accepted
import sys
input=sys.stdin.buffer.readline
H,N = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
dp = [10000000000]*(H+1)
dp[0] = 0
for i in range(1,H+1):
    for j in range(N):
        A = ab[j][0]
        B = ab[j][1]
        if i - A < 0:
            dp[i] = min(dp[i],dp[0]+B)
        else:
            dp[i] = min(dp[i],dp[i-A]+B)
print(dp[H])
# Judge status: Accepted
S = input()
s = "keyence"
ans = "NO"

for i in range(len(S)):
  if s == S[:i] + S[len(S)-len(s)+i:]:
    ans = "YES"
    
print(ans)
# Judge status: Accepted
N = int(input())
P = list(map(int,input().split()))

min = P[0]
cnt = 1

for i in range(1,N):
 
    
 if min > P[i]:
     min = P[i]
     cnt +=1
 else:
     min = min
     
print(cnt)
# Judge status: Wrong Answer
S = input()
T = input()

l = len(S)
count = 0

for i in range(l):
    for j in range(l):
        if i+j >= l:
            if S[i+j-l] == T[j]:
                count += 1
            else:
                break
        else:
            if S[i+j] == T[j]:
                count += 1
            else:
                break

    if count == l:
        print('Yes')
        exit()

print('No')
# Judge status: Accepted
x,y=map(int,input().split())
if y==0:print(x);exit()
l=list(map(int,input().split()))
work=x
if not work in l:
    print(work)
    exit()
i=1
while 1:
    if not work-i in l:
        print(work-i)
        exit()
    if not work+i in l:
        print(work+i)
        exit()
    i+=1
# Judge status: Accepted
a,b = map(int,input().split())
print(a+(b//2))
# Judge status: Accepted
heart_taka, power_taka, heart_aoki, power_aoki = map(int, input().split())

aliveTaka = True
aliveAoki = True
while (aliveTaka) and (aliveAoki):
    heart_aoki -= power_taka
    heart_taka -= power_aoki
    if heart_aoki <= 0:
        aliveAoki = False
    if heart_taka <= 0:
        aliveTaka = False

if aliveAoki == False:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input())
ans = 0
for i in range(1,N+1):
    if i%3==0 or i%5==0:
        continue
    ans += i
print(ans)
# Judge status: Accepted
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
T, X, Y = 0, 0, 0
result = "Yes"
for t, x, y in txy:
    d =  (x-X) + (y-Y)
    if t<d or (t-d)%2==1:
        result = "No"
        break
print(result)
# Judge status: Accepted
import math
from decimal import Decimal, ROUND_DOWN
def main():
    a,b = list(input().split())
    a = Decimal(a)
    b = Decimal(b)
    ans = a * b
    print(Decimal(ans).quantize(Decimal(1), rounding=ROUND_DOWN))

if __name__=='__main__':
    main()
# Judge status: Accepted
def main():
    n = int(input())
    dp = [[0 for i in range(10)] for i in range(10)]
    for i in range(1,n+1):
        h,t = int(str(i)[0]), int(str(i)[-1])
        dp[h][t] += 1
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += dp[i][j] * dp[j][i]
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
S=input()
T=input()
for i in range(len(S)):
  if S==T:
    print("Yes")
    exit()
  temp=S[-1]
  S=temp+S[0:4]
print("No")
# Judge status: Wrong Answer
X = int(input())

# for b in range(65, -64, -1):
for b in range(10000, -10000, -1):
    a = (X + b**5)**0.2
    # print('b a', b, a)
    if type(a) == complex:
        continue
    if a.is_integer():
        print(int(a), b)
        exit()
# Judge status: Wrong Answer
from collections import Counter
input()
lst = input().split()
dic = dict(Counter(lst))
x = max(list(dic.values())) - 1
if x:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
x = int(input())
if x ==7 or x == 5 or x == 3:
	print('YES')
else:
	print('NO')
# Judge status: Accepted
n, m = map(int, input().split())
total = (n+m) * (n+m-1) / 2
odd = n * m

result = int(total - odd)
print(result)
# Judge status: Accepted
from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
edges = [[]for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    edges[a].append(b)
    edges[b].append(a)

next_v = deque([0])
prev = [-1]*n
while next_v:
    v = next_v.popleft()
    for v2 in edges[v]:
        if prev[v2] != -1:
            continue
        prev[v2] = v+1
        next_v.append(v2)

print('Yes')
for x in prev[1:]:
    print(x)
# Judge status: Wrong Answer
import numpy as np

N = int(input())
A = list(map(int,input().split()))
print(np.argsort(A) + 1)
# Judge status: Accepted
K,N=map(int, input().split())
As=list(map(int, input().split()))
ans=K
m=0
for i in range(len(As)-1):
    if As[i+1]-As[i] > m:
        m=As[i+1]-As[i]
if As[0]+K-As[-1]>m:
    m=As[0]+K-As[-1]
print(ans-m)
# Judge status: Accepted
n=int(input())
dp=[0 for _ in range(n+1)]
for j in range(1,n+1):
    i = 1
    while j*i<=n:
        dp[j*i] += j*i
        i+=1

print(sum(dp))
# Judge status: Accepted
n = list(map(int, input().split()))[0]
x = list(map(int, input().split()))
m = 1000000009
for i in range(100):
    sum = 0
    for j in range(len(x)):
        sum += (i - x[j]) ** 2
    m = min([m, sum])
print(m)
# Judge status: Accepted
n = int(input())
A = []

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

sum_b = sum(B)
left = 0
for i in range(n-1):
    left += B[i]
    right = sum_b - left
    A.append(abs(right - left))
print(min(A))
# Judge status: Wrong Answer
S = input()
if int(S[:2]) == 0 or int(S[3:]) ==0:
    print('NA')
elif int(S[:2]) > 12 and int(S[3:]) >12:
    print('NA')
elif int(S[:2]) > 12 and int(S[3:]) <=12:
    print('YYMM')
elif int(S[:2]) <= 12 and int(S[3:]) >12:
    print('MMYY')
elif int(S[:2]) <= 12 and int(S[3:]) <= 12:
    print('AMBIGUOUS')
# Judge status: Accepted
N, A, B = map(int, input().split())
 
if A > B:
  print(0)
  exit()

if N == 1:
  if A == B:
    print(1)
    exit()
  else:
    print(0)
    exit()

print((N-2)*(B-A)+1)
# Judge status: Wrong Answer
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V-W <= 0:
  print("NO")
elif B-A <= 0:
  print("NO")
else:
  if ((B-A)/(V-W)) <= T:
    print("YES")
  else:
    print("NO")
# Judge status: Accepted
x=int(input())

if 400<=x<=599:
    a=8
elif 600<=x<=799:
    a=7
elif 800 <= x <= 999:
    a = 6
elif 1000 <= x <= 1199:
    a = 5
elif 1200 <= x <= 1399:
    a = 4
elif 1400 <= x <= 1599:
    a = 3
elif 1600 <= x <= 1799:
    a = 2
elif 1800 <= x <= 1999:
    a = 1

print(a)
# Judge status: Wrong Answer
import math
n=int(input())
y=pow(10,n)-100*(pow(9,n-1))
y=y%(pow(10,9)+7)
print(y)
# Judge status: Accepted
n = input()
ans = 0
for nn in n:
    ans += int(nn)
print('Yes') if ans%9 == 0 else print('No')
# Judge status: Accepted

n=int(input())
lx=[]
ly=[]
for i in range(n):
  x,y=map(int,input().split())
  lx.append(x+y)
  ly.append(x-y)
ax,bx,ay,by=max(lx),min(lx),max(ly),min(ly)
print(max(ax-bx,ay-by))
# Judge status: Accepted
S = input()
s = list(S)
if S == "RSR":
    print(1)
else:
    print(s.count('R'))
# Judge status: Accepted
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    A=LIST()
    for i in range(n-k):
        #print(A[i],A[i+k])
        if A[i]<A[i+k]:
            print('Yes')
        else:
            print('No')
        
    
    
if __name__ == '__main__':
    do()
# Judge status: Accepted
n, m = map(int, input().split())
if n > m:
  n, m = m, n
if n == 1:
  if m == 1:
    ans = 1
  else:
    ans = m - 2
else:
  ans = (n - 2) * (m - 2)
print(ans)
# Judge status: Accepted
import collections

n = int(input())
a = [int(input()) for i in range(n)]
m = sorted(list(set(a)))
c =collections.Counter(a)

t = [max(a)]*n

if c[max(a)] == 1:
    t[a.index(max(a))] = m[-2]

[print(i) for i in t]
# Judge status: Accepted
n=str(input())
if n[len(n)-1]=="3":
    print("bon")
elif n[len(n)-1]=="2" or n[len(n)-1]=="4" or n[len(n)-1]=="5" or n[len(n)-1]=="7" or n[len(n)-1]=="9":
    print("hon")
else:
    print("pon")
# Judge status: Accepted
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  s = list(map(int, list(input().strip())))
  odd1, odd0, even1, even0 = 0, 0, 0, 0
  for i in range(len(s)):
    if i%2 == 0:
      if s[i] == 0:
        even0 += 1
      else: 
        even1 += 1
    else:
      if s[i] == 0:
        odd0 += 1
      else:
        odd1 += 1
  print(min(even0+odd1, even1+odd0))

if __name__=='__main__':
  main()
# Judge status: Accepted
l=int(input())
l3=l/3
print(l3*l3*l3)
# Judge status: Accepted
D = int(input())
if D ==  25:
  a = 'Christmas'
elif D == 24:
  a = 'Christmas Eve'
elif D == 23:
  a = 'Christmas Eve Eve'
elif D == 22:
  a = 'Christmas Eve Eve Eve'
print(a)
# Judge status: Wrong Answer
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
# n = int(input())
n,x,y = map(int,input().split())
# A = list(map(int,input().split()))
# An = [list(map(int,input().split())) for i in range(n)]
l = np.zeros((n,n))
l[0][1] = 1
l[n-1][n-2] = 1
l[x-1][y-1] = 1
l[y-1][x-1] = 1
for i in range(n-3):
    l[i+1][i] = 1
    l[i+1][i+2] = 1

for j in range(n-1):
    print(np.count_nonzero(shortest_path(l)==j))
# Judge status: Wrong Answer
a, b = map(int, input().split())
x = a + b

print((x+1)/2)
# Judge status: Accepted
n,a,b = map(int,input().split())

sum1 = 0

for i in range(1,n+1):
  sum = 0
  N = list(str(i))
  for j in N:
    sum += int(j)
  
  if a<=sum <= b:
    sum1 += i
    
print(sum1)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
def main():
    K, X = map(int, input().split())
    LOWER = max(X - K + 1, -1000000)
    UPPER = min(X + K - 1, 1000000)
    print(LOWER)
    ans = [i for i in range(LOWER, UPPER+1)]
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
X, Y = map(int,input().split())
MOD = 10 ** 9 + 7


def calc_comb(n, k, mod):
    '''
        n が大きい場合に使う
    '''
    a = 1
    b = 1
    for i in range(1,k+1):
        a *= i
        a %= mod
        b *= n
        n -= 1
        b %= mod
    return b * pow(a, mod-2, mod) % mod

if (X+Y) % 3 != 0:
    print(0)
else:
    n = (2 * X - Y) // 3
    m = Y - 2 * n
    print(calc_comb(n+m,m, MOD))
# Judge status: Wrong Answer
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
l = c.most_common()
n, m = l[0]
ans = []
for i, j in l:
    if j == m:
        ans.append(i)
print(ans.sort())
# Judge status: Accepted

import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

def resolve():
    return 

N,W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range (N)]

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j>=wv[i][0]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]] + wv[i][1])
        else:
            dp[i+1][j] = max(dp[i][j], dp[i+1][j])

print(dp[N][W])
# Judge status: Accepted
import math
N = int(input())
def gcdtriple(a,b,c):
    return math.gcd(a, math.gcd(b,c))
ans = 0
for a in range(1, N+1):
    for b in range(1, a+1):
        for c in range(1, b+1):
            if a == b and b == c:
                ans += gcdtriple(a,b,c)
            elif a == b or b == c or c == a:
                ans += gcdtriple(a,b,c) * 3
            else:
                ans += gcdtriple(a,b,c) * 6
print(ans)
# Judge status: Wrong Answer
#26 A - Prefix and Suffix
N = int(input())
s = list(input())
t = list(input())
s_rev = list(reversed(s))

cnt = N
for i in range(1,N+1):
    # s の部分文字列を後ろから取り出す
    tgt = list(reversed(s_rev[:i]))
    if tgt == t[:i]:
        cnt -= 1
    else:
        break
    
if s == t:
    print(N)
else:
    ans = s[:cnt] + t
    print(len(ans))
# Judge status: Accepted
a,b,c=map(int,input().split())
k=int(input())
b_list=[]
c_list=[]

for i in range(k+1):
    b_list.append(b*(2**i))
    c_list.append(c*(2**i))

for j in range(k):
    if b_list[j]>a and c_list[k-j]>b_list[j]:
        print('Yes')
        break
else:
    print('No')
# Judge status: Accepted
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    x = int(input())
    T.append(x)
T.sort()
lim = 0
tim = 0
ans = 0
for i in range(N):
    if lim == 0:
        lim += 1
        tim = T[i]
    else:
        if tim + K >= T[i] and lim < C:
            lim += 1
        else:
            lim = 1
            tim = T[i]
            ans += 1

print(ans+1)
# Judge status: Accepted
n=int(input())
w=[input() for _ in range(n)]
for i in range(n-1):
	if	w[i][-1] != w[i+1][0]:
		print('No')
		exit(0)
	else:
		pass
if len(set(w)) == len(w):
	print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
n,k = map(int,input().split())
d = list(map(str, input().split()))
for i in range(n,10001):
    for j in d:
        if j in str(i):
            break
    else:
        print (i)
        exit ()
# Judge status: Accepted
n = int(input())

a_list = list(map(int, input().split()))
a_list.sort()
a_max = a_list[n - 1]
temp_max = [1, 0]
bunbo = 1
bunshi = 1
center = int((a_max + 1) / 2)
a_set = set(a_list)
diff_min = a_max
ans = 0
for a in a_set:
    diff = abs(a-center)
    if diff_min > diff:
        diff_min = diff
        ans = a

print(a_max, ans)
# Judge status: Accepted
a,b,c,d = input()
if (a==b)or(b==c)or(c==d):
    print("Bad")
else : print("Good")
# Judge status: Wrong Answer
first_string = "abcde"
second_string = "abcfd"
count = 0

for x, y in zip(first_string, range(len(first_string))):
    if(second_string[y] != x):
        count += 1
print(count)
# Judge status: Accepted
N=int(input())


a = []

for i in range(N):
    a.append(int(input()))
# a=[0]*N
# for i in range(N):
#   a[i]=int(input())
count=0

#loopの定義→同じインデックスを使用したらloop判定
#in の処理を爆速で実行するためにsetを使用する
#loop=[]
loop=set()

tmp=1
while True:  
  tmp=a[tmp-1]
  count+=1
  if tmp==2:
    print(count)
    exit()
  if tmp-1 in loop:
    print(-1)
    exit()
  #loop.append(tmp-1)
  loop.add(tmp-1)
# Judge status: Accepted
n = int(input())
square = [i ** 2 for i in range(1, int(n**0.5)+1)]
print(max(square))
# Judge status: Accepted
N,A = map(int, open(0).read().split())
print('Yes' if N % 500 <= A else 'No')
# Judge status: Accepted
a,b,c = sorted(map(int,input().split()))

print(int(1/2*a*b))
# Judge status: Wrong Answer
P=2019
S = input()
N=len(S)

ans = 0
count = [0] * P
count[0] = 1
u = 0
for i, s in enumerate(reversed(S)):
  print(i,s)
  u = (int(s) * pow(10, i, P) + u) % P
  ans += count[u]
  count[u] += 1

print(ans)
# Judge status: Accepted
N = int(input())
v = list(map(int,input().split()))
v1 = v.sort()
ans=v[0]
for i in v[1:]:
    ans=(ans+i)/2
print(ans)
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

n = int(input())

if (n % 2 != 0):
    print (n//2+1)
else:
    print(n//2)
# Judge status: Accepted
def resolve():
    n = int(input())
    xdiv = int(n**0.5)
    for i in range(xdiv, 0, -1):
        if n % i ==0:
            dest = i + n//i
            print(dest-2)
            exit()
resolve()
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"

for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] = H[i+1]-1
    if H[i] > H[i+1]:
        ans = "No"
        break

print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

if a * b % 2 == 0:
        print('Even')
else :
        print('Odd')
# Judge status: Wrong Answer
import sys
S=input()
for i in range(1,len(S)):
  S=S[:-1]
  if len(S)%2==0:
    c=len(S)
    print(S[c//2+1:])
    print(S[:c//2])
    if S[:c//2]==S[c//2+1:]:
      print(i)
      sys.exit()
# Judge status: Accepted
r = int(input())
r = r**2
print(r)
# Judge status: Accepted
n, k, s = map(int, input().split())
A = [s]*k
if s == pow(10, 9):
    A += [1]*(n-k)
else:
    A += [s+1]*(n-k)
print(*A)
# Judge status: Wrong Answer
N,K = map(int,input().split())
tmp = 1
num_cnt = 0
while K > tmp :
  tmp *= 2
  num_cnt +=1
nums_list = []
for i in range(1,N+1):
  for j in range(num_cnt+1):
    if i*(2**j) > K:
      nums_list.append((1/2)**j)
      break
print(sum(nums_list)*(1/N))
# Judge status: Accepted
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    if N % 2:
        print(0)
        return

    ans = N // 10
    p = 50
    while True:
        tmp = N // p
        if tmp == 0:
            break
        ans += tmp
        p *= 5

    print(ans)
    return


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b,x = map(int,input().split())
import math
if a**2*b / 2 <  x:
    alpha = math.degrees(math.atan(2 * (a**2 * b - x) / a**3))
else:
    alpha =  math.degrees(math.atan((a*b**2)/2*x ))
    
print(alpha)
# Judge status: Wrong Answer
s = input()
s = s.replace("eraser", "X")
s = s.replace("dreamer", "X")
s = s.replace("erase", "X")
s = s.replace("dream", "X")
 
count = s.count("X")
if len(s) == count:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
w, h, x, y = map(int, input().split())
s = w * h / 2
if x * 2 == w and y * 2 == h:
    print(s, 1)
else:
    print(s, 0)
# Judge status: Accepted
import queue
s = str(input())
t = str(input())

for i in range(int(len(s))):
    if s == t:
        print("Yes")
        exit()
    else:
        tmp = s[0]
        s = s[1:]
        s = s + tmp
    
print("No")
# Judge status: Wrong Answer
s=input()
t="keyence"

ans=False
for i in range(len(t)):
    a=t[:i]
    b=t[i:]
    if s.find(a)==0 and s.find(b)!=-1:
        ans = True
        break

if ans is True:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
s=list(input())
s.sort()
if s[0]==s[1] and s[2]==s[3]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

hoge=0
for i in range(K):
    hoge += A[i]

re=hoge
for i in range(N-K):
    hoge=hoge+A[K+i]-A[i]
    if hoge >= re:
        re=hoge
        
print((re+K)/2)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

if n == len(set(a)):
  print('YES')
else:
  print('NO')
# Judge status: Accepted
b, c = map(int, input().split())
if b * c % 2 == 1:
  print("Odd")
else:
  print("Even")
# Judge status: Accepted
n = int(input())
x = []
for i in range(n):
    X,L = map(int, input().split())
    x.append([X-L,X+L])
x.sort(key=lambda x:x[0])
ans = n
tmp = x[0][1]
for i in range(1,n):
    if tmp>x[i][0]:
        ans -=1
        tmp = min(tmp,x[i][1])
    else:
        tmp = x[i][1]
print(ans)
# Judge status: Accepted
n,h = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

maxa = 0
for a,b in ab:
    maxa = max(maxa,a)

ab.sort(key = lambda x: x[1], reverse = True)

ans = 0

for a,b in ab:
    if h <= 0:
        break
    else:
        if maxa > b:
            break
        else:
            h -= b
            ans += 1

if h > 0:
    ans += -(-h // maxa)

print(ans)
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# WA

N, K = map(int, input().split())
S = list(input())

START = S[0]
prev = S[0]
ans = 0
for i in range(1, N):
    s = S[i]

    if prev == s:
        ans += 1
    else:
        if s == START and K > 0:
            ans += 2 if i < N else 1
            K -= 1

        prev = s

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = [0 for _ in range(N)]
for i in range(N-1):
  c, s, f = map(int, input().split())
  for j in range(i+1):
    if A[j] < s:
      A[j] = s + c
    else:
      d = - (s - A[j]) // f + 1
      A[j] = s + f * d + c
  print(A)
for i in range(N):
  print(A[i])
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
  x = min(a[i],b[i])
  b[i] -= x
  ans += x
  y = min(a[i+1],b[i])
  ans += y
  a[i+1] -= y
print(ans)
# Judge status: Accepted

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

X.sort()
res = M
ans = 0
for a, b in X:
    if res <= 0:
        break

    tmp = min(b, res)
    res -= tmp
    ans += tmp * a

print(ans)
# Judge status: Accepted
from collections import deque

s = input()
q = int(input())
revflag = 1
d = deque(s)
for i in range(q):
	tfc = list(map(str, input().split()))
	if tfc[0] == '1':
		revflag *= -1
	elif tfc[1] == '1':
		if revflag > 0:
			d.appendleft(tfc[2])
		else:
			d.append(tfc[2])
	else:
		if revflag > 0:
			d.append(tfc[2])
		else:
			d.appendleft(tfc[2])
if revflag > 0:
	print(''.join(d))
else:
	print(''.join(reversed(d)))
# Judge status: Accepted
n = input()
N = []
ans = 0
l = len(str(n))

for i in range(l):
    N.append(int(n[-i-1]))
N.append(0)

for i in range(l+1):
    if N[i]<5:
        ans += N[i]
    elif N[i]>5:
        ans += 10-N[i]
        N[i+1] += 1
    elif N[i+1]>4:
        ans += 10-N[i]
        N[i+1] += 1
    else:
        ans += N[i]

print(ans)