peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N=int(input())
a=sorted(list(map(int,input().split())))
n=a[-1]
tmp=0
if n%2==0:
  ideal=n//2
  for i in range(N-1):
    if abs(ideal-tmp)>abs(ideal-a[i]):
      tmp=a[i]
else:
  ideal1=(n-1)//2
  ideal2=ideal1+1
  for i in range(N-1):
    if abs(ideal1-tmp)>abs(ideal1-a[i]) or abs(ideal2-tmp)>abs(ideal2-a[i]):
      tmp=a[i]
print(' '.join([str(n),str(tmp)]))
# Judge status: Wrong Answer
x,y = map(int,input().split())

m=4*x
yf=y//4

ans='Yes'

if m<y:
    ans='No'
elif y%2!=0:
    ans='No'
elif y%2==0 or y%4==0:
    pass
elif yf+1<=x:
    pass
else:
    ans='No'

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

ans = 10 ** 6

for a in A:
  c = 0
  while a % 2 == 0:
    a //= 2
  ans = min(c,ans)
  
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

num_4 = 0
num_2 = 0
num_1 = 0
for ai in a:
    if(ai%4==0):
        num_4 += 1
    elif(ai%2==0):
        num_2 += 1
    else:
        num_1 += 1

if(num_4 >= num_1):
    print('Yes')
elif(num_4 + 1 == num_1)&(num_2==0):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
H, N = map(int, input().split())
Magic = [list(map(int, input().split())) for i in range(N)]
MAX_COST = max(Magic)[1]

# dp[damage] := モンスターに damage を与えるために必要な最小コスト
dp = [float('inf')] * (H + 1)
dp[0] = 0
for h in range(H):
    for damage, cost in Magic:
        next_index = min(h + damage, H)
        dp[next_index] = min(dp[next_index], dp[h] + cost)

print(dp[-1])
# Judge status: Accepted
n = int(input())
s = input()

w = [0]*n
e = [0]*n

if s[0] == "W": w[0] += 1
else: e[0] += 1
for i in range(1,n):
  if s[i] == "W":
    w[i] = w[i-1]+1
    e[i] = e[i-1]
  else:
    w[i] = w[i-1]
    e[i] = e[i-1]+1

ans = float("inf")
if e[n-1]-e[0] < ans: ans = e[n-1]-e[0]
if w[n-1] < ans: ans = w[n-1]

for i in range(1,n-1):
  t = w[i-1] + e[n-1]-e[i]
  if t < ans: ans = t
print(ans)
# Judge status: Accepted
a, b, x= map(int, input().split())
if (a <= x <= a+b):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
a=int(input())
if a%2==0:
  print(int(a/2))
else:
  print(int((a+1)/2))
# Judge status: Accepted
a, b, c = map(int, input().split())

if a <= c <= b or b <= c <= a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#114_B
S=input()
Ans=1000
for i in range(len(S)-2):
    x=int(S[i:i+3])
    Ans=min(Ans,abs(x-753))
print(Ans)
# Judge status: Wrong Answer
c1 = list(input())
c2 = list(input())
if c1.reverse == c2:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=int(b)
if a%(b*2+1)==0:
  print(a//(b*2))
else:
  print(a//(b*2)+1)
# Judge status: Wrong Answer
import numpy as np
N = int(input())
numbers = np.array(list(map(int, input().split())))
mod = 1e9 + 7
numbers_r_cumsum = numbers[N - 1:0:-1].cumsum()[::-1]
each = numbers[:N-1] * numbers_r_cumsum
total = 0
for e in each:
    total += e
    total %= mod
print(int(total))
# Judge status: Wrong Answer
a, b, c, d = map(int,input().split())

if abs(a-b) <= d and abs(b-c) <= d:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from sys import stdin

def I(): return int(stdin.readline().rstrip())

a,b,h = [I() for i in range(3)]

ans = int((a+b)*h/2)

print(ans)
# Judge status: Accepted
import random

N = int(input())
x = [0]*N
y = [0]*N
for i in range(N):
  x[i], y[i] = map(int, input().split())

minn = 10**10
maxn = -10**10
minp = 10**10
maxp = -10**10

for i in range(N):
  minn = min(minn, x[i]-y[i])
  maxn = max(maxn, x[i]-y[i])
  minp = min(minp, x[i]+y[i])
  maxp = max(maxp, x[i]+y[i])

print(max(maxn-minn, maxp-minp))
# Judge status: Wrong Answer
n = int(input())

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

c = 0
for i in range(n):
    if i % 2 == 1 and a[i] % 2 == 1:
        c += 1

print(c)
# Judge status: Wrong Answer
d = int(input())

print("Christmas"+ "Eve"*(25-d))
# Judge status: Wrong Answer
n=int(input())
txy=[list(map(int,input().split())) for _ in range(n)]
txy.insert(0,[0,0,0])
for i in range(n):
  d=abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
  t=txy[i+1][0]-txy[i][0]
  if t-d<0 or d%2==0:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
n,k = map(int, input().split())
x = list(map(int, input().split()))

s = 10**9
for i in range(n-k+1) :
  f1 = x[i]
  f2 = x[i+k-1]
  m = min(abs(f1) +abs(f2 - f1) , abs(f2) + abs(f2 - f1))
  if s >m :
    s = m
print(s)
# Judge status: Accepted
A,B,K=map(int,input().split())
answers=[]
for a in range(K):
    if A+a<=B and not A+a in answers:
        answers.append(A+a)
for b in range(K):
    if B-b>=A and not B-b in answers:
        answers.append(B-b)
answers=sorted(answers)
for a in answers:
    print(a)
# Judge status: Accepted
a,b = map(int, raw_input().split(' '))
q = 1
u = 0
while(q < b):
	q -= 1
	q += a
	u += 1
print u
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

left = 0 # できない
right = a[0] # できる
while left+1 < right:
    mid = (left+right) // 2
    cnt = 0
    for i in range(n):
        cnt += a[i] // mid
        if cnt > k: break
    if cnt > k:
        left = mid
    else:
        right = mid
print(right)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
#aの倍数の中でbで割って余りがcになるものが存在すればよい
if a%2==0 and b%2==0 and c%2==1:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
import math

H = int(input())
W = int(input())
N = int(input())

tmp = max(H,W)
print(math.ceil(N/tmp))
# Judge status: Accepted
def Convert(string): 
    li = list(map(int, string.split(" "))) 
    return li 

N = input().split()
L = Convert(input())
Min = L[0]
Sum = 0

for i in L:
    if i <= Min:
        Sum += 1
        Min = i
        

print(Sum)
# Judge status: Accepted
import math

N = int(input())

if N % 2 == 1:
    print(0)
else:
    i = 10
    ans = 0
    while(True):
        a = math.floor(N // i)
        if a < 1:
            break
        ans += a
        i *= 5
    print(ans)
# Judge status: Accepted
N=int(input())
N_sum=[]
for A in range(1,int(N/2)+1):
  B=N-A
  N_sum.append(sum(map(int,str(A)+str(B))))
print(min(N_sum))
# Judge status: Accepted
import heapq

N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[-A[i] for i in range(0,N)]
heapq.heapify(A)
for i in range(0,M):
    m=(-1)*heapq.heappop(A)
    m=m//2
    m=-m
    heapq.heappush(A,m)
print((-1)*sum(A))
# Judge status: Accepted
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
a = 0
for x in set(s):
  a = max(s.count(x) - t.count(x), a)
print(a)
# Judge status: Accepted
def solve():
    H,W,K = map(int,input().split())

    for k in range(0,H+1):
        for l in range(0,W+1):
            if k*(W-l)+l*(H-k) == K:
                print('Yes')
                return
    else:
        print('No')
if __name__ == '__main__':
    solve()
# Judge status: Wrong Answer
h, w = map(int, input().rstrip().split())
if h % 2 == 1 and w % 2 == 1:
  print(h*w//2 + 1)
else:
  print(h*w // 2)
# Judge status: Wrong Answer
a=int(input())

list=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23]
i=1
while(a<=15):
    print(list[a-1])
    break
# Judge status: Accepted
n = int(input())
a_i = list(map(int, input().split()))
ans_list = [0] * n
for i in a_i:
  ans_list[i - 1] += 1
for i in ans_list:
  print(i)
# Judge status: Accepted
a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6 and a <= 12:
    print(b//2)
else:
    print(0)
# Judge status: Wrong Answer
from math import sqrt as s
a,b,c=map(int,input().split())
print('Yes' if s(a)+s(b)<s(c) else 'No')
# Judge status: Wrong Answer
from sys import stdin
s = int(stdin.readline().rstrip())
a = s//10**9+1
b = 10**9-s%10**9
print(0,0,10**9,1,b,a)
# Judge status: Accepted
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

k = inp()
dt = {}
no = 0
ans = -1
i = 0
while True:
    no = (no*10+7)%k
    if no in dt:
        break
    dt[no] = 1
    #print(dt,no)
    if no == 0:
        ans = i+1
        break
    i += 1
print(ans)
# Judge status: Wrong Answer
w,h,x,y = map(int,input().split())
if min(x,w-x)*h == min(y,h-y)*w:
     print(max(min(x, w - x) * h, min(y, h - y) * w), 1)
else:
     print(max(min(x, w - x) * h, min(y, h - y) * w), 0)
# Judge status: Wrong Answer
# a, b = map(int, input().split())
print('Christmas' + 'Eve'*(int(input())-25))
# Judge status: Accepted
N = int(input())
D = sorted([d for d in map(int,input().split())])

Nd2 = int(N/2)
ans = D[Nd2]-D[Nd2-1]
print(ans)
# Judge status: Accepted
N, M = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
BC_list = []
for _ in range(M):
    B, C = map(int, input().split(' '))
    BC_list.append((B, C))
BC_list = sorted(BC_list, key= lambda x: x[1], reverse=True)

for b, c in BC_list:
    A.extend([c]*b)
    if len(A) > 2*N:
        break
print(sum(sorted(A)[-N:]))
# Judge status: Accepted
i = input().split(" ")
a = int(i[0])
b = int(i[1])
c = int(i[2])
d = int(i[3])

negneg = a * c
negpos = a * d
posneg = b * c
pospos = b * d

print(max([negneg,negpos,posneg,pospos]))
# Judge status: Wrong Answer
n = int(input())
s = input()

flg = False
ans = 0

for i in s:
    if i == '#':
        flg = True

    if flg is True and i == '.':
        ans += 1

print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
if a<=c and b>=c:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a ,b ,n = map(int, input().split())

ans = -1
if(a % b == 0):
    x = b-1
    abc = ((a*x)//b)-(a*(x//b))
    if(ans < abc):
        ans = abc
else:
    for x in range(n-int(n**(1/2)),n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc


print(ans)
# Judge status: Accepted
a, b, c, k = map(int, input().split())
if abs(a-b) > 10 ** 18:
	print('Unfair')
else:
	print(a - b if k % 2 == 0 else b - a)
# Judge status: Accepted
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

ans = "No"
cnt = 0

for i in range(N):
    if len(set(D[i])) == 1:
        cnt += 1
    else:
        cnt = 0
    
    if cnt >= 3:
        ans = "Yes"

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

K = int(input())
q = deque()
for i in range(1, 10):
    q.append(i)
for _ in range(K - 1):
    x = q.popleft()
    if x % 10:
        q.append(10 * x + x % 10 - 1)
    q.append(10 * x + x % 10)
    if x % 10 != 9:
        q.append(10 * x + x % 10 + 1)
print(q.popleft())
# Judge status: Accepted
n = int(input())
wa = [0]*n
sa = [0]*n
for i in range(n):
    x,y = map(int,input().split())
    wa[i] = x+y
    sa[i] = x-y
wanosa = max(wa) - min(wa)
sanosa = max(sa) - min(sa)
ans = max(wanosa,sanosa)
print(ans)
# Judge status: Wrong Answer
x = input()
a, b = int(x[0:2]), int(x[2:4])
flag = 0
ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"]

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12):
    flag = 3
elif (a > 0 and a <= 12) and (b >= 13):
    flag = 2
elif (a >= 13) and (b > 0 and b <= 12):
    flag = 1


print(ans[flag])
# Judge status: Accepted
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+int(S[i+1]))
        make7(i+1, f+"-"+S[i+1], sum-int(S[i+1]))


S = input()
n = len(S)

make7(0, S[0], int(S[0]))
# Judge status: Accepted
s=input()
s=list(set(s))

A=[]
for i in range(97,123):
    A.append(chr(i))


for i in range(len(A)):
    if A[i] in s:
        continue
    else:
        print(A[i])
        exit()

print("None")
# Judge status: Accepted
a,b,c= map(int, input().split())
if a<c<b or b<c<a:
	print("Yes")
else:
	print("No")
# Judge status: Accepted
d = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}

s = input()
print(d[s])
# Judge status: Accepted
N = map(int, list(input()))
if 7 in N:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

t_crr = t[0]
cnt = 0
ans = 1

for i in t:
    # print(cnt, ans, t_crr, i)
    if i - t_crr <= k and cnt < c:
        cnt += 1
        continue
    else:
        t_crr = i
        ans += 1
        cnt = 1

print(ans)
# Judge status: Wrong Answer
a=input()
if ('R'or'U'or'D') in a[0::2] and ('L'or'U'or'D') in a[1::2]:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer


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

print(a)
print(b)

answer = a * b

print(answer)
# Judge status: Accepted
import numpy as np

w, h, n = map(int, input().split())
grid = np.array([[0] * w for _ in range(h)])
# print(grid)


def F(grid, x, y, a):
    if a == 1:
        grid[:, :x] = 1
    elif a == 2:
        grid[:, x:] = 1
    elif a == 3:
        grid[:y, :] = 1
    elif a == 4:
        grid[y:, :] = 1


for i in range(n):
    x, y, a = map(int, input().split())
    F(grid, x, y, a)
    # print(grid)
print(np.count_nonzero(grid == 0))
# Judge status: Wrong Answer
N = int(input())
n = 0
if not N%2:
    s = 5
    N = N//2
    while N>s:
        n += N//s
        s *= 5
print(n)
# Judge status: Wrong Answer
a, b = map(int, input().split())

n = a*10 + b
found = False
for i in range(1, 330):
    if(n == i**2):
        # print(i)
        found = True

if(found == True):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a = list(map(int,input().split()))
cna = cnb = 0
a.sort()
x = a[2]-a[1]
y = a[1]-a[0]
while True:
    if x%2 == 0 and x != 0:
        cna += 1
        x //= 2
    else:
        break
while True:
    if y%2 == 0 and y != 0:
        cnb += 1
        y //= 2
    else:
        break
if cna == 0 and cnb == 0:
    print(-1)
else:
    print(min(cna,cnb))
# Judge status: Accepted
a,b=map(str,input().split())
c=int(a+b)
for i in range(320):
	if i**2==c:
		print('Yes')
		exit()
print('No')
# Judge status: Accepted
def main() -> None:
    n, k = map(int, input().split())

    check = [0] * n
    for _ in range(k):
        _ = input()
        having = tuple(map(int, input().split()))
        for idx in having:
            check[idx-1] += 1
    print(check.count(0))
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = list(input().split())
odd = []
even = []

for i in range(N):
    if i % 2 == 1:
        odd.append(A[i])
    else:
        even.append(A[i])

if N % 2 == 0:
    odd = odd[::-1]
    odd.extend(even)
    ans = odd
else:
    even = even[::-1]
    even.extend(odd)
    ans = even

print(" ".join(ans))
# Judge status: Wrong Answer
N = int(input())

print(1000-N % 1000)
# Judge status: Accepted
a,b=map(int,input().split())
total=a*(a+2*b-1)//2
x=b
y=a+b-1
if abs(x)<abs(y):
  z=x
else:
  z=y
if x<=0 and y>=0:
  print(total)
else:
  print(total-z)
# Judge status: Accepted
x,n=map(int,input().split())
p=list(map(int,input().split()))
j=0
while(1):
    if((x-j in p)==False):
        print(x-j)
        break
    elif((x+j in p)==False):
        print(x+j)
        break
    j+=1
# Judge status: Wrong Answer
# AtCoder
N = int(input())
ans = N*(N-1)/2
print(int(ans))
# Judge status: Accepted
abef=0
bbef=1
s=input()
for i in range(len(s)):
  curr=int(s[len(s)-1-i])
  a=abef+curr
  b=bbef+9-curr
  a=min(a,1+bbef+curr)
  b=min(b,abef+10-curr)
  abef=a
  bbef=b
curr=0
a=abef+curr
b=bbef+9-curr
a=min(a,1+bbef+curr)
b=min(b,abef+10-curr)
print(min(a,b))
# Judge status: Accepted
N = int(input())
i = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる

s = 0

for j in range(0,N,2):
  if i[j] % 2 == 1 :
    s += 1
print(s)
# Judge status: Accepted
S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if S == U:
  print(A - 1, B)
else:
  print(A, B -1)
# Judge status: Wrong Answer
a, b, c, d = map(int,input().split())

if b < 0 and d < 0:
  print(a*c)
  
elif a > 0 and b > 0 and d < 0:
  print(a*d)
  
elif b < 0 and c > 0 and d > 0:
  print(b*c)

elif a < 0 and b > 0 and c < 0 and d > 0:
  print(b*d)
  
elif a < 0 and b > 0 and d < 0:
  print(a*c)
  
else:
  print(b*d)
# Judge status: Accepted
N, K = map(int, input().split())
S = input()
RL = 0
for i in range(N - 1):
    if S[i] == 'R' and S[i + 1] == 'L':
        RL += 1
egde = (S[0] == 'L') + (S[-1] == 'R')
if K >= RL:
    K -= RL
    RL = 0
    if K > 0:
        egde = max(1, egde - K)
else:
    RL -= K
print(N  - 2 * RL - egde)
# Judge status: Wrong Answer
n = int(input())
print(n ** 0.5 ** 2)
# Judge status: Accepted
n = int(input())
pf = {}

for i in range(2, int(n**0.5) + 1):
    while not n % i:
        pf[i] = pf.get(i, 0) + 1
        n //= i
if n > 1:
    pf[n] = 1
#print(pf)

cnt = 0
for i in pf.values():
    for j in range(1, 50):
        if i - j >= 0:
            cnt += 1
            i -= j
        else:
            break
print(cnt)
# Judge status: Accepted
S = input()

a = len(S)

c = 'x'*a

print(c)
# Judge status: Wrong Answer
a, b = map(int, input().split())
s = input()

num = list(map(str, range(0, 10)))

ans = 'Yes'

if s[a] == '-':
    for x in range(a):
        if s[x] not in num:
            ans = 'No'
            break
    for x in range(a+1, b+1):
        if s[x] not in num:
            ans = 'No'
            break
else:
    ans = 'No'

print(ans)
# Judge status: Wrong Answer
N = int(input())
A1= list(map(int,input().split()))
A2= list(map(int,input().split()))
sum2 = sum(A2)
ans = A1[0]+A2[0]
value = A1[0]+sum2
for i in range(1,N):
    value = value + A1[i] - A2[i-1]
    ans = max(ans,value)
print(ans)
# Judge status: Wrong Answer
S=list(input())
a=S[::2]
c=S[1::2]
b='Yes'
for i in a:
  if i!='R' or i!='U' or i!='D':
    b='No'
for j in c:
  if j!='L' or j!='U' or j!='D':
    b='No'
print(b)
# Judge status: Accepted
n,m = map(int,input().split())
a = [int(k) for k in input().split()]
cnt = 0
for i in range(n):
    if 4*m*a[i] >= sum(a):
        cnt += 1
print("Yes" if cnt >= m else "No")
# Judge status: Accepted
from bisect import bisect_left as bl
from bisect import bisect_right as br
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
c.sort()
ans = 0
for i in range(n): ans += bl(a,b[i])*(n-br(c,b[i]))
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a < b:
    b = a
print(str(b)*a)
# Judge status: Accepted
a = input().split()
print(len(set(a)))
# Judge status: Accepted
a,b,c = map(int,input().split())
t = int(b/a)
if t<=c:
    print(t)
else:
    print(c)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
result = 0
for i in range(N):
    result += A[(i + 1) // 2]
print(result)
# Judge status: Accepted
N, Q = map(int,input().split())
m = 1
M = N
for k in range(Q):
    L, R = map(int,input().split())
    m = max(L,m)
    M = min(M,R)
print(max(0,M-m+1))
# Judge status: Wrong Answer
n = int(input())
x = int(n/1.08+.5)
print(x) if int(x * 1.08) == n else print(':(')
# Judge status: Wrong Answer
n = int(input())
for i in range(n+1):
    if i*i > n:
        i-=1
        print(i*i)
        break
# Judge status: Accepted
import fractions
N=int(input())
list=[]
for a in range(N):
    T=int(input())
    list.append(T)
ans=list[0]
for z in range(1,N):
    ans=ans*list[z]//fractions.gcd(ans,list[z])
print(ans)
# Judge status: Accepted
N = int(input())
As = list(map(int,input().split()))
c = 0
nums = [0]*(10**5+2)
for a in As:
    nums[a]+=1

for i in range(1,len(nums)-1):
    t = nums[i-1]+nums[i]+nums[i+1]
    c = max(c,t)
print(c)
# Judge status: Accepted
X = int(input())
def check(mid):
    if mid%2 == 0:
        point = 11*mid//2
    else:
        point = 6*(mid//2+1)+5*(mid//2)
    return point >= X
left = 0
right = 10**18
while right-left > 1:
    mid = (right+left)//2
    if check(mid):
        right = mid
    else:
        left = mid
if check(left):
    print(left)
else:
    print(right)
# Judge status: Accepted
a,b,c = map(int,input().split())
k = int(input())
cnt = 0
while a >= b:
    cnt += 1
    b *= 2
while b >= c:
    cnt += 1
    c *= 2

if cnt <= k:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

all_score = [k - q for _ in range(n)]
for ai in a:
    all_score[ai - 1] += 1
for j in all_score:
    if j > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
a,b,c,d = map(int,input().split())
if abs(c - a) <= d or ( abs(b - a) <= d and abs(c - b) <= d):
	print("Yes")
else:
	print("No")
# Judge status: Wrong Answer
# ABC 060: B – Choose Integers
a, b, c = map(int, input().split())
canSelect = 'No'

for i in range(1, b + 1):
    if (i * a) % b == c:
        canSelect = 'Yes'
        break

print(canSelect)
# Judge status: Accepted
import math

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

if B-A==C-B:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
a, b = map(int, input().split())

ans = 0
for x in range(a, b + 1):
    if x // 10000 == x % 10 and (x // 1000) % 10 == (x // 10) % 10:
        ans += 1
print(ans)
# Judge status: Accepted
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = int(input())
    S = input()
    L = [0] * 26

    for s in S:
        L[ord(s) - 97] += 1

    ans = 1
    for i in range(26):
        if L[i] != 0:
            ans = (ans * (L[i] + 1)) % (10 ** 9 + 7)

    print(ans - 1)


if __name__ == '__main__':
    main()
# Judge status: Accepted
# coding: utf-8
# Your code here!
#N = input()
N, K = map(int, input().split())
PList = list(map(int, input().split()))

PList.sort()
PList=PList[:K]
print(sum(PList))
# Judge status: Wrong Answer
N, M = map(int, input().split())

ans = 0
restM = M - (N*2)
ans = ans + N

ans = ans + restM//4

print(ans)
# Judge status: Accepted
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int, input().split())),reverse=True)
q=sorted(list(map(int, input().split())),reverse=True)
r=sorted(list(map(int, input().split())),reverse=True)
ans=sorted(p[:x]+q[:y],reverse=True)
for i in range(c):
    if ans[-i-1]<r[i]:
        ans[-i-1]=r[i]
    else:
        break
print(sum(ans))
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
counter = 0
breaker = 0
while True:
	for i in range(n):
		if A[i]%2 == 0:
			A[i] = A[i] // 2
		else:
			breaker = 1
	if breaker == 0:
		counter += 1
	else:
		break
print(counter)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=set(a)
if len(a)==len(b):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
for _ in range(len(input())):
  print('x', end = '')
# Judge status: Wrong Answer
n=int(input())
if n%2==0:
  print('{:.0f}'.format((n/2)**2/2))
else:
  print('{:.0f}'.format((n+1)/2*(n-1)/2/2))
# Judge status: Accepted
import fractions
n , x = map(int,input().split())
X = list(map(int,input().split()))
Y =[]
for i in range(n):
    Y.append(abs(X[i]-x))
ans = Y[0]
for i in range(n):
    ans = fractions.gcd(ans, Y[i])
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
S = input()
Q = int(input())

flip = 0
ad1 = []
ad2 = []
for i in range(Q):
  st = input()
  if(st[0] == '1'):
    flip += 1
  else:
    if((st[2] == '1' and flip % 2 == 0) or (st[2] == '2' and flip % 2 == 1)):
      #nS = st[4] + S
      ad1.append(st[4])
    else:
      #nS = S + st[4]
      ad2.append(st[4])

ft = ''.join(ad1)
ft = ft[::-1]
ed = ''.join(ad2)

S = ft + S + ed

if(flip % 2 != 0):
  S = S[::-1]
print(S)
# Judge status: Wrong Answer
#!/usr/bin/env python3
# N = int(input())
# S = input()
A, B, C = map(int, input().split())
# A = list(map(int, input().split()))
print(C - (A - B))
# Judge status: Accepted
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
answer = 0
for i in range(N):
    # print(A1[:i+1])
    # print(A2[i:])
    if answer <= sum(A1[:i+1] + A2[i:]):
        answer = sum(A1[:i+1] + A2[i:])

print(answer)
# Judge status: Accepted
if(65 <= ord(str(input())) <= 90):
  print('A')
else:
  print('a')
# Judge status: Wrong Answer
S=list(input())
S[3] = '8'
print(S)