peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
w,h,n=map(int,input().split())

x_mx=w
x_mn=0
y_mx=h
y_mn=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        x_mn=max(x_mn,x)
    elif a==2:
        x_mx=min(x_mx,x)
    elif a==3:
        y_mn=max(y_mn,y)
    else:
        y_mx=min(y_mx,y)

ans=(x_mx-x_mn)*(y_mx-y_mn)
if x_mx-x_mn<=0 or y_mx-y_mn<=0:
    ans=0
print(max(ans,0))
# Judge status: Accepted
import sys
import math
import bisect

def main():
    if input() in 'aeiou':
        print('vowel')
    else:
        print('consonant')
 
if __name__ == "__main__":
    main()
# Judge status: Accepted
k, x = list(map(int, input().split()))

if 500*k >= x:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
t,a=[int(i) for i in input().split()]

h=[int(i) for i in input().split()]

min=1000000
ans=0
for i in range(n):
    temp=t-0.006*h[i]
    if min>abs(a-temp):
        min=abs(a-temp)
        ans=i+1
        
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
kill,surplus = 0,0

for i in range(n):
    tmp = min(a[i],surplus)
    kill += tmp
    a[i] -= tmp
    if b[i] > a[i]:
        kill += a[i]
        surplus = b[i]-a[i]
    else:
        kill += b[i]
        surplus = 0
tmp = min(a[n],surplus)
kill += tmp
print(kill)
# Judge status: Accepted
a,b,c=map(int,input().split())
l = sorted([a,b,c])
print(l[0]+l[1])
# Judge status: Wrong Answer
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
count=0
if x==a:
    if y==a:
        count+=1
    else:
        count+=0
if x!=a and x!=2:
    if y!=a and y!=2:
        count+=1
    else:
        count+=0
if x==2:
    if y==2:
        count+=1
    else:
        count+=0
if count!=0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())

x = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        x += 1
    else:
        x = 0

    if x >= 3:
        print("Yes")
        break
else:
    print("No")
# Judge status: Accepted
S = input()

deletes = -1
while len(S) + deletes > 0:
    # 削る
    test_s = S[:deletes]

    # 判定
    if len(test_s) % 2 == 0:
        l = test_s[:len(test_s) // 2]
        r = test_s[len(test_s) // 2:]

        if l == r:
            break

    deletes -= 1

# print(deletes, test_s, l, r)
print(len(test_s))
# Judge status: Accepted
from collections import Counter

N, K = map(int, input().split(' '))
balls = tuple(map(int, input().split(' ')))

counter = Counter(balls)
counts = sorted(counter.values(), reverse=True)

print(sum(counts[K:]))
# Judge status: Wrong Answer
n, m = [int(x) for x in input().split(' ')]

cities = list()
for i in range(m):
    pi, pm = [int(x) for x in input().split(' ')]
    cities.append((pi, pm))

p = [0] * (n+1)
for city in sorted(cities, key=lambda city: city[1]): # sort by year
    p[city[0]] += 1 # city birth order
    print('{:06d}{:06d}'.format(city[0], p[city[0]]))
# Judge status: Accepted
import math
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
cd = []
for i in range(n):
    cd.append(iil())

dist = 0
for i in range(n):
    for j in range(i,n):
        dist += math.factorial(n-1)*2*((cd[i][0]-cd[j][0])**2+(cd[i][1]-cd[j][1])**2)**0.5
print(dist/math.factorial(n))
# Judge status: Accepted
s=input()
sl=len(s)

l=[0 for i in range(sl+1)]
for i in range(sl):
    if s[i]=='<':
        l[i+1]=max(l[i]+1, l[i+1])

for i in range(sl-1,-1,-1): # reversed(range(sl))
    if s[i]=='>':
        l[i]=max(l[i+1]+1, l[i])

print(sum(l))
# Judge status: Accepted
import math 
a,b=map(int,input().split())
print(math.ceil((b-1)/(a-1)))
# Judge status: Accepted
a,b,c,x,y = map(int,input().split())
ans = 0

if c*2 <= a+b:
    m = min(x,y)
    ans += m*c*2
    x -= m
    y -= m
    if 0 < x and c*x*2 < a*x:
        ans += (c*x*2)
    elif 0 < y and c*y*2 < b*y:
        ans += (c*y*2)
    else:
        ans += (a*x)+(b*y)
else:
    ans = (a*x)+(b*y)

print(ans)
# Judge status: Wrong Answer
from copy import deepcopy

N = int(input())
X = list(map(int,input().split()))
Y = deepcopy(X)
Y.sort()
med1 = Y[N//2-1]
med2 = Y[N//2]
##print("med1:",med1,"med2",med2)
for i in range(N):
    if X[i] == med2:
        print(med1)
    else:
        print(med2)
# Judge status: Accepted
n = int(input())
m = 10**9+7
a = 10**n - 9**n - 9**n + 8**n
print(a % m)
# Judge status: Accepted
N = int(input())

print(N * 800 - (N // 15 * 200))
# Judge status: Accepted
#!/usr/bin/env python3
import math


def main():
    n, k = map(int, input().split())
    p = 0
    for i in range(1, n + 1):
        head_num = math.ceil(math.log(k / i, 2.0))
        head_num = max(head_num, 0)
        p += 1 / n * ((0.5) ** head_num)
    print(p)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from decimal import Decimal
n, k = map(int, input().split())
p = list(map(int, input().split()))

num_li = [0]*n
ans = 0
num = 0

for i in range(n):
    num_li[i] = ((Decimal(p[i])*(Decimal(p[i])+1))/2)/Decimal(p[i])

num = sum(num_li[:k])

for j in range(n-k):
    num = num-num_li[j]+num_li[j+k]
    ans = max(num,ans)

print('{:.10f}'.format(ans))
# Judge status: Wrong Answer
n= 100
k= 80
s= 1000
su = []
for i in range(n):
  su.append(s)

for i in range(n-k):
  su[n-i-1] = s+1

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

result = 2020202020
num_left = 0
num_right = sum(a)

for i in range(n):
    num_left += a[i]
    num_right -= a[i]
    result = min(result, abs(num_left - num_right))
print(result)
# Judge status: Accepted
N = int(input())

words = set()

flag = True
for i in range(N):
    word = input()
    if i == 0:
        words.add(word)
        prev_word = word
    else :
        if prev_word[-1] != word[0]:
            flag = False
        else :          
            words.add(word)
            prev_word = word
            
if flag:
    if len(words) == N :
        print('Yes')
    else :
        print('No')
else :
    print('No')
# Judge status: Accepted
def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

k = int(input())
s = input()
if len(s) <= k:
    print(s)
else:
    print(s[:k]+"...")
# Judge status: Accepted
n = int(input())
flag = 0
def dfs(val):
    global flag
    if val == n:
        flag = 1
        return
    if val>n:
        return
    if val<0:
        return
    dfs(val+4)
    dfs(val+7)
dfs(0)
if flag == 1:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
s = input()
mod = 1000000007
ans = 1
cnt = Counter(s)
for v in cnt.values(): ans *= (v+1)
ans -= 1
print(ans)
# Judge status: Accepted
n = str(input().rstrip())

ans = 0

a = list(map(int, list(n)))
a = a[::-1]
a.append(0)
for i in range(len(a) - 1):
    c = a[i]
    if c < 5:
        ans += c
    else:
        if c == 5 and a[i+1] < 5:
            ans += 5
        else:
            a[i+1] += 1
            ans += 10 - c
ans += a[-1]

print(ans)
# Judge status: Accepted
x,y,z,w = input()

l = []
l.append(x)
l.append(y)
l.append(z)
l.append(w)
new_l = sorted(l)

if new_l[0] == new_l[1] and new_l[1] != new_l[2] and new_l[2] == new_l[3]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = sorted(input())
t = sorted(input())
t_reverse = t[::-1]
if s < t_reverse:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
aiueo = ['a', 'i', 'u', 'e', 'o']

if input() in aiueo:
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
l = []
x = 0
s = sum(a)
for i in range(n-1):
    x+=a[i]
    l.append(abs(x*2-s))
print(min(l))
# Judge status: Accepted
W, H, x, y = map(int, input().split())

z = 0
if x == W / 2 and y == H / 2:
    z = 1
print(W * H / 2, z)
# Judge status: Accepted
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = LS2()

a,b = 0,0
left = []
for i in range(N):
    if S[i] == '(':
        a += 1
    else:
        b += 1
    if a < b:
        a,b = 0,0
        left.append('(')

ANS = left + S + [')']*(a-b)

print(''.join(ANS))
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
nn = int(n/2)
p.sort()
ans = p[nn] - p[nn-1]

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = int(input())

if N%500 <= A:
    print('Yse')
else:
    print('No')
# Judge status: Accepted
N, M = map(int, input().split())
divisors = sorted(sum((list({n, M // n}) for n in range(1, int(M ** 0.5) + 1) if not M % n), []), reverse=True)

for d in divisors:
    if M // d >= N:
        print(d)
        break
# Judge status: Accepted
from operator import itemgetter

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
#print(ab)
i = 0
ans = 0
while m >0:
  if ab[i][1]<=m:
    m -= ab[i][1]
    ans += ab[i][0]*ab[i][1]
  else:
    ans += ab[i][0]*m
    m = 0
  i+=1
print(ans)
# Judge status: Accepted
s=input()
ans=[]
for i in range(len(s)):
  if s[i]=='0':
    ans.append('0')
  elif s[i]=='1':
    ans.append('1')
  else:
    if ans:
      ans.pop()
print(''.join(ans))
# Judge status: Accepted
k, a, b = map(int, input().split())

max_change = max(0, (k - (a - 1)) // 2)
print(max(k+1, 1+k-max_change*2 + (b-a)*max_change))
# Judge status: Accepted
c = str(input())
al = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(al)):
    if c == al[i]:
        print(al[i+1])
# Judge status: Accepted
a, b, c, d = map(int, input().split())

n = [a*c, a*d, b*c, b*d]
print(max(n))
# Judge status: Accepted
n = int(input())
row = list(map(int, input().split()))
m = row[0]
count = 0
for i in range(n):
  if row[i] <= m:
    m = row[i]
    count += 1
print(count)
# Judge status: Accepted
s = [x for x in input()]
t = [x for x in input()]
s.sort()
t.sort(reverse=True)
s, t = "".join(s), "".join(t)
ans = "No"
m = min(len(s), len(t))
for i in range(m):
    if s[i] < t[i]:
        ans = "Yes"
        break
if ans == "No" and s[:m] == t[:m] and len(s) < len(t): ans = "Yes"
print(ans)
# Judge status: Accepted
L = int(input())

# 普通に立方体が一番大きい
print(pow(L/3,3))
# Judge status: Accepted
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]
for i in range(3):
    if set(A[i]) <= set(b):
        print("Yes")
        exit()
    if set([A[0][i], A[1][i], A[2][i]]) <= set(b):
        print("Yes")
        exit()
if set([A[0][0], A[1][1], A[2][2]]) <= set(b) or set([A[0][2], A[1][1], A[2][0]]) <= set(b):
    print("Yes")
    exit()
print("No")
# Judge status: Wrong Answer
N,K = map(int,input().split())
x = sorted(list(int(i) for i in input().split()))
ans = 10**5
for i in range(N-K+1):
  left =x[i]
  right =x[i+K-1]
  p1 = abs(left) + abs(right-left)
  p2 = abs(right) + abs(right-left)
  p = min(p1,p2)
  ans = min(ans,p)
  
print(ans)
# Judge status: Accepted
from collections import Counter

s = input()
t = input()

a = Counter(s)
b = Counter(t)

c = list(a.values())
d = list(b.values())

print('Yes') if c == d else print('No')
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(N):
    if i % 2 != 0:
        alice += a[i]
        continue
    bob += a[i]
print(bob - alice)
# Judge status: Accepted
a,b=map(int,input().split())
s=input().split("-")
print("Yes" if len(s)==2 and len(s[0])==a and len(s[1])==b else "No")
# Judge status: Accepted
N = int(input())

N = -N

if N == 0:
  print(0)
  exit()
  
t = []
while N != 0:
  s = N % -2
  if s == 0:
    t.append(0)
  else:
    t.append(1)
    
  N //= -2
  
t = list(reversed(t))
print(''.join(map(str, t)))
# Judge status: Accepted
n = int(input())
s = ""
while n != 0:
    r = n % (-2)
    if r < 0:
        r += 2
    s += str(r)
    n = int((n - r) / (-2))
if s != "":
    print(s[::-1])
else:
    print(0)
# Judge status: Accepted
def main() -> None:
    N, M = map(int, input().split())
    cards = [(x, 1) for x in map(int, input().split())]
    for _ in range(M):
        b, c = map(int, input().split())
        cards.append((c, b))
    cards.sort(reverse=True)
    res, ans_sum = N, 0
    for x, num in cards:
        if res <= num:
            ans_sum += res * x
            break
        ans_sum += num * x
        res -= num
    print(ans_sum)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
A = [int(input()) for i in range(5)]
Aa = [i for i in A if i % 10 == 0]
Ab = [i for i in A if not i % 10 == 0]
Ab = sorted(Ab, key=lambda x : (x) % 10, reverse=True)
#print(Aa, Ab)

total = 0
for i in range(len(Aa)):
  total += math.ceil(Aa[i] / 10) * 10
  #print(total)
for i in range(len(Ab)):
  if i +1 == len(Ab):
  	total += Ab[i]
  else:
  	total += math.ceil(Ab[i] / 10) * 10
  #print(total)
  
print(total)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

r = max(0, min((a + b),(c + d)) - c)
print(r)
# Judge status: Accepted
a,b,x=map(int, input().split())
if a <= x and x <= a+b:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
n,k = map(int,input().split())
s = input()
edge,inside,cnt,ix = 0,0,0,0
if s[0]=='R' or s[-1]=='R':
  edge += 1
temp = ''
#print(ix)
s += 'L'
for i in range(n+1):
  if i!=n:
    if temp=='R' and s[i]=='L':
      inside += 1
    elif temp==s[i]:
      cnt += 1
  temp = s[i]
#print(inside,cnt,edge)
if inside>=k:
  print(k*2+cnt)
else:
  print(inside*2+edge+cnt)
# Judge status: Accepted
a,b,c = map(int,input().split())

if (10*b+c)%4 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
a, b = map(int, input().split())

if a<=9 and b<=9:
	print(a*b)
else:
	print(-1)
# Judge status: Wrong Answer
import numpy as np

# = int(input())
# = str(input())
N, K = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

first = np.asarray(A[:K])
score = np.prod(first)

for i in range(K, N):
    nextscore = score * A[i] //A[i-K]
    if nextscore <= score:
        print("No")
    else:
        print("Yes")
    score = nextscore
# Judge status: Wrong Answer
#https://atcoder.jp/contests/abc174/tasks/abc174_a

N= []
N= int(input(" "))

if N>=30:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N = int(input())
H = list(map(int,input().split()))

cnt = 0
ans = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
        ans =max(cnt,ans)
    else:
        cnt = 0
        
print(cnt)
# Judge status: Accepted
import sys


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


def resolve():
    s1, s2, t1, t2 = map(int, input().split())
    l = []
    yoko = t1 - s1
    tate = t2 - s2
    a,c,f,h='R','L','L','R'
    b,d,e,g='U','D','D','U'
    l.append(a*yoko+b*tate+c*yoko+d*tate)
    l.append(e+a*(yoko+1)+b*(tate+1)+f)
    l.append(g+c*(yoko+1)+d*(tate+1)+h)
    print(''.join(l))
resolve()
# Judge status: Accepted
N = int(input())
for i in range(1,10):
    for j in range(1,10):
        ij = i * j
        if(N == i*j):
            print("Yes")
            exit(0)
print("No")
# Judge status: Wrong Answer
n = int(input())
ans = (n-1)*n/2

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

if A + B != 0 and (A + B) % 3 == 0:
	print("Yes")
else:
	print("No")
# Judge status: Wrong Answer
import math
N, M = map(int,input().split())
b = 0
P = [1]
for k in range(2,math.floor(math.sqrt(M))+1):
    if M % k == 0:
        P.append(k)
        P.append(M//k)
P = sorted(P)
for e in P:
    if e >= N:
        print(M//e)
        exit(0)
# Judge status: Wrong Answer
import sys
n = int(sys.stdin.readline().strip('\n'))
h = list(map(int, sys.stdin.readline().strip('\n').split()))
dp = [float('inf') for _ in range(n)]
dp[0] = 0
for i in range(n-2):
  # 配るdp
  if i+1<=n-1: dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1]))
  if i+2<=n-1: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2])) 
print(dp[n-1])
# Judge status: Wrong Answer
S=input()
Q=int(input())
l=list(input().split() for i in range(Q))
for j in l:
  if j[0]=="1":
    S=S[::-1]
  else:
    if j[1]=="1":
      S=S+j[2]
    else:
      S=j[2]+S

print(S)
# Judge status: Accepted
N = int(input())
A = tuple(map(int, input().split()))
limit = sum(A)
alive = 1
total = 0
for a in A:
    alive -= a
    limit -= a
    if alive < 0:
        print(-1)
        break
    total += alive + a
    alive = min(alive * 2, limit)
else:
    print(total)
# Judge status: Accepted
import collections

n = int(input())

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

c = collections.Counter(a)
total = 0
for i in c:
    total += c[i]*(c[i]-1)//2


for i in range(n):
    target = c[a[i]]
    print(total - target*(target-1)//2 + (target-1)*(target-2)//2)
# Judge status: Wrong Answer
A,B,C,K = map(int,input().split())
for i in range(min(K, 100000)):
    A,B,C = B+C,C+A,A+B
    if A - B > 10**18:
        print("Unfair")
        exit()
print(A-B)
# Judge status: Accepted
n=int(input())
s=input()
b=s.count('#')
w=s.count('.')
B=0
ans=w
for i in range(n):
    if s[i]=='#':
        B+=1
    W=n-(i+1)-(b-B)
    ans=min(ans,B+W)
print(ans)
# Judge status: Wrong Answer
import math
a,b = map(int,input().split())
i = 0
while i < math.log(b,a):
  i += 1
print(i)
# Judge status: Wrong Answer
#!/usr/bin/env python3

n, m = list(map(int, input().split()))

ans = 1
num = int(m**0.5)+1

for i in range(1, num):
    if m % i != 0:
        continue
    j = m//i
    # if i >= n:
    #     ans = max(ans, j)
    if j >= n:
        ans = max(ans, i)
print(ans)
# Judge status: Accepted
d = int(input())
 
if d == 25:
  print('Christmas')
elif d == 24:
  print('Christmas Eve')
elif d == 23:
  print('Christmas Eve Eve')
else:
  print('Christmas Eve Eve Eve')
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
print(['B', 'A'][abs(x-a)> abs(x-b)])
# Judge status: Wrong Answer
N, K = [int(x) for x in input().split()]
D = input().split()

for payment in range(N, 10000):
    if all(char not in D for char in str(payment)):
        print(payment)
        break
# Judge status: Accepted
n, m, k = map(int, input().split())
s = set()
for i in range(n + 1):
    s.add(i * m)
for i in range(m + 1):
    s.add(i * n)
for i in range(1, n):
    for j in range(1, m):
        s.add(i * j + (n - i) * (m - j))
if k in s:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import sys

if __name__ == "__main__":
    N, M, K = [int(x) for x in input().split(" ")]
    for x in range(0, N + 1):
        for y in range(x, M + 1):
            if x * M + (y - x) * N == K:
                print("Yes")
                sys.exit(0)
    print("No")
# Judge status: Wrong Answer
a=input()
if(int(a) > 0):
	s=str(a)
	if(s[-1] in ('2','4','5','7','9')):
		print('hon')
	elif(s[-1] in ('0','1','6','8')):
		print('pon')
	elif(s[-1] == '3'):
		print('bonn')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
sum_a = sum(a)
result = 0
for i in range(n):
  result += a[i] * (sum_a - a[i])
print((result)//2 %(10**9+7))
# Judge status: Accepted
n = int(input())

for x in range(1,n+1):
    if n==int(x*1.08):
        print(x)
        exit()
print(":(")
# Judge status: Accepted
#高橋君の夏休みは N 日間です。
#夏休みの宿題が M 個出されており
#i 番目の宿題をやるには Ai 日間かかります。
#夏休み中に全ての宿題を終わらせるぉとができないときは、かわりに '-1' を出力

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

if sum(A) > N:
    print(-1)
else:
    print(N-sum(A))
# Judge status: Accepted
N = int(input())
B = [int(i) for i in input().split(" ")]
B.append(10**5+1)
Sum = B[0]

for i in range(N-1):
    Sum += B[i]
    if B[i+1]<B[i]:
        Sum = Sum -B[i] + B[i+1]
print(Sum)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    q,h,s,d=map(int,input().split())
    n=int(input())
    weight=[(0.25,q,q/0.25),(0.5,h,h/0.5),(1,s,s),(2,d,d/2)]
    weight.sort(key=itemgetter(2))
    cost=0
    for w in weight:
        kosu=n//w[0]
        cost+=int(w[1]*kosu)
        n-=w[0]*kosu
        print(w[1],kosu)
    print(cost)
if __name__=='__main__':
    main()
# Judge status: Wrong Answer
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*n
a.sort()
amin = a[n-1]-a[0]
for i in range(n):
  if a[i] < k/2:
    b[i] = a[i] + k
  else:
    b[i] = a[i]
b.sort()
bmin = b[n-1]-b[0]

print(min(amin,bmin))
# Judge status: Accepted
N,K=map(int,input().split())
A=list(map(int,input().split()))

ans=1
X=N-K

while X>0:
  X-=K-1
  ans+=1
print(ans)
# Judge status: Accepted
N=int(input())
X=list(map(int,input().split()))
ans=float('inf')
for i in range(1,100):
  cnt=0
  for j in range(N):
    cnt+=(X[j]-i)**2
  if ans>cnt:
    ans=cnt
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
ans = [0]*M

for _ in range(N):
  K, *A = map(int, input().split())
  for x in A:
    ans[x-1] += 1

print(sum([1 for i in ans if i == N]))
# Judge status: Accepted
s=[0 for i in range(60)]
def totwo(x):
  return [int(x&(2**i)>0) for i in range(60)]

n=int(input())
a=list(map(lambda x:totwo(int(x)),input().split()))

d=[a[0][i] for i in range(60)]
for i in range(1,n):
  for j in range(60):
    if a[i][j]:
      s[j]+=i-d[j]
    else:
      s[j]+=d[j]
    d[j]+=a[i][j]

ss=0
r=1
mod=10**9+7
for i in range(60):
  ss=(ss+r*s[i])%mod
  r=(r*2)%mod
print(ss)
# Judge status: Accepted
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())
h = int(input())

print(int((a + b) * h / 2))
# Judge status: Accepted
n,k = map(int, input().split())
l = list(map(int, input().split()))

# 期待値:マス目の総和／マス目の数, マス目の最大値+最小値[1]／2
l = [(i+1)/2 for i in l] # 期待値に変換

# 累積和を取得
from itertools import accumulate
cum = [0] + list(accumulate(l))

# 差分を考慮しつつ k個の和をリストする → 最大値が ans
sum_k = []
for j in range(n-k+1):
    sum_k.append(cum[k+j] - cum[j])

print(max(sum_k))
# Judge status: Accepted
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(-1, -N - 1, -1):
  a, b = AB[i]
  m = (a + ans) % b
  if m != 0:
    ans += b - m

print(ans)
# Judge status: Wrong Answer
n=int(input())
for i in range(1,26):
	for j in range(1,26):
		if n == 4*i+7*j:
			print('Yes')
			exit(0)
print('No')
# Judge status: Wrong Answer
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

cnt=0
for i in range(n):
    for j in range(i+1,n):
        sum=0
        for k in range(d):
            sum += (x[i][k]-x[j][k])**2
        route = sum**0.5
        if route.is_integer:
            cnt += 1

print(cnt)
# Judge status: Wrong Answer
tupni = [int(idx) for idx in input().split(" ")]
if tupni.sort() == [5,5,7]:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
x, a, b = map(int,input().split())
 
if x > abs(b - a):
  print("safe")
elif x < abs(b - a):
  print("dangerous")
else:
  print("delicious")
# Judge status: Accepted
n,*i=map(int,open(0).read().split())
p=0
for l in range(n):
    a,b=i[-2-2*l:2*n-2*l]
    g=b-(a+p)%b if (a+p)%b!=0 else 0
    p+=g
print(p)
# Judge status: Accepted
x, y = map(int, input().split())
mul = x
ans = 1
for i in range(10 ** 18):
    if mul*2 > y:
        break
    else:
        mul *= 2
        ans += 1
print(ans)
# Judge status: Wrong Answer
import numpy as np
n, k = map(int, input().split())
array = list(map(int, input().split()))
array = np.array(array)
Array = np.array([0]*n)
print(array)
print(Array)
def plusone(n):
    return n + 1

for j in range(k):
    for i in range(n):
        ai = array[i]
        Array[max(i-ai, 0):min(i+ai+1,n+1)] = Array[max(i-ai, 0):min(i+ai+1,n+1)] + 1
        if j == k - 1:
            answer = Array
    array = Array
    Array = np.array([0]*n)

print(' '.join(map(str, answer)))
# Judge status: Accepted
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
inf = 10**10
parent = [inf]*n
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent[i] = a
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break