Harryxun/stf_run huggingface dataset:
A, B = map(str, input().split())
 
B = str(int(float(B)*100) + 0.0001)
 
#print(B)
ans = []
p = [[]for k in range(len(B))]
for k in range(len(B)):
    for j in range(k):
        p[k].append(0)
for k in range(1, len(B)+1):
    a = 0
    for j in range(1, len(A)+1):
        if a > 9:
            a = int(str(a)[0]) + int(B[-k])*int(A[-j])
        else:
            a = int(B[-k])*int(A[-j])
        #print(a)
 
        p[k-1].append(int(str(a)[-1]))
        if j == len(A) and a >9:
            p[k-1].append(int(str(a)[0]))
 
for k in range(len(B)):
    for j in range(len(p[-1]) - len(p[k])):
        p[k].append(0)
 
#print(p)
a = 0
for k in range(len(p[0])): 
    if int(a) > 9: 
        a = int(str(a)[0])
    else:
        a =0
    for j in range(len(p)):
        a += p[j][k]
    ans.append(str(a)[-1])
 
#print(ans)
op = ""
for k in range(1, len(ans)-1):
    op += ans[-k]
if len(ans)<3:
    print("0")
else:
    print(op)

### FIXED CODE ###

A, B = map(str, input().split())
 
B = str(int(float(B)*100+0.00001))
 
#print(B)
ans = []
p = [[]for k in range(len(B))]
for k in range(len(B)):
    for j in range(k):
        p[k].append(0)
for k in range(1, len(B)+1):
    a = 0
    for j in range(1, len(A)+1):
        if a > 9:
            a = int(str(a)[0]) + int(B[-k])*int(A[-j])
        else:
            a = int(B[-k])*int(A[-j])
        #print(a)
 
        p[k-1].append(int(str(a)[-1]))
        if j == len(A) and a >9:
            p[k-1].append(int(str(a)[0]))
 
for k in range(len(B)):
    for j in range(len(p[-1]) - len(p[k])):
        p[k].append(0)
 
#print(p)
a = 0
for k in range(len(p[0])): 
    if int(a) > 9: 
        a = int(str(a)[0])
    else:
        a =0
    for j in range(len(p)):
        a += p[j][k]
    ans.append(str(a)[-1])
    if k ==  len(p[0])-1 and a >9:
        ans.append(str(a)[0])

 
#print(ans)
op = ""
for k in range(1, len(ans)-1):
    op += ans[-k]
if len(ans)<3 or int(op) < 1:
    print("0")
else:
    print(op)
import sys

import numpy as np

s = raw_input()
x, y = [int(x) for x in raw_input().split(" ")]

s = s + "T"

a = []
b = []

cum_len = 0
turn = 0
for command in s:
    if command == "F":
        cum_len += 1
    elif command == "T":
        (a if turn == 0 else b).append(cum_len)
        turn ^= 1
        cum_len = 0

a0 = a.pop(0)

alpha = abs(x-a0)
beta = abs(y)

targetX = sum(a) - alpha
targetY = sum(b) - beta

def search(a, target):
    forwardTable = np.zeros((len(a), target+1))
    forwardTable[:,0] = 1
    for i_i in xrange(len(a)):
        new_item = a[i_i]
        if i_i == 0:
            forwardTable[i_i, new_item] = 1
            forwardTable[i_i, 2*new_item:2*new_item+1] = 1
        else:
            forwardTable[i_i] += forwardTable[i_i-1]
            if new_item>0:
                forwardTable[i_i,new_item:] += forwardTable[i_i-1,:-new_item]
                forwardTable[i_i,2*new_item:] += forwardTable[i_i-1,:-2*new_item]
        if forwardTable[i_i,-1] > 0:
            forwardTable[-1,-1] = 1
            break

    return (forwardTable[-1,-1]>0)

if (targetX < 0) or (targetY < 0):
    print "No"
    sys.exit()
else:
    if (targetX > 0):
        if not search(a, targetX):
            print "No"
            sys.exit()
    if (targetY > 0):
        if not search(b, targetY):
            print "No"
            sys.exit()
    print "Yes"

### FIXED CODE ###

import sys

import numpy as np

s = raw_input()
x, y = [int(x) for x in raw_input().split(" ")]

s = s + "T"

a = []
b = []

cum_len = 0
turn = 0
for command in s:
    if command == "F":
        cum_len += 1
    elif command == "T":
        (a if turn == 0 else b).append(cum_len)
        turn ^= 1
        cum_len = 0

a0 = a.pop(0)

alpha = abs(x-a0)
beta = abs(y)

targetX = sum(a) - alpha
targetY = sum(b) - beta

def search(a, target):
    forwardTable = np.zeros((len(a), target+1))
    forwardTable[:,0] = 1
    for i_i in xrange(len(a)):
        new_item = a[i_i]
        if i_i == 0:
            forwardTable[i_i, 2*new_item:2*new_item+1] = 1
        else:
            forwardTable[i_i] += forwardTable[i_i-1]
            if new_item>0:
                forwardTable[i_i,2*new_item:] += forwardTable[i_i-1,:-2*new_item]
        if forwardTable[i_i,-1] > 0:
            forwardTable[-1,-1] = 1
            break

    return (forwardTable[-1,-1]>0)

if (targetX < 0) or (targetY < 0):
    print "No"
    sys.exit()
else:
    if (targetX > 0):
        if not search(a, targetX):
            print "No"
            sys.exit()
    if (targetY > 0):
        if not search(b, targetY):
            print "No"
            sys.exit()
    print "Yes"
N = int(input())
a = [int(num) for num in input().split()]
print(str(max(a)-min(a))

### FIXED CODE ###

N = int(input())
a = [int(num) for num in input().split()]
print(str(max(a)-min(a)))
a=input()
b=input()

if a+b>9 :
    print('error')
else :
    print(a+b)


### FIXED CODE ###


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

s=a+b


if s>=10 :
    print("error")
else :
    print(s)
n = int(input())
    p_list = list(map(int, input().split()))
    count = 0
    for i in range(len(p_list)-2):
    	if (p_list[i]<p_list[i+1] and p_list[i+1]<p_list[i+2]) or (p_list[i]>p_list[i+1] and p_list[i+1]>p_list[i+2]):
    		count += 1
    print(count)

### FIXED CODE ###

n = int(input())
p_list = list(map(int, input().split()))
count = 0
for i in range(len(p_list)-2):
	if (p_list[i]<p_list[i+1] and p_list[i+1]<p_list[i+2]) or (p_list[i]>p_list[i+1] and p_list[i+1]>p_list[i+2]):
		count += 1
print(count)
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)

# 各数字に必要なマッチの本数
num  = [0,2,5,5,4,5,6,3,7,6]
# dp : i本のマッチで実現できる最大の桁数
dp = [-1*float("inf")]*(N+1)
# dp初期化 (0本では0桁, 各数字を1つ作る場合は1桁)
dp[0] = 0
for a in A:
    if num[a] <= N:
        dp[num[a]] = 1

for i in range(1,N+1):
    for a in A:
        if i - num[a] >= 0:
            dp[i] = max(dp[i], dp[i-num[a]] + 1)

ans = ""
for i in range(dp[N]):
    for a in A:
        if dp[N-num[a]] == dp[N]-1  and  N-num[a] >= 0:
            ans += str(a)
            N -= num[a]
            break

print(ans)

### FIXED CODE ###

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

A.sort(reverse=True)

# 各数字に必要なマッチの本数
num  = [0,2,5,5,4,5,6,3,7,6]
# dp : i本のマッチで実現できる最大の桁数
dp = [-1*float("inf")]*(N+1000)
# dp初期化 (0本では0桁, 各数字を1つ作る場合は1桁)
dp[0] = 0
for a in A:
    dp[num[a]] = 1

for i in range(1,N+1):
    for a in A:
        if i - num[a] >= 0:
            dp[i] = max(dp[i], dp[i-num[a]] + 1)

ans = ""
for i in range(dp[N]):
    for a in A:
        if dp[N-num[a]] == dp[N]-1  and  N-num[a] >= 0:
            ans += str(a)
            N -= num[a]
            break

print(ans)
a, b, c = map(int, input().split())
d = a + b + c

if a = b:
    print(c)
elif b = c:
    print(a)
elif c = a:
    print(b)

### FIXED CODE ###

a, b, c = map(int, input().split())
d = a + b + c

if a == b:
    print(c)
elif b == c:
    print(a)
elif c == a:
    print(b)
a=int(input())
for x in range(int(a**0.5),0,-1):
	if a%x==0:
    d=int(a//x)
    s=d+x-2
    break
print(s)


### FIXED CODE ###

a=int(input())
for x in range(int(a**0.5),0,-1):
  if a%x==0:
    b=int(a//x)
    break
print(b+x-2)
#!/usr/bin/env python3

import heapq

h,w=map(int,input().split())
sy,sx=map(int,input().split())
sy-=1
sx-=1
gy,gx=map(int,input().split())
gy-=1
gx-=1
board=''
for _ in range(h):
  board+=input()
costs=[10**18]*(w*h)
costs[sy*w+sx]=0
q=[]
heapq.heappush(q,(0,sy,sx))
while len(q)!=0:
  cost,y,x=heapq.heappop(q)
  cur_pos=y*w+x
  for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
    next_pos=cur_pos+dy*w+dx
    if 1<=y+dy<=h and 1<=x+dx<=w and board[next_pos]=='.' and costs[next_pos]>costs[cur_pos]:
      costs[next_pos]=costs[cur_pos]
      heapq.heappush(q,(cost,y+dy,x+dx))
  for dy in range(-2,3):
    for dx in range(-2,3):
      if dy==0 and dx==0:
        continue
      next_pos=cur_pos+dy*w+dx
      if 1<=y+dy<=h and 1<=x+dx<=w and board[next_pos]=='.' and costs[next_pos]>costs[cur_pos]+1:
        costs[next_pos]=costs[cur_pos]+1
        heapq.heappush(q,(cost+1,y+dy,x+dx))
if costs[gy*w+gx]==10**18:
  print(-1)
else:
  print(costs[gy*w+gx])

### FIXED CODE ###

#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
board=[['#']*(w+2)]+[list('#'+input().replace('\n','')+'#') for _ in range(h)]+[['#']*(w+2)]
scores=[[10**18]*(w+2) for _ in range(h+2)]
scores[sy][sx]=0
q=collections.deque()
q.append((sy,sx))
count=0
while len(q)!=0:
  y,x=q.popleft()
  for dx,dy in [[-1,0],[1,0],[0,-1],[0,1]]:
    if 1<=x+dx<=w and 1<=y+dy<=h and board[y+dy][x+dx]!='#' and scores[y+dy][x+dx]>scores[y][x]:
      scores[y+dy][x+dx]=scores[y][x]
      q.appendleft((y+dy,x+dx))
  for dy in range(-2,3):
    for dx in range(-2,3):
      if dx==0 and dy==0:
        continue
      if 1<=x+dx<=w and 1<=y+dy<=h and board[y+dy][x+dx]!='#' and scores[y+dy][x+dx]>scores[y][x]+1:
        scores[y+dy][x+dx]=scores[y][x]+1
        q.append((y+dy,x+dx))
if scores[gy][gx]==10**18:
    print(-1)
else:
    print(scores[gy][gx])
a,b=map(int,input().split())
if a%3==0 or b%3==0: or (a+b)%3==0:
    print ('Possible')
else:
    print('Impossible')

### FIXED CODE ###

a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print ('Possible')
else:
    print('Impossible')
N, K = map(int, input().split())
total = 0
for i in range(N):
  h = int(input())
  if h >= K:
    total += 1
    
print(total)

### FIXED CODE ###

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

total = 0
for height in h:
  if height >= K:
    total += 1
    
print(total)
def solve():
	N, *A = map(int, open(0).read().split())

	top = [A[0]]
	for i in range(1, N):
		da_min = 10**9
		color = -1
		for j in range(len(top)):
			da = A[i] - top[j]
			if da > 0:
				if da_min > da:
					da_min = da
					color = j
		if color != -1:
			top[color] = A[i]
		else:
			top.append(A[i])

	print(len(top))


if __name__ == '__main__':
	solve()

### FIXED CODE ###

r = int(input())
answer = 3 * r ** 2
print(answer)
import sys
import math
sys.setrecursionlimit(1000000)
mod=1000000007
def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: 
        return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p
class Node:
    def __init__(self):
        self.next=[]
    def get_data(self,new_next,weight=1):
        self.next.append(new_next)
def BFS(i,depth,K):  
    depth+=1
    tmp=i
    seki=1
    num=len(tmp)
    if depth==1:
        calc=K-1
        diff=0

        
    else:
        calc=K-2
        diff=1
    #for i in range(calc,calc-(num-diff),-1):
    #    seki*=i%1000000007
    if num-diff>0 and num-diff<calc:
        fac=math.factorial(calc-(num-diff))%mod
        seki*=((math.factorial(calc)%mod)*power_func(fac,mod-2,mod))%mod
    elif num-diff>calc
        seki=0
            
    for each in tmp:
        if not check_node[each]:
            check_node[each]=True
            seki*=BFS(node[each].next,depth,K)%mod
    return seki


N,K=list(map(int,input().split()))
node=[Node() for _ in range(N)]
check_node=[False for _ in range(N)]
check_node[0]=True
for i in range(N-1):
    p,n=list(map(int,input().split()))
    node[n-1].get_data(p-1)
    node[p-1].get_data(n-1)
start=0
d=0

com=K*BFS(node[0].next,d,K)
print(int(com)%mod)

### FIXED CODE ###

import sys
import math
sys.setrecursionlimit(1000000)
mod=1000000007
class Node:
    def __init__(self):
        self.next=[]
    def get_data(self,new_next,weight=1):
        self.next.append(new_next)
def BFS(i,depth,K):  
    depth+=1
    tmp=i
    seki=1
    num=len(tmp)
    if depth==1:
        calc=K-1
        loop=range(calc,calc-num,-1)
        for i in loop:
            seki*=i%1000000007

        
    else:
        calc=K-2
        num-=1
        if calc>=num:
            seki=cache[num]
        else:
            print(0)
            exit()

            
            
    for each in tmp:
        if not check_node[each]:
            check_node[each]=True
            seki*=BFS(node[each].next,depth,K)%mod
    return seki


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

if K>2:
    cache=[0 for i in range(K-2)]
    cache[0]=1
    for i in range(1,K-2):
        cache[i]=cache[i-1]*(K-1-i)%mod
    cache.append(cache[-1])
else:
    cache=[1,1]
node=[Node() for _ in range(N)]
check_node=[False for _ in range(N)]
check_node[0]=True
for i in range(N-1):
    p,n=list(map(int,input().split()))
    node[n-1].get_data(p-1)
    node[p-1].get_data(n-1)
start=0
d=0

com=K*BFS(node[0].next,d,K)
print(int(com)%mod)
print(len(set(input())-1)

### FIXED CODE ###

a = set(input().split())
print(len(a))
n, k = list(map( int , input().split()))
 print( max( 0 , n - 2*k))

### FIXED CODE ###

n, k = list(map( int , input().split()))
print( max( 0 , n - 2*k))
n=input()
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
return (ans/2)%(10**9+7)

### FIXED CODE ###

n=input()
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
print((ans//2)%(10**9+7))
N,Q=input().split()
N=int(N)
Q=int(Q)
s=input()
t=['']*Q
d=['']*Q
for i in range(Q):
    t[i],d[i]=input().split()

    
t.reverse()
d.reverse()

golem=set()
count=set()

for i in range(Q):
    tmp=set()
    
    if d[i]=='R':
        for gtmp in golem-count:
            if gtmp>1 and (gtmp-1 not in golem):
                if s[gtmp-1]==t[i]:
                    tmp.add(gtmp-1)
                    count.add(gtmp)
    else:
        for gtmp in golem-count:
            if gtmp<N-1 and (gtmp+1 not in golem):
                if s[gtmp+1]==t[i]:
                    tmp.add(gtmp+1)
                    count.add(gtmp)

    golem=golem.union(tmp)
    if t[i]==s[0] and d[i]=='L':
        golem.add(0)
    elif t[i]==s[-1] and d[i]=='R':
        golem.add(N-1)

        
print(N-len(golem))

### FIXED CODE ###

A=[int(x) for x in input().split()]

A=sorted(A)

if A[0]==A[1] and A[0]==A[2]:
    print('Yes')
else:
    print('No')
H, W = list(map(int,input().split()))


blank = ["#" for i in range(W + 2)]
print("".join(blank))
for line in range(H):
    print("#" + input() + "#")
print("".join(blank))


### FIXED CODE ###

lis = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x, y = list(map(int,input().split()))

for i in lis:
    if x in i:
        if y in i:
            print("Yes")
        else:
            print("No")
import heapq
N , M = map(int , input().split())
jobs = [list(map(int , input().split())) for _ in range(N)]
jobs.sort()

q = []
index = 0
ans = 0
for limit in range(1 , M + 1):
    while index < N:
        time =jobs[index][0]
        reward = jobs[index][1]
        if limit >= time:
            heapq.heappush(q , -reward)
            index += 1
        else:
            break
    print(q)
    if len(q) != 0:
        tmp = heapq.heappop(q)
        ans -= tmp

print(ans)


### FIXED CODE ###

import heapq
N , M = map(int , input().split())
jobs = [list(map(int , input().split())) for _ in range(N)]
jobs.sort()

q = []
index = 0
ans = 0
for limit in range(1 , M + 1):
    while index < N:
        time =jobs[index][0]
        reward = jobs[index][1]
        if limit >= time:
            heapq.heappush(q , -reward)
            index += 1
        else:
            break
    #print(q)
    if len(q) != 0:
        tmp = heapq.heappop(q)
        ans -= tmp

print(ans)
from collections import deque
S = input()
S = list(S)
counter = 0
que = deque([])
stack = deque([])
for i in range(len(S)):
    que.append(S[i])
for i in range(1000000):
  if stack:
    1
  else:
    stack.append(que.popleft())
  if que:
    s1 = que.popleft()
  else:
    break
  s2 = stack.pop()
  if(s1 != s2):
    counter+=2
  else:
    stack.append(s1)
    stack.append(s2)
print(counter)

### FIXED CODE ###

S =input()
S = list(S)
c_one = S.count('1')
c_zero = S.count('0')
print(min(c_one,c_zero)*2)
N, K = map(int,input().split())
A = list(map(int,input().split()))
B = [0]
S = set([]);S.add(0)
now = 0
Flag = False
loop_start = -1
if K <= 2*pow(10,5)+10:
  for i in range(K):
    nxt = A[now]-1
    B.append(nxt)
    now = nxt
  #print(B)
  print(B[K]+1)
  exit()
for i in range(N*2):
  nxt = A[now]-1
  #print(now,nxt)
  if nxt in S:
    if Flag:
      if nxt == loop_start:
        #print(nxt,i)
        loop_cycle = i-loop_num
        break
    else:
      loop_start = nxt
      loop_num = i
      Flag = True
  else:
    B.append(nxt);S.add(nxt)
  now = nxt
#print(B,loop_start,loop_cycle,loop_num)
loc = (K-loop_start)%loop_cycle+loop_start
#print(loc)
print(B[loc]+1)

### FIXED CODE ###

N , K = map(int,input().split())
 
A = list(map(int,input().split()))
 
reach = [-1 for i in range(N)]
reach[0] = 0 #最初の町は0回でいく
now = 0
#loop = 1
dic ={}
dic[0] = 0
for i in range(N):
  to = A[now]-1
  if reach[to] != -1:
    ini = i+1
    #print(i,to,reach[to])
    loop = i+1 - reach[to]
    break
  if i+1 not in dic:
    dic[i+1] = to
  reach[to] = i+1
  #loop += 1
  now = to
 
 
#print(dic,reach,loop,ini)
if K < ini:
  print(dic[K]+1)
else:
  t = (ini-loop) + (K-ini)%loop
  print(dic[t]+1)
n, m = list(map(int, input().split()))

a = []
b = []

for i in range(n):
    tmp1, tmp2 = list(map(int, input().split()))
    a.append(tmp1)
    b.append(tmp2)

c = []
d = []

for i in range(m):
    tmp1, tmp2 = list(map(int, input().split()))
    c.append(tmp1)
    d.append(tmp2)

for i in range(n):
    tmp = abs(a[n] - c[0]) + abs(b[n] - d[0])
    s = 1
    for j in range(m):
        tmp3 = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if tmp3 < tmp:
            tmp = tmp3
            s = j + 1
    print(s)

### FIXED CODE ###

tmp = input().split()
a, b = int(tmp[0]), int(tmp[1])

s = a + b

if s < 24:
    print(s)
else:
    print(s-24)
from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs

def main(inputs):
	k,n=getIntList(inputs[0])
	aList=getIntList(inputs[1])
	
	d=k-aList[n-1]+aList[0]
	di=n-1
# 	print(d,di)
	for ai in range(n-1):
		dd=aList[ai+1]-aList[ai]
# 		print(dd)
		if dd>d:
			di=ai
			d=dd
	
	print(k-d)


if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)


### FIXED CODE ###

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs

def main(inputs):
	k,n=getIntList(inputs[0])
	aList=getIntList(inputs[1])
	
	d=k-aList[n-1]+aList[0]
	di=n-1
# 	print(d,di)
	for ai in range(n-1):
		dd=aList[ai+1]-aList[ai]
# 		print(dd)
		if dd>d:
			di=ai
			d=dd
	
	print(k-d)


if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

### FIXED CODE ###

import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    if n-k+1-i<0:
        print(0)
    else:
        print(comb(n-k+1,i)*comb(k-1,i-1)%mod)
from functools import reduce

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

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

def lcm(n):
  return reduce(lcm_base, n)

f = 0
m = lcm(a) - 1
for i in a:
  f += m % i

print(int(f))

### FIXED CODE ###

n = int(input())
print(sum(list(map(int, input().split()))) - n)
from heapq import*
n,m,*t=map(int,open(0).read().split())
k=max(t)
d=[[]for _ in range(k+1)]
for a,b in zip(t[::2],t[1::2]):d[a]+=b,
q=[]
for i,b in enumerate(d[::-1]):
    i=k-i
    for b in sorted(b)[::-1][:m-i+1]:
        if len(q)<=m-i:heappush(q,b)
        else:
            if q[0]<b:heappushpop(q,b)
print(sum(q))

### FIXED CODE ###

from collections import*
from heapq import*
n,m,*t=map(int,open(0).read().split())
d=defaultdict(list)
for a,b in zip(t[::2],t[1::2]):d[a].append(b)
q=[]
for i in sorted(d.keys())[::-1]:
    for b in sorted(d[i])[::-1][:m-i+1]:
        if len(q)<=m-i:heappush(q,b)
        elif q and q[0]<b:heappushpop(q,b)
print(sum(q))
n = int(input())
a = list(map(int, input()))
count =0
for i in range(0, n, 2):
    if a[i] % 2 ==1:
        count+=1
print(count)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
count =0
for i in range(0, n, 2):
    if a[i] % 2 ==1:
        count+=1
print(count)
S = input()
T = input()

t = len(T)
ans = "UNRESTORABLE"

answers = []

for index, s in enumerate(S):
  if index + t > len(S):
    break

  if s != '?' and s != T[0]:
    continue

  for a in range(1, t):
    if S[index+a] != '?' and S[index+a] != T[a]:
      break

  else:
    ans = S[0:index] + T + S[index+t:-1]
    answers.append(ans.replace('?', 'a'))

answers.sort()  
print(answers[0])

### FIXED CODE ###

S = input()
T = input()

ans = []

for index, s in enumerate(S):
  if s == '?' or s == T[0]:
    if index+len(T)-1 > len(S)-1:
        break

    for indexs, t in enumerate(T):
      if S[index+indexs] != t and S[index+indexs] != '?':
        break
    else:
      ans.append(S[0:index]+T+S[index+len(T):])


if len(ans) == 0:
  print("UNRESTORABLE")
else:
  ans.sort()
  print(ans[0].replace('?', 'a'))
import math

N=int(input())
cnt=0
num=0
for j in range(1,N+2,2):
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
    cnt=0
#    print("---")
print(num)

### FIXED CODE ###

A,B=map(int,input().split())
print((A-1)*(B-1))
N = int(input())
txys = [list(map(int, input().split())) for _ in range(N) ]
txys.insert(0, [0, 0, 0])
 
for i in range(N):
    dt = txys[i+1][0] - txys[i][0]
    dist = abs(txys[i][1] - txys[i+1][1]) + abs(txys[i][2] - txys[i+1][2])
    if dt % 2 != dist % 2 or dist > dt:
        print("No")
        exit()
print("Yes")


### FIXED CODE ###

a, b = map(int, input().split())
print("Even" if a * b % 2 == 0 else "Odd")
K = int(input())
lis = []

def search(s):
  lis.append(s)
  
  if int(s) > 3234566667:
    return
  
  it = int(s[-1])
  if it == 0:
    search(s + '1')
  elif it == 9:
    search(s + '8')
  else:
    search(s + str(it - 1))
    search(s + str(it + 1))
  

for i in (1, 10):
  search(str(i))
  
ans = sorted(map(int,lis))
print(ans[K-1])

### FIXED CODE ###

K = int(input())
lis = []

lis = []
def search(s):
  lis.append(s)
  
  if int(s) > 3234566667:
    return
  
  it = int(s[-1])
  if it == 0:
    search(s + '0')
    search(s + '1')
  elif it == 9:
    search(s + '8')
    search(s + '9')
  else:
    search(s + str(it - 1))
    search(s + str(it))
    search(s + str(it + 1))
  

for i in range(1, 10):
  search(str(i))

x = list(map(int, lis))
x.sort()
print(x[K-1])
# coding: utf-8
# Here your code !
a = input()
b = input()
men = a*b
syu = a*2 + b*2
print men ,
print syu ,

### FIXED CODE ###

# coding: utf-8
# Here your code !
a,b = input().split()
m = int(a) * 2 + int(b) * 2
s = int(a) * int(b)
print(s,m)
import math

while(1):
    thv = float(raw_input())
    for i in range(1, 20):
        y = 5 * (i-1)
        t = math.sqrt(y/4.9)
        v = 9.8 * t
        if v >= thv:
            print i
            

### FIXED CODE ###

import math

while(1):
    try:
        thv = float(raw_input())
    except:
        break
    for i in range(1, 1000):
        y = 5 * (i-1)
        t = math.sqrt(y/4.9)
        v = 9.8 * t
        if v >= thv:
            print i
            break
N=int(input())
H=list(map(int,input().split()))
i=0
s=o
t=[]
while H[i]>=H[i+1]:
  s+=1
  i+=1
  if H[i]<H[i+1]:
    t.append(s)
    break
print(max(t))

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
ans=0
cnt=0
for i in range(N-1):
  if H[i]>=H[i+1]:
    cnt+=1
  else:
    ans=max(cnt,ans)
    cnt=0
ans=max(ans,cnt)
print(ans)