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

Solution code:
/*Author--Vishwas Agrawal*/
/*Author--Vishwas Agrawal*/
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define test ll t; cin>>t; while(t--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define M 1000000007LL
#define input(v,n) inc(i,0,n){ll x; cin>>x; v.pb(x);}
#define print(v,n)   inc(i,0,n){cout<<v[i]<<" ";}
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define inc(i,a,n) for (ll i=a;i<n;i++)
#define dec(i,a,n) for (ll i=n-1;i>=a;i--)
long long binpow(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
long long mod(long long x){
return ((x%M+M)%M);
}

long long add(long long a, long long b){
return mod(mod(a)+mod(b));
}

long long mul(long long a, long long b){
return mod(mod(a)*mod(b));
}

int main()
{
  ll n;
  cin>>n;
  cout<<(binpow(10,n,1e9+7)-2*binpow(9,n,1e9+7)+binpow(8,n,1e9+7))%M;
   return 0;
}

Submission status: Runtime Error

Solution code:
import math


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


N = int(input())
ans = combinations_count(N, 2) * 10 ** (N-2) * 2 % (10**9 + 7)
print(ans)

Submission status: Runtime Error

Solution code:
# 整数の入力
N = int(input())
r = 2
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(10**(N-2) * combinations_count(n, r) / (10**9 + 7))

Submission status: Runtime Error

Solution code:
n = int(input())
x = n*(n-1)%1000000007
y = 10**(n-2)%1000000007
print((x*y)%1000000007

Submission status: Runtime Error

Solution code:
import sys
import math
from scipy.special import comb

mod = 10 ** 9 + 7

N = int(input())

if N <= 1:
    print(0)
    sys.exit()

# ans = comb(N, 2, exact=True) * 2 * (8 ** (N - 2)) + (9 ** N - 8 ** N) * 2
ans = 10 ** N - 8 ** N - (9 ** N - 8 ** N) * 2
print(ans % mod)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ld long double
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactive problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

ll power(ll x, ll y, ll p){
    ll res=1;
    while(y>0){
        if(y%2==1){
            res = (res*x)%mod;
        }
        x = (x*x)%mod;
        y=y/2;
    }
    return res;
}

int main(){ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll n;
    cin>>n;
    
    ll p1 = power(10, n, mod);
    ll p2 = 2*power(9, n, mod);
    ll p3 = power(8, n, mod);
    ll ans = (((((p1-p2)%mod) + mod)%mod) + p3)%mod;
    cout<<ans;

    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)
n = int(input())
p = pow(10, n-1)
if n == 1:
    print(0)
elif n==2:
    print(2)
else:
    a = (10**(n-2))%(10**9+7)
    b = ((int( nCr(n, 2) * 2) % (10**9+7) ))
    print((a*b)%(10**9+7))

Submission status: Runtime Error

Solution code:
n = int(input())
x = n*(n-1)*2(10**(n-2))

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

Submission status: Runtime Error

Solution code:
N = int(input())
mod = 10**9+7
import math
NN = math.factorial(N+7)
U = (NN*(N+8)*(N+9))/362880
A = (NN*(N+8))/40320
C = NN/5040
S = int((U-2*A+C)%mod)
print(S)

Submission status: Runtime Error

Solution code:
N = int(input())

num = N*(N-1)*(10**(N-2))/ (10**9 +7)
print(num)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}

const int maxn=1e6;
//const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int arr[maxn];
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=(ans*a)%MAX;
        b/=2;
        a=(a*a)%MAX;
    }
    return(ans);
}

void solve(){
    ll N;cin>>N;
    ll no_zero=power(9,N);
    ll no_nine=power(9,N);
    ll total=power(10,N);
    ll no_both=power(8,N);
    ll ans=(no_nine+no_zero)%MAX;
    ans=(ans-no_both+MAX)%MAX;
    total=(total-ans+MAX)%MAX;
    cout<<total;



    return;

}

int main(){
    IO


    //TEST
    solve();


}

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int,input().split())
ans = []
for i in c,d:
    ans.append(a*i)
for j in c,d:
    ans.append(b*j)

print(max(ans))

Submission status: Runtime Error

Solution code:
N = int(input())

num = (N*(N-1)*10**(N-2)) / (10**9 +7)
print(num)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

if(n == 1):
    print(0)
elif (n == 2):
    print(2)
else:
    kotae = 0
    a = power_func(10,n,MOD)
    b = power_func(9,n,MOD)
    c = power_func(8,n,MOD)

    kotae = a + c - ( 2 * b)
    kotae = kotae % MOD

print(kotae)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int,input().split())

if a*b>0 and c*d>0 and (a<0 ^ c<0):
  ans=max(a*d,b*c)
else:
  ans=max(a*c,b*d)
print(ans)

Submission status: Runtime Error

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

if(n == 1):
    print(0)
elif (n == 2):
    print(2)
else:
    kotae = 0
    a = 1
    b = 1
    c = 1
    for i in range(n):
        a *= 10
        b *= 9
        c *= 8
        a = a % MOD
        b = b % MOD
        c = c % MOD
    kotae = a + c - ( 2 * b)
    kotae = kotae % MOD

print(kotae)

Submission status: Runtime Error

Solution code:
import operator

def ncr(n, r):
    if n < r: return 0
    r = min(r, n-r)
    if r == 0: return 1
    numer = functools.reduce(operator.mul, range(n, n-r, -1), 1)
    denom = functools.reduce(operator.mul, range(1, r+1), 1)
    return numer // denom

def solve():
    n = int(input())
    if n < 2:
        print(0)
    elif n == 2:
        print(2)
    else:
        ans = ncr(n, 2)*2 + 9**(n-2)
        ans %= 10**9+7
        print(ans)
    return 0

if __name__ == "__main__":
    solve()