TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
import math
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())

answer = 0
rest = 10 ** 9 + 7
  
if N == 1:
  answer = 0
else:
  answer = cmb(N, 2) * 2 * (10 ** (N - 2))
print(answer % rest)

a = cmb(N, 2)
print(a)


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())

answer = 0
rest = 10 ** 9 + 7
if N == 1:
  answer = 0
else:
  answer = (10 ** N) - (9 ** N) - (9 ** N) + (8 ** N)
print(answer % rest)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
mod = 1000000007
def f(a, b):
  ans = 1
  while b:
    ans = ans * a % mod
    b >>= 1
    a = a * a % mod
  return ans
n=int(input())
print(((f(10,n)-2*f(9,n)+f(8,n))%mod+mod)%mod)

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)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

N = int(input())
 
print( (10**(N-2) * N * (N-1) - (N * (N-1))) % (10**9 + 7))

import math

N = int(input())
r = 2
def combinations_count(N, r):
    return math.factorial(N) // (math.factorial(N - r) * math.factorial(r))
 
print(math.ceil(10**(N-2) * combinations_count(N, r) / (10**9 + 7)))


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

import math

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


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

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

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

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

N = int(input())
r = 2

print(combinations_count(N, r))

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


N = int(input())
r = 2

print(combinations_count(N, r) * 10**(N-r) % (10**9 +7))


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


N = int(input())

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


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


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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
mod = 10**9+7
ans = pow(10, n, mod)
ans -= pow(9, n, mod)
ans += pow(8, n, mod)
print(ans % mod)


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)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

mod = 10 ** 9 + 7

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

print(10 ** int(input()) - 2 * 9 ** int(input()) + 8 ** int(input()))

N = int(input())

mod = 10 ** 9 + 7

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):


#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long a = 1, b = 1, c = 1;
    for (int i = 0; i < n; i++)
    {
        a *= 10;
        a %= 1000000007;
        b *= 9;
        b %= 1000000007;
        c *= 8;
        c %= 1000000007;
    }
    cout << (a-b-b+c+1000000007)%1000000007 << endl;
}

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
m=10**9+7
n=int(input())
a=(8**n)%m
b=(9**n)%m
c=(10**n)%m
print((2*b-c+a)%m)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,d = map(int, input().split())

if a >= 0 and c >= 0:
  print(b*d)
elif b <= 0 and d <= 0:
  print(a*c)
elif a < 0 and c < 0:
  if b<=0 or d<=0:
    print(a*c)  
  elif abs(a)>=abs(b) and abs(c)>=abs(d):
    print(a*c)
  else:
    print(b*d)
elif (b<0 and c>=0):
  print(b*c)
elif (a>=0 and d<0):
  print(a*d)
else:
  print(b*d)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys

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


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

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


import sys

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


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

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
print((10**N-9**N-9**N+8**N)/(10**7+7)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
y=(2**3)-2
x=y*9**(y-2)%(10**9+7)
if x<10**10:print(x)
else:print('ERROR')

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())

if N<2:
	print(0)
ellif N==2:
	print(2)
else:
	without=10**(N-2)
	considered=(without+2)*(without+1)
	considered=considered%(1000000007)
	print(considered)
	


N=869121

if N<2:
	print(0)

else:
	without=10**(N-2)
	each=N*(N-1)
	final=without*each-each

	considered=final%(10**9+7)

	print(considered)

N=input()

if N<2:
	print(0)
elif N==2:
	print(2)
else:
	without=10*(N-2)
	considered=(without+2)*(without+1)/2
	print(considered)

N=int(input())

if N<2:
	print(0)

else:
	without=10**(N-2)
	each=N*(N-1)
	final=without*each-each

	considered=final%(10**9+7)

	print(considered)


N=input()

if N<2:
	print(0)
elif N==2:
	print(2)
else:
	without=10*(N-2)
	considered=without*(without-1)/2
	print(considered)

N=869121

if N<2:
	print(0)

else:
	without=10**(N-2)
	considered=(without+2)*(without+1)
	considered=considered%(1000000007)
	print(considered)
	

N=int(input())

if N<2:
	print(0)

else:
	without=10**(N-2)
	each=N*(N-1)
	final=without*each-each

	considered=final%(10**9+7)

	print(considered)


N=int(input())

if N<2:
	print(0)

else:
	without=10*(N-2)
	considered=(without+2)*(without+1)
	consider%=10**9+7

N=int(input())

if N<2:
	print(0)

else:
	without=10**(N-2)
	considered=(without+2)*(without+1)
	considered=considered%(1000000007)
	print(considered)

N=input()

if N<2:
	print(0)

else:
	without=10*(N-2)
	considered=(without+2)*(without+1)
	print(considered)


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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

x = n*(n-1)*2*(10**(n-2))

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


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

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

n = int(input())

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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))

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
print(10**n-2*(9**n)-8**n)

n = int(input())
s = (10**n-2*(9**n)-8**n)//1000000007
print(10**n-2*(9**n)-8**n)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):


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



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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

n_zero = 10**n - 9**n #19
n_nine = 10**n - 9**n #19
n_non_zn = 8**n #64

a = (10**n - n_zero - n_nine - n_zn)

if a < 0:
  a = -a

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


n = int(input())

ten = 10**n
nine = 9**n
eight = 8**n

n_zero = ten - nine #19
n_zn = eight #64

a = (ten - n_zero * 2 - n_zn)

if a < 0:
  a = -a

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())

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

n=int(input())

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a, b, c, d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d))


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

print((A-B*2+C) % mod)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    N = int(input())
        
    A = 1
    countA = 0
    for i in range(N):
        if A*10 >= 10**9 + 7:
            countA += 1
        A = (A*10)%(10**9 + 7)
        
    B = 1
    countB = 0
    for i in range(N):
        if B*9 >= 10**9 + 7:
            countB += 1
        B = (B*9)%(10**9 + 7)
        
    C = 1
    countC = 0
    for i in range(N):
        if C*8 >= 10**9 + 7:
            countC += 1
        C = (C*8)%(10**9 + 7)
        
    Z = B*(countB-countC)*(10**9 + 7) - C
        
    ans = (A*(countA-countC)*(10**9 + 7) - 2*Z - C) % (10**9 + 7)
        
    print(ans)
    
if __name__ == '__main__':
    main()

def main():
    N = int(input())
        
    A = 1
    countA = 0
    for i in range(N):
        if A*10 >= 10**9 + 7:
            countA += 1
        A = (A*10)%(10**9 + 7)
        
    B = 1
    countB = 0
    for i in range(N):
        if B*9 >= 10**9 + 7:
            countB += 1
        B = (B*9)%(10**9 + 7)
        
    C = 1
    countC = 0
    for i in range(N):
        if C*8 >= 10**9 + 7:
            countC += 1
        C = (C*8)%(10**9 + 7)
        
    Z = B*countB*(10**9 + 7) - C*countC*(10**9 + 7)
        
    ans = (A*(countA-countC)*(10**9 + 7) - 2*Z - C*countC*(10**9 + 7)) % (10**9 + 7)
        
    print(ans)
    
if __name__ == '__main__':
    main()

def main():
    N = int(input())
        
    A = 1
    countA = 0
    for i in range(N):
        A = (A*10)%(10**9 + 7)
        
    B = 1
    countB = 0
    for i in range(N):
        B = (B*9)%(10**9 + 7)
        
    C = 1
    countC = 0
    for i in range(N):
        C = (C*8)%(10**9 + 7)
        
    ans = (A - 2*B + C)%(10**9 + 7)
        
    print(ans)
    
if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

if N == 1:
    print(0)
elif N == 2:
    print(1)
else:
    a = 10 ** 2
    b = 2 * 9 ** 2
    c = 8 ** 2
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(N-2):
        a = a * 10 % mod
        b = b * 9 % mod
        c = c * 8 % mod
        ans = a - b + c
        ans %= mod
    print(ans)


N = int(input())

if N == 1:
    print(0)
elif N == 2:
    print(2)
else:
    a = 10 ** 2
    b = 2 * 9 ** 2
    c = 8 ** 2
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(N-2):
        a = a * 10 % mod
        b = b * 9 % mod
        c = c * 8 % mod
        ans = a - b + c
        ans %= mod
    print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
mod = 10**9+7

def pow(n, num):
  s = num
  for i in range(1,num):
    s = s*num%mod
  return s
print((pow(n,10) - 2*pow(n,9) + pow(n,8))%mod)


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

def pow(n, num):
  s = num
  for i in range(1,num):
    s = s*n%mod
  return s
print((pow(n,10) - 2*pow(n,9) + pow(n,8))%mod)


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

def pow(n, num):
  s = num
  for i in range(1,num):
    s += s*num%mod
  return s
print((pow(n,10) - 2*pow(n,9) + pow(n,8))%mod)


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

def pow(n, num):
  s = num
  for i in range(1,n):
    s = s*num%mod
  return s
print((pow(n,10) - 2*pow(n,9) + pow(n,8))%mod)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = input()
mod = 10**9 + 7
ans = (pow(10, n, mod) - ((2 * pow(9, n, mod)) % mod - pow(8, n, mod) + mod) % mod + mod) % mod
print(ans)

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a = 1000000007

n = input()

not0 = 1
not0and9 = 1
all = 1
for i in range(n):
  not0and9 = (not0and9 * 8) % a
  not0 = (not0 * 9) % a
  all = (all * 10) % a;
  
print((all + not0and9 - 2 * not9) % a) 

a = 1000000007
 
n = int(input())
 
not0 = 1
not0and9 = 1
all = 1
for i in range(n):
  not0and9 = (not0and9 * 8) % a
  not0 = (not0 * 9) % a
  all = (all * 10) % a;
  
print((all + not0and9 - 2 * not0) % a) 

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
print((10**N-2*9*N+8**N)%(10**9+7))

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

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

N = int(input())

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

N = int(input())

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



Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
MOD=10**9+7
MAX=N+1
powerls=[0 for i in range(MAX)]
powerls[0]=1
powerls[1]=base                     
def powermod(ind):
  if powerls[ind]!=0:
    return powerls[ind]
  elif ind%2==0:
    p=(powermod(base,ind//2)**2)%MOD
    powerls[ind]=p
    return p
  else:
    p=((powermod(base,ind//2)**2)*base)%MOD     
    powerls[ind]=p
    return p

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


N=int(input())
MOD=10**9+7
MAX=N+1
def powermod(base,ind):
  if ind==1:
    return base
  elif ind%2==0:
    return (powermod(base,ind//2)**2)%MOD
  else:
    return ((powermod(base,ind//2)**2)*base)%MOD

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, factorial
from copy import deepcopy
 
def main():
    n = int(input()) % (10**9+7)
    num = 0
    ans = (10**n) - 2(9**n) + (8**n) 
    print(ans%810**9+7)
    

if __name__ == "__main__":
    main()

import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, factorial
from copy import deepcopy
 
def main():
    n = int(input()) 
    ans = (10**n) - 2*(9**n) + (8**n) 
    print(ans%(10**9+7))
    

if __name__ == "__main__":
    main()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


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


x=int(input())
y=10^x- 9^x -9^x-8^x
print(y)


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

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

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

print(ans%mod)

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)


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)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

n = int(input())
n_all = 10**(n) % mod
bad_0 = 9**(n)%mod
bad_9 = 9**(n)%mod
bad_18 = 8**(n)%mod

print(n_all-bad_0-bad_9+bad_18)

n = int(input())
mod = (10**9)+7
n_all = 10**(n) % mod
bad_0 = 9**(n)%mod
bad_9 = 9**(n)%mod
bad_18 = 8**(n)%mod

print((n_all-bad_0-bad_9+bad_18)%mod)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

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

N = int(input())

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
n = int(input())
ans = math.factorial(10) / math.factorial(10 - (n-2))
print(ans % (10**9 + 7))

n = int(input())
ans = math.factorial(10) // math.factorial(10 - (n-2))
print(ans % (10**9 + 7))

import math
n = int(input())
ans = math.factorial(10) // math.factorial(10 - (n-2))
print(ans % (10**9 + 7))

n = int(869121)
ans = 10**n - 9**n - 9**n + 8**n
print(ans % (10**9 + 7))

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from functools import reduce

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


def powmod(val, n, mod):
    vals = [val]*n
    ret = reduce(lambda x, y : x * y % mod, vals)

    return ret

    
    

    return ret


all = powmod(10, N, mod)
b = powmod(9, N, mod)
c = powmod(8, N, mod)

from functools import reduce

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


def powmod(val, n, mod):
    
    

    # return ret

    for i in range(n):
        ret = ret * val % mod

    return ret


all = powmod(10, N, mod)
b = powmod(9, N, mod)
c = powmod(8, N, mod)

ans = (all - (2*b - c))%mod

print(ans)

from functools import reduce

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


def powmod(val, n, mod):
    
    

    # return ret

    ret = 1
    for i in range(n):
        ret = ret * val % mod

    return ret


all = powmod(10, N, mod)
b = powmod(9, N, mod)
c = powmod(8, N, mod)

ans = (all - (2*b - c))%mod

print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
b,c,a=1,M=1e9+7;main(s){for(scanf("%d",&s);s-->2;c=(a+b)%M)a=b,b=c;print("%d",c);}

b,c,a=1,M=1e9+7;main(s){for(scanf("%d",&s);s-->2;c=(a+b)%M)a=b,b=c;printf("%d",c);}

a = 1; b = c = 0
for _ in range(int(input()) - 2):
  a, b, c = b, c, (a + c) % (10**9 + 7)
print(c)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
s=int(input())
dp=[0 for i in range(s+10)]
dp[3]=1
mod=10**9+7
for i in range(3,s+3):
    dp[i]=1
    for j in range(i-2): dp[i]=(dp[i]+dp[j])%mod
print(dp)

s=int(input())
dp=[0 for i in range(s+10)]
dp[3]=1
mod=10**9+7
for i in range(3,s+3):
    dp[i]=1
    for j in range(i-2): dp[i]=(dp[i]+dp[j])%mod
print(dp[s])

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
N = int(input())
table = [0,0,1]
if N >= 4:
  for i in range(3, N):
    table.append((table[i-1] + table[i-3]) % mod)
  print(table[-1] % mod)
elif N == 3:
  print(1)
else:
  print(0)

import math
mod = 10 ** 9 + 7
def combinations_count(n, r): 
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())

if N < 3:
  print(0)
elif N == 3:
  print(1)
else:
  ans = 0
  num_digit = N // 3 
  for i in range(num_digit): 
    combi = combinations_count((N - (3 * (i+1)) + i), i) 
    ans += combi
  if ans >= mod:
    print(int(ans % mod))
  else:
    print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
S = int(input())
if S < 3: return 0
MODULO = int(1e9+7)
dp = [0,0,0,1]
for i in range(4,S+1):
  x = dp[i-3] + dp[i-1]
  x %= MODULO
  dp.append(x)
print(dp[-1])

S = int(input())
if S < 3: return 0
MODULO = int(1e9+7)
dp = [0,0,0,1]
for i in range(4,S+1):
  x = dp[i-3] + dp[i-1]
  x %= MODULO
  dp.append(x)
print(dp[-1]

S = int(input())
if S < 3:
    print(0)
else:
    MODULO = int(1e9+7)
    dp = [0,0,0,1]
    for i in range(4,S+1):
        x = dp[i-3] + dp[i-1]
        x %= MODULO
        dp.append(x)
    print(dp[-1])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
s = int(input())
p = [1]*(s+1)
mod = 10**9 + 7

p[1] = 0
p[2] = 0
if s >= 3
	for i in range(3,s+1):
		p[i] = (sum(p[:i-2]))%mod
print(p[s])

s = int(input())
p = [0]*(s+1)
mod = 10**9 + 7
p[0] = 1

if s >= 3:
	for i in range(3,s+1):
		p[i] = (sum(p[:i-2]))%mod
print(p[s])

Verdicts: Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
s = int(input())
maxcount = int(s / 3)
amari = s % 3
count = 0
if amari == 0 and maxcount > 0:
    count = 1

for i in range(maxcount):
    amari = s - (i + 1) * 3
    count += comb(amari + i, i, exact=True)
    count %= 1000000007
print(count)

from scipy.special import comb

s = int(input())
maxcount = int(s / 3)
amari = s % 3
count = 0
if amari == 0 and maxcount > 0:
    count = 1

for i in range(maxcount):
    amari = s - (i + 1) * 3
    if amari != 0:
        count += comb(amari + i, i, exact=True)
    count %= 1000000007
print(count)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
n=int(input())
if n<6:print(int(n>2));quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=0
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M,dp+=1
  s=(s+n*d)%M
print(s)

n=int(input())
if n<6:print(int(n>2));quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=0
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M;dp+=1
  s=(s+n*d)%M
print(s)

n=int(input())
if n<7:print(n//3);quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=n-4
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M;dp+=1
  s=(s+n*d)%M
print(s)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
S=int(input())
MOD=10**9+7
dp=[0]*(S+1)
dp[0]=1
for i in range(1,S+1):
    for j in range(0,S-2):
        dp[i]+=dp[j]
        dp[i]%=MOD
print(dp[S])

S=int(input())
MOD=10**9+7
dp=[0]*(S+1)
dp[0]=1
for i in range(1,S+1):
    for j in range(0,S-2):
        dp[i]+=dp[j]
        dp[i]%=MOD
print(dp)

S=int(input())
MOD=10**9+7
dp=[0]*(S+1)
dp[0]=1
for i in range(1,S+1):
    for j in range(0,i-2):
        dp[i]+=dp[j]
        dp[i]%=MOD
print(dp[S])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
S=int(input())
ans=int(0)
iqs=[1]
for i in range(1,S):
  iqs.append(i*iqs[-1])

for i in range(1,S//3+1):
        raw=S-i*3
    
        ans+=iqs[raw+i-1]//iqs[i-1]//iqs[raw]
        ans=ans%(10**9+7)
        print(ans)
print(ans)

S=int(input())
ans=int(0)
iqs=[1]
for i in range(1,S):
  iqs.append(i*iqs[-1])

for i in range(1,S//3+1):
        raw=S-i*3
    
        ans+=iqs[raw+i-1]//iqs[i-1]//iqs[raw]
        ans=ans%(10**9+7)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
    from math import log10

    class Mod:
        fac = []
        inv = []
        finv = []
        mod = 0
        def __init__(self,maxi:int ,mod:int):
            self.mod = mod
            self.fac = [1]*maxi
            self.inv = [1]*maxi
            self.finv = [1]*maxi
            for i in range(2,maxi):
                self.fac[i] = self.fac[i - 1]*i%mod
                self.inv[i] = mod - self.inv[mod%i]*(mod//i)%mod
                self.finv[i] = self.finv[i-1]*self.inv[i]%mod


        def com(self,n:int, k:int)->int:
            #return nCk
            if n < k:
                return 0
            if n < 0 or k < 0:
                return 0
            return self.fac[n]*(self.finv[k]*self.finv[n-k]%self.mod)%self.mod


    def main():
        s = int(input())
        m =  Mod(s,10**9 + 7)
        ans = 0
        for n in range(1,s // 3 + 1):
            if 3*n == s:
                ans = (ans+1)%(10**9 + 7)
                break
            ans = (ans + m.com(-2*n + s - 1,s - 3*n))%(10**9 + 7)
        print(ans)
        return

    if __name__ == "__main__":
        main()

from math import log10

class Mod:
    fac = []
    inv = []
    finv = []
    mod = 0
    def __init__(self,maxi:int ,mod:int):
        self.mod = mod
        self.fac = [1]*maxi
        self.inv = [1]*maxi
        self.finv = [1]*maxi
        for i in range(2,maxi):
            self.fac[i] = self.fac[i - 1]*i%mod
            self.inv[i] = mod - self.inv[mod%i]*(mod//i)%mod
            self.finv[i] = self.finv[i-1]*self.inv[i]%mod


    def com(self,n:int, k:int)->int:
        #return nCk
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n]*(self.finv[k]*self.finv[n-k]%self.mod)%self.mod


def main():
    s = int(input())
    m =  Mod(s,10**9 + 7)
    ans = 0
    for n in range(1,s // 3 + 1):
        if 3*n == s:
            ans = (ans+1)%(10**9 + 7)
            break
        ans = (ans + m.com(-2*n + s - 1,s - 3*n))%(10**9 + 7)
    print(ans)
    return

if __name__ == "__main__":
    main()

Verdicts: Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
from scipy.special import comb

S = int(input())

n = S//3
k = S%3
Q = 10**9+7
ans = 0
for i in range(n):
    
    m = n-i 
    ans += comb(n-1,i,exact=true)*comb(m,k,exact=True)
    if k==2:
        ans += k
    ans %=Q
print(ans)

S = int(input())
A = [0]*(S+1)
A[0] = 1
MOD = 10**9+7

if S<=2:
    print(A[S])
    exit()

for i in range(3,S+1):
    for j in range(i-2):
        A[i] += A[j]
    A[i]%=MOD
print(A[S])

Verdicts: Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
s = int(input())

table = [1, 1, 1]
for i in range(s):
  table.append(table[i]+table[i+2])
print(table[s])

s = int(input())
mod = 10**9+7
table = [1, 0, 0]
for i in range(s):
  table.append((table[i]+table[i+2])%mod)
print(table[s])

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
N = int(input())
INF = 10 ** 9 + 7
print((pow(10, N, INF) - 2 * pow(9, N, INF) + pow(8, N, INF)) % INF)

S = int(input())
INF = 10 ** 9 + 7
dp = [0] * (S + 1)
dp[0] = 1

for i in range(1, S + 1):
    for j in range(i - 2):
        dp[i] += dp[j]
        dp[i] %= INF

print(dp[S])

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
mod = 10 ** 9 + 7

class Solution:
    def FactorialMod(self, n):
        if n <= 1:
            return 1
        else:
            return n * self.FactorialMod(n - 1) % mod
    def ModInv(self, p):
        if p <= 1:
            return 1
        return (-self.ModInv(mod % p) * (mod // p)) % mod
    def FactorialModInv(self, p):
        if p <= 1:
            return 1
        return modinv_table[p] * self.FactorialModInv(p - 1)
    def Solve(self, n):
        ans = 0
        #Fill in the modinv_table
        for p in range(2, n + 1):
            modinv_table[p] = (-modinv_table[mod % p] * (mod // p)) % mod
        # print(modinv_table)
        for item in range(1, max_items + 1):
            print("----------------------------------")
            print("item", item)
            max_value = S - 3 * item
            print("max_value", max_value)
            add = self.CalculateAddition(max_value, item)
            print("add", add)
            ans += add
            ans %= mod
        return ans
    def CalculateAddition(self, max_value, item):
        if max_value == 0:
            return 1
        add = 1
        add = add * self.FactorialMod(max_value + item - 1) % mod
        add = add * self.FactorialModInv(max_value) % mod
        add = add * self.FactorialModInv(item - 1) % mod
        return add

S = int(input())
if S <= 2:
    print(0)
    exit()

max_items = S // 3
# print("max_items", max_items)
modinv_table = [-1] * (S + 1)
modinv_table[1] = 1

sol = Solution()
print(sol.Solve(S))


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

if S <= 2:
    print(0)
    exit()

ans = 0
max_items = S // 3

# print("max_items", max_items)

for item in range(1, max_items + 1):
    # print("---------------------------")
    # print("item", item)
    n = S - 3 * item
    # print("n", n)
    if n == 0:
        ans += 1
        break

    modinv_table = [-1] * (n + 1)
    modinv_table[1] = 1
    for i in range(2, n + 1):
        modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod

    add = 1
    for p in range(n):
        add *= (n + item - 1) - p
        add *= modinv_table[p + 1]
        add %= mod


    # print("add", add)


    ans += add
    ans %= mod



print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
import math
N = input()
N = int(N)
x = N / 3
p = 10 **9 + 7
if x == 0:
  print(0)
sum = 0
else:
  for k in range(x):
  y = N - 3 * k
  l = k - 1
  M = y + l
  a = math.factorial(l)
  b = math.factorial(M) 
  c = math.factorial(y)
  z = b / a / c
  z = z % p
  sum += z

print(z)

  

  

import math
N = input()
N = int(N)
x = N // 3
x = int(x)
p = 10 ** 9 + 7
sum = 0
if x == 0:
  print(0)
else:
  for k in range(x):
    y =  N - 3*k - 3
    l = k 
    M = y + l
    a = math.factorial(l)
    b = math.factorial(M) 
    c = math.factorial(y)
    d = a * c
    z = b // d
    z = z % p
    sum += z
    sum = sum %p

  sum = int(sum)
  print(sum)

  

  

Verdicts: Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):

"""a = int(input())

import itertools
a_list = [i for i in range(3,a+1)]
#print(a_list)

for i in itertools.combinations_with_replacement(a_list,len(a_list)):
    if(sum(i) == a):
        print(sum(i))
        """

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

dp = [1] * 2001
dp[0] = dp[1] = dp[2] = 0
"""
for i in range(S+1):
    for j in range(3, i):
        dp[i] += dp[i-j]
    print(i,dp[0:S+1])

"""

for i in range(3,S+1):
    for l in range(i+1-3):
        dp[i] += dp[l]

    print(i,dp[0:i+1])

      

print(dp[S] % MOD)




"""a = int(input())

import itertools
a_list = [i for i in range(3,a+1)]
#print(a_list)

for i in itertools.combinations_with_replacement(a_list,len(a_list)):
    if(sum(i) == a):
        print(sum(i))
        """

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

dp = [1] * 2001
dp[0] = dp[1] = dp[2] = 0
"""
for i in range(S+1):
    for j in range(3, i):
        dp[i] += dp[i-j]
    print(i,dp[0:S+1])

"""

for i in range(3,S+1):
    for l in range(i+1-3):
        dp[i] += dp[l]

    #print(i,dp[0:i+1])

      

print(dp[S] % MOD)



Verdicts: Runtime Error

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
n = int(input())
mod = 10**9 + 7

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

inv = [1] * (n+1)
inv[-1] = pow(per[-1], mod-2, mod)
for j in range(2, n+1):
  inv[-j] = inv[-j+1] * (n-j+1)
  inv[-j] %= mod

def C(n, k):
  cmb = per[n] * inv[k] * inv[n-k]
  cmb %= mod
  return cmb

total = 0
for k in range(1, n+1):
  if n < 3*k:
    break
  total += C(n-2*k-1, k-1)
  total %= mod

print(total)

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

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

inv = [1] * (n+1)
inv[-1] = pow(per[-1], mod-2, mod)
for j in range(2, n+2):
  inv[-j] = inv[-j+1] * (n-j+2)
  inv[-j] %= mod

def C(n, k):
  cmb = per[n] * inv[k] * inv[n-k]
  cmb %= mod
  return cmb

total = 0
for k in range(1, n+1):
  if n < 3*k:
    break
  total += C(n-2*k-1, k-1)
  total %= mod

print(total)


Verdicts: Wrong Answer

Accepted
Problem: Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.

Submission attempts (in order):
s=int(input())
a=[0]*2001
x=(10**9)+7
if s<3:
  print(0)
  exit()
  
elif 3<=x<6:
  for i in range(3,6):
    a[i]=1
    
else:
  for i in range(6,2001):
    a[i]=(sum(a[2:i-2])+1)%(x)

print(a[s])
  

n=int(input)

a=list()
for i in range(n):

    a.append(list(map(int,input().strip().split())))
a=list(set(a))
ans=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        ans=max(ans,abs(a[i][0]-a[j][0])+abs(a[j][1],a[i][1]))

print(ans)

s=int(input())
a=[0]*2001
x=(10**9)+7
if s<3:
  print(0)
  exit()
  
elif 3<=x<6:
  for i in range(3,6):
    a[i]=1
    
else:
  for i in range(6,2001):
    a[i]=(sum(a[3:i-2])+1)%(x)

print(a[s])
  

s=int(input())
a=[0]*2001
x=(10**9)+7
if s<3:
    print(0)
    exit()

    
else:

    for i in range(3,6):
        a[i]=1

    for i in range(6,2001):
        a[i]=(sum(a[3:i-2])+1)%(x)

print(a[s])
  





Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted