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

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

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(8, N, Mod)
    # ans -= 2 * pow(9, N-1, Mod)
    # ans *= 2
    # ans -= pow(2, N-2)
    # ans %= Mod
    # ans *= N * (N - 1) // 2 % Mod
    ans = 0
    a = 8
    b = 2
    for _ in range(N - 1):
        ans *= 10
        ans += b
        b *= 9 
        b += a * 2
        a *= 8
        ans %= Mod
        a %= Mod
        b %= Mod

    print(ans%Mod)

Submission status: Accepted

Solution code:
from math import factorial
def comb(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

N = int(input())

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

Submission status: Accepted

Solution code:
mod = 1000000000 + 7

N = int(input())
ans = 1
no9 = 1
no0 = 1
no09 = 1
for i in range(N):
    ans = ans * 10 % mod
    #print(ans)
    no9 = no9 * 9 % mod
    #print(no9)
    no0 = no0 * 9 % mod
    #print(no0)
    no09 = no09 * 8 % mod
    #print(no09)
ans = (ans - no9 -no0 + no09) % mod

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ma = 10**9+7

print((10**N - 9**N - 9 ** N + 8 ** N)% ma)

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
import math
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisect_left
from scipy.special import comb


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


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

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

def bindex(a,x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return i
    return None

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)

if __name__ == '__main__':
    N = intinput()
    mi_10 = ModInt(10)
    mi_9 = ModInt(9)
    mi_8 = ModInt(8)
    mi_2 = ModInt(2)
    mi_n = ModInt(N)
    ans = (mi_10**mi_n)-mi_2*(mi_9**mi_n)+(mi_8**mi_n)
    print(int(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

M = 1000000007
def nCr(n, r, M):
    return fact[n] * inv[n-r] % M * inv[r] % M


n = int(input())

fact = [1] * (n + 1)
inv = [1] * (n + 1)

for i in range(1, n + 1):
    fact[i] = fact[i-1] * i % M

inv[n] = pow(fact[n], M - 2, M)
for i in range(n-1, -1, -1):
    inv[i] = inv[i + 1] * (i + 1) % M
pw2 = [1]
for _ in range(n+1):
    pw2.append((pw2[-1]*2)%M)
pw8 = [1]
for _ in range(n+1):
    pw8.append((pw8[-1]*8)%M)
    
mod = 10**9+7
ans = 0
for i in range(2,n+1):
    if pw2[i]-2==-1:
        t = 10**9+6
    elif pw2[i]-2==-2:
        t = 10**9+5
    else:
        t = pw2[i]-2
    #print(n-i,len(pw8))
    temp = nCr(n, i, M) * t * pw8[n-i]
    temp %= M
    ans += temp
    ans %= M
print(ans)

Submission status: Accepted

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

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

nones = 8
zero = 1
nine = 1
other = 0
for x in range(1, n):
    other = other * 10 + zero + nine
    zero = zero * 9 + nones
    nine = nine * 9 + nones
    nones *= 8

    other %= M
    zero %= M
    nine %= M
    nones %= M

print(other)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    N = int(input())
    MOD = 10 ** 9 + 7

    if N == 1:
        print(0)
        return
    if N == 2:
        print(2)
        return
    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())

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    N = int(input())
    if N == 1:
        return 0
    if N == 2:
        return 2
    
    mod = 10**9+7 #出力の制限
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    ans = (10 ** N - 2) % (10**9+7)
    comb = 1
    tmp = 2
    total = 0
    for k in range(1, N):
        tmp = (tmp * 8) % (10**9+7)
        total += ((tmp * cmb(N, N - k, mod, g1, g2) % (10**9+7)))
    total += ((tmp * 8 // 2) % (10**9+7))
    return ((ans - total) % (10**9+7))

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

Submission status: Accepted

Solution code:
n = int(input())

def modpow(b,e):
    if e == 0:
        return 1
    elif e%2 == 1:
        return b*modpow(b,e-1)
    else:
        return modpow(b*b,e//2)

total = modpow(10,n)
minus = modpow(9,n)
add = modpow(8,n)

answer = total - minus - minus + add

answer %= 1000000007

print(answer)

Submission status: Accepted

Solution code:
N = int(input())

if N == 1 or N == 2:
    print((N-1)*2)
    exit()
 
kumi = 10**N
kata = 9**N - 8**N
zen = 8**N
x = (10**9)+7
print((kumi-(2*kata)-zen)%x)

Submission status: Accepted

Solution code:
n = int(input())

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

mod = 10 ** 9 + 7

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ten=1
nine=1
eight=1
mod = 1000000007

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

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

Submission status: Accepted

Solution code:
#import
#import math
#import numpy as np
modnum = 10 ** 9 + 7
N = int(input())

def mod(num):
    return num % modnum

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

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

    return mod(k * x)

t1 = pow_k(10, N)
t2 = pow_k(9, N)
t3 = pow_k(8, N)

print(mod(t1 - t3 - (t2 - t3) * 2))

Submission status: Accepted

Solution code:

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


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


def II():
    return int(input())


def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)


def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


N = II()

10**N-9**N-9**N+8**N

mod = 10**9+7

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

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

#print(a, b, c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

mod = 10**9 + 7

if N < 2:
    print(0)
else:
    #9がない
    no9 = 1
    no09 = 1
    tot = 1
    for i in range(N):
        no9 *= 9
        no9 %= mod
        no09 *= 8
        no09 %= mod
        tot *= 10
        tot %= mod
    print((tot - 2 * no9 + no09) % mod)

Submission status: Accepted

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

    eightN = 8 ** N

    Num = 10 ** N
    Num_not_0_9 = eightN
    Num_not_0_or_9 = 9 ** N - eightN

    answer = (Num - Num_not_0_or_9 * 2 - Num_not_0_9) % (10 ** 9 + 7)

    print(answer)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

    n1_8 = pow(8, n, mod)
    n0 = (pow(9, n, mod) - n1_8) % mod

    ans = pow(10, n, mod) - n1_8 - n0 * 2
    ans %= mod

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
P=1000000007
all = pow(10,n,P)
no0 = pow(9,n,P)
no9 = pow(9,n,P)
neither = pow(8,n,P)
print((all - (no0 + no9 - neither)) % P)

Submission status: Accepted

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

# print((n * (n - 1) * 10**(n - 2 ) % mod))
print((10**n - 9**n - 9**n + 8**n) % mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

a=9**N
b=8**N
c=10**N
A=c-2*a+b

print(A%(1000000007))

Submission status: Accepted

Solution code:
n=input()
N=int(n)

un=1
sum=pow(10,N)-2*pow(9,N)+pow(8,N)
sum=sum%1000000007
print(int(sum))

Submission status: Accepted

Solution code:
N = int(input())
all_num = 10**N
non09 = 8**N
a0 = all_num-9**N
a1 = all_num-9**N
ans = a0+a1-(all_num-non09)
print(ans%(10**9+7))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math,bisect
sys.setrecursionlimit(10 ** 5)
from collections import defaultdict
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,OrderedDict
def I(): return int(sys.stdin.readline())
def neo(): return map(int, sys.stdin.readline().split())
def Neo(): return list(map(int, sys.stdin.readline().split()))
mod = 10**9+7
N = I()
p,q,r = 1,1,1
if N == 1:
    print(0)
    exit()
for i in range(N):
    p = (p*10)%mod
    q = (q*9)%mod
    r = (r*8)%mod
print((p-2*q+r)%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

m = 1e9+7

N = int(input())

def culc_mod(a, b, md):
    """a^b (mod md)"""
    tmp = 1
    for _ in range(b):
        tmp *= a
        tmp = tmp%md
    return tmp
    
a = culc_mod(10, N, m)
b = culc_mod(9, N, m)
c = culc_mod(8, N, m)

print(int((a-2*b+c)%m))

Submission status: Accepted

Solution code:
import sys
import math as mt
import collections as cc
import sys
import itertools as it
input=sys.stdin.readline
I=lambda:list(map(int,input().split()))
fact=[1]
N=10**6+1
inv=[1]
mod=10**9+7
def iv(n):
	return pow(n,mod-2,mod)%mod
for i in range(2,N):
	fact.append((fact[-1]*i)%mod)
	inv.append(iv(fact[-1]))
def ncr(n,r):
	return (fact[n-1]*inv[n-r-1]*inv[r-1])%mod
n,=I()
tot=pow(10,n,mod)
m1=1
for i in range(1,n):
	m1+=pow(8,n-i,mod)*(ncr(n,i))
m2=m1
m3=pow(8,n,mod)
print((tot-(m1+m2+m3))%mod)

Submission status: Accepted

Solution code:
N = int(input())

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

ans %= 10**9+7

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
ans=0
if N==1:
    print(0)
elif N==2:
    print(2)
else:
    """
    0,2-8だけで構成される個数（1 9 nasi）
    0,2-9だけで構成される個数(1 nasi)
    0-8で構成される個数(9 nasi)
    全部1の個数
    全部9の個数
    """
    a1=8**N
    a2=9**N
    a3=a2
    a4=0
    a5=0
    zentai=10**N
    ans=zentai -(a2+a3+a4+a5-a1)

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    # a, b, c, d = map(int, input().split())
    # l = list(map(int, input().split()))
    # s = input()
    print(((10**n - 9**n) * 2 % (10**9 + 7) - (10**n-8**n) %
           (10**9 + 7)) % (10**9 + 7))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())

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

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

Submission status: Accepted

Solution code:
N = int(input())
mod = int(1e9 +7)

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

print(ans%mod)

Submission status: Accepted

Solution code:
n = int(input())

# not 0, but 9 == not 9, but 0
#2 * (9 ** n - 8 ** n)

# not 0,9
#8 ** n

# ans = all - (not 0, but 9 + not 9, but 0) - not 0,9
print((10**n - 2 * (9 ** n - 8 ** n) - 8 ** n) %  (10**9 + 7))

Submission status: Accepted

Solution code:
n = int(input())

mod = 10**9 + 7

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

print(ans%mod)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
MOD = 10 ** 9 + 7
MAX = 10 ** 6 + 1000
fact = [0] * MAX
invfact = [0] * MAX
fact[0] = 1
for i in range(1, MAX):
    fact[i] = fact[i - 1] * i % MOD
invfact[MAX - 1] = pow(fact[MAX - 1], MOD-2, MOD)
for i in range(MAX - 2, -1, -1):
    invfact[i] = invfact[i+1] * (i+1) % MOD

def nCk(n, k):
    if k < 0 or n < k: return 0
    return (fact[n] * invfact[k] % MOD) * invfact[n-k] % MOD

def nPk(n, k):
    if k < 0 or n < k: return 0
    return fact[n] * invfact[n-k] % MOD



allcnt = pow(10,N,MOD)
notcnt = pow(8,N,MOD)
for i in range(1,N+1):
    notcnt += pow(8,N-i,MOD) * invfact[i] * invfact[N-i] * fact[N] * 2
    notcnt %= MOD

print((allcnt - notcnt) % MOD)

Submission status: Accepted

Solution code:
_inp = int(input())

_bef_div = 10**_inp - (9**_inp + 9**_inp) + 8**_inp
_answer = _bef_div % (10**9 + 7)

print(_answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

solve()

Submission status: Accepted

Solution code:
n=int(input())

b=10**9+7

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

print(ans)

Submission status: Accepted

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

    a = 9 ** n
    b = 9 ** n
    c = 8 ** n

    ans = 10 ** n - (a + b - c)

    print(ans % mod)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

res1 = power_func(10,N,s)
res2 = power_func(9,N,s)
res3 = power_func(8,N,s)
print((res1 - (res2*2-res3))%s)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans%mod)

Submission status: Accepted

Solution code:
n=int(input())
a=pow(10,n)
b=pow(9,n)
c=pow(8,n)
print((a-b-b+c)%1000000007)

Submission status: Accepted

Solution code:
n = int(input())
x = [2, 8, 0]
y = [0,0,0]
mod = 10**9 + 7
for i in range(n-1):
    y[0] = (x[0]*9 + x[1]*2)%mod
    y[1] = (x[1]*8)%mod
    y[2] = (x[0] + x[2]*10)%mod
    x = y.copy()
print(y[-1])

Submission status: Accepted

Solution code:
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

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

Submission status: Accepted

Solution code:
def main():
    INF = int(1e9+7)
    N = int(input())
    ans_total = 1
    ans1 = 1
    ans2 = 1
    if N <= 1:
        print(0)
        return 
    
    for i in range(N):
        ans_total = ans_total * 10
        ans1 = ans1 * 9
        ans2 = ans2 * 8

        ans_total = ans_total % INF
        ans1 = ans1 % INF
        ans2 = ans2 % INF

    print((ans_total - ((2*ans1 - ans2)))%INF)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())


num, num2,num3 = 1, 1, 1

for _ in range(N):
    num = num * 10 % 1000000007
    num2 = num2 * 9 % 1000000007
    num3 = num3 * 8 % 1000000007
print((num - num2 * 2 + num3) % 1000000007)

Submission status: Accepted

Solution code:
n = int(input())
#a, b, c, d = list(map(int, input().split()))
# Ch, Cw = list(map(int, input().split()))
# Dh, Dw = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(4)]
# k = int(input())
# a = list(map(int, input().split("/")))
# r = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# data = [list(map(int, input().split())) for i in range(n)]
# month = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]


def permutations(n, r):
    return math.factorial(n) // math.factorial(n - r)


def calc_eight(n):
    ans = 1
    mod = 10**9 + 7
    for i in range(n):
        ans *= 8
        ans %= mod
    return ans


def calc_ten(n):
    ans = 1
    mod = 10**9 + 7
    for i in range(n):
        ans *= 10
        ans %= mod
    return ans


def calc_nine(n):
    ans = 1
    mod = 10**9 + 7
    for i in range(n):
        ans *= 9
        ans %= mod
    return ans


if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    mod = 10**9 + 7
    _all = calc_ten(n)
    _all %= mod
    other = calc_eight(n)
    other %= mod
    nine = calc_nine(n)
    nine %= mod
    # print(_all)
    # print(other)
    # print(nine)
    # print(nine*2-other)
    # print(ans)
    ans = _all-(nine*2-other)
    ans %= mod
    print(ans)

Submission status: Accepted

Solution code:
# your code goes here
n=int(input())
total=10**n
a=9**n
b=8**n
a*=2
val=total-(a-b)
print(val%1000000007)

Submission status: Accepted

Solution code:
N = int(input())

result = 10**N - 9**N * 2 + 8**N
print(max(0, result % (10**9 + 7)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import re
import queue
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []



def main():
	N = i_input()
	a = []
	a.append(1)
	a.append(19)
	for i in range(2,N):
		a.append((a[i-1]*19-90*a[i-2])%MOD)

	b = []
	b.append(0)
	b.append(2)
	for i in range(2,N):
		b.append((b[i-1]*8+2*a[i-1])%MOD)


	print(b[N-1])
	
	return


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import itertools
n = int(input())
if n == 1 :
    ans = 0
elif n == 2 :
    ans = 2
else :
    ans = 10**n - (9**n)*2 + 8**n


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

ans=1;
m=10**9+7
if n==1:
  print(0)
else:
  ans1=1;
  ans2=1;
  ans3=1;
  for i in range(n):
    ans1 = (ans1*10)%m
    ans2 = (ans2*9)%m
    ans3 = (ans3*8)%m
   

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

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())
M=10**9+7
A=pow(9,N,M)
B=pow(9,N,M)
C=pow(8,N,M)
A-=C
B-=C
S=pow(10,N,M)
ans=S-C-(A+B)
print(ans%M)

Submission status: Accepted

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

def for_factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
        val = val%MOD
    return val

def for_ten(n):
  val = 1
  for i in range(n):
    val *= 10
    val = val%MOD
  return val

def for_nine(n):
  val = 1
  for i in range(n):
    val *= 9
    val = val%MOD
  return val

def for_eight(n):
  val = 1
  for i in range(n):
    val *= 8
    val = val%MOD
  return val

answer = (-2*for_nine(N)+for_eight(N)+for_ten(N))%MOD
print(answer)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def calculate(n):
    mod = 1000000000 + 7

    result = pow(10, n, mod)

    # has 0 exists  9 not exists
    # 0 - 8
    s1 = pow(9, n, mod) - pow(8, n, mod)

    # has 9 exists 0 not exists
    # 1 - 9
    s2 = pow(9, n, mod) - pow(8, n, mod)

    # 9 not exists and 8 not exists
    # 1-8
    s3 = pow(8, n, mod)

    result = result - (s1 + s2 + s3)

    print(result % mod)


calculate(int(input()))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

def main():
    N = int(input())

    MOD = 10 ** 9 + 7

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


    def cmb(n, k, p):
        if (k < 0) or (n < k):
            return 0
        r = min(k, n - k)
        return fact[n] * factinv[k] * factinv[n - k] % p


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


    ans = pow(10, N, MOD)
    ans -= pow(8, N, MOD)
    ans %= MOD
    for i in range(1, N + 1):
        ans -= pow(8, N - i, MOD) * cmb(N, i, MOD) * 2
        ans %= MOD
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

bunbo = (10 ** n) - 2 * (9 ** n) + (8 ** n)
bunsi = 10 ** 9 + 7

print(bunbo % bunsi)

Submission status: Accepted

Solution code:
import numpy as np
from numba import njit

MOD = 10**9 + 7

@njit
def f(N):
  # 項数、0が出現したかどうか、9が出現したかどうか
  dp = np.zeros((N+1, 2, 2), np.int64)
  dp[0,0,0] = 1
  for n in range(N):
    # (0,0) からの遷移
    dp[n+1,0,0] += 8 * dp[n,0,0]  # 1 から 8
    dp[n+1,0,1] += dp[n,0,0]  # 0
    dp[n+1,1,0] += dp[n,0,0]  # 9
    
    # (0,1) からの遷移
    dp[n+1,0,1] += 9 * dp[n,0,1]  # 1 から 9
    dp[n+1,1,1] += dp[n,0,1]  # 0
    
    # (1,0) からの遷移
    dp[n+1,1,0] += 9 * dp[n,1,0]  # 0 から 8
    dp[n+1,1,1] += dp[n,1,0]  # 9
    
    # (1,1) からの遷移
    dp[n+1,1,1] += 10 * dp[n,1,1]
    
    dp[n+1] %= MOD
  return dp[N,1,1]
         
N = int(input())
print(f(N))