peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from bisect import bisect

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

x=a[-1]
if n%2==0:
  mid=x//2
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])
else:
  mid=x//2+1
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])
# Judge status: Accepted
n,a,b=map(int,input().split())
c=max(a,b)
b=min(a,b)
a=c
MOD = pow(10,9) + 7

X=1
Y=1

for i in range(1,a+1):
    X=X*(n+1-i)%MOD
    Y=Y*i%MOD
    if i==b:
        b_X=X
        b_Y=Y
a_X=X
a_Y=Y
def calc(X,Y,MOD):
    return X*pow(Y,MOD-2,MOD)

ans=pow(2,n,MOD)%MOD-1-calc(a_X,a_Y,MOD)-calc(b_X,b_Y,MOD)

print(ans%MOD)
# Judge status: Wrong Answer
a,b,c,k = map(int,input().split())
if a >= k:
    print(a)
elif a < k and b >= k-a:
    print(a)
else:
    print(a-(k-a-b))
# Judge status: Wrong Answer
a=list(map(int,input().split()))
a.sort()
if a[0]+a[1]>a[2]:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
K,N = map(int,input().split())
A = list(map(int,input().split()))
ans = []

for i in range(N-1):
  now = i
  pre = now-1
  post = now +1
  #nowとpreの距離を求める
  if now == 0:
    preDic = (K-A[N-1])+A[now]
  else:
    preDic = A[now]-A[pre]
  postDic = A[post]-A[now]  
  if preDic >= postDic:#時計回りに、i-1の位置まで進む
    ans.append(K-preDic)
  else:
    ans.append(K-postDic)
  
print(min(ans))
# Judge status: Wrong Answer
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
discounts = {}
for _ in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    discounts[(x, y)] = c

ans = float('inf')
for i in range(A):
    for j in range(B):
        tmp = a[i] + b[j]
        if (i, j) in discounts:
            tmp -= discounts[(i, j)]
        ans = min(ans, tmp)
print(ans)
# Judge status: Wrong Answer
a,b,h,m = map(int,input().split())
import math
t =abs(30*h + 0.5*m - 6*m)
angle = min(t, 360-t)

l = a**2 + b** 2 -2*a*b*math.cos(angle*3.1415/180)
print(l**0.5)
# Judge status: Accepted
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7
INF = float('inf')

def main():
    S = list(readline().rstrip().decode('utf-8'))

    bl = S[0] == 'A'
    bl &= ('C' in S[2:-1])

    if bl:
        S.remove('A');
        S.remove('C')

    bl &= all('a' <= x <= 'z' for x in S)

    answer = 'AC' if bl else 'WA'
    print(answer)




if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
a , b= map(int , input().split())
print(int(math.ceil((a + b)/2)))
# Judge status: Accepted
import copy
n,k=map(int,input().split())
d=list(map(int,input().split()))
ans=n
while True:
    flag=True
    c=copy.deepcopy(str(ans))
    for i in range(len(c)):
        if int(c[i]) in d:
            flag=False
            break
    if flag:
        print(ans)
        exit()
    ans+=1
# Judge status: Accepted
S = input()
T = input()
 
alphabet = 'abcdefghijklmnopqrstuvwxyz'
 
S_list = []
T_list = []
 
for i in alphabet:
    Scnt = S.count(i)
    Tcnt = T.count(i)
    if Scnt > 0:
        S_list.append(Scnt)
    if Tcnt > 0:
        T_list.append(Tcnt)
 
if sorted(T_list) == sorted(S_list):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
n, a, b = map(int, input().split())
strings = input()
lists = ['No'] * len(strings)
remain = a + b
b_remain = b
for i in range(len(strings)):
  if strings[i] == 'a':
    if remain > 0:
      lists[i] = 'Yes'
      remain = remain - 1
  elif strings[i] == 'b':
    if remain > 0:
      if b_remain > 0:
        lists[i] = 'Yes'
        remain = remain - 1
        b_remain = b_remain - 1
  else:
    pass
for i in lists:
  print(i)
# Judge status: Accepted
o = list(input())
e = list(input()) + ['']

for x,y in zip(o, e):
    print(x+y, end='')
# Judge status: Accepted
n = int(input())
H = list(map(int,input().split()))

ans = "Yes"
c=0
for i in range(n-1):
    if H[i]-1>H[i+1] :
        ans = "No"
        break
    elif H[i]>H[i+1] :
        c+=1
        if c>=2 :
            ans = "No"
            break
    elif H[i]<H[i+1] :
        c=0
print(ans)
# Judge status: Wrong Answer
import math
def solve(n, k, a):
    lb = 0
    ub = max(a)
    while abs(ub - lb) > 1:
        cur = (lb + ub) / 2
        cnt = sum(math.ceil(x/cur-1) for x in a)
        if cnt > k:
            lb = cur
        else:
            ub = cur
    return int(math.ceil((lb+ub) / 2))

n, k = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, k, a))
# Judge status: Accepted
a,b,c,d=map(int,input().split())
if abs(c-a)<=d:
  print("Yes")
elif abs(c-b)<=d and abs(b-a)<=d:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
x = int(input())

for a in range(-120, 121):
    for b in range(-120, 121):
        if a**5 - b**5 == x:
            break

print(a, b)
# Judge status: Accepted
def main():
    n = int(input())
    n = n % 26
    s = input()
    s_list = [d for d in s]
    new_s = ""
    new_ord_base = 64
    for i in s_list:
        new_ord = ord(i) + n
        if new_ord > 90:
            new_ord = new_ord % 90 + new_ord_base
        new_s += chr(new_ord)

    print(new_s)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a = input().split()
print('Yes' if a[0] == a[1] else 'No')
# Judge status: Accepted
st = input() 
n = st.count('N') 
s = st.count('S') 
e = st.count('E') 
w = st.count('W') 

if (n>0 and s==0) or (n==0 and s>0) or (w==0 and e>0) or (e==0 and w>0): 
  print("No") 
else:
  print("Yes")
# Judge status: Accepted
# coding: utf-8
# Your code here!
n=int(input())
num=[0]
ans=0
count=0
k=1
for i in range(n):
    a=int(input())
    num.append(a)

for i in range(n+1):
    k=num[k]
    count+=1
    if k==2:
        ans=1
        break
if ans==1:
    print(count)
else:
    print("-1")
# Judge status: Wrong Answer
x, y, z = map(int,input().split())

print(y//z - x//z +1)
# Judge status: Wrong Answer
q, h, s, d = map(int, input().split())
n = int(input())
m = min(4 * q, 2 * h, s)
if d < 2*m:
    print((n // 2) * d + m)
else:
    print(n * m)
# Judge status: Accepted
n, m, k = map(int, input().split(' '))
a_list = list(map(int, input().split(' ')))
b_list = list(map(int, input().split(' ')))
sa = [0] * (n+1)
sb = [0] * (m+1)

for i in range(n):
  sa[i+1] = a_list[i] + sa[i]
for j in range(m):
  sb[j+1] = b_list[j] + sb[j]

best=0
r = m
for i, a in enumerate(sa):
  if a>k:
    break
  while ((a + sb[r]) > k) & (r>=0):
    r-=1
    
  best = max(best,i+r)
      
  
    
print(best)
# Judge status: Accepted
import numpy as np
h, n = map(int, input().split())
ab = np.array([np.fromstring(input(), dtype=np.int64, sep=" ") for _ in range(n)])

a = ab[:, 0]
b = ab[:, 1]

dp = np.zeros(10**6, dtype=np.int)

for i in range(1,h+1):
    dp[i] = (dp[i-a]+b).min()

print(dp[h])
# Judge status: Accepted
from math import gcd
n = int(input())
alst = list(map(int, input().split()))
ans = alst[0]
for a in alst:
  ans = gcd(ans, a)
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ans = 10**9
for i in range(-100,101):
    s = 0
    for j in range(n):
        s += (a[j]-i)**2
    ans = min(ans,s)
print(ans)
# Judge status: Wrong Answer
from math import log
x, y = map(int, input().split())
print(int(log(y / x, 2)) + 1)
# Judge status: Wrong Answer
n = int(input())
k = 1
while(n != 0):
  m = n % 10
  n /= 10
  if(m == 7):
    k = 2
    break
if k == 2:
  print('Yes')
else: 
  print('No')
# Judge status: Wrong Answer
n=int(input())

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

c=[]
ans=ab[n-1][1]-(ab[n-1][0]%ab[n-1][1])
#print(ab[n-1][0],ab[n-1][1],ans)
for i in range(n-2,-1,-1):
    ab[i][0]+=ans
    ans+=ab[i][1]-(max(1,ab[i][0]%ab[i][1]))
   # print(ab[i][0],ab[i][1],ans)
print(ans)
# Judge status: Wrong Answer
a, b, c= [int(i) for i in input().split()]

if (b - a) == (c - b):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
# d
import numpy as np
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = np.array(list(input()))
t = np.where(t == 'r', p, t)
t = np.where(t == 's', r, t)
t = np.where(t == 'p', s, t)
t = t.astype(dtype='int64')
tt = t
point = 0
point += np.sum(t[:k])

for i in range(k,n):
    if t[i] == t[i-k]:
        t[i] = 0
        pass
    elif t[i] != t[i-k]:
        point += t[i]

print(point)
# Judge status: Accepted
import math
x=int(input())
ans=0
money=100
while money<x:
  money=money*(1.01)
  money=int(money)
  ans+=1
print(ans)
# Judge status: Accepted
import itertools

n, m, q = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(q)]


ans = 0
for l in itertools.combinations_with_replacement(range(1, m + 1), n):
    tmp_sum = 0
    for a, b, c, d in lst:
        if l[b - 1] - l[a - 1] == c:
            tmp_sum += d
    if ans < tmp_sum:
        ans = tmp_sum

print(ans)
# Judge status: Wrong Answer
k,s=map(int,input().split())
count=0

if k*3==s:
  print(1)
  exit()

for x in range(k+1):
  for y in range(k+1-x):
    z=s-x-y
    if z>=0 and z<=k:
      count+=1
print(count)
# Judge status: Accepted
def euclid(m, n):
    while n != 0:
        m, n = n, m % n
    return m

# ABC148C

a, b = map(int, input().split())
print(a * b // euclid(a, b))
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(lambda x: int(x) - 1, input().split()))
P = [-1] * N 
cur = 0
P[cur] = 0
route = [1]

for step in range(K):
  cur = A[cur]
  route.append(cur + 1)
  if P[cur] >= 0:
    l_start = P[cur]
    l_end = step + 1
    l_len = l_end - l_start
    break
  else:
    P[cur] = step + 1
else:
  print(cur + 1)
  quit()

print(route[l_start + ((K - l_start) % l_len)])
# Judge status: Accepted
n=int(input())
jud=0
a=1
ans=0
while jud!=1:
    x=n//a
    if x==1:
        jud=1
    else:
        ans+=x
        if n%a==0:
            ans-=1
        a+=1
ans+=n-a
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())

S = 0
S = (a+b)*h/2
print(int(S))
# Judge status: Accepted
n,m = map(int, input().split())

print('Yes' if n==m else 'No')
# Judge status: Accepted
A, B = map(int, input().split())
H = [i * (i + 1) // 2 for i in range(1, 1001)]

for l, r in zip(H, H[1:]):
    if r - l == B - A:
        print(r - B)
        exit()
# Judge status: Wrong Answer
# 10の余りの絶対値でソートできると良いのですが、今のところ検討中です。
# Judge status: Accepted
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)
      
N=int(input())
T=[]
total=1
for i in range(N):
    a=int(input())
    T.append(a)
T_set=sorted(list(set(T)))
M=len(T_set)

ans=T_set[0]
if M==1:
    ans=T_set[0]
else:
    for i in range(1,M):
        ans=lcm(ans,T_set[i])

print(ans)
# Judge status: Accepted
ABC=input().split()

five_count=ABC.count("5")
seven_count=ABC.count("7")

if five_count == 2 and seven_count == 1:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
print("Hello")
a,b,c = list(map(int, input().split()))

if((b-a) == (c-b)):
        print("YES")
else:
        print("NO")
# Judge status: Wrong Answer
n = int(input())

ans = abs(n)
for i in range(n > 0, 30, 2):
    if ans & (1 << i) == (1 << i):
        ans += (1 << (i + 1))
print(f'{ans:b}')
# Judge status: Accepted
import math
from functools import reduce


n=int(input())
    
res=0
nlist=[]
for a in range(1,n+1):
    for b in range(1,n+1):
        nlist.append(math.gcd(a,b))
        
import collections

c = collections.Counter(nlist)
ck=list(c.keys())
cv=list(c.values())

cn=len(ck)

for i in range(cn):
    for c in range(1,n+1):
        res+=math.gcd(c,ck[i])*cv[i]
print(res)
# Judge status: Wrong Answer
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = int(input())
    ans = [0, 0, s, 0, 0, 1]
    print(*ans)
        
        
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b,c = map(int, input().split())

if 4*a*b < (c-a-b)**2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n,k=map(int,input().split())
ar=list(map(int,input().split()))
ar.sort()
pos=0
for i in range(k):
  pos+=ar[i]
print(pos)
# Judge status: Wrong Answer
import numpy as np
def solve(n, k, a):
    lb = 0
    ub = np.max(a)
    while ub - lb > 1:
        cur = (lb + ub) / 2
        cnt = np.sum(np.ceil(a/cur)) - n
        if cnt > k:
            lb = cur
        else:
            ub = cur
    return int(np.ceil((lb+ub) / 2))

n, k = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, k, a))
# Judge status: Wrong Answer
X,Y,Z=map(int,input().split())
X+=Z
print(X//(Z+Y))
# Judge status: Accepted
def resolve():
    x = int(input())
    mod = x%11
    div = x//11
    if mod==0:
        print(div*2)
    elif mod <= 6:
        print(div*2 + 1)
    else:
        print(div*2+2)

resolve()
# Judge status: Accepted
a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
  s = str(i)
  if s[0]==s[4] and s[1]==s[3]:
    ans += 1
print(ans)
# Judge status: Accepted
n, k = (int(i) for i in input().split())

data = list(int(i) for i in input().split())
s =data.sort()
res = 0
for i in range(k):
    res += int(data[i])
print(res)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

r, g, b = input().split()

if int(r+g+b)%4==0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
#???
n=int(input())
a=list(map(int,input().split()))
MOD=10**9+7

def gcd(x,y):
  if x<y:x,y=y,x
  if y==0:return x
  return gcd(x%y,y)

def lcm(x,y):
  return x*y//gcd(x,y)

def inv(x):
  return pow(x,MOD-2,MOD)

L=1
for i in a:
  L=lcm(L,i)

L=L%MOD
ans=0
for i in a:
  ans=(ans+L*inv(i))%MOD
  

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

ans = 0
s = sum(A)
while s % 2 == 0:
    s /= 2
    ans += 1
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
x = int(input())
for i in range(50000):
    if int(i * 1.08) == x:
        print(i)
        quit()
print(':(')
# Judge status: Wrong Answer
Q, H, S, D = map(int, input().split())
N = int(input())

q = Q*4
h = H*2
s = S
d = D//2

r = min([q, h, s, d])

if r != d:
    print(r*N)
else:
    if N%2==0:
        print(r*N)
    else:
        ans = (N-1)*r
        ans += min([q, h, s])
        print(ans)
# Judge status: Wrong Answer
a,b,t=map(int,input().split())
n=t//a
print(b*n*(n+1)//2)
# Judge status: Accepted
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
mosters=sum(a)

for i in range(n):
    hunted1 = min(a[i],b[i])
    a[i] -=hunted1
    b[i] -=hunted1
    hunted2 = min(a[i+1],b[i])
    a[i+1] -=hunted2
    b[i] -=hunted2
    
print(mosters-sum(a))
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

dict = {}

for a in A:
    if a not in dict:
        dict[a] = 1
    else:
        dict[a] += 1

countlist = sorted([a for a in dict.values()], reverse=True)

print(sum(countlist[K:]))
# Judge status: Wrong Answer
import copy
N = int(input())
X = list(map(int,input().split()))
length = len(X)
X.sort()
bef = int(length/2)-1
aft = bef
for i in range(N):
    if(i<=bef):
        print(X[bef])
    else:
        print(X[aft])
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
cost = [0] * n
cost[1] = abs(a[1]-a[0])
for i in range(2,n):
    cost[i] = min(cost[i-1]+abs(a[i]-a[i-1]),cost[i-2]+abs(a[i]-a[i-2]))
print(cost)
print(cost[n-1])
# Judge status: Wrong Answer
H, N = map(int, input().split())

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

c = 0

for i in range(len(A)):
  c = c + A[i]
  
if c > H:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N, M = map(int, input().split())

if N < M // 2:
    print((N + M // 2) // 2)
else:
    print(M//2)
# Judge status: Accepted
from collections import deque

N = int(input())
As = list(map(int,input().split()))

h = deque([])
for i in range(N):
  if i%2 == 0:
    h.append(As[i])
  else:
    h.appendleft(As[i])
    
if N%2 == 1:
  h.reverse()
  
print(" ".join(map(str,h)))
# Judge status: Accepted
S = list(input())
# min(全部０１０１０、全部１０１０１)
cnt0 = 0
cnt1 = 0
for e in S[::2]:
    if e == '1':
        cnt0 += 1
    else:
        cnt1 += 1
for e in S[1::2]:
    if e == '0':
        cnt0 += 1
    else:
        cnt1 += 1
print(min(cnt0, cnt1))
# Judge status: Accepted

from bisect import bisect_right
import sys

readline = sys.stdin.readline
n, m = map(int, readline().split())
ken = [list() for _ in range(n)]
PY = []
for _ in range(m):
    p, y = map(int, readline().split())
    PY.append((p, y))
    ken[p-1].append(y)
for i in range(n):
    ken[i].sort()

for p, y in PY:
    print(str(p).zfill(6) + str(bisect_right(ken[p-1],y)).zfill(6))
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
import collections
c=collections.Counter(a)
t=list(c.items())
t.sort(reverse=True)
if t[0][1]>=4:
  print(t[0][0]**2)
elif t[1][1]>=2:
  print(t[0][0]*t[1][0])
else:
  print(0)
# Judge status: Wrong Answer
a,b = map(int,(input().split()))

if a + b > 16 or (a > 9 or b > 9):
    print(":( ")
else:
    print("Yay!")
# Judge status: Accepted
n,m = map(int,input().split())
a = list(map(int,input().split()))
x = []
for i in range(m):
    x.append(list(map(int,input().split())))
x = sorted(x, key=lambda s:s[1], reverse=True)
y = []
for i in range(m):
    b,c = x[i][0],x[i][1]
    y += [c]*b
    if len(y) >= n:
        break
z = a+y
print(sum(sorted(z,reverse=True)[:n]))
# Judge status: Wrong Answer
N,M,K = map(int, input().split())


for n in range(N+1):
  for m in range(M+1):
    if M*(N-n) + N*(M-m) == K:
      print('Yes')
      exit()
else:
  print('No')
# Judge status: Accepted
o = input()
e = input()

for i in range(len(e)):
    print(o[i], end = '')
    print(e[i], end = '')

if len(o) != len(e):
    print(o[len(o)-1])
# Judge status: Accepted
a,b = map(int,input().split())

if a > b:
  print(a-1)
else:
  print(a)
# Judge status: Wrong Answer
n=[int(x) for x in input()]
for i in range((len(n)-1)**2):
    result=n[0]
    a=["-"]*len(n)
    for j in range(len(n)-1):
        if (i>>j &1)==1:
            result+=n[1]
            a[j]="+"
        else:
            result-=0
    if result==7:
        print(n[0],a[0],n[1],a[1],n[2],a[2],n[3],"=7")
        break
# Judge status: Accepted
#なるべく小さいものから合成した方が良い
from functools import reduce
n = int(input())
v = sorted(list(map(int, input().split())))
def flat(x,y):
    return (x+y)/2
print(reduce(flat, v))
# Judge status: Wrong Answer
N=int(input())
A=list(map(int, input().split()))
p=10**9+7
S=sum(A)
S2=S**2
T=0
for i in range(N):
    T+=A[i]**2
ans=((S2-T)//2)%p
print(ans,S2)
# Judge status: Accepted
from sys import stdin

s = stdin.readline().rstrip()

pos_a = s.find('A')
pos_z = s.rfind('Z')

print(pos_z - pos_a + 1)
# Judge status: Accepted
N = int(input())

if N <= 5:
    print(N//3)
    exit()
    
A = [1,1,1]
for i in range(N - 5):
    A += A[i] + A[i+2],
print(A.pop()%(10**9+7))
# Judge status: Wrong Answer
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M = map(int, input().split())

i = 1
ans = 0
while i * i <= M:
    if M % i == 0 and M // i >= N:
        ans = max(ans, i)
    if M % i == 0 and M // (M // i) >= N:
        ans = max(ans, i)

    i += 1

print(ans)
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

n = int(input())
s = input()

x = 0
ans = 0
for i in range(n):
    if (s[i] == "I"):
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print(ans)
# Judge status: Accepted
import itertools
N, M, Q = map(int, input().split())
query = []
for i in range(Q):
    query.append(list(map(int, input().split())))

As = list(itertools.combinations_with_replacement(range(1, M+1), N))
ans = 0
for a in As:
    point = 0
    for q in query:
        if a[q[1]-1] - a[q[0]-1] == q[2]:
            #print(a, " + ", q)
            point += q[3]
    ans = max(ans, point)
    #print(point)

#print(As)
#print(query)
print(ans)
# Judge status: Accepted
s = [ord(alph)-97 for alph in input()]
K = int(input())
i = 0
while K > 0 and i < len(s)-1:
    if s[i] != 0 and 26-s[i] <= K:
        K -= 26-s[i]
        s[i] = 0
    else:
        i += 1
s[-1] = (s[-1]+K)%26 
print(*[chr(x+97) for x in s], sep = '')
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline

N, K, Q = list(map(int, readline().split()))
A = []
for a in range(Q):
    A.append(int(readline()))

points = [0] * N

for i in range(Q):
    points[A[i] - 1] += 1

for p in points:
    score = K - Q + p
    print("Yes" if score > 0 else "No")
# Judge status: Accepted
N, K = map(int, input().split())
ans = 0
for tmp in range(1, N+1):
    i = 0
    while tmp < K:
        tmp *= 2
        i += 1
    ans += (1/N)*(0.5**i)
print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

if b < c :
	print(0)
	exit()

if a == 0 and b > c and b < d:
	print(b - c)
	exit()

if a < c and  d < b:
	print(d - c)
	exit() 

if a == c :
	print(b - a)
	exit()
# Judge status: Wrong Answer
n = int(input())
result = 0
if n % 2 == 0:
  n = n // 2
  a = 5
  while (n // a) > 0:
    result += n // a
    a *= 5
    result += n // a
print(result)
# Judge status: Accepted
n = int(input())
A = [0]*n
B = [0]*n
for i in range(n):
    A[i],B[i]=map(int,input().split())
A.sort()
B.sort()

def median(li):
    if n%2==1:
        return li[n//2]
    else:
        return sum(li[n//2-1:n//2+1])
print(median(B)-median(A)+1)
# Judge status: Wrong Answer
total = int(input())
tall = list(map(int, input().split()))
dif = 0
for i in range(total - 1):
    if tall[i+1] > tall[i]:
        var = tall[i+1] - tall[i]
        tall[i] += var
        dif += var
    else:
        pass
print(dif)
# Judge status: Wrong Answer
time=int(input())
nums=[int(i) for i in input().split()]
odd=0
even=0
even35=0
for j in range(time):
    if nums[j]%2==0:
        even+=1
        if nums[j]%3!=0 and nums[j]%5!=0:
            continue
        else:
            even35+=1
    else:
        odd+=1
        
if even35==even==0:
    print("DENIED")
elif even35==even:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)
# Judge status: Wrong Answer
n = int(raw_input())
es = [map(int, raw_input().split(' ')) for _ in range(n)]
es.sort(key = lambda x:x[1])
res = []
t = 0
while(es):
	delta = abs(t - es[0][1])
	bag = []
	for j in range(len(es)):
		if es[j][0] <= delta:
			#duration, deadline
			bag.append([es[j][1], es[j][0],j])
	if bag:
		a,b,i = min(bag)
		res.append([b])
		t += a
		es = es[:i] + es[i+1:]
		es.sort(key = lambda x:x[1])

	else:
		break
print 'Yes' if not(es) else 'No'
# Judge status: Accepted
n, a, b = map(int, input().split())
M = b*(n-1)+a
m = b+a*(n-1)
print(max(M-m+1, 0))
# Judge status: Accepted
import networkx as nx
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]

g=nx.Graph()
g.add_nodes_from([i for i in range(1,n+1)])

for x in s:
    g.add_edge(x[0],x[1])
di=nx.predecessor(g,source=1)

if len(di)!=n:
    print("No")
    exit()

print("Yes")
for x in range(2,n+1):
    print(di[x][0])
# Judge status: Accepted
a=input()
if a.isupper():
  print("A")
else:
  print("a")
# Judge status: Wrong Answer
import sys
S = input()
if len(S) != 10:
    sys.exit()
if S[0:8] != '2017/01/':
    sys.exit()
if 1 <= int(S[-2]) <= 31:
    sys.exit()
    
print(S.replace('2017','2018'))
# Judge status: Wrong Answer
n, m = map(int, input().split())
xx = sorted(list(map(int, input().split())))

yy = [abs(xx[i]-xx[i+1]) for i in range(m-1)]

sy = sorted(yy)
print(sum(sy[:-n+1]))