Harryxun/stf_run huggingface dataset:
import numpy as np
import sys
input = sys.stdin.readline

mod = 10**9+7
N, K = map(int, input().split())
a = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int64)
ans = np.identity(N, dtype=np.int64)
while K > 0:
    if K & 1 == 1:
        ans = np.matmul(ans, a) % mod
    a = np.matmul(a, a) % mod
    K >>= 1
print(np.sum(ans) % mod)

### FIXED CODE ###

import sys
input = sys.stdin.readline

def matmul(a, b, mod):
    m = len(a)
    l = len(a[0])
    n = len(b[0])
    ret = [[0] * n for _ in range(m)]
    for i in range(m):
        for j in range(n):
            e = 0
            for k in range(l):
                e = (e + a[i][k] * b[k][j]) % mod
            ret[i][j] = e
    return ret

mod = 10**9+7
N, K = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
ans = [[i == j for j in range(N)] for i in range(N)]
while K > 0:
    if K & 1 == 1:
        ans = matmul(ans, a, mod)
    a = matmul(a, a, mod)
    K >>= 1
print(sum(sum(row) % mod for row in ans) % mod)
N,M = map(int,input().split())
ALL = [i for i in range(N)]
ALL = set(ALL)
Graph = [[] for _ in range(N)]
gyaku = [set([]) for _ in range(N)]
for i in range(N-1+M):
  a,b = map(int,input().split())
  a-=1;b-=1
  Graph[a].append(b)
  gyaku[b].add(a)
  ALL.discard(b)
#print(Graph,gyaku)
ALL = list(ALL);root = ALL[0]

used = set([])
TS = []
def dfs(v):
  if v in used:
    return
  used.add(v)
  for w in Graph[v]:
    if w in used:
      continue
    dfs(w)
    TS.append(w)
    
dfs(root)
TS.append(root)
#TS.reverse()
#print(TS)
ans = [0 for _ in range(N)]
for i in range(N):
  now = TS[i]
  for j in range(i+1,N):
    #print(now,TS[j],gyaku[now])
    if TS[j] in gyaku[now]:
      ans[now] = TS[j]+1 #1index
      break
for x in ans:
  print(x)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N,M = map(int,input().split())
ALL = [i for i in range(N)]
ALL = set(ALL)
Graph = [[] for _ in range(N)]
gyaku = [set([]) for _ in range(N)]
for i in range(N-1+M):
  a,b = map(int,input().split())
  a-=1;b-=1
  Graph[a].append(b)
  gyaku[b].add(a)
  ALL.discard(b)
#print(Graph,gyaku)
ALL = list(ALL);root = ALL[0]

used = set([])
TS = []
def dfs(v):
  if v in used:
    return
  used.add(v)
  for w in Graph[v]:
    if w in used:
      continue
    dfs(w)
    TS.append(w)
    
dfs(root)
TS.append(root)
TS.reverse()
#print(TS)
ans = [0 for _ in range(N)]
for i in range(N):
  now = TS[i]
  for nxt in Graph[now]:
    ans[nxt] = now+1
    
for x in ans:
  print(x)
import math
A, B = input().split()
A = int(A)

B_i = int(B[:-3])
B_f = int(B[-2:])

print(A*B_i + int(str(A*B_f)[:-2]))


### FIXED CODE ###

import math
A, B = input().split()
A = int(A)

B_i = int(B[:-3])
B_f = int(B[-2:])


f = str(A*B_f)
if (len(f) >= 3):
    f_i = int(f[:-2])
else:
    f_i = 0

print(A*B_i + f_i)
s = input()
c = 0
for i in range(len(s)):
    for j in range(i+4,len(s)+1):
        a = int(s[i:j])
        if a>=2019 and a%3==0 a%673==0:
            c += 1
print(c)

### FIXED CODE ###

s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))
s = sorted(list(input()))
if len(s) == 4 
    if s[0] == s[1]:
        if s[2] == s[3] and s[1] != s[2]:
            print("yes")
        else:
            print("no")

    else:
        print("no")
else:
    print("no")

### FIXED CODE ###

s = sorted(input())

if len(s) == 4:
    if s[0] == s[1] and s[2] == s[3] and s[0] != s[3]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
#--import&define---------------------
import math

def yes():
    print("Yes")
def no():
    print("No")
#--my_library--------------------------------
#mapを利用したリストの入力
# x,y = map(int,input().split())

#forを利用したリストの入力
#l = []
#for i in range():
#    l.append(int(input()))

#intの最大値と最小値
#maxX = 2147483647
#minX =-2147483648 
#--以下解答---------------------------------
n = int(input())
l = []
min = 2147483647
for i in range(n):
   l.append(int(input()))
   min = l[i] if l[i]<min else min

if n%min == 0:
    print(int(n/min)+4)
else:
    tmp = int(n/min) +1
    print(tmp+4)



### FIXED CODE ###

N,*A = map(int,open(0).read().split())
print((N+min(A)-1)//min(A) + 4)
a, b = [int(i) in input().split(" ")]

print(int(a/b), a%b, a/b, sep = " ")

### FIXED CODE ###

a, b = [int(i) for i in input().split(" ")]
num1 = a // b
num2 = a % b
num3 = "{:.8f}".format(a / b)

print(num1, num2, num3)
N, K = map(int, input().split())

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

now = 1

d = []

while True:
    if A[now-1] in d:
        i = d.index(A[now-1])
        check = d[i:]
        break
    d.append(A[now-1])
    now = A[now-1]
    print(d,now)

if K <= len(d):
    print(d[K-1])
else:
    K -= (len(d)-len(check))
    K = K % len(check)
    print(check[K-1])



### FIXED CODE ###

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

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

now = 1

d = []
set_d = set()

while True:
    if A[now-1] in set_d:
        i = d.index(A[now-1])
        check = d[i:]
        break
    now = A[now-1]
    d.append(now)
    set_d.add(now)

    if len(set_d) >= K:
        break

if K <= len(set_d):
    print(d[K-1])
else:
    K -= (len(set_d)-len(check))
    K = K % len(check)
    print(check[K-1])
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for _ in range(D):
        S.append(list(map(int, input().split())))
    ans = 0
    last = [-1] * 26
    days = [[-1] for _ in range(26)]
    T = []
    for d in range(D):
        t = int(input()) - 1
        T.append(t)
        ans += S[d][t]
        last[t] = d
        days[t].append(d)
        for i in range(26):
            ans -= C[i] * (d - last[i])
    for t in range(26):
        days[t].append(D)

    M = int(input())
    for _ in range(M):
        d, q = map(int, input().split())
        d -= 1
        q -= 1
        t = T[d]
        ans += S[d][q]
        ans -= S[d][t]
        i = bisect_left(days[q], d)
        ans += C[q] * (d - days[q][i-1]) * (days[q][i] - d)
        j = bisect_left(days[t], d)
        ans -= C[t] * (d - days[t][i-1]) * (days[t][i+1] - d)
        #print(days[q], days[t])
        T[d] = q
        days[q].append(d)
        days[q].sort()
        days[t].remove(d)
        print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for _ in range(D):
        S.append(list(map(int, input().split())))
    ans = 0
    last = [-1] * 26
    days = [[-1] for _ in range(26)]
    T = []
    for d in range(D):
        t = int(input()) - 1
        T.append(t)
        ans += S[d][t]
        last[t] = d
        days[t].append(d)
        for i in range(26):
            ans -= C[i] * (d - last[i])
    for t in range(26):
        days[t].append(D)

    M = int(input())
    for _ in range(M):
        d, q = map(int, input().split())
        d -= 1
        q -= 1
        t = T[d]
        ans += S[d][q]
        ans -= S[d][t]
        i = bisect_left(days[q], d)
        ans += C[q] * (d - days[q][i-1]) * (days[q][i] - d)
        j = bisect_left(days[t], d)
        ans -= C[t] * (d - days[t][j-1]) * (days[t][j+1] - d)
        #print(days[q], days[t])
        T[d] = q
        days[q].append(d)
        days[q].sort()
        days[t].remove(d)
        print(ans)


if __name__ == '__main__':
    main()
class Node:
    def __init__(self, parent, value):
        self.parent = parent
        self.value = value

class UnionFindTree:
    def __init__(self, size):
        self.table = [Node(i, 0) for i in range(size)]
    
    def hoge(self, x):
        while self.table[x].parent != self.table[self.table[x].parent].parent:
            parent = self.table[x].parent
            self.table[x].value += self.table[parent].value
            self.table[x].parent += self.table[parent].value

    def find_root(self, x):
        self.hoge(x)
        return self.table[x].parent

    def find_value(self, x):
        self.hoge(x)
        return self.table[x].value

    def union(self, x, y, d):
        r1 = self.find_root(x)
        r2 = self.find_root(y)
        v1 = self.find_value(x)
        v2 = self.find_value(y)
        print(r1, r2, v1, v2)
        if r1 != r2:
            self.table[r2].parent = r1
            self.table[r2].value = (v1 - v2) + d
        else:
            if (v2 - v1) != d:
                return False
        return True
    
    def __repr__(self):
        return repr(self.table)

def main():
    n, m = map(int, input().split())
    tree = UnionFindTree(n+1)
    for i in range(m):
        li, ri, di = map(int, input().split())
        if not tree.union(li, ri, di):
            print('No')
            return
    print('Yes')

main()


### FIXED CODE ###

class UnionFindTree:
    def __init__(self, size):
        self.parent = list(range(size))
        self.dist = [0] * size

    def find_root(self, x):
        if self.parent[x] == x:
            return x, 0
        else:
            self.parent[x], d = self.find_root(self.parent[x])
            self.dist[x] += d
            return self.parent[x], self.dist[x]

    def union(self, x, y, d):
        r1, d1 = self.find_root(x)
        r2, d2 = self.find_root(y)
        if r1 != r2:
            self.parent[r2] = r1
            self.dist[r2] = (d1 - d2) + d
        else:
            if (d2 - d1) != d:
                return False
        return True

def main():
    n, m = map(int, input().split())
    tree = UnionFindTree(n+1)
    for i in range(m):
        l, r, d = map(int, input().split())
        if not tree.union(l, r, d):
            print('No')
            return
    print('Yes')

main()
n,m,x = map(int,input().split())
a=list(map(int,input().split()))
cnt1, cnt2 = 0, 0
for i in range(x):
  if a[i] <= x:
    cnt1 += 1
for j in range(x, n):
  if x <= a[i] <= n:
    cnt2 += 1
print(min(cnt1 -1, cnt2 -1))

### FIXED CODE ###

n,m,x = map(int,input().split())
a=list(map(int,input().split()))
cnt1, cnt2 = 0, 0
for i in range(m):
  if 0 <= a[i] < x:
    cnt1 += 1
  if x < a[i] <= a[-1]:
    cnt2 += 1
print(min(cnt1, cnt2))
def conv(s):
  return ord(s) - 97

def sum_list(i):
    return int((i*(i+1))/2)

n = int(input())

ls = []
for i in range(n):
    ls.append(input())

lss = []
for i in range(n):
    ll = [0] * 25
    lss.append(ll)

for i in range(n):
    for j in range(10):
        lss[i][conv(ls[i][j])]+=1

ans = 0
llss = sorted(lss)

count = 0
for i in range(len(llss)):
    if (i == len(llss)-1):
        break

    if (llss[i] == llss[i+1]):
        count+=1
        if (i == len(llss)-2):
            ans += sum_list(count)
    else:
        ans += sum_list(count)
        count=0

print(ans)


### FIXED CODE ###

def sum_list(i):
    return int((i*(i+1))/2)

n = int(input())
ls = []
for i in range(n):
    ls.append(''.join(sorted(input())))

ls.sort()
ans = 0
count = 0

for i in range(len(ls)):
    if (ls[i] == ls[i+1]):
        count += 1
    else:
        ans += sum_list(count)
        count = 0
    if (i == n-2):
      ans += sum_list(count)
      break

print(ans)
import fractions

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    ans=T0*T//fractions.gcd(T0,T)
    T0=T
print(ans)

### FIXED CODE ###

import fractions

N=int(input())
T0=int(input())

if N==1:
  print(T0)
  exit()

for i in range(1,N):
    T=int(input())
    g=fractions.gcd(T0,T)
    ans=T0*T//g
    T0=ans
print(ans)
S, T = map(input().split())
A, B = map(int, input().split())
U = input()

print(A-1 B if U == S else A B)


### FIXED CODE ###

S, T = input().split()
A, B = map(int, input().split())
U = input()

print(A-1, B) if U == S else print(A, B-1)
N = int(input())

a = []
for i in range(1,N + 1):
  count = 0
  while True:
    if i % 2 == 0:
      i /= 2
    count += 1
    else:
      break
  a.append(count)
print(a.index(max(X) + 1)

### FIXED CODE ###

N = int(input())

a = []
for i in range(1,N + 1):
  count = 0
  while True:
    if i % 2 == 1:
      break
    else:
      i /= 2
      count += 1
  a.append(count)
print(a.index(max(a)) + 1)
a = map(int,input().split())
print(a*a*a)


### FIXED CODE ###

a = int(input())
print(a*a*a)
int a,b
a=input()
b=input()
print(a**2-b)

### FIXED CODE ###

a=int(input())
b=int(input())
print(a**2-b)
import math
r = int(input())
print(math.pai * r * r, 4 * math.pai * r * r * r / 3)


### FIXED CODE ###

pai = 3.141592653589793

r = float(input())
s = pai * r ** 2
l = 2 * pai * r
print(s, l)
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

def check(x):
    if A[x] >= K:
        return True
    dp = [False] * (K + 1)
    dp[0] = True
    for j, a in enumerate(A):
        if j == x:
            continue
        for i in range(K, 0, -1):
            if i >= a:
                dp[i] |= dp[i - a]
    for i in range(K - x, K):
        if dp[i]:
            return True
    return False
left = -1
right = N
while right - left > 1:
    mid = (left + right) // 2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)

### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

def check(x):
    if A[x] >= K:
        return True
    dp = [False] * (K + 1)
    dp[0] = True
    for j, a in enumerate(A):
        if j == x:
            continue
        for i in range(K, 0, -1):
            if i >= a:
                dp[i] |= dp[i - a]
    for i in range(K - A[x], K):
        if dp[i]:
            return True
    return False
left = -1
right = N
while right - left > 1:
    mid = (left + right) // 2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)
from collections import Counter
n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
tmp = a[p-1]
ans = p
l = 0
r = n+1
if v <= p:
    for i in range(p, n):
        if a[i]+m >= tmp:
            ans += 1
    print(ans)
    exit()
while l<r:
    mid = (l+r)//2
    a[n]

### FIXED CODE ###

from collections import Counter
n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
tmp = a[p-1]
ans = p
l = 0
r = n
if v <= p:
    for i in range(p, n):
        if a[i]+m >= tmp:
            ans += 1
    print(ans)
    exit()
while l<r-1:
    mid = (l+r)//2
    if mid<=p:
        l = mid
        continue
    if a[mid]+m<tmp:
        r = mid
    else:
        thresh = a[mid]+m 
        amari = (v-p)*m
        for i in range(p-1,n):
            if i==mid:
                continue
            amari-=min(m,thresh-a[i])
        if amari<=0:
            l = mid
        else:
            r=mid
print(l+1)
INF = 10**9+7 
import scipy.misc as scm

n = int(input())
a = list(map(int, input().split()))
s = set()
result = [x for x in a if x in s or s.add(x)]

indexes = [i for i, x in enumerate(a) if x == result[0]]
l0 = indexes[0]+1
l1 = indexes[1] +1

for i in range(1,n+2):
        print(int((scm.comb(n+1,i)-scm.comb(n-(l1-l0), i-1))%INF))


### FIXED CODE ###

INF = 10**9+7 

n = int(input())
a = list(map(int, input().split()))
s = set()
result = [x for x in a if x in s or s.add(x)]
indexes = [i for i, x in enumerate(a) if x == result[0]]
l0 = indexes[0]+1
l1 = indexes[1] +1

def bin_pow(a,n):
    ans = 1
    mag = a
    while(n>0):
        if n%2==0:
            mag = (mag*mag)%INF
            n /= 2
        else:        
            ans = ans* mag%INF
            n -= 1
    return ans

factorial = [0]*(n+2)
inverse_factorial = [0] * (n+2)

factorial[0] = 1
for i in range(1, n+2):
    factorial[i] = factorial[i-1] * i % INF

inverse_factorial[n+1] = bin_pow(factorial[n+1], INF-2)
for i in range(n,-1,-1):
    inverse_factorial[i] = (inverse_factorial[i+1]*(i+1))%INF

def combi(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    return (factorial[n] * inverse_factorial[r] )%INF * (inverse_factorial[n-r]% INF)

for i in range(1,n+2):
    print((combi(n+1,i)-combi(n-(l1-l0), i-1) )%INF)
N, M, K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
    if Asum[i]>K:
        break
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    if Bsum[i]>K:
        break
    
m=0
for i in range(len(Asum)):
    for j in range(len(Bsum)):

    elif Asum[i]+Bsum[j]<=K and m<i+j:
        m=i+j
print(m)

### FIXED CODE ###

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

Asum=[0]
Bsum=[0]

for i in range(N):
    Asum.append(Asum[-1]+A[i])
        
for i in range(M):
    Bsum.append(Bsum[-1]+B[i])
    
m=0
j=M

for i in range(len(Asum)):
    if Asum[i]>K:
        break
    while Asum[i]+Bsum[j]>K:
        j-=1
    if m<i+j:
        m=i+j
        
print(m)
a = list(input())
print(a)
i = 0
while True:
    odd = a[i]
    if odd == 'L':
        print('NO')
        break
    i += 1
    if i+1 == len(a):
        print('YES')
        break
    even = a[i]
    if even == 'R':
        print('NO')
    i += 1
    if i+1 == len(a):
        print('YES')
        break


### FIXED CODE ###

a = list(input())
i = 0
while True:
    odd = a[i]
    if odd == 'L':
        print('No')
        break
    i += 1
    if i == len(a):
        print('Yes')
        break
    even = a[i]
    if even == 'R':
        print('No')
        break
    i += 1
    if i == len(a):
        print('Yes')
        break
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(0))

### FIXED CODE ###

n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
roads = []
for i in range(m):
    roads += [list(map(int, input().split()))]
for road in roads:
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a = str(input())
if a[0]=a[-1]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a = str(input())
if a[0] == a[-1]:
    print("Yes")
else:
    print("No")
a,b,m = list(map(int,input().split()))
a_li = list(map(int,input().split()))
b_li = list(map(int,input().split()))
cost = [min(a_li) + min(b_li)]

for i in range(m):
  x,y,c = list(map(int,input().split()))
  price = a_li[x-1] + a_li[y-1] - c
  cost.append(price)
print(min(cost))


### FIXED CODE ###

A, B, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(M)]

ans = [min(a) + min(b)]
for x in X:
    a_idx, b_index, c = x
    ans.append(a[a_idx - 1] + b[b_index - 1] - c)

print(min(ans))
inp = input().split(" ")
n,m = int(inp[0]),int(inp[1])
brokens = []
for i in range (m):
    brokens.append(int(input()))

dp = []
for i in range(n+1):
    dp.append(0)

for i in brokens:
    dp[i]= -1

if dp[1] == -1 and dp[2] == -1:
    dp[1] = 0
    dp[2] = 0
elif dp[1] == -1:
    dp[1] = 0
    dp[2] = 1
elif dp[2] == -1 :
    dp[1] = 1
    dp[2] = 0
else:
    dp[1] = 1
    dp[2] = 2


for i in range(3,n+1):
    if dp[i] == -1:
        dp[i] = 0
    else:
        dp[i] = dp[i - 1] + dp[i - 2]

print(dp[n] % 1000000007)

### FIXED CODE ###

import sys

inp = input().split(" ")
n,m = int(inp[0]),int(inp[1])
brokens = []
for i in range (m):
    brokens.append(int(input()))

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


dp = []
for i in range(n+1):
    dp.append(0)

for i in brokens:
    dp[i]= -1

if dp[1] == -1 and dp[2] == -1:
    dp[1] = 0
    dp[2] = 0
elif dp[1] == -1:
    dp[1] = 0
    dp[2] = 1
elif dp[2] == -1 :
    dp[1] = 1
    dp[2] = 0
else:
    dp[1] = 1
    dp[2] = 2


if n <= 2:
    print(dp[n])
    sys.exit(0)


for i in range(3,n+1):
    if dp[i] == -1:
        dp[i] = 0
    else:
        dp[i] = dp[i - 1] + dp[i - 2]

print(dp[n] % 1000000007)
a, b, k = map(int, input().split())
ans = [e for e in range(1, min(a, b) // 2 + 1) if (a % e) + (b % e) == 0]
print(ans[-k])

### FIXED CODE ###

a, b, k = map(int, input().split())
ans = [e for e in range(1, min(a, b) + 1) if (a % e) + (b % e) == 0]
print(ans[-k])
a,b=map(int, input().split())
if 0<a<10　and 0<b<10:
	print(a*b)
else:
	print('-1')

### FIXED CODE ###

a,b=map(int, input().split())
if 0<a<10 and 0<b<10:
	print(a*b)
else:
	print('-1')
#74b
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans=0

for i in range(n):
    ans+=min(2*x[i],2*(k-x[i])

print(ans)

### FIXED CODE ###

#74b
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans=0
for i in range(n):
    ans+=min(2*x[i],2*(k-x[i]))
print(ans)
n,m = map(int,input().split())
from collections import defaultdict
dic = defaultdict(list)
l = []
for i in range(n):
    a,b=map(int,input().split())
    dic[a].append(b)
s = 0
t = [0,0,0,0,0,0,0,0,0,0,0]
for i in range(m):
    t += dic[i+1]
    M = max(t)
    s +=M
    t.remove(M)
print(s)

### FIXED CODE ###

n,m = map(int,input().split())
import heapq
from collections import defaultdict
dic = defaultdict(list)
l = []
heapq.heapify(l)
for i in range(n):
    a,b=map(int,input().split())
    b = -b
    dic[a].append(b)
s = 0
t = [0]
for i in range(m):
    for i in dic[i+1]:
        heapq.heappush(l,i)
    if len(l) ==0 : M = 0
    else:
        # print(l)
        M = heapq.heappop(l)
        s += -M
print(s)