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())
p = 10**9 + 7

def cmb(n, r, p):
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def pow(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

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, 10**6 + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    ans = 0
    powered_2 = pow(2, 1, p)
    for i in range(2, n + 1):
        powered_2 = powered_2 * 2 % p
        tryvalue = ((powered_2 - 2)*cmb(n, i, p)*pow(8, n-i, p))
        ans = (ans + tryvalue) % p
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
total = 10 ** N
no_9 = 9 ** N
no_0 = 9 ** N
no_0and9 = 8 ** N
print((total - (no_9 - no_0and9) - (no_0 - no_0and9) - no_0and9)%(10**9 + 7))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)

mod = 10 ** 9 + 7
def pow(a, n):
    if n == 0:
        return 1
    if n == 1:
        return a
    tmp = pow(a, n//2)
    tmp = (tmp * tmp) % mod
    if n % 2 == 1:
        tmp = (tmp * a) % mod
    return tmp

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

d_num = (10 ** 9) + 7

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

Submission status: Accepted

Solution code:
n = int(input())

def mod_k_n(k,n,default):
    r = []
    j = k
    while n > 1:
        if n % 2 == 1:
            r.append(j)
            n -= 1
        j = (j ** 2) % (10 ** 9 + 7)
        n = n // 2
    else:
        r.append(j)
        for s in r:
            default = (default * s) % (10 ** 9 + 7)
    return default
if n == 1:
  print(0)
else:
  ans = mod_k_n(10,n,1) - mod_k_n(9,n,2) + mod_k_n(8,n,1) + (10 ** 9 + 7)
  print(ans%(10 ** 9 + 7))

Submission status: Accepted

Solution code:
N = int(input())
MOD = 10**9+7
ans = 1
for i in range(N):
  ans*=10
  ans%=MOD
sub = 2
for i in range(N):
  sub*=9
  sub%=MOD
sub2 = 1
for i in range(N):
  sub2*=8
  sub2%=MOD
print((ans-(sub-sub2))%MOD)

Submission status: Accepted

Solution code:
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
  
n = int(input())
x = power_func(10, n, (10**9 + 7))
y = power_func(8, n, (10**9 + 7))
z = power_func(9, n, (10**9 + 7))
print((x + y - 2 * z) % (10**9 + 7))

Submission status: Accepted

Solution code:
N=int(input())
ans=0
NUM=7+10**9
if N==1: ans=0
else:
    a=10**N%NUM
    b=9**N%NUM
    b*=2
    c=8**N%NUM
    ans=a-b+c
    ans%=NUM
print(ans)

Submission status: Accepted

Solution code:
a = int(input())


x = 10 ** a 
y = 9 ** a
z = 9 ** a
q = 8 ** a

ans = ( x - y - z + q ) % (10 ** 9 + 7 )

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
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


n = int(input())

if n == 1:
    print(0)
else:
    r = modpow(10, n, 1000000007) - 2 * modpow(9, n, 1000000007) + modpow(8, n, 1000000007)
    print(r % 1000000007)

Submission status: Accepted

Solution code:
import sys
N= int(input())
if N==1:
    print(0)
    sys.exit()
if N>=2:
    a=10
    b=9
    c=8
    for i in range(N-1):
        a=a*10
        b=b*9
        c=c*8
        if a>(10**9+7):
            if b>(10**9+7):
                if c>(10**9+7):
                    a=a%(10**9+7)
                    b=b%(10**9+7)
                    c=c%(10**9+7)
s=(a-2*b+c)%(10**9+7)
print(s)

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7

n = int(input())

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

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

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

# 10 ^ n | 数列全体
#  9 ^ n | 0 を含まない数列全体
#  9 ^ n | 9 を含まない数列全体
#  8 ^ n | 0, 9 を含まない数列全体

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(x):
    return 10 ** x - 9 ** x - 9 ** x + 8 ** x


n = int(input())
if n == 1:
    print(0)
    exit()
elif n == 2:
    print(2)
    exit()

print(solve(n) % (10 ** 9 + 7))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

d = 1000000007
result = int(10 ** N) % d
result -= int(9 ** N) % d
result = result % d
result *= 2
result = result % d
result -= int(10 ** N) % d
result += int(8 ** N) % d

result = result if result >= 0 else d + result
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
n2=10**n
n3=8**n
n4=9**n
n5=n4-n3
print((n2-n3-n5-n5)%(10**9+7))

Submission status: Accepted

Solution code:
# // 2* nc2 * 10 **(n -2)
MOD = 10**9 + 7
def mpow(b,n):
    ## calculate 10 ^ n-2 mod 10**9 + 7

    # b = 10
    # n-=2
    ans = 1
    while n> 0:
        if n&1:
            ans = ans * b
            ans%= MOD
        b = b * b
        b%=MOD
        n>>=1 
    return ans



n = int(input())
# ans = (10**n) - 2*(9**n)+ 8**n
ans = mpow(10,n)
ans = ans - 2*(mpow(9,n))
if ans < 0:
    ans+=MOD
ans = ans+ mpow(8,n)
ans = ans%MOD
# print(ans%MOD)
print(ans)
# count = 0
# for i in range(10**(n)):
#     if ( '0' in str(i) or i < 10**(n-1) )and '9' in str(i):
#         count+=1
#         # print(i)
# print(count)
# count = 0
# for i in range(1000):
#     st  = '0'*(3-len(str(i))) + str(i)
#     if '0'  in st : #or '9' in st:
#         count+=1
#         print(st)


# print(count)

Submission status: Accepted

Solution code:
n=int(input())

k=1
mod=10**9+7
for i in range(n):
    k*=10
    k%=mod
l=1
m=1
for i in range(n):
    l*=9
    l%=mod
for i in range(n):
    m*=8
    m%=mod
a=k+m
a-=2*l
a%=mod
print(a)

Submission status: Accepted

Solution code:
import math
NN = int(input())

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


a = power_func(10, NN , 10 ** 9 + 7)
b = power_func(9 , NN , 10 ** 9 + 7)
c = power_func(8 , NN , 10 ** 9 + 7)

x = ((a - b - b + c) + 10 ** 9 + 7 + 10 ** 9 + 7 ) % (10 ** 9 + 7)
print(x)

Submission status: Accepted

Solution code:
import math
def solve():
	ret = 0
	n = int(input())
	val = 10**n-8**n
	val2= 10**n-9**n
	ret = val-(val-val2)*2
	#9's but no 0's

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

solve()

Submission status: Accepted

Solution code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np
import collections as col

N = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())
if N==1:
    print(0)
    exit(0)

MOD=10**9+7

a=1
b=1
c=1
for i in range(N):
    a=(a*10)%MOD
    b=(b*9)%MOD
    c=(c*8)%MOD

b*=2%MOD
if a+b-c>=0:
    print((a-b+c)%MOD)
else:
    print((a-b+c+MOD)%MOD)

Submission status: Accepted

Solution code:
n = int(input())
if n ==1:
  print(0)
  exit()
  
mod = 10**9 + 7  
c = 10**n + 8**n
d = 9**n + 9**n
print((c-d)%mod)

Submission status: Accepted

Solution code:
n = int(input())
if n == 1:
    print(0)
    exit()
ans1 = 1
ans2 = 1
ans3 = 1
for i in range(n):
    ans1 = (ans1*10)%1000000007
    ans2 = (ans2*9)%1000000007
    ans3 = (ans3*8)%1000000007

ans = (ans1 - ans2*2 + ans3)%1000000007

print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())
if N == 1:
    print(0)
    exit()
# print(((3**N  - 2**(N+1) + 1) / math.factorial(N)) % (10**9 + 7))
print(((10**N  - 9**(N) * 2 + 8**N)) % (10**9 + 7))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
mod = 10 ** 9 + 7
A = pow(10, N, mod)
B = pow(9, N, mod)
C = pow(8, N, mod)
A = A - (2 * B - C)
A %= mod
if A < 0:
  A = A + mod
print(A)

Submission status: Accepted

Solution code:
def solve():
    
    N = int(input())

    all = 10 ** N
    n9 = 9 ** N
    n0 = 9 ** N
    n0_9 = 8 ** N

    tmp_ans = all -(n9 + n0 - n0_9)

    ans = tmp_ans % ((10**9) + 7)

    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n = int(input())
ans = pow(10,n,1000000000+7)
x = pow(8,n,1000000000+7)
y = pow(9,n,1000000000+7)

ans = ans + x - 2*y
print(ans%(1000000000+7))

Submission status: Accepted

Solution code:
def div(n,T):
    tmp = 10 ** 9 + 7
    _ = 1
    for t in range( T- 1):
        _ *= n
        _ %= tmp
    return _ * n
    
N = int(input())
a = div(10,N)
b = div(9,N)
c = div(8,N)
print((a + c - b * 2) % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    a = input()
    a = int(a)
    # not(0and9)
    not_0and9 = 8**a
    # not0
    not_0 = 9**a
    # not9
    not_9 = 9**a
    # not
    not_n = not_0 + not_9 - not_0and9
    n = 10**a - not_n
    print(n%(10**9+7))

Submission status: Accepted

Solution code:
n=int(input())
ans=1
sub=1
sub2=1
for i in range(n):
    ans*=10
    ans%=(10**9+7)
    sub*=9
    sub%=(10**9+7)
    sub2*=8
    sub2%=(10**9+7)
ans-=2*sub-sub2
print(ans%(10**9+7))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

MOD = 1000000007

a  = 10**N-2*9**N+8**N

a = a % MOD

print(a)

Submission status: Accepted

Solution code:
n = int(input())
mod = pow(10, 9)+7
ans1 = 1
ans2 = 1
ans3 = 1
for i in range(n):
    ans1 = (ans1*10)%mod
    ans2 = (ans2*8)%mod
    ans3 = (ans3*9)%mod
print((ans1+ans2-ans3*2)%mod)

Submission status: Accepted

Solution code:
N = int(input())

if N == 1:
  print(0)
else:
  ALL = 10**N % (10**9 + 7)
  t = 2 * 9**N % (10**9 + 7)
  s = 8**N % (10**9 + 7)
  print((ALL - (t - s)) % (10**9 + 7))

Submission status: Accepted

Solution code:
n = int(input())

if n > 1:
    cnt = 10**n-2*9**n+8**n
    cst = 10**9+7
    print (cnt%cst)
else:
    print (0)

Submission status: Accepted

Solution code:
mod = 10**9 + 7

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

N = int(input())
ans = (modpow(10,N)-2*modpow(9,N)+modpow(8,N))%mod

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


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

def solve(N: int):
    if N==1:
        print(0)
    elif N==2:
        print(2)
    else :
        tmp=(power_func(10,N,MOD))+(power_func(8,N,MOD))
        tmp=tmp%MOD
        tmp2=(2*power_func(9,N,MOD))%MOD
        if tmp-tmp2<0:
            print(tmp-tmp2+MOD)
        else :
            print(tmp-tmp2)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = 1
b = 1
c = 1
for i in range(N):
  a = (a * 10) % (10 ** 9 + 7)
  b = (b * 9) % (10 ** 9 + 7)
  c = (c * 8) % (10 ** 9 + 7)
d = a - 2 * b + c
while d < 0:
  d += 10 ** 9 + 7
print(d)

Submission status: Accepted

Solution code:
N = int(input())
mod_num =int(1.0e+9+7)

all_num = pow(10,N,mod=mod_num)
not09_num = pow(9,N,mod=mod_num)
both09_num = pow(8,N,mod=mod_num)
print((all_num-not09_num*2+both09_num)%mod_num)

Submission status: Accepted

Solution code:
n=int(input())
mod=10**9+7
ans=0
temp1=1
temp2=1
temp3=pow(2,n,mod)
for i in range(n-1):
    ans+=(((temp1*temp2)%mod)*(temp3%mod-2))%mod
    temp1=((temp1*(n-i))*pow(i+1,mod-2,mod))%mod
    temp2=(temp2*8)%mod
    temp3=pow(2,n-i-1,mod)
    

print(ans%mod)

Submission status: Accepted

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



print(int((10**N-(2*9**N-8**N))%waru))

Submission status: Accepted

Solution code:
import sys
N=int(sys.stdin.readline().strip())
mod=10**9+7
print (pow(10,N,mod)-(pow(9,N,mod)*2-pow(8,N,mod)))%mod

Submission status: Accepted

Solution code:
MOD = 1000000007
def modpow(a, n, mod) :
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % mod        
        a = a * a % mod
        n = n // 2
    return ret

N = int(input())

ret1 = modpow(10,N,MOD) 
ret2 = modpow(8,N,MOD)
ret3 = modpow(9,N,MOD)
ret = (ret1 - ret3 - ret3 + ret2) % MOD
print(ret)

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  
  if n == 1: return 0
  if n == 2: return 2
  
  mod = 10**9 + 7

  n_10 = pow(10, n, mod)
  n_9 = pow(9, n, mod)
  n_8 = pow(8, n , mod)
  
  ans = (n_10 - 2*n_9 + n_8) % mod
  
  return ans
  
  
ans = main()
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

def solve(num, div):
    if num < 2:
        return 0
    if num == 2:
        return 2
    ans = 10 ** num - 2 * 9 ** num + 8 ** num
    return ans % div

num = int(input())
div = 10 ** 9 + 7
print(solve(num, div))

Submission status: Accepted

Solution code:
def pow_k(x, n,mod = 10**9+7):
    x %= mod
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K * x % mod

def solve(n,mod = 10**9+7):
    total = pow_k(10,n)
    not_include_0 = pow_k(9,n)
    not_include_9 = not_include_0
    not_include_0_and_9 = pow_k(8,n)
    return (total%mod-(not_include_0 + not_include_9 - not_include_0_and_9)%mod)%mod

def main():
    n = int(input())
    print(solve(n))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
mod = 1000000007

N = int(input())

A = 1
B = 1
C = 1
ans = 0

for _ in range(1,N+1):
  A *= 10
  A %= mod
  B *= 9
  B %= mod
  C *= 8
  C %= mod
  ans = A - (2*B - C)
  if ans < 0: ans += mod

if ans < 0: ans += mod

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

#a(1) : 0
#a(2) : 2
#a(3) : ( 3*10 - 2 ) * 2 - 2 = 54
#a(4) : 
  
#10**n - 8**n - 2*( 9**n - 8**n ) = 10**n - 2* (9**n) + 8**n

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

Submission status: Accepted

Solution code:
n = int(input())
MOD = 10**9 + 7
a = 1
b = 1
c = 1
for i in range(n):
    a *= 10
    b *= 9
    c *= 8
    a %= MOD
    b %= MOD
    c %= MOD
ans = (a - 2*b +c) % MOD
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7

N = int(input())
x = 10**N + 8**N - 2*9**N
print(x%MOD)

Submission status: Accepted

Solution code:
n = int(input())
p = 10**9 + 7
dp=[[0]*(2) for i in range(2)]
dp[0][0]=1

for i in range(n):
  nextDP = [[0]*(2) for i in range(2)]
  nextDP[1][1] += (dp[0][1] + dp[1][0] + dp[1][1] * 10) % p
  nextDP[1][0] += (dp[1][0] * 9 + dp[0][0]) % p
  nextDP[0][1] += (dp[0][1] * 9 + dp[0][0]) % p
  nextDP[0][0] += (dp[0][0] * 8) % p
  dp = nextDP
print(dp[1][1] % p)

Submission status: Accepted

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



  
if n == 1:
	ans = 0
else:
	cala = 10 ** n % MOD
	calb = 9 ** n % MOD
	calc = 8 ** n % MOD
	ans = (cala - calb*2 + calc) % MOD

     
print(ans)

Submission status: Accepted

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

ans = pow(10, N, M)
ans = ans + M - pow(9, N, M)
ans = ans + M - pow(9, N, M)
ans = ans + pow(8, N, M)
ans = ans % M
print(ans)

Submission status: Accepted

Solution code:
from scipy.special import comb
def main():
    n = int(input())
    # sum = 0
    # for i in range(1, n):
    #     sum += comb(n, i, exact=True)
    # sub = (n-2)*sum
    # ans = n*(n-1)*(10**(n-2))-sub
    ans = 10**n - 2*(9**n) + 8**n
    print(int(ans%((10)**9+7)))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
DP = [[0]*4 for _ in range(N)]
MOD = 10**9+7
for i in range(N):
    if i == 0:
        DP[i][0] = 8
        DP[i][1] = 1
        DP[i][2] = 1
        DP[i][3] = 0
        continue
    DP[i][0] = (DP[i-1][0] * 8) % MOD
    DP[i][1] = (DP[i-1][1] * 9) %MOD + (DP[i-1][0]) % MOD
    DP[i][2] = (DP[i-1][2] * 9) % MOD + ( DP[i-1][0]) % MOD
    DP[i][3] = (DP[i-1][3] * 10)% MOD + DP[i-1][1] % MOD+ DP[i-1][2] % MOD

print(DP[-1][3]%MOD)

Submission status: Accepted

Solution code:
n=int(input())
mod=(1e+9)+7
x=1
if n>=2:
  ans=1
else:
  ans=0
for i in range(n):
  x*=10
  ans*=8
  ans%=mod
  x%=mod
nin=1

for i in range(n):
  nin*=9
  nin%=mod
x+=ans
x%=mod
x-=(nin*2)%mod
if x<0:
  x+=mod
if n==1:
  print(0)
else:
  print(int(x%mod))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

q = int(1e9+7)

print((pow(10, N, q) - 2 * pow(9, N, q) + pow(8, N, q)) % q)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
mod=10**9+7
if N==1:
   print(0)
else:
   ans=pow(10,N,mod)
   ans-=pow(9,N,mod)*2
   ans+=pow(8,N,mod)
   if ans<0:
      ans+=mod
   print(ans%mod)

Submission status: Accepted

Solution code:
N = int(input())
a = 10**9 + 7
tmp1 = 10**N %a

tmp2 = 2*9**N  %a

tmp3 = 8**N  %a


answer = (tmp1-tmp2+tmp3) %a

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

if N == 0 or N == 1:
    print(0)

else:
    # DPテーブル
    dp = [0] * (N + 1)

    # 9の冪乗テーブル
    exp_9 = [0] * (N + 1)
    exp_9[0] = 1
    for i in range(1, N + 1):
        exp_9[i] = (exp_9[i - 1] * 9) % mod

    # 8の冪乗テーブル
    exp_8 = [0] * (N + 1)
    exp_8[0] = 1
    for i in range(1, N + 1):
        exp_8[i] = (exp_8[i - 1] * 8) % mod

    # DP計算
    for i in range(2, N + 1):
        dp[i] = (dp[i - 2] * 100 + 38 * exp_9[i - 2] - 36 * exp_8[i - 2]) % mod
        # print(i, dp[i])

    print(dp[N])

Submission status: Accepted

Solution code:
"""
int(input())
map(int, input().split())
list(map(int, input().split()))
input()
input().split()
"""


n = int(input())
mod = 1000000007

tmp = 1
diff = 1
eight = 1

for i in range(n):
    tmp *= 10
    tmp %= mod
    diff *= 9
    diff %= mod
    eight *= 8
    eight %= mod

ans = tmp - 2*diff + eight
ans %= mod
print(ans)

# tmp = (10**n)%mod
# diff = 2*(9**n)%mod
# eight = (8**n)%mod

# ans = tmp - diff + eight
# print(ans)

Submission status: Accepted

Solution code:
n = int(input())
mod = 10**9 + 7
ans = 1
for _ in range(n):
    ans *= 10
    ans %= mod

no1 = 1
no19 = 1
for _ in range(n):
    no1 *= 9
    no1 %= mod
for _ in range(n):
    no19 *= 8
    no19 %= mod
print((ans -(no1*2 - no19))%mod)

Submission status: Accepted

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

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

print (ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    m = 10 ** 9 + 7
    ans = pow(10, N, m) - 2 * pow(9, N, m) + pow(8, N, m)
    ans = ans % m
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
mod = 10**9 + 7
a = 10**n % mod
b = 9**n % mod
c = 8**n % mod
ans = a + c - 2*b
if ans >= 0:
    ans = ans % mod
else:
    ans += 2*mod
    ans = ans % mod
    
print(ans)

Submission status: Accepted

Solution code:
def powmod(a, n, p):
    if(n==0):
        return 2
    elif(n==1):
        return a%p
    elif(n%2==1):
        return ((a%p)*(powmod(a,n//2,p)**2%p))%p
    elif(n%2==0):
        return powmod(a,n//2,p)**2%p
N=int(input())
p=10**9+7
if(N==1):
    print(0)
else:
    print((powmod(10,N,p)-2*powmod(9,N,p)+powmod(8,N,p))%p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
ant,bnt,cnt=1,1,1

for i in range(n) :
    ant=10*ant%1000000007
    bnt=9*bnt%1000000007
    cnt=8*cnt%1000000007

ans=(ant-(bnt*2-cnt))%1000000007

if ans>=0 :
    print(ans)
else :
    print(1000000007+ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
a=1
b=1
c=1

for i in range(N):
    a=(a*10)%(10**9+7)
for j in range(N):
    b=(b*8)%(10**9+7)
for k in range(N):
    c=(c*9)%(10**9+7)

ans=(a+b-2*c)%(10**9+7)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

p = 10**9+7


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

_09 = pow(10,n,p)
_19 = _08 = pow(9,n,p)
_18 =  pow(8,n,p)

print((_09-_19*2+_18)%p)

Submission status: Accepted

Solution code:
N = int(input())

if N == 1:
  print('0')
  exit()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

n1 = (10**n) % x
n2 = (9**n) % x
n3 = (8**n) % x
ans = (n1 - n2 *2 + n3) % x

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MOD = 1000000007
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
      
n = int(input())
a = ModInt(1)
b = ModInt(1)
w = ModInt(1)
for i in range(n):
  a *= 9
  b *= 8
  w *= 10
  
ex = a * 2 - b
ans = w - ex
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

m = 10 ** n
m = m + 8 ** n - 9 ** n - 9 ** n
print(m % 1000000007)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

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

Submission status: Accepted

Solution code:
n = int(input())

nab = (10**n)-(8**n)
na = (10**n)-(9**n)
ans = na*2-nab

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

Submission status: Accepted

Solution code:
from itertools import combinations 
n=int(input())
waru=10**9+7
num_all=(10**n)%waru
num_0_9=(9**n)%waru
num_no=(8**n)%waru
print((num_all-num_0_9*2+num_no+waru)%waru)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
count9 = 1
count0 = 1
other = 8
for i in range(n-1):
  ans = ans*10 + count9+count0
  count9 = count9*9 + other
  count0 = count0*9 + other
  other *= 8
  
  count9 %= MOD
  count0 %= MOD
  ans %= MOD
  other %= MOD
  
print(ans%MOD)

Submission status: Accepted

Solution code:

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

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

  print(int(res))

Submission status: Accepted

Solution code:
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    mod0=1000000007

    print((10**N-2*9**N+8**N)%mod0)

   




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = 1000000007
 
n = int(input())
 
not0 = 1
not0and9 = 1
all = 1
for i in range(n):
  not0and9 = (not0and9 * 8) % a
  not0 = (not0 * 9) % a
  all = (all * 10) % a;
  
print((all + not0and9 - 2 * not0) % a)

Submission status: Accepted

Solution code:
N=int(input())

if N == 1:
    print(0)
    
else:
    s=10**N + 8**N - 2*(9**N)
    print(s%1000000007)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

N = int(input())

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

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

print(ans % mod)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn = int(input())
    stdOut = solve(stdIn)
    print(stdOut)


"""
方針
パターン数としては
(0を少なくとも一つ含む場合 + 9を少なくとも一つ含む場合 - 0,9どちらか一つを含む場合)
= (10^n - 9^n) * 2 - (10^n - 8^n)
10^n + 8^n - 2 * 9^n
正しn<=10^6なので単純に計算するとオーバーフローする
逐次計算して10^9+7を超えたら減らす方針にする

"""

mod = 1000000007


def solve(n):
    # s = 10 ** n + 8 ** n - 9 ** n * 2
    n10 = modpow(10, n, mod)
    n8 = modpow(8, n, mod)
    n9 = modpow(9, n, mod)
    s = n10 + n8 - n9 * 2
    while s < 0:
        s += mod
    return s

# a^n mod を計算する


def modpow(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 __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MOD=10**9+7

def modpow(a,n):
    r=1
    while n > 0:
        if n%2==1:
            r = r*a%MOD
        a = a*a % MOD
        n = n//2
    return r

N=int(input())
a10N=modpow(10,N)
a9N=modpow(9,N)
a8N=modpow(8,N)
ans=a10N-(a8N+2*(a9N-a8N))
ans%=MOD
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

MOD = 1_000_000_007
a, b, c, d = 8, 1, 1, 0
for i in range(N - 1):
    a, b, c, d = 8 * a, a + 9 * b, a + 9 * c, b + c + 10 * d
    a %= MOD
    b %= MOD
    c %= MOD
    d %= MOD
print(d)

Submission status: Accepted

Solution code:
def fast_pow(x, n, MOD):
    res = 1
    while n:
        if n & 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1
    return res
  

MOD = 10**9+7

n = int(input())

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

Submission status: Accepted

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

def fun (x):
  return (x if x >= 0 else x + mod)

ans = fun(fun(10**n%mod-9**n%mod)*2%mod-fun(10**n%mod-8**n%mod))

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print((a - 2*b + c)%mod)