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())

def modpow(a, n, mod):
    res = 1
    n_bi = str(format(n, 'b'))

    for i in range(len(n_bi)):
        res = (res*res) % mod
        if n_bi[i] == "1":
            res = (res*a) % mod
        
    return res

p = 1000000007

if (N == 1):
    print(0)
elif (N == 2):
    print(2)
else:
    temp = (modpow(10, N, p) - modpow(9, N, p)) % p
    temp = (temp - modpow(9, N, p)) % p
    temp = (temp + modpow(8, N, p)) % p
    print(temp)

Submission status: Accepted

Solution code:
n = int(input())

fi = 1
se = 1
tot = 1
mod = 10**9 + 7
for i in range(0,n):
    fi*=8
    fi%=mod
    se*=9
    se%=mod
    tot*=10
    tot%=mod
se*=2
se-=fi
print((tot - se)%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())
p = 10**9+7
ans = pow(10,N,p) + pow(8,N,p)-2*pow(9,N,p)
ans %= p
print(ans)

Submission status: Accepted

Solution code:
MOD = 1000000007

def fpow(x, n):
    e = 1
    while n > 1:
        if n & 1: e = (e*x) % MOD
        x = (x*x) % MOD
        n >>=1
    return (x*e)%MOD

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
from numba import njit

MOD = 1000000007

@njit
def solve(dp, N):
    dp[0, 0] = 8
    dp[0, 1] = 2
    dp[0, 2] = 0
    for i in range(1, N):
        dp[i, 0] = dp[i - 1, 0] * 8 % MOD
        dp[i, 1] = (dp[i - 1, 0] * 2 + dp[i - 1, 1] * 9) % MOD
        dp[i, 2] = (dp[i - 1, 1] + dp[i - 1, 2] * 10) % MOD
    return dp[N - 1, 2]


N = int(input())
dp = np.empty((N, 3), dtype=np.int32)
ans = solve(dp, N)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = 10**9+7
if n==1:
    print(0)
else:
    ans = 1
    b = 1
    c = 1
    for _ in range(n):
        b *= 9
        c *= 8
        b %= a
        c %= a
        ans *= 10
        ans %= a
    ans = (ans-2*b+c)%a
    if ans< 0:
        ans += a
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 21:20:10 2020

@author: naoki
"""

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

Submission status: Accepted

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

MOD = 1000000007  # type: int


def solve(N: int):
    t = pow(10,N,MOD)- pow(8,N,MOD)
    m = pow(10,N,MOD)- pow(9,N,MOD)
    print((2*m-t)%MOD)
    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())

mod = 10**9+7

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

Eight=1
Seven=1

for i in range(2,N+1):
    Eight*=9
    Seven*=8
    ok=(Eight- Seven)%mod
    OK=OK*10+ok*2
    OK%=mod
    Eight%=mod
    Seven%=mod
print(OK)

Submission status: Accepted

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

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)
ans=(((a-b*2)%mod)+c)%mod
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#(a^b) % (1e9 + 7)を求める
def powmod(a, b):
    result = 1;
    for i in range(b):
        result *= a
        result %= 1e9 + 7
    return result


n = int(input())

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    # print(10 ** n - 2 * (9 ** n) + 8 ** n)
    r = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n)
    r = int(r % (1e9 + 7))
    print(r)

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    a = (10 ** n )%MOD
    b = (9 ** n)%MOD
    c = (8 ** n)%MOD
    print((a-b*2+c)%MOD)



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    M = 10**9 + 7
    if N == 1:
        print(0)
        return
    ans = 0
    ans = 10**N - (9**N)*2 + 8**N 
    print(ans%M)    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = 10 ** n - 8 ** n

b = 2 * (10 ** n - 9 ** n)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def solve():
    N = int(input())
    M = 10**9+7
    a = pow(10,N,M)
    b = pow(9,N,M)
    c = pow(8,N,M)
    return str((a-2*b+c)%M)

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

def njou( x, k ):
    if k == 1:
        return x % mod
    else:
        return njou( x, k - 1 ) * x % mod

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

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

Submission status: Accepted

Solution code:
N = int(input())

const = 10**9 + 7

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

max = (10**n)%mod
a = 8**n%mod
b = 9**n%mod
no09 = a
nine_in = (b - a)%mod
zero_in = (b - a)%mod

ans = abs((max - no09 - nine_in - zero_in)%mod)
print(ans)

Submission status: Accepted

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

ans1 = 1
ans2 = 1
ans3 = 1
for _ in range(N):
    ans1 = (ans1*10)%MOD
    ans2 = (ans2*9)%MOD
    ans3 = (ans3*8)%MOD

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

Submission status: Accepted

Solution code:
import math
N=int(input())
MOD = (10**9)+7
a=pow(10,N,MOD)
b=pow(8,N,MOD)
c=pow(9,N,MOD)
d=(c*2)%MOD
if a+b-d<0:
  print((a+b-d+MOD)%MOD)
else:
  print((a+b-d)%MOD)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
#create date: 2020-09-13 21:03

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

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

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

all = 10**N % MOD
none = 8**N % MOD
zero = 9**N % MOD - none
nine = 9**N % MOD - none

ans = (all - none - zero - nine) % MOD
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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())

MOD = 1000000007

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

Submission status: Accepted

Solution code:
import math
mod = 10**9+7
n = int(input())
ans = 1
a = 2
b = 1
for i in range(0 , n):
	ans  = (ans%mod)*(10%mod)
	ans = ans%mod
	a = (a%mod)*(9%mod)
	b = (b%mod)*(8%mod)
	a =a%mod
	b =b%mod
          
ans = (ans%mod - (a-b)%mod)%mod
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

#0を一回も使わない
no_0 = 9**n

#9を一回も使わない
no_9 = 9**n

#0と9を一回も使わない
no_09 = 8**n

#全体-上記集合
yes_09 = 10**n - (no_0+no_9-no_09)

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

Submission status: Accepted

Solution code:
n = int(input())
val1 = 10
val2 = 9
val3 = 8
if n == 1:
    print(0)
else:
    for i in range(n-1):
        val1 = (val1*10)%(10**9+7)
        val2 = (val2*9)%(10**9+7)
        val3 = (val3*8)%(10**9+7)
    ans = int((val1-2*val2+val3)%(10**9+7))
    if ans<0:
        print(ans+1000000007)
    else:
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    

#乗法のmod逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

# nCr mod m
# modinvが必要
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


#べき乗
def Raise(x, y, mod=10**9+7):
    # xをy乗する。
    n = 0
    while True:
        if (1<<n) > y:
            break
        n+=1
    D = [0]*(n+1)
    x = x % mod
    D[0] = x
    index = 0
    for index in range(1,n):
        D[index] = (D[index-1]**2)
    res = 1
    index = 0
    for index in range(0, n):
        if (y>>index)&1 == 1:
            res *= D[index]
    return res


def main():
    #答えは 10^2 - 2*9^2 + 8^2
    n = I()
    res = Raise(10, n)- 2 * Raise(9, n) + Raise(8, n)
    print(res % (10**9+7))
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    num = int(input())
    mod = 1000000007
    ans = pow(10, num, mod) - pow(9, num, mod) * 2 + pow(8, num, mod)
    # # 0, 9 を含まない
    # ans -= pow(8, num, mod)
    # ans %= mod
    # # 0, 9 が片方ない
    # tmp = (pow(9, num, mod) - pow(8, num, mod)) * 2 % mod
    ans %= mod

    return ans


if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

a, b = 10, 9
for i in range(N - 1):
    a = (a * 10) % m
    b = (b * 9) % m

A = B = (a - b) % m


a, b = 10, 8
for i in range(N - 1):
    a = (a * 10) % m
    b = (b * 8) % m

C = (a - b) % m

print((A + B - C) % m)

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:
n=int(input())
print((10**n-(9**n)*2+8**n)%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())
a = 10**9 +7
b = pow(10,n,a) + pow(8,n,a) - 2 * pow(9,n,a)
if b >= 0:
    print(b)
elif a+b >=0:
    print(a+b)
else:
    print(a+a+b)

Submission status: Accepted

Solution code:
mod = int(1e9+7)
def pot(a, b):
    result = 1
    while(b):
        if(b%2):
            result=(result*a)%mod
        a=(a*a)%mod
        b//=2
    return result

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

MOD = 10 ** 9 + 7
dp = [[0] * 4 for i in range(n + 1)]
for i in range(1, n + 1):
    if i == 1:
        dp[i][0] = 0
        dp[i][1] = 1
        dp[i][2] = 1
        dp[i][3] = 8
    else:
        dp[i][0] = (dp[i - 1][0] * 10 + dp[i - 1][1] + dp[i - 1][2]) % MOD
        dp[i][1] = (dp[i - 1][1] * 9 + dp[i - 1][3]) % MOD
        dp[i][2] = (dp[i - 1][2] * 9 + dp[i - 1][3]) % MOD
        dp[i][3] = (dp[i - 1][3] * 8) % MOD

print(dp[n][0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

mod = 10**9+7

total = 10**n % mod
rest = (((9**(n) % mod) * 2 % mod) - (8**n % mod)) % mod

print((total - rest) % mod)

Submission status: Accepted

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

N = int(readline().strip())

p = 10**9 + 7

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

print(ans)

Submission status: Accepted

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

K = 10**9+7

def binary(N):
    s = N
    k = int(math.log2(N))
    result = []
    for i in range(k+1,0,-1):
        q = 2**(i-1)
        r = s // q
        result.append(r)
        s -= r*q
        i += 1
    return result

def compute(L, N):
    binary_seq = binary(N)[::-1]
    res = 1
    p = L
    for b in binary_seq:
        if b == 1:
            res = (res * p) % K
        p = p**2 % K
    return res

A= compute(8, N)
B= compute(9, N)
C= compute(10, N)

R = (A+C-2*B) % K
print(R)

Submission status: Accepted

Solution code:
def LI():
    return list(map(int, input().split()))


N = int(input())
mod = pow(10, 9)+7
if N == 1:
    ans = 0
else:
    total = pow(10, N, mod)
    a = 2*pow(9, N, mod)
    b = pow(8, N, mod)
    ans = (total-a+b) % mod

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ten = 1
for i in range(n):
    ten *= 10
    ten %= r

nine = 1
for i in range(n):
    nine *= 9
    nine %= r

eight = 1
for i in range(n):
    eight *= 8
    eight %= r

print((ten - 2 * nine + eight) % r)

Submission status: Accepted

Solution code:

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


def mod_factorials(n, m):
    mod_factorials = [1] * (n + 1)
    for i in range(1, n+1):
        mod_factorials[i] = mod_factorials[i-1]*i
        mod_factorials[i] %= m
    return mod_factorials

# 1!,2!,3!,...,n! �εո� (mod m)
def mod_inv_factorials(n, m):
    mod_invs = [1] * (n + 1)
    invs = [1] * (n + 1)
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    for i in range(1, n+1):
        mod_invs[i] = invs[i]*mod_invs[i-1]
        mod_invs[i] %= m
    return mod_invs

if N == 1:
    print(0)
else:
    ans = 0
    pow8 = [1]*(N+1)
    pow2 = [1]*(N+1)
    mod_facts = mod_factorials(N,mod)
    mod_invs = mod_inv_factorials(N,mod)
    for i in range(1,N+1):
        pow8[i] = pow8[i-1]*8
        pow8[i] %= mod
        pow2[i] = pow2[i-1]*2
        pow2[i] %= mod

    for k in range(2,N+1):
        ans += mod_facts[N]*mod_invs[k]*mod_invs[N-k]*(pow2[k]-2)*pow8[N-k]
        ans %= mod
    ans %= mod 


    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mod = 1000000007

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

mod = 10**9+7

niko = 0
zero = 1
kyu = 1
nai = 8


for _ in range(N-1):
    niko = niko*10 + (zero+kyu)
    zero = nai+zero*9
    kyu = nai+kyu*9
    nai *= 8
    
    niko %= mod
    zero %= mod
    kyu %= mod
    nai %= mod
    ##print(niko,zero,kyu,nai,niko+zero+kyu+nai)

print(niko)

Submission status: Accepted

Solution code:
N = int(input())
S = 0
if N == 1:
  print('0')
else:
  S0 = 10**N - 9**N
  S9 = 10**N - 9**N
  S09 = 8**N
  S = S0 + S9 + S09 - 10**N
  S = S % (10**9 + 7)
  print(S)

Submission status: Accepted

Solution code:
n = int(input())

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

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

print(x)

Submission status: Accepted

Solution code:
from sys import setrecursionlimit
setrecursionlimit(4100000)

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod

n = int(input())
mod = 10 ** 9 + 7
if n == 1:
    print(0)
else:
    ans = (mod_pow(10, n, mod) - (2 * mod_pow(9, n, mod) - mod_pow(8, n, mod))) % mod 
    print(ans)

Submission status: Accepted

Solution code:
import sys
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())

a1 = power_func(10,N,10**9+7)
a2 = power_func(9,N,10**9+7)
a3 = power_func(8,N,10**9+7)
if a1 - 2 * a2 + a3 >= 0:
    print(a1 - 2 * a2 + a3)
    sys.exit()
ans = a1 - 2*a2 + a3
while ans < 0:
    ans += 10**9 + 7
print(ans)

Submission status: Accepted

Solution code:

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



n = int(input())

mod = 1000000000 + 7

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

Submission status: Accepted

Solution code:
inf = pow(10,9)+ 7

n=int(input())
if n==1:
  print(0)
elif n==2:
  print(2)
else:
  f=pow(10,n,inf) - 2*pow(9,n,inf) + pow(8,n,inf)
  print(f%inf)

Submission status: Accepted

Solution code:
N = int(input())

mod = 10**9+7

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

from pprint import pprint

def main():
    N=ii()
    if N==1:
        print(0)
        return
    elif N==2:
        print(2)
        return
    ans = 0
    def get(n):
        l = [1]
        for _ in range(N):
            l.append(l[-1] * n % N1097)
        return l
    l8 = get(8)
    l9 = get(9)
    l10 = get(10)

    for i in range(N-1):
        fr = N - i - 1
        a = l8[i] * ((l10[fr] - l9[fr]) % N1097)
        a = (a*2) % N1097
        ans += a
        ans %= N1097
    print(ans)





main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):

    return [list(map(int,input().split()))for _ in range(n)]

n = iinp()
x = 10**9+7

a = 1
b = 1
c = 1

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

for i in range(n):
    a *= 10
    a %= x
    b *= 9
    b %= x
    c *= 8
    c %= x

b *= 2
b %= x

b -= c
if b < 0:
    b += x

a -= b
if a < 0:
    a += x

print(a)

Submission status: Accepted

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

def comb(n,k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n]*finv[k]%mod*finv[n-k]%mod

fac = [1]*(n+1)
finv = [1]*(n+1)
for i in range(1,n+1):
    fac[i] = fac[i-1]*i%mod
    finv[i] = pow(fac[i],mod-2,mod)

ans = 0
for i in range(2,n+1):
    ans += comb(n,i)*((pow(2,i,mod)-2)%mod)%mod*pow(8,n-i,mod)%mod
    ans %= mod
    # print(ans)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
mod = 10**9+7
def power_naive(n, base=8):
  ret = 1
  for _ in range(n):
    ret = (ret*base)%mod

  return ret

ret = 0

if N >= 2:
  ret = power_naive(N, base=10)
  subt = (2*power_naive(N, base=9))%mod
  ret = (ret-subt)%mod
  ret = (ret+power_naive(N, base=8))%mod

print(ret)

Submission status: Accepted

Solution code:
def getval():
    n = int(input())
    return n 

def main(n):
    mod = 10**9+7
    #Number of comb for 1-8
    pow8 = [1]
    for i in range(n):
        temp = pow8[i] * 8
        temp %= mod 
        pow8.append(temp)

    #Number of comb for 0 and 9
    pow2 = [1]
    for i in range(n):
        temp = pow2[i] * 2
        temp %= mod
        pow2.append(temp)
    for i in range(n+1):
        temp = pow2[i] - 2
        if temp<=0:
            temp = 0
        pow2[i] = temp 

    ans = 0

    lim = n + 1
    fact = [1,1]
    inv = [1,1]
    finv = [1,1]
    for i in range(2,lim+1):
        fact.append((fact[i-1] * i) % mod)
        inv.append(mod - inv[mod%i] * (mod // i) % mod)
        finv.append(finv[i-1] * inv[i] % mod)
    def mod_comb(n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return fact[n] * (finv[k] * finv[n-k] % mod) % mod

    for i in range(n+1):
        temp = pow2[i]*pow8[n-i]*mod_comb(n,i)
        temp %= mod
        ans += temp 
        ans %= mod

    print(ans)

if __name__=="__main__":
    n = getval()
    main(n)

Submission status: Accepted

Solution code:
N = int(input())


MAX = 10**9+7

def pow_k(x, n):
    if n == 0:
        return 1

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

    return K * x



if N == 1:
    print(0)
elif N == 2:
    print(2)
else:
    res = pow_k(10, N) - 2*pow_k(9, N) + pow_k(8, N) 
    print(res % MAX)

Submission status: Accepted

Solution code:
n=int(input())
p=10**9+7
def power(a,n,p):
    ret=1
    for _ in range(n):
      ret*=a
      ret%=p
    return ret

print((power(10,n,p)-(2*power(9,n,p))%p+power(8,n,p))%p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
MOD = 1_000_000_007
ans = pow(10, N, MOD)
ans -= 2 * pow(9, N, MOD)
ans %= MOD
ans += pow(8, N, MOD)
ans %= MOD
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
if N == 1:
    print(0)
    sys.exit()
alla = 1
for i in range(N):
    alla = (alla * 10) % (10**9+7)
exi1or9 = 1
for i in range(N):
    exi1or9 = (exi1or9 * 9) % (10**9+7)
exi1and9 = 1
for i in range(N):
    exi1and9 = (exi1and9 * 8) % (10**9+7)
ans = (alla-2*exi1or9+exi1and9) % (10**9+7)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    if n == 1:
        res = 0
    elif n == 2:
        res = 2
    else:
        res = (10 ** n % MOD - 9 ** n % MOD * 2 + 8 ** n) % MOD
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"] = [int(i) for i in cin][0]

    cout = main(kwargs)
    print(cout)

Submission status: Accepted

Solution code:
def p(val):
    print(val)


n = int(input())
sho = 10**9+7
vv=0
if n==1:
    vv=0
else:
    vv = ((10**n%sho - 9**n%sho -9**n%sho +8**n%sho)%sho)
p(vv)

Submission status: Accepted

Solution code:
#178-C

N = int(input())

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

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

inf = int(1e10)
mod = int(1e9 + 7)


def solve(N):
    c1 = pow(10, N, mod)
    c2 = (2 * pow(9, N, mod)) % mod
    c3 = pow(8, N, mod)
    ans = (c1 - c2) % mod
    ans = (ans + c3) % mod
    return ans

def main():
    from builtins import int, map
    N = int(input())

    ans = -1
    if N == 1:
        ans = 0
    elif N == 2:
        ans = 2
    else:
        ans = solve(N)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# author:  Taichicchi
# created: 13.09.2020 21:21:37

import sys

N = int(input())

MOD = (10 ** 9) + 7

ans = (10 ** N - ((9 ** N) * 2 - (8 ** N))) % MOD

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
MOD = 1_000_000_007
A = pow(10, N, MOD) - pow(9, N, MOD)
AorB = pow(10, N, MOD) - pow(8, N, MOD)
print( (A * 2  - AorB) % MOD if N > 1 else 0)

Submission status: Accepted

Solution code:
N=int(input())
inf=10**9+7
ans=0
if N==1:
    print(0)
else:
    temp1=1
    temp2=1
    temp3=1
    for i in range(N):
        temp1*=10
        temp2*=8
        temp3*=9
        temp1%=inf
        temp2%=inf
        temp3%=inf
    ans=temp1+temp2-2*temp3
    ans%=inf
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = N*(N-1)
mod = 10**9 + 7
ans %= mod
ans = 1
A = 1
B = 1
C = 1
for i in range(N):
    A *= 10
    B *= 9
    C *= 8
    A %= mod
    B %= mod
    C %= mod

print((A-B*2+C) % mod)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ans = 10**n-(2*9**n-8**n)
    print(ans%(10**9+7))
    
    
if __name__ == "__main__":
    main()