peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
mod = 10**9+7
ans = 0
m = max(a)
x = 0
while m > 0:
    m >>= 1
    x += 1 

for i in range(x):
    cnt = 0
    for j in range(n):
        if a[j]>>i & 1 == 0: cnt += 1
    ans = (ans+pow(2,i,mod)*cnt%mod*(n-cnt)%mod)%mod
    
print(ans)
# Judge status: Accepted
import math
A,B = map(int,input().split())
for i in range(10000):
  if math.floor(i * 1.08 -i )==A and math.floor(i * 1.1 -i)==B:
    print(i)
    exit()
print(-1)
# Judge status: Wrong Answer
h1, m1, h2, m2, k = map(int, input().split())
h = h2-h1
if m1 > m2:
    m2 += 60
m = m2-m1
a = h*60
m += a
b = k
if k != m:
    while k+b != m and k < m:
        if k+b == m:
            k = 0
            break
        k += b
else:
    k = 0
print(k)
# Judge status: Wrong Answer
s = str(input())
n = len(s)
p = [0] * n
if int(s[0]) % 2 == 0:
  for i in range(1, n, 2):
    p[i] = 1
elif int(s[0]) % 2 == 1:
  for i in range(1, n, 2):
    p[i] = 0
q = []
for i in range(n):
  q.append(int(s[i]) ^ int(p[i]))
print(q.count(1))
# Judge status: Accepted
PQR = list(list(input().split()))
PQR.sort()
print(int(PQR[0]) + int(PQR[1]))
# Judge status: Accepted

import numpy as np  

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

dp = np.array([0] * (w+1)) 

for i in range(n):
    weight, value = map(int, input().split())

    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value) 

print(int(dp[-1]))
# Judge status: Accepted
N = input()
s = N[-1]


if s in "24579":
    print("hon")
elif s in "0168":
    print("pon")
else:
    print("bon")
# Judge status: Accepted
def main():
    from bisect import bisect_right
    n=int(input())
    a=[int(input()) for _ in range(n)]

    color=[]
    for i in range(n-1,-1,-1):
        num=a[i]
        idx=bisect_right(color,num)
        if idx==len(color):
            color.append(num)
        else:
            color[idx]=num
    
    print(len(color))    
if __name__=='__main__':
    main()
# Judge status: Accepted
s=input()
k=int(input())

alpha=list('abcdefghijklmnopqrstuvwxyz')

ans=[]
for i in range(len(s)):
    ki= 26-alpha.index(s[i]) if s[i]!='a' else 0
#    print(ki,k)
    if(i==len(s)-1):
        kn=k+alpha.index(s[i])
        kn=kn%26
        ans.append(alpha[kn])
    elif(ki<=k):
        ans.append('a')
        k-=ki
    else:
        ans.append(s[i])
print(''.join(ans))
# Judge status: Accepted
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        index=bisect.bisect_left(l,l[i]+l[j])
        if j<index:
            ans+=index-j-1
print(ans)
# Judge status: Accepted
from math import ceil
def main():
    x = int(input())
    r = 0
    for i1 in range(1, ceil(x**0.5) + 1):
        beki = 2
        while True:
            num = pow(i1, beki)
            if num <= x:
                r = max(r, num)
            else:
                break
            if num == pow(i1, beki - 1):
                break
            beki += 1

    print(r)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
A = list(map(int,input().split()))
A.sort()
print(A[0]*A[1]/2)
# Judge status: Wrong Answer
coin = int(input())
fivet_yen = 0
five_yen = 0
if coin == 0:
    print(0)
else:
   while(coin > 0):
    if coin >= 500:
        coin = coin - 500
        fivet_yen = fivet_yen + 1000
    else:
        if coin >= 5:
            coin = coin - 5
            five_yen   = five_yen + 5
            
        coin = coin - 1


print(fivet_yen + five_yen)
# Judge status: Accepted
n = int(input())

a = 2
res = dict()

for i in range(1, 142):
    for j in range(1, 142):
        for k in range(1, 142):
            tmp = int(((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) / 2)
            res[tmp] = res.get(tmp, 0) + 1

for i in range(n):
    print(res.get(i + 1, 0))
# Judge status: Wrong Answer
N, M = map(int, input().split())
ans = 1
K = M//N
for i in range(1, int(M**0.5)+1):
    if M%i == 0:
        if i <= K:
            ans = max(ans, i)
        if M//i <= K:
            ans = max(ans, i)

print(ans)
# Judge status: Accepted
N,K=map(int,input().split())
light=list(map(int,input().split()))
for k in range(K):
  imo=[0]*(N+1)
  for i in range(N):
    l=max(0,i-light[i])
    r=min(N-1,i+light[i])+1
    imo[l]+=1
    imo[r]-=1
  for i in range(1,N):
    imo[i]+=imo[i-1]
  if light==imo:
    break
  else:
    light=imo[:]
print(*light[:-1])
# Judge status: Accepted
def main():
    N, Q = (int(i) for i in input().split())
    S = input()
    C = [0] * (len(S) + 1)
    for i in range(1, len(S)):
        C[i+1] = C[i] + (1 if S[i] == "C" and S[i-1] == "A" else 0)

    for q in range(Q):
        le, ri = (int(i) for i in input().split())
        print(C[ri] - C[le])


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
ball = [0] * N

def divisors(n):
  for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      ball[i - 1] += 1
  if n != 1:
    ball[n - 1] += 1

for i in range(N - 1,-1,-1):
  if A[i] != (ball[i] % 2):
    divisors(i + 1)

if sum(ball) == 0:
  print(0)
else:
  M = sum(ball)
  ball = [i for i in ball if i >= 1]
  print(M)
  print(*ball)
# Judge status: Wrong Answer
n=float(input())
if n%2==0:
  print(float(1/2))
else:
  print((n-1)/(2*n))
# Judge status: Wrong Answer
mod=1000000007
dp=[1]*2001
for i in range(3,2001):
	for j in range(i+3,2001):
		dp[j]=(dp[j]+dp[i])%mod
n=int(input())
print(dp[n])
# Judge status: Wrong Answer
A, B = map(int, input().split())
commulti = A * B
count = 1
while True:
    if commulti / A / B == 1:
        break

    if count%2 == 0:
        commulti /= A
    else:
        commulti /= B

print(commulti)
# Judge status: Wrong Answer
A = [int(input()) for _ in range(5)]
cnt = 0
Max = 10
for i in range(len(A)):
    if A[i]%10 < Max:
        Max = i
for i in range(len(A)):
    if i != Max:
        cnt += A[i]
    while cnt%10 != 0:
        cnt += 1
print(cnt+A[Max])
# Judge status: Accepted
S = [input() for _ in range(int(input()))]
T = [input() for _ in range(int(input()))]
l = list(set(S))
print(max(0, max(S.count(l[i]) - T.count(l[i]) for i in range(len(l)))))
# Judge status: Accepted
"""
kari1 = '2'
kari2 = '4 8' #8
#kari1 = '3'
#kari2 = '1 1 3' #3
#kari1 = '3'
#kari2 = '4 2 5' #5
#kari1 = '4'
#kari2 = '-100 -100 -100 -100' #0
in1 = kari1
in2 = kari2.split()
"""
in1 = input()
in2 = input().split()

AVEa = 0
RC   = 0
for item in in2:
    AVEa = AVEa + int(item)

AVEa = round(AVEa / len(in2))

for item in in2:
    if int(item) != AVEa:
        RC = RC + ((int(item) - AVEa) ** 2)

print(RC)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
print(":(" if max(a,b,c,d,e) - min(a,b,c,d,e) > k else "Yay!")
# Judge status: Wrong Answer
X, K, D = map(int, input().split())

Xa = abs(X)
Xs = X // D
Xm = X % D

if (K < Xs):
    print(Xa - D*K)
elif Xm == 0 and X != 0:
    if K % 2 == 0:
        print(D)
    else:
        print(0)
elif (K-Xs) % 2 == 0:
    print(Xm)
else:
    print(D-Xm)
# Judge status: Accepted
A, B, C = map(int,raw_input().split())
area = (A*B)/2
print area
# Judge status: Wrong Answer
S=input()
T=input()
a=S.split()
b=T.split()
l=[]
for i in range(len(a)):
  if a[i]!=b[i]:
    l.append(1)
print(len(l))
# Judge status: Wrong Answer
H = int(input())

cnt = 1
ans = 1
while True:
    if H // 2 > 1:
        H //= 2
        ans += 2 ** cnt
        cnt += 1
    else:
        ans += 2 ** cnt
        break

print(ans)
# Judge status: Wrong Answer
n=int(input())
d={}
for i in range(1, n+1):
  x=int(input())
  d[i] = x
tmp = d[1]
ans=1
for _ in range(n):
  ans+=1
  tmp = d[tmp]
  #print(tmp)
  if tmp == 2:
    print(ans)
    exit()
print(-1)
# Judge status: Accepted
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10 ** 12
for i in range(n-k+1):
    ans = min(ans,abs(x[i])+(abs(x[i+k-1]-x[i])),abs(x[i+k-1])+(abs(x[i+k-1]-x[i])))
print(ans)
# Judge status: Accepted
from math import sqrt, ceil

N = int(input())
a = 0

for i in range(1, ceil(sqrt(N)) + 1):
    if N % i == 0:
        a = i

ans = (a - 1) + (N // a - 1)

print(ans)
# Judge status: Accepted
import math
a,b=map(int,input().split())
print (math.ceil((a+b)/2))
# Judge status: Accepted
N = int(input())
ans = 0
for n in range(1,N+1,2):
    d = set()
    m = 1
    while m*m <= n:
        if n%m==0:
            d.add(m)
            d.add(n//m)
        m += 1
    if len(d)==8:
        ans += 1
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
cs = [0]*9
for a in A:
    if a >= 3200:
        cs[8] += 1
    else:
        cs[a//400] += 1

fixed = 0
for i in range(8):
    if cs[i]: fixed += 1

if fixed:
    print(fixed, fixed + cs[8])
else:
    print(1, cs[8])
# Judge status: Wrong Answer
k = int(input())

ans = 1
cnt = 0
while cnt < k:
    # print(ans, cnt)
    if ans <= 9:
        cnt+=1
        ans+=1
        continue
    li = list(map(int, list(str(ans))))
    for i in range(len(li)-1):
        if abs(li[i]-li[i+1]) > 1:
            ans+=1
            break
        cnt+=1
        ans += 1
print(ans-1)
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
if k > b-a:
    k = b-a
print('\n'.join(map(str,sorted(set(range(a,a+k)) | set(range(b-k+1,b+1))))))
# Judge status: Accepted
x = int(input())
q, mod = divmod(x, 11)
if mod == 0:
    ans = q * 2
elif mod > 6:
    ans = q * 2 + 2
else:
    ans = q * 2 + 1
print(ans)
# Judge status: Accepted
N, M = map(int, input().split(" "))

li_a = list(map(int, input().split(" ")))
days = 0

for i in range(M):
  days += li_a[i]

if N >= days:
  print (N - days)
else:
  print(-1)
# Judge status: Accepted
y,m,d=map(int,input().split("/"))
if y<2019 or (y==2019 and (m<4 or (m==4 and d<=30))):
    print("Heisei")
else:print("TBD")
# Judge status: Accepted
n = int(input())

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

def dfs(s, cmax):
    if len(s) == n:
        print(s)
    else:
        for i in range(ord(cmax)-ord('a')+2):
            c = chr(i+ord('a'))
            if ord(c) < ord(cmax):
                dfs(s+c, cmax)
            else:
                dfs(s+c, c)

dfs('a', 'a')
# Judge status: Wrong Answer
from math import ceil

n, k = map(int, input().split())
a = list(map(int, input().split()))
idx = a.index(1)
if idx == 0:
    print(ceil(len(a[(idx + 1):]) / (k - 1)))
elif idx == (n - 1):
    print(ceil(len(a[:idx]) / (k - 1)))
else:
    print((ceil(len(a[:idx]) / (k - 1))) + (ceil(len(a[(idx + 1):]) / (k - 1))))
# Judge status: Wrong Answer
nb = int(input())
somme = 0
mmax = 0
for loop in range(nb):
  n,m = map(int,input().split())
  somme+=n
  if m>mmax:
    mmax = m
if somme<=mmax:
  print("yes")
else:
  print("no")
# Judge status: Accepted
import itertools

n = int(input())

alpha_list = ['a','b','c','d','e','f','g','h','i','j']
string_list = []
count = 0

def extend(string,count,n):
    if len(string) >= n:
        string_list.append(string)
        return True
    else:
        for i in range(count+1):
            sc = string
            sc += alpha_list[i]
            if i == count:
                count += 1
            extend(sc,count,n)
    
extend('',count,n)

string_list.sort()
for s in string_list:
    print(s)
# Judge status: Wrong Answer
S = input()
for i in range(9):
    i = i +1
    hikaku = i*10+i
    #print(hikaku)
    if (str(hikaku) in S) == True:
        result = "Bad"
        break
    else:
        result = "Good"
print(result)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
b=reversed(b)
c=[]
for i in b:
  if a.count(i)>=2:
    c+=[i]
    if len(c)==2:
      break
if len(c)<=1:
  print(0)
else:
  print(c[0]*c[1])
# Judge status: Accepted
n = int(input())
flag = True
for a in map(int, input().split()):
  if a % 2 == 0 and a % 3 != 0 and a % 5 != 0:
    flag = False
    break
if flag:
  print('APPROVED')
else:
  print('DENIED')
# Judge status: Accepted
S = int(input())

v = 10**9
a = (v-S%v)%v
b = (S+a)//v

print(0, 0, 10**9, 1, a, b)
# Judge status: Accepted
s=input();a=list(map(int,input().split()));ans=0
mean=round(sum(a)/len(a))

for i in a:
  p=(i-mean)**2
  ans+=p
  
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
if a > 0:
    print("Positive")
elif b < 0:
    if abs(a-b)%2 == 0:
        print("Negative")
    else:
        print("Positive")
else:
    print("Zero")
# Judge status: Wrong Answer
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    mi = 0
    le = len(a)
    cost = 0
    for i in range(le-1):
        if a[i] > a[i+1]:
            mi = max(a[i], mi)
            cost += mi - a[i+1]
    print(cost)
    return 0

if __name__ == "__main__":
    solve()
# Judge status: Accepted
import math

n=int(input())

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

L=[0]

for i in range(n):
  L.append(math.gcd(L[i],a[i]))

R=[0]
for i in range(n):
  R.append(math.gcd(R[i],a[n-1-i]))

ans=1
for i in range(n):
  ans=max(ans,math.gcd(L[i],R[n-1-i]))

print(ans)
# Judge status: Wrong Answer
listA = []
A,B = list(map(int,input().split()))
for i in range(B-A+1,B+1):
    listA.append(i)
for i in range(B+1,B+A):
    listA.append(i)
print(listA)
# Judge status: Wrong Answer
S = list(input())
for i in range(0,len(S),2):
  if S[i] == 'R':
    print('No')
    exit()
for j in range(1,len(S),2):
  if S[j] == 'L':
    print('NO')
    exit()
print('Yes')
# Judge status: Accepted
N, A, B = map(int,input().split())
lst_1 = []
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

sub = [k for k in range(1,N+1)]

for j in sub:
    if A <= digitSum(j) <= B:
        lst_1.append(j)
print(sum(lst_1))
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))
print("Yes" if len([i for i in a if i/sum(a) >= 1/(4 * m)]) >= m else "No")
# Judge status: Accepted
n,k= map(int, input().split())

li=[0]*n
for i in range(k):
        d=int(input())
        lis = list(map(int,input().split()))
        for j in range(len(lis)):
                li[lis[j]-1]+=1
        lis.clear
cnt=0
for i in range(len(li)):
        if li[i]==0:
                cnt+=1

print(cnt)
# Judge status: Accepted
N=int(input())
*H,=map(int,input().split())


i=0
cnt=0
ans=0
while i < N-1:
    if 1<=H[i]/H[i+1]:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
    i+=1
ans=max(ans,cnt)
print(ans)
# Judge status: Wrong Answer
n = (int(input()))
sum = 0
for i in range(n):
  if not((i+1)%3 == 0 or (i+1)%5 == 0):
    sum += i+1
    print(i+1)
print(sum)
# Judge status: Wrong Answer
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
res = 0
for a in A:
    if a > X:
        break
    res += 1
    X -= a
if X > 0:
    res -= 1
print(max(res, 0))
# Judge status: Wrong Answer
import math
n = int(input())
ab = []
ans = 0

def prime(x):
    cbn, ct = 0, 0
    l2 = int(math.sqrt(x))
    for i in range(1, l2+1):
        if x % i == 0:
            ab.append([i, int(x/i)])
            ct += 2
            if ab[-1][0] == ab[-1][1]:
                ct -= 1
        cbn += ct
        ct = 0
    return cbn

for c in range(1, n):
    print(c)
    ans += prime(n-c)
print(ans)
# Judge status: Accepted
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = list(map(str,input().split()))
    print("A"+s[1][0]+"C")

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n, m = map(int, input().split())
h = list(map(int, input().split()))

flag = [True] * n
for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        flag[b-1] = False
    elif h[b-1] > h[a-1]:
        flag[a-1] = False


cnt = 0
for i in flag:
    if i:
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
k = ['R','U','D']
g = ['L','U','D']

s = input()
for i in range(len(s)):
  if s[i] == 'U' or s[i] == 'D':
    continue
  else:
    if i%2 == 0:
      if s[i] != 'L':
        print("No")
        exit()
    else:
      if s[i] != 'R':
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
moji = str(input())
if int(moji[0:4]) < 2019:
  print("Heisei")
elif int(moji[0:4]) == 2019:
  if int(moji[6:7])<=4:
    print("Heisei")
  else:
    print("TBD")
else:
  print("TBD")
# Judge status: Accepted
A, B, C, K = map(int, input().split())
print(A-B if K%2 == 0 else B-A)
# Judge status: Wrong Answer
W,H,x,y = map(int, input().split())
flg = 0
if 2*x==W or 2*y==H:
    flg = 1
res = [W*H/2, flg]
print(*res)
# Judge status: Wrong Answer
N=int(input())
S=input()
if S[0:N//2-1]==S[N//2:-1]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a, b, c = map(int, input().split())
if a+b == c or b+c == a or c+a == b:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import itertools
import math

n=int(input())
town=[0]*n
for i in range(n):
    town[i]=tuple(map(int,input().split(' ')))

sum_len=0
now=[0,0]

permu = itertools.permutations([i for i in range(n)])
for case in permu:
    now = town[case[0]]
    for i in case[1:]:
        sum_len += ((now[0]-town[i][0])**2 + (now[1]-town[i][1])**2)**(1/2)
        now = town[i]
print(sum_len/math.factorial(n))
# Judge status: Wrong Answer
n,*x=map(int,open(0).read().split());a=0;t=1
for i in sorted(x):a+=t*i;t*=-1
print(a)
# Judge status: Wrong Answer
N=int(input())
for i in range(0,11000,1000):
  if N<=i:
    print(int(i-N))
# Judge status: Accepted
a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

m=(b-a-1)*(b-a)/2

print(int(m-a))
# Judge status: Wrong Answer
def LI(): return list(map(int, input().split()))


A,B,C = LI()
print(max([A,B,C])*10+B+C)
# Judge status: Accepted
a,b=map(int,input().split())
if a>b:
    print(a*2-1)
elif a==b:
    print(a*2)
else:
    print(b*2-1)
# Judge status: Accepted
a, b, c = map(int, input().split())
print(max(a*10+b+c, b*10+c+a, c*10+a+b))
# Judge status: Accepted
n, m = map(int, input().split())

mod = 1000000007

from collections import deque

d = deque()

for _ in range(m):
    d.append(int(input()))

old = 0
new = 1

for i in range(1, n+1):
    if len(d):
        if i != d[0]:
            old, new = new, (old+new) % mod
        else:
            old, new = new, 0
            d.popleft()
    else:
        old, new = new, (old+new) % mod



print(new)
# Judge status: Accepted
N = int(input())
ls = []
for i in range(N,1000):
  if i % 111 == 0:
    ls.append(i)
print(ls[0])
# Judge status: Wrong Answer
a = int(input())
ans = (a+a*2+a*3)//1
print(ans)
# Judge status: Accepted
a, b = input().split()
s = int(a + b)

is_ok = False
for i in range(1, 1000):
    if i * i == s:
        is_ok = True
        break

print("Yes" if is_ok else "No")
# Judge status: Accepted
x, y = map(int, input().split())

ans = 10**18
if x <= y:
    ans = min(y - x, ans)
if -x <= y:
    ans = min(y - (-x) + 1, ans)
if x <= -y:
    ans = min((-y) - x + 1, ans)
if -x <= -y:
    ans = min((-y) - (-x) + 2, ans)
print(ans)
# Judge status: Accepted


def solve():

    N, K = map(int, input().split())
    hlist = [int(input()) for i in range(N)]

    # sortして走破？
    hlist.sort()
    l = []

    for i in range(N-K+1):
        l.append(hlist[i+K-1]-hlist[i])

    print(min(l))


if __name__ == "__main__":
    solve()
# Judge status: Accepted
N, M = map(int, input().split())

red = [0]*N
red[0] = 1

q = [1]*N

for _ in range(M):
    x, y = map(int, input().split())
    red[y-1] |= red[x-1]
    q[x-1] -= 1
    q[y-1] += 1
    if q[x-1] == 0:
        red[x-1] = 0

print(sum([1 for i in range(N) if q[i]>0 and red[i]]))
# Judge status: Accepted
#ABC056

x = int(input())

for i in range(10 ** 6):
    if i * (i - 1) // 2 < x <= i * (i + 1) // 2:
        print(i)
        break
# Judge status: Accepted
a=int(input())

b=a+a*a+a*a*a

print(b)
# Judge status: Accepted
import re
s = input().replace("?",".")
t = input()
for i in range(len(s)-len(t),-1,-1):
  if re.match(s[i:i+len(t)],t):
    s = s.replace(".","a")
    print(s[:i]+t+s[i+len(t):])
    exit()
print("UNRESTORABLE")
# Judge status: Accepted
n = int(input())

# ぜんぶ
a = 10 ** n
# 0が存在しない
b = 9 ** n
# 9が存在しない
c = 9 ** n
# 0も9も存在しない
d = 8 ** n

ans = a - b - c + d

print(ans % 1000000007)
# Judge status: Accepted
import sys
from heapq import heappop, heappush

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

N, M = lr()
works = [[] for _ in range(M+1)]
# M-1日後から選んでいく,
for _ in range(N):
    a, b = lr()
    if a <= M:
        works[a].append(-b)

heap = []
answer = 0
for work in works:
    for x in work:
        heappush(heap, x)
    if heap:
        answer -= heappop(heap) # heap構造なので

print(answer)
# 08
# Judge status: Accepted
S = input()
list_S = [int(x) for x in S]

N = len(S)
if N % 2 == 0:
  op1 = [0, 1] * int(N//2)
  op2 = [1, 0] * int(N//2)
else:
  op1 = [0, 1] * int(N//2) + [0]
  op2 = [1, 0] * int(N//2) + [1]
  
cnt_op1 = 0
cnt_op2 = 0
for i in range(N):
  if list_S[i] != op1[i]:
    cnt_op1 += 1
  if list_S[i] != op2[i]:
    cnt_op2 += 1

print(min(cnt_op1, cnt_op2))
# Judge status: Accepted
x,y = map(int,input().split())

cand = [x]

while(cand[-1]*2<=y) :
    cand.append(cand[-1]*2)

print(len(cand))
# Judge status: Accepted
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

cnt = 0
sum_x = 0
for i in range(N):
  if(i == N-1):
    if((x-sum_x) == A[N-1]):
      cnt += 1
    break
  
  if(sum_x+A[i] <= x):
    sum_x += A[i]
    cnt += 1
  else:
    break
   
    
print(cnt)
# Judge status: Accepted
h = int(input())

def solve(n):
  if n == 1:
    return 1
  else:
    return 1 + 2 * solve(n//2)

print(solve(h))
# Judge status: Accepted
n = int(input())
A = list(input().split())
if n % 2:
    print(" ".join(A[::2][::-1]), " ".join(A[1::2]))
else:
    print(" ".join(A[1::2][::-1]), " ".join(A[::2]))
# Judge status: Accepted
n, m = map(int,input().split())
ans = 0
if n*2 > m:
  if m%2 == 0:
    ans = m//2
  else:
    ans = (m-1)//2
else:
  ans += n
  m -= n*2
  ans += m//4
print(ans)
# Judge status: Wrong Answer
a=input()
b=input()
count=0
for str_i in range (len(a)):
  if a[str_i:] != b[str_i:]:
    count+=1
print(count)
# Judge status: Accepted
import math
a, b, c = map(int, input().split())

if 4 * a * b >= (c - b - a) ** 2 or c - b - a < 0:
    ans = "No"
else:
    ans = "Yes"


print(ans)
# Judge status: Accepted
n=int(input())

dp=list(map(int,input().split()))
for day in range(1,n):
    m=[0]*3
    day_points=list(map(int, input().split()))
    for i in range(3):
        for j in range(3):
            if i!=j:
                 m[i]=max(m[i],day_points[i]+dp[j])
    dp=m
print(max(dp))
# Judge status: Accepted
a,b = input().split()
a_int = int(a)
b_int = int(b)
ab = a*b_int
ba = b*a_int
if ab >= ba:
    print(ba)
elif ab <= ba:
    print(ab)
# Judge status: Accepted
from math import floor
from decimal import Decimal

A, B = map(Decimal, input().split())
print(floor(A * B))
# Judge status: Wrong Answer
from bisect import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A_count = [0] * len(A)
B_count = [0] * len(B)
for i in range(len(B)):
    B_count[i] = len(C) - bisect(C, B[i])
for i in range(len(A)):
    A_count[i] = sum(B_count[bisect(B, A[i]):])
print(sum(A_count))
# Judge status: Accepted
A,B,M = map(int,input().split())
rei = list(map(int,input().split()))
ren = list(map(int,input().split()))
rrw = []
for i in range(M):
    rrw.append(list(map(int,input().split())))
saiyasu = min(rei) + min(ren)
for j in range(M):
    onedan = rei[(rrw[j][0])-1] + ren[rrw[j][1]-1] - rrw[j][2]
    if onedan < saiyasu:
        saiyasu = onedan

print(saiyasu)
# Judge status: Accepted
n = int(input())
cmax = 100 // 4
dmax = 100 // 7
for i in range(0, cmax + 1):
    for j in range(0, dmax + 1):
        if i * 4 + j * 7 == n:
            print("Yes")
            exit()
print("No")