Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * M
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

for p, y, i in data:
    num[p-1] += 1
    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)

for i in range(M):
    print(ans[i])

### FIXED CODE ###

N, M = map(int, input().split())
cnt = [0 for i in range(N + 1)] 
check = []
ans = []

for i in range(M):
    p, y = map(int, input().split())
    check.append((y, p, i))

check.sort()

for y, p, i in check:
    cnt[p] += 1
    ans.append((i,str(p).zfill(6)+str(cnt[p]).zfill(6)))

ans.sort()

for aa, bb in ans:
    print(bb)
def cal(i):
    return floor(a*i/b)-a*floor(i/b)
from  math import floor
a, b, n = map(int, input().split())
if b-1<n:
    ans = cal(b-1)
print(max(cal(ans), cal(0),cal(n)))

### FIXED CODE ###

a, b, n = map(int, input().split())
def cal(x):
    return (a*x)//b - a*(x//b)
print(cal(min(b-1,n)))
n,m = [int(i) for i in input().split()]
a = {int(input()) for i in range(m)}
dp = {}
def stairs(step):
  if step in a:
    return 0
  if step == 1:
    return 1
  if step == 2:
    return stairs(step-1) + 1
  if step in dp.keys():
    return dp[step]
  else:
    dp[step] = stairs(step-1) + stairs(step-2)
    return dp[step]
print(int(stairs(n)%1000000007))


### FIXED CODE ###

n,m = [int(i) for i in input().split()]
a = {int(input()) for i in range(m)}
dp = {}
for step in range(1,n+1):
    if step in a:
        dp[step] = 0
        continue
    if step == 1:
        if step in a:
            dp[1] = 0
        else:
            dp[1] = 1
        continue
    if step == 2:
        if step in a:
            dp[2] = dp[1]
        else:
            dp[2] = dp[1] + 1
        continue
    dp[step] = dp[step-1] + dp[step-2]
print(int(dp[n]%1000000007))
import math
n=int(input())
a=[]
for i in range(n):a.append(int(input()))
while len(a)>1:
    j=a.pop()
    k=a.pop()
    a.append(j*k//math.gcd(j,k))
print(a[0])

### FIXED CODE ###

import fractions
n=int(input())
a=[]
for i in range(n):a.append(int(input()))
while len(a)>1:
    j=a.pop()
    k=a.pop()
    a.append(j*k//fractions.gcd(j,k))
print(a[0])
a = list(map(int,input().split()))

cnt = 1
for i in range(a):
  if i == 0:
    print(cnt)
    cnt += 1

### FIXED CODE ###

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

if a == 0 :
  print(1)
elif b == 0 : 
  print(2)
elif c == 0 :
  print(3)
elif d == 0 : 
  print(4)
else :
  print(5)
import math
# input
N = input()

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm_base(2, N))

### FIXED CODE ###

# input
N = int(input())

if N % 2 == 0:
    print(N)
else:
    print(N * 2)
import sys
stdin = sys.stdin
 

 
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())

categories = [ tuple(li()) for _ in range(N) ]
categories.sort()

total = 0
def buy_M(cate, M, cost):
    if M <= 0:
        return cost
    if cate[0][1] >= M:
        cur_cost = cate[0][0] * M
        return cur_cost + cost
    else:
        rest = M - cate[0][1]
        cur_cost = cate[0][1] * cate[0][0]
        return buy_M(cate[1:], rest, cost + cur_cost)
print(buy_M(categories, M, 0))


### FIXED CODE ###

import sys
import bisect
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())

categories = [ tuple(li()) for _ in range(N) ]
categories.sort()

total_cost = [(0, 0)]
for A, B in categories:
    total_cost.append((B + total_cost[-1][0], A * B + total_cost[-1][1]))
    idx = bisect.bisect_right( total_cost, (M, 0) )
total = total_cost[idx][1] + (M - total_cost[idx][0]) * categories[idx - 1][0]
print(total)
# -＊- coding:utf-8 -＊-
R=int(input())
G=int(input())
print(2G-R)

### FIXED CODE ###

# coding: utf-8

R=int(input())
G=int(input())

print((G-R)+G)
import copy

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

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

    n, m = map(int, input().split())
    # これだと72がREになる
    A = set([int(x) for x in input().split()])
    # これだと74も78もREになる
    # A = [int(x) for x in input().split()]
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for i in A:
        if (a_lcm / 2) % i == 0:
        # if (a_lcm / i) % 2 == 0: 
            print(0)
            exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    # if (a_lcm / 2) > m:
    if a_lcm > m * 2:
        print(0)
    else:
        # あとは定数倍の数調べて終わり
        # ans = int((m - (a_lcm / 2))) // a_lcm + 1
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


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

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
R, G, B, N = map(int, input().split())

cnt = 0

for i in range(N//R + 1):
    for j in range(N//G + 1):
        sum = N - i * R - j * G
        if sum >= 0 and sum % B == 0:
            cnt += 1

print(cnt)

### FIXED CODE ###

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

print(n - k + 1)
N=int(input)
a=N%111
if a==0:
   print(a*111)
else:
  b=N//111
  c=b+1
  print(c*111)
      

### FIXED CODE ###

N=int(input())
a=N%111
if a==0:
   print(N)
else:
  b=N//111
  c=b+1
  print(c*111)
あ

### FIXED CODE ###

あ=int(input())
い=input()

if あ>=3200:
  print(い)
else:
  print('red')
abcd = str(input())
n = 3
x1 = '+'
x2 = '+'
x3 = '+'
for bits in range(1 << n):
    for i in range(n):
        if (bits >> i & 1) == 1:
            if i == 0:
                x1 = '-'
            if i == 1:
                x2 = '-'
            if i == 2:
                x3 = '-'
    check1 = abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3]
    check2 = eval(abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3])
    if check2 == 7:
        ans = check1
print(ans+'=7')

### FIXED CODE ###

n = input()

a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if (a+b+c+d) == 7:
    print(a, "+" ,b, "+" ,c, "+", d, "=7", sep="")
elif (a+b+c-d) == 7:
    print(a, "+" ,b, "+" ,c, "-", d, "=7", sep="")
elif (a+b-c+d) == 7:
    print(a, "+" ,b, "-" ,c, "+", d, "=7", sep="")
elif (a+b-c-d) == 7:
    print(a, "+" ,b, "-" ,c, "-", d, "=7", sep="")
elif (a-b+c+d) == 7:
    print(a, "-" ,b, "+" ,c, "+", d, "=7", sep="")
elif (a-b+c-d) == 7:
    print(a, "-" ,b, "+" ,c, "-", d, "=7", sep="")
elif (a-b-c+d) == 7:
    print(a, "-" ,b, "-" ,c, "+", d, "=7", sep="")
elif (a-b-c-d) == 7:
    print(a, "-" ,b, "-" ,c, "-", d, "=7", sep="")
X = int(input())
a = X
b = 0
while (a>10):
    b += (a % 10) + (X / 10)
if X % b == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

T,A,B = map(int, input().split())
if T * A <= B:
    print(T*A)
else:
    print(B)
N = int(input())
x = N - ((N/15)200)

print (x)

### FIXED CODE ###

n = int(input())
x = (n*800) - ((n//15)*200)
print (x)
a,b,c,d=list(map(int,input().split()))
 
while True:
	c-=b
    if c<=0:
		print("Yes")
		break
    a-=d
	if a<=0:
		print("No")
		break

### FIXED CODE ###

a,b,c,d=list(map(int,input().split()))
 
while True:
	c-=b
	if c<=0:
		print("Yes")
		break
	a-=d
	if a<=0:
		print("No")
		break
import math
N = int(input())
p = int(math.sqrt(N))

def search(N, p):
#     print(p, N % p)
    if N % p == 0:
        q = int(N / p)
        return p, q
    else:
        if p * N // p > N:
            p, q = search(N, p - 1)
        else:
            p, q = search(N, p + 1)
    
    return p, q

p, q  = search(N, p)
print(p + q - 2)

### FIXED CODE ###

import math
N = int(input())
s = int(math.sqrt(N))

for p in reversed(range(1, s + 1)):
#     print(p)
    if N % p == 0:
        p, q = p, N // p
        print(p + q - 2)
        break
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(n):
  a.append(a[i]+A[i])
for i in range(m):
  b.append(b[i]+B[i])
a.pop(0)
b.pop(0)
j=m-1
x=0
for i in range(n-1,-1,-1):
  if a[i]>k:
    continue
  while b[j]>k-a[i]:
    j-=1
  x=max(x,i+j+2)
print(x)


### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
 a.append(a[i] + A[i])
for i in range(M):
 b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
 if a[i] > K:
  break
 while b[j] > K - a[i]:
  j -= 1
 ans = max(ans, i + j)
print(ans)
import numpy as np
alp = [chr(v) for v in range(ord("a"), ord("z") + 1)]
inp = input()

if inp[::-1] == "".join(alp):
    print(-1)
    exit()

if len(inp) == len(alp):
    prev = inp[0]
    indices = [0]
    for index, char in enumerate(inp[1:]):
        if prev > char:
            indices.append(index)
        prev = char
    indices = np.array(indices)
    diff = indices[1:] - indices[:-1]
    maxv = float("-inf")
    maxv_index = 0
    for i, d in enumerate(diff):
        if maxv <= d:
            maxv = d
            maxv_index = i

    index = indices[maxv_index + 1]
    print(inp[:index - 1] + min(inp[index:]))

else:
    print(inp + min(set(alp) - set(list(inp))))


### FIXED CODE ###

import numpy as np
alp = [chr(v) for v in range(ord("a"), ord("z") + 1)]
inp = input()

if inp[::-1] == "".join(alp):
    print(-1)
    exit()

if len(inp) == len(alp):
    prev = inp[0]
    indices = [0]
    for index, char in enumerate(inp[1:]):
        if prev < char:
            indices.append(index)
        prev = char
    # diff = [0] * (len(indices) - 1)
    # for i, (v1, v2) in enumerate(zip(indices[1:], indices[:-1])):
    #     diff[i] = v1 - v2
    # maxv = float("-inf")
    # maxv_index = 0
    # for i, d in enumerate(diff):
    #     if maxv <= d:
    #         maxv = d
    #         maxv_index = i
    #
    # index = indices[maxv_index + 1]
    index = indices[-1]
    targets = inp[index + 1:]
    for v in sorted(targets):
        if inp[index] < v:
            break
    print(inp[:index] + v)

else:
    print(inp + min(set(alp) - set(list(inp))))
rom collections import Counter
N = int(input())
S = [input() for _ in range(N)]
CS = Counter(S)
v = 0
ans = []
for i  in CS.values():
  v = max(v,i)
for i,j in CS.items():
  if v == j:
    ans.append(i)
ans.sort()
print(ans[i] for i in range(len(ans)))

### FIXED CODE ###

from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
CS = Counter(S)
v = 0
ans = []
for i  in CS.values():
  v = max(v,i)
for j,k in CS.items():
  if v == k:
    ans.append(j)
ans.sort()
print(*ans,sep="\n")
from collections import Counter
N, A, B = map(int, input().split())
ans = ''
while len(ans) < N:
    ans += 'b' * A + 'r' * B
ans = list(ans)
ans = ans[:N]
ans = dict(Counter(ans))
ans = list(ans.values())
print(ans[0])

### FIXED CODE ###

N, A, B = map(int, input().split())
if N % (A + B) <= A:
    ans = (N // (A + B)) * A + N % (A + B)
    print(ans)
else:
    ans = (N // (A + B)) * A + A
    print(ans)
N, X = map(int, input().split())
A = [int(a) for a in input().split()]
x = 0
c = 0
i = 0
while x <= X:
    c += 1
    x += A[i]
    i += 1
print(c)

### FIXED CODE ###

N, X = map(int, input().split())
A = [int(a) for a in input().split()]
x = 0
c = 0
i = 0
while x <= X:
    c += 1
    if i == N:
        break
    x += A[i]
    i += 1
print(c)
import sys
import numpy as np
input=sys.stdin.readline
h,w=map(int,input().split())
red=[list(map(int,input().split()))+[0] for i in range(h)]+[[0 for i in range(w+1)]]
blue=[list(map(int,input().split()))+[0] for i in range(h)]+[[0 for i in range(w+1)]]
field = [[None]*(w+1) for i in range(h+1)]
    for i in range(h):
        for j in range(w):
            field[i][j] = np.zeros(6500, np.bool)
for i in range(h):
    for j in range(w):
        for f in range(6401):
            if field[i][j][f]:
                field[i][j+1][f+abs(red[i][j+1]-blue[i][j+1])]=True
                field[i][j+1][abs(f-abs(red[i][j+1]-blue[i][j+1]))]=True
                field[i+1][j][f+abs(red[i+1][j]-blue[i+1][j])]=True
                field[i+1][j][abs(f-abs(red[i+1][j]-blue[i+1][j]))]=True
for i in range(6500):
    if field[h-1][w-1][i]:print(i);exit()


### FIXED CODE ###

import sys
input=sys.stdin.readline
h,w=map(int,input().split())
red=[list(map(int,input().split()))+[0] for i in range(h)]+[[0 for i in range(w+1)]]
blue=[list(map(int,input().split()))+[0] for i in range(h)]+[[0 for i in range(w+1)]]
field=[[[0 for h in range(6500)] for i in range(w+1)] for j in range(h+1)]
field[0][0][abs(red[0][0]-blue[0][0])]=1
for i in range(h):
    for j in range(w):
        for f in range(6401):
            if field[i][j][f]==1:
                field[i][j+1][f+abs(red[i][j+1]-blue[i][j+1])]=1
                field[i][j+1][abs(f-abs(red[i][j+1]-blue[i][j+1]))]=1
                field[i+1][j][f+abs(red[i+1][j]-blue[i+1][j])]=1
                field[i+1][j][abs(f-abs(red[i+1][j]-blue[i+1][j]))]=1
for i in range(6500):
    if field[h-1][w-1][i]==1:print(i);exit()
n, k = input().split()
sum(input().split().sorted()[:k])

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
print(sum(sorted([int(i) for i in input().split()])[:k]))
n,k = list(map(int,input().split()))
h = list(map(int,input()))

cnt = 0
for i in h:
    if i >= k:
        cnt+=1

print(cnt)

### FIXED CODE ###

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

h = list(map(int,input().split()))
ans=0
for i in range(n):

    if(h[i] >=k):
        ans += 1

print(ans)
def hierarchize(source):
    global edges, hierarchy
    l, r = 0, 1
    hierarchy = [-1] * n
    hierarchy[source] = 0
    queue[0] = source
    while l != r:
        v = queue[l]
        l += 1
        if v == sink:
            break
        for remain, target, idx in edges[v]:
            if hierarchy[target] == -1 and remain != 0:
                hierarchy[target] = hierarchy[v] + 1
                queue[r] = target
                r += 1
    return hierarchy[sink] != -1


def augment(v, limit):
    global sink, edges, hierarchy
    if v == sink:
        return limit
    res = 0
    for e in edges[v]:
        remain, target, idx = e
        if remain == 0 or hierarchy[v] >= hierarchy[target]:
            continue
        aug = augment(target, min(limit, remain))
        e[0] -= aug
        edges[target][idx][0] += aug
        res += aug
        limit -= aug
        if not limit:
            break
    return res


n, m = map(int, input().split())
sink = n - 1
edges = [[] for _ in range(n)]

queue = [-1] * n
hierarchy = [-1] * n

for _ in range(m):
    s, t, c = map(int, input().split())
    edges[s].append([c, t, len(edges[t])])
    edges[t].append([0, s, len(edges[s])])

res = 0
while hierarchize(0):
    res += augment(0, 10000001)
print(res)

### FIXED CODE ###

import sys
from queue import deque

sys.setrecursionlimit(200000)


def hierarchize(source):
    global edges, hierarchy
    hierarchy = [-1] * n
    queue = deque([(0, source)])
    while queue:
        h, v = queue.popleft()
        if hierarchy[v] != -1:
            continue
        hierarchy[v] = h
        if v == sink:
            return True
        queue.extend((h + 1, target)
                     for remain, target, _ in edges[v] if hierarchy[target] == -1 and remain)
    return False


def augment(v, limit):
    global sink, edges, hierarchy
    if v == sink:
        return limit
    res = 0
    for e in edges[v]:
        remain, target, idx = e
        if remain == 0 or hierarchy[v] >= hierarchy[target]:
            continue
        aug = augment(target, min(limit, remain))
        e[0] -= aug
        edges[target][idx][0] += aug
        res += aug
        limit -= aug
        if not limit:
            break
    return res


n, m = map(int, input().split())
sink = n - 1
edges = [[] for _ in range(n)]

hierarchy = [-1] * n

for _ in range(m):
    s, t, c = map(int, input().split())
    es, et = edges[s], edges[t]
    ls, lt = len(es), len(et)
    edges[s].append([c, t, lt])
    edges[t].append([0, s, ls])

res = 0
while hierarchize(0):
    res += augment(0, 10000001)
print(res)
def main():
    import math

    A, B, N = map(int, input().split())

    if (N >= B):
        syou = N // B
    else:
        syou = 0

    if (syou == N / B):
        a=1
        ## ans = syou * (A - 1) + 1
        # ans = math.floor(A * syou) - A * syou
        # ans = syou * (A - 1)

    else:
        ans = syou * (A - 1)
        mod = N / B - N // B
        y = 1 - mod
        cnt = 0
        for i in range(1, A):
            num = i / A
            if (num > y):
                cnt = A - i
                break
        ans += cnt

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math

A, B, N = map(int, input().split())

ans_x = min(N, B - 1)
ans = math.floor(A * ans_x / B) - A * math.floor(ans_x / B)

print(ans)
N,M=map(int,input().split)
lis=list(map(int, input().split()))
s=0
for i in lis:
    s+=i
if N-s<0:
    print("-1")
else:
    print(N-s)

### FIXED CODE ###

N,M=map(int,input().split())
lis=list(map(int, input().split()))
s=0
for i in lis:
    s+=i
if N-s<0:
    print("-1")
else:
    print(N-s)
satoooh
a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)

### FIXED CODE ###

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

print(b//x-(a-1)//x)
N,M,K = map(int, input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a,b=[0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j =0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=i
    ans =max(ans,i+j)
print(ans)

### FIXED CODE ###

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

a,b=[0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j =0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans =max(ans,i+j)
print(ans)
from math import factorial
def ncr(n,r):
 if r <= 0:
  return 1
 if not n == r:
  return (factorial(n)) // factorial(r) // factorial(n - r)
 else:
    return 1

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  blue = k
  red  = n-k
  blueplace = red+1
  
  for i in range(1,k+1):
    print(ncr(blueplace,i)*ncr(k-1,i-1)%mod)
solve()

### FIXED CODE ###

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  fact = [1]*(n+5)
  inv = [1]*(n+5)
  finv = [1]*(n+5)
  fact[0] = fact[1] = 1
  finv[0] = finv[1] = 1
  inv[1]  = 1
  for i in range(2,n+4):
   fact[i] = (fact[i-1]*i)%mod
   inv[i] = mod-inv[mod%i]*(mod//i)%mod
   finv[i]= finv[i-1]*inv[i]%mod

  
  blue = k
  red  = n-k
  blueplace = red+1
  
  for i in range(1,k+1):
    if (n-k+1)>= i:
     tmp = fact[n-k+1]*(finv[i]*finv[n-k+1-i]%mod)%mod
     tmp *= fact[k-1]*(finv[i-1]*finv[k-i]%mod)%mod
     print(tmp%mod)
    else:
      print(0)
solve()
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=int(input())
t=[int(input()) for i in range(n)] 

print(lcm_list(t))

### FIXED CODE ###

import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
n=int(input())
t=[int(input()) for i in range(n)] 
 
print(lcm_list(t))
N = int(input())
A = sorted(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

ans = sum(A)
nums = [A.count(num) for num in range(10 ** 5)]

for i in range(Q):
    ans += (C[i] - B[i]) * nums[B[i]]
    nums[C[i]] += nums[B[i]]
    nums[B[i]] = 0
    print(ans)

### FIXED CODE ###

import collections

N = int(input())
A = sorted(map(int, input().split()))

cnt = collections.defaultdict(int)
for a in A:
    cnt[a] += 1
ans = sum(A)

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * cnt[B]
    cnt[C] += cnt[B]
    cnt[B] = 0
    print(ans)
n, m = map(int, input().split())

mod = 10 ** 9 + 7


def Fib(n, memo={}):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif n in memo:
        return memo[n] % mod
    else:
        memo[n] = Fib(n - 1, memo) + Fib(n - 2, memo)
        return memo[n] % mod


A = list(int(input()) for i in range(m))

ans = Fib(A[0] + 1)
for i in range(m - 1):
    ans *= Fib(A[i + 1] - A[i])
    ans %= mod
    if A[i] + 1 == A[i + 1]:
        print(0)
        exit()
ans *= Fib(n - A[-1] + 1)
ans %= mod
print(ans % mod)

### FIXED CODE ###

n, m = map(int, input().split())
A = list(int(input()) for i in range(m))

mod = 10 ** 9 + 7

def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b


if m > 0:
    ans = Fib(A[0] + 1) % mod
    for i in range(m - 1):
        if A[i] == A[i + 1]:
            continue
        ans *= Fib(A[i + 1] - A[i])
        ans %= mod
    ans *= Fib(n - A[-1] + 1)
    ans %= mod
else:
    ans = Fib(n + 2) % mod
print(ans)
N, A, B = map(int, input().split())
print(sum(i for in range(N + 1)
          if A <= sum(map(int, str(i))) <= B))

### FIXED CODE ###

N, A, B = map(int, input().split())
print(sum(i for i in range(N + 1) 
         if A <= sum(map(int, str(i)))
         <= B))
N , K = map(int, input().split())
A =list(map(int, input().split()))
mod = 10**9 + 7
count =0
for k in range(len(A)):
    if A[k] == 0:
        count +=1
        A[k] = float("inf")
if N-count < K:
    print(0)
    exit()
A.sort()
A = A[:N-count]
A.sort(reverse=True)
#print(A)
ans = 1
plus = 0
minus = -1
countp = 0
countm = 0
if A[0] >0:
    for k in range(K):
        if abs(A[plus]) >= abs(A[minus]):
            ans = ans*A[plus]%mod
            plus+=1
        else:
            ans = ans*A[minus]%mod
            if A[minus] <0:
                lasm = 0+minus
            minus-=1
            
    if minus%2 == 1:
        print(ans%mod)
    else:
        print(ans//A[lasm]*max(A[plus], A[minus])%mod)
else:
    for k in range(K):
        ans = ans*A[k]%mod
    print(ans%mod)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0 
if N %2 ==1:
    ans += A[0]
    k = 0
    for j in range(1, N//2):
        k += 1
        ans += 2*A[k]
    ans += A[k+1]
if N%2 == 0:
    ans += A[0]
    k = 0
    for j in range(1, N//2):
        k += 1
        ans += 2*A[k]
print(ans)
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  absv = x
  for i in range(1, 100):
    if i in p:
      pass
    else:
      if absv > abs(x - i):
        absv = abs(x - i)
        value = x - i
  print(x - value)

### FIXED CODE ###

x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  absv = x
  value = x
  for i in range(-1, 102):
    if i in p:
      pass
    else:
      if absv > abs(x - i):
        absv = abs(x - i)
        value = x - i
  print(x - value)
import bisect

n = int(input())
d = list(map(int, input().split()))
d.sort()

m = 0

for a in range(n-2):
	for b in range(a+1,n-1):
		m+=bisect.bisect_left(d,d[a]+d[b])-1-j

print(m)

### FIXED CODE ###

import bisect

n = int(input())
d = list(map(int, input().split()))
d.sort()

m = 0

for a in range(n-2):
	for b in range(a+1,n-1):
		m+=bisect.bisect_left(d,d[a]+d[b])-1-b

print(m)