Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10 ** 9)
M = 10 ** 9 + 7


cache = {}

# Combination under a prime modulo: nCk % p
def combmod(n, k, p=M):
    if k > n:
        return 0
    if k > n - k:
        k = n - k
    if (n, k) in cache:
        return cache[n, k]
    num, den = 1, 1
    for i in range(k):
        num = num * (n - i) % p
        den = den * (i + 1) % p
    # By Fermat's little theorem,
    # a^(p-1) ≡ 1 mod p
    # i.e. a^(p-2) ≡ a^(-1) mod p
    inv_dev = pow(den, p - 2, p)
    res = num * inv_dev % p
    cache[n, k] = res
    return res


n = int(input())
a = list(map(int, input().split()))
assert len(a) == n + 1

b = [None] * (n + 1)
d1, d2 = -1, -1
for i in range(n + 1):
    if b[a[i]] is None:
        b[a[i]] = i
    else:
        d1 = b[a[i]]
        d2 = i
        break
assert d1 >= 0 and d2 >= 0 and a[d1] == a[d2]


def comb(n, k):
    if k > n:
        return 0
    if k > n - k:
        k = n - k
    if k == 0:
        return 1
    if k == 1:
        return n
    if (n, k) in cache:
        return cache[n, k]
    res = combmod(n - 1, k) + combmod(n - 1, k - 1)
    cache[n, k] = res
    return res


for k in range(1, n + 2):
    ans = comb(n + 1, k) - comb(n - d2 + d1, k - 1)
    print(ans % M)


Fixed submission:
import sys

input = sys.stdin.readline
M = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n + 1

b = [None] * (n + 1)
d1, d2 = -1, -1
for i in range(n + 1):
    if b[a[i]] is None:
        b[a[i]] = i
    else:
        d1 = b[a[i]]
        d2 = i
        break
assert d1 >= 0 and d2 >= 0 and a[d1] == a[d2]


a, b, ik = n + 1, 1, 1
for k in range(1, n + 2):
    ans = (a - b) % M
    print(ans)
    b = b * (n + 1 - d2 + d1 - k) * ik % M
    ik = pow(k + 1, M - 2, M)
    a = a * (n + 1 - k) * ik % M

Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10 ** 9)
M = 10 ** 9 + 7


cache = {}
n = int(input())
a = list(map(int, input().split()))
assert len(a) == n + 1

b = [None] * (n + 1)
d1, d2 = -1, -1
for i in range(n + 1):
    if b[a[i]] is None:
        b[a[i]] = i
    else:
        d1 = b[a[i]]
        d2 = i
        break
assert d1 >= 0 and d2 >= 0 and a[d1] == a[d2]


def comb(n, k):
    if k > n:
        return 0
    if k > n - k:
        k = n - k
    if k == 0:
        return 1
    if k == 1:
        return n
    if (n, k) in cache:
        return cache[n, k]
    res = comb(n - 1, k) + comb(n - 1, k - 1)
    cache[n, k] = res
    return res


for k in range(1, n + 2):
    ans = comb(n + 1, k) - comb(n - d2 + d1, k - 1)
    print(ans % M)


Fixed submission:
import sys

input = sys.stdin.readline
M = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n + 1

b = [None] * (n + 1)
d1, d2 = -1, -1
for i in range(n + 1):
    if b[a[i]] is None:
        b[a[i]] = i
    else:
        d1 = b[a[i]]
        d2 = i
        break
assert d1 >= 0 and d2 >= 0 and a[d1] == a[d2]


a, b, ik = n + 1, 1, 1
for k in range(1, n + 2):
    ans = (a - b) % M
    print(ans)
    b = b * (n + 1 - d2 + d1 - k) * ik % M
    ik = pow(k + 1, M - 2, M)
    a = a * (n + 1 - k) * ik % M

Buggy python submission (verdict: Time Limit Exceeded):
M = 10 ** 9 + 7


cache = {}

# Combination under a prime modulo: nCk % p
def combmod(n, k, p=M):
    if k > n:
        return 0
    if k > n - k:
        k = n - k
    if (n, k) in cache:
        return cache[n, k]
    num, den = 1, 1
    for i in range(k):
        num = num * (n - i) % p
        den = den * (i + 1) % p
    # By Fermat's little theorem,
    # a^(p-1) ≡ 1 mod p
    # i.e. a^(p-2) ≡ a^(-1) mod p
    inv_dev = pow(den, p - 2, p)
    res = num * inv_dev % p
    cache[n, k] = res
    return res


n = int(input())
a = list(map(int, input().split()))
assert len(a) == n + 1

b = [None] * (n + 1)
d1, d2 = -1, -1
for i in range(n + 1):
    if b[a[i]] is None:
        b[a[i]] = i
    else:
        d1 = b[a[i]]
        d2 = i
        break
assert d1 >= 0 and d2 >= 0 and a[d1] == a[d2]

for w in range(1, n + 2):
    ans = combmod(n + 1, w) - combmod(n - d2 + d1, w - 1)
    print(ans % M)


Fixed submission:
import sys

input = sys.stdin.readline
M = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n + 1

b = [None] * (n + 1)
d1, d2 = -1, -1
for i in range(n + 1):
    if b[a[i]] is None:
        b[a[i]] = i
    else:
        d1 = b[a[i]]
        d2 = i
        break
assert d1 >= 0 and d2 >= 0 and a[d1] == a[d2]


a, b, ik = n + 1, 1, 1
for k in range(1, n + 2):
    ans = (a - b) % M
    print(ans)
    b = b * (n + 1 - d2 + d1 - k) * ik % M
    ik = pow(k + 1, M - 2, M)
    a = a * (n + 1 - k) * ik % M