peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
X,Y = map(int,input().split())
MOD = 10**9+7

if (X+Y)%3:
    print(0)
    exit()
n = (X+Y)//3
r = X-n
if not 0 <= r <= n:
    print(0)
    exit()

MAXN = r
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
def comb(n,r):
    ret = 1
    for i in range(r):
        ret *= n-i
        ret *= inv[i+1]
        ret %= MOD
    return ret

print(comb(n,r))
# Judge status: Accepted
# A,B,C = map(int, input().split())
N = int(input())
# s = int(input())
# C = int(input())
# s= input()
print((N/2)/N if N%2 == 0 else (N//2+1)/N)
# Judge status: Wrong Answer
a,b = map(int,input().split())

r = b*2+1

if a%b == 0:
    print(a//r)
else:
    print(a//r+1)
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-

(A, B, C, X) = [int(input()) for i in range(4)]

r = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                r += 1

print(r)
# Judge status: Wrong Answer
h = int(input())
w = int(input())
n = int(input())
print(n % max(h,w))
# Judge status: Accepted
# -coding: utf-8 -

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

s = range(a,b+1)
s_small = s[:k]
s_large = s[-k:]
ans = list(set(s_small)|set(s_large))
ans = sorted(ans)
for i in ans:
    print(i)
# Judge status: Accepted
def resolve():
    n, x = map(int, input().split())
    a = [int(i) for i in input().split()]
    a = sorted(a)

    ans = 0
    for _a in a[:-1]:
        x = x - _a
        if x >= 0:
            ans += 1
    if x == a[-1]:
        ans += 1
    print(ans)


resolve()
# Judge status: Accepted
a, b, c, k = input().split()
count = 0
if int(a) <= int(k):
  count += int(a)
  if int(k)-int(a) >= int(b):
    count -= int(k)-int(a)-int(b)
else:
  count = int(k)
print(count)
# Judge status: Wrong Answer
N,M = input().split()
A=list(map(int, input().split())) 

N=int(N)
M=int(M)
total=sum(A)
cnt=0
for i in range(N):
  if A[i]>total*(1/(4*M)):
  	cnt=cnt+1
    
if cnt>=M:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n, m = list(map(int, input().split()))
#n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
# n = int(input())
# n, m = list(map(int, input().split()))
if n >= m:
    print(0)
else:
    x.sort()
    ans = x[-1]-x[0]
    p = []
    for i in range(m-1):
        p.append(x[i+1]-x[i])
    p.sort(reverse=True)
    for i in range(n-1):
        ans -= p[i]
    print(ans)
# Judge status: Wrong Answer
# coding: utf-8

X, N = map(int, input().split())
P = list(map(int, input().split()))
Ans = X

for i in range(N // 2):
  if not(X - i in P):
    Ans = X - i
    break
  elif not (X + i in P):
    Ans = X + i
    break

print(Ans)
# Judge status: Accepted
arr = list(input().split())
print( arr[0][0] + arr[1][0] + arr[2][0] )
# Judge status: Accepted
import statistics
n=int(input())
x=list(map(int,input().split()))
y=statistics.median(x)
xs=sorted(x)
for i in x:
    if i<y:
        print(xs[n//2])
    else:
        print(xs[n//2-1])
# Judge status: Accepted
H, A = map(int, input().split())
count = 0
while(1):
    count += 1
    H = H - A
    if H <= 0:
        break
print(count)
# Judge status: Accepted
def solve():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    ret = 0
    total = 0
    for i in range(N)[::-1]:
        diff = (-1*(AB[i][0]+ret))%AB[i][1]
        ret += diff
        
    print(ret)
    
solve()
# Judge status: Wrong Answer
D, T, S = map(int, input().split())
if (S * T >= D):
    print("Yes")
else:
    print("NO")
# Judge status: Wrong Answer

n,m,x,y = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0 #0 = War, 1= No War

A.sort()
B.sort()
#print(A[-1])
#print(B[0])

for i in range(x+1,y+1):
    if A[-1]<i and B[0]>=i:
        print(i)
        pass
    else:
        ans = 1
        print("ans")

if ans == 1:
    print("No War")
else:
    print("War")
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
ans = max(l)
for i in l:
  count = 0
  while i % 2 == 0:
    count += 1
    i //= 2
  ans = min(ans,count)
  if ans == 0:
    print(0)
    exit()
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
print("Yes" if c-a-b>=0 and 4*a*b<(c-a-b)**2 else "No")
# Judge status: Accepted
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]

if x==y:
  print("Yes")
else:
  if (x in a and y in a) or (y in b and x in b):
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
a=[int(n) for i in input().split()]
b=[int(n) for i in input().split()]
c=[int(n) for i in input().split()]

s=sum(b)

for i in range(n-1):
    if a[i+1]-a[i]==1:
        s+=c[a[i]-1]
print(s)
# Judge status: Wrong Answer
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a,b = map(int,input().split())
li = []
for i in range(1,1001):
    li.append((1/2)*i*(i+1))
for i in range(len(li)):
    if li[i]>=a and li[i]<=b:
        check = i
        break
print(int(li[check]-a))
# Judge status: Accepted
import collections
w = input()
c = collections.Counter(w).most_common()
for i in c:
    if i[1] % 2 != 0:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
A, B = [int(i) for i in input().split()]
if A < 6:
    print(0)
elif A < 13:
    print(B // 2)
else:
    print(B)
# Judge status: Accepted
n,a,b,c,d = map(int,input().split())
s = input()
a,b,c,d = a-1,b-1,c-1,d-1
if s[a:c+1].count('##') > 0 or s[b:d+1].count('##') >0:
  print('No')
  exit()
if c > d:
  if s[b-1:d+2].count('...') == 0:
    print('No')
    exit()
print('Yes')
# Judge status: Accepted
S=input()
if len(set(S))==3:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans=[]
for i in range(n):
	ans.append(a-(t-h[i]*0.006))
print(ans.index(min(ans))+1)
# Judge status: Wrong Answer

K=list(map(int,input().split()))
ans=0
for i in range(1,min(K[0],K[1]+1)):
    if K[0]%i==0 and K[1]%i==0:ans+=1
    if ans==K[2]:
        print(i)
        break
# Judge status: Accepted
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
s = 1
for i in range(-100,101):
    if X < i <= Y and max(x) < i <= min(y):
        s = 0
print(["No War","War"][s])
# Judge status: Wrong Answer
from collections import Counter
from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

for i in range(n):
    tmp_c = deepcopy(c)
    ans = 0
    tmp_c[a[i]] -= 1
    for v in tmp_c.values():
        ans += v*(v-1)/2
    print(ans)
# Judge status: Accepted
n, x, t = map(int,input().split())

act = n // x

if n % x != 0:
    act += 1

print(int(act * t))
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
min_ab = (N-1)*A+B
max_ab = (N-1)*B+A
print(max_ab-min_ab+1)
# Judge status: Accepted
n,k = map(int, input().split())
num_list = list(map(int, input().split()))

num_list.sort()
min_list = num_list[:k]
min = sum(min_list)
print(min)
# Judge status: Wrong Answer
n,m=map(int,input().split())
li=[[] for i in range(n)]
for i in range(m):
    ai,bi=map(int,input().split())
print("No")
# Judge status: Accepted
N = int(input())
A = [int(input()) for _ in range(N)]
B = max(A)
C = [B]*N
D = sorted(A)[-2]
i = A.index(B)
if A.count(B) == 1:
    C[i] = D

for a in C:
    print(a)
# Judge status: Accepted
n,a,b=map(int,input().split())
q,r = n//(a+b),n%(a+b)
print(q*a + min(r,a))
# Judge status: Accepted
N=int(input())
s=[]
sum=0
for i in range(N):
    s.append(int(input()))
    sum+=s[i]
if(sum%10!=0):
    print(sum)
    exit()
else:
    m=0
    for i in range(N):
        t=sum-s[i]
        m=max(t,m) if t%10!=0 else m
    print(m)
# Judge status: Wrong Answer
from collections import Counter
N,K,Q = map(int,input().split())

A = [int(input()) for _ in range(Q)]
c = dict(Counter(A))
print(c)
for i in range(1,N+1):
    if i in c:
        t = Q - c[i]
        print('Yes' if t < K else 'No')
    else:
        print('Yes' if Q < K else 'No')
# Judge status: Wrong Answer
import numpy as np
n, m = map(int, input().split())

mat = [[0] * n] * n
mat = np.array(mat)

for i in range(m):
    a, b = map(int, input().split())
    mat[a - 1, b - 1] = 1
    mat[b - 1, a - 1] = 1


for i in range(n):
    ans = np.sum(mat[i, :])
    print(ans)
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
print("A" if abs(a - x) < abs(a - x) else "B")
# Judge status: Wrong Answer
print('YNeos'[input()==input()[::-1]::2])
# Judge status: Wrong Answer
S = input()
T = input()

if len(T) - len(S) == 1:
    if S in T:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Wrong Answer
def main():
    N, *AB = map(int, open(0).read().split())
    ans = 0
    for i in range(N - 1, 0, -1):
        a = AB[i * 2 + 0]
        b = AB[i * 2 + 1]
        ans += (b - a - ans) % b
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
A = {num: i+1 for i,num in enumerate(map(int, input().split()))}

for i in range(1, N+1):
    if i == N:
        print(A[i])
    else:
        print(A[i], end=" ")
# Judge status: Accepted
_input = input().split(" ")
_A = int(_input[0])
_B = int(_input[1])

if _A + _B < 24:
  print(_A + _B)
else:
  print(_A + _B - 24)
# Judge status: Wrong Answer
import sys
# input=sys.stdin.readline

val = []
val = input()

arrays = val.split(' ')
a = int(arrays[0])*500

if a>=int(arrays[1]):
    print("Yes")
elif a<int(arrays[1]):
    print("No")

print(arrays, a)
sys.exit()
# Judge status: Wrong Answer
n = int(input())
a,b,c=0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    sa = t-a
    if sa<x+y:
        print("No")
        exit()
    else:
        tw = sa-x-y
        if tw%2!=0:
            print("No")
            exit()
print("Yes")
# Judge status: Accepted
fn=str
n,k=map(int, input().split())
ds=list(map(fn, input().split()))
while any(i in fn(n) for i in ds):
  n+=1
print(fn(n))
# Judge status: Accepted
k=int(input())
s=input()

if len(s)<=k:
    print(s)
else:
    print(s[:k]+'...')
# Judge status: Accepted
h, n = map(int, input().split())
a = [int(i) for i in input().split()]

sum = 0
for i in range(n):
	sum += a[i]

print("Yes" if h <= sum else "No")
# Judge status: Wrong Answer
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
c.sort()
ans = 0
print(a)
print(b)
print(c)
for i in range(n):
    ans += bisect.bisect_left(a,b[i])*n-(bisect.bisect_right(c,b[i]))
print(ans)
# Judge status: Wrong Answer
n = int(input())

if n >= 1000:
  print('ABC')
else:
  print('ABD')
# Judge status: Accepted
def main():
    x,y,a,b,c=map(int,input().split())
    P=list(map(int,input().split()))
    P.sort(reverse=True)
    Q=list(map(int,input().split()))
    Q.sort(reverse=True)
    R=list(map(int,input().split()))
    A=P[:x]+Q[:y]+R
    A.sort(reverse=True)
    print(sum(A[:x+y]))
    
if __name__=='__main__':
    main()
# Judge status: Accepted
a=sorted(list(map(int,input().split())))
print("YES" if a == [5,5,7] else "NO")
# Judge status: Accepted
s = input()
t = len(s)
l = [999]*(t - 2)
for i in range(t - 2):
    u = int(s[i:i+3])
    if u <= 753:
        l[i] = 753 - u
    else:
        l[i] = u - 753
print(min(l))
# Judge status: Accepted
h = int(input())
w = int(input())
n = int(input())
x = 0
y = 0

c = 1

if h > w:
    x = h
    y = h
else:
    x = w
    y = w

while x < n:
    c += 1
    x += y
print(c)
# 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():
    (*A,) = map(int, read().split())
    k = A[-1]

    for i in range(5):
        for j in range(i + 1, 5):
            if A[j] - A[i] > k:
                print(':(')
                return

    print('Yay!')
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
X = int(input())

mod = X % 100
syou = X // 100

if (mod <= syou * 5):
    print('1')
else:
    print('0')
# Judge status: Wrong Answer
n,m = map(int,input().split())
l_max=0
r_min=n 
for i in range(m):
  l,r = map(int,input().split())
  l_max = max(l_max,l)
  r_min = min(r_min,r)
print(r_min - l_max+1)
# Judge status: Wrong Answer
#!/usr/bin/env python3
n, k, *x = map(int, open(0).read().split())
ans = 10**18
neg = []
pos = [0]
for i in x:
    if i < 0:
        neg.append(i)
    else:
        pos.append(i)
neg.append(0)
k += 1
c = len(neg)
c -= k -min(k, len(pos))
k = min(k, len(pos))
while c > 0 and k > 1:
    c -= 1
    k -= 1
    ans = min(ans, -neg[c] * 2 + pos[k], -neg[c] + pos[k] * 2)
print(ans)
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))


ans = 0
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
    else:
        ans = max(cnt, ans)
        cnt = 0
print(ans)
# Judge status: Accepted
st = input()
if st == 'A'*3 or st == 'B'*3:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
N = int(input())
for i in range(0,8):
    if 2**i <= N:
        ans = 2**i
print(ans)
# Judge status: Accepted
N,X,Y=map(int,input().split())
A=[0]*(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
    A[min(j-i,abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))-1]+=1
for a in A:
  print(a)
# Judge status: Wrong Answer
#入力受け取り N=個数 X=焼ける数 T=時間
N,X,T = map(int, input().split())

#回数定義
count = 0

#NがXで割り切れなければ+1
if N % X == 0:
    count = N / X
else:
    count = N // X + 1

#回数×時間
ans = count * T
print(ans)
# Judge status: Accepted
r, g, b = map(int, input().split())
if (g*10+b) % 4 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
import math
N,M = (int(y) for y in input().split())
A = list(map(int, input().split()))
X = math.ceil(sum(A)/(4*M))
B = [i for i in A if i >= X]
print(sum(A))
print(X)
print(B)
if len(B) >= M:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a, b = map(int, input().split())
c = 0

for i in range(a, b+1):
    j = str(i)
    if j[0] == j[4] and j[1] == j[3]:
        c += 1

print(c)
# Judge status: Accepted
N, R = map(int, input().split())
if N >= 10:
    print(R)
else:
    print(R + (100 * (10 - N)))
# Judge status: Wrong Answer
n=int(input())
max=0
for i in range(1,n):
    if i**2<=n:
        if i**2>max:
            max=i**2
    else:
        break
print(max)
# Judge status: Wrong Answer
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
import numpy as np
# D

N, M = list(map(int, input().split()))
ABs = np.array([list(map(int, input().split())) for i in range(M)])

row = list(ABs.T[0]-1)
col = list(ABs.T[1]-1)
data = [1] * (M)

csr = csr_matrix((data, (row, col)), shape=(N, N))
from_starts, procs = dijkstra(csr, indices=[0], directed=False, return_predecessors=True)
proc = procs[0]+1
 
if -9999 in proc[1:]:
  print('No')
else:
  print('Yes')
  for i in range(N-1):
    print(proc[i+1])
# Judge status: Wrong Answer
a,b = map(int,(input().split()))
i = 1
result = 0
#雪の高さX
#1 3 6 10
left = 0
right =0
while True:
    result = result + i
    i += 1
    if result > a:
        left = result
        break 

while True:
    result = result + i
    i += 1
    if result > b:
        right = result
        break 



print(left - a)
#print(right)
# Judge status: Accepted
word = input()
if word[-1] == 's':
  print(word, end='es\n')
else:
  print(word, end='s\n')
# Judge status: Accepted
# ABC 155: A – Poor
n = [int(s) for s in input().split()]
print('Yes' if n.count(n[0]) == 2 or n.count(n[1]) == 2 or n.count(n[2]) == 2 else 'No')
# Judge status: Wrong Answer
l, r = map(int, input().split())
rem = []
mod = 2019
if r - l + 1 > 2019:
    ans = 0
else:
    for i in range(l, r+1):
        rem.append(i % mod)
    rem.sort()
    ans = rem[0]*rem[1] % mod
    # print(rem[0], rem[1])
print(ans)
# Judge status: Accepted
W,a,b=map(int,input().split())
if a<=b:
  if a+W<=b:
    print(b-W-a)
  else:
    print(0)
else:
  if b+W<=a:
    print(a-W-b)
  else:
    print(0)
# Judge status: Wrong Answer
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, A = list(map(int,readline().split()))
print(H // A + 1)
# Judge status: Wrong Answer
data1 = list(map(str, input().split()))
data2 = list(map(str, input().split()))

count = len(data1) - 1
sw = 0
i = 0
j = len(data2)-1
while i <= count:
    if data1[i] == data2[j]:
        sw += 1
        print(data1[i],data2[j])
    i += 1
    j -= 1
if sw == len(data1):
    print("Yes")
else:
    print("No")
# Judge status: Accepted


if __name__ == "__main__":
    N = int(input())
    a_str = list(map(int, input().split(" ")))

    min_a = min(a_str)
    max_a = max(a_str)

    min = float("inf")
    ans = 0
    for i in range(min_a, max_a):

        temp = sum(list(map(lambda x: (x - i)**2, a_str)))
        if min > temp:
            min = temp
            ans = temp
    print(ans)
# Judge status: Accepted
N,K = map(int,input().split())

N %= K
print(min(N,K-N))
# Judge status: Accepted
N=int(input())

P= [tuple(map(int,input().split())) for i in range(N)]


from math import sqrt
def d(p1,p2):
    x1,y1=p1
    x2,y2=p2
    return sqrt((x1-x2)**2 + (y1-y2)**2)

s=0
n=0

import itertools
from functools import reduce
for p in itertools.permutations(P):
    s += sum( [ d(p[i],p[i+1]) for i in range(N-1) ] )
    n+=1
print(s/n)
# Judge status: Accepted
n = int(input())

c = 0
for i in range(1,n+1):
    cc = 0
    if i % 2 == 1:
        for j in range(1,i+1):
            if i % j == 0:
                cc += 1
        if cc == 8:
            c += 1

print(c)
# Judge status: Wrong Answer
import decimal
decimal.getcontext().prec = 5
S = input().split()
A = int(S[0])
B = float(S[1])

B = decimal.Decimal(B)

print(int((A*B)/1))
# Judge status: Wrong Answer
N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))

l = []
count = -1

for i in range(N):
    count+=1
    total_li = sum(candies_i[:count])
    total_lj = sum(candies_j[count:])
    total = total_li + total_lj
    l.append(total)

print(max(l))
# Judge status: Accepted
_input_list = list(map(int, input().split(" ")))
a = _input_list[0]
b = _input_list[1]
c = _input_list[2]
d = _input_list[3]

alice_push_time = set(list(range(a, b + 1))) 
bob_push_time = set(list(range(c, d + 1)))

both_push_time = len(alice_push_time & bob_push_time)


if both_push_time > 0:
  both_push_time -= 1
print(both_push_time)
# Judge status: Wrong Answer
N = int(input())
D = list(map(int, input().split()))
SD = sorted(D)
m = len(D) // 2
med = (SD[m - 1] + SD[m]) // 2
l, h = 0, 0
for d in SD:
	if d < med:
		l = d
	elif h == 0:
		l = min(med, l + 1)
		h = d
		break
if h != l:
	print(h - l + 1)
else:
	print(0)
# Judge status: Accepted
S = input()
if S.count('N') > 0 and S.count('S') == 0 or S.count('N') == 0 and S.count('S') > 0 or S.count('W') > 0 and S.count('E') == 0 or S.count('W') == 0 and S.count('E') > 0:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
n = int(input())

mod = 10 ** 9 + 7

re = (10 ** n) - (2 * (9 ** n)) + (8 ** n)

if n == 1:
    print(0)
else:
    print(re)
# Judge status: Accepted
X = int(input())

dp = [False] * (X + 1)
dp[0] = True
for i in range(X):
  if dp[i]:
    for x in [100, 101, 102, 103, 104, 105]:
      if i+x <= X:
        dp[i+x] = True

if dp[-1]:
  print(1)
else:
  print(0)
# Judge status: Accepted
a = list(map(int, list(input())))
if all(a[i]!=9 for i in range(len(a))):
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
a, b, x = map(int, input().split())

i = a
j = b
while i % x != 0:
  i+= 1

while j % x != 0:
  j-= 1
  
ans = (j- i)/ x+ 1

if(ans<= 0):
  print(0)
else:
  print(int(ans))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)
count = 0
for i in range(n, 3*n, 2):
    count += a[i]
print(count)
# Judge status: Accepted
N=int(input())
if N%1000:
    print(1000-N%1000)
else:
    print(0)
# Judge status: Accepted
from sys import stdin
from math import floor,ceil

N, K = map(int, input().rstrip().split())
A = [int(x) for x in stdin.readline().rstrip().split()]

def is_max_len_less_than_input(x,K,A):
  count = 0
  if x==0:
    return False
  for ln in A:
    count += ceil(ln/x)-1
    if count > K:
      return False
  return True

def binary_search(begin,end,K,A):
  while abs(end-begin)>1:
    mid = (begin+end)//2
    if is_max_len_less_than_input(mid,K,A):
      end = mid
    else:
      begin = mid
  return end

print(binary_search(0,max(A),K,A))
# Judge status: Accepted
from collections import deque
from bisect import bisect_left
N = int(input())
A = [int(input()) for i in range(N)]

X = deque([])

for a in A:
  i = bisect_left(X,a)
  if i == 0:
    X.appendleft(a)
  else:
    X[i-1] = a
print(len(X))
# Judge status: Accepted
s = input()

n = len(s)

a = 0
b = 0
c = 0

for i in range(n):
    if s[i] == 'a':
        a += 1
    elif s[i] == 'b':
        b += 1
    else:
        c += 1
min_num = min(a,b,c)
a -= min_num
b -= min_num
c -= min_num

if a <= 1 and b <= 1 and c <= 1:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
N,K,S = map(int,input().split())
if S == 10**9:
    ans = [str(S)]*K + ["1"]*(N-K)
else:
    ans = [str(S)]*K + [str(S+1)]*(N-K)
print(" ".join(ans))
# Judge status: Accepted
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xyc=[]
for _ in range(M):
    x,y,c=map(int,input().split())
    xyc.append([x,y,c])
mi=min(a)+min(b)
for i in range(M):
    e=xyc[i][0]-1
    f=xyc[i][1]-1
    g=xyc[i][2]
    h=a[e]+b[f]-g
    mi =min(mi,h)
print(mi)
# Judge status: Wrong Answer
import math

n = int(input())

d = {}
ans = 0
for i in range(n):
    s = str(input())
    s = "".join(sorted(list(s)))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

for j in d.values():
    if j == 1:
        pass
    else:
        ans += math.factorial(j)//2
        

print(ans)
# Judge status: Wrong Answer
n,m,x=map(int,input().split())
lis=[list(map(int,(input().split()))) for i in range(n)]

c=10**5+1
p=0
for i in range(1,2**n+1):
    al=[0]*m
    cost=0
    for j in range(n):
        if (i>>j)&1:
            for k in range(m):
                al[k]+=lis[j][k]
            cost+=lis[j][0]
    if min(al)>=x:
        c=min(c,cost)
        p=1
print(c) if p==1 else print(-1)
# Judge status: Wrong Answer
n,m = map(int, input().split())
x = sorted(list(map(int, input().split())))
print(sum(sorted([abs(x[i+1]-x[i]) for i in range(m-1)])[:-(n-1)]))
# Judge status: Accepted
n,k = map(int,input().split())
h = sorted([int(input()) for i in range(n)])
res = [0]*(n-k+1)
for i in range(n-k+1):
    res[i] = h[i+k-1]-h[i]
print(min(res))
# Judge status: Wrong Answer
a,b,x = map(int,(input().split()))
if a <= x <= b:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N,L=map(int,input().split())
S=[input() for i in range(N)]
S=sorted(S)
print("".join(S))
# Judge status: Accepted
N = int(input())
t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0) + abs(y - y0)
    time = t - t0
    if (abs(kyori - time)) % 2 == 0 and time - kyori >= 0:
        t0, x0, y0 = t, x, y
    else:
        print('No')
        exit(0)
print('Yes')
# Judge status: Accepted
N, K, S = map(int, input().split())
A = [S] * K
A.extend([S + 1 if S < 10**9 else 1] * (N - K))
print(" ".join(str(a) for a in A))
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

s = A, B, C
print('Yes') if s.count(5) == 2 and s.count(7) == 1 else print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
ans = float('inf')
l_sum = 0
r_sum = sum(A)
for i in range(N):
    l_sum += A[i]
    r_sum -= A[i]
    ans = min(ans, abs(r_sum - l_sum))

print(ans)
# Judge status: Wrong Answer
k = int(input())
a,b = list(map(int,input().split()))

flag=False
for i in range(a,b+1):
    if i % k == 0:
        flag =True


if(flag):
    print('OK')
else:
    print('NO')