Problem:


Score : 600 points

Problem Statement

You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.
It is known that each of the n integers 1,...,n appears at least once in this sequence.

For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.

Notes

If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.

A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.

Constraints

1 \leq n \leq 10^5

1 \leq a_i \leq n

Each of the integers 1,...,n appears in the sequence.

n and a_i are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_{n+1}

Output

Print n+1 lines.
The k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.

Sample Input 1

3
1 2 1 3

Sample Output 1

3
5
4
1

There are three subsequences with length 1: 1 and 2 and 3.

There are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.

There are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.

There is one subsequence with length 4: 1,2,1,3.

Sample Input 2

1
1 1

Sample Output 2

1
1

There is one subsequence with length 1: 1.

There is one subsequence with length 2: 1,1.

Sample Input 3

32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9

Sample Output 3

32
525
5453
40919
237336
1107568
4272048
13884156
38567100
92561040
193536720
354817320
573166440
818809200
37158313
166803103
166803103
37158313
818809200
573166440
354817320
193536720
92561040
38567100
13884156
4272048
1107568
237336
40920
5456
528
33
1

Be sure to print the numbers modulo 10^9+7.



Sample input:
3
1 2 1 3


Sample output:
3
5
4
1

Submission status: Wrong Answer

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

from collections import Counter
import re

def pow(a, x):
        y = 1
        p = a % mask
        n = x 
        while (n > 0):
                if ((n % 2) == 0):
                        p = (p * p) % mask
                        n /= 2
                else:   
                        y = (y * p) % mask
                        n -= 1
        return y

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0

mask = 10**9 + 7
invm = 10**9 + 5

com = [1]*(n+2)
inv = [1]*(n+2)

tmp = 1
for i in range(1, n+2):
        tmp = (tmp * i) % mask
        com[i] = tmp
        inv[i] = pow(tmp, invm) % mask

counter = Counter(a)
dup = counter.most_common(1)[0][0]
left = a.index(dup)
right = a[left+1:].index(dup) + left + 1

for i in range(1, n + 2):
        ans = (com[n + 1] * (inv[i] * inv[n + 1 - i])) % mask

        if ((left + n - right - i + 1) >= 0):
                ans -= (com[left + n - right] * inv[i - 1] * inv[left + n - right - i + 1]) % mask
        print ans

Submission status: Wrong Answer

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

from collections import Counter
import re

def pow(a, x):
        y = 1
        p = a
        n = x % mask
        while (n > 0):
                if ((n % 2) == 0):
                        p = (p * p) % mask
                        n /= 2
                else:
                        y = (y * p) % mask
                        n -= 1
        return y

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0

mask = 10**9 + 7
invm = 10**9 + 5

com = [1]*(n+2)
inv = [1]*(n+2)
tmp = 1
for i in range(1, n+2):
        tmp = (tmp * i) % mask
        com[i] = tmp
        inv[i] = pow(tmp, invm) % mask

counter = Counter(a)
dup = counter.most_common(1)[0][0]
left = a.index(dup)
right = a[left+1:].index(dup) + left + 1

for i in range(1, n + 2):
        ans = (com[n + 1] * (inv[i] * inv[n + 1 - i])) % mask

        if ((left + n - right - i + 1) >= 0):
                ans -= (com[left + n - right] * inv[i - 1] * inv[left + n - right - i + 1]) % mask
        print ans

Submission status: Wrong Answer

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

import re

def pow(a, x):
        y = 1
        p = a
        n = x % mask
        while (n > 0):
                if ((n % 2) == 0):
                        p = (p * p) % mask
                        n /= 2
                else:   
                        y = (y * p) % mask
                        n -= 1
        return y

n = int(raw_input())
a = map(int, re.split("\s", raw_input()))
left = 0
right = 0

mask = 10**9 + 7
invm = 10**9 + 5

com = [1]*(n+2)
inv = [1]*(n+2)

tmp = 1
for i in range(1, n+2):
        tmp = (tmp * i) % mask
        com[i] = tmp
        inv[i] = pow(tmp, invm) % mask

for i in range(0, n + 1):
        x = a.index(a[i])
        if a[i] in a[x+1:]:
                left = i
                right = a[x+1:].index(a[i]) + x + 1
                break

for i in range(1, n + 2):
        ans = (com[n + 1] * (inv[i] * inv[n + 1 - i])) % mask

        if ((left + n - right - i + 1) >= 0):
                ans -= (com[left + n - right] * inv[i - 1] * inv[left + n - right - i + 1]) % mask
        print (ans - x)

Submission status: Wrong Answer

Solution code:
def power(x, n):
    y = 1
    while n > 0:
        if n % 2 == 0:
            x = (x * x) % (10 ** 9 + 7)
            n = n // 2
        else:
            y = (y * x) % (10 ** 9 + 7)
            n = n - 1
    return y


MOD = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))

fact = [1] * (n + 2)
inv = [1] * (n + 3)

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


def nCm(n, m):
    global fact
    global inv
    return fact[n] * inv[m] % MOD * inv[n - m] % MOD


saw = [-1] * n
left = 0
right = 0
for i in range(n):
    if saw[a[i] - 1] == -1:
        saw[a[i] - 1] = i
    else:
        left, right = saw[a[i] - 1], n - i
        break

for i in range(1, n + 2):
    if i == 1:
        print(n)
    elif left + right >= i - 1:
        print((nCm(n + 1, i) - nCm(left + right, i - 1) % MOD))
    else:
        print(nCm(n + 1, i))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

fact = [1] * (n + 2)

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

def nCm(n, m):
    global fact
    return fact[n] // (fact[m] * (fact[n - m]))

saw = [-1] * n
left = 0
right = 0
for i in range(n):
    if saw[a[i] - 1] == -1:
        saw[a[i] - 1] = i
    else:
        left, right = saw[a[i] - 1], n - i
        break

for i in range(1, n + 2):
    if i == 1:
        print(n)
    elif left + right >= i - 1:
        print((nCm(n + 1, i) - nCm(left + right, i - 1) % 1000000007))
    else:
        print(nCm(n + 1, i))

Submission status: Wrong Answer

Solution code:
import math

def nCm(n, m):
    return math.factorial(n) // (math.factorial(m) * (math.factorial(n - m)))

n = int(input())
l = list(map(int, input().split()))

tmp = [-1]*n

for i in range(n+1):
    if(tmp[l[i]-1] == -1):
        tmp[l[i]-1] = i
    else:
        j = tmp[l[i]-1]
        k = i
        break

print(j, k)

for i in range(1, n+2):
    if(j+n-k < i-1):
        print((nCm(n+1, i)) % 1000000007)
    else:
        print((nCm(n+1, i) - nCm(j+n-k, i-1)) % 1000000007)

Submission status: Wrong Answer

Solution code:
import math

def nCm(n, m):
    return math.factorial(n) // (math.factorial(m) * (math.factorial(n - m)))


n = int(input())
a = list(map(int, input().split()))

saw = [-1] * n
left = 0
right = 0
for i in range(n):
    if saw[a[i] - 1] == -1:
        saw[a[i] - 1] = i
    else:
        left, right = saw[a[i] -1], n - i
        break

for i in range(1, n+2):
    if i == 1:
        print(n)
    elif left + right >= i - 1:
        print((nCm(n+1, i) - nCm(left+right, i - 1) % 1000000007))
    else:
        print(nCm(n+1, i))

Submission status: Wrong Answer

Solution code:
import math


def nCm(n, m):
    return math.factorial(n) // (math.factorial(m) * (math.factorial(n - m)))


n = int(input())
a = list(map(int, input().split()))

saw = [-1] * n
left = 0
right = 0
for i in range(n):
    if saw[a[i] - 1] == -1:
        saw[a[i] - 1] = i
    else:
        left, right = saw[a[i] -1 ], n - i
        break
print(left, right)

for i in range(1, n+2):
    if i == 1:
        print(n)
    else:
        print((nCm(n+1, i) - max(0, (left + right - (i - 2)))) % 1000000007)

Submission status: Wrong Answer

Solution code:
l=int(input())+1
if l==2:
    print(1)
    print(1)
    exit()
mod = 10**9+7
N = 10**5+2
g1 = [1, 1]  #0! と1!
g2 = [1, 1]  #(0!)^-1 と(1!)^-1
inverse = [0, 1]
data=list(map(int,input().split()))
for i in data:
    if data.count(i)==2:
        x=i
        break
for i in range( 2, N + 1 ):
    #元テーブルは，最後尾の要素にiを乗算したのを加える
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    #逆元テーブルは，最後尾の要素にinverseの最後尾を乗算したのを加える
    g2.append( (g2[-1] * inverse[-1]) % mod )

def combination(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

c1=[1]
l-=1
for i in range(1,l+2):
    c1.append(combination(l+1,i,mod))
t1=data.index(x,2)
t2=data.index(x)
for i in range(1,l+2):
    print(c1[i]-combination(l-t1,i-1,mod)-(1 if i<=t2 else 0))

Submission status: Wrong Answer

Solution code:
l=int(input())+1
if l==2:
    print(1)
    print(1)
    exit()
mod = 10**9+7
N = 10**5+2
g1 = [1, 1]  #0! と1!
g2 = [1, 1]  #(0!)^-1 と(1!)^-1
inverse = [0, 1]
data=list(map(int,input().split()))
for i in data:
    if data.count(i)==2:
        x=i
        break
for i in range( 2, N + 1 ):
    #元テーブルは，最後尾の要素にiを乗算したのを加える
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    #逆元テーブルは，最後尾の要素にinverseの最後尾を乗算したのを加える
    g2.append( (g2[-1] * inverse[-1]) % mod )

def combination(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

c1=[1]
l-=1
for i in range(1,l+2):
    c1.append(combination(l+1,i,mod))
t1=data.index(x,2)
t2=data.index(x)
for i in range(1,l+2):
    print(c1[i]-combination(l-t1+1,i-1,mod)-(1 if i<t2 else 0))

Submission status: Wrong Answer

Solution code:
l=int(input())+1
if l==2:
    print(1)
    print(1)
    exit()
mod = 10**9+7
N = 10**5+2
g1 = [1, 1]  #0! と1!
g2 = [1, 1]  #(0!)^-1 と(1!)^-1
inverse = [0, 1]
data=list(map(int,input().split()))
for i in data:
    if data.count(i)==2:
        x=i
        break
for i in range( 2, N + 1 ):
    #元テーブルは，最後尾の要素にiを乗算したのを加える
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    #逆元テーブルは，最後尾の要素にinverseの最後尾を乗算したのを加える
    g2.append( (g2[-1] * inverse[-1]) % mod )

def combination(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

c1=[1]
l-=1
for i in range(1,l+2):
    c1.append(combination(l+1,i,mod))
for i in range(1,l+2):
    print(c1[i]-combination(l-data.index(x,2)+1,i-1,mod)-(1 if i<data.index(x) else 0))

Submission status: Wrong Answer

Solution code:
# ------ combination -------
N, MOD = 10**5 + 1, 10**9 + 7
fc, ifc, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)

def combination_init():
    fc[0] = ifc[0] = inv[1] = 1
    for i in range(1, N):
        fc[i] = fc[i-1] * i % MOD
    for i in range(2, N):
        inv[i] = (MOD - MOD//i) * inv[MOD%i] % MOD
    for i in range(1, N):
        ifc[i] = inv[i] * ifc[i-1] % MOD

def Comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    return (fc[n] * ifc[n-r] % MOD) * ifc[r] % MOD

# --------------------------

n = int(input())
a = list(map(int, input().split()))

num = [-1] * (n+1)
l = r = -1
for i in range(len(a)):
    if num[a[i]] != -1:
        l, r = num[a[i]], i
        break
    num[a[i]] = i

combination_init()
for k in range(1, len(a)+1):
    ans = Comb(len(a), k) - Comb(l+len(a)-r-1, k-1)
    while ans < 0:
        ans += MOD
    print(ans)

Submission status: Wrong Answer

Solution code:
# ------ combination -------
N, MOD = 10**5 + 1, 10**9 + 7
fc, ifc, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)

def combination_init():
    fc[0] = ifc[0] = inv[1] = 1
    for i in range(1, N):
        fc[i] = fc[i-1] * i % MOD
    for i in range(2, N):
        inv[i] = (MOD - MOD//i) * inv[MOD%i] % MOD
    for i in range(1, N):
        ifc[i] = inv[i] * ifc[i-1] % MOD

def Comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    return (fc[n] * ifc[n-r] % MOD) * ifc[r] % MOD

# --------------------------

n = int(input())
a = list(map(int, input().split()))

num = [-1] * (n+1)
l = r = -1
for i in range(len(a)):
    if num[a[i]] != -1:
        l, r = num[a[i]], i
        break
    num[a[i]] = i

combination_init()
for k in range(1, len(a)+1):
    ans = Comb(len(a), k) - Comb(l+len(a)-r-1, k-1)
    while ans < 0:
        ans += MOD
    print(Comb(len(a), k) - Comb(l+len(a)-r-1, k-1))

Submission status: Wrong Answer

Solution code:
# ------ combination -------
N, MOD = 10**5 + 1, 10**9 + 7
fc, ifc, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)

def combination_init():
    fc[0] = ifc[0] = inv[1] = 1
    for i in range(1, N):
        fc[i] = fc[i-1] * i % MOD
    for i in range(2, N):
        inv[i] = (MOD - MOD//i) * inv[MOD%i] % MOD
    for i in range(1, N):
        ifc[i] = inv[i] * ifc[i-1] % MOD

def Comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    return (fc[n] * ifc[n-r] % MOD) * ifc[r] % MOD

# --------------------------

n = int(input())
a = list(map(int, input().split()))

num = [-1] * (n+1)
l = r = -1
for i in range(len(a)):
    if num[a[i]] != -1:
        l, r = num[a[i]], i
        break
    num[a[i]] = i

combination_init()
for k in range(1, len(a)+1):
   print(Comb(len(a), k) - Comb(l+len(a)-r-1, k-1))

Submission status: Wrong Answer

Solution code:
# ------ combination -------
N, MOD = 10**5 + 1, 10**9 + 7
fc, ifc = [0] * (N+1), [0] * (N+1)

def power(n, a):
    res, exp = 1, n
    while(a):
        if a & 1:
            res = res * exp % MOD
        exp = exp * exp % MOD
        a = a // 2
    return res

fc[0] = 1
for i in range(1, N+1):
    fc[i] = fc[i-1] * i % MOD
ifc[N] = power(fc[N], MOD-2)
for i in range(N-1, -1, -1):
    ifc[i] = ifc[i+1] * (i+1) % MOD

def comb(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    return fc[n] * ifc[r] % MOD * ifc[n-r] % MOD

# --------------------------

n = int(input())
a = list(map(int, input().split()))

num = [-1] * (n+1)
l = r = -1
for i in range(len(a)):
    if num[a[i]] != -1:
        l, r = num[a[i]], i
        break
    num[a[i]] = i

for k in range(1, len(a)+1):
   print(comb(len(a), k) - comb(l+len(a)-r-1, k-1))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split(" ")))

MOD = 1000000007

def mul(a,b):
    return (a*b) % MOD
 
def pow(a,n):
    ans = 1
    mag = a
    for b in reversed(str(bin(n))):
        if b == 'b': break
        if b == '1':
            ans = mul(ans, mag)
        mag = mul(mag, mag)
    return ans
 
def inv(a):
    return pow(a, MOD-2)
 
fac = [1]
fac_inv = [1]
for n in range (1,N+2):
    f = mul(fac[n-1], n)
    fac.append(f)
    fac_inv.append(inv(f))

def ncr(n,r):
    return mul(mul(fac[n], fac_inv[n-r]), fac_inv[r])


dejavu = []
for i, a_i in enumerate(a):
    if a_i in dejavu:
        l = dejavu.index(a_i) + 1
        r = i+1
    else:
        dejavu.append(a_i)

for i in range(1, N+1):
    if N+l-r >= i-1:
        print("%d"%((ncr(N+1, i) - ncr(l+N-r, i-1))%MOD))
    else:
        print("%d"%((ncr(N+1, i))%MOD))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split(" ")))

MOD = 1000000007
import math
def comb(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)


dejavu = []
for i, a_i in enumerate(a):
    if a_i in dejavu:
        l = dejavu.index(a_i) + 1
        r = i+1
    else:
        dejavu.append(a_i)

for i in range(1, n+1):
    if n+l-r >= i-1:
        print("%d"%((comb(n+1, i) - comb(l+n-r, i-1))%MOD))
    else:
        print("%d"%((comb(n+1, i))%MOD))

Submission status: Wrong Answer

Solution code:
#11
n = int(input())
a = list(map(int, input().split()))

f = [-1]*(n+1)
p = 0
for i in range(n+1):
    t = a[i]
    if ( f[t] == -1 ):
        f[t] = i
    else:
        p = i - f[t] - 1
        break

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
mod = 10**9 + 7
for i in range( 2, n + 2 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

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


for i in range(n+1):
    if ( p>=i ):
        c = combination(n+1, i+1) - combination(p, i)
    else:
        c = combination(n+1, i+1)
    print( int(c) )

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7
n = int(input())
la = list(map(int,input().split()))
L = [-1]*(n+1)
l = 0

for i in range(n+1):
    a = la[i]
    if L[a] == -1:
        L[a] = i
    else:
        l = i - L[a] - 1
    break
 
MAX = n
factorial = [1, 1]
inverse = [0, 1]
inverse_factorial = [1, 1]
for i in range(2,MAX+1):
    factorial.append( (factorial[-1]*i)%MOD )
    inverse.append( (-inverse[MOD%i]*(MOD//i))%MOD )
    inverse_factorial.append( (inverse_factorial[-1]*inverse[-1])%MOD )
 
def C_MOD(n, k):
    if k < 0 or k > n:
        return 0
    k = min(k,n-k)
    return factorial[n] * inverse_factorial[k] * inverse_factorial[n-k] % MOD
 
print(n)
#print((2*C_MOD(n-1,1)-C_MOD(n-1-l,1)+C_MOD(n-1,2)+1)%MOD)
for i in range(2,n+1):
    if n > l+1:
        print((2*C_MOD(n-1,i-1)-C_MOD(n-1-l,i-1)+C_MOD(n-1,i)+C_MOD(n-1,i-2))%MOD)
    else:
        print((2*C_MOD(n-1,i-1)+C_MOD(n-1,i)+C_MOD(n-1,i-2))%MOD)
print(1)

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7
n = int(input())
la = list(map(int,input().split()))
L = [-1]*(n+1)
l = 0
 
MAX = n
factorial = [1, 1]
inverse = [0, 1]
inverse_factorial = [1, 1]
for i in range(2,MAX+1):
    factorial.append( (factorial[-1]*i)%MOD )
    inverse.append( (-inverse[MOD%i]*(MOD//i))%MOD )
    inverse_factorial.append( (inverse_factorial[-1]*inverse[-1])%MOD )
 
def C_MOD(n, k):
    if k < 0 or k > n:
        return 0
    k = min(k,n-k)
    return factorial[n] * inverse_factorial[k] * inverse_factorial[n-k] % MOD
 
print(n)
for i in range(2,n+1):
    if n > l+1:
        print((2*C_MOD(n-1,i-1)-C_MOD(n-1-l,i-1)+C_MOD(n-1,i)+C_MOD(n-1,i-2))%MOD)
    else:
        print((2*C_MOD(n-1,i-1)+C_MOD(n-1,i)+C_MOD(n-1,i-2))%MOD)
print(1)

Submission status: Wrong Answer

Solution code:
from math import factorial as f
N=int(input())
a={}
temp=[0 for i in range(N+1)]
l=list(map(int,input().split()))
for i in range(N+1):
    temp[l[i]]+=1
    if(temp[l[i]])==2:
        o=i+1
        p=a[l[i]]+1
        break
    else:
        a[l[i]]=i
print(p,o)
l=p-1
r=N+1-o
q=l+r
for i in range(1,N+2):
    if(i==N+1):
        print(1)
        continue
    if(i==1):
        print(N)
        continue
    nck=int(f(N+1)/(f(N+1-i)*f(i)))
    if(q-(i-1)>=0):
        other=int(f(q)/(f(q-(i-1))*f(i-1)))
    else:
        other=0
    print((nck-other)%(10**9+7))

Submission status: Wrong Answer

Solution code:
from math import factorial as f
N=int(input())
a=[0 for _ in range(N+1)]
temp=[0 for i in range(N+1)]
l=list(map(int,input().split()))
for i in range(N+1):
    a[i]=l[i]
    temp[l[i]]+=1
    if(temp[l[i]])==2:
        o=i+1
        index=l[i]
p=a.index(index)+1
print(p,o)
l=p-1
r=N+1-o
q=l+r
for i in range(1,N+2):
    if(i==N+1):
        print(1)
        continue
    if(i==1):
        print(N)
        continue
    nck=int(f(N+1)/(f(N+1-i)*f(i)))
    if(q-(i-1)>=0):
        other=int(f(q)/(f(q-(i-1))*f(i-1)))
    else:
        other=0
    print(nck%(10**9+7)-other%(10**9+7))

Submission status: Wrong Answer

Solution code:
import math
f = math.factorial

def comb(n, k):
    return (f(n) % mod)//((f(k) % mod) * (f(n-k) % mod))% mod

mod = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))

d = [i for i in range(len(a)) if a.count(a[i]) == 2]

na = d[0]
nb = (n+1) - (d[1] + 1)

tot = 1
for k in range(1, n+2):
    tot = (tot *  ((n+1)-(k-1)) // k) 
    minus = 0
    if (k - 1) <= (na + nb):
        if k == 1:
            minus = 1
        else:
            minus = (minus * ((na + nb) - ((k-1) - 1) // (k - 1)))
    print((tot - minus) % mod)

Submission status: Wrong Answer

Solution code:
import math
def nCi(n, i):
  return int(math.factorial(n)/math.factorial(n-i)/math.factorial(i))

n=int(input())
a=list(map(int,input().split()))
b = [ai for i,ai in enumerate(a) if i!=a.index(ai)]
c = a.index(b[0])
a.reverse()
d = a.index(b[0])
for i in range(n+1):
  if i == 0: print(int((nCi(n, i+1))%(7+1e9)))
  elif i+1 <= (c+d): print(int((nCi(n+1,i+1)-nCi(c+d,i))%(7+1e9)))
  else: print(nCi(n+1, i+1))

Submission status: Wrong Answer

Solution code:
import math
def nCi(n, i):
  return int(math.factorial(n)/math.factorial(n-i)/math.factorial(i))

n=int(input())
a=list(map(int,input().split()))
for i,ai in enumerate(a):
  if i != a.index(ai):
    b = a.index(ai)
    b += n-i
    break
for i in range(n+1):
  if i == 0: print(int((nCi(n, i+1))%(7+1e9)))
  elif i+1 <= b: print(int((nCi(n+1,i+1)-nCi(b,i))%(7+1e9)))
  else: print(nCi(n+1, i+1))

Submission status: Wrong Answer

Solution code:
import math
def nCi(n, i):
  return int(math.factorial(n)/math.factorial(n-i)/math.factorial(i))

n=int(input())
a=list(map(int,input().split()))
a2=[]
for i in a:
  if i in a2:
    a1 = a[:a.index(i)]
    a2 = a[:a.index(i)]+a[len(a2)+1:]
    break
  a2.append(i)
for i in range(n+1):
  if i == 0: print(int((nCi(n, i+1))%(7+1e9)))
  elif i+1 <= len(a2): print(int((nCi(n+1,i+1)-nCi(len(a2),i))%(7+1e9)))
  else: print(nCi(n+1, i+1))

Submission status: Wrong Answer

Solution code:
import sys
import math

N = int(input())
a_array = list(map(int, input().split()))

def combination(n,k):
	if k == 0:
		return 1
	elif k == n:
		return 1
	else:
		return math.factorial(n)/math.factorial(n-k)/math.factorial(k)

#hoge = "29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9"
#a_array = list(map(int,hoge.split(" ")))
#a_array = [2,3,1,4,5,1,6,7]
#a_array = [1,2,1,3]
#N = len(a_array)-1

#print(N)
#print(a_array)

s = set()
for x in a_array:
	if x in s:
		result=x
	s.add(x)
#print(result)

indexes = [i for i, x in enumerate(a_array) if x == result]
#print(indexes)
r = indexes[0] + N-indexes[1]
#print(r)

for i in range(1,N+2):
	if r >= i-1:
		print(int(combination(N+1,i)-combination(r,i-1)))
	else:
		print(int(combination(N+1,i)))

Submission status: Wrong Answer

Solution code:
import sys
import math

N = int(input())
a_array = list(map(int, input().split()))

def combination(n,k):
	if k == 0:
		return 1
	elif k == n:
		return 1
	else:
		return math.factorial(n)/math.factorial(n-k)/math.factorial(k)

#hoge = "29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9"
#a_array = list(map(int,hoge.split(" ")))
#a_array = [2,3,1,4,5,1,6,7]
#a_array = [1,2,1,3]
#N = len(a_array)-1

#print(N)
#print(a_array)

s = set()
for x in a_array:
	if x in s:
		result=x
	s.add(x)
print(result)

indexes = [i for i, x in enumerate(a_array) if x == result]
#print(indexes)
r = indexes[0] + N-indexes[1]
#print(r)

for i in range(1,N+2):
	if r >= i-1:
		print(int(combination(N+1,i)-combination(r,i-1)))
	else:
		print(int(combination(N+1,i)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
M = 10**9 + 7

def calc_index(a):
    t = sorted(a)
    for i, x in enumerate(t[1:]):
        if t[i] == x:
            break
    result = []
    for i, v in enumerate(a):
        if v == x:
            result.append(i)
    return result

f, e = calc_index(a)
out = n - e + f
def fact(a):
    result = 1
    for i in a:
        result *= i
        if result > M:
            result %= M
    return result

def powmod(a, b):
    if b == 0:
        return 1
    elif b & 1:
        return (powmod(a, b - 1) * a) % M
    else:
        return powmod(a, b // 2)**2 % M

def c(a, b):
    return fact(range(a, a - b, -1)) * powmod(fact(range(2, b + 1)) % M, M - 2) % M

for i in range(1, n + 1):
    c1, c2 = c(n + 1, i), c(out, i - 1)
    r = c1 - c2
    if r < 0:
        r += M
    print(r)
if n != 1: print(1)

Submission status: Wrong Answer

Solution code:
import sys
import math

#N = int(input())
#a_array = list(map(int, input().split()))

a_array = [1,1]
N = len(a_array)-1

def combination(n,k):
	if k == 0:
		return 1
	elif k == n:
		return 1
	else:
		return math.factorial(n)/math.factorial(n-k)/math.factorial(k)

indexes = [i for i, x in enumerate(a_array) if x == 1]
r = indexes[0] + N-indexes[1]

for i in range(1,N+2):
	if r >= i-1:
		print(int(combination(N+1,i)-combination(r,i-1)))
	else:
		print(int(combination(N+1,i)))

Submission status: Wrong Answer

Solution code:
import sys
import math

#N = int(input())
#a_array = list(map(int, input().split()))

a_array = [1,2,1,3]
N = len(a_array)-1

def combination(n,k):
	if k == 0:
		return 1
	elif k == n:
		return 1
	else:
		return math.factorial(n)/math.factorial(n-k)/math.factorial(k)

indexes = [i for i, x in enumerate(a_array) if x == 1]
r = indexes[0] + N-indexes[1]

for i in range(1,N+2):
	if r >= i-1:
		print(int(combination(N+1,i)-combination(r,i-1)))
	else:
		print(int(combination(N+1,i)))

Submission status: Wrong Answer

Solution code:
import sys
import math

N = int(input())
a = list(map(int, input().split()))

'''
def combination(n,k):
	if k == 0:
		return 1
	elif k == n:
		return 1
	else:
		return math.factorial(n)/math.factorial(n-k)/math.factorial(k)

#hoge = "1 2 1 3"
#a_array = list(map(int,hoge.split(" ")))
#a_array = [2,3,1,4,5,1,6,7]
#a_array = [1,2,1,3]
#N = len(a_array)-1

#print(N)
#print(a_array)

indexes = [i for i, x in enumerate(a_array) if x == 1]
#print(indexes)
r = indexes[0] + N-indexes[1]
#print(r)

for i in range(1,N+2):
	if r >= i-1:
		print(int(combination(N+1,i)-combination(r,i-1)))
	else:
		print(int(combination(N+1,i)))
'''

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math

n = int(input())
a = [int(x) for x in input().split()]

low = 0
high = 0

po = 10**9+7

def nCr(n,r):
    f = math.factorial
    fa = f(n)
    fb = f(n-r)*f(r)
    return fa//fb

for i, x in enumerate(a):
	for j in range(i+1,n+1):
		if x == a[j]:
			low = i
			high = j
			break
		else:
			pass

ll = low
hh = n-high
d = ll+hh

for k in range(1,n+2):
	c = nCr(n+1, k)
	if k > d+1:
		m = 0
	else:
		m = nCr(d, k-1)
	ans = m - c
	print(ans%po)

Submission status: Wrong Answer

Solution code:
def f(a, b):
	s = 1
	for i in range(a - b + 1, a + 1):
		s = (s * i / (i - (a - b))) % int(10e8 + 7)
	return s

a = input()
l = map(int, raw_input().split())

d = sum(l) - (1 + a) * a / 2

c = 0

for i in l:
	if i != d:
		c += 1
	else:
		break

for i in reversed(l):
	if i != d:
		c += 1
	else:
		break

s, t = a + 1, a + 1
ss, tt = 1, c
p = 1
pp = 1
print a
temp, temp1 = 0, 0


for i in range(2, a + 2):
	t -= 1
	p += 1
	s = (s + temp * int(10e8 + 7)) * t / p
	temp = s / int(10e8 + 7)
	s = s % int(10e8 + 7)

	if i - 1 <= c:
		ss = (ss + temp1 * int(10e8 + 7)) * tt / pp
		temp1 = ss / int(10e8 + 7)
		ss = ss % int(10e8 + 7)
		print s - ss
		tt -= 1
		pp += 1
	else:
		print s

Submission status: Wrong Answer

Solution code:
def f(a, b):
	s = 1
	for i in range(a - b + 1, a + 1):
		s = (s * i / (i - (a - b))) % int(10e8 + 7)
	return s

a = input()
l = map(int, raw_input().split())

d = sum(l) - (1 + a) * a / 2

c = 0

for i in l:
	if i != d:
		c += 1
	else:
		break

for i in reversed(l):
	if i != d:
		c += 1
	else:
		break

t = a + 1
tt = c
print a
p = 1
pp = 0
s = t
ss = tt
temp = 0


for i in range(2, a + 2):
	t -= 1
	p += 1
	s = (s + temp * int(10e8 + 7)) * t / p
	temp = s / int(10e8 + 7)
	s = s % int(10e8 + 7)

	if i - 1 <= c:
		tt -= 1
		pp += 1
		ss = (ss + temp * int(10e8 + 7)) * tt / pp
		temp = ss / int(10e8 + 7)
		ss = ss % int(10e8 + 7)
		print s - ss
	else:
		print s

Submission status: Wrong Answer

Solution code:
import sys

#N = int(input())
#a = list(map(int, input().split()))

def margeArray(arrayf, arrayl):
	flen = len(arrayf)
	llen = len(arrayl)
	arraym = [0] * (flen+llen);
	for i in range(0,flen):
		arraym[i] += arrayf[i]
		for j in range(0,llen):
			arraym[i+j+1] += arrayf[i] * arrayl[j];
	for k in range(0,llen):
		arraym[k] += arrayl[k]
	return arraym

def searchLeaf(array):
	N = len(array)
	if N == 1:
		print(array)
		return [1]
	if N%2 == 1:
		fh = array[0:int((N-1)/2)]
		lh = array[int((N-1)/2):N]
		arrayf = searchLeaf(fh)
		arrayl = searchLeaf(lh)
	else:
		fh = array[0:int(N/2)]
		lh = array[int(N/2):N]
		arrayf = searchLeaf(fh)
		arrayl = searchLeaf(lh)
	arraym = margeArray(arrayf, arrayl)
	return arraym


array = [1,2,1,3]
dictm = searchLeaf(array)
print(dictm)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from math import factorial

def nPk(n, k) :
    return factorial(n)/factorial(n-k)

def combination(n,k) :
    if n < k :
        return 0
    return int(nPk(n,k)/factorial(k))

D = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

dict = Counter(a).most_common()
dd = dict[0][0]

indexs = [i for i in range(n+1) if a[i] == dd]
for i in range(1,n+2) :
    print(combination(n+1,i) - combination(indexs[0]+(n-indexs[1]), i-1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def mod_pow(a, x, p):
    # return a^x mod p
    res = 1
    while x > 0:
        if(x & 1):
            res = (res * a) % p
        a = (a * a) % p;
        x >>= 1;
    return res
 
 
def mod_inverse(a, p):
    return mod_pow(a, p-2, p);
 
 
def mod_binomial(n, k, p):
    numerator = 1;
    for i in range(k):
        numerator = (numerator * (n - i)) % p;
 
    denominator = 1;
    for i in range(k):
        denominator = (denominator * (i + 1)) % p;
 
    res = mod_inverse(denominator, p);
    res = (res * numerator) % p;
    return res;


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def get_same_indices(arr):
    mem = [-1 for _ in arr]
    for i in range(len(arr)):
        n = arr[i]
        if not mem[n] == -1:
            return (mem[n], i)
        mem[n] = i


def main():
    n = get_ln_int_inputs()[0]
    a = get_ln_int_inputs()

    si = get_same_indices(a)

    former_c = si[0]
    latter_c = n - si[1]
    rem_c = former_c + latter_c
    mod = 1000000007

    for k in range(1, n + 1):
        total = mod_binomial(n + 1, k, mod)

        if k == 1:
            print(n)
            continue

        dup = 0
        if rem_c >= k - 1:
            dup = mod_binomial(rem_c, k - 1, mod)

        ans = (total - dup) % mod
        print(ans)


main()