Harryxun/stf_run huggingface dataset:
mod = 1000000007
fact = []
fact_inv = []
pow_ = []

def pow_ini(nn):
	pow_ = []
	pow_.append(nn)
	for j in range(62):
		nxt = pow_[j] * pow_[j]
		nxt %= mod
		pow_.append(nxt)
	return pow_

def pow1(k):
	global pow_
	ansk = 1
	for ntmp in range(62):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow_[ntmp]
			ansk %= mod
	return ansk

def pow25(k):
	global pow25_
	ansk = 1
	for ntmp in range(62):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow25_[ntmp]
			ansk %= mod
	return ansk

def pow26(k):
	global pow26_
	ansk = 1
	for ntmp in range(62):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow26_[ntmp]
			ansk %= mod
	return ansk

def fact_ini(n):
	global fact
	global fact_inv
	global pow_
	for i in range(n + 1):
		fact.append(0)
		fact_inv.append(0)
	fact[0] = 1
	for i in range(1, n + 1, 1):
		fact_tmp = fact[i - 1] * i
		fact_tmp %= mod
		fact[i] = fact_tmp
	pow_ = pow_ini(fact[n])
	fact_inv[n] = pow1(mod - 2)
	for i in range(n - 1, -1, -1):
		fact_inv[i] = fact_inv[i + 1] * (i + 1)
		fact_inv[i] %= mod
	return

def nCm(n, m):
	assert(m >= 0)
	assert(n >= m)
	ans = fact[n] * fact_inv[m]
	ans %= mod
	ans *= fact_inv[n - m]
	ans %= mod
	return ans;

fact_ini(1100000)
pow25_ = pow_ini(25)
pow26_ = pow_ini(26)
K = int(input())
S = input()
N = len(S)
ans = 0
for k in range(0, K+1, 1):
	n = N + K - k
	anstmp = 1
	anstmp *= pow26(k)
	anstmp %= mod
	anstmp *= nCm(n - 1, N - 1)
	anstmp %= mod
	anstmp *= pow25(n - N)
	anstmp %= mod
	ans += anstmp
	ans %= mod
print(ans)

### FIXED CODE ###

mod = 1000000007
fact = []
fact_inv = []
pow_ = []
pow25_ = []
pow26_ = []

def pow_ini(nn):
	global pow_
	pow_.append(nn)
	for j in range(62):
		nxt = pow_[j] * pow_[j]
		nxt %= mod
		pow_.append(nxt)
	return

def pow_ini25(nn):
	global pow25_
	pow25_.append(nn)
	for j in range(62):
		nxt = pow25_[j] * pow25_[j]
		nxt %= mod
		pow25_.append(nxt)
	return

def pow_ini26(nn):
	global pow26_
	pow26_.append(nn)
	for j in range(62):
		nxt = pow26_[j] * pow26_[j]
		nxt %= mod
		pow26_.append(nxt)
	return

def pow1(k):
	ansk = 1
	for ntmp in range(62):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow_[ntmp]
			ansk %= mod
	return ansk

def pow25(k):
	ansk = 1
	for ntmp in range(31):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow25_[ntmp]
			ansk %= mod
	return ansk

def pow26(k):
	ansk = 1
	for ntmp in range(31):
		if((k >> ntmp) % 2 == 1):
			ansk *= pow26_[ntmp]
			ansk %= mod
	return ansk

def fact_ini(n):
	global fact
	global fact_inv
	global pow_
	for i in range(n + 1):
		fact.append(0)
		fact_inv.append(0)
	fact[0] = 1
	for i in range(1, n + 1, 1):
		fact_tmp = fact[i - 1] * i
		fact_tmp %= mod
		fact[i] = fact_tmp
	pow_ini(fact[n])
	fact_inv[n] = pow1(mod - 2)
	for i in range(n - 1, -1, -1):
		fact_inv[i] = fact_inv[i + 1] * (i + 1)
		fact_inv[i] %= mod
	return

def nCm(n, m):
	assert(m >= 0)
	assert(n >= m)
	ans = fact[n] * fact_inv[m]
	ans %= mod
	ans *= fact_inv[n - m]
	ans %= mod
	return ans;

fact_ini(2200000)
pow_ini25(25)
pow_ini26(26)
K = int(input())
S = input()
N = len(S)
ans = 0
for k in range(0, K+1, 1):
	n = N + K - k
	anstmp = 1
	anstmp *= pow26(k)
	anstmp %= mod
	anstmp *= nCm(n - 1, N - 1)
	anstmp %= mod
	anstmp *= pow25(n - N)
	anstmp %= mod
	ans += anstmp
	ans %= mod
print(ans)
n = input()
A = [input() for i in range(n)]
q = input()
m = [input() for i in range(q)]
i = 0
j = 0

def solve(i,m):
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i+1,m) | solve(i+1, m - A[i])
  return res

for m in q:
    if solve(0, m):
      print 'yes'
    else:
      print 'no'

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

min = min(A)
sum = sum(A)

def solve(i,m):
  if sum < m:
    return False
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i+1,m) or solve(i+1, m - A[i])
  return res
 
for m in M:
    if solve(0, m):
      print 'yes'
    else:
      print 'no'
print(max(a+b,a-b,a*b))


### FIXED CODE ###

a,b = map(int,input().split())
 
print(max(int(a+b),int(a-b),int(a*b)))
a, b, c, d = map(int, input().split())
diff = a + b - c - d
print("Left" if diff > 0 "Balanced" if diff == 0 else "Right")

### FIXED CODE ###

a, b, c, d = map(int, input().split())
diff = a + b - c - d
print("Left" if diff > 0 else "Balanced" if diff == 0 else "Right")
whatMan = []

N, K = input()
for i in range(int(K)):
    wahtMan.append(input().split())

print(int(N) - set(wahtMan).count)

### FIXED CODE ###

whatMan = []

N, K = input().split()
for i in range(int(K)):
    input()
    whatMan.extend(input().split())
print(int(N) - len(set(whatMan)))
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = dp.zeros(n, dtype=int)
h = np.array(h)

for i in range(1,n):
    start = max(0, i-k)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))

print(dp[n-1])

### FIXED CODE ###

import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = np.zeros(n, dtype=int)
h = np.array(h)

for i in range(1,n):
    start = max(0, i-k)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))

print(dp[n-1])
R,G = map(int,input().split())
print(2*G-R)

### FIXED CODE ###

R = int(input())
G = int(input())
print((2*G)-R)
n=int(input())
s=input()
a=s[:n//2]
if s=a+a:
  print("Yes")
else:
  print("No")

### FIXED CODE ###


n=int(input())
s=input()
a=s[:n//2]
if s==a+a:
  print("Yes")
else:
  print("No")
import math
a = list(map(int, input().split()))
print(a[0]*a[1] // math.gcd(a[0], a[1]))


### FIXED CODE ###

import fractions
a = list(map(int, input().split()))
print(a[0]*a[1] // fractions.gcd(a[0], a[1]))
n=int(input())
h=list(map(int,input().split()))
cnt=0
a=0
for i in range(n-1):
    if h[i]>=h[i+1]:
    a+=1
    else:
        a=0
    cnt=max(cnt,a)
print(cnt)

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
cnt=0
a=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        a+=1
    else:
        a=0
    cnt=max(cnt,a)
print(cnt)
from collections import Counter
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
l=list_difference(s,t)
l1=Counter(l)
print(l1.most_common()[0][1])

### FIXED CODE ###

from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)
N = int(input())
N = str(N)
print(1000 - int(N[-3] + N[-2] + N[-1]))

### FIXED CODE ###

N = int(input())

if(N % 1000 != 0):
 print(1000 - (N % 1000))
else:
  print(0)
def keyb(s):
	ans = ""
	for i in range(0, len(s)):
		if s[i] == 'B':
			ans.pop()
		else:
			ans.append(s[i])
	return ans

def main():
	s = raw_input()
	print keyb(s)

main()


### FIXED CODE ###

S = input()
ans = ''
for i in range(0, len(S)):
	if S[i] == 'B':
		if ans != '': ans = ans[0:len(ans)-1]
	else:
		ans = ans + S[i]
print(ans)
def answer(n, m, taro, hanako):
    for t in sorted(taro):
        for h in sorted(hanako):
            if sum(taro) - y + h == sum(hanako) - h + t:
                return '{t} {h}'

while True:
    n, m = map(int, input().split())
    if n == 0 and m == 0:
        break
    taro = []
    hanako = []
    for I in range(n)
        taro.append(int(input()))
    for I in range(m)
        hanako.append(int(input()))
    print(answer(n, m, taro, hanako)


### FIXED CODE ###

def answer(n, m, taro, hanako):
    for t in sorted(taro):
        for h in sorted(hanako):
            if sum(taro) - t + h == sum(hanako) - h + t:
                return f'{t} {h}'
    return -1


while True:
    n, m = map(int, input().split()) # 組み込み関数input()は標準入力から読み込まれた1行を返す．
    if n == 0 and m == 0:
        break
    taro = []
    hanako = []
    for i in range(n):
        taro.append(int(input()))
    for i in range(m):
        hanako.append(int(input()))
    print(answer(n, m, taro, hanako))
S = input()
W = input()
if S > W:
  print("safe")
else:
  print("unsafe")

### FIXED CODE ###

S, W = map(int, input().split())
if S > W:
  print("safe")
else:
  print("unsafe")
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
s=Counter(s)
p=[]
p.append(s.most_common()[0][0])
for i in range(n):
    if s.most_common(i+1)[i][1]==s.most_common(i+2)[i+1][1]:
        p.append(s.most_common(i+2)[i+1][0])
    else:
        break
p=sorted(p)
for i in range(len(p)):
    print(p[i])

### FIXED CODE ###

import collections
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
s=Counter(s)
p=[]
k=s.most_common()
p.append(k[0][0])
for i in range(len(collections.Counter(s))-1):
    if k[i][1]==k[i+1][1]:
        p.append(k[i+1][0])
    else:
        break
p=sorted(p)
for i in range(len(p)):
    print(p[i])
a=int(input())
if a > 500:
    print((a//500)*1000+((a%500)//5)*5)
else:
    print((a//5)*5)

### FIXED CODE ###

a=input()
if a[2] == a[3] and a[4] == a[5]:
    print("Yes")
else:
    print("No")
if int(input().strip(" "))%4==0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

if int("".join(input().split(" ")))%4==0:
  print("YES")
else:
  print("NO")
n, y = map(int, input().split())

for yukiti in range(0, 1 + (y // 10000)):
  for higuti in range(0, 1 + (y - 10000 * yukiti) // 5000):
    noguti = (y - 10000 * yukiti - 5000 * higuti) // 1000
    paper = yukiti + higuti + noguti # 今気がついたんだけど全員tiで終わってるわw
    #count = yukiti * 10000 + higuti * 5000 + noguti * 
    if paper == n:
      print("{0} {1} {2}".format(yukiti, higuti, noguti))
      exit(1)

print("-1 -1 -1")

### FIXED CODE ###

n, y = map(int, input().split())

for yukiti in range(0, 1 + (y // 10000)):
  for higuti in range(0, 1 + (y - 10000 * yukiti) // 5000):
    noguti = (y - 10000 * yukiti - 5000 * higuti) // 1000
    paper = yukiti + higuti + noguti # 今気がついたんだけど全員tiで終わってるわw
    #count = yukiti * 10000 + higuti * 5000 + noguti * 
    if paper == n:
      print("{0} {1} {2}".format(yukiti, higuti, noguti))
      exit(0)

print("-1 -1 -1")
while True:
    a,b,c = input().split()
    if b=='?':
        break
    elif b =='+':
        d = int(a) + int(c)
    elif b=='-':
        d = int(a) - int(c)
    elif b=='*':
        d = int(a)*int(c)
    else :
        d = int(a)/int(c)
    print(int(d)

### FIXED CODE ###

while True:
    Input = input().split()
    a = int(Input[0])
    op = Input[1]
    b = int(Input[2])
    
    if op == '?':
        break
    
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    else:
        print(a//b)
import math

def resolve():
    A, B = map(int, input().split())

    answer = least_common_multiple(A, B)    
    print(answer)

def least_common_multiple(a, b):
    if b > a:
        a, b = b, a
    
    ab = a*b

    while (a%b) != 0
        a, b = b, a%b

    return int(ab/b)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

import math

def resolve():
    A, B = map(int, input().split())

    answer = least_common_multiple(A, B)    
    print(answer)

def least_common_multiple(a, b):
    if b > a:
        a, b = b, a
    
    ab = a*b

    while (a%b) != 0:
        a, b = b, a%b

    return int(ab/b)

if __name__ == "__main__":
    resolve()
a, b, c = map(int, input().split())
if a+b+2*math.sqrt(a)*math.sqrt(b) < c:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a, b, c = map(int, input().split())
if c-a-b < 0:
    print("No")
elif 4*a*b < (c-a-b)**2:
    print("Yes")
else:
    print("No")
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

i = j = 0

passed = [[None] * W for _ in range(H)]

def dp(i, j):
    global H, W
    passed[i][j] = True
    if i == H - 1 and j == W - 1: return True
    #
    if i + 1 >= H:
        d = False
    else:
        d = (A[i + 1][j] == '#')
    #
    if j + 1 >= W:
        r = False
    else:
        r = (A[i][j + 1] == '#')
    #
    if d and not r:
        return dp(i + 1, j)
    elif not d and r:
        return dp(i, j + 1)
    else:
        return False

if dp(0, 0):
    ans = 'Possible'
    for i in range(H):
        for j in range(W):
            if not visited[i][j] and A[i][j] == '#':
                ans = 'Impossible'
    #
    print(ans)
else:
    print('Impossible')

### FIXED CODE ###

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

i = j = 0

visited = [[None] * W for _ in range(H)]

def dp(i, j):
    global H, W
    visited[i][j] = True
    if i == H - 1 and j == W - 1: return True
    #
    if i + 1 >= H:
        d = False
    else:
        d = (A[i + 1][j] == '#')
    #
    if j + 1 >= W:
        r = False
    else:
        r = (A[i][j + 1] == '#')
    #
    if d and not r:
        return dp(i + 1, j)
    elif not d and r:
        return dp(i, j + 1)
    else:
        return False

if dp(0, 0):
    ans = 'Possible'
    for i in range(H):
        for j in range(W):
            if not visited[i][j] and A[i][j] == '#':
                ans = 'Impossible'
    #
    print(ans)
else:
    print('Impossible')
a, b, c = map(int,input().split())

if a =< c =< b:
  print ("Yes")
else:
  print ("No")


### FIXED CODE ###

a, b, c = map(int,input().split())
if (a <= c) and (b >= c):
  print ("Yes")
else:
  print ("No")
import sympy
N = int(input())
sumcount = 0
for i in range(N):
    if sympy.divisor_count(i+1)==8:
        if (i+1) % 2 != 0:
            sumcount += 1
print(sumcount)

### FIXED CODE ###

def div(num):
    counter = 0
    for i in range(num):
        if num % (i+1) == 0:
            counter += 1
    return counter
N = int(input())
sumcount = 0
for i in range(N):
    if div(i+1)==8:
        if (i+1) % 2 != 0:
            sumcount += 1
print(sumcount)
from decimal import *
a,b=input().split()
a=Decimal(a)
b=Decimal(b)
ans=int(a*b)
print(ans)

### FIXED CODE ###

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

d=c-a-b
if d>0 and d*d>4*a*b:
  print("Yes")
else:
  print("No")
N, M = map(int, input().split())

if M % N == 0:
    print(M//N)
    exit()


# そもそも素数だとだめなので、素数判定
pn = 2
is_prime = True
while pn*pn <= M:
    if M % pn == 0:
        #その数字以外のある数字で割り切れるので素数ではない
        is_prime = False
        break
    pn += 1


if is_prime == False:
    ans = 1
    for i in reversed(range(1, (M**0.5)+1)):
        # 最大公約数がiとする
        rest = M - (i * N)
        if (i+rest) % i == 0:
            ans = i
            break
else:
    if N == 1:
        ans = M
    else:
        ans = 1

print(ans)  

### FIXED CODE ###

n,m = map(int, input().split()) 

ans = 1

for i in range(1, int(m ** 0.5)+1):
  if m % i == 0:
    if i >= n:
      ans = max(ans, m // i)
    elif m // i >= n:
      ans = max(ans, i)
      
      
print(ans)
A, B = map(int, input().split())
if B%A=0:
  print(A+B)
else:
  print(B-A)

### FIXED CODE ###

A, B = map(int, input().split())
if B%A==0:
  print(A+B)
else:
  print(B-A)
N,M=map(int,input().split())
s=[]
c=[]
ans=0
for i in range(M):
    x,y=map(int,input().split())
    s.append(x)
    c.append(y)
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
            print(-1)
            exit()
for i in range(M):
    if N<s[i]:
        print(-1)
        exit()
for i in range(M):
    if s[i]==1 and c[i]==0 and N>1:
        print(-1)
        exit()
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]==c[j]:
            s[j]=0
            c[j]=0
if N==1:
    print(c[0])
if N==2:
    for i in range(M):
        if s[i]==1:
            ans+=10*c[i]
        if s[i]==2:
            ans+=c[i]
    print(ans)
    exit()
if N==3:
    for i in range(M):
        if s[i]==1:
            ans+=100*c[i]
        if s[i]==2:
            ans+=10*c[i]
        if s[i]==3:
            ans+=c[i]
    print(ans)

### FIXED CODE ###

#なんもわからんくなった
N,M=map(int,input().split())
s=[]
c=[]
ans=0
#入力
for i in range(M):
    x,y=map(int,input().split())
    s.append(x)
    c.append(y)

if M==0:
    if N==1:
        print(0)
        exit()
    elif N==2:
        print(10)
        exit()
    else:
        print(100)
        exit()
#同じ桁だけど数が違う場合
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
            print(-1)
            exit()

#1桁目が0なのにNが2桁以上の時
for i in range(M):
    if s[i]==1 and c[i]==0 and N>1:
        print(-1)
        exit()

#処理の重複を消してる
for i in range(M-1):
    for j in range(i+1,M):
        if s[i]==s[j] and c[i]==c[j]:
            s[j]=0
            c[j]=0

#各桁ごとの最小値
if N==1:
    print(c[0])
    exit()
if N==2:
    ans=10
    for i in range(M):
        if s[i]==1:
            ans=0
    for i in range(M):
        if s[i]==1:
            ans+=10*c[i]
        if s[i]==2:
            ans+=c[i]
    print(ans)
    exit()
if N==3:
    ans=100
    for i in range(M):
        if s[i]==1:
            ans=0
    for i in range(M):
        if s[i]==1:
            ans+=100*c[i]
        if s[i]==2:
            ans+=10*c[i]
        if s[i]==3:
            ans+=c[i]
    print(ans)
N = input()
K = int(input())
m = len(N)
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp[0][0][0] = 1 #[i][j][k] i桁目まで決める　N未満で確定でj=1 0でない数がk個

for i in range(1, m + 1):
    l = int(N[i - 1])
    for k in range(K + 1): # 0でない数の個数 k を変化させていく
        if k -1 >= 0:
            if l != 0: #i桁目 1～9
                dp[i][0][k] = dp[i - 1][0][k-1]
                dp[i][1][k] = dp[i - 1][1][k] + 9*dp[i - 1][1][k-1] + dp[i - 1][0][k] + (l-1)*dp[i - 1][0][k-1]
            else: #i桁目 0
                dp[i][0][k] = dp[i - 1][0][k]
                dp[i][1][k] = dp[i - 1][1][k] + 9*dp[i - 1][1][k-1]
        else: #すべての数が0ではない場合
            if l != 0: #i桁目 1～9
                #dp[i][0][k]
                dp[i][1][k] = dp[i - 1][1][k] + dp[i - 1][0][k] # i桁目　N未満　すべてが0　→　0のみ　1コ
            else: #i桁目 0
                dp[i][0][k] = dp[i - 1][0][k] #  # i桁目　Nと一致　すべてが0　→　該当なし　0コ
                dp[i][1][k] = dp[i - 1][1][k] # =1

print(dp)
print(dp[m][0][K] + dp[m][1][K])

N = input()
K = int(input())
m = len(N)
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp[0][0][0] = 1 #[i][j][k] i桁目まで決める　N未満で確定でj=1 0でない数がk個

for i in range(1, m + 1):
    l = int(N[i - 1])
    for k in range(K + 1): # 0でない数の個数 k を変化させていく
        if k -1 >= 0:
            if l != 0: #i桁目 1～9
                dp[i][0][k] = dp[i - 1][0][k-1]
                dp[i][1][k] = dp[i - 1][1][k] + 9*dp[i - 1][1][k-1] + dp[i - 1][0][k] + (l-1)*dp[i - 1][0][k-1]
            else: #i桁目 0
                dp[i][0][k] = dp[i - 1][0][k]
                dp[i][1][k] = dp[i - 1][1][k] + 9*dp[i - 1][1][k-1]
        else: #すべての数が0ではない場合
            dp[i][0][k] = 0 # i桁目　Nと一致　すべてが0　→　該当なし　0コ
            dp[i][1][k] = 1 # i桁目　N未満　  すべてが0  →　0のみ　  1コ

#print(dp)
print(dp[m][0][K] + dp[m][1][K])

### FIXED CODE ###

N = input()
K = int(input())
m = len(N)
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp[0][0][0] = 1 #[i][j][k] i桁目まで決める　N未満で確定でj=1 0でない数がk個

for i in range(1, m + 1):
    l = int(N[i - 1])
    for k in range(K + 1): # 0でない数の個数 k を変化させていく
        if k -1 >= 0:
            if l != 0: #i桁目 1～9
                dp[i][0][k] = dp[i - 1][0][k-1]
                dp[i][1][k] = dp[i - 1][1][k] + 9*dp[i - 1][1][k-1] + dp[i - 1][0][k] + (l-1)*dp[i - 1][0][k-1]
            else: #i桁目 0
                dp[i][0][k] = dp[i - 1][0][k]
                dp[i][1][k] = dp[i - 1][1][k] + 9*dp[i - 1][1][k-1]
        else: #すべての数が0ではない場合
            dp[i][0][k] = 0 # i桁目　Nと一致　すべてが0　→　該当なし　0コ
            dp[i][1][k] = 1 # i桁目　N未満　  すべてが0  →　0のみ　  1コ

#print(dp)
print(dp[m][0][K] + dp[m][1][K])
N = int(input())
K = int(input())
n1 = N%K
n2 = K -n1
print(min(n1,n2))

### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[10]:


N,K = map(int,input().split())
new = N % K
n2 = K - new

print(min(new,n2))
N, M = map(int, input().split())
sc = []
tf = True
tff = False
for i in range(M):
  sc.append(list(map(int, input().strip().split())))
num = []
for i in range(N):
  num.append(0)
sc.sort()
if N == 1 and sc[0][0] == 1 and sc[0][1] == 0:
  tff = True
for i in range(M-1):
  if sc[i][0] == sc[i+1][0] and sc[i][1] != sc[i+1][1]:
    tf = False
for i in sc:
  if i[0] == 1 and i[1] == 0:
    tf = False
  else:
    num[i[0]-1] = i[1]
if tf and num[0] == 0:
  num[0] = 1
string = ""
for i in num:
  string += str(i)
if tff == True:
  print(0)
elif tf == True:
  print(string)
else:
  print(-1)

### FIXED CODE ###

N, M = map(int, input().split())
sc = []
tf = True
tff = False
for i in range(M):
  sc.append(list(map(int, input().strip().split())))
if len(sc) == 0:
  if N == 1:
    print(0)
  else:
    print("1"+"0"*(N-1))
else:
  num = []
  for i in range(N):
    num.append(0)
  sc.sort()
  if N == 1 and sc[0][0] == 1 and sc[0][1] == 0:
    tff = True
  for i in range(M-1):
    if sc[i][0] == sc[i+1][0] and sc[i][1] != sc[i+1][1]:
      tf = False
  for i in sc:
    if i[0] == 1 and i[1] == 0:
      tf = False
    else:
      num[i[0]-1] = i[1]
  if tf and num[0] == 0:
    num[0] = 1
  string = ""
  for i in num:
    string += str(i)
  if tff == True:
    print(0)
  elif tf == True:
    print(string)
  else:
    print(-1)
N,K=map(int,input().split())
class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
ide_ele = 0
def segfunc(x,y):
    return max(x,y)
seg=SegTree([0]*(N+4),segfunc,ide_ele)
for i in range(N):
    a=int(input())
    seg.update(a,seg.query(max(0,a-K),min(N,a+K+1))+1)
print(seg.query(0,N+3))


### FIXED CODE ###

N,K=map(int,input().split())
class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
ide_ele = 0
b=[int(input()) for _ in range(N)]
c=max(b)
def segfunc(x,y):
    return max(x,y)
seg=SegTree([0]*(c+6),segfunc,ide_ele)
for i in range(N):
    a=b[i]
    seg.update(a,seg.query(max(0,a-K),min(c+2,a+K+1))+1)
print(seg.query(0,c+3))
numbers = []
n = raw_input()
numbers = n.split(" ")
for i in range(5):
	numbers[i] = int(numbers[i])
W = numbers[0]
H = numbers[1]
x = numbers[2]
y = numbers[3]
r = numbers[4]

if x - r => 0 and y - r => 0 and x + r <= W and y + r <= H:
	print "Yes"
else:
	print "No"

### FIXED CODE ###

w, h, x, y, r = map(int, input().split())
if 0 <= x - r and x + r <= w and 0 <= y - r and y + r <= h:
    print("Yes")
else:
    print("No")