Harryxun/stf_run huggingface dataset:
s=input()
k=int(input())

ss=""
for i in range(k):
	ss+=s

count=0

i=0
while i<len(ss):
	if ss[i]!=ss[i+1]:
		i+=1
	else:
		i+=2
		count+=1
print(count)

### FIXED CODE ###

#O(2n)程度を見込む解答
s=input()
k=int(input())
ss=s+s
n=len(s)

ppp=1
for i in range(n-1):
	if s[i]!=s[i+1]:
		ppp=0
		break
		
if ppp==1:
	print(n*k//2)
else:		
	counts=0
	i=0
	while i<n-1:
		if s[i]!=s[i+1]:
			i+=1
		else:
			i+=2
			counts+=1
			
	countss=0
	i=0
	while i<n*2-1:
		if ss[i]!=ss[i+1]:
			i+=1
		else:
			i+=2
			countss+=1
			
	if countss==counts*2:
		print(counts*k)
	else:
		print(counts*k+k-1)
s = input()
t = input()

c=1
j=0
k=0

flag = 0

#t
for i in range(0,len(t)):
  print("i",i)
  flag = 0
  while True:
    print("j",j) 
    if t[i:i+1]==s[j:j+1]:
      J=J+1
      flag = 1
      k=0
      break
    else:
      if j==len(s):
        j=0
      else:
        j=j+1
        k=k+1
        c=c+1
        if k+1==len(s):
          print("-1")
          exit()
        else:
          j=j+1
          k=k+1
          c=c+1
print(c)

### FIXED CODE ###

s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)
A, B, K = map(int, input().split())
res = 0
cnt = 0

for i in range(1, min(A, B)+1):
	if A % i == 0 and B % i == 0:
        cnt += 1
    if cnt == K:
	    res = i
        break
print(res)


### FIXED CODE ###

A, B, K = map(int, input().split())
res = 0
cnt = 0
 
for i in range(min(A, B), 0, -1):
  if A % i == 0 and B % i == 0:
    cnt += 1
  if cnt == K:
    res = i
    break
print(res)
import math
N,K = map(int,input().split())
ans = 0

for n in range(1,min(K,N+1)):
    ans += 2**(20-math.ceil(math.log2(K/n)))

ans /= 2**20

ans += max(N-K+1,0)
ans /= N

print(ans)

### FIXED CODE ###

import math
N,K = map(int,input().split())
ans = 0

for n in range(1,min(K,N+1)):
    ans += 2**(20-math.ceil(math.log2(K/n)))

ans /= 2**20

ans += max(N-K+1,0)
ans /= N

print(ans)
n,m = map(int,input().split())
a = [-1]
flag = True

if m>0:
  for i in range(m):
    a.append(int(input()))
    if i>0 and a[i+1]==a[i]+1:
      flag = False
    break
  if not flag:
    print(0)
  
  a.append(n+1)
  step = [a[i+1]-a[i]-1 for i in range(m+1)]
  onestep = [1,1]
  if max(step)>=3:
    for i in range(3,max(step)+1):
      onestep.append(onestep[-2]+onestep[-1])
  
  ans = 1
  for i in range(m+1):
    ans *= onestep[step[i]-1]
  if flag:
    print(ans%1000000007)
else:
  onestep=[1,1]
  for i in range(2,n+1):
    onestep.append(onestep[-2]+onestep[-1])
  print(onestep[-1])



### FIXED CODE ###

n,m = map(int,input().split())
a = [-1]
flag = True
 
if m>0:
  for i in range(m):
    a.append(int(input()))
    if a[i+1]==a[i]+1:
      flag = False
      break
  if not flag:
    print(0)
  else:
    a.append(n+1)
    step = [a[i+1]-a[i]-1 for i in range(m+1)]
    onestep = [1,1]
    if max(step)>=3:
      for i in range(3,max(step)+1):
        onestep.append(onestep[-2]+onestep[-1])
  
    ans = 1
    for i in range(m+1):
      ans *= onestep[step[i]-1]
    print(ans%1000000007)
else:
  onestep=[1,1]
  if n==1:
    print(1)
  else:
    for i in range(2,n+1):
      onestep.append(onestep[-2]+onestep[-1])
    print(onestep[-1]%1000000007)
N,M = map(int,input().split())
dic = {}
for _ in range(N):
  a, b = map(int,input().split())
  if a in dic:
    dic[a] += b
  else:
    dic[a] = b
List = sorted(dic)
ans = 0
i = 0
while M >= 0:
  M -= dic[List[i]]
  ans = List[i]
  i += 1
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
dic = {}
for _ in range(N):
  a, b = map(int,input().split())
  if a in dic:
    dic[a] += b
  else:
    dic[a] = b
List = sorted(dic)
ans = 0
i = 0
while M > 0:
  M -= dic[List[i]]
  ans = List[i]
  i += 1
print(ans)
N, M = [int(i) for i in input().split(" ")]
p = list()
y = list()
yd = {}
for i in range(0, M):
    pi, yi = [int(i) for i in input().split(" ")]
    p.append(pi)
    y.append(yi)
    if pi in yd.keys():
        yd[pi].append(yi)
    else:
        yd[pi] = [yi]

ydid = {}
for i in yd.keys():
    num = 1
    for j in sorted(yd[p[i]]):
        ydid[j] = num
        num = num + 1

for i in range(0, M):
    print("{:06}{:06}".format(p[i], ydid[y[i]]))


### FIXED CODE ###

N, M = [int(i) for i in input().split(" ")]
p = list()
y = list()
yd = {}
for i in range(0, M):
    pi, yi = [int(i) for i in input().split(" ")]
    p.append(pi)
    y.append(yi)
    if pi in yd.keys():
        yd[pi].append(yi)
    else:
        yd[pi] = [yi]

ydid = {}
for i in yd.keys():
    num = 1
    for j in sorted(yd[i]):
        ydid[j] = num
        num = num + 1

for i in range(0, M):
    print("{:06}{:06}".format(p[i], ydid[y[i]]))
N,P = map(int,input().split())
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

M = prime_decomposition(P)
            
c = Counter(M)
temp = [i[0] for i in c.items() if i[1] >= N]
if temp == []:
  temp.append(1)
print(int(reduce(lambda x,y:x*y,temp)))

### FIXED CODE ###

N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break
k = int(input())
a, b = map(int,input().split())

if b//k == a//k:
  if a % k == 0:
    print("OK")
    else:
      print("NG")
else:
  print("OK")


### FIXED CODE ###

K = int(input())
A, B = map(int,input().split())
 
 
if A // K == B // K:
    if A % K ==0:
        print('OK')
    else:
        print('NG')  
else:
    print('OK')
def cal_cnt(num):
  cnt = 0
  for bit in format(num, 'b'):
    if bit == '1':
      cnt += 1

  return cnt


def main():
  n = int(input())
  src = input()
  base = int(src, 2)
  base_cnt = 0
  for bit in src:
    if bit == '1':
      base_cnt += 1

  basep = base % (base_cnt + 1)
  basem = base % (base_cnt - 1)

  memo = tuple(map(cal_cnt, range(n)))

  dp = [None] * n
  dp[0] = 0

  def f(num, cnt):
    if num < n and dp[num] is not None:
      return dp[num]

    nxt = num % cnt
    res = 1 + f(nxt, memo[nxt])
    if num < n:
      dp[num] = res

    return res


  for i in range(n - 1, -1, -1):
    num = None

    if src[n - i - 1] == '0':
      mod = base_cnt + 1
      num = ((basep + pow(2, i, mod)) % mod)
    else:
      mod = base_cnt - 1
      num = ((basem - pow(2, i, mod)) % mod)

    print(1 + f(num, memo[num]))


main()


### FIXED CODE ###


def f(n):
  cnt = 0
  while n:
      cnt += 1
      n = n % bin(n).count('1')

  return cnt

def main():
  n = int(input())
  src = input()
  base = int(src, 2)
  base_cnt = src.count('1')

  basep = base % (base_cnt + 1)
  basem = base % (base_cnt - 1) if base_cnt > 1 else 0

  for i, s in enumerate(src):
    i = n - 1 - i
    num = None

    if s == '0':
      mod = base_cnt + 1
      num = (basep + pow(2, i, mod)) % mod
    elif base_cnt > 1:
      mod = base_cnt - 1
      num = (basem - pow(2, i, mod)) % mod
    else:
      print(0)
      continue

    print(1 + f(num))


main()
L = int(input().split())

ans = (L/3)**3
print(ans)

### FIXED CODE ###

L = int(input())

ans = (L/3)**3
print(ans)
import math
n = int(input())

if n == 1:
    print(1)
    exit()

if n % 2 != 0:
    n -= 1

h = math.log2(n)
h = math.floor(h)
print(2**(h+1)-1)

### FIXED CODE ###

import math
n = int(input())

if n == 1:
    print(1)
    exit()

# if n % 2 != 0:
#     n -= 1

h = math.log2(n)
h = math.floor(h)
print(2**(h+1)-1)
S = input()
k = 0
if S[0] == 'A' and S[3:-1].count('C') == 1:
    for i in range(len(S)):
        if S[i].isupper()
            if k == 2:
                print('WA')
                break
            k += 1
    print('AC')
else:
    print('WA')

### FIXED CODE ###

S = input()
k = 0
if S[0] == 'A' and S[2:-1].count('C') == 1:
    for i in range(len(S)):
        if S[i].isupper():
            if k == 2:
                print('WA')
                exit()
            k += 1
    print('AC')
else:
    print('WA')
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()
L = [LIST() for i in range(M)]
dic = defaultdict(int)

# for a, b in L:
    # dic[A[a]] = b
A.sort()
L = sorted(L, key=lambda x : x[1], reverse=True)
# print(L)
i = 0
# for i, a in enumerate(A):
for f, t in L:
    while f > 0:
        if t > A[i]:
            A[i] = t
            f -= 1
            i += 1
        else:
            print(sum(A))
            exit()
print(sum(A))
    
    

### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
import heapq

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()
L = [LIST() for i in range(M)]
L = sorted(L, key=lambda x : x[1], reverse=True)
default_sum = sum(A)

heapq.heapify(A)  # リストを優先度付きキューへ

for max_cnt, target in L:
    cnt = 0
    while cnt < max_cnt and len(A) != 0:
        min_num = heapq.heappop(A) # pop min
        default_sum += max(target - min_num, 0)
        cnt += 1
    
print(default_sum)



    

exit()
print(heapq.heappop(a))  # 最小値の取り出し

heapq.heappush(a, -2)  # 要素の挿入
print(a)
for i in range(M):
    a = heapq.heappop(A) * (-1)
    a = a // 2
    heapq.heappush(A, -a)
A = list(map(lambda x: x * (-1), A))
print(sum(A))
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin
from itertools import *
from fractions import Fraction
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())

a,b=mp()
if a>b:
    if gcd(a,b)==1:
    	print a
	elif a%b==0:
		print -1
	else:
		print a
else:
	if gcd(a,b)==1:
    	print b
	elif b%a==0:
		print -1
	else:
		print b

### FIXED CODE ###

from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin
from itertools import *
from fractions import Fraction
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())
 
 
a,b=mp()
if a>=b:
    if a%b==0:
    	print -1
    else:
    	print a
else:
	if 0:
		print -1
	else:
		print a
a, b, c = input().split()
if a + b + c >= 21:
  print("win")
else:
  print("bust")

### FIXED CODE ###

a = map(int, input().split())
if sum(list(a)) <= 21:
  print("win")
else:
  print("bust")
from collections import deque

H, W = map(int, input().split())
for _ in range(H):
    temp = list(map(int, input().split()))
    a = [t % 2 for t in temp]
    A.append(a)

operations = []

for i in range(H):
    y = i + 1
    if i % 2 == 0:
        for j in range(W):
            x = j + 1
            if A[i][j] == 1:
                if x != W:
                    operations.append((y, x, y, x+1))
                    A[i][j+1] = (A[i][j+1] + 1) % 2
                elif y != H:
                    operations.append((y, x, y+1, x))
                    A[i+1][j] = (A[i+1][j] + 1) % 2
    else:
        for j in reversed(range(W)):
            x = j + 1
            if A[i][j] == 1:
                if x != 1:
                    operations.append((y, x, y, x-1))
                    A[i][j-1] = (A[i][j-1] + 1) % 2
                elif y != H:
                    operations.append((y, x, y+1, x))
                    A[i+1][j] = (A[i+1][j] + 1) % 2

N = len(operations)
print(N)
if N != 0:
    for op in operations:
        print(*op, sep=' ')
    

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
A = []
for _ in range(H):
    temp = list(map(int, input().split()))
    a = [t % 2 for t in temp]
    A.append(a)

operations = []

for i in range(H):
    y = i + 1
    if i % 2 == 0:
        for j in range(W):
            x = j + 1
            if A[i][j] == 1:
                if x != W:
                    operations.append((y, x, y, x+1))
                    A[i][j+1] = (A[i][j+1] + 1) % 2
                elif y != H:
                    operations.append((y, x, y+1, x))
                    A[i+1][j] = (A[i+1][j] + 1) % 2
    else:
        for j in reversed(range(W)):
            x = j + 1
            if A[i][j] == 1:
                if x != 1:
                    operations.append((y, x, y, x-1))
                    A[i][j-1] = (A[i][j-1] + 1) % 2
                elif y != H:
                    operations.append((y, x, y+1, x))
                    A[i+1][j] = (A[i+1][j] + 1) % 2

N = len(operations)
print(N)
if N != 0:
    for op in operations:
        print(*op, sep=' ')
while True:
  a = map(int,raw_input().split())
  print a[0]+a[1]

### FIXED CODE ###

while True:
 try:
  a = map(int,raw_input().split())
  print a[0]+a[1]
 except EOFError:
   break
s = input()
n = int(input())

cnt = 0
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    s[i+1] = "1"
    cnt += 1
print(cnt*n)

### FIXED CODE ###

S = list(input())
K = int(input())
l = len(S)

if len(set(S)) == 1:
    print(l*K//2)
    exit()
else:
    ans = 0
    tmp = ""
    count = [1]
    for i in range(l-1):
        if S[i] == S[i+1]:
            count[-1] += 1
        else:
            count.append(1)
    
    for i in count:
        ans += i//2*K

    if S[0] == S[-1] and count[0]%2 == count[-1]%2:
        ans += K-1

    print(ans)
a,b = map(int,input().split())
if a*b<=0:
    print(Zero)
elif a<0 and (b-a)%2==0:
    print(Positive)
else:
    print(Negative)

### FIXED CODE ###

a,b = map(int,input().split())
if a*b<=0:
    print("Zero")
elif a<0 and (b-a)%2==0:
    print("Negative")
else:
    print("Positive")
#151c
n,w=map(int,input().split())
ac=0
wa=[0]*w
wa_cnt=0
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] +=wa_cnt
			wa_cnt=0
		else:
			wa_cnt+=1

wa_ans=0
for i in range(n):
	wa_ans+=wa[i]

print(ac,wa_ans)

### FIXED CODE ###

#151c
n,w=map(int,input().split())
ac=0
wa=[0]*n
wa_cnt=[0]*n
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] =wa_cnt[p]
			#wa_cnt=0
		else:
			wa_cnt[p]+=1

wa_ans=0
for i in range(n):
	wa_ans+=wa[i]

print(ac,wa_ans)
N,M=map(int,input().split())
n=int(N)
m=int(M)
numlist=[0,0,0]
access_log=[0,0,0]
answer=0
for i in range(m):
  s,c=map(int,input().split())
  s=int(s)
  c=int(c)
  if access_log[s]==1 and numlist[s]!=c:
    answer=-1
    break
  else:
    numlist[s]=c
    access_log[s]=1
if answer==-1:
  print(answer)
else:
  answer=numlist[2]*10**2+numlist[1]*10+numlist[0]
  if answer==0:
    print(-1)
  else:
    print(answer)

### FIXED CODE ###

N,M=map(int,input().split())
n=int(N)
m=int(M)
numlist=[]
loglist=[]
for i in range(n):
  numlist.append(0)
  loglist.append(0)
answer=0

for i in range(m):
  s,c=map(int,input().split())
  s=int(s)
  c=int(c)
  if s==1 and c==0 and n!=1:
    answer=-1
  elif loglist[s-1]!=0 and numlist[s-1]!=c:
    answer=-1
  else:
    numlist[s-1]=c
    loglist[s-1]=1

if answer==-1:
  print(answer)
elif n==1 and numlist[0]==0:
  print(0)
else:
  if numlist[0]==0:
    numlist[0]=1
  else:
    pass
  for i in range(n):
    answer+=numlist[i]*10**(n-i-1)
  print(answer)
num=(int)(input())
n=num//100
amari=num%100
if amari / n > 6:
  print(0)
else:
  print(1)

### FIXED CODE ###

num=(int)(input())
n=num//100
amari=num%100
if num <= 99 or amari / n > 5:
  print(0)
else:
  print(1)
#coding:utf-8

n,k = map(int,input().split())
ls = list(map(int,input().split()))

# n, k = 5, 3
# ls = [-30,-10,10,20,50]

# n,k = 3,2
# ls=[10,20,30]

# n,k = 1,1
# ls = [0]

# n,k=8,5
# ls=[-9,-7,-4,-3,1,2,3,4]

def set_max(ls):
    try:
        return set([max(ls)])
    except:
        return set()
def set_min(ls):
    try:
        return set([min(ls)])
    except:
        return set()


plus = list(filter(lambda n:n>=0, ls))
minus = list(filter(lambda n:n<=0, ls))

neighbor = set_max(minus) | set_min(plus)

print (neighbor)
answer = []
for i in range(n-k+1):
    if len(set(ls[i:i+k])&neighbor)>0:
        print (ls[i:i+k])
        temp = [0,ls[i],ls[i+k-1]]
        temp = [abs(min(temp)),abs(max(temp))]
        answer.append((2*min(temp)+max(temp)))
print (min(answer))

# first = -1
# for i,point in enumerate(ls):
#     if point >= 0:
#         first = i
#         break
# size=k+1
# ans = []
# for i in range(size):
#     if first-size+i+1>=0 and first+i-1< len(ls):
#         temp = [0,ls[first-size+i+1],ls[first+i-1]]
#         temp = [abs(min(temp)),abs(max(temp))]
#         ans.append((2*min(temp)+max(temp)))
# print (min(ans))


### FIXED CODE ###

#coding:utf-8
import numpy as np
n,k = map(int,input().split())
ls = list(map(int,input().split()))

# n, k = 5, 3
# ls = [-30,-10,10,20,50]
#
# n,k = 3,2
# ls=[10,20,30]

# n,k = 1,1
# ls = [0]

# n,k=8,5
# ls=[-9,-7,-4,-3,1,2,3,4]
if not (0 in ls):
    ls.append(0)
    k+=1
#print (ls)

ls = np.array(ls)
ls.sort()
#print (ls)

idx = np.where(ls==0)[0][0]
#print (idx,k)
#print (idx+k)
start = max(0,idx-k)
goal = min(idx+k,len(ls)-1)

#print (start,goal)
answer = []
for i in range(goal-(k-1)+1):
    #print (i,i+k-1)
    mi = min(abs(ls[i]),abs(ls[i+k-1]))
    ma = max(abs(ls[i]),abs(ls[i+k-1]))
    #print (mi,ma)
    answer.append(2*mi+ma)
print (min(answer))
# def set_max(ls):
#     if len(ls)>0:
#         return set([max(ls)])
#     else:
#         return set()
# def set_min(ls):
#     if len(ls)>0:
#         return set([min(ls)])
#     else:
#         return set()
#
#
# plus = list(filter(lambda n:n>=0, ls))
# minus = list(filter(lambda n:n<=0, ls))
#
# neighbor = set_max(minus) | set_min(plus)
#
# #print (neighbor)
# answer = []
# cnt = 0
# for i in range(n-k+1):
#     if len(set(ls[i:i+k])&neighbor)>0:
#
#         #print (ls[i:i+k])
#         #print (np.sign(ls[i]*ls[i+k-1]))
#         temp = [abs(ls[i]),abs(ls[i+k-1])]
#         if np.sign(ls[i]*ls[i+k-1])<0:
#
#             answer.append(2*min(temp)+max(temp))
#         else:
#             answer.append(max(temp))
#         cnt += 1
#         if cnt == k + 1:
#             break
# print (min(answer))

# first = -1
# for i,point in enumerate(ls):
#     if point >= 0:
#         first = i
#         break
# size=k+1
# ans = []
# for i in range(size):
#     if first-size+i+1>=0 and first+i-1< len(ls):
#         temp = [0,ls[first-size+i+1],ls[first+i-1]]
#         temp = [abs(min(temp)),abs(max(temp))]
#         ans.append((2*min(temp)+max(temp)))
# print (min(ans))
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(M)]
C = [0 for i in range(M)]
for i in range(M):
B[i],C[i] = map(int, input().split())
import bisect
import deque

for i in range(M):
  A = deque(sorted(A))
  lm = A.bisect_right(A, C[i]-1)
  A[:min(B[i],lm)] = C[i]

print(sum(A))


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [[] for _ in range(M)]
for i in range(M):
  BC[i] = list(map(int, input().split()))

BC.sort(key=lambda x: x[1], reverse=True)

for i in BC:
  A.extend([i[1]]*i[0])
  if len(A) > 2*N:
    break
    
A = sorted(A,reverse=True)
print(sum(A[:N]))
n = input()
if n[-1] in "24579":
    print("hon")
elif n[-1] in "0168":
    print("pon")
else :
    pinnt("bon")

### FIXED CODE ###

n = input()
if n[-1] in "24579":
    print("hon")
if n[-1] in "0168":
    print("pon")
if n[-1] in "3":
    print("bon")
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)
m = []
for i in range(n):
    m.append(m, a[i+1] - a[i])
print(k - max(m))

### FIXED CODE ###

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

a.append(a[0] + k)
m = 0
s = 0
for i in range(n):
    m = max(m, a[i+1] - a[i])
    s += a[i+1] - a[i]
print(s - m)
numTest = int(input())

value = numTest % 10

if value == 2 or value == 4 or value == 5 or value == 7 or value == 9 :
	print('hon')
elif value == 0 or value == 1 or value == 6 or value == 8 :
	print('pon')
elif value == 3 :
	print(bon)

### FIXED CODE ###

numTest = int(input())

value = numTest % 10

if value == 2 or value == 4 or value == 5 or value == 7 or value == 9 :
	print('hon')
elif value == 0 or value == 1 or value == 6 or value == 8 :
	print('pon')
elif value == 3 :
	print('bon')
n,m = map(int,input().split())
ss = [1]*n
for i in range(0,m):
    ss[int(input())-1] = 0
if ss[n-3] != 0:
    ss[n-3] = ss[n-2]+ ss[n-1]
for i in range(n-4,-1,-1):
    if ss[i] == 0:
        continue
    ss[i] = ss[i+1] + ss[i+2]
print((ss[0]+ss[1])%(10**9+7))

### FIXED CODE ###

n,m = map(int,input().split())
ss = [1]*n
for i in range(0,m):
    ss[int(input())-1] = 0
if n == 0:
    print(0)
elif n == 1:
    print(1)
elif n == 2:
    if ss[0] == 0:
        print(1)
    else:
        print(2)
else:
    if ss[n-3] != 0:
        ss[n-3] = ss[n-2]+ ss[n-1]
    for i in range(n-4,-1,-1):
        if ss[i] == 0:
            continue
        ss[i] = ss[i+1] + ss[i+2]
    print((ss[0]+ss[1])%(10**9+7))
N = int(input())

for i in range(2, N):
    if N%i == 0:
        a = i
        b = N//i
        if a <= 9 and b <= 9:
            break

if N <= 2:
    print("Yes")
elif a <= 9 and b <= 9:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())

for i in range(2, N+1):
    if N%i == 0:
        a = i
        b = N//i
        if a <= 9 and b <= 9:
            break

if N <= 2:
    print("Yes")
elif a <= 9 and b <= 9:
    print("Yes")
else:
    print("No")
a,b=map(int, input().split())
ans=0
f=b//10000
for i in range(f+1):
    for j in range(a-i+1):
        if 10000*i+5000*j+1000*(a-i-j)==b and ans==0:
            z=a-i-j
            print(i,j,z)
            ans+=1
if ans==0:
    print(f'-1 -1 -1')

### FIXED CODE ###

a,b=map(int, input().split())
ans=0
for i in range(a+1):
    for j in range(a-i+1):
        z=a-i-j
        if 10000*i+5000*j+1000*z==b and ans==0:
            print(i,j,z)
            ans+=1
if ans==0:
    print(-1,-1,-1)
N=int(input())
a=list (map(int,input().split()))
abs_list=[]
for b in range(-max(a),max(a)):
	c=0
	for i in range(N):
		c=abs(a[i]-(b+i+1))+c	
	abs_list.append(c)	
print(abs_list)	
print(min(abs_list))	

### FIXED CODE ###

N=int(input())
if N%2==0:
	print(N)
else:
	print	(2*N)
print(int(input())-int(input()))

### FIXED CODE ###

x,t=map(int,input().split());print(max(x-t,0))