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
print((pow(10,n,m) - 2*pow(9,n,m) + pow(8,n,m))%m)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())
P=10**9+7
s_10=1
for i in range(N):
  s_10=(s_10*10)%P
s_9=1
for i in range(N):
  s_9=(s_9*9)%P
s_9=(s_9*2)%P
s_8=1
for i in range(N):
  s_8=(s_8*8)%P
print ((s_10-s_9+s_8)%P)

Submission status: Accepted

Solution code:
N = int(input())

if N == 1:
    print(0)
else:
    a = (10**N) % (10**9+7)
    b = (2*(9**N)) % (10**9+7)
    c = (8**N) % (10**9+7)
    print((a-b+c)%(10**9+7))

Submission status: Accepted

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

N = int(readline())

DIV = 10 ** 9 + 7

# dp[i][j][k] = i - 1桁目で、すでに0が出た(j), すでに9が出た(k)

dp = [[[0] * 2 for j in range(2)] for i in range(N + 1)]

dp[0][0][0] = 1

for i in range(1, N + 1):
  dp[i][0][0] += dp[i - 1][0][0] * 8 # まだ0も9も出ない
  dp[i][0][0] %= DIV
  
  dp[i][1][0] += dp[i - 1][0][0] # 0が出た
  dp[i][1][0] += dp[i - 1][1][0] * 9 # 9以外何が出てもよい
  dp[i][1][0] %= DIV
  
  dp[i][0][1] += dp[i - 1][0][0] # 9が出た
  dp[i][0][1] += dp[i - 1][0][1] * 9 # 0以外何が出てもよい
  dp[i][0][1] %= DIV
  
  dp[i][1][1] += dp[i - 1][1][0] # 9が出た
  dp[i][1][1] += dp[i - 1][0][1] # 0が出た
  dp[i][1][1] += dp[i - 1][1][1] * 10 # 何が出てもよい
  dp[i][1][1] %= DIV
  
print(dp[-1][1][1])

Submission status: Accepted

Solution code:
N = int(input())

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

print(int(ans))

Submission status: Accepted

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


def pow_mod(a, b):
    if b <= 0:
        return 1
    elif b % 2 == 0:
        d = pow_mod(a, b // 2)
        return d ** 2 % MOD
    else:
        return a * pow_mod(a, b - 1) % MOD


ans = pow_mod(10, N) - pow_mod(9, N) * 2 + pow_mod(8, N)
if ans < 0:
    ans += MOD * 2
print(ans % MOD)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
#10**N - 8**N
mod = 10**9 + 7
TEN = 1
EIGHT = 1
NINE = 1
for n in range(N):
    TEN *= 10
    EIGHT *= 8
    NINE *= 9#どっちか使わない
    TEN %= mod
    EIGHT %= mod
    NINE %= mod
print((TEN - NINE*2 + EIGHT)%mod)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = 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
if n == 1:
    print(0)
else:
    mod = 10**9+7
    print((power_func(10, n, mod)-(power_func(9, n, mod)*2-power_func(8, n, mod)))%mod)

Submission status: Accepted

Solution code:
# print('input >>')
N = int(input())
MOD = 10 ** 9 + 7

# print('-----output-----')
print((10 ** N - (2 * (9 ** N) - 8 ** N)) % MOD)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = a - b - c + d

print(ans % 1000000007)

Submission status: Accepted

Solution code:
n = int(input())
mod = 10**9+7
dp = [[0]*4 for _ in range(n)]
dp[0] = [8,1,1,0]
for i in range(1,n):
    dp[i][0] = (dp[i-1][0]*8)%mod
    dp[i][1] = (dp[i-1][0] + dp[i-1][1]*9)%mod
    dp[i][2] = (dp[i-1][0] + dp[i-1][2]*9)%mod
    dp[i][3] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3]*10)%mod
print(dp[-1][-1])

Submission status: Accepted

Solution code:
a=int(input())
n1=10**a
n2=9**a
n3=8**a
x=n1-n2
y=n1-n3
z=x*2-y
print(z%(10**9+7))

Submission status: Accepted

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

def main():
    input = sys.stdin.readline
    n = int(input())
    mod = 10 ** 9 + 7
    if n == 1:
        print(0)
    elif n == 2:
        print(2)
    else:
        print((pow(10, n, mod) - pow(9, n, mod) * 2 + pow(8, n, mod)) % mod)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
if n<2:
    print(0)
    exit()
k=2
mod=10**9+7
framod=[1]
def framod_calc(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
        framod.append(a)

def permmod(n, k, mod):
    if n<k: return 0
    a=framod[n]
    c=framod[n-k]
    return (a * pow(c, mod-2, mod)) % mod

def combmod(n, k, mod):
    if n<k: return 0
    a=framod[n]
    b=framod[k]
    c=framod[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod

framod_calc(n+1, mod)
ans=0

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    mod = 10 ** 9 + 7
    mod_1 = 1
    mod_2 = 1
    mod_3 = 1
    for _ in range(N):
        mod_1 = (mod_1 * 10) % mod
        mod_2 = (mod_2 * 9) % mod
        mod_3 = (mod_3 * 8) % mod
    v = mod_1 - 2 * mod_2 + mod_3
    if v < 0:
        v *= -1
        v = ((v // mod) + 1) * mod - v
    print(v)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    print((pow(10, n, mod) - pow(9, n, mod) * 2 + pow(8, n, mod)) % mod)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
MAX = 1000100
MOD = 10**9 + 7
modPow8 = [1] * MAX
modPow2 = [1] * MAX
for i in range(1, MAX):
    modPow2[i] = modPow2[i-1] * 2 % MOD
    modPow8[i] = modPow8[i-1] * 8 % MOD
fact = [1] * MAX
inv = [1] * MAX
fact_inv = [1] * MAX 
for i in range(2, 1000100):
    fact[i] = fact[i-1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    fact_inv[i] = fact_inv[i-1] * inv[i] % MOD
def comb(n, k):
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD
ans = 0
for k in range(2, n+1):
    ans += comb(n, k) * (modPow2[k] - 2) * modPow8[n-k]
    ans %= MOD
print(ans)

Submission status: Accepted

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

dp=[[0,0,0,0] for _ in range(n)]

dp[0]=[8,1,1,0]

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

#print(dp)

print(dp[-1][3]%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

mod = 1000000007

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7

n = int(input())

x = pow(10, n, MOD)
y = pow(9, n, MOD)
z = pow(8, n, MOD)

ans = (((x - ((2 * y) % MOD) + MOD) % MOD) + z) % MOD

print(ans)

Submission status: Accepted

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def cmb_mod(N, mod=10**9+7):
    N1 = N + 1
    g1 = [0] * N1
    g2 = [0] * N1
    inv = [0] * N1
    g1[0] = g1[1] = g2[0] = g2[1] = inv[1] = 1

    for i in range(2, N1):
        g1[i] = g1[i-1] * i % mod
        inv[i] = -inv[mod % i ] * (mod//i) % mod
        #inv[i] = pow(g1[i-1], mod-2, mod)
        g2[i] = g2[i-1] * inv[i] % mod

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

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

    cmb = cmb_mod(N)

    ans = 0
    x8 = 1
    ans = pow(10, N, mod)
    for i in reversed(range(1, N+1)):
        tmp = 2 * cmb(N, i) * x8 % mod
        ans = (ans - tmp) % mod
        x8 = x8*8 % mod

    ans = (ans - x8) % mod

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
from math import factorial

def calc_permutation(n, r):
    return factorial(n) // factorial(n - r)


if __name__ == '__main__':
    n = int(input())

    mod_num = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
n = int(input())
a = [8]; b = [1]; c = [1]; d = [0]; m = 10**9+7
for _ in range(n-1):
    d.append((b[-1]+c[-1]+d[-1]*10)%m)
    c.append((a[-1]+c[-1]*9)%m)
    b.append((a[-1]+b[-1]*9)%m)
    a.append(a[-1]*8%m)
print(d[-1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
N = int(readline())
if N == 1:
    print(0)
    sys.exit()
    
a = pow(10,N,MOD)
b = pow(9,N,MOD)
c = pow(8,N,MOD)

ans = ((a-b)*2%MOD - (a-c)%MOD) % MOD

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    MOD = 10**9+7
    if N < 2:
        print(0)
    elif N == 2:
        print(2)
    else:
        noone = 9**N
        noone %= MOD
        notwo = 8**N
        notwo %= MOD
        ALL = 10**N
        ALL %= MOD
        zeroplsnine = ALL - noone
        zeroplsnine %= MOD
        zeroplsnine *= 2
        zeroplsnine %= MOD
        zeroandnine = ALL - notwo
        zeroandnine %= MOD
        ans = zeroplsnine - zeroandnine
        ans %= MOD
        print(ans)
    


if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
mod = 10 ** 9 + 7
ans = 0
if num >= 2:
    temp9 = (9 ** num) % mod
    temp8 = (8 ** num) % mod
    val = (temp9 * 2 - temp8) % mod
    ans = (10 ** num) % mod + mod - val
print(ans % mod)

Submission status: Accepted

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

def f(n, m):
    ans = 1
    for _ in range(m):
        ans *= n
        ans %= MOD
    return ans

ans = f(10, N) - 2 * f(9, N) + f(8, N)
ans %= MOD
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
PRIME = 10 ** 9 + 7

n = int(input())
bp1 = [0 for i in range(n + 1)]
bp0 = [0 for i in range(n + 1)]

bp1[1] = 2
bp0[1] = 8

for i in range(2, n + 1):
  bp0[i] = (bp0[i - 1] * 8) % PRIME
  bp1[i] = (bp1[i - 1] * 9 + bp0[i - 1] * 2) % PRIME

ans = pow(10, n, PRIME) + (PRIME - bp0[n]) + (PRIME - bp1[n])
print(ans % PRIME)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
mod=10**9+7
ans=1
for i in range(n):
    ans*=10
    ans%=mod
tmp=1
for i in range(n):
    tmp*=9
    tmp%=mod
ans-=2*tmp
ans%=mod
tmp=1
for i in range(n):
    tmp*=8
    tmp%=mod
ans+=tmp
ans%=mod
print(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()
nine,ei,se=1,1,1
for i in range(n):
    nine*=10
    nine%=mod
    ei*=9
    ei%=mod
    se*=8
    se%=mod
print((nine-2*ei+se)%mod)

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    mod = 10**9+7

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


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

Solution code:
n = int(input())
M = 10 ** n
m1 = 8 ** n
m2 = (9 ** n) - (8 ** n) 

print((M - m1 - 2*m2)%((10 ** 9) + 7))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())


if(N == 2):
  print("2")
  exit()
if(N == 1):
  print("0")
  exit()
ans_n = 10**N - 2*9**N + 8**N 
answer = ans_n % 1000000007

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

input = sys.stdin.readline
mod = 1000000007


def ST():
    return input().rstrip()


def I():
    return int(input())


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


def LI():
    return list(MI())


n = I()

ten = 1
nine = 1
eight = 1
for _ in range(n):
    ten *= 10
    ten %= mod
    nine *= 9
    nine %= mod
    eight *= 8
    eight %= mod

ans = ten - 2 * nine + eight
ans %= mod
print(ans)

Submission status: Accepted

Solution code:

x = 1000000007

n = int(input())

ans10 = 1
ans9 = 1
ans8 = 1
for i in range(n):
    ans10 *= 10
    ans10 %= x

    ans9 *= 9
    ans9 %= x

    ans8 *= 8
    ans8 %= x

ans=(ans10 - 2*ans9 + ans8) % x

print(ans)

Submission status: Accepted

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

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

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

print(x)

Submission status: Accepted

Solution code:
N = int(input())

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

print(mod)

Submission status: Accepted

Solution code:
n = int(input())

def pow(x, n):
    ans = 1
    n_tmp = n
    while n:
        if n % 2:
            ans *= x
            ans %= mod
        x *= x
        n >>= 1
    return ans

mod = 10**9+7 #出力の制限

a = pow(8, n) # 0,9を含まない
b = pow(9, n) - pow(8, n) # 0 or 9 のどちらかを含む
c = pow(10, n) # 全て
ans = c-2*b-a
if ans < 0:
    ans += mod
print(ans%mod)

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

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

Submission status: Accepted

Solution code:
N = int(input())

A = 1
B = 1
C = 1

for i in range(N):
    A *= 10
    A = A % int(1e+9 + 7)

for i in range(N):
    B *= 9
    B = B % int(1e+9 + 7)

for i in range(N):
    C *= 8
    C = C % int(1e+9 + 7)

D = A - 2 * B + C
D = D % int(1e+9 + 7)

print(D)

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

ans_num = 10**N - 2*9**N + 8**N 
ans = ans_num % 1000000007

print(ans)

Submission status: Accepted

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

mod = 10 ** 9 + 7
ans = pow(10, n, mod) - pow(9, n, mod) * 2 + 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)
elif(N == 2):
    print(2)
else:
    ans = (10 **N) - (9 ** N)*2 +(8 **N)
    print(ans % mod)

Submission status: Accepted

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()

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


    print(ans % MOD)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())

MOD=10**9+7
if N==1:
    ans=0
elif N==2:
    ans=2
else:
    ans10=1
    ans9=1
    ans8=1

    for i in range(N):
        ans10=ans10*10%MOD
        ans9=ans9*9%MOD
        ans8=ans8*8%MOD

    ans=(ans10-2*ans9+ans8)%MOD

print(ans)

Submission status: Accepted

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

result = 10**N - (9**N + 9**N - 8**N)

print(result%mod)

Submission status: Accepted

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

MOD = 1000000007  # type: int

def solve(N: int):
    a = pow(10, N, MOD)
    b = pow(9, N, MOD)
    c = pow(8, N, MOD)
    return (2 * (a - b) - (a - c)) % MOD

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
import itertools


def main():
    n = int(input())
    return (10**n-(2*(9**n)-8**n)) % (10**9+7)


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

Submission status: Accepted

Solution code:
mod = 1000000007

N = int(input())

total = 10**N
non_9 = 9**N
non_09 = 8**N

ans = (total-2*non_9+non_09)%mod

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
if n>2:
  N=10**n
  i=9**n
  j=8**n
  k=N-2*i+j
  print(k%(10**9+7))

elif n ==2:
  print(2)

else:
  print(0)

Submission status: Accepted

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

mod = 1000000007
res = ((pow(10, N, mod) - 2 * pow(9, N, mod) + pow(8, N, mod)) + 10 * mod) % mod

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    mod=10**9+7
    p10=pow(10,n,mod)+mod*5
    p8=pow(8,n,mod)
    p9=pow(9,n,mod)
    ans=p10+p8-p9-p9
    ans=ans%mod


    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Submission status: Accepted

Solution code:
N = int(input())

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

mod = int(10**9+7)

zeronai = 1
for i in range(N):
    zeronai = zeronai * 9
    zeronai = zeronai % mod

dottimonai = 1
for i in range(N):
    dottimonai = dottimonai * 8
    dottimonai = dottimonai % mod

aru = 1
for i in range(N):
    aru = aru * 10
    aru %= mod


# print(aru, zeronai, dottimonai)
print((aru - 2*zeronai + dottimonai) % mod)

Submission status: Accepted

Solution code:
#ABC178 C
from scipy.special import comb
n = int(input())
if n == 1:
  print(0)
else:
  mod = 1000000007
  ans = (10 ** n - 9 ** n - 9 ** n + 8 ** n) % mod
  print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

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

def combination(n,r,mod=10**9+7):
    r=min(r,n-r)
    up,down=1,1
    for i in range(r):
        up=up*(n-i)%mod
        down=down*(i+1)%mod
    return up*pow(down,mod-2,mod)%mod

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

now = 1
hiki = 1
hiki2 = 1

for i in range(n):
    now *= 10
    hiki *= 8
    hiki2 *= 9

    now %= mod
    hiki %= mod
    hiki2 %= mod

hiki2 *= 2
hiki2 %= mod

print((now+hiki-hiki2)%mod)

Submission status: Accepted

Solution code:
import math

mod = 1000000007

def add(a, b):
    return (a + b) % mod
def sub(a, b):
    return (a + mod - b) % mod
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y/2)**2 % mod
    else            : return power(x, y/2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))
#N = map(int,input().split())
#AB=[]
N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []
#for i in range(N):
#    C.append(list(map(int,input().split())))
c = 1
d = 1
e = 1
for i in range(N):
    c = mul(c,10)
for i in range(N):
    e = mul(e,9)
for i in range(N):
    d = mul(d,8)

print(sub(sub(c,mul(sub(e,d),2)),d))

Submission status: Accepted

Solution code:
from sys import stdin
INF = 10**9 + 7
n = int(stdin.readline().rstrip())
ten = 1
nine = 1
eight = 1
for x in range(n):
    ten = (ten * 10) % INF
    nine = (nine * 9) % INF
    eight = (eight * 8) % INF
ans = (((ten + eight) % INF) - ((2 * nine) % INF)) % INF
if ans < 0:
    ans += INF
print(ans)

Submission status: Accepted

Solution code:
def f(N):
    return (10**N-2*9**N+8**N)%(10**9+7)
print(f(int(input())))

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

if n<2:
  print(0)
else:
  print(((10**n-9**n)%mod-(9**n-8**n)%mod)%mod)

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

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

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

Submission status: Accepted

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

memo_1 = 9*9
memo_2 = 8*8
for i in range(2,N):
    ans *= 10
    ans %= mod
    ans += (memo_1*2)%mod - (memo_2*2)%mod
    ans %= mod
    memo_1 *= 9
    memo_1 %= mod
    memo_2 *= 8
    memo_2 %= mod
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from scipy.special import comb



N=int(input())

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

Submission status: Accepted

Solution code:
from math import factorial

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    if n == 1:
        print(0)
        exit()

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
M = 10 ** 9 + 7
set1 = (9 ** N) % M
set2 = (10 ** N) % M
set3 = (8 ** N) % M
tmp = (set2 + set3)% M
tmp = (tmp - set1)% M
print((tmp - set1)% M)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans%mod)

Submission status: Accepted

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

def powmod(x, n, mod):

    if n == 0:
        return 1

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

    return (K * x) % mod

sol = powmod(10,n,mod) - 2 * powmod(9,n,mod) + powmod(8,n,mod)
sol = sol % mod
print(sol)

Submission status: Accepted

Solution code:
import sys
import itertools as it


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

M = 10 ** 9 + 7


def pow(x, n):
    if n == 0:
        return 1
    ret = pow(x, n // 2)
    if n % 2 == 0:
        return (ret * ret) % M
    else:
        return (ret * ret * x) % M


ret = pow(10, N) - 2 * pow(9, N) + pow(8, N)
print(ret % M)

Submission status: Accepted

Solution code:
n = int(input())

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

print(y)

Submission status: Accepted

Solution code:
N = int(input())


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

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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
temp = int(1)
mod = int(1000000007)
temp2 = int(1)
temp3 = int(1)
ans = int(0)
if a >= 2:
    for i in range(a):
        temp = temp * 10
        temp = temp % mod
        temp2 = temp2 * 8
        temp2 = temp2 % mod
        temp3 = temp3 * 9
        temp3 = temp3 % mod
    ans = temp + temp2 - temp3*2
    ans = ans % mod
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
tmp = 10
for i in range(1, n):
    tmp *= 10
    tmp %= 1000000007
ans += tmp
tmp = 18
for i in range(1, n):
    tmp *= 9
    tmp %= 1000000007
ans -= tmp
tmp = 8
for i in range(1, n):
    tmp *= 8
    tmp %= 1000000007
ans += tmp
if ans < 0:
    ans += 1000000007
print(ans)

Submission status: Accepted

Solution code:
def mod(x):
    return int(x % (1e+9 + 7))


def power(x, n):
    ans = 1
    for _ in range(n):
        ans = mod(ans) * mod(x)
    return mod(ans)


def combination(n):
    return mod(power(10, n) - 2 * power(9, n) + power(8, n))


if __name__ == '__main__':
    N = int(input())
    print(combination(N))

Submission status: Accepted

Solution code:
# we want to use total to subtract away, 10**n
# both 0 and 9 doesn't appear
# find those where 0 appear but not 9
# find those where 9 appear but not 0
mod = 10**9 + 7
n = int(input())

# focus on the computation where 9 doesn't appear and 0 doesn't appear
# exactly_one_appear = 9**n - 8**n
# 10**n-8**n-2*(9**n-8**n)

# neither in the sequence 8**n
# 0 in the sequence but 9 is not

ten, nine, eight = 1, 1, 1
for i in range(n):
    ten *= 10 
    nine *= 9
    eight *= 8
    ten %= mod
    nine %= mod
    eight %= mod
print((ten - 2*nine + eight)%mod)

Submission status: Accepted

Solution code:
MOD = 10**9 + 7


def main():
    N = int(input())
    if N == 1:
        print(0)
        return
    ans = pow(10, N, MOD) - (pow(9, N, MOD) + pow(9, N, MOD) - pow(8, N, MOD))
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
MOD = (10**9)+7
res = (10**n)%MOD
res = (res - ((9**n)%MOD))%MOD
res = (res - ((9**n)%MOD))%MOD
res = ((res%MOD) + ((8**n)%MOD) )
if(res<0):
	res+= MOD
print(res%MOD)

Submission status: Accepted

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

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

print(ans)