peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from fractions import gcd
N, M = map(int, input().split())
S = list(map(int, input().split()))

temp = S[0]
cnt = 0
while temp%2 == 0:
    temp //= 2
    cnt += 1
temp = S[0]
for i in range(1, N):
    temp = temp*S[i]//gcd(temp, S[i])
    if S[i]%(2**cnt) == 1 or (S[i]//(2**cnt))%2 == 0:
        print(0)
        break
else:      
    if temp//2 > M:
        print(0)
    else:
        print((M-temp//2)//temp+1)
# Judge status: Wrong Answer
N, K = map(int, input().split())
S = list(input())
r_cnt = 0
answer = 0
before = S[0]
for s in S:
  if s == before:
    answer += 1
  else:
    r_cnt += 1
    before = s
answer -= 1
print(answer, r_cnt)
if r_cnt%2 == 0:
  print(answer+min(r_cnt//2, K)*2)
elif r_cnt//2 >= K:
  print(answer+K*2)
else:
  print(answer+r_cnt*2-1)
# Judge status: Accepted
n=int(input())
x=800*n
y=n//15*200
print(x-y)
# Judge status: Accepted
a,b,c = input().split(None, 3)
A = int(a)
B = int(b)
C = int(c)
if A == B and B == C:
    print("No")
elif A != B and A != C and B != C:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
A, B = map(int, input().split())
S = input()

def judge(S):
	if S[A] != "-":
		return False
	if len(S) != A+B+1:
		return False

	S = S[:A] + S[A+1:]

	if not S.isdigit():
		return False
	return True

print("Yes") if judge(S) else print("No")
# Judge status: Accepted
def main():
    S = input()
    K = int(input())

    tmp = ''
    count = 0
    for s in S:
        if s == '1':
            count += 1
        else:
            tmp = s
            break

    if count >= K:
        print('1')
    else:
        print(tmp)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
n = int(input())
print((math.floor(math.sqrt(n))**2))
# Judge status: Accepted
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
total = 0
for k, v in c.items():
  total += v* (v-1)/2
for a in A:
  print(int(total - c[a]+1))
# Judge status: Accepted
from fractions import gcd
n = input()
s = list(map(int,input().split()))
L = 1
for i in s:
  L = L * i //gcd(L,i)
ans = 0
for j in s:
  ans += L // j
print(ans % (10**9+7))
# Judge status: Accepted
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])
a=[a for a,b in ab]
b=[b for a,b in ab]
a.sort()
b.sort()
l=0
if n%2==1:
  print(b[n//2]-a[n//2]+1)
  #print(b[n//2],a[n//2])
else:
  am=(a[n//2]+a[n//2-1])
  bm=(b[n//2]+b[n//2-1])
  print(bm-am+1)
# Judge status: Wrong Answer
x,a,b = map(int, raw_input().split())
print 'delicious' if b - a <= x else 'dangerous'
# Judge status: Accepted
import sys
# import math
from decimal import *
input = sys.stdin.readline

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


if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = list(input())
K = int(input())
l = len(s)
for i in range(l-1):
    x = (ord('a')-ord(s[i])) % 26
    if x <= K:
        K -= x
        s[i] = 'a'
s[l-1] = chr(ord('a') + (ord(s[-1])-ord('a')+K) % 26)
print(''.join(s))
# Judge status: Accepted
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

aa = [0]
bb = [0]
for i in range(n):
    aa.append(a[i]+aa[-1])
for i in range(m):
    bb.append(b[i]+bb[-1])
ans = 0
j = m
for i in range(n+1):
    r = k - aa[i]
    while bb[j] > r and j >= 0:
        j -= 1
    if j >= 0:
        ans = max(ans, i+j)
print(ans)
# Judge status: Accepted
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

max_index = A.index(max(A))
A.sort(reverse=True)

for i in range(N):
    if i==max_index:
        print(A[1])
    else:
        print(A[0])
# Judge status: Accepted
n,k,q=map(int,input().split())
a=[]
[a.append(int(input())-1) for _ in range(q)]
i=[k-q]*n

for l in range(q):
    i[a[l]] += 1

for l in range(n):
    if i[l] <= 0:
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
N,M,X,Y=map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))
x.append(X)
y.append(Y)
if max(x)>=min(y):
  print('War')
else:
  print('No War')
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if abs(b-a)>10**18:
    print("Unfair")
else:
    if k%2==0:
        print(a-b)
    else:
        print(b-a)
# Judge status: Wrong Answer
N=int(input())
S=input()

left=0
right=0
cnt1=0
cnt2=0

for i in range(N):
    if S[i]=="(":
        cnt1+=1
    elif S[i]==")":
        cnt2+=1
        if i<N-2 and S[i+1]=="(":
            left+=max(0,cnt2-cnt1)
            right+=max(0,cnt1-cnt2)
            cnt1=0
            cnt2=0

left+=max(0,cnt2-cnt1)
right+=max(0,cnt1-cnt2)

print("("*left+S+")"*right)
# Judge status: Wrong Answer
n = int(input())
a = int(input())
print("Yes" if n < a or (n - a) % 500 == 0 else "No")
# Judge status: Accepted
H,N = map(int,input().split())
magic = [list(map(int,input().split())) for i in range(N)]

INF = 10**10
#print(magic)

AM = 0
for i in range(N):
    AM = max(AM,magic[i][0])
#print(AM)


dp = [INF for i in range(H+AM+1)]
dp[0] = 0

for i in range(1,H+AM+1):
    for j in range(N):
        if magic[j][0] > i:
            dp[i] = min(dp[i],magic[j][1])
        else:
            dp[i] = min(dp[i-magic[j][0]]+magic[j][1],dp[i])
ans = INF
print(dp[H])
# Judge status: Accepted
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()


def main():
    N, T = map(int, input().split())
    roads = [tuple(map(int, input().split())) for _ in range(N)]
    roads = [(c, t) for c, t in roads if t <= T]
    print('TLE' if len(roads) == 0 else min(c for c, _ in roads))

main()
# Judge status: Accepted
#ABC097
import math
x = int(input())
l = [1]
for i in range(int(math.sqrt(x))+1):
    for j in range(2,100):
        if i ** j > x:
            l.append(i ** (j-1))
            break
            
print(max(l))
# Judge status: Accepted
s = input()
if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
elif s == 'SAT':
  print(1)
# Judge status: Wrong Answer
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))

def kitai(dice):
	#期待値を求める
	S=0
	for p in range(dice):
		S+=p+1
	return S/dice


result=[]
for i in range(K):
	if (K+i)<=N:
		m=p[i:(K+i)]
		Sum=0
		for j in m:
			Sum+=kitai(j)
		result.append(Sum)
print(max(result))
# Judge status: Wrong Answer
s=input()
n=len(s)
for i in range(1,n+1):
  if s[0:i]==s[i:i+i]:
    print(i)
    break
# Judge status: Wrong Answer
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, m = nm()

aa = nl()

mx = sum(aa)/(4*m)

a = sorted(aa)[::-1]


for i in range(m):
  if a[i] <= mx:
    print('No')
    exit()
print('Yes')
# Judge status: Accepted
a,b = map(int, input().split())

if a * b < 0:
    print('Zero')
    exit()
elif a > 0 and b > 0:
    print('Positive')
    exit()
else:
    if abs(a-b) % 2 == 0:
        print('Negative')
    else:
        print('Positive')
# Judge status: Accepted
n, m = map(int, input().split()) # 'S':n 'c':m

if n <= m // 2:
    m -= 2 * n
    print(n + m // 4)
else:
    print(m // 2)
# Judge status: Wrong Answer
a, b = map(int, input().split())
x = a + b
if x % 2 == 0:
  print(x/2)
else:
  print((x + 1)/2)
# Judge status: Accepted
a,b,c = map(int,input().split())
k = int(input())
count = 0
while a>=b:
    count+=1;b*=2
while b>=c:
    count+=1;c*=2
print(['No','Yes'][count<=k])
# Judge status: Accepted
n=int(input())
a=[]
ans=0
for i in range(n):
    a.append(int(input()))
    if(i>0 and a[-2]==1 and a[-1]>0):
        ans+=1
        a[-2]-=1
        a[-1]-=1
    ans+=a[-1]//2
    a[-1]=a[-1]%2
    if(i>0 and a[-2]==1 and a[-1]==1):
        ans+=1
        a[-2]-=1
        a[-1]-=1

print(ans)
# Judge status: Accepted
n,m,x,y=map(int,input().split())
xl=list(map(int,input().split()))
yl=list(map(int,input().split()))
a=max(x,max(xl))
b=min(y,min(yl))
if b-a<=0:
  print('War')
else:
  print('No War')
# Judge status: Wrong Answer
n = int(input())
x,y = map(int,input().split())
maxplus = x+y
minplus = x+y
maxminus = x-y
minminus = x-y
for i in range(n-1):
  x,y = map(int,input().split())
  if x+y > maxplus:
    maxplus = x+y
  elif x+y < minplus:
    minplus = x+y
  elif x-y > maxminus:
    maxminus = x-y
  elif x-y < minminus:
    minminus = x-y
print(max(maxplus-minplus,maxminus-minminus))
# Judge status: Wrong Answer
a=input()
a=list(map(int,input().split()))
count=0
for itr in range(len(a)):
    if itr+1==a[itr]: count+=1
if count==0: print(0)
elif count%2==0:
    print(count//2)
else: print(count//2+1)
# Judge status: Accepted
n, m = [int(i) for i in input().split()]
if n >= 3 and m >= 3:
    ans = (n - 2) * (m - 2)
elif n == 1 and m == 1:
    ans = 1
elif n == 1 and m >= 2:
    ans = m - 2
elif n >= 2 and m == 1:
    ans = n - 2
elif n == 2 or m == 2:
    ans = 0

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

l_plus = []
for i in range(n):
    tmp = [l[i], i+1]
    l_plus.append(tmp)

l_plus.sort()

for j in l_plus:
    print(j[1], end = ' ')
# Judge status: Accepted
#!/usr/bin/env python

x = int(input())
t = x-11*(x//11)
if t <= 6:
    if x%11 != 0:
        ans = 2*(x//11)+1
    else:
        ans = 2*(x//11)
else:
    if x%11 != 0:
        ans = 2*(x//11)+2
    else:
        ans = 2*(x//11)+1
print(ans)
# Judge status: Wrong Answer
nums = input()
n = 4


def calc(i, f, sum):
    if i == n-1:
        print(f+'=7')
        exit()
        return sum == 7

    else:
        calc(i+1, f + '-' + nums[i+1], sum - int(nums[i+1]))

        calc(i+1,  f + '+' + nums[i+1], sum + int(nums[i]))



calc(0, nums[0], int(nums[0]))
# Judge status: Accepted
o = input()
e = input()
ans = ''
for i in range(len(e)):
    ans += o[i] + e[i]
if len(o) - len(e) == 1:
    ans += o[len(o)-1]
print(ans)
# Judge status: Accepted
X, Y = map(int, input().split())
ans = 0
while X <= Y:
    X = X * 2
    ans += 1
print(ans)
# Judge status: Wrong Answer
s = input()
count = 0
i = 0
n = len(s)
check = False
while True:
    if check:
        count += 1
    elif s[i] != s[i+1]:
        count += 1
    else:
        i += 1
        count += 1
    if i+2 >= n:
        count += 1
        break
    i += 1
print(count)
# Judge status: Wrong Answer
from sys import exit
from math import sqrt

x = int(input())
if x == 2:
    print(3)
    exit()
elif x == 3:
    print(5)
    exit()
i = x
while i <= x * int(sqrt(x)):
    j = 2
    while j <= int(sqrt(i)):
        if not i % j:
            break
        j += 1
    if j > int(sqrt(i)):
        print(i)
        exit()
    i += 1
# Judge status: Accepted
s = input()

if s == "RRR":
    print(3)
elif s == "RRS" or s == "SRR":
    print(2)
elif s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR":
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
n,k=[int(i)for i in input().split()]
s=str(input())
print(s.replace(s[k-1],str(s[k-1].lower)))
# Judge status: Accepted
n, m = map(int,input().split())

res = 1
num = int(m ** 0.5) + 1
for i in range(1, num):
    if m % i != 0:continue 
    j = m // i
    if i >= n:
        res = max(j, res)
    if j >= n:
        res = max(i, res)
print(res)
# Judge status: Accepted
a,b,c=map(int,input().split())
if a+b+c >= 22:
    print("bust")
else:
    print("win")
# Judge status: Wrong Answer
d, n = map(int, input().split())

r = 100**d
print(r*n)
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

red = P[:X]
green = Q[:Y]
ans = sum(red + green)
rg = sorted(red + green)

for i in range(min(C, X+Y)):
    if rg[i] < R[i]:
        ans += R[i] - rg[i]

print(ans)
# Judge status: Wrong Answer
import sys
import itertools


def resolve(in_, out):
    n, k = map(int, next(in_).split())
    a = tuple(map(int, next(in_).split()))

    b, c = itertools.tee(a)
    c = itertools.islice(c, k, None)
    for v, w in zip(b, c):
        s = 'Yes' if v < w else 'No'
        print(s, file=out)
        


def main():
    answer = resolve(sys.stdin.buffer, sys.stdout)
    print(answer)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def dts():
	return list(map(int,input().split()))

d,t,s=dts()

if d/t<=s:
    print("yes")
else:
    print("No")
# Judge status: Wrong Answer

input()
a=sorted([int(x) for x in input().split()])
b=sorted([int(x) for x in input().split()])
if(a[-1]<b[0]):
    print("No ",end="")
print("War")
# Judge status: Accepted
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

dist = abs(B-A)
r_vel = V - W

if r_vel * T >=dist:
  print("YES")
 
else:
  print("NO")
# Judge status: Wrong Answer
import sys
import copy
import math
import itertools
import numpy as np
import re

S = input()
s = "keyence"
for i in range(len(S)):
    if re.match(s[:i]+".*"+s[i:],S):
        print("Yes")
        sys.exit(0)

print("No")
# Judge status: Wrong Answer
a,b = map(int, input().split())
print((a+b)//2)
# Judge status: Accepted
n, k = map(int, input().strip().split())
sunuke=[False]*n
for i in range(k):
    d=int(input().strip())
    L = list(map(int, input().strip().split()))
    for j in L:
        sunuke[j-1]=True
ans=0
for i in sunuke:
    if not i:
        ans+=1
print(ans)
# Judge status: Accepted
import math

a, b, h, m = map(int, input().split())
st = (60*h+m)/360*math.pi
lt = m/30*math.pi
sx = a*math.sin(st)
sy = a*math.cos(st)
lx = b*math.sin(lt)
ly = b*math.cos(lt)
print(math.sqrt((lx-sx)**2+(ly-sy)**2))
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(map(int,input().split()))
    BC = [list(map(int,input().split())) for _ in range(m)]

    BC = sorted(BC,key=lambda x:(x[1]),reverse=True)
    append_list = []
    for b,c in BC:
        if len(append_list)>=n:
            break
        append_list+=[c]*b
    A+=append_list
    A.sort(reverse=True)
    print(sum(A[:n]))
if __name__=='__main__':
    main()
# Judge status: Accepted
n, k = map(int, input().split())

c = 0

for l in range(k, n+2):
    c += l*(2*n + 1 - l)/2 - l*(l - 1)/2 + 1
    c %= 10**9+7

print(int(c%(10**9 + 7)))
# Judge status: Accepted
def cin():  return list(map(int,input().split()))

N = cin()[0]
S = input()

tmp = S[::]
for i in range(100): tmp = tmp.replace("()", "")
cnt1 = 0
cnt2 = 0
for i in range(len(tmp)):
    if tmp[i] == '(': cnt1 += 1
    else: cnt2 += 1

ans = S[::]
ans = "(" * cnt2 + S + ')' * cnt1;
print(ans);
# 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()))
print(sum(bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b)) for b in B))
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


L = [A[0]]
for a in A[1:]:
    L.append(gcd(L[-1], a))

R = [A[-1]]
for a in reversed(A[:-1]):
    R.append(gcd(R[-1], a))
R.reverse()

ans = max(L[-2], R[1])
# i番目を使わない
for i in range(1, n-1):
    x = gcd(L[i-1], R[i+1])
    if ans < x:
        ans = x
print(ans)
# Judge status: Accepted
a,b=list(map(int, input().split()))
print(a+(b//2))
# Judge status: Accepted
t = input()

t = t.replace('?','D')

c = t.count('D')
c += t.count('PD')

print(t)
# Judge status: Wrong Answer
n, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
a.sort()
pos = -1
for i in range(0, n):
    x -= a[i]
    if x < 0:
        pos = i
        break
if pos == -1:
    print(n)
else:
    print(pos)
# Judge status: Wrong Answer
x = int(input())

if x == 1:
    print("1")
    exit()


def func(p):
    q = 1
    while q <= x:
        if q == x:
            return q
            break
        else:
            q *= p
    return q


z = []
a = 2

while a <= x:
    z.append(func(a))
    a += 1

print(max(z))
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans=20202020200
sum_A=0
sum_B=sum(A)
for i in range(N):
    sum_A+=A[i]
    sum_B-=A[i]
    tmp=abs(sum_A-sum_B)
    if tmp<ans:
        ans=tmp
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
*A, = map(int, input().split())
s = 0
l = 0
n = 0
h = [0]*N
while True:
    h[s] = l
    s = A[s]-1
    l += 1
    if h[s]:
        n = l-h[s]
        break

if K < h[s]:
    s = 0
else:
    K -= h[s]
    K = K % n

while K > 0:
    s = A[s]-1
    K = K-1
print(s+1)
# Judge status: Wrong Answer
L = int(input())

res = 0
result = 0
for i in range(1,L):
    for j in range(1,L - i):
        l = L - i - j
        res = i * j * l
        result = max(res,result)

print(result)
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    com_left = [0] * (N+1)
    com_right = [0] * (N+1)
    total = sum(A)
    for i in range(N):
        com_left[i+1] = com_left[i] + A[i]
        com_right[i] = total - com_left[i]
    ans = 2020202020
    for i in range(N):
        diff = abs(com_left[i] - com_right[i])
        ans = min(ans, diff)
    print(ans)
if __name__ == "__main__":
    main()
# Judge status: Accepted
N,M,K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

for i in range(N):
	A[i+1] += A[i]
for i in range(M):
	B[i+1] += B[i]

b = M
r = 0
for i,a in enumerate(A):
	if a > K:
		break
	while a+B[b]>K and b>=0:
		b -= 1
	r = max(r, i+b)

print(r)
# Judge status: Accepted
n, m = map(int, input().split())
h = list(map(int,input().split()))
x = [0 for i in range(n)]

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

ans = 0
for i in range(n):
    if h[i] > x[i]:
        ans += 1

print(ans)
# Judge status: Wrong Answer
s=[input() for i in range(3)]
l=[len(s[i]) for i in range(3)]
abc=[0,0,0]
now=0
while abc[now]!=l[now]:
    now=(0 if s[now][abc[now]]=="a" else 1 if s[now][abc[now]]=="b" else 2)
    abc[now]+=1
print("A" if now==0 else "B" if now==1 else "C")
# Judge status: Accepted
x, a, b = map(int, input().split())

A = abs(x-a)
B = abs(x-b)
if A <= B:
    print('A')
elif A > B:
    print('B')
# Judge status: Wrong Answer
n, k = map(int, input().split())
A = list(map(int, input().split()))

print(n//(k-1))
# Judge status: Accepted
from math import ceil
n, h = map(int, input().split())
data1, data2 = [], []
for i in range(n):
    a, b = map(int, input().split())
    data1.append([a, b])
    data2.append([a, b])

data1 = sorted(data1, key = lambda x: x[0], reverse = True)
data2 = sorted(data2, key = lambda x: x[1], reverse = True)
ans = 0
while h > 0 and data1[0][0] < data2[0][1]:
    h -= data2[0][1]
    ans += 1
    del data2[0]
    if len(data2) == 0:
        break
ans += ceil(max(0, h) / data1[0][0])
print(ans)
# Judge status: Accepted
import fractions
N=int(input())
gcd,*alist=map(int,input().split())

for a in alist:
  gcd=fractions.gcd(gcd,a)
  
print(gcd)
# Judge status: Accepted
a = list(map(int, input().split()))
a.sort(reverse=True)

c = a[0] - a[1]
b = a[0] - a[2]

ans = c // 2 + b // 2
c %= 2
b %= 2

if c == 0 and b == 0:
    print(ans)
elif c == 1 and b == 1:
    print(ans + 1)
else:
    print(ans + 2)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
ans=1
temp=0
for i in range(1,n):
  if a[i-1]<a[i] and temp==0:
    temp=1
  elif a[i-1]>a[i] and temp==0:
    temp=2
  elif a[i-1]>a[i] and temp==1:
    temp=2
    ans=ans+1
  elif a[i-1]<a[i] and temp==2:
    temp=1
    ans=ans+1
print(ans)
# Judge status: Accepted
n = input()
if len(set(list(n)))==1:
    print(n)
else:
    num = int(n[0])+int(n[0])*10+int(n[0])*100
    if int(n) < num:
        print(num)
    else:
        print(num+111)
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    n = int(input())
    a = []
    b = []
    for _ in range(n):
        A,B = map(int,input().split())
        a.append(A)
        b.append(B)
    a.sort()
    b.sort()
    if n%2:
        print(b[n//2]-a[n//2]+1)
    else:
        print((b[n//2]+b[n//2-1]) - (a[n//2]+a[n//2-1])+1)
    
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())
print("YNeos"[N not in [a+b for a in range(4,N+1,4) for b in range(7,N+1,7)]::2])
# Judge status: Accepted
k=int(input())
cand=[[1,2,3,4,5,6,7,8,9]]
for _ in range(9):
  tmp=[]
  for val in cand[-1]:
    if val%10!=0:
      tmp.append(val*10+(val%10-1))
    tmp.append(val*10+(val%10))
    if val%10!=9:
      tmp.append(val*10+(val%10+1))
  cand.append(tmp)
ans=[]
for i in range(len(cand)):
  for val in cand[i]:
    ans.append(val)
ans=sorted(ans)
print(ans[k-1])
# Judge status: Wrong Answer
#D ModSum
n=int(input())
print(int(n*(n-1)/2))
# Judge status: Wrong Answer
n = int(input())
l, l1, l2 = list(""), list(""), list("")
for i in range(n):
    x, y = map(int, input().split())
    l1.append(x)
    l2.append(y)
for i in range(n - 1):
    for j in range(i + 1, n):
        l.append(((l1[i] -l1[j]) ** 2 + (l2[i] - l2[j]) ** 2) ** 0.5)
print('{:.10f}'.format(2 * sum(l) / len(l)))
# Judge status: Wrong Answer
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N > K:
    print(X * K + Y*(N-K))
else:
    print(X * K)
# Judge status: Accepted
x=int(input())
print(int(x+x**2+x**3))
# Judge status: Wrong Answer
a, b = map(int, input().split())
print((a+b)//2)
# Judge status: Accepted
from decimal import *
import math

s = input().split()
a = Decimal(s[0])
b = Decimal(s[1])
res = math.floor(a * b)
print(res)
# Judge status: Wrong Answer
N,M=map(int,input().split())
dp=[0]*(N+1)
dp[0]=1
for _ in range(M):
    a=int(input())
    dp[a]=-1

for i in range(N+1):
    if dp[i]==-1:
        continue
    if dp[i-1]!=-1:
        dp[i]+=dp[i-1]
    if dp[i-2]!=-1:
        dp[i]+=dp[i-2]

#print(dp)
print(dp[-1]%(10**9+7))
# Judge status: Accepted
A = str(input())
B = str(input())
C = str(input())

turn = "A"
while True:
  if turn == "A":
    if len(A) == 0:
      print(turn)
      break
    turn = A[0].upper()
    A = A[1:len(A)]
  elif turn == "B":
    if len(B) == 0:
      print(turn)
      break
    turn = B[0].upper()
    B = B[1:len(B)]
  else:
    if len(C) == 0:
      print(turn)
      break
    turn = C[0].upper()
    C = C[1:len(C)]
# Judge status: Accepted
N, K = map(int, input().split())
P = list(map(int, input().split()))
S =[0] * (N - K + 1)
S[0] = sum(P[0:K])

for i in range(1, N - K + 1):
    S[i] = S[i-1] - P[i-1] + P[i+K-1]

print((max(S) + K) / 2)
# Judge status: Accepted
n = int(input())
if (n%10) in [2, 4, 5, 7, 9]:
    print("hon")
elif (n%10) in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")
# Judge status: Accepted
L =[]
L.append(input())
L.append(input())
L.append(input())
i = 0
win = ['a','b','c']
while len(L[i]) > 0:
  if L[i][0] == 'a':
    L[i] = L[i][1:]
    i = 0
  elif L[i][0] == 'b':
    L[i] = L[i][1:]
    i = 1
  else:
    L[i] = L[i][1:]
    i = 2
print(win[i].upper())
# Judge status: Wrong Answer
s = input()
t = input()
ans = 0
for i in range(len(s)):
  ans += 1 if s[i] == t[i] else 0
print(ans)
# Judge status: Accepted
a,b=map(int, input().split())
c=0
while a<=b:
  s=str(a)
  if s==s[::-1]:
    c+=1
  a+=1
print(c)
# Judge status: Wrong Answer
import sys
from collections import Counter

S = sys.stdin.readline().strip()
counter = Counter(S)

counter = sorted(counter.items(), key=lambda x: x[1])
# print(counter)

if len(counter) == 1:
    print("NO")
elif len(counter) == 2:
    if counter[0][1] < counter[1][1]:
        print("NO")
    else:
        print("YES")
else:
    if counter[0][1] + counter[1][1] < counter[2][1]:
        print("NO")
    else:
        print("YES")