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

mod = 1000000007
set_non_exist_0 = pow(9, n, mod)
set_non_exist_9 = pow(9, n, mod)
set_non_exist_both = pow(8, n, mod)
print((pow(10, n, mod) - (set_non_exist_0 + set_non_exist_0 - set_non_exist_both)) % mod)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys
import math
input = sys.stdin.readline
mod = int(1e9)+7

def solve():
    n=int(input())
    ans = pow(10,n,mod)-(2*pow(9,n,mod)-pow(8,n,mod))
    print(ans%mod)

    
if __name__=="__main__":
    solve()

Submission status: Accepted

Solution code:
import math

a = int(input())

if a==1:
  print(0)
elif a==2:
  print(2)
else:
  
  num = (10**a)-(9**a)-(9**a)+(8**a)
  
  print(int(num % ((10**9)+7)))

Submission status: Accepted

Solution code:
n = int(input())

t = 10**9 + 7

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

if ans < t:
   print(ans)
else:
   print(ans%t)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a=1
b=1
c=1
d=1
mod = 1000000007
for _ in range(n):
    a=a*10%mod
    b = b*9%mod
    c = c*9%mod
    d = d*8%mod
print((a-b+mod - c+mod+d)%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):
    # xをy乗する。
    n = 0
    while True:
        if (1<<n) > y:
            break
        n+=1
    D = [0]*(n+1)
    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()
    mod=10**9+7
    res = pow(10, n, mod)- 2 * pow(9, n, mod) + pow(8, n, mod)
    print(res % (10**9+7))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
# mod = 998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"
INF = 1<<32-1
# INF = 10**18

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

    return None

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    MOD = 10 ** 9 + 7

    N = int(input())

    # a:0,9なし
    # b:0あり
    # c:9あり
    # d:0,9あり
    a, b, c, d = 1, 0, 0, 0
    for i in range(N):
        a, b, c, d = (
            (a * 8) % MOD,
            (b * 9 + a) % MOD,
            (c * 9 + a) % MOD,
            (d * 10 + c + b) % MOD
        )

    print(d)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def npower(n, b):
    q = n // 10
    r = n % 10
    pwr10 = (b ** 10) % ns
    pwr_r = (b ** r) % ns
    temp = 1
    for t in range(q):
        temp = (temp * pwr10) % ns
    return (temp * pwr_r) % ns

ans = npower(n, 10) -npower(n, 9) * 2 + npower(n, 8)
if ans >= 0:
    print(ans % ns)
else:
    ans = ans + 2*ns
    print(ans % ns)

Submission status: Accepted

Solution code:
import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline

# input functions
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda: list(map(int, input().split()))
MOD = int(1e9 + 7)

n = I()
if n < 2:
    print(0)
else:
    ans = (10 ** n)  # all comb
    ans %= MOD
    ans -= 2 * (9 ** n)  # without 9 or 0
    ans %= MOD
    ans += 8 ** n  # without 9 and 0
    ans %= MOD
    print(ans)

Submission status: Accepted

Solution code:
N=int(input())

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

y = 1000000007
print((power_func(10,N,y)-2*power_func(9,N,y)+power_func(8,N,y))%y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ri():
    return int(input())


def rii():
    return [int(v) for v in input().split()]


def solve():
    N = ri()
    m = int(1e9 + 7)
    ans = 10 ** N % m
    ans = (ans - 9 ** N) % m
    ans = (ans - 9 ** N) % m
    ans = (ans + 8 ** N) % m

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

den = int(1e9 + 7)
print((10**n - 2 * 9**n + 8**n) % den)

Submission status: Accepted

Solution code:
n = int(input())
mod = int(1e9+7)
allnum = 10**n
kata = 2*(9**n)
tt = 8**n
print((allnum - kata + tt)%mod)

Submission status: Accepted

Solution code:
n = int(input())
num_list = [0]*n

mod = (10**9)+7

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
n = int(readline())
if n > 1 : print((pow(10,n) - 2*pow(9,n) + pow(8,n)) % 1000000007)
else : print(0)

Submission status: Accepted

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

# -- 包除原理というらしい。勉強になった。 --
# 0も9も存在する
# 全体　- 0または9が存在しない
# 全体 - (0が存在しない + 9が存在しない　- 0,9どちらも存在しない)
# 10^n - (9^n + 9^n + 8^n)
print((pow(10,n,MOD) - 2 * pow(9,n,MOD) + pow(8,n,MOD)) % MOD)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(250000)

# a = comb(n, r)

def main():
    # a,b,c,d = map(int, input().split())
    n = int(input())

    # temp = (10 ** 9 + 7)
    # sum = 0
    # if n >= 2:
    #     for i in range(2, n+1):
    #         a = int(comb(i, 2)) * 2
    #         a = (a * 8**(i-2)) % temp
    #         sum = sum + a
    # else:
    #     print(0)

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

main()

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

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

Submission status: Accepted

Solution code:
MOD = 1000000007


def powmod(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        x = powmod(n, p // 2) % MOD
        return (x * x) % MOD
    x = powmod(n, p - 1) % MOD
    return (n * x) % MOD


def main():
    n=int(input())
    ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n)
    ans %= MOD
    ans = (ans + MOD) % MOD
    return ans


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

Submission status: Accepted

Solution code:
n=int(input())
mod=10**9+7
def pw(k,t):
    return pow(k,t,mod)

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

Submission status: Accepted

Solution code:
n=int(input())

p=10**n
q=8**n
r=(9**n)*2

print((p-r+q)%(10**9+7))

Submission status: Accepted

Solution code:
N=int(input())
a,b,c=(1,1,1)
MOD=1000000007
for i in range(N):
    a=(a*10)%MOD
    b=(b*9)%MOD
    c=(c*8)%MOD
ans=a-(b*2-c)

print(ans%MOD)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
x=(10**9)+7
a=pow(10,n,x)+pow(8,n,x)-2*pow(9,n,x)

print(a%x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic

MOD = 10 ** 9 + 7
n = rri()
every = pow(10, n, MOD)
none = pow(8, n, MOD)
no_zero = no_nine = pow(9, n, MOD)

zero_and_nine = every - no_zero - no_nine + none
zero_and_nine %= MOD
print zero_and_nine

Submission status: Accepted

Solution code:
def powmod(x, y, mod):
    res = pow(x, y) % mod
    return res

N = int(input())
mod = pow(10, 9) + 7
# (x + y) mod z = (x mod z + y mod z) mod z
ans = powmod(10, N, mod) - 2 * powmod(9, N, mod) + powmod(8, N, mod)
ans = ans % mod
print(ans)

Submission status: Accepted

Solution code:
import sys
from scipy.special import comb


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')
MOD = 10**9 + 7

n = I()
ans = pow(10, n) % MOD
ans = (ans - pow(9, n)) % MOD
ans = (ans - pow(9, n)) % MOD
ans = (ans + pow(8, n)) % MOD
print(ans)

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

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:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N = Scanner.int()
    MOD = 1000000007
    ans = pow(10, N, MOD)
    ans -= pow(9, N, MOD)

    ans -= pow(9, N, MOD)
    ans += pow(8, N, MOD)
    while ans < 0:
        ans += MOD
    ans %= MOD
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()
    # T = Scanner.int()
    # for _ in range(T):


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

mod = 10  ** 9 + 7
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())
M=10**9+7
ans=pow(10,n,M)-pow(9,n,M)-pow(9,n,M)+pow(8,n,M)+M
print(ans%M)

Submission status: Accepted

Solution code:
mod = 10**9 + 7
def solve(n):
    s = 2*pow(9, n, mod) % mod
    d = pow(8, n, mod) % mod
    ans_inv = (s - d)%mod
    ans = (pow(10, n, mod) - ans_inv) % mod

    return ans

n = int(input())
print(solve(n))

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

Submission status: Accepted

Solution code:
mod = 10 ** 9 + 7

N = int(input())

s, n, z, e = 1, 0, 0, 0
for _ in range(N):
    s, n, z, e = 8 * s, s + n * 9, s + z * 9, n + z + e * 10
    s %= mod
    n %= mod
    z %= mod
    e %= mod

print(e)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n=int(input())
print((10**n-9**n*2+8**n)%(10**9+7))

Submission status: Accepted

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

#都度MODで割らないと値がoverflowする
def powmod(x, y):
    res = 1
    for p in range(y):
        res = res*x%MOD
    return res

ans = powmod(10,N)-powmod(9,N)-powmod(9,N)+powmod(8,N)
print(int(ans%MOD))

Submission status: Accepted

Solution code:
n = int(input())

mod = 10**9+7

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

print(ans%mod)

Submission status: Accepted

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

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

ans = 10**n - 9**n * 2 + 8**n
ans %= mod

print(ans)

Submission status: Accepted

Solution code:
from sys import exit, stdin

input = stdin.readline
import copy

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

(N,) = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = (pow(10, N, mod) + pow(8, N, mod) - 2 * pow(9, N, mod)) % mod

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(250000)

from scipy.special import comb
# a = comb(n, r)

def main():
    # a,b,c,d = map(int, input().split())
    n = int(input())

    # temp = (10 ** 9 + 7)
    # sum = 0
    # if n >= 2:
    #     for i in range(2, n+1):
    #         a = int(comb(i, 2)) * 2
    #         a = (a * 8**(i-2)) % temp
    #         sum = sum + a
    # else:
    #     print(0)

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

main()

Submission status: Accepted

Solution code:
D = 10 ** 9 + 7

def li():
    return [int(x) for x in input().split()]

N = int(input())

total = pow(10, N, D)
A = total - pow(9, N, D)
B = total - pow(9, N, D)
C = total - pow(8, N, D)

ans = (A + B - C) % D
print(ans)

Submission status: Accepted

Solution code:
import math

N = int(input())

mod = 10 ** 9 + 7

if N >=2:
    zero_or_nine = 10**N - 8 **N
    zero = 9 ** N - 8 ** N
    nine = 9 ** N - 8 ** N
    zero_and_nine =  zero_or_nine - zero - nine
    print(zero_and_nine % mod)

else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import os
from sys import stdin, stdout

MOD = int(1e9) + 7


def power(a, b):
    ret = 1
    base = a
    while b > 0:
        if b % 2:
            ret *= base
            ret %= MOD
        b //= 2
        base *= base
        base %= MOD
    return ret


def solve(tc):
    n = int(stdin.readline().strip())

    ans = power(10, n)
    ans -= power(9, n)
    ans += MOD
    ans %= MOD

    ans -= power(9, n)
    ans += MOD
    ans %= MOD

    ans += power(8, n)
    ans %= MOD

    print(ans)


tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Submission status: Accepted

Solution code:
N = int(input())

MOD = 1000000007

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(250000)

from scipy.special import comb
# a = comb(n, r)

def main():
    # a,b,c,d = map(int, input().split())
    n = int(input())

    sum = 10**n - 9**n*2 + 8**n
    # temp = (10 ** 9 + 7)
    # sum = 0
    # if n >= 2:
    #     for i in range(2, n+1):
    #         a = int(comb(i, 2)) * 2
    #         a = (a * 8**(i-2)) % temp
    #         sum = sum + a
    # else:
    #     print(0)

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

main()

Submission status: Accepted

Solution code:
N = int(input())
TEN = 1
NINE = 1
EIGHT = 1
a = 10
b = 9
c = 8

mod = 10 ** 9 + 7

while N:
    if N % 2:
        TEN *= a
        TEN %= mod
        NINE *= b
        NINE %= mod
        EIGHT *= c
        EIGHT %= mod
    N //= 2
    a *= a
    a %= mod
    b *= b
    b %= mod
    c *= c
    c %= mod

print((TEN - 2 * NINE + EIGHT + mod * 2)%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
z=[[[0 for _1 in xrange(2)] for _2 in xrange(2)] for _3 in xrange(n+1)]
z[-1][1][1]=1
for i in xrange(n-1,-1,-1):
  for j in xrange(2):
    for k in xrange(2):
      for t in xrange(10):
        z[i][j][k]+=z[i+1][j or t==0][k or t==9]
      z[i][j][k]%=(pow(10,9)+7)
print z[0][0][0]

Submission status: Accepted

Solution code:
M = 10**9 + 7


def main():
    n = int(input())
    a = 1
    b = 1
    c = 1
    for i in range(n):
        a *= 10
        a %= M
        b *= 9
        b %= M
        c *= 8
        c %= M
    print((a - b - b + c) % M)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit, stdin

input = stdin.readline
import copy

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


def pow_mod(a, n, d):
    tmp = 1
    for _ in range(n):
        tmp = (tmp * a) % d
    return tmp


(N,) = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = (pow_mod(10, N, mod) + pow_mod(8, N, mod) - 2 * pow_mod(9, N, mod)) % mod

print(ans)

Submission status: Accepted

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

print((ten-nine-nine+eight)%MOD)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def test(N):
    MOD = 10**9+7
    U = (pow(10, N, MOD) - 1)%MOD
    notA = (pow(9, N, MOD) - 1)% MOD
    notB = (pow(9, N, MOD) - 1)% MOD
    A = (U - notA) % MOD
    B = (U - notB) % MOD
    AnorB = (pow(8, N, MOD) - 1)%MOD
    AorB = (U - AnorB) % MOD
    AandB = (A+B-AorB) %MOD
    #print(f"{U=}, {AorB=}, {A=}, {B=}, {AnorB=}")
    return AandB


def solve(N):
    MOD = 10**9+7
    dp = [[0, 0, 0, 0] for i in range(N+1)]
    dp[0] = [1, 0, 0, 0]
    A = 0
    B = 1
    C = 2
    D = 3
    for i in range(1, N+1):
        dp[i][A] = (dp[i-1][A]*8) % MOD
        dp[i][B] = (dp[i-1][A]   + dp[i-1][B]*9) % MOD
        dp[i][C] = (dp[i-1][A]   + dp[i-1][C]*9) % MOD
        dp[i][D] = (dp[i-1][B]   + dp[i-1][C]    + dp[i-1][D]*10) % MOD
        #print(i, dp[i], sum(dp[i]))
    return dp[N][D]

N = int(input())
print(test(N))
#print(solve(N))

Submission status: Accepted

Solution code:
def resolve():
    from itertools import permutations
    n = int(input())
    RES = 10 ** 9 + 7
    ans = 10 ** n - 2 * 9 ** n + 8 ** n
    print(ans % RES)

resolve()

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:
M = 10**9+7

def factorial(n):
    f = 1
    for i in range(1,n+1):
        f = f*i%M
    return f

def comb(n,k):
    if n==0 or k == 0:
        return 1
    if n<k:
        return 0

    return perm(n,k)*inverse(factorial(k))%M

def mcomb(n,k):
    return comb(n+k-1,k)

def perm(n,k):
    if n==0 or k == 0:
        return 1
    if n<k:
        return 0

    p = 1
    for i in range(n-k+1,n+1):
        p = p*i%M

    return p

def inverse(a):
    return pow(a,M-2,M)

def main():
    n = int(input())
    
    if n==1:
        print(0)
    else:
        ans = pow(10,n,M)-2*pow(9,n,M)+pow(8,n,M)
        ans %= M
        print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 10**n -2 * 9**n + 8**n
ans %= MOD

print(ans%MOD)

Submission status: Accepted

Solution code:
m = 10**9 + 7
def powmod(x,y):
  a=1
  for i in range(y):
    a=(a*x)%m
  return a
n=int(input())
s=powmod(10,n)-2*powmod(9,n)+powmod(8,n)
print((s+m)%m)

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:
N=int(input())
print((pow(10,N,1000000007)-pow(9,N,1000000007)*2+pow(8,N,1000000007))%1000000007)
#print((pow(10,N)-pow(9,N)*2+pow(8,N))%1000000007)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

mod = 10**9 + 7

if __name__ == "__main__":
    n = int(input())
    all0 = (10**n)
    no0 = (9**n)
    no9 = (9**n)
    no0and9 = (8**n)
    ans = (all0 - no0 - no9 + no0and9)%mod
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

a = (10**N-9**N)
b = a*2
c = b - ((10**N) - (8**N))

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

Submission status: Accepted

Solution code:
from sys import stdin
N = stdin.readline().rstrip()
N = int(N)
satisfied_pattern = 10**N - (2*(9**N) - 8**N)
output = satisfied_pattern % (10**9+7)
print(output)

Submission status: Accepted

Solution code:
n = int(input())

mod = int(1e9+7)

have_any = 1
not_have_0 = 1
not_have_9 = 1
not_have_09 = 1

for _ in range(n):
    have_any *= 10
    have_any %= mod

    not_have_0 *= 9
    not_have_0 %= mod

    not_have_09 *= 8
    not_have_09 %= mod

not_have_9 = not_have_0

ans = have_any - not_have_0 - not_have_9 + not_have_09
ans %= mod
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def powmod(a, n, _mod):
    res = 1
    for i in range(n):
        res = a * res % mod
    return res
N = int(input())

mod = 1000000007

ans = powmod(10, N, mod) - powmod(9, N, mod) - powmod(9, N, mod) + powmod(8, N, mod)
ans %= mod
if ans < 0:
    ans = (ans + mod) % mod
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
M = 1000000007
n = int(input())
if n == 1:
    print(0)
    exit(0)
a = pow(10, n, M)
b = 2 * (pow(9, n, M)) % M
c = pow(8, n, M)
ans = (a - b + c + M) % M
print(ans)

Submission status: Accepted

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

if n == 1:
  print(0)
elif n == 2:
  print(2)
else:
  a = pow(10,n) % mod
  b = pow(9,n) % mod
  c = pow(9,n) % mod
  d = pow(8,n) % mod
  print((a-b-c+d)%mod)

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
ans = 10 ** N - 9 ** N * 2 + 8 ** N
print(ans % mod)

Submission status: Accepted

Solution code:
n = int(input())

MOD = 10**9+7
# ans = (10**n-9**n) + (10**n-9**n) - (10**n-8**n)
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())
ans=10**n-2*(9**n)+8**n
ans=ans%1000000007
print(ans)

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())
mod = int(1e9) + 7

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

Submission status: Accepted

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

if n == 1:
  print(0)
elif n == 2:
  print(2)
else:
  a = pow(10,n) % mod
  b = pow(9,n) % mod
  c = pow(9,n) % mod
  d = pow(8,n) % mod
  print((a-b-c+d)%mod)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7


# def main(n):
#     tenn = mfact(8, n)
#     twon = mfact(2, n)
#     print(tenn, twon)
#     result = (tenn - 3 * twon - 1) % MOD
#     return result

def main(n):
    result = 0
    tens = 10
    eights = 9
    fives = 8
    for i in range(1, n+1):
        result = (tens - (2 * eights) + fives) % MOD
        tens = (tens * 10) % MOD
        eights = (eights * 9) % MOD
        fives = (fives * 8) % MOD
    return result


n = int(input())
print(main(n))

Submission status: Accepted

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

ans1=1
ans2=1
ans3=1

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

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

Submission status: Accepted

Solution code:
n=int(input())
if n<2:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

# 包除原理を用いる

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input(''))
A=10**9+7
if n==1:
    print(0)
elif n==2:
    print(2)
elif n>=3:
    e=1
    f=1
    g=1
    for i in range(n):
        e=e*10
        f=f*9
        g=g*8
        if e>=A:
           e=e%A
        if f>=A:
            f=f%A
        if g>=A:
            g=g%A

    print((e-f*2+g)%A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mod = 10**9+7
def powmod(x,y):
    res = 1
    for i in range(y):
        res = res*x%mod
    
    return res

N = int(input())
ans = powmod(10,N)-powmod(9,N)-powmod(9,N)+powmod(8,N)
ans %=mod
ans = (ans+mod)%mod
print(ans)

Submission status: Accepted

Solution code:
INF=1000000007;
def RepeatSquaring(N,P,M):
    if (P == 0):
      return 1;
    if (P % 2 == 0):
        t = RepeatSquaring(N, P / 2, M);
        return t * t % M;
    return N * RepeatSquaring(N, P - 1, M);
N=int(input())
A=RepeatSquaring(9,N,INF);
B=RepeatSquaring(8,N,INF);
C=RepeatSquaring(10,N,INF);
print((C+B-A*2)%INF)