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: Time Limit Exceeded

Solution code:
#coding: UTF-8
def n_mod(a, n, mod):
  res = 1
  while(n > 0):
    if n & 1:
      res = res * a % mod
    a = a * a % mod
    n = n >> 1
  return res

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

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

N = int(input())
MOD = 1000000007

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 )
    
now = n_mod(10, N, MOD) - n_mod(9, N, MOD)
for i in range(1,N):
  now = (now - n_mod(8, N-i, MOD) * cmb(N, i, MOD)) % MOD

print(now-1)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n = int(input())
nums = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
  
if n == 1:
  print(0)
elif n == 2:
  print(2)
else:
  count = 0
  for v in itertools.product(nums, repeat=n):
    check = list(v)
    if "0" in check and "9" in check:
      count += 1
  print(count%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
from math import factorial

N = int(input())
if N == 1:
    ans = 0
else:
    # N == 3
    # [[0|9], [0|9], [1-8]] = (3! * 8^1 * (2^2 - 2)) / 2! * 1!
    # [[0|9], [0|9], [0|9]] = (3! * 8^0 * (2^3 - 2)) / 3! * 0!
    # N == 4
    # [[0|9], [0|9], [1-8], [1-8]] = (4! * 8^2 * (2^2 - 2)) / 2! * 2!
    # [[0|9], [0|9], [0|9], [1-8]] = (4! * 8^1 * (2^3 - 2)) / 3! * 1!
    # [[0|9], [0|9], [0|9], [0|9]] = (4! * 8^0 * (2^4 - 2)) / 4! * 0!
    ans = 0
    factorial_N = factorial(N)
    factorial_r = factorial_N // N
    e = 8 ** (N-2)
    t = 2
    rem = N - 2
    for i in range(2, N+1):
        t *= 2
        factorial_N = factorial_N // i
        factorial_r = factorial_r // (rem + 1)
        ans += (factorial_N * e * (t - 2)) // factorial_r
        e = e // 8
        rem -= 1
print(ans % (10**9 + 7))

Submission status: Time Limit Exceeded

Solution code:
def modInv(a, m) : 
    m0 = m 
    y = 0
    x = 1
  
    if (m == 1): 
        return 0
  
    while (a > 1): 
        q = a // m 
        t = m 
        m = a % m 
        a = t 
        t = y 
        y = x - q * y 
        x = t 
        
    if (x < 0) : 
        x = x + m0 
    return x 

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

fact = [0]*(n+1)

fact[0] = 1
fact[1] = 1

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

ans = 0

for i in range(2, n+1):
    x = pow(2, i, M) - 2
    y = fact[n]
    y = (y * modInv(fact[i] * fact[n-i], M))%M
    z = pow(8, n-i, M)
    ans = (ans + (((x*y)%M)*z)%M)%M
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

  
n = int(input())
if n == 1:
  print(0)
  sys.exit()

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 )

pow8 = [0]*(n+1)
pow8[0] = 1
for i in range(1,n+1):
  pow8[i] = (pow8[i-1]*8) % mod


ans = (10**n) % mod - pow8[n]
for i in range(1,n+1):
  ans = (ans - pow8[n-i]*2*cmb(n,i,mod)) % mod
               
print(ans)

Submission status: Time Limit Exceeded

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

P = 10 ** 9 + 7


def combination(n, r):
    x = 1
    y = 1
    for i in range(n - r + 1, n + 1):
        x = (x * i % P)
    for i in range(1, r + 1):
        y = (y * i % P)
    y_inv = _power(y, P - 2)
    return (x * y_inv) % P


def _power(x, n):
    ans = 1
    while n > 0:
        if bin(n & 1) == bin(1):
            ans = (ans * x) % P
        x = (x * x) % P
        n = n >> 1
    return ans


def power(x, n):
    ans = 1
    while n > 0:
        if bin(n & 1) == bin(1):
            ans = (ans * x) % P
        x = (x * x) % P
        n = n >> 1
    return ans


ans = 0
for i in range(N):
    ans += power(8, i) * combination(N, i) * 2

print(power(10, N) - ans - power(8, N))

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
n = int(input())

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

res = 0
for i in range(1, n):
    for j in range(1, (n-i)+1):
        res += combinations_count(n, i) * combinations_count(n-i, j) * (8**((n-i)-j))
print(res % ((10**9)+7))

Submission status: Time Limit Exceeded

Solution code:
digit = int(input())
li = []
if digit == 1:
	print("0")
elif digit == 0:
	print("0")
elif digit == 2:
	print("2")
else:
	for i in range((10 ** digit) - 1):
		i = str(i)
		i = i.zfill(digit)
		li.append(i)
	count = 0
	for i in li:
		if "0" in i and "9" in i:
			count += 1
		if count >= 1000000007:
			count = 1
	print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import numpy as np

N = int(input())

L = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

count = 0
ptr_num = np.array(list(itertools.product(L, repeat=N)))

print(np.count_nonzero(np.any(ptr_num == 0, axis=1) & np.any(ptr_num == 9, axis=1)))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

mod = 10**9+7
MAX = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

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

buf=0
for k in range(1,N+1):
    for j in range(1,N-k+1):
        buf += (cmb(N,k,mod)*cmb(N-k,j,mod)*(8**(N-k-j)%mod))%mod
        buf = buf % mod
print(buf)

Submission status: Time Limit Exceeded

Solution code:
def comb(a, b, mod):
    c, d = 1, 1
    for i in range(a, a - b, -1):
        c = c * (i % mod) % mod

    for i in range(1, b + 1):
        d = d * (i % mod) % mod
        
    return((c // d)% mod)


N = int(input())

mod = 10 ** 9 + 7
r = 8

list_ans = []
for n0 in range(1, N):
    for n9 in range(1, N - n0 + 1):
        n_nokori = N - n0 - n9
        comb_0 = comb(N, n0, mod)
        comb_9 = comb(N - n0, n9, mod)
        
        tmp = 1
        for i in range(n_nokori):
            tmp = (tmp * r) % mod
        
        ans = ((comb_0 % mod) * (comb_9 % mod) * tmp) % mod
        list_ans.append(ans)
        
#         print(f'n0, n9: {n0}, {n9}')
#         print(f'comb_0, comb_9: {comb_0}, {comb_9}')
#         print(ans)
#         print()
        
ans2 = 0
for ans in list_ans:
    ans2 = (ans2 + ans) % mod

print(ans2)

Submission status: Time Limit Exceeded

Solution code:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())

# all = 0
# for i in range(2, N+1):
#     basyo = combinations_count(N, i)
#     # basyo = permutations_count(N, i) / 2  # 9と0が入る場所。i箇所。
#     # zerokyuu = i*(i-1)*2(i-2)  # 入る場所に0と9を入れる。
#     zerokyuu = 2**i - 2  # 全部0と全部9を抜く。
#     iti_hachi = 8**(N-i)  # 残った部分に1-8が入る全通り
#     all += basyo * zerokyuu * iti_hachi

lis = [int(combinations_count(N, i) * (2**i - 2) * (8**(N-i))) for i in range(2, N+1)]
print(sum(lis) % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

a=1
b=1
c=1

for i in range(N):
    a*=9
    b*=8
    c*=10
A=c-2*a+b

print(A%(1000000007))

Submission status: Time Limit Exceeded

Solution code:
m = 1000000007

factorials = [1]

for i in range(1,1000001):
    factorials.append((factorials[-1]*i) % m)

n = int(input())

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

    singles = 0
    for i in range(1,n+1):

        comb = (factorials[n] * pow(factorials[n-i],m-2,m) * pow(factorials[i],m-2,m)) % m
        singles += (comb * pow(8,n-i,m)) % m

    temp = pow(10,n,m) - pow(8,n,m) - 2*singles
    print(temp % m)

Submission status: Time Limit Exceeded

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

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

def pow(a, n, p):
    bi = str(format(n, 'b'))
    res = 1
    for i in range(len(bi)):
        res = (res * res) % p
        if bi[i] == '1':
            res = (res * a) % p
    return res

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

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

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    ans = 0
    for i in range(2, n + 1):
        tryvalue = ((pow(2, i, p) - 2)*cmb(n, i, p)*pow(8, n-i, p))
        ans = (ans + tryvalue) % p
    print(ans)

Submission status: Time Limit Exceeded

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

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

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
  """a^b mod 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

if N == 1:
  print("0")
else:
  ans = 0
  for i in range(1,N+1):
    for j in range(1,N-i+1):
      ans = (ans+comb(N,i,p)*comb(N-i,j,p)*8**(N-i-j))%p
  print(ans)

Submission status: Time Limit Exceeded

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

base = comb(5,3)
N = int(input())
all = 10**N
cnt=0
for i in range(1, N+1):
    cnt+=2*(8**(N-i))*comb(N, i)
else:
    cnt+=8**N
print((all-cnt)%((10**9)+7))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n == 1:
  print(0)
elif n == 2:
  print(2)
else:
  sn = n*"9"
  count = 0
  for i in range(1,int(sn)+1):
    check = str(i).zfill(n)
    if "0" in check and "9" in check:
      count += 1
  print(count%(10**9+7))

Submission status: Time Limit Exceeded

Solution code:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
if N==1:
  print(0)
else:
  ans = 0
  for i in range(N-1):
    a1= combinations_count(N, i+2) % 1000000007
    a2=(8**(N-(i+2))) % 1000000007
    a3=((2**(i+2))-2)%1000000007
    ans += a1*a2*a3
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

q = int(1e9+7)

comb = [1]

for i in range(0, N):
    comb.append((comb[-1] * (N - i) * pow(i+1, q-2, q)) % q)

base = [pow(8, N-2, q)]
for i in range(2, N+1):
    base.append((base[-1] * pow(8, q-2, q)) % q)

ans = 0
for i in range(2, N + 1):
    ans = (ans + (base[i-2] * comb[i] * (pow(2, i, q) - 2)) % q) % q
print(ans)

Submission status: Time Limit Exceeded

Solution code:
mod = 10**9 + 7

# x ** a をmodで割った余りを、O(log(a))時間で求める。
def power(x, a):
    if a == 0:
        return 1
    elif a == 1:
        return x
    elif a % 2 == 0:
        return power(x, a//2) **2 % mod
    else:
        return power(x, a//2) **2 * x % mod

# xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はO(log(mod))程度。
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  # 分子
    denomi = 1  # 分母

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod

def mypow(x, n):
    res = 1
    while n > 0:
        if n & 1 == 1:
            res *= x
        x *= x
        n >>= 1
    return res

ans = 0
N = int(input())
for i in range(1,N):
    for j in range(1,N-i+1):
        ans = ans + ((binomial_coefficients(N, i)%mod)*(binomial_coefficients(N-i, j)%mod)*(mypow(8,N-i-j)%mod))%mod

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

if n == 1:
  print(0)
elif n == 2:
  print(2)
else:
  sn = n*"9"
  count = 0
  for i in range(1,int(sn)+1):
    check = str(i).zfill(n)
    if "0" in check and "9" in check:
      count += 1
  print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
# def permutations_count(n, r):
#     return math.factorial(n) // math.factorial(n - r)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())

sum = 0
for i in range(2, N+1):
    basyo = combinations_count(N, i)
    # basyo = permutations_count(N, i) / 2  # 9と0が入る場所。i箇所。
    # zerokyuu = i*(i-1)*2(i-2)  # 入る場所に0と9を入れる。
    zerokyuu = 2**i - 2  # 全部0と全部9を抜く。
    iti_hachi = 8**(N-i)  # 残った部分に1-8が入る全通り
    sum += basyo * zerokyuu * iti_hachi

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

Submission status: Time Limit Exceeded

Solution code:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
if N==1:
  print(0)
else:
  ans = 0
  for i in range(N-1):
    ans += ((2**(i+2))-2)*combinations_count(N, i+2)*(8**(N-(i+2)))
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())

L = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
A = list(itertools.product(L, repeat=N))

count = 0

for a in A:
    if (0 in a) and (9 in a):
        count += 1

print(count % (1000000007))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
p = 10**9 + 7
dp=[[[0]*(2) for i in range(2)] for i in range(n+1)]
dp[0][0][0]=1

for i in range(n):
  dp[i+1][1][1] += (dp[i][1][1] * 10 + dp[i][0][1]+ dp[i][1][0])
  dp[i+1][1][1] %= p
  dp[i+1][1][0] += (dp[i][1][0] * 9 + dp[i][0][0])
  dp[i+1][1][0] %= p
  dp[i+1][0][1] += (dp[i][0][1] * 9 + dp[i][0][0])
  dp[i+1][0][1] %= p
  dp[i+1][0][0] += (dp[i][0][0] * 8)
  dp[i+1][0][0] %= p
print(dp[n][1][1])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
mod=10**9+7
if N==1:
  print(0)
  exit()
dp=[[0,0,0,0]for i in range(N-1)]
dp[0]=[64,17,17,2]
for i in range(N-2):
  dp[i+1][3]=dp[i][1]+dp[i][2]+dp[i][3]*10
  dp[i+1][2]=dp[i][0]+dp[i][2]*9
  dp[i+1][1]=dp[i][0]+dp[i][1]*9
  dp[i+1][0]=dp[i][0]*8
  dp[i+1][3]%=mod
  dp[i+1][2]%=mod
  dp[i+1][1]%=mod
  dp[i+1][0]%=mod
print(dp[-1][-1])

Submission status: Accepted

Solution code:
n = int(input())
MOD = 10**9 + 7
u = pow(10, n, MOD)
v = pow(9, n, MOD)
w = pow(8, n, MOD)

print( (u - 2*v + w) % MOD)

Submission status: Accepted

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
import random
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()



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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")

MOD = 1000000007

# 処理内容
def main():
    N = int(input())
    
    a = 1
    for _ in range(N):
        a = a * 10 % MOD
    
    b = 1
    for _ in range(N):
        b = b * 9 % MOD
    
    c = 1
    for _ in range(N):
        c = c * 8 % MOD
    
    ans = (a - 2*b + c) % MOD
    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())
M = 10**9+7
a = 10**N-2*9**N+8**N
print(a%M)

Submission status: Accepted

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

Submission status: Accepted

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

#負の処理
ans = (ans+MOD)%MOD

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
mod=10**9+7
x=pow(10,n,mod)
y=pow(9,n,mod)
z=pow(8,n,mod)
print((x-2*y+z)%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())
print((10**n-9**n*2+8**n)%(10**9+7))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# C - Ubiquity
N = int(input())
all = 1
no_1 = 1
no_1_and_9 = 1
mod = 10 ** 9 + 7

for _ in range(N):
  all *= 10
  all %= mod

  no_1 *= 9
  no_1 %= mod

  no_1_and_9 *= 8
  no_1_and_9 %= mod

print((all - (no_1 * 2 - no_1_and_9)) % mod)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
mod = int(1e9) + 7
def doubling(n, m):
    y = 1
    bas = n
    tmp = m
    while tmp:
        if tmp % 2:
            y *= bas
            y %= mod
        bas *= bas
        bas %= mod
        tmp >>= 1
    return y
d10 = doubling(10, N)
d9 = doubling(9, N)
d8 = doubling(8, N)
print((d10 - 2*d9 + d8) % mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mod = 1000000007
def ff(a, b):
  ans = 1
  while b:
    if b & 1: ans = ans * a % mod
    b >>= 1
    a = a * a % mod
  return ans
n=int(input())
print(((ff(10,n)-2*ff(9,n)+ff(8,n))%mod+mod)%mod)

Submission status: Accepted

Solution code:
mod = 1000000007
def ff(a, b):
  ans = 1
  while b:
    if b & 1: ans = ans * a % mod
    b >>= 1
    a = a * a % mod
  return ans
n=int(input())
print(((ff(10,n)-2*ff(9,n)+ff(8,n))%mod+mod)%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''
参考
https://qiita.com/u2dayo/items/98917c94c89c77b9b3a1#c%E5%95%8F%E9%A1%8Cubiquity
'''

MOD = 10 ** 9 + 7

N = int(input())

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

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 = 7+10**9
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())
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:
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:
N = int(input())

mod = int(1000000007)


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

print(ans%mod)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

def modpow(n, p, m):
    if p == 0:
        return 1
    if p % 2 == 0:
        t = modpow(n, p // 2, m)
        return t * t % m
    return n * modpow(n, p - 1, m) % m

n = ni()

A = modpow(9, n, mod)
B = A
C = modpow(8, n, mod)
D = modpow(10, n, mod)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mod = pow(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:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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
r_1,r_2,r_3 = 1,1,1

for i in range(n):
    r_1 = r_1 * 10 % mod
    r_2 = r_2 * 9 % mod
    r_3 = r_3 * 8 % mod

print((r_1-r_2-r_2+r_3)%mod)

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())
m = 10**9+7
a = 10**n - 9**n - 9**n + 8**n
print(a % m)

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)
ans %= mod

print(ans)

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)
ans %= 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())
if n==1:
  print(0)
else:
  zen=10**n
  no=8**n
  zero=zen-9**n
  x=no+2*zero-zen
  print(int(x%(10**9+7)))

Submission status: Accepted

Solution code:
def modpow(a, n, mod):
    res = 1
    while n:
        if n % 2:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


MOD = 1000000007

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

a, b, c = 1, 1, 1

for i in range(n):
    a *= 10;
    b *= 9;
    c *= 8;
    a %= MOD;
    b %= MOD;
    c %= MOD;
    
print((a - 2 * b + c) % MOD);

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

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

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

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)

print(ans%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num=int(input())
num2=[10, 9 ,8]



def multi(x):
	y=x**num
	return y


a, b, c=map(multi, num2)
print((a-2*b+c)%(int(1e9+7)))

Submission status: Accepted

Solution code:
num=int(input())
num2=[10, 9 ,8]

num2a=map(int, num2)

def multi(x):
	y=x**num
	return y


a, b, c=map(multi, num2a)
print((a-2*b+c)%(int(1e9+7)))

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)
print(A%mod)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  N=int(input())
  m=int(1e9+7)
  print((pow(10,N,m)-pow(9,N,m)-pow(9,N,m)+pow(8,N,m))%m)
if __name__=='__main__':
  main()

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

MOD = 1000000007
whole = 10**n % MOD
bad = (9**n + 9**n - 8**n) % MOD
ans = (whole - bad) % MOD

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n = int(input())
a = pow(10, n, 10**9+7)
b = pow(9, n, 10**9+7)
c = pow(9, n, 10**9+7)
d = pow(8, n, 10**9+7)
print((a-b-c+d) % (10**9+7))

Submission status: Accepted

Solution code:
n = int(input())

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    x = (10 ** 9) + 7
    a = (10 ** n) % x
    b = (9 ** n) % x
    c = (8 ** n) % x
    y = a - b * 2 + c
    if y < 0:
        y += x
    y %= x
    print(y)

Submission status: Accepted

Solution code:
from sys import exit

def mod_pow(a, n, p):
    """累乗 O(logN)

    Args:
        a (int): 対象の値
        n (int): 指数
        p (int): 除数

    Returns:
        int: a^n mod p
    """
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % p
        a = a * a % p
        n >>= 1
    return res

def mod_comb_k(n, k, p):
    """二項係数 0(1)

    Args:
        n (int): 添字
        k (int): 添字
        p (int): 除数

    Returns:
        int: nCk mod p
    """
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return fact[n] * fact_inv[k] * fact_inv[n-k] % p

def com_init(n, p):
    """二項係数の計算の前処理 O(N)

    Args:
        n (int): 上限値
        p (int): 除数
    """
    for i in range(n):
        fact.append(fact[-1] * (i+1) % p)

    fact_inv[-1] = pow(fact[-1], p-2, p)
    for i in range(n-1, -1, -1):
        fact_inv[i] = fact_inv[i+1] * (i+1) % p


n = int(input())

mod = 10 ** 9 + 7

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

res1 = mod_pow(10, n, mod)
res2 = mod_pow(8, n, mod)
res3 = 0
fact = [1]
fact_inv = [0] * (n+1)
com_init(n, mod)
for i in range(1, n+1):
    res3 = (res3 + mod_pow(8, n-i, mod) * mod_comb_k(n, i, mod) % mod) % mod
print(((res1 - res2) % mod - res3 * 2 % mod) % mod)

Submission status: Accepted

Solution code:
mod = 1000000007

n = int(input())

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

print(ans % mod)

Submission status: Accepted

Solution code:
# n = int(input())
# mod = 10**9+7
# print((10**n - (9**n)*2 + 8**n) % mod)
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:
def main():
    mod=1000000007
    n=int(input())
    if n==1:
        return 0
    
    inv=lambda x: pow(x,mod-2,mod)
    Fact=[1] #階乗
    for i in range(1,n+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(n+1) #階乗の逆元
    Finv[-1]=inv(Fact[-1])
    for i in range(n-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod

    ans=0
    p=2**2
    others=pow(8,n-2,mod)
    for i in range(2,n+1):
        c=comb(n,i)
        ans+=(p-2)*others*c
        ans%=mod
        p*=2
        p%=mod
        others*=inv(8)
        others%=mod
    return ans

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

div = 1000000000+7

p10 = pow(10,n)
p9 = pow(9,n)
p8 = pow(8,n)


ans = p10-2*p9+p8
ans %= div

print(ans)