peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,m,c= map(int,input().split())
cnt=0
for i in range(n,m+1):
    if i %c==0:
        cnt+=1
print(cnt)
# Judge status: Wrong Answer
A, B, C, D = input()
op = ["+", "-"]

for i in op:
    for j in op:
        for k in op:
            ans = A + i + B + j + C + k + D
            if eval(ans) == 7:
                break
print(ans + "=7")
# Judge status: Wrong Answer
s = sorted(input())
t = sorted(input(),reverse=True)
flag = -1
i = 0



while(i < min(len(s),len(t))):
  if s[i] > t[i]:
    flag = -1
    break
  elif s[i] < t[i]:
    flag = 1
    break
  else:
    if len(s[i]) == 1:
      flag = 1
      break
    i += 1

if flag == 1: print("Yes")
else: print("No")
# Judge status: Accepted
N, *A = map(int, open(0).read().split())

s = sum(A)

ans = 1
cur = 1
for a in A:
    s -= a

    cur = min(2 * (cur - a), s)
    if cur < 0:
        print(-1)
        quit()

    ans += cur

print(ans)
# Judge status: Wrong Answer
import collections
N = int(input())
A = [int(x) for x in input().split()]
c = collections.Counter(A)
cc = {k:v for k, v in c.items() if v>1}
ccc = list(cc.keys())[-2:]
if len(ccc)==2:
    print(ccc[0] * ccc[1])
else:
    print(0)
# Judge status: Accepted
s = str(input())
n = len(s)+1
a = [0]*n
a_2 = [0]*n
tmp = 1
ems = list(enumerate(s))
for i,c in ems:
    if c == "<":
        a[i+1] = tmp
        tmp += 1
    else:
        tmp = 1

for i,c in reversed(ems):
    if c == ">":
        a[i] = max(a[i],tmp)
        tmp += 1
    else:
        tmp = 1

print(sum(a))
# Judge status: Accepted
# Problem A - Range Product

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

# calc
if (a==0 or b==0) or (a<0 and b>0) or (a>0 and b<0):
    print("Zero")
elif a>0 and b>0:
    print("Positive")
elif a<0 and b<0:
    nums = abs(b - a) + 1
    if nums%2==1:
        print("Negative")
    else:
        print("Positive")
# Judge status: Accepted
def resolve():
    l=list(map(int, input().split()))
    l.sort(reverse=True)
    if l[0]==l[1]+l[2]:
        print('Yes')
    else:
        print('No')
resolve()
# Judge status: Wrong Answer
print("win" if sum(list(map(int,input().split())))<21 else "bust")
# Judge status: Accepted
# -*- coding: utf-8 -*-

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict

a = int(input())
ans = a+a**2+a**3
print(ans)
# Judge status: Accepted
n = input()
s = 0
for i in range(len(n)):
    s += int(n[i])
if s % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
S=input()
T=input()

keys=[]
for i in range(2**(len(T))):
    key=''
    for j in range(len(T)):
        if (i>>j)&1:
            key+='?'
        else:
            key+=T[j]
    keys.append(key)
    
res=''
for key in sorted(keys)[::-1]:
    if S.find(key)>-1:
        res=S.replace(key,T,1)
        break
else:
    res='UNRESTORABLE'
    
print(res.replace('?','a'))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
s, l = sum(a), 0
for i in range(n):
  l += a[i]
  if l>= s/2:
    ans = min([abs(l-a[i]-sum(a[i:])),abs(l-sum(a[i+1:]))])
    print(round(ans))
    break
# Judge status: Accepted
x, n = map(int, input().split())

if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    while(1):
        if (x - i) not in p:
            print(x - i)
            break
        if (x + i) not in p:
            print(x + i)
            break
        i += 1
# Judge status: Wrong Answer
# 1.値を正しく取得
a, b, c = (int(x) for x in input().split())

# 2.正しく処理
youki = a - b
nokori = youki-c

print(nokori)
# Judge status: Wrong Answer
s = list(input())

for i in range(len(s)):
  if s[i] == '?':
    if i+1 < len(s) and s[i+1] == 'D':
      s[i] = 'P'
    elif i+1 < len(s) and  s[i+1] == '?':
      s[i] = 'P'
      s[i+1] = 'D'
    else :
      s[i] = 'D'
      
print("".join(s))
# Judge status: Wrong Answer
from collections import Counter

n, k = map(int, input().split())
a = [int(an) for an in input().split()]
ans = 0
set_a = set(a)
num_of_types = len(set_a)
if num_of_types > k:
  cnt = Counter(set_a)
  ans = sum(sorted(cnt.values())[: num_of_types - k])

print(ans)
# Judge status: Accepted
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X, Y = lr()
answer = X + Y // 2
print(answer)
# Judge status: Accepted
N=int(input())
H=list(map(int,input().split()))
if N==1:
  print("Yes")
  exit()
if H[0]<H[1]:
  H[0]-=1
elif H[0]>H[1]:
  print("No")
  exit()
for i in range(1,N):
  if H[i-1]<H[i]:
    H[i]-=1
  elif H[i-1]>H[i]:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
import math
N = input().split()
def main():
    sum = int(N[0] + N[1])

    for i in range(1110):
        if sum == i*i:
            print("Yes")
            return
    print("No")
    return

main()
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
flg=0
for i in range(n):
  if a[i]%2==0:
    if a[i]%3!=0 and a[i]%5!=0:
      flg=1

if flg==0:
  print("APPROVED")
else:
  print("DENIED")
# Judge status: Accepted
# coding: utf-8
# Your code here!

N, K, Q = map(int,input().split())
L = [0]*N
for i in range(Q):
    a = int(input())
    L[a-1] += 1

for i in range(N):
    if Q - L[i] < K:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
N,C,K = map(int,input().split())

T = []

for i in range(N):
    T.append(int(input()))
T.sort()
res = 0
cnt = 0
i = 0

while i < N:
    lim = T[i]+K
    while T[i] <= lim and cnt < C:
        i += 1
        cnt += 1
        if N == i:
            break
    res += 1
    cnt = 0
print(res)
# Judge status: Wrong Answer
N,M = map(int,input().split())
C = sorted([list(map(int,input().split())) for m in range(M)])
n = 1

for m in range(M-1):
  if C[m][0]==C[m+1][0]:
    C[m]+=[n]
    n+=1
  else:
    C[m]+=[n]
    n = 1

C[-1]+=[n]

for m in range(M):
  print("{:06d}{:06d}".format(C[m][0],C[m][2]))
# Judge status: Wrong Answer
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
dict = {"r":p, "s":r, "p":s}
val = 0
mae = ""

for i in range(len(t)):
  if i <= k or t[i-k] != t[i]:
    val += dict[t[i]]

print(val)
# Judge status: Accepted
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

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

def main():
    N, M = map(int, input().split())
    counter = Counter()
    for _ in range(N):
        K, *A = map(int, input().split())
        counter += Counter(A)
    print(sum(1 for c in counter.values() if c == N))

main()
# Judge status: Accepted
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n= ii()
a= li()

ans=1
a.sort()
a.reverse()

if a[-1] == 0:
    print(0)
    exit()

for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
    elif a[i] == 0:
        print(0)
        exit()
print(ans)
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()

mod = 1000000007
X,Y = map(int, input().split())


def combination(n, r, mod):
    r = min(r, n-r)

    numer = 1
    denom = 1

    for i in range(r):
        numer = numer * (n-i) % mod
        denom = denom * (r-i) % mod

    return numer * pow(denom, mod-2, mod) % mod

m_n = (X+Y) // 3
m = X - m_n
n = Y - m_n

if X+Y % 3 != 0 or m < 0 or n < 0:
    print(0)
    exit()

print(combination(m_n, m, mod))
# Judge status: Accepted
import bisect
 
N=int(input())
b1=0
d=0

ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B, reverse=True)
C=list(map(int, input().split()))
C=sorted(C)
D=[]
E=[]

for b in B:
  d=d+len(C)-bisect.bisect_right(C,b)
  D.append(d)

D=sorted(D, reverse= True)  
B=sorted(B)

for a in A:
  if 0 <= bisect.bisect_right(B,a) <= len(D)-1:
    ans += D[bisect.bisect_right(B,a)]
print(ans)
# Judge status: Wrong Answer
n, m = list(map(int, input().split()))

if m >= 2*n:
    print(n + (m - 2*n)//4)
else:
    print(0)
# Judge status: Accepted
n,h=map(int,input().split())
AB = [list(map(int, input().split())) for i  in range(n)]
AB = sorted(AB, key=lambda x:x[1])
ans = 0

a = sorted(AB)[-1][0]
for i in range(len(AB)):
  if len(AB) <= 0 or h <= 0:
    break
  b = AB.pop(-1)[1]
  h -= b if b > a else a
  ans += 1

if h > 0:
  ans += (h+a-1)//a

print(ans)
# Judge status: Wrong Answer
s = list(str(input()))
q = int(input())
for i in range (q):
    t = list(str(input()))
    if t[0] == '1':
        s.reverse()
    elif t[0] == '2':
        if t[2] == '1':
            s.append(t[4])
        elif t[2] == '2':
            s.reverse()
            s.append(t[4])
            s.reverse()
s.reverse()
print(''.join(s))
# Judge status: Accepted
# coding: utf-8
S = set(input())
i = {'N', 'S'}
j = {'W', 'E'}
k = {'N', 'S', 'W', 'E'}
if S == i or S == j or S == k:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,m = map(int, input().split())
print(int((n+m)*(n+m-1)-n*m))
# Judge status: Wrong Answer
import numpy as np
a = input().split(" ")
if(a[0]>a[1]):print("safe")
else:print("unsafe")
# Judge status: Accepted
r = int(input())
x = r ** 2
print(x)
# Judge status: Accepted
a =  list(map(int, input().split()))
if sum(a)-max(a) == max(a):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
#C - Count Order
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
l = list(range(1,N+1))
count = 0
ans_p = 0
ans_q = 0
for i in permutations(l):
    count += 1
#    print(i)
#    print(P)
    if i == P:
        ans_p = count
    elif i == Q:
        ans_q = count
    else:
        pass
#print(ans_p,ans_q)
print(abs(ans_p - ans_q))
# Judge status: Accepted
from math import ceil


def main():
    n = int(input())

    min_value = n * 100 / 108
    max_value = (n + 1) * 100 / 108

    candidate = ceil(min_value)

    if candidate < max_value:
        print(candidate)
    else:
        print(":(")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
S=input()
k=0
if S[0]=='A':
    k=100
if k==100:
    for i in range(2,len(S)):
        if S[i]=='C':
            k=i
            break
if 'a'<=(S[1:k] and S[k+1:])<='z':
    print('AC')
    exit()
if k==100:
    print('WA')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
remainder_a = a - b
remainder_c = c - remainder_a
print(remainder_c)
# Judge status: Accepted
nums = list(map(int, input().split()))
nums.sort(reverse=True)
ans = nums[0] * 10 + sum(nums[1:])
print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
if(n==2)or(m==2):
  print(0)
elif(n==1)or(m==1):
  if(n==1)and(m==1):
    print(1)
  else:
    print(max(0,max(n,m)-2))
else:
  print((n-2)*(m-1))
# Judge status: Accepted
#!python3

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


def main():
    if N == 1 and M == 1:
        ans = 1
    elif N == 1 or M == 1:
        ans = max(N, M) - 2
    else:
        ans = (N - 2) * (M - 2)
    
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))

import heapq

heapq.heapify(A)

for _ in range(M):
    tmp = heapq.heappop(A) * (-1) // 2
    heapq.heappush(A, tmp*(-1))

ans = 0
for i in range(N):
    ans += heapq.heappop(A)

print(-ans)
# Judge status: Accepted
s, t = input().split()

print(t+s)
# Judge status: Accepted
N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
ans = 0
for i in range(1,N+1):
    cnt = sum(A[0][:i])+sum(A[1][i-1:])
    ans = max(ans,cnt)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

allenemy = sum(A)
for i in range(N):
    A[i] -= B[i]
    if A[i] < 0:
        A[i+1] += A[i]
        A[i] = 0
        if A[i+1] < 0:
            A[i+1] = 0
print(allenemy - sum(A))
# Judge status: Accepted
n,k=[int(x) for x in input().split()]
infy=float('inf')
arr=[int(x) for x in input().split()]

val=[infy]*(n)
val[0]=0
for i in range(0,n-1):
    for j in range(1,k+1):
        if i+j < n:
            val[i+j]=min(val[i+j],abs(arr[i+j]-arr[i])+val[i])


print(val[n-1])
# Judge status: Accepted
a,b,c = map(int,input().split())
print("YES" if (100*a+10*b+c)%4==0 else "NO")
# Judge status: Accepted
A,B,C,D = map(int, input().split())
while A>0 and C>0:
    C-=B
    A-=D
if C<=0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, P = readnums()
A = map(lambda x: x % 2, readnums())

if P:
    if not sum(A):
        print(0)
    else:
        print(2 ** N // 2)
else:
    if not sum(A):
        print(2 ** N)
    else:
        print(2 ** N // 2)
# Judge status: Wrong Answer
K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    flg = False
    for j in range(K+1):
        if flg == True:
            break
        for k in range(K+1):
            ijk_sum = i + j + k
            if ijk_sum == S:
                flg = True
                cnt += (K+1 - j)
                break
print(cnt)
# Judge status: Wrong Answer
c1=input()
c2=input()
c2_rev=c2[::-1]
if c1==c2_rev:
    print("YES")
else:
    print("No")
# Judge status: Accepted
n=input()
l=len(n)
if n==n[0]+'9'*(l-1):
  print(int(n[0])+9*(l-1))
else:
  print(9*(l-1)+int(n[0])-1)
# Judge status: Wrong Answer
n=int(input())
x=7
s=1
while s<n:
    if x%n==0:
        break
    else:
        x=int(str(x)+"7")
        s+=1
print(s)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
x=[i for i in a if i%4==0]
b=[i for i in a if i%4!=0 and i%2==0]
if len(x)+len(b)//2>=n//2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
s = input()

rb = s.count(')')
lb = s.count('(')

r=0
l=0
ll = 0
rr = 0
for c in s:
  if c =='(' :
    l += 1
  else:
    if l > 0:
      ll += 1
    l -= 1
    if l < 0:
      l = 0          
      
for c in s[::-1]:
  if c ==')' :
    r += 1
  else:
    if r > 0:
      rr += 1
    r -= 1
    if r < 0:
      r = 0
      
print('('*(rb - rr) + s + ')'*(lb - ll))
# Judge status: Wrong Answer
n,K = map(int,input().split())
p = min(n,K-1)
ans = 0
chk = [1]*(K-1)
k = K
for i in range(14):
  k /= 2
  for i in range(int(k*2-k-0.0000000000000000001)):
    chk[i] += 1
  if k <= 1:
    break
    
#print(chk)
for i in range(p):
  ans += float(1/(2**chk[i]*n))
  #print(ans)
ans += max(0,(n-K+1)/n)
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def ok(n):
	print(n)
	exit(0)

def main():
	#N = int(input())
	#S = input().rstrip()
	X,Y = map(int,input().split())
	
	res = 0
	if X==Y:
		ok(res)
	if X>Y:
		res += 1
		X = -X
	res += abs(abs(Y)-abs(X))
	if X*Y<0:
		res += 1
	
	print(res)
	
main()
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))
S = sum(W)
ans = float('inf')


for index in range(1, N+1):
    ans = min(ans, abs(S - 2* sum(W[:index])))
print(ans)
# Judge status: Accepted
import sys
input= lambda: sys.stdin.readline().rstrip()
#cythonを使うために実行
#%load_ext Cython
#%%code
def resolve():
    N=int(input())
    ans=0
    for i in range(1,N*2):
        ans+=i
        if ans >= N:
            stop=i+1
            j=ans-N
            break
    for k in range(1,stop):
        if k!=j:print(k)
        
#%%submit!
resolve()
# Judge status: Accepted
N, A, B = map(int, input().split())
ans = N//(A+B) * A
if N%(A+B) < A:
    ans += N%(A+B)
else:
    ans += A
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
for i in range(a+1):
    for j in range(b+1):
        if (a-i)*b+(b-j)*a==c:
            print('Yes')
            exit()
print('No')
# Judge status: Wrong Answer
import sys
n=int(input())
a=list(map(int,input().split()))
for i in a:
  if i%2==0:
    if i%3!=0 or i%5!=0:
      print("DENIED")
      sys.exit()

print("APPROVED")
# Judge status: Accepted
s = input() + '*'

ans = 0
before_s = s[0]
i = 1

while i < len(s):
    if s[i] == before_s:
        # print('hi',before_s, s[i:i+2])
        before_s = s[i:i+2]
        ans += 1
        i += 2
    else:
        # print(i, before_s, s[i])
        before_s = s[i]
        ans += 1
        i += 1

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

if 13<=a:
  p=int(b)
  print(p)
if 6<=a<=12:
  p=int(b//2)
  print(p)
if a<=5:
  print('0')
# Judge status: Accepted
N, D = map(int, input().split())
num = [input().split() for _ in range(N)]
 
X = []
Y = []
count = 0
 
for n in num:
    X.append(int(n[0]))
    Y.append(int(n[1]))
 
for x, y in  zip(X, Y):
    dist = x**2 + y**2
    if dist <= D**2:
        count += 1
 
print(count)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
a,b=map(int,input().split())
cnt=0
for i in range(1,a+1):
    for j in range(1,b+1):
        if i==j:
            cnt+=1
print(cnt)
# Judge status: Wrong Answer
def binary_search2(func, n_min, n_max):
    left,right=n_min,n_max
    y_left, y_right = func(left), func(right)
    while True:
        middle = (left+right)//2
        y_middle = func(middle)
        if y_left==y_middle: left=middle
        else: right=middle
        if right-left==1:break

    return left
  
def f(x):
  return sum([A[i]//x for i in range(N)])<=K

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

print(binary_search2(f, 1, max(A)+5)+1)
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
candidates = [i for i in range((A+B+C)%3*2+(A+B+C),150,6)]
for i in candidates:
    x = i/3
    if A<= x and B<= x and C<=x and ((x-A)+(x-B)+(x-C))%2==0:
        print(int((i-(A+B+C))/2))
        break
# Judge status: Accepted
n,k=map(int,input().split())
r,s,p = map(int,input().split())
t=input()

def score(c):
	if c=="r":
		return p
	elif c=="s":
		return r
	else:
		return s

isUsed = [False]*n
ans = 0
for i in range(n):
	if i < k:
		ans+=score(t[i])
		isUsed[i]=True
	else:
		if t[i] == t[i-k] and isUsed[i-k]:
			continue
		ans+=score(t[i])
		isUsed[i]=True

print(ans)
# Judge status: Accepted
#!/usr/bin/python3
#coding: utf-8

N, H = (int(x) for x in input().split())

A = []
B = []
for i in range(N):
    a, b = (int(x) for x in input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)

ret = 0
AMax=A[0]
for b in B:
    if b < AMax or H <= 0:
        break
    H -= b
    ret += 1

if (H > 0):
    ret += H // AMax
    if H % AMax != 0:
        ret += 1
print(ret)
# Judge status: Accepted
n = int(input())
L = [list(map(int,input().split())), list(map(int,input().split()))]
ans = 0

for i in range(n):
  cnt = 0
  for j in range(n):
    if j < i: 
      cnt += L[0][j]
    elif j == i:
      cnt += L[0][j] + L[1][j]
    else:
      cnt += L[1][j]
  ans = max(ans,cnt)

print(ans)
# Judge status: Accepted
s=input()
cnt=[0]*3
for i in range(len(s)):
    if s[i]=="a":
        cnt[0]+=1
    elif s[i]=="b":
        cnt[1]+=1
    else:
        cnt[2]+=1
m=min(cnt)
for i in range(3):
    cnt[i]-=m
if max(cnt)<=1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())))
ai=a[-1]
aa=ai/2
ans=float("inf")
for i in range(n-1):
    tmp=abs(a[i]-aa)
    if tmp<ans:
        ans=tmp
        aj=a[i]
print(ai,aj)
# Judge status: Accepted
(n, k) = list(map(int, input().split()))
snk = set(range(1, n + 1))
items = []
for i in range(k):
    d = int(input())
    for a in list(map(int, input().split())):
        if a in snk:
            snk.remove(a)
print(len(list(snk)))
# Judge status: Accepted
x = int(input())
cnt = x//100

if 100*cnt <= x <= 105*cnt:
    print(1)
else:
    print(0)
# Judge status: Accepted
from functools import reduce
from fractions import gcd

def lcm(a, b):
  return a * b // gcd(a, b)

n = int(input())
print(reduce(lcm, [int(input()) for i in range(n)]))
# Judge status: Accepted
from collections import Counter
 
def factorize(N):
    p = 2
    PRIME = []
    while p * p <= N:
        if N % p == 0:
            N //= p
            PRIME.append(p)
        else:
            p += 1
    if N > 1:
        PRIME.append(N)
    return Counter(PRIME)
 
n = int(input())
 
prime = factorize(n)
ans=0
for i in prime:
  for j in range(1,prime[i]+1):
    if n % i**j==0:
      n//=i**j
      ans+=1
print(ans)
# Judge status: Accepted
from itertools import compress

import numpy as np

N, M, X = [int(x) for x in input().split()]
CA = np.array([[int(x) for x in input().split()] for _ in range(N)])

minimal_cost = None
for bought_book in range(1, 2**N):
    bought_book = [int(b) for b in ("{:0" + str(N) + "b}").format(bought_book)]

    CA_filtered = np.array(list(compress(CA, bought_book)))

    total_cost = sum(CA_filtered[:, 0])
    total_understanding = np.sum(CA_filtered[:, 1:], axis=0) >= X
    if np.all(total_understanding):
        minimal_cost = min(minimal_cost or total_cost, total_cost)

print(minimal_cost if minimal_cost is not None else "-1")
# Judge status: Accepted
h,n=map(int,input().split())
dp=[10**9]*(h+1)
dp[0]=0
for i in range(n):
    a,b=map(int,input().split())
    for j in range(h):
        k=min(j+a,h)
        dp[k]=min(dp[k],dp[j]+b)
print(dp[h])
# Judge status: Accepted
s = int(input());print(10**9,1*(s<10**18),10**9-s%10**9,s//10**9+1*(s<10**18),0,0)
# Judge status: Accepted
#n=int(input())
n,m=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])

l.sort(key=lambda x: x[0])
count=0;cost=0
for i in range(n):
    a,b=l[i][0],l[i][1]
    if count+b>=m:
        cost+=a*(m-count)
        break
    else:
        cost+=a*b
        count+=b
print(cost)
# Judge status: Wrong Answer
S = input()
S = S[::-1]
leng = len(S)
S = int(S)

count = [0] * 2019
count[0] = 1

for i in range(leng):
    remainder = (S // (10**i)) % 2019

res = 0
for cnt in count:
    res += cnt * (cnt - 1) // 2
    
res
# Judge status: Wrong Answer
n = int(input())
ans = [0] * 10001
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x < n:
                ans[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1

for i in range(1, n + 1):
    print(ans[i])
# Judge status: Wrong Answer
a,b,k =map(int ,input().split())
n =[]
for i in range(1 ,100):
    if a %i ==0 and b %i ==0:
        n.append(i)
n.sort(reverse =True)
print(n[k-1])
print(n)
# Judge status: Wrong Answer
import sys

n,k = list(map(int, input().split(" ")))
l = list(map(int, input().split(" ")))
l = [999999]*k + l
print(l)
dp= [0]*(n+k)

for i in range( k + 1, n+k):
	dp[i] = min([ dp[i - j] + abs(l[i] - l[i - j]) for j in range(1, k + 1) ])

print(dp[n + k - 1])
# Judge status: Wrong Answer
from math import ceil

N, K = map(int, input().split())
ll = list(map(int, input().split()))

idx = ll.index(1)

l, r = idx, N-idx
print(l, r)
print(ceil((l)/(K-1))+ ceil((r-1)/(K-1)))
# Judge status: Accepted
n, a, b = map(int, input().split())
ans = []

for i in range (n+1):
    i_10000 = i//10000
    i_1000 = i%10000//1000
    i_100 = i%1000//100
    i_10 = i%100//10
    i_1 = i%10
    i_sum = i_10000 + i_1000 + i_100 + i_10 + i_1
    if a<=i_sum<=b:
        ans.append(i)

print(sum(ans))
# Judge status: Accepted
s = list(input())
a = int(s.index("A"))
del s[:a]

list_z = [i for i, x in enumerate(s) if x =="Z"]
z = max(list_z)
del s[len(s):z:-1]
print(len(s))
# Judge status: Accepted
import heapq

N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(A)

for _ in range(M):
  v = heapq.heappop(A) * (-1)
  heapq.heappush(A, -(v >> 1))

print(-sum(A))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    s=input()
    cunt=0
    for i in range(n-1):
        if s[i]!=s[i+1]:
            cunt+=1
    print(n-1-cunt+min(2*k,cunt))

if __name__=='__main__':
    main()