Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    pow2 = [1, 1]
    for i in range(2, N+2):
        j = powquick(i, div-2, div)
        pow2.append(pow2[-1]*j % div)

    # pow2 = [1, 1]
    # inv = [0, 1]
    # for i in range(2, N+2):
    #     inv.append((-inv[div % i]) *(div // i) % div)
    #     pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    # pow2 = [1, 1]
    # for i in range(2, N+2):
    #     j = powquick(i, div-2, div)
    #     pow2.append(pow2[-1]*j % div)

    pow2 = [1, 1]
    inv = [0, 1]
    for i in range(2, N+2):
        inv.append((-inv[div % i]) *(div // i) % div)
        pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    pow2 = [1, 1]
    for i in range(2, N+2):
        j = powquick(i, div-2, div)
        pow2.append(pow2[-1]*j % div)

    # pow2 = [1, 1]
    # inv = [0, 1]
    # for i in range(2, N+2):
    #     inv.append((-inv[div % i]) *(div // i) % div)
    #     pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    # pow2 = [1, 1]
    # for i in range(2, N+2):
    #     j = powquick(i, div-2, div)
    #     pow2.append(pow2[-1]*j % div)

    pow2 = [1, 1]
    inv = [0, 1]
    for i in range(2, N+2):
        inv.append((-inv[div % i]) *(div // i) % div)
        pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)
    pow2 = [1, 1]
    for i in range(2, N+2):
        j = powquick(i, div-2, div)
        # print((i * j) % div)
        pow2.append(pow2[-1]*j % div)

    # print(pow1)
    # print(pow2)
    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    # pow2 = [1, 1]
    # for i in range(2, N+2):
    #     j = powquick(i, div-2, div)
    #     pow2.append(pow2[-1]*j % div)

    pow2 = [1, 1]
    inv = [0, 1]
    for i in range(2, N+2):
        inv.append((-inv[div % i]) *(div // i) % div)
        pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    B = [1]
    v = 1
    for i in range(1, N+2):
        v = (v*(N-i+2))//i
        B.append(v % div)
    # print(B)

    C = [1]
    v = 1
    for i in range(1, M+1):
        v = (v*(M-i+1))//i
        C.append(v % div)

    for l in range(1, N+2):
        if l <= M+1:
            print((B[l] - C[l-1]) % div)
        else:
            print(B[l])

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    # pow2 = [1, 1]
    # for i in range(2, N+2):
    #     j = powquick(i, div-2, div)
    #     pow2.append(pow2[-1]*j % div)

    pow2 = [1, 1]
    inv = [0, 1]
    for i in range(2, N+2):
        inv.append((-inv[div % i]) *(div // i) % div)
        pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    B = [1]
    v = 1
    for i in range(1, N+2):
        v = (v*(N-i+2))//i
        B.append(v % div)
    # print(B)

    C = [1]
    v = 1
    for i in range(1, M+1):
        v = (v*(M-i+1))//i
        C.append(v % div)

    for l in range(1, N+2):
        if l <= M+1:
            print((B[l] - C[l-1]) % div)
        else:
            print(B[l])

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    # pow2 = [1, 1]
    # for i in range(2, N+2):
    #     j = powquick(i, div-2, div)
    #     pow2.append(pow2[-1]*j % div)

    pow2 = [1, 1]
    inv = [0, 1]
    for i in range(2, N+2):
        inv.append((-inv[div % i]) *(div // i) % div)
        pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    B = [1]
    v = 1
    for i in range(1, N+2):
        v = (v*(N-i+2))//i
        B.append(v % div)
    # print(B)

    C = [1]
    v = 1
    for i in range(1, M+1):
        v = (v*(M-i+1))//i
        C.append(v % div)

    for l in range(1, N+2):
        if l <= M+1:
            print((B[l] - C[l-1]) % div)
        else:
            print(B[l])

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = pow(10, 9) + 7

    # print(A)
    d = dict()
    for i in range(N+1):
        if A[i] not in d: d[A[i]] = [i]
        else: d[A[i]].append(i)

    i1, i2 = 0, 0
    for a in d:
        if len(d[a]) == 2:
            i1, i2 = d[a]
            break
    M = i1 + N-i2
    # print(N, i1, i2)

    # N+1_C_l
    pow1 = [1, 1]
    for i in range(2, N+2):
        pow1.append(pow1[-1]*i % div)

    # pow2 = [1, 1]
    # for i in range(2, N+2):
    #     j = powquick(i, div-2, div)
    #     pow2.append(pow2[-1]*j % div)

    pow2 = [1, 1]
    inv = [0, 1]
    for i in range(2, N+2):
        inv.append((-inv[div % i]) *(div // i) % div)
        pow2.append(pow2[-1] * inv[-1] % div)

    for l in range(1, N+2):
        v = (pow1[N+1]*pow2[l]*pow2[N+1-l]) % div
        # print(v)
        if l <= M+1:
            v -= (pow1[M]*pow2[l-1]*pow2[M-l+1]) % div
        print(v % div)

def powquick(x, y, div):
        if y == 0: return 1
        if y == 1: return x % div
        if y % 2 == 0: return pow(powquick(x, y // 2, div), 2) % div
        if y % 2 == 1: return pow(powquick(x, y// 2, div), 2) * x % div


if __name__ == '__main__':
    main()