peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N,K = map(int,input().split())
P = list(map(int,input().split()))

Q = [(P[i]+1)/2 for i in range(N)]

max,tmp = sum(Q[0:K]),sum(Q[0:K])
for i in range(N-K):
    tmp = tmp + Q[K+i] - Q[i]
    if max < tmp:
        max = tmp

print(max)
# Judge status: Accepted
a,b,x = map(int, input().split())

import math

if x==a*a*b:
    print(0)
    exit()

if x > (a*a*b)/2:
    theta = math.atan(((a*a*a)/(a*a*b-x))/2)
else:
    theta = math.atan((2*x) / (a*b*b))

print(90-math.degrees(theta))
# Judge status: Accepted
W,H,N=map(int,input().split())

a1,a2,a3,a4=0,W,0,H
for i in range(N):
  x,y,a=map(int,input().split())
  if a==1:a1=max(a1,x)
  elif a==2:a2=min(a2,x)
  elif a==3:a3=max(a3,y)
  else:a4=min(a4,y)
    
if a1>=a2 or a3>=a4:
  print(0)
  exit()
if a1>=W or a2<=0 or a3>=H or a4<=0:
  print(0)
  exit()
  
print((a2-a1)*(a4-a3))
# Judge status: Accepted
# A - Wanna go back home
ss=input()
n=ss.count('N')
w=ss.count('W')
s=ss.count('S')
e=ss.count('E')

ns=False
if n>0 and s>0:
    ns=True
elif n==0 and s>0:
    ns=False
elif n>0 and s==0:
    ns=False
elif n==0 and s==0:
    ns=True

we=False
if w>0 and e>0:
    we=True
elif w==0 and e>0:
    we=False
elif w>0 and e==0:
    we=False
elif w==0 and e==0:
    we=True

if ns==True and we==True:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a = map(int, input().split())
a = list(a)
a.sort()
print (a[0] + a[1])
# Judge status: Accepted
H,W = map(int,input().split())

if (H == 1) or (W ==1):
    print(1)
elif (H*W) % 2 == 0:
    print(int(H*W/2))
else:
    print(int(H*(W-1)/2+(H/2+1)))
# Judge status: Accepted
s=input()
t=s[::-1]
cnt=0
for i in range(len(t)//2):
    if s[i]!=t[i]: cnt+=1
print(cnt)
# Judge status: Wrong Answer
n = int(input())

count = 0
max_count = 0
for i in range(n):
    input_elements = input().split()
    if input_elements[0] == input_elements[1]:
        count += 1
    else:
        max_count = count
        count = 0

if max_count < count:
    max_count = count

if max_count >= 3:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x = input()
s_q = []
arc = []
for i, v in enumerate(x):
    if v == 'S':
        s_q.append(v)
    else:
        if len(s_q) > 0:
            s_q.pop()
        else:
            arc.append(v)
print(len(s_q)+len(arc))
# Judge status: Accepted
import math
a, b = map(int, input().split())
if(a % b == 0):
  print(-1)
else:
  i = math.gcd(a, b)
  c = a // i
  d = b // i
  print(c * d * i + a)
# Judge status: Accepted
def main() -> None:
    A, B = map(int, input().split())
    now, cnt = 1, 0
    while True:
        if now >= B:
            break
        now += A - 1
        cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
d1 = b - a
d2 = c - b
d3 = d - c
d4 = e - d
if d1 <= k and d2 <= k and d3 <= k and d4 <= k:
  print('Yay!')
else:
  print(':(')
# Judge status: Accepted
n, m, *a = map(int, open(0).read().split())
div = 1000000007
broken = set(a)
 
f = [0] * (n + 1)
f[0] = 1
if 1 not in broken:
    f[1] = 1
 
for i in range(2, n + 1):
    if i in broken:
        continue
    f[i] = (f[i - 1] + f[i - 2]) % div
 
print(f[-1])
# Judge status: Accepted
n = int(input())
if 1 <= n <= 999:
    print('ABC')
else:
    print('ABD')
# Judge status: Wrong Answer
a, b = map(int, input().split())
if (a + b) % 2 == 0:
  print((a+b)/2)
else:
  print((a+b+1)/2)
# Judge status: Accepted
s = input()
m = int(s[5:7])
d = int(s[8:10])
tt = m * 100 + d
print('Heisei' if tt <= 430 else 'TBD')
# Judge status: Wrong Answer
s = list(str(input()))
s = list(map(int, s))
k = int(input())

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

if flag:
    print(1)
else:
    for i in range(len(s)):
        if s[i] != 1:
            print(s[i])
            break
# Judge status: Wrong Answer
n,m = map(int,input().split())
d = dict()
for i in range(m):
    k,v = map(int,input().split())
    if k in d:
        if d[k] !=v:
            print(-1)
            exit()
    else:
        d[k] = v
res = ""
for i in (1,n+1):
    if i not in d:
        d[i] = 0
    res += str(d[i])
res = int(res)
if res == 0:
    print(-1)
    exit()
print(res)
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for _ in range(n)]

ans, tmp = 0, 0
for ai in a:
    ans += (ai + tmp) // 2
    tmp = 0
    if ai != 0:
        tmp = (ai + tmp) % 2
print(ans)
# Judge status: Accepted
def main():
    X=int(input())
    X=X//100
    print(10 - X//2)

main()
# Judge status: Wrong Answer
a,b,c=(map(int,input().split()))
if a!=b!=c:
  print(3)
elif a==b==c:
  print(1)
else:
  print(2)
# Judge status: Wrong Answer
N = int(input())
A = [int(i) for i in input().split()]
li = ["" for i in range(N)]
for i in range(N):
    li[A[i]-1] = str(i)
print(" ".join(li))
# Judge status: Accepted
N, L = list(map(int, input().strip().split()))
strl = [input().strip() for s in range(N)]
strl = sorted(strl)
s = ''
for t in strl:
  s += str(t)
print(s)
# Judge status: Accepted
n=int(input())
s=input()

r,g,b=s.count('R'),s.count('G'),s.count('B')

cnt=0

for i in range(n):
  d=0
  while 1:
    d+=1
    j=i+d
    k=j+d
    if not k<n:
      break
    if not (s[i]==s[j] or s[j]==s[k] or s[k]==s[i]):
      cnt+=1
print(r*g*b-cnt)
# Judge status: Wrong Answer
#169A https://atcoder.jp/contests/abc169/tasks/abc169_a
# 1. 入力を受け取ること
# スペース区切りの入力を整数として受け取れる「2 5」　→　「a=2, b=5」となる
a, b = map(int, input().split())

print(a)
print(b)

# 2. 受け取った結果を使って目的の計算をすること
answer = a * b

# 3. 出力すること
print(answer)
# Judge status: Accepted
# B - Qualification simulator
N,A,B = map(int,input().split())
S = input()
domestic,foreign = 0,0

for i in range(N):
    s = S[i]
    if s=='a':
        if domestic+foreign<A+B:
            print('Yes')
            domestic += 1
        else:
            print('No')
    elif s=='b':
        if domestic+foreign<A+B and foreign<B:
            print('Yes')
            foreign += 1
        else:
            print('No')
    else:
        print('No')
# Judge status: Wrong Answer
n, m, x = map(int, input().split())
b = []
for _ in range(n):
    c, *a = list(map(int, input().split()))
    b.append((c, a))

mc = 100001
k = [0 for _ in range(n)]

def search(i, cost, k):
    if i == n:
        return cost if min(k) >= x else mc
    else:
        return min(search(i + 1, cost + b[i][0], [k[idx] + b[i][1][idx] for idx in range(m)]), search(i + 1, cost, [e for e in k]))

ans = search(0, 0, [0 for _ in range(m)])
if ans == mc:
    ans = -1
print(ans)
# Judge status: Accepted
s = input()

while 1:
    for x in ('dream', 'dreamer', 'erase', 'eraser'):
        if s.endswith(x):
            s = s[:-len(x)]
            break
    else:
        print('NO')
        break
    if not s:
        print('YES')
        break
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = 0
plus = ""
for i in range(N):
  if plus != "":
    if plus:
      if A[i-1] > A[i]:
        ans += 1
        plus = ""
    else:
      if A[i-1] < A[i]:
        ans += 1
        plus = ""
  if i < N-1 and plus == "":
    if A[i] < A[i+1]:
      plus = True
    elif A[i] > A[i+1]:
      plus = False
print(ans+1)
# Judge status: Wrong Answer
n = int(input())

for x in range(1, 9 + 1):
    a  = n / x
    if a < 10:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
n=int(input())
x=pow(10,n,10**9+7)-2*pow(9,n,10**9+7)+pow(8,n,10**9+7)
print(x%(10**9+7))
# Judge status: Accepted
n = int(input())
s = input()
count_r = s.count("R")
count_g = s.count("G")
count_b = s.count("B")
sum = count_r * count_g * count_b
minus = 0

for i in range(n-2):
    for j in range(2, n-i+1, 2):
        if i+j <= n-1:
            tem = [s[i], s[i+j//2], s[i+j]]
            if tem[0] != tem[1] and tem[0] != tem[2] and tem[1] != tem[2]:
                minus += 1
            

print(sum - minus)
# Judge status: Accepted
n = int(input())
a,b = map(int,input().split())
 
dif = b//n-a//n
 
if dif == 0 and b%n != 0 and a%n !=0 :
  print("NG")
else:
  print("OK")
# Judge status: Wrong Answer
def main():
    section_num = int(input())
    length = list(map(int, input().split()))
    sums = [sum(length[:section_num // 2]), sum(length[section_num // 2:])]
    answer = abs(sums[0] - sums[1])
    sums[0] += length[section_num // 2]
    sums[1] -= length[section_num // 2]
    answer = min(answer, abs(sums[0] - sums[1]))
    print(answer)


if __name__ == '__main__':
    main()
# Judge status: Accepted
#https://atcoder.jp/contests/abc073/tasks/abc073_a

if "9" in str(input()):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
if x < a + b:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
from decimal import Decimal
a,b = input().split()
print(int(Decimal(a) * Decimal(b)))
# Judge status: Accepted
A, B, C = map(int, input().split())

ans = min(B // A, C)
print(ans)
# Judge status: Wrong Answer
N=int(input())
X=sorted(list(map(int,input().split())))
for i in range(N):
  if i<(N//2):
    print(X[N//2])
  else:
    print(X[N//2-1])
# Judge status: Accepted
import sys
input = sys.stdin.readline
a,b=map(int,input().split())
print((a+b)%24)
# Judge status: Accepted
#ANS-3
input_N,A,B = input().split()
A = int(A)
B = int(B)

count = 0
for i in range(int(input_N)+1):
    sum_all = 0
    i_str = str(i)
    for j in range(len(i_str)):
        sum_all += int(i_str[j])
    if A<=sum_all:
        if sum_all<=B:
            count += i
            
print(count)
# Judge status: Accepted
from itertools import combinations
def triangle(l_tuple):
  if len(set(l_tuple)) == 3:
    if l_tuple[0] + l_tuple[1] > l_tuple[2] and l_tuple[1] + l_tuple[2] > l_tuple[0] and l_tuple[2] + l_tuple[0] > l_tuple[1]:
      return True
  return False
n = int(input())
l = list(map(int, input().split()))
l_comb = list(combinations(l, 3))
cnt = 0
for i in l_comb:
  if triangle(i):
    cnt += 1
print(cnt)
# Judge status: Wrong Answer
# -*- coding : utf-8 -*-

S = str(input())

w = ""

if len(S) == 0:
  if S[0] == "B":
    w = ""
  else :
    w = w + S[0]
else:
  if S[0] == "B":
    w = ""
  else :
    w = w + S[0]
    for i in range(1,len(S)):
      if S[i] == "B":
        if w == "":
          w = ""
        else :
          w = w.rstrip(S[i-1])
      else:
        w = w + S[i]

print(w)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
last = A[-1]
count = last
root = 1
for i in range(N):
  if i+1 == N and root-A[i] > A[i+1]:
    root = last + A[i]
  elif root-A[i] > (last + A[i+1]):
    root = (last + A[i+1]) + A[i]
  count+=root
  root = (root-A[i])*2
  if root < A[i+1]:
    print(-1)
    break
else:
  print(count)
# Judge status: Accepted
N, K = map(int, input().split())
ans = 0
mod = 10 ** 9 + 7

def sum_num(n):
    return (n*(n+1))//2

for k in range(K, N+1):
    min_sum = sum_num(k-1)
    max_sum = sum_num(N) - sum_num(N-k)
    # print(k, min_sum, max_sum)
    ans += max_sum - min_sum + 1

ans += 1
ans %= mod
print(int(ans))
# Judge status: Accepted
X = int(input())
print(X//500*1000 + (X-X//500*500)//5*5)
# Judge status: Accepted
s = input()
h = 'hi'
if s == h or s == h * 2 or s == h * 3 or s == h * 4 or s == h * 5:
    print('Yes')

else:
    print('No')
# Judge status: Accepted
S = input()
lll = "abcdefghijklmnopqrstuvwxyz"
for i in range(26):
    if lll[i] in S:
        pass
    else:
        print(lll[i])
        exit()
    
print("None")
# Judge status: Accepted
x, y = map(int, input().split())
a = [4, 6, 9, 11]
b = [1, 3, 5, 7, 8, 10, 12]
if x == 2 or y == 2:
    print('No')
elif x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=b[a[i]-1]
  if i>0 and a[i]==a[i-1]+1:
    sum+=c[a[i-1]-1]
  
print(str(sum))
# Judge status: Accepted
s = input()
ls =["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
t = ls.index(s)
print(7-t)
# Judge status: Accepted
N = int(input())
X = set([input() for _ in range(N)])
print(len(X))
# Judge status: Accepted
n, q = map(int, input().split())
s = input()
"""ナイーブ
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))
"""
# 前処理＋全探索
# 区間なので累積和を疑う
t = [0]*n
count = 0
for i in range(n-1):
    t[i] = count
    if s[i] + s[i+1] == "AC":
        count += 1
    t[i+1] = count
#print(t)
for i in range(q):
    l, r = map(int, input().split())
    ans = t[r-1] - t[l-1]
    print(ans)
# Judge status: Wrong Answer
k = int(input())
c = 0
a = [0]*(k+1)
a[0] = 7%k

if k%2 == 0 or k%5 == 0:
	print('-1')
elif 7%k == 0:
	print('1')
else:
	for i in range(1,k):
		c += 1
		a[i+1] = (10*a[i] + 7)%k
		if a[i+1] == 0:
			break
	print(c)
# Judge status: Wrong Answer
import math
H,W = list(map(int,input().split()))
ans = 0
if H * W % 2 == 0:
    ans = H * W / 2
elif H == 1 or W == 1:
    ans = 1
else:
    ans = ((H-1) * W / 2) + math.ceil(W/2)
print(int(ans))
# Judge status: Wrong Answer
s= list(map(str,input().split()))
print('A' + ''+ s[0] + '' +'C')
# Judge status: Accepted
N,D=map(int, input().split())
print((N+D*2)//(D*2+1))
# Judge status: Accepted
K,A,B = map(int,input().split())

if B-A < 3:
  print(1+K)
  exit()

ans = 1

N = K - (A-1)
if N >= 2:
  ans += A-1
  ans += (B-A)*(N//2) + N%2
else:
  ans += K
print(ans)
# Judge status: Wrong Answer
N = int(input())
ans = [0 for i in range(N)]
for i in range(N-1):
  c, s, f = map(int, input().split())
  for j in range(i+1):
    if ans[j]>=s:
      x = int((ans[j]-s)/f)
      ans[j] = s+f*x+c
    else:
      ans[j] = s+c
for i in range(N):
  print(ans[i])
# Judge status: Accepted
N, K = map(int, input().split())
pN = list(map(int, input().split()))

ex_p = [(pi+1)/2 for pi in pN]
cum_p = [ex_p[0]]
for i in range(1,N):
    cum_p.append(cum_p[i-1]+ex_p[i])

max_ex = cum_p[K-1]
for i in range(1,N-K+1):
    if max_ex < cum_p[K+i-1] - cum_p[i-1]:
        max_ex = cum_p[K+i-1] - cum_p[i-1]

print(max_ex)
# Judge status: Accepted
A,B,C=map(int,input().split());print(['Yes','No'][C<A or C>B])
# Judge status: Wrong Answer
from math import pi, tan
EPS = 0.0000000001

def f(a, b, theta):
    if theta >= pi * 0.5:
        return 0.0
    elif tan(theta) >= b / a:
        return a * b**2 * 0.5 / tan(theta)
    else:
        return a**2 * b - a**2 *b * 0.5 * tan(theta)

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

l = 0
r = pi * 0.5
while r - l >= EPS:
    mid = (l + r) * 0.5
    if f(a, b, mid) >= x:
        l = mid
    else:
        r = mid

print("{:.10f}".format(l / pi * 180))
# Judge status: Wrong Answer
import copy
li=[int(input()) for i in range(5)]

ans=10**9
temp=0

for j in li:
    temp = j
    li2 = copy.copy(li)
    li2.remove(j)
    for k in li2:
        temp += k + (10 - (k % 10))
    ans = min(ans, temp)

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

p,q = max(a), sum(a) - max(a)
if p < q:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import re

s2 = input().replace('?','.')
t = input()
a = len(s2)
b = len(t)
l = []

for i in range(a-b+1):
    if re.match(s2[i:i+b], t) is not None:
        s3 = s2.replace(s2[i:i+b], t, 1).replace('.','a')
        l.append(s3)

if not l:
    print('UNRESTORABLE')
else:
    print(sorted(l)[0])
# Judge status: Wrong Answer
N = int(input())
h = list(map(int,input().split()))
cost = [100000]*N

cost[0] = 0
for i in range(N-1): 
  num = cost[i] + abs(h[i+1]-h[i])
  if cost[i+1] > num:
    cost[i+1] = num
  if i > 0:
    num2 = cost[i-1] + abs(h[i+1]-h[i-1])
    if cost[i+1] > num2:
      cost[i+1] =  num2
      
print(cost[N-1])
# Judge status: Accepted
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    a=input()
    if a=='AC':
        ac+=1
    elif a=='WA':
        wa+=1
    elif a=='TLE':
        tle+=1
    else:
        re+=1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))
# Judge status: Wrong Answer
N = int(input())
L = list(map(int,input().split()))
L.sort()
print(L)
from bisect import bisect_left
ans = 0
for i in range(N):
  for j in range(i+1, N):
    sum = L[i]+L[j]
    count = bisect_left(L, sum)
    print(count)
    ans += max(0, count-j-1)
    print(ans)
print(ans)
# Judge status: Accepted
K,N = map(int,input().split())
A = list(map(int,input().split()))
a = []
for i in range(N-1):
    a.append( A[i+1] - A[i])
a.append(K-A[N-1] + A[0])
Am = max(a)
print(K-Am)
# Judge status: Wrong Answer
import collections
N=int(input())
S=[list(input()) for i in range(N)]
x=[]
for i in S:
  a=collections.Counter(i)
  a=sorted(a)
  x.append(a)
x=list(map(list,set(map(tuple,x))))
print(N-len(x)+1)
# Judge status: Accepted
k = int(input())
a, b = input().split(' ')
a = int(a)
b = int(b)
result = 'NG'
for i in range(a, b + 1 ):
  n = i % k
  if n == 0:
    result = 'OK'
    break
print(result)
# Judge status: Accepted
n, a, b = map(int, input().split())

if n%(a+b) >= a:
    print(n//(a+b)*a+a)
else:
    print(n//(a+b)*a+n%(a+b))
# Judge status: Accepted
n,m = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
sortsecond = lambda val : val[0]
a.sort(key=sortsecond)
count = 0
for i in range(n):
    if a[i][1] <= m:
        count += a[i][1]*a[i][0]
        m -= a[i][1]
    else:
        count += m*a[i][0]
        break
print(count)
# Judge status: Wrong Answer
n=int(input())
s=input()
x=0
L=[]
for i in range(n):
    if s[i]=="I":
        x+=1
    elif s[i]=="D":
        x-=1
    L.append(x)
print(max(L))
# Judge status: Accepted
#!/usr/bin/env python3
a, b, c = map(int, input().split())
print(a*b//2)
# Judge status: Accepted
a, b, x = map(int, input().split())
print(b//x - (a-1)//x )
# Judge status: Wrong Answer
row_data = input().split()
trial_data = int(row_data[0])
change_coin = int(row_data[1])
change_buiscuit = int(row_data[2])

if change_coin - change_buiscuit >= -1:
  print(int(trial_data+1))
else:
  residual = trial_data - change_coin + 1
  if residual % 2 == 0:
    if residual <= 1:
      print(int(change_buiscuit))
    else:
      print(int(((residual-2)/2) * (change_buiscuit - change_coin) + change_buiscuit))
  else:
    if residual <= 1:
      print(int(change_buiscuit + 1))
    else:
      print(int(((residual-3)/2) * (change_buiscuit - change_coin)+ change_buiscuit + 1))
# Judge status: Wrong Answer
n,k = map(int,input().split())
ans = 0
for i in range(10**9):
    if n >=2:
        n = n//k
        ans +=1
    else:
        break
print(ans+1)
# Judge status: Accepted
N,K,X,Y = [int(input()) for i in range(4)]
if N>K:
  total = N*X- (N-K)*(X-Y)
  print(total)
else:
  total = N*X
  print(total)
# Judge status: Wrong Answer
import math
N = int(input())

if N <= 6:
  ans = 1
elif N <= 11:
  ans = 2
elif N % 11 == 0:
  ans = N / 11
else:
  ans = (math.floor(N / 11) * 2) + 1

print(ans)
# Judge status: Accepted
a,b,c = map(int, input().split())

res = a*b*c
res = min(res, abs(a*b*(c//2) - a*b*(c-c//2)))
res = min(res, abs(a*(b//2)*c - a*(b-b//2)*c))
res = min(res, abs((a//2)*b*c - (a-a//2)*b*c))
print(res)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

L = list(range(A, min(B+1, A+K+1))) + list(range(max(A, B-K+1), B+1))
L_no_duplication = set(L)
print(*sorted(L_no_duplication), sep="\n")
# Judge status: Accepted
#!/usr/bin/env python3

def main():
    A, B, K = map(int, open(0).read().split())
    if (A > K):
        print(A - K, B)
    elif (B - (K - A) >= 0):
        print(0, B - (K - A))
    else:
        print(0, 0)



main()
# Judge status: Accepted
def A():
    s = input()
    print(s[:3])
A()
# Judge status: Accepted
H,N=map(int,input().split())
dp=[10**12 for _ in range(H+1)]
dp[0]=0
for i in range(N):
  h,n=map(int,input().split())
  for j in range(H+1):
    dp[j]=min(dp[j],dp[max(0,j-h)]+n)
print(dp[H])
# Judge status: Accepted
n = int(input())
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
  alpha_dict[i] = str(chr(c)).lower()


ans = []
def dfs(s, mx, ans):
  if len(s) == n:
    ans += [s]
    return 
  else:
    for i in range(mx+1):
      dfs(s+alpha_dict[i], max(i+1, mx), ans)

dfs("", 0, ans)
ans = sorted(ans)
for a in ans:
  print(a)
# Judge status: Accepted
N,M = map(int,input().split())
A = list(map(int,input().split()))
s = sum(A)
t = 0
for x in A:
    if 4*M*x >= s:
        t += 1
print("Yes" if t >= M else "No")
# Judge status: Wrong Answer
S, W = map(int, input().split())

if S/2 <= W:
    print("{}".format("unsafe"))
else:
    print("{}".format("safe"))
# Judge status: Accepted
import sys

ss=input().strip()

ans=["000","111","222","333","444","555","666","777","888","999"]

for a in ans:
  if a in ss:
    print("Yes")
    sys.exit()

print("No")
# Judge status: Accepted
def main():
    N = int(input())
    X, Y = [], []
    for _ in range(N):
        x, y = map(int, input().split())
        X.append(x - y)
        Y.append(x + y)
    return max(max(X) - min(X), max(Y) - min(Y))


print(main())
# Judge status: Accepted
K=int(input())

if K%2==0:
  print((K//2)**2)
else:
  print((K//2)*(K//2+1))
# Judge status: Accepted
N=int(input())
H=list(map(int,input().split()))
dp=[0]*N
dp[1]=abs(H[1]-H[0])

for i in range(N-2):
  dp[i+2]=min(dp[i+1]+abs(H[i+2]-H[i+1]),dp[i]+abs(H[i+2]-H[i]))

print(str(dp[N-1]))
# Judge status: Accepted
def resolve():
    N = int(input())
    A = int(input())
    print("Yes" if N % 500 <= A else "No")


if '__main__' == __name__:
    resolve()
# Judge status: Wrong Answer
s = input()
min_ = 10**18
for i in range(len(s)-2):
  min_ = min(min_, abs(753 - int(s[i:i+3])))
# Judge status: Accepted
x,y=map(int,input().split())
answer = 0
a=x
while True:
    answer += 1
    a*=2
    if a>y:
        break
print(answer)
# Judge status: Accepted
n =int(input())
s = input()
x,ans =0,0
for i in s:
  if i =="I":
    x +=1
    ans =max(x,ans)
  else:
    x-=1
    ans =max(x,ans)
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())

mi = min(min(a, b), c)
ma = max(max(a, b), c)
r = (a + b + c) - mi - ma

ans = (mi * r) * 1 if ma % 2 == 1 else 0
print(ans)
# Judge status: Wrong Answer
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aaa = min(a)
bbb = min(b)
for k in range(M):
    x, y, c = map(int, input().split())
    ans = min((aaa + bbb), ((a[x - 1] + b[y - 1]) - c))
print(ans)
# Judge status: Accepted
X,Y =map(int,input().split())
mod = 10**9+7

cnt = 0
for p in range(X//2+1):
  if Y == 2*X-3*p:
    A = 1
    for a in range(p):
      A *= (X-p)-a
      A %= mod
    B = 1
    for b in range(1,p+1):
      B *= b 
      B %= mod
    cnt +=( A*pow(B,mod-2,mod) )% mod
print(cnt)
# Judge status: Accepted
N, K = map(int,input().split())
mylist = list(map(int,input().split()))
mylist.sort()
print(sum(mylist[:K]))
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]>x:
        ans+=a[i]-x
        a[i]=x
    if a[i]+a[i+1]>x:
        ans+=a[i]+a[i+1]-x
        a[i+1]-=a[i]+a[i+1]-x
print(ans)
# Judge status: Accepted
S=list(input())
T=list(input())
slist=[None]*26
flag=True
for i in range(len(S)):
    if slist[ord(S[i])-97] == None and T[i] not in slist:
        slist[ord(S[i])-97] = T[i]
    elif slist[ord(S[i])-97] != T[i]:
        flag = False
        break
    else:
        slist[ord(S[i])-97] = T[i]


if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a=input()

if int(a) >= 30:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))

ans = 0
min_num = N
for i in range(N):
    if P[i] <= min_num:
        ans += 1
        min_num = P[i]

print(ans)
# Judge status: Accepted
a,b,c=list(input()),list(input()),list(input())
a,b,c=list(reversed(a)),list(reversed(b)),list(reversed(c))
x="a"
while True:
  if x=="a":
    if not a:
      print("A")
      break
    x=a.pop(-1)
  elif x=="b":
    if not b:
      print("B")
      break
    x=b.pop(-1)
  elif x=="c":
    if not c:
      print("C")
      break
    x=c.pop(-1)