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:
import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
mod = 10**9+7
if (n==1):
    print(0)
elif (n==2):
    print(2)
else:
    ans = 1
    no1 = 1
    no2 = 1
    for i in range(n):
        ans *= 10
        ans %= mod
        no1 *= 9
        no1 %= mod
        no2 *= 8
        no2 %= mod
    print((ans-2*no1+no2)%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
mod = 1000000007
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:
N = int(input())
mod = 10 ** 9 + 7
res = (10 ** N) % mod
res = res - ((9 ** N) % mod) # no 9
res = res - ((9 ** N) % mod) # no 0
res = res + ((8 ** N) % mod) # no 9 and no 0
print(res % mod)

Submission status: Accepted

Solution code:
(N,) = [int(x) for x in input().split()]

MOD = 10 ** 9 + 7

if N <= 1:
    print(0)
    exit()
else:
    total = pow(10, N, MOD)
    noZeroes = pow(9, N, MOD)
    noNines = pow(9, N, MOD)
    noZeroOrNines = pow(8, N, MOD)
    print((total - noZeroes - noNines + noZeroOrNines) % MOD)

Submission status: Accepted

Solution code:
N=int(input())

ten=1
nine=1
eight=1

mod=10**9+7

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

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:
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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def soinsubunkai_e(n,m): #高速素因数分解 m[n]=nを割ることの出来る最小の素数
    a = set()
    i = 1
    while n>1:
        a.add(m[n])
        n=n//m[n]
    nokori=n
    a.add(nokori)
    return a

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def era(n): #b[n]=nを割ることの出来る最小の素数　の配列を生成　エラトステネスの篩
    b=[i for i in range(n+1)]
    for i in range(2,int(math.sqrt(n)+10)):
        j=1
        temp=i*j
        while temp<=n:
            b[temp]=min(i,b[temp])
            temp+=i
    return b


def main():
    #l,r,d=map(int,input().split())
    n=int(input())
    ans=0
    not0=1
    all=1
    not01=1
    for i in range(n):
        not0*=9
        all*=10
        not01*=8
        not0%=MOD
        all%=MOD
        not01%=MOD
    if n>=2:
        ans=all-2*not0+not01
        ans%=MOD
    #a
    print(ans)






if __name__ == "__main__":

    main()

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())
#a = list(map(int, input().split()))
#a, b, c, d = map(int, input().split())

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

Submission status: Accepted

Solution code:
N = int(input())

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


def fexp(x, y):
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = ans * x % mod
        x = x * x % mod
        y //= 2
    return ans


n = int(input())
ans = fexp(10, n) - 2 * fexp(9, n) + fexp(8, n)
ans %= mod
if ans < 0:
    ans += mod
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ===============================================================================================
# importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb  # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
# If the element is already present in the list,

# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect

# If the element is already present in the list,
# the right most position where element has to be inserted is returned

# ==============================================================================================
# fast I/O region

BUFSIZE = 8192
from sys import stderr


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

# inp = lambda: sys.stdin.readline().rstrip("\r\n")

# ===============================================================================================
### START ITERATE RECURSION ###
from types import GeneratorType


def iterative(f, stack=[]):
    def wrapped_func(*args, **kwargs):
        if stack: return f(*args, **kwargs)
        to = f(*args, **kwargs)
        while True:
            if type(to) is GeneratorType:
                stack.append(to)
                to = next(to)
                continue
            stack.pop()
            if not stack: break
            to = stack[-1].send(to)
        return to

    return wrapped_func


#### END ITERATE RECURSION ####

# ===============================================================================================
# some shortcuts

mod = 1000000007


def inp(): return sys.stdin.readline().rstrip("\r\n")  # for fast input


def out(var): sys.stdout.write(str(var))  # for fast output, always take string


def lis(): return list(map(int, inp().split()))


def stringlis(): return list(map(str, inp().split()))


def sep(): return map(int, inp().split())


def strsep(): return map(str, inp().split())


def zerolist(n): return [0] * n


def nextline(): out("\n")  # as stdout.write always print sring.


def testcase(t):
    for p in range(t):
        solve()


def printlist(a):
    for p in range(0, len(a)):
        out(str(a[p]) + ' ')


def pow(x, y, p):
    res = 1  # Initialize result
    x = x % p  # Update x if it is more , than or equal to p
    if (x == 0):
        return 0
    while (y > 0):
        if ((y & 1) == 1):  # If y is odd, multiply, x with result
            res = (res * x) % p

        y = y >> 1  # y = y/2
        x = (x * x) % p
    return res


from functools import reduce


def factors(n):
    return set(reduce(list.__add__,
                      ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))


def gcd(a, b):
    if a == b: return a
    while b > 0: a, b = b, a % b
    return a


# =========================================================================================

def solve():
    N=10**9 +7
    n=int(inp())
    if n==1:
        print(0)
    else:
        print(((pow(10,n,N)-2*pow(9,n,N)+pow(8,n,N))%N + N)%N)


solve()
# testcase(int(inp()))

Submission status: Accepted

Solution code:
M = 10 ** 9 + 7

N = int(input())

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

print(total)

Submission status: Accepted

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

w = pow(10,N,MOD)
n = w - pow(9,N,MOD)
e = w - pow(8,N,MOD)
a = n*2 - e
print(a%MOD)

Submission status: Accepted

Solution code:
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def NLI(n):return [[int(i) for i in input().split()] for i in range(n)]
def NLI_(n):return [[int(i)-1 for i in input().split()] for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def RLI(n=8,a=1,b=10):return [random.randint(a,b)for i in range(n)]
def RI(a=1,b=10):return random.randint(a,b)
def INP():
    N=10;A=10
    n=random.randint(1,N)
    a=[random.randint(1,A) for i in range(n)]
    return n,a
def Rtest(T):
    case,err=0,0
    for i in range(T):
        inp=INP()
        a1=naive(*inp)
        a2=solve(*inp)
        if a1!=a2:
            print((a1,a2),inp)
            err+=1
        case+=1
    print('Tested',case,'case with',err,'errors')
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
#mo=998244353
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**9)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()


class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True

ans=0

n=I()

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



print(ans%mo)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        ret = power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        ret = n * power(n, r-1, mod) % mod
    return ret


M = 10 **9 + 7
n = int(input())
out = power(10, n, M)  - 2*  power(9, n, M) + power(8, n, M)
out = out %M

print(out)

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

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

from math import factorial as fac

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

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

Submission status: Accepted

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

sm1=1
sm2=1
sm3=1
for i in range(n):
    sm1*=10
    sm1%=mod
for i in range(n):
    sm2*=9
    sm2%=mod
for i in range(n):
    sm3*=8
    sm3%=mod
sm=sm1-2*sm2+sm3
sm%=mod
print(sm)

Submission status: Accepted

Solution code:
N = int(input())
MOD = 1000000007
A = pow(10, N, MOD)
B = pow(9, N, MOD)
C = pow(8, N, MOD)
X = A - 2 * B + C
print(X % 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))%mod
print(ans)

Submission status: Accepted

Solution code:
from sys import exit
import math
import collections
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

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

Submission status: Accepted

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