Problem:


Score : 300 points

Problem Statement

How many integer sequences A_1,A_2,\ldots,A_N of length N satisfy all of the following conditions?

0 \leq A_i \leq 9

There exists some i such that A_i=0 holds.

There exists some i such that A_i=9 holds.

The answer can be very large, so output it modulo 10^9 + 7.

Constraints

1 \leq N \leq 10^6

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer modulo 10^9 + 7.

Sample Input 1

2

Sample Output 1

2

Two sequences \{0,9\} and \{9,0\} satisfy all conditions.

Sample Input 2

1

Sample Output 2

0

Sample Input 3

869121

Sample Output 3

2511445



Sample input:
2


Sample output:
2

Submission status: Accepted

Solution code:
n=int(input())
m=10**9+7
if n==1:
  print(0)
  exit()
ans=0
ans=10**n-2*9**n+8**n
print(ans%m)

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from decimal import *

n = int(input())
d = 1000000007

if 2 < n:
    #ans = (10 ** n - 8 ** n) - (9 ** n - 8 ** n) * 2
    a = 10 ** n
    a %= d
    b = 9 ** n
    b %= d
    c = 8 ** n
    c %= d
    ans = a + c - b * 2
    ans %= d
elif n == 2:
    ans = 2
else:
    ans = 0
print(ans)

Submission status: Accepted

Solution code:
m = 1000000000+7
from scipy.special import comb

n = int(input())

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

ans = pow(10,n) - (2 * pow(9,n) - pow(8,n))
ans %= m

print(ans)

Submission status: Accepted

Solution code:
""" C
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

M = 1000000007

def _pow(n, m):
    ret = 1
    for _ in range(m):
        ret = (ret * n) % M
    return ret

def main(N):
    return (_pow(10, N) - 2 * _pow(9, N) + _pow(8, N)) % M

if __name__ == "__main__":
    _N = readInteger()

    print(main(_N))

Submission status: Accepted

Solution code:
N = int(input())

a = 10 ** N - (9 ** N) * 2 + 8 ** N
print(a % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
N =int(input())

count = pow(10, N) - 2 * pow(9, N) + pow(8, N)
print(count % (1000000007))

Submission status: Accepted

Solution code:
m=10**9+7
def power(a,b):
    res=1
    while(b>0):
        if(b&1):
            res=(res*a)%m
        b//=2
        a=(a*a)%m
    return res
n=int(input())
s=(power(10,n)+power(8,n))%(10**9+7)
s=(s-(2*power(9,n)))%(10**9+7)
print((s))

Submission status: Accepted

Solution code:
N = int(input())

# 0 <= A_i <= 9
# 「あるi, jがあって A_i=0 かつ A_j=9」
# 排反事象を取ると：
# 全体 - 「全てのiで A_i != 0 または A_i != 9」
# 「全てのiで A_i != 0 または A_i != 9」はベン図で考えると：
# 「全てのiで A_i = {0,1,2,3,4,5,6,7,8}」+「全てのiで A_i = {1,2,3,4,5,6,7,8,9}」-「全てのiで A_i = {1,2,3,4,5,6,7,8}」
# 以上から、求める値は：10^N - 2*9^N + 8^N
ans = 10**N - 2*9**N + 8**N
ans %= 10**9+7

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = (10**N+8**N-2*(9**N))%((10**9)+7)
print(a)

Submission status: Accepted

Solution code:
n = int(input())

if (n == 1):
	res = 0
else:
	res = (10 ** n - 9 ** n * 2 + 8 ** n) % 1000000007

print(str(res))
#	f(x) = 10^n - 9^n * 2 + 8^n

Submission status: Accepted

Solution code:
N = int(input())

ans = (10**N-2*9**N+8**N)%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

ans = (10 ** N) - (9 ** N + (9 ** N - 8 ** N))
ans %= (10 ** 9 + 7)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
all = 10 ** n
o0q0 = 8 ** n
o0q1 = 9 ** n - o0q0
mod = 10 ** 9 + 7
a = (all - (o0q1 * 2) -o0q0) % mod
print(a)

Submission status: Accepted

Solution code:
n = int(input())
mod = 1000000007
anss = 10**n - 9**n - 9**n + 8**n
print(anss%mod)

Submission status: Accepted

Solution code:
n = int(input())

mod = 1000000000 + 7
ans = 10 ** n
hoge = 8 ** n
fuga = 9 ** n

ans = ans - hoge - (fuga - hoge) * 2
ans = ans % mod
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    import math
    n = int(input())
    if n <= 1:
        print(0)
        return
    elif n == 2:
        print(2)
        return
    print((10**n - 2 * (9**n) + 8**n) % (10**9 + 7))

resolve()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    MODULO = 10**9 + 7
    N = int(input())
    res = 2 * pow(9, N, MODULO)#(9*9) % MODULO
    res = (pow(10,N, MODULO) + pow(8, N, MODULO) - res) % MODULO# (res * pow(10, N-2, MODULO)) % MODULO
    # for i in range(N-2):
    #     res = (res * 10) % MODULO
    print(res)

Submission status: Accepted

Solution code:
m = 1000000007
 
factorials = [1]
 
for i in range(1,1000001):
    factorials.append((factorials[-1]*i) % m)
 
n = int(input())
 
if n == 1:
    print(0)
else:
    temp = pow(10,n,m) - (2*pow(9,n,m) - pow(8,n,m))
    print(temp % m)

Submission status: Accepted

Solution code:
n = int(input())
mod = 10**9+7

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    facs = [1] * (n+1)
    invs = [1] * (n+1)
    nfac = 1
    for i in range(1, n+1):
        nfac = nfac * i % mod
        facs[i] = nfac
        invs[i] = pow(facs[i], mod-2, mod)

    d = 0
    comb = 1
    p = 1
    for i in range(0, n):
        # nCi
        comb = facs[n] * invs[i] * invs[n-i]%mod
        d = (d + comb*p%mod) % mod
        p *= 8
        p %= mod

    # {1~8}のみで構成されるパターン
    diff = (pow(10, n, mod) - pow(8, n, mod)) % mod
    diff = (diff - (2*d%mod)) % mod
    print(diff)

Submission status: Accepted

Solution code:
def resolve():
    n=int(input())
    d=10**9+7
    m=len(bin(n))-2
    a=[(n >> j) & 1 for j in range(m)]
    ansten=1
    anshati=1
    anskyu=1
    for i in range(m):
        ten = 10
        hati = 8
        kyu=9
        if a[i]==1:
            for j in range(i):
                ten=ten*ten
                hati=hati*hati
                kyu=kyu*kyu
                ten=ten%d
                hati=hati%d
                kyu=kyu%d
            ansten*=ten
            anshati*=hati
            anskyu*=kyu
            ansten=ansten%d
            anshati=anshati%d
            anskyu=anskyu%d
    print((ansten-2*anskyu+anshati)%d)
resolve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right
def mcomb(n, k, mod):
    def mfac(l, r, mod):
        ans = l
        for i in reversed(range(r, l)):
            ans *= i
            ans %= mod
        return ans

    A = mfac(n,n-k+1,mod)
    B = mfac(k,1,mod)
    # B = mpow(B,mod-2,mod)
    B = pow(B, mod-2, mod)
    return A * B % mod

def solve():
    N = II()
    MOD = 1000000007
    if N == 1:
        print(0)
        return
    # print(pow(9, N), pow(8, N))
    # print(pow(10, N), 2 * pow(9, N) - pow(8, N))
    ans = pow(10, N, MOD) - ((2 * pow(9, N, MOD)) % MOD - pow(8, N, MOD)) % MOD
    print(ans % MOD)

    
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n=int(input())

if n<2:
    print(0)
    exit()

mod = 10**9+7

ans=(pow(10,n,mod)-pow(9,n,mod)*2+pow(8,n,mod))%mod
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

n10 = 1
n8 = 1
n9 = 1
beki = N
while beki>4:
    n10 = (n10*(10**5))%(10**9+7)
    beki -= 5  
n10 = (n10*(10**beki))%(10**9+7)
beki = N
while beki>4:
    n8 = (n8*(8**5))%(10**9+7)
    beki -= 5  
n8 = (n8*(8**beki))%(10**9+7)
beki = N
while beki>4:
    n9 = (n9*(9**5))%(10**9+7)
    beki -= 5  
n9 = (n9*(9**beki))%(10**9+7)

print((n10-2*n9+n8)%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())

MOD = 10 ** 9 + 7

print( (10 ** n - (2 * ( 9 ** n) - (8 ** n))) % MOD )

Submission status: Accepted

Solution code:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

print((pow(10,n,mod)-2*pow(9,n,mod)+pow(8,n,mod))%mod)

Submission status: Accepted

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


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

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    print((pow(10, n) - (pow(9, n) + pow(9, n) - pow(8, n))) % mod)
    # print((pow(n, 10) - (pow(n, 9) + pow(n, 9) - pow(n, 8))) % mod)
    # ans = 0
    # now = 0
    # for i in range(n):

    #     for j in range(10):


# def pow(n, num):
#     s = num
#     for i in range(1, n):
#         s = s * num % mod
#     return s

def pow(a, n):
    x = 1
    while n > 0:
        if(n & 1):
            x *= a
        a = a*a
        n >>= 1
    return x


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
N = int(input())

if N == 1:
    print(0)
    sys.exit(0)

if N == 2:
    print(2)
    sys.exit(0)

# out = (N * (N - 1) * (10 ** (N - 2))) % ((10 ** 9) + 7)
out = ((10 ** N) - ((9 ** N) * 2 - (8 ** N))) % ((10 ** 9) + 7)
print(out)

Submission status: Accepted

Solution code:
n = int(input())

a = 10**n % (10**9+7)
b = 8**n % (10**9+7)
c = 9**n % (10**9+7)

x = b + a - 2*c

print(x % (10**9+7))

Submission status: Accepted

Solution code:
n = int(input())

print((10 ** n - 8 ** n - ((9 ** n - 8 ** n) * 2)) % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
n = int(input())

count = 10**n-2*(9**n)+8**n
count = count%1000000007

print(count)

Submission status: Accepted

Solution code:
N = int(input())

ans = (10**N - ((9**N - 8**N) *2 + 8**N)) % (10**9 + 7)
print(ans)

Submission status: Accepted

Solution code:
import math

N = int(input())

count = 0

only = 8**N
one = 2 * (9**N - only)
#print(only)
#print(one)

count = 10**N - only - one

ans = count % (10**9 + 7)
print(ans)

Submission status: Accepted

Solution code:
def powmod(a,n,mod):
    ans = 1
    while n > 0:
        if n & 1:
            ans = ans * a % mod
        a = a ** 2 % mod 
        n >>= 1 
    return ans

N=int(input())
m=10**9+7
L=[powmod(10,N,m),powmod(9,N,m),powmod(9,N,m),powmod(8,N,m)]
A=(L[0]+L[3]-(L[1]+L[2]))%m
print(A)

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
  print(0)
  exit()
if N == 2:
  print(2)
  exit()
print((10**N - (9**N)*2 + 8**N)%(10**9+7))

Submission status: Accepted

Solution code:
N = int(input())
if N ==1:
  print(0)
else:
  A = (10**N)-2*(9**N)+(8**N)
  print(A%((10**9)+7))

Submission status: Accepted

Solution code:
n = int(input())
total = 1
total8 = 1
total9 = 1
MOD = 1000000007

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

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

for i in range(n):
    total *= 10
    total9 *= 9
    total8 *= 8
    total %= MOD
    total8 %= MOD
    total9 %= MOD


ans = total + total8 - (2 * total9) % MOD
if ans < 0:
    ans += MOD

print(ans)

Submission status: Accepted

Solution code:
n=int(input())

MOD = 10 ** 9 + 7

if n >= 2:
  result = 10**n%MOD - (2*9**n%MOD - 8**n%MOD)
elif n == 1:
  result = 0
else:
  result = 1
print(result%MOD)

Submission status: Accepted

Solution code:
N = int(input())
a = 2 * (10**(N) - 9**(N)) - (10**(N) - 8**(N))        
ans = a % (10**9+7)
print(ans)

Submission status: Accepted

Solution code:
INF = 10 ** 9 + 7
N = int(input())
a = 10**N
b = 9**N
c = 8**N
ans = a -(b + b - c)
ans = ans%INF
print(ans)

Submission status: Accepted

Solution code:
import sys

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

n = int(input())
if n == 1:
  print(0)
  sys.exit()

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
pow8 = [0]*(n+1)
pow8[0] = 1
pow8[1] =8

pow10=10

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    pow8[i] = (pow8[i-1]*8) % mod  
    pow10 =(pow10*10) % mod
ans = pow10 - pow8[n]
for i in range(1,n+1):
  ans = (ans - pow8[n-i]*2*cmb(n,i,mod)) % mod
               
print(ans)

Submission status: Accepted

Solution code:
MOD = 10**9 + 7
n = int(input())
if n == 1:
    print(0)
    exit()
print((pow(10,n,MOD)-pow(8,n,MOD)-pow(9,n,MOD)+pow(8,n,MOD)-pow(9,n,MOD)+pow(8,n,MOD))%MOD)

Submission status: Accepted

Solution code:
n = int(input())
n10 = 10 ** n
n9 = 9 ** n
n8 = 8 ** n
ans = n10 - 2 * n9 + n8
ans = ans % 1000000007
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
m = 10 ** 9 + 7
print((pow(10, n, m) + pow(8, n, m) - 2 * pow(9, n, m)) % m)

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())

    mod = (10 ** 9) +7

    ans = 0

    ans = pow(10,N,mod) - pow(8,N,mod) - (pow(9,N,mod) - pow(8,N,mod))*2

    ans %= mod

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
if(N>1):
    all = 2**N * ((5**N) + (4**N)) - 2 * (9**N)
else:
    all = 0
print(all % 1000000007)

Submission status: Accepted

Solution code:
n = int(input())

ten = [0]*20
nin = [0]*20
egt = [0]*20

for i in range(0,20):
    a = (10 ** (2**i)) % (10**9 +7)
    ten[i] = a

for i in range(0,20):
    a = (9 ** (2**i)) % (10**9 +7)
    nin[i] = a

for i in range(0,20):
    a = (8 ** (2**i)) % (10**9 +7)
    egt[i] = a

l = bin(n)
m = len(l)
tens   = 1
nines  = 1
eights = 1
for i in range(0,m-2):
    if l[i+2] == '1':
        tens = (tens*ten[m-3-i])%(10**9 + 7)

for i in range(0,m-2):
    if l[i+2] == '1':
        nines = (nines*nin[m-3-i])%(10**9 + 7)

for i in range(0,m-2):
    if l[i+2] == '1':
        eights = (eights*egt[m-3-i])%(10**9 + 7)

ans = (tens - nines*2 + eights)%(10**9 + 7)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
m = 10**9 + 7
ans = 0

ans += pow(10,n,m)
ans += pow(8,n,m)
ans -= pow(9,n,m) *  2


print(ans%m)

Submission status: Accepted

Solution code:
import sys

N = int(input())
if N == 1:
    print(0)
    sys.exit()

p= (-2*9**N+8**N+10**N) % (10**9+7)
print(p)

Submission status: Accepted

Solution code:
def ubiq(N):
    if(N == 1):
        print("0")
    elif(N == 2):
        print("2")
    else:
        result = (10**N-(9**N)*2+8**N) % (10**9+7)
        print(result)

N = int(input())
ubiq(N)

Submission status: Accepted

Solution code:
N = int(input())

A = 10**N -(2*9**N-8**N)
ans = A%(10**9+7)

print(int(ans))

Submission status: Accepted

Solution code:
import math
MODINT = 1000000007
n = int(input())
print((10**n - 9**n*2 + 8**n)%MODINT)

Submission status: Accepted

Solution code:
n = int(input())

if n < 2:
    print(0)
    exit()

mod = 10**9+7

res = (pow(10, n, mod) - pow(9, n, mod) * 2 + pow(8, n, mod)) % mod
print(res)

Submission status: Accepted

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    mod = 10 ** 9 + 7
    print((pow(10, n) % mod - (2 * pow(9, n)) % mod + pow(8, n) % mod) % mod)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans = 10**N - 2*(9**N) + 8**N
ans = ans % (10**9+7)
print (ans)

Submission status: Accepted

Solution code:
n=int(input())
r=10**n-(2*9**n-8**n)

m=10**9+7
#print(m)
print(r%m)

Submission status: Accepted

Solution code:
N = int(input())
all = 10 ** N
not_0 = 9 ** N
not_9 = 9 ** N
not_09 = 8 ** N
ans = all - ((not_0+not_9) - not_09)

if N == 1:
  print(0)
else:
  div_num = (10**9) + 7
  print(ans % div_num)

Submission status: Accepted

Solution code:
x = int(input())
ans = 0

a = (10**x)%1000000007
b = (9**x)%1000000007
c = (8**x)%1000000007

d = ((a-b)*2)%1000000007
e = (a-c)%1000000007
ans = (d-e)%1000000007
print(ans)

Submission status: Accepted

Solution code:
"""
task statement
==============

長さ N の整数の列 A_1,A_2,\ldots,A_N であって以下の条件をすべて満たすものはいくつありますか。

0 \leq A_i \leq 9
A_i=0 なる i が存在する。
A_i=9 なる i が存在する。

ただし、答えはとても大きくなる可能性があるので、10^9+7 で割った余りを出力してください。

io_style
-------
N
"""
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    if n == 1:
        print(0)
        return
    MOD = 10**9 + 7
    ans = pow(10, n, MOD) - pow(9, n, MOD) - pow(9, n, MOD) + pow(8, n, MOD)
    print(ans % MOD)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
m = 7 + 10**9
t = 10 ** n + 8 ** n - (9**n) * 2
print(t%m)

Submission status: Accepted

Solution code:
N = int(input())

MOD = 10**9+7
if N == 1:
    print(0)
    exit()

def power_func(a,n,p):
    bi = str(format(n,"b"))
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

a = power_func(10, N, MOD)
b = power_func(8, N, MOD)
c = power_func(9, N, MOD)
print((a+b-2*c)%MOD)

Submission status: Accepted

Solution code:
N=int(input())

if N<2:
    print(0)
    exit()

MOD = 10**9+7 
res=(pow(10,N,MOD)-pow(9,N,MOD)*2+pow(8,N,MOD))%MOD
print(res)

Submission status: Accepted

Solution code:
N = int(input())
mod = 10 ** 9 + 7

combi_all = 10 ** N
not0 = 9 ** N
not9 = 9 ** N
not09 = 8 ** N
ans = combi_all - not0 - not9 + not09

if ans >= mod:
  print(int(ans % mod))
else:
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())

mod = 1000000007

def modpow(a, n, mod):
    res = 1
    while (n>0):
        if (n & 1):
            res = res*a%mod
        a = a*a%mod
        n = n >> 1
    return res

temp10 = modpow(10,N,mod)
temp9 = modpow(9,N,mod)
temp8 = modpow(8,N,mod)

ans = (temp10-temp9+mod)%mod
ans = (ans-temp9+mod)%mod
ans = (ans+temp8+mod)%mod

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n < 2:
    print('0')
elif n == 2:
    print('2')
else:

    zero = 10 ** n - 9 ** n
    nine = 10 ** n - 9 ** n
    zq = 10 ** n - 8 ** n
    ans = zero + nine - zq
    print(ans % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
f = []
def precompute():
    f.append(1)
    for i in range(1,10**6+1):
        f.append((f[i-1]*i)%m)
def ncr(n,r):
    return f[n]*pow(f[n-r],m-2,m)*pow(f[r],m-2,m)
    
n,m = int(input()),int(1e9+7)
precompute()
x = pow(10,n,m)%m
y = pow(8,n,m)%m
z = 1
for i in range(1,n):
    z += ncr(n,i)*pow(8,n-i,m)
print((x-(y+z+z))%m)

Submission status: Accepted

Solution code:
N=int(input())
if N==1:
    print(0)
elif N==2:
    print(2)
else:
    print((10**N-9**N-9**N+8**N)%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())
MOD = pow(10, 9) + 7

ans = pow(10, n, MOD)
ans -= 2 * pow(9, n, MOD)
ans += pow(8, n, MOD)

print(ans % MOD)

Submission status: Accepted

Solution code:
n=int(input())
print((10**n+8**n-(9**n)*2)%(10**9+7))

Submission status: Accepted

Solution code:
N = int(input())
F = 10 ** 9 + 7
ans = 0
ans = 10 ** N % F
ans -= int((2 * 9 ** N) % F)
ans += int((8 ** N) % F)
ans = int(ans % F)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from math import factorial

n = int(input())
mod = 10**9+7

# if n == 1
# fac = [1]
# for i in range(2, n+2):
#     fac.append(fac[-1]*i % mod)

tens = [1]
for i in range(1, n+2):
    tens.append(tens[-1]*10 % mod)
nines = [1]
for i in range(1, n+2):
    nines.append(nines[-1]*9 % mod)
eights = [1]
for i in range(1, n+2):
    eights.append(eights[-1]*8 % mod)


# ans = 10**n - 8**n - (9**n-8**n)*2
ans = tens[n] - eights[n] - (nines[n]-eights[n])*2


print(ans % mod)

Submission status: Accepted

Solution code:
import math
MOD = 10**9 + 7

def mod_pow(x, mod):
    xx = [1, x]
    def _pow(y, x=x):
        nonlocal xx
        if y == 0:
            return 1
        while len(xx) <= math.log(y, 2)+1:
            v = xx[-1] * xx[-1]
            v %= mod
            xx.append(v)
        i = 1
        result = 1
        while y > 0:
            if y % 2 == 1:
                result *= xx[i]
                result %= mod
            y = y >> 1
            i += 1
        return result
    return _pow

pow10 = mod_pow(10, MOD)
pow9 = mod_pow(9, MOD)
pow8 = mod_pow(8, MOD)

def f(n):
    ans = pow10(n) - (2 * pow9(n) - pow8(n))
    ans %= MOD
    return ans


def main():
    N = int(input())
    ans = f(N)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
w = 1000000007

if(n == 1):
  print(0)
  exit()
if(n == 2):
  print(2)
  exit()
  
ans1 = 1


for i in range(n):
  ans1 = ans1*10%w
  
ans2 = 2

for i in range(n):
  ans2 = ans2*9%w
  
ans3 = 1

for i in range(n):
  ans3 = ans3*8%w

ans = ans1-ans2+ans3
ans %= w
ans += w
ans %= w

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
mod = (10**9)+7
n_all = 10**(n) % mod
bad_0 = 9**(n)%mod
bad_9 = 9**(n)%mod
bad_18 = 8**(n)%mod

print((n_all-bad_0-bad_9+bad_18)%mod)

Submission status: Accepted

Solution code:
N = int(input())
MOD = (10**9)+7

# 全体から0も9も含まない数を引く
result = ((10**N) - (8**N)) % MOD
result = (result - (((9**N) - ((8**N))) * 2)) % MOD

print(result)

Submission status: Accepted

Solution code:
x = int(input())

if x==1:
    print(0)
else:
    ans=(2*(10**x-9**x)-(10**x-8**x))%(10**9+7)
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

mod = int(1e9) + 7
res = pow(10, N) % mod

res -= pow(9, N) % mod
res %= mod

res -= pow(9, N) % mod
res %= mod

res += pow(8, N) % mod
res %= mod

print(res)

Submission status: Accepted

Solution code:
n = int(input())
if n > 1:
    print(((10**n) - (9**n * 2 - 8**n))%(10**9+7))
else:
    print("0")

Submission status: Accepted

Solution code:
n=int(input())
a=10**n-2*(9**n)+8**n
print(a%((10**9)+7))

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())

div=1000000007

loop=(n)//10
amari=(n)%10

mod1=1
mod2=1
mod3=1
for i in range(0,loop):
  mod1=(mod1*(10**10 % div) ) % div
  mod2=(mod2*(9**10 % div) ) % div
  mod3=(mod3*(8**10 % div) ) % div
mod1=mod1*(10**amari % div)
mod2=mod2*(9**amari % div)
mod3=mod3*(8**amari % div)

#print (loop, amari)
#print (mod1, mod2, mod3)
print((((mod1-mod2*2))+mod3) % div)

Submission status: Accepted

Solution code:
n=int(input())

mod=10**9+7

al=10**n
ex=8**n
a=9**n

x=al-ex

ans=x-(a-ex)*2

print(ans%mod)

Submission status: Accepted

Solution code:
n = int(input())

num1 = 10**n % (10**9 + 7)
num2 = (9**n * 2) % (10**9 + 7)
num3 = 8**n % (10**9 + 7)

print((num1 - num2 + num3) % (10**9 + 7))

Submission status: Accepted

Solution code:
MOD=10**9+7
lim=200000
inv_t = [-1 for i in range(lim+1)]
factrial = [-1 for i in range(lim+1)]
factrial_inv = [-1 for i in range(lim+1)]


def mod_inv(x, mod=MOD):
    y, u, v, _x = mod, 1, 0, x
    while y:
        t = _x//y
        _x -= t*y
        _x, y = y, _x
        u -= t*v
        u, v = v, u
    u %= mod
    if u < 0:
        u += mod
    return u

def mod_pow(a, n, mod=MOD):
    res = 1
    while n:
        if n & 1:
            res = res*a % mod
        a = a*a % mod
        n >>= 1
    return res

def COMinit(max=lim, mod=MOD):
    factrial[0] = factrial_inv[0] = 1
    factrial[1] = factrial_inv[1] = 1
    inv_t[0] = inv_t[1] = 1
    for i in range(2, max):
        factrial[i] = factrial[i-1]*i % mod
        inv_t[i] = -inv_t[mod % i]*(mod//i) % mod
        factrial_inv[i] = factrial_inv[i-1]*inv_t[i] % mod

def comb(a, b, mod=MOD):
    if a<b:
        return 0
    if factrial[0] == -1:
        COMinit()
    return (factrial[a]*factrial_inv[b]*factrial_inv[a-b]) % mod


n=int(input())
ans=mod_pow(10,n)

nine=mod_pow(9,n)
ei=mod_pow(8,n)


print((ans-ei-(nine-ei)*2)%MOD)

Submission status: Accepted

Solution code:
from math import factorial
import math
import itertools as it


def main():
    n = int(input())
    rem = pow(10, 9) + 7

    ans = pow(10, n) - (2*pow(9,n)) +pow(8,n)
    print(ans % rem)

    return


main()

Submission status: Accepted

Solution code:
n=int(input())
md=10**9+7
ft=[1,1]
for i in range(2,10**6+2):
  ft.append((i*ft[-1])%md)
def ncr(n,r,p=10**9+7):
  a=(ft[n])*((pow(ft[n-r],md-2,md)*pow(ft[r],md-2,md)))%md
  return a%md
if n==1:
  print(0)
else:
  an=pow(10,n,md)
  pan=1
  for i in range(1,n):
    pan+=(ncr(n,i)*pow(8,n-i,md))
  print((an-2*pan-pow(8,n,md))%md)

Submission status: Accepted

Solution code:
import math
n = int(input())
MOD = 1000000007
ans=(pow(10,n)+pow(8,n)-pow(9,n)*2)%MOD
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
MOD = 10**9 + 7

a10 = 1
a9 = 1
a8 = 1
for i in range(n):
    a10 *= 10
    a10 %= MOD
    a9 *= 9
    a9 %= MOD
    a8 *= 8
    a8 %= MOD
a98 = 2 * a9 - a8
if a98 < 0: a98 += MOD
ans = a10 - a98
if ans < 0: ans += MOD
ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

if __name__ == "__main__":
    N = int(input())
    mod = 1000000007
    def power_func(a,n,p):
        bi = str(format(n,"b"))#2進表現に
        res = 1
        for i in range(len(bi)):
            res = (res*res) %p
            if bi[i] == "1":
                res = (res*a) %p
        return res

    if N <= 1:
        print(0)
    elif N == 2:
        print(2)
    else:
        Ans = (power_func(10,N,mod) - 2 * power_func(9, N, mod) + power_func(8,N,mod))%mod
        print(Ans)

Submission status: Accepted

Solution code:
n = int(input())

def p(m, n):
    k = 1
    for i in range(n):
        k = (k * m) % (10**9 + 7)
    return k

x = p(10, n) - 2*p(9, n) + p(8, n)
while x < 0:
    x += 10 ** 9 + 7
if x == 10 ** 9 + 7:
    x = 0
print(x)

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print(0)
else:
    print(pow(pow(10,N) - pow(9,N) - pow(9,N) + pow(8,N), 1, 1000000007))

Submission status: Accepted

Solution code:
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x
            x = x ** 2
            n = (n - 1) // 2
        else:
            x = x ** 2
            n = n // 2

    return K * x


input_num = int(input())
divide_num = pow_k(10, 9) + 7

all_comb = pow_k(10, input_num)

zero_comb = pow_k(9, input_num) - pow_k(8, input_num)

else_comb = pow_k(8, input_num)

result_comb = all_comb - (zero_comb * 2 + else_comb)


print(result_comb % divide_num)

Submission status: Accepted

Solution code:
p = int(1e9)+7
N = int(input())
c = 1
for i in range(N):
    c = (c*10)%p
d = 1
for i in range(N):
    d = (d*9)%p
e = 1
for i in range(N):
    e = (e*8)%p
print((c-(d*2-e))%p)

Submission status: Accepted

Solution code:
n = int(input())
a = [1]*10000001 
b = [1]*10000001
c = [0]*(n+1)
answer = 0
for i in range(1000001):
  a[i+1] = (a[i]*9)%1000000007
for j in range(1000001):
  b[j+1] = (b[j]*8)%1000000007
if(n==1):
  print(0)
else:
  for k in range(2,n+1):
    c[k] = 2*a[k-1]-2*b[k-1]+10*c[k-1]
    c[k] = c[k]%1000000007
  print(c[n])

Submission status: Accepted

Solution code:
m=int(1e9+7)
n=int(input())
ans=pow(10,n,m)-2*pow(9,n,m)+pow(8,n,m)
print(ans%m)

Submission status: Accepted

Solution code:
n = int(input())
f10 = 1
f8 = 1
f9 = 2
for _ in range(n):
    f10 = (f10*10) % (1e9+7)
    f8 = (f8*8) % (1e9+7)
    f9 = (f9*9) % (1e9+7)
print(int((f10+f8-f9)%(1e9+7)))

Submission status: Accepted

Solution code:
n = int(input())

def fact(n):
    return n*(n-1)

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    ans = (10**n - 2*9**n + 8**n) % (10**9+7)        
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

x = (10**N)-(9**N)*2+(8**N)


y = (10**9)+7

print(x%y)

Submission status: Accepted

Solution code:
from math import *
N = int(input())
M = 0
mod = 10**9+7

if N==1:
  print(0)
elif N==2:
  print(2)
else:
  print((10**N-8**N-2*(9**N-8**N))%mod)

Submission status: Accepted

Solution code:
n = int(input())

ten = 10**n
nine = 9**n
eight = 8**n

n_zero = ten - nine #19
n_zn = eight #64

a = (ten - n_zero * 2 - n_zn)

if a < 0:
  a = -a

print(a % (10**9+7))

Submission status: Accepted

Solution code:
n = int(input())
a = 10**n + 8**n - 9**n*2
print(a % (10**9 + 7))

Submission status: Accepted

Solution code:
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
# import numpy as np


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

mod = 10 ** 9 + 7
a, b, c = 1, 1, 2
for i in range(N):
    a = a * 10 % mod
    b = b * 8 % mod
    c = c * 9 % mod

ans = (a + b - c) % mod

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
 
def add(a, b):
    mod = 10**9 + 7
    return (a + b) % mod
  
def mul(a, b):
    mod = 10**9 + 7
    return ((a % mod) * (b % mod)) % mod

def sub(a, b):
    mod = 10**9 + 7
    return (a + mod - b) % mod
  
def mypow(a, n, mod):
    val = 1
    for k in range(n):
        val = mul(val, a)
    return val

ans = add(mypow(10, N, mod=10**9+7), mypow(8,N, mod=10**9+7))
ans = sub(ans, mul(2, mypow(9, N, mod=10**9+7)))
print(ans)