peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

i = a.index(1)

s = n

for j in range(i-k+1, i+k):
    if j < 0:
        continue
    elif j >= n:
        continue
    else:
        l = j
        u = (n-1-j)
        t = (l+k-2) // (k-1) + (u+k-2) // (k-1)
        #print(t)
        s = min(s, t)

print(s)
# Judge status: Accepted
a = [input() for _ in range(int(input()))]
b = [input() for _ in range(int(input()))]
c = a + b
print(max(0, max([ a.count(i) - b.count(i) for i in set(c)])))
# Judge status: Wrong Answer
S = list(input())

cnt = 0

if S[0]=="R":
    cnt = 1

if S[1]=="R":
    cnt += 1
    if S[2]=="R":
        cnt += 1
else:
    if S[2]=="R":
        cnt += 1
    
    
print (cnt)
# Judge status: Accepted
D, T, S=map(int, input().split())
if S*T-D>=0:print('Yes')
else:print('No')
# Judge status: Wrong Answer
import sys
a1=sys.stdin.readline()
a2=list(a1)
b=[ord(x) for x in a2]
b.sort()
if len(a2)==4 and b[0]==b[1] and b[2]==b[3] and b[1]!=b[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = list(map(int,input().split()))
if sum(a) >= 22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
N, M = map(int,input().split())


def calculate(n, m):

    if (m // 2) < n:
        print(m // 2)
        return

    res = ((m - n * 2) // 4) + n
    print(res)

calculate(N, M)
# Judge status: Wrong Answer
import math
def ii():
  return int(input())

N = ii()

def facts(n):
  facts = []
  for i in range(1, int(math.sqrt(n))+1):
    if n%i==0:
      facts.append(i)
  return facts

fs = facts(N)
print(fs)
a = fs[-1]
b = N//a

print(a+b-2)
# Judge status: Accepted
import sys
import math
import itertools

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [True] * n
lis = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    lis[a - 1] = max(lis[a - 1], h[b - 1])
    lis[b - 1] = max(lis[b - 1], h[a - 1])
ans = 0
for i in range(n):
    if lis[i] < h [i]:
        ans += 1
print(ans)
# Judge status: Wrong Answer
stdin = [input() for i in range(3)]
line = stdin[0].split(' ')
A = int(line[0])
V = int(line[1])
line = stdin[1].split(' ')
B = int(line[0])
W = int(line[1])
T = int(stdin[2])
length = 0
if B < A:
    length = B-A
else:
    length = A-B
if (V-W)*T < length:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())))

print(a[n//2]-a[n//2-1])
# Judge status: Accepted
import math
N, P = map(int,input().split())
A = list(map(int,input().split()))
B = [e%2 for e in A]
ans = pow(2,B.count(0))
def nCr(n,r):
    return (math.factorial(n)//(math.factorial(r)*math.factorial(n-r)))
t = 0
for k in range(B.count(1)+1):
    if k%2 == 0:
        t += nCr(B.count(1),k)
print(ans*t if P == 0 else pow(2,N)-ans*t)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
if N > M: N, M = M, N
if N == 2: print(0)
elif N == 1 and (M == 2): print(0)
elif N == 1: print(max(0, M - 2))
else: print(max(0, (N - 2) * (M - 2)))
# Judge status: Wrong Answer
n, r = map(int, input().split())

if n >= 10 :
  print(r)
else:
  print(r - 100 * (10 - n))
# Judge status: Accepted
#!/usr/bin/env python3
import numpy as np


def main():
    N, X = map(int, input().split())
    L_list = list(map(int, input().split()))
    L_sum = np.cumsum(L_list)
    print(np.where(L_sum <= X)[0][-1] + 2)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n,a,b = map(int,input().split())
s = input()
ans = 0
pass_b = 0
for i in range(n):
  if s[i] == 'a' and ans < (a+b):
    ans += 1
    print('Yes')
  elif s[i] == 'b' and ans < (a+b) and pass_b <= b:
    ans += 1
    pass_b += 1
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
a, v = map(int,input().split())
b, w = map(int,input().split())
t = int(input())

d = abs(a-b)
v_diff = abs(v-w)

if w >= v:
    print('NO')
elif d > t * v_diff:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = list(map(int, list(readline().rstrip().decode())[::-1]))
a = 0
b = 10000
for x in n:
    memo = min(a + x, b + x)
    b = min(a + 11 - x, b + 9 - x)
    a = memo
print(min(a, b))
# Judge status: Accepted
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    S = list(set(A))
    ND = [True]*(10**6 + 1)
    for e in S:
        m = e*2
        while m <= 10**6:
            ND[m] = False
            m += e
    ans = 0
    for a in A:
        if C[a] == 1 and ND[a]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
# ???
def mi():return map(int,input().split())
n,a,b,c,d=mi()
s=input()

if c<d:
    # print(s[a-1:d+1-1])
    if s[a-1:d+1-1].count("##")>0:
        print("No")
    else:
        print("Yes")
else:
    # print(s[a-1:c+1-1])
    if s[a-1:c+1-1].count("##")>0 or s[a-1:c+1-1].count("...")==0:
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
k = int(input())
 
cnt = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            cnt += gcd(i,j,m)
            
 
print(cnt)
# Judge status: Wrong Answer
from math import pi
R = int(input())
print(R ** 2 * pi)
# Judge status: Accepted
import math

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

N -= K
K -= 1
C = math.ceil(N/K)

print(C+1)
# Judge status: Wrong Answer
n = input()
if len(n) == 3:
  print('ABC')
else:
  print('ABD')
# Judge status: Wrong Answer
X = int(input())
for i in range(1, 361):
  if i%X == 0:
    print(i//X)
    exit()
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
S = input()

cnt = Counter(S)

res = 1
for v in cnt.values():
    res *= v+1

print(res-1)
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))
D.sort()
res = D[(N - 1) // 2 + 1] - D[(N - 1) // 2]
print(res)
# Judge status: Accepted
A,B,N=map(int,input().split())

if N>=B:
    X=B-1
else:
    X=N

print(int(A*X/B)-A*int(X/B))
# Judge status: Accepted
n = int(input())
ans = "No"
for f in range(26):
    for s in range(15):
        if f * 4 + s * 7 == n:
            ans = "Yes"
            break

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

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

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


c = [0]
d = 0
for i in range(n):
    d += a[i]
    c.append(d)

e = [0]
f = 0
for i in range(m):
    f += b[i]
    e.append(f)


ans = 0
j = m
for i in range(n+1):
    if c[i] > k:
        break
    else:
        while c[i] + e[j] > k:
            j -= 1
    ans = max(i + j,ans)

print(ans)
# Judge status: Accepted
N = int(input())
L = list(map(int,input().split()))
for i in range(N-1,0,-1):
    if L[i-1] > L[i]:
        if L[i-1] - 1>L[i]:
            print("No")
            exit()
        L[i-1]-=1
print("Yes")
# Judge status: Accepted
from sys import stdin
from collections import deque, Counter, defaultdict
import heapq

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    N = int(input())
    N %= 10
    if N in set({2, 4, 5, 7, 9}):
        print("hon")
    elif N in set({0, 1, 6, 8}):
        print("pon")
    else:
        print("bon")

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s = input()
#print(s)

score=0
for i in range(len(s)):
	if s[i]=="0":
		score = score +1
	else:
		score = score -1
#	print(s[i])
print(len(s)-score)
# Judge status: Accepted
S = input()

ss = ""
for i in range(len(S)):
    # print(i)
    ss += S[len(S) - i - 1]

count = 0
for i in range(len(S)):
    if S[i] != ss[i]:
        count += 1

print(int(count / 2))
# Judge status: Accepted
MOD = 1000000007
n = int(input())
a = [int(_) for _ in input().split()]
p = [0] * (n + 1)
for i in range(n - 1, -1, -1):
    p[i] = p[i + 1] + a[i]
ans = 0
for i in range(n):
    add = a[i] * (p[i] - a[i])
    add = add % MOD
    ans += add
    ans = ans % MOD
print(ans)
# Judge status: Accepted

import sys  
import numpy as np

input = sys.stdin.readline

N = input()
sum_ = 0

for i in list(N)[:-1]:
    
    sum_+=int(i)

if sum_ != 1:
    print(sum_)
else :
    print(10)
# Judge status: Wrong Answer

n,d = map(int,input().split())
l = []
a = []
count = 0
sum = 0

for i in range(n):
    a = list(map(int,input().split()))
    l.append(a)

for x in range(1,n):
    for y in range(x+1,n):
        for z in range(d):
            sum += (l[x][z]-l[y][z])**2
            dis = sum ** 0.5

            if dis % 1 ==0:
                count += 1
print(count)
# Judge status: Accepted
s=input()
q=int(input())

rev = 1
fr = ""
rr = ""

for i in range(q):
    ss=input()
    if int(ss[0])==1:
        rev *= -1
    else:
        f,c=int(ss[2]),ss[4]
        if f == 2:
            f = -1
        
        if f*rev ==1:
            fr+=c
        else:
            rr+=c

if rev == 1:
    ans = fr[::-1]+s+rr
else:
    ans = rr[::-1]+s[::-1]+fr
print(ans)
# Judge status: Wrong Answer
n = int(input())
ans = "No"
for i in range(1,252):
    for j in range(1,16):
        if (i*4)+(j*7)==n:
            ans = "Yes"
            break
print(ans)
# Judge status: Accepted
x=int(input())
tmp=x%11
ans=x//11*2
if tmp==0:
    ans+=0
elif tmp<=6:
    ans+=1
else:
    ans+=2
print(ans)
# Judge status: Accepted
from math import sqrt
a, b = input().split()
print("Yes" if float.is_integer(sqrt(int(a + b))) else "No")
# Judge status: Accepted
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c

x = int(input())

n = x // 100
m = x % 100
c = 0
for i in range(1, 6)[::-1]:
    c += m // i
    m %= i
if c <= n:
    print(1)
else:
    print(0)
# Judge status: Accepted
A,B,K=map(int,input().split())

if A>=K:
  A=A-K
elif A+B<=K:
  A=B=0
else:
  B=A+B-K
  A=0

print('{} {}'.format(A,B))
# Judge status: Accepted
from itertools import combinations
n,m,x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = float("inf")
for i in range(1,n+1):
  for j in combinations(ca,i):
    l = [0]*(m+1)
    for k in j:
      for i2 in range(m+1):
        l[i2] += k[i2]
    if all(l[num] >= x for num in range(1,m+1)):
      ans = min(ans, l[0])
if ans == float("inf"): print(-1)
else: print(ans)
# Judge status: Wrong Answer
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

s = input()
if s == "ABC":
    print("ARC")
else:
    print(s)
# Judge status: Accepted
def solution(temp: int) -> None:
    if temp >= 30:
        print("Yes")
    else:
        print("No")


temp: int = int(input())
solution(temp)
# Judge status: Accepted
s=raw_input("")
if(len(list(set(s)))==2):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
from collections import defaultdict as dd
import heapq
N = int(input())
a = list(map(int,input().split()))
res = 0
a = sorted(a, reverse=True)
dic=dd(list)
ls = [a[0]]
heapq.heapify(ls)
for val in a[1:]:
    tmp = heapq.heappop(ls)
    res += tmp
    heapq.heappush(ls,val)
    heapq.heappush(ls,val)
print(res)
# Judge status: Accepted
import itertools
import numpy as np

N, M, Q = map(int, input().split())
grid = []
for i in range(Q):
    array = list(map(int, input().strip().split()))
    grid.append(array)

l = np.arange(1, M + 1)
max = 0
temp = 0

for c in itertools.combinations_with_replacement(l, N):
    for d in grid:
        if c[d[1]-1] - c[d[0]-1] == d[2]:
            temp += d[3]
    if max < temp:
        max = temp
    temp = 0

print(max)
# Judge status: Accepted
x=list(map(int,input().split()))
x.sort()
if x[2]%2==0:
    print('0')
else:
    print(x[0]*x[1])
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
print(B + C - A)
# Judge status: Accepted
X, K, D = map(int, input().split())
X = abs(X)
k = X//D
if k >= K:
    print(X-D*K)
else:
    print(abs(X - D * k - D*((K-k)%2)))
# Judge status: Accepted
s = input()
ans = 753
for i in range(len(s)-2):
  x = abs(753 - int(s[i:i+3]))
  ans = min(ans, x)
print(ans)
# Judge status: Wrong Answer
import math
a,b,h,m = map(int,input().split())

aangle = m * 6
bangle = h * 30

diff = abs(aangle - bangle)
if diff > 180:
    diff -= 180

#print(diff,a,b,round(math.cos(math.radians(diff)),10))
print((a*a + b*b - 2 * a * b * round(math.cos(math.radians(diff)),10)) ** 0.5)
# Judge status: Accepted
def ncr(n, r):
    num, den = 1, 1
    if n - r < r:
        r = n - r
    for i in range(1, r + 1):
        num *= n - i + 1
        num %= MOD
        den *= i
        den %= MOD
    return num * pow(den, MOD - 2, MOD) % MOD


MOD = 10 ** 9 + 7
X, Y = map(int, input().split())
Z = X + Y

if Z % 3 or Y > 2 * X or Y < X // 2:
    print(0)
else:
    print(ncr(Z // 3, X - Z // 3))
# Judge status: Accepted
N = int(input())
ans = []

while True:
  if N%26 == 0:
    ans.append('z')
  else:
    ans.append(chr(N%26+96))
  N = (N-1)//26
  if N == 0:
    break
ans.reverse()
print(''.join(ans))
# Judge status: Accepted
x,a,b = map(int,input().split())
K = abs(a-x)
L = abs(b-x)
if K < L:
    print("A")
else:
    print("B")
# Judge status: Wrong Answer
N, K = map(int, input().split())
High = list(map(int, input().split()))

DP = [1000000]*N
DP[0] = 0
for i in range(N):
    for j in range(K):
        if i + j + 1 >= N:
            break
        DP[i + j + 1] = min(DP[i + j + 1], DP[i] + abs(High[i] - High[i + j + 1]))
print(DP[N-1])
# Judge status: Accepted
s = list(str(input()))
s = list(map(int, s))
k = int(input())

flag = True
for i in range(min(len(s),k)):
    if s[i] != 1:
        flag = False
    else:
        pass

if flag:
    print(1)
else:
    for i in range(len(s)):
        if s[i] != 1:
            print(s[i])
            break
# Judge status: Accepted
N=int(input())
S=input()
ans=S.count("R")*S.count("G")*S.count("B")
for i in range(N):
    for j in range(i+1,N):
        k=2*j-i
        if k<N and S[k]!=S[i] and S[k]!=S[j] and S[j]!=S[i]:
            ans-=1
print(ans)
# Judge status: Accepted
print(input() if input()>='3200' else 'red')
# Judge status: Accepted
s=input()
t=input()
m=1000
for i in range(len(s)-len(t)+1):
  mm=0
  for j in range(len(t)):
    if s[i+j]!=t[j]:
      mm+=1
  m=min(mm,m)
print(m)
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M, X, Y = map(int, input().split())
    XN = list(map(int, input().split()))
    YM = list(map(int, input().split()))
    result = 'War'

    for z in range(X + 1, Y + 1):
        if X < z <= Y and max(XN) < z <= min(YM):
            result = 'No War'
    print(result)


if __name__ == "__main__":
    main()
# Judge status: Accepted
K = int(input())
S = list(input())

if K >= len(S):
    print(''.join(S))

if K < len(S):
    print(''.join(S[:K])+'...')
# Judge status: Accepted
x,y=map(int,input().split())

if (x+y)%3!=0:
    print(0)
    exit()
    
a=(2*y-x)//3
b=(2*x-y)//3

if a<0 or b<0:
    print(0)
    exit()

mod=10**9+7

F=[1]
for i in range(1,a+b+1):
    tmp=F[-1]*i
    F.append(tmp%mod)

Ia=pow(F[a],mod-2,mod)
Ib=pow(F[b],mod-2,mod)

ans=F[a+b]*Ia*Ib%mod
print(ans)
# Judge status: Wrong Answer
from functools import reduce
from fractions import gcd
 
N = int(input())
A = list(map(int, input().split()))
 
MOD = 10 ** 9 + 7
 
lcm = reduce(lambda x,y: x*(y//gcd(x,y)), A)
lcm %= MOD
answer = sum(lcm//x for x in A)
answer %= MOD
print(answer)
# Judge status: Wrong Answer
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
x = a[-1]
y = a[-1]//2

a = a[:-1]
y = bisect.bisect_left(a,y)
if len(a) <= y: y -= 1
print(x,a[y])
# Judge status: Accepted
k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)
# Judge status: Accepted
n, d = map(int, input().split())

x = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        y = x[i]
        z = x[j]
        a = 0
        for k in range(d):
            a += (y[k] - z[k]) ** 2
        a = a ** 0.5
        if int(a) == a:
            ans += 1

print(ans)
# Judge status: Wrong Answer
N =int(input())
SIX  = [6**i for i in range(1,7)]
NINE = [9**i for i in range(1,6)]
SIX.extend(NINE)
SIX.append(1)
SIX = sorted(SIX,reverse=True)

ans = 99
for s in SIX:
    cnt=0
    if N > s:
        N2 =N-s
    else:
        N2 = N
    for s2 in SIX:
        if N2 >=s2:
        
            P,N2 = divmod(N2,s2)
            cnt+=P
    if cnt <= ans:
        ans = cnt
print(ans+1)
# Judge status: Accepted
n = int(input())

if n <= 1000:
    print(1000-n)
elif 1000< n <=2000:
    print(2000-n) 
elif 2000< n <=3000:
    print(3000-n)
elif 3000< n <=4000:
    print(4000-n)
elif 4000< n <=5000:
    print(5000-n)
elif 5000< n <=6000:
    print(6000-n)
elif 6000< n <=7000:
    print(7000-n)
elif 7000< n <=8000:
    print(8000-n)
elif 8000< n <=9000:
    print(9000-n)
elif 9000< n <=10000:
    print(10000-n)
# Judge status: Accepted
from collections import Counter
N, K = map(int, input().split())
A = list(map(int,input().split()))
B = set(A)
C = Counter(A).most_common()[::-1]
pre_color = len(B)
ans = 0
if pre_color <= K:
    print(0)
    exit()
else:
    dec = pre_color - K
    for i in range(dec):
        ans += C[i][1]
print(ans)
# Judge status: Wrong Answer

n = int(input())
w = list(map(int,input().split()))
l = []
r = []
print(w)

min = abs(w[0] - sum(w[1:]))
#print(min)
s1 = 0
s2 = 0

for i in range(n-1):
    s1 = sum(w[:i+1])
    s2 = sum(w[i+1:])
    tmp = abs(s1 - s2)
#    print(s1,s2,tmp)
    if tmp < min:
        min = tmp

print(min)
# Judge status: Wrong Answer
A, B = map(int, raw_input() .split())
if A + B < 24:
    print A + B
elif A + B > 24:
    print A + B - 24
# Judge status: Accepted
x=int(input())
v=0
for i in range(10**9):
    v+=i
    if v>=x:
        print(i)
        exit()
# Judge status: Accepted
a, b = map(int, input().split())

print(int(a * b))
# Judge status: Accepted
n,k = map(int,input().split())
ls = list(map(int,input().split()))
ls.sort()
ans = 0
for i in range(k):
    ans += ls[i]
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
sousa = sorted([[int(i) for i in input().split()] for i in range(M)],reverse=True, key=lambda x:x[1])
# Judge status: Wrong Answer
S = input()
T = input()
l = len(T)

mx = -1
for i in range(len(S) - l):
    m = [a == b for a, b in zip(S[i:i + l], T)].count(True)
    mx = max(m, mx)

print(l - mx)
# Judge status: Wrong Answer
s = list(input())
ans = 0
cnt = 0
l = ['A', 'C', 'G', 'T']
for i in range(len(s)):
    if s[i] in l:
        cnt += 1
    else:
        ans = max(cnt, ans)
        cnt = 0
print(ans)
# Judge status: Accepted
x,a,b=map(int,input().split())
if a>=b:
  print("delicious")
elif b-a<=x:
  print("safe")
else:
  print("dangerous")
# Judge status: Accepted
n = int(input())

for i in range(1,10):
    for j in range(1, 10):
        if n == i*j:
            print('Yes')
            quit()

print('No')
# Judge status: Wrong Answer

k=int(input())
s=input()

if len(s)<=k:
    print(s)
else:
    print(s+"...")
# Judge status: Wrong Answer
S = input()
T = input()
ls = len(S)
lt = len(T)
for i in range(ls-lt+1):
    if S[i]=='?' or S[i]==T[0]:
        c = 0
        for j in range(i+1,i+lt):
            c+=1
            if S[j]!='?' and S[j]!=T[c]:
                break
        else:
            S = S[:i]+T+S[i+lt:]
if T not in S:
    print('UNRESTORABLE')
else:
    S2=S.replace('?','a')
    print(S2)
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for l in range(n)]
flag = True
ans = 0
i = a[0]
while flag:
  i = a[i-1]
  ans += 1
  if i == 2:
    print(ans+1)
    flag = False
 
  if ans >= n-1:
    print(-1)
    flag = False
# Judge status: Wrong Answer
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
ans=0
for i in range(1,n+1,2):
    s=set()
    for j in range(1,int(pow(i,0.5)+1)):
        if i%j==0:
            s.add(j)
            s.add(i//j)
    if len(s)==8:
        print(s)
        ans+=1
print(ans)
# Judge status: Accepted
N, A, B = list(map(int,input().split()))
S = input()
p = fp = 0
for s in S:
    if s=="a" and p<A+B:
        print("Yes")
        p += 1
    elif s=="b" and p<A+B and fp<B:
        print("Yes")
        p += 1
        fp += 1
    else:
        print("No")
# Judge status: Wrong Answer
n = int(input())
robots = []
for _ in range(n):
  x,l = map(int,input().split())
  a,b = x-l,x+l
  robots.append((a,b))
robots.sort(key = lambda x:x[1])

ex_a = ex_b = -1
count = 0

for a,b in robots:
  if a >= ex_b:
    ex_b = b
    count += 1
  else:
    continue
print(count)
# Judge status: Accepted
S = input()
T = input()
ans = ""
for i in range(len(S)-len(T)+1):
  u = S[i:i+len(T)]
  flag = True
  for j in range(len(T)):
    if u[j] == T[j] or u[j] == "?":
      continue
    else:
      flag = False
      break
  if flag:
    ans = S[0:i] + T + S[i+len(T):]
if ans != "":
  print(ans.replace("?","a"))
else:
  print("UNRESTORABLE")
# Judge status: Accepted
N = int(input())
A = []
for i in range(N):
  a = list(input().split())
  A.append([a[0], -int(a[1]), i+1])
A.sort()
for i in range(N):
  print(A[i][2])
# Judge status: Wrong Answer
from sys import stdin


def main(inp1, inp2):
    n, k = [int(i) for i in inp1.split(sep=' ')]
    h_list = sorted([int(i) for i in inp2.split(sep=' ')])

    print(h_list)
    num_enemy = n
    enable_special = k

    if enable_special >= num_enemy:
        return 0
    elif enable_special == 0:
        return sum(h_list)
    else:
        return sum(h_list[:-enable_special])


if __name__ == '__main__':
    input1 = stdin.readline().rstrip()
    input2 = stdin.readline().rstrip()
    ret = main(input1, input2)
    print(ret)
# Judge status: Accepted
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = [list(map(int,input().split())) for _ in range(m)]
ans = min(a) + min(b)

for i in range(m):
	ans = min(a[x[i][0]-1] + b[x[i][1]-1] - x[i][2],ans)
print(ans)
# Judge status: Accepted
D,N = map(int, input().split())
ans = (N+N//100)*100**D
print(ans)
# Judge status: Accepted
a,b,k = map(int,input().split())

if k <= a:
  print(a-k,b)
elif k <= a+b:
  print(0,b+a-k)
else:
  print(0,0)
# Judge status: Wrong Answer
import math
N = int(input())
print(math.floor(math.sqrt(N))**2)
# Judge status: Wrong Answer
# ABC-142-D
A, B = map(int, input().split())
ans = 1

#最大公約数
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def factorize(x):
    factor = []
    for num in range(2, int(x**0.5)+1):
        while x % num == 0:
            x //= num
            factor.append(num)
        if x != 1:
            factor.append(x)
    return set(factor)
    
gcd_AB = gcd(A, B)
prime = factorize(gcd_AB)
ans += len(prime)
print(ans)
# Judge status: Accepted
s = input()
k = int(input())
for i in range(len(s)):
    if s[i] == "1":
        k -= 1
    else:
        k-=10**19
    if k <= 0:
        print(s[i])
        break
# Judge status: Accepted
s=input()
x=['A','T','C','G']
a=[0]*len(s)
if s[0] in x:
  a[0]=1
for i in range(1,len(s)):
  if s[i] in x:
    a[i]=a[i-1]+1
print(max(a))
# Judge status: Accepted
def is_month( n :int ):
  return ( 1 <= n ) and ( n <= 12 )

def judge( first, second ):
  if (first and second):
    return "AMBIGUOUS"
  elif (first and not(second)):
    return "MMYY"
  elif (not( first ) and second):
    return "YYMM"
  else:
    return "NA"

s = input()
first = is_month( int( s[0:2] ))
second = is_month( int( s[2:4] ))
print( judge( first, second ) )
# Judge status: Accepted
h,n = map(int,input().split())
a = list(map(int,input().split()))
print("YNeos"[sum(a)<h::2])
# Judge status: Accepted
a, b, c, d = map(int, input().split())
if (abs(a-b)<=d and abs(c-b)<=d) or (abs(a-c)<=d):
    print("Yes")
else:
    print("No")