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


def modpow(a, n, mod):
    """ 二分累乗法 """
    n_bin = bin(n)
    res = 1
    for i in range(len(n_bin)):
        res = res**2 % mod
        if n_bin[i] == '1':
            res = (res * a) % mod
    return res


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    MOD = 10**9 + 7
    ans =  pow(10, N, MOD)      # 全事象
    ans -=  pow(9, N, MOD) * 2  # 0の出ない確率+9の出ない確率
    ans +=  pow(8, N, MOD)      # 0かつ9の出ない確率
    ans %= MOD
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

while ans < 0:
    ans += mod
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:

mod = 1000000007
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
powof10 = 1
powof9 = 1
powof8 = 1
MOD = 10**9+7
for _ in range(n):
    powof10 *= 10
    powof10 %= MOD
    powof9 *= 9
    powof9 %= MOD
    powof8 *= 8
    powof8 %= MOD
print((powof10-2*powof9+powof8) % MOD)

Submission status: Accepted

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

n9 = 1
n8 = 1
n10 = 1

for i in range(N):
    n9 = (n9*9)%MOD
    n8 = (n8*8)%MOD
    n10 = (n10*10)%MOD

ans = n10 - 2*n9 + n8
print(ans%MOD)

Submission status: Accepted

Solution code:
from sys import stdin


def modpow(a, n, mod):
    """ 二分累乗法
    """
    n_bin = bin(n)
    res = 1
    for i in range(len(n_bin)):
        res = res**2 % mod
        if n_bin[i] == '1':
            res = (res * a) % mod
    return res


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    MOD = 10**9 + 7
    ans =  modpow(10, N, MOD)      # 全事象
    ans -=  modpow(9, N, MOD) * 2  # 0の出ない確率+9の出ない確率
    ans +=  modpow(8, N, MOD)      # 0かつ9の出ない確率
    ans %= MOD
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

def f(num):
    return pow(num, n, MOD)

print((f(10)-f(9)-f(9)+f(8))%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:
MOD = 1000000007
N = int(input())
A = 10 ** N - 2 * 9 ** N + 8 ** N
print(A % 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 =input()
N = int(N)
M = 10 ** 9 +7
x =  2 * 9 ** N % M
y = 8 ** N % M
z = 10 ** N % M - x + y
z = z % M
print(z)

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

Submission status: Accepted

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

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())
dp = [0 for j in range(4)]
dp[0] = 1
M = 1_000_000_007;
for i in range(N):
    x = dp[0]
    y = dp[1]
    z = dp[2]
    dp[0] = (x * 8) % M
    dp[1] = (y * 9 + x) % M
    dp[2] = (z * 9 + x) % M
    dp[3] = (dp[3] * 10 + y + z) % M
print(dp[3])

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())
p = 10 ** 9 + 7
a = 1
b = 1
c = 1
for i in range(n):
    a = (a * 10) % p
    b = (b * 9) % p
    c = (c * 8) % p
y = a - 2 * b + c
z = y % p
print(z)

Submission status: Accepted

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

Submission status: Accepted

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

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:
mod=1000000007
n=int(input())
a=pow(10,n,mod)
b=pow(9,n,mod)
c=pow(8,n,mod)
print((a-b-b+c)%mod)

Submission status: Accepted

Solution code:
#C問題　解説
MOD = 10**9 + 7
N = int(input())

#考え方はあってた
#a^N mod p はpow(a,N,p)で高速実装可能
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:
# -*- coding:utf-8 -*-

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
mod = 10**9 + 7
if n == 1:
	print(0)
	exit()
a = pow(10,n,mod)
b = pow(9,n,mod)
c = pow(8,n,mod)
ans = (a - (2*b) + c) % mod
if ans < 0:
	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))%mod
print(ans)

Submission status: Accepted

Solution code:
'''
Created on 2020/09/14

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  mod=10**9+7
  if N==1:
    print(0)
  elif N==2:
    print(2)
  else:
    ans1=1 #全体
    ans0=1  #0がないor9がない
    ans2=1 #0と9がない
    for i in range(N):
      ans1=(ans1*10)%mod 
      ans0=(ans0*9)%mod 
      ans2=(ans2*8)%mod 
    ans=(ans1-2*ans0+ans2)%mod
    print(ans)
  return
main()

Submission status: Accepted

Solution code:
## necessary imports
import sys
input = sys.stdin.readline
from bisect import bisect_left;
from bisect import bisect_right;
from math import ceil, factorial;

def ceil(x):
    if x != int(x):
        x = int(x) + 1;
    return x;
    
# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp;

## gcd function
def gcd(a,b):
    if b == 0:
        return a;
    return gcd(b, a % b);

## nCr function efficient using Binomial Cofficient
def nCr(n, k): 
    if(k > n - k): 
        k = n - k; 
    res = 1;
    for i in range(k): 
        res = res * (n - i);
        res = res / (i + 1); 
    return int(res);

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p): 
    res = 1
    x = x % p  
    if (x == 0) : 
        return 0
    while (y > 0) : 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
        y = y >> 1      
        x = (x * x) % p 
    return res 

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b;

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];
    
    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;


# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n): 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e5 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
# spf = [0 for i in range(MAXN)]
# spf_sieve();
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret;
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()));

def float_array():
    return list(map(float, input().strip().split()));

## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

n = int(input());
# ans = (10 ^ n) - 2 * (9 ^ n) + (8 ^ n);
ans = power(10, n, MOD) - 2 * power(9, n, MOD) + power(8, n, MOD);
print(ans % 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)) %MOD
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
MOD = 10 ** 9 + 7
if N == 1:
  print(0)
  exit()
a = pow(10, N, MOD)
b = pow(9, N, MOD)
c = pow(8, N, MOD)
ans = (a - (2 * b) + c) % MOD
if ans < 0:
  ans += MOD
print(ans)

Submission status: Accepted

Solution code:
import math

mod = 10**9 + 7

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

Submission status: Accepted

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

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

print(ans%MOD)

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline

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

dp = [[0 for _ in range(N + 3)] for _ in range(4)]
dp[0][0] = 1

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

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())
waru = 10**9+7
#nmod = n%(waru)
nmod = pow(10,n,waru)
#print(nmod)
#n1mod = int((n-1)%waru)
n1mod = pow(9,n,waru)*2
#print(n1mod)
#nnmod = int((9**(n-2))%waru)
nnmod = pow(8,n,waru)
#print(nnmod)
ans = (nmod-n1mod+nnmod) % waru
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
sys.setrecursionlimit(10**6)

MOD = 10**9+7


def main(input, print):
    n = int(input())

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


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

mod = 10**9 + 7
ans = 10**N - (9**N + 9**N - 8**N)
print(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())
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:
import sys
import math
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    MOD = 10 ** 9 + 7
    N = int(rl())
    ans = pow(10, N, MOD) - (2 * pow(9, N, MOD) - pow(8, N, MOD))
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()

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())
if n == 1:
    print(0)
    exit()

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
readline=sys.stdin.readline

N = int(readline())

DIV = 10 ** 9 + 7

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(readline())

DIV = 10 ** 9 + 7

print((pow(10, N, DIV) - 2 * pow(9, N, DIV) + pow(8, N, DIV)) % DIV)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    mod = 10**9+7
    print((pow(10,n,mod)-2*pow(9,n,mod)+pow(8,n,mod))%mod)

if __name__=='__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
                res %= mod
            x *= x % mod
            n >>= 1
        return res
 
    # 全パターン:10 ** n
    all_p = modpow(10, n, mod)
    # 0を含まないパタンーン:9 ** n
    not_0 = modpow(9, n, mod)
    # 9を含まないパターン:9 ** n
    not_9 = modpow(9, n, mod)
    # 0と９を含まないパターン:8 ** n
    not_0_9 = modpow(8, n, mod)
    # 条件のパターン
    ans = (all_p - not_0 - not_9 + not_0_9) % mod
    print(ans)
 
if __name__ == '__main__':
    main()

Submission status: Accepted

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

# 少なくとも0がはいる
in0 = 10**N - 9**N
# 少なくとも0がはいる
in9 = 10**N - 9**N
# 0または9がはいる
not0and9 = 10**N - 8**N

answer = in0 + in9 - not0and9

print(answer%MOD)

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
logk = N.bit_length()

# 一般項が出ない場合でも
# 漸化式にできるなら行列計算に落とし込める
dp = [[[0, 0, 0, 0] for i in range(4)] for i in range(logk)]
dp[0] = [[8, 1, 1, 0], [0, 9, 0, 1], [0, 0, 9, 1], [0, 0, 0, 10]]

# 行列掛け算 O(n3)かかる
def array_cnt(ar1, ar2):
    h = len(ar1)
    w = len(ar2[0])
    row = ar1
    col = []
    for j in range(w):
        opt = []
        for i in range(len(ar2)):
            opt.append(ar2[i][j])
        col.append(opt)

    res = [[[0, 0] for i in range(w)] for i in range(h)]
    for i in range(h):
        for j in range(w):
            cnt = 0
            for x, y in zip(row[i], col[j]):
                cnt += x * y
            res[i][j] = cnt
            res[i][j] %= mod
    return res

for i in range(1, logk):
    dp[i] = array_cnt(dp[i - 1], dp[i - 1])

ans = [[1, 0, 0, 0]]
for i in range(logk):
    if N & (1 << i):
        ans = array_cnt(ans, dp[i])
        
print(ans[0][-1] % mod)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
            x *= x % mod
            n >>= 1
        return res
 
    # 全パターン:10 ** n
    all_p = modpow(10, n, mod)
    # 0を含まないパタンーン:9 ** n
    not_0 = modpow(9, n, mod)
    # 9を含まないパターン:9 ** n
    not_9 = modpow(9, n, mod)
    # 0と９を含まないパターン:8 ** n
    not_0_9 = modpow(8, n, mod)
    # 条件のパターン
    ans = (all_p - not_0 - not_9 + not_0_9) % mod
    print(ans)
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def bekijou(a,x):
  MOD = 1000000007
  ret = 1
  for _ in range(x):
    ret *= a
    ret %= MOD
  return ret
    
n=int(input())
MOD = 1000000007
ret = (bekijou(10,n)+MOD-((2*bekijou(9,n)) % MOD)+bekijou(8,n))%MOD
print(ret)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
                res %= mod
            x *= x % mod
            n >>= 1
        return res

    # 全パターン:10 ** n
    all_p = modpow(10, n, mod)
    # 0を含まないパタンーン:9 ** n
    not_0 = modpow(9, n, mod)
    # 9を含まないパターン:9 ** n
    not_9 = modpow(9, n, mod)
    # 0と９を含まないパターン:8 ** n
    not_0_9 = modpow(8, n, mod)
    # 条件のパターン
    ans = all_p - not_0 - not_9 + not_0_9
    print(ans%mod)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	ret = pow(10, n, mod) - (pow(9,n, mod)*2)+pow(8, n, mod)
	ret %= mod
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
M=10**9+7
n=int(stdin.readline())
# a,b,c,d=list(map(int,stdin.readline().split()))
# pp=int(pow(10,n-2))
# ans=(pp*n*(n-1))
ans=(10**n)-2*(9**n)+(8**n)
print(ans%M)

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math,sys
P = 1000000007
# def modpow(a,n,mod):
#     res = 1
#     while n > 0:
#         if n & 1:
#             res = res * a % mod
#         a = a * a % mod
#         n >>= 1
#     return res

N = int(sys.stdin.readline())
print((pow(10,N,P)-pow(9,N,P)-pow(9,N,P)+pow(8,N,P))%P)

Submission status: Accepted

Solution code:
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

MOD = 1000000000 + 7

def powmod(x,y):
    res = 1
    for i in range(y):
        res = res*x%MOD

    return res

N = ini()

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())
mod = 10**9+7
a = 10**n-9**n-9**n+8**n
print(a%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:
# C - Ubiquity
def main():
    N = int(input())
    MOD = 10 ** 9 + 7
    res = (10 ** N - 2 * (9 ** N) + 8 ** N) % MOD  # inclusion–exclusion principle
    print(res)


if __name__ == "__main__":
    main()

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


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

print(int(x)%mod)

Submission status: Accepted

Solution code:
# @uthor : Kaleab Asfaw
from sys import stdin, stdout
# Fast IO
# from math import gcd

def input():
	a = stdin.readline()
	if a[-1] == "\n": a = a[:-1]
	return a
def print(*argv, end="\n", sep=" "):
	n = len(argv)
	for i in range(n):
		if i == n-1: stdout.write(str(argv[i]))
		else: stdout.write(str(argv[i]) + sep)
	stdout.write(end)
# Others
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n):
	return (((10**n) + (8**n)) - ((9**n)*2)) %(10**9+7)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#------------------------template--------------------------#
import os
import sys
# from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
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")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]


#-------------------------code---------------------------#
#vsInput()


n=Int()

tot=pow(10,n,M)
no9no0=pow(8,n,M)
no9but0=(pow(9,n,M)-pow(8,n,M)+M)%M
no0but9=no9but0

ans=(tot-no9but0-no9no0-no0but9)%M
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

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

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())
 
 
def ruizyou(x, n, S=1):
    
    S = 1
    for _ in range(n):
        S = (S*x)%(1e9+7)
    
    return S
    
a = int( ruizyou(10, N) + ruizyou(8, N) - ruizyou(9, N)*2 )
 
print(int(a%(1e9+7)))

Submission status: Accepted

Solution code:
from math import factorial as f
n = int(input())
ans = 10 ** n - 2 * 9 ** n + 8 ** n
print(ans % 1000000007)

Submission status: Accepted

Solution code:
N = int(input())

mod = pow(10,9)+7

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

print(ans%mod)

Submission status: Accepted

Solution code:
def binexp(a,b):
  res = 1
  while b>0:
    if b&1:
      res *= a
      res%=mod
    a *= a
    a%=mod
    b>>=1
  return res
mod = 1000000007
n = int(input())
if n==1:
  print(0)
elif n==2:
  print(2)
else:
  ans = binexp(10,n)
  ans1 = binexp(9,n)
  ans2 = binexp(8,n)
  print((ans-2*ans1+ans2)%mod)

Submission status: Accepted

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