Buggy python submission (verdict: Time Limit Exceeded):
def comb(n,k,p):
	from math import factorial
	if n<0 or k<0 or n<k: return 0
	if n==0 or k==0: return 1
	a,b,c = factorial(n)%p,factorial(k)%p,factorial(n-k)%p
	return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
	if b==0: return 1
	elif b%2==0:
		d = power_func(a,b//2,p)
		return d**2 %p
	elif b%2==1: return (a*power_func(a,b-1,p))%p
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
twice = Counter(a).most_common(1)[0][0]
x,y = (i for i,j in enumerate(a) if j == twice)
num,y = 1,n-y
for i in range(1,x+y+2):
	ans = comb(n+1,i,10**9+7)
	for j in range(max(0,i-y-1),min(i,x+1)):
		ans -= comb(x,j,10**9+7)*comb(y,i-j-1,10**9+7)
	print(ans)
for i in range(x+y+2,n+2): print(comb(n+1,i,10**9+7))

Fixed submission:
def comb(n,k):
	if n<k or n==0: return 0
	elif k==0: return 1
	else: return f[n]*p[k]*p[n-k]%(10**9+7)
from collections import Counter
n = int(input())
print(n)
a = [int(i) for i in input().split()]
twice = Counter(a).most_common(1)[0][0]
x,y = (i for i,j in enumerate(a) if j == twice)
num,y,f,p = 1,n-y,[1],[1]
for i in range(1,n+2):
	f.append(f[-1]*i%(10**9+7))
	p.append(pow(f[-1],10**9+5,10**9+7))
for i in range(2,x+y+2): print((comb(n+1,i)-comb(x+y,i-1))%(10**9+7))
for i in range(x+y+2,n+2): print(comb(n+1,i))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from math import factorial
n = int(input())
print(n)
a = [int(i) for i in input().split()]
twice = Counter(a).most_common(1)[0][0]
x,y = (i for i,j in enumerate(a) if j == twice)
num,y = n+1,n-y
X,Y,numx,numy = [1],[1],1,1
for i in range(1,x+1):
	numx = numx*(x-i+1)//i
	X.append(numx)
for i in range(1,y+1):
	numy = numy*(y-i+1)//i
	Y.append(numy)
for i in range(2,x+y+2):
	num = num*(n+2-i)//i
	ans = num
	for j in range(max(0,i-y-1),min(i,x+1)):
		ans -= X[j]*Y[i-j-1]
	print(ans%(10**9+7))
for i in range(x+y+2,n+2):
	num = num*(n+2-i)//i
	print(num%(10**9+7))

Fixed submission:
def comb(n,k):
	if n<k or n==0: return 0
	elif k==0: return 1
	else: return f[n]*p[k]*p[n-k]%(10**9+7)
from collections import Counter
n = int(input())
print(n)
a = [int(i) for i in input().split()]
twice = Counter(a).most_common(1)[0][0]
x,y = (i for i,j in enumerate(a) if j == twice)
num,y,f,p = 1,n-y,[1],[1]
for i in range(1,n+2):
	f.append(f[-1]*i%(10**9+7))
	p.append(pow(f[-1],10**9+5,10**9+7))
for i in range(2,x+y+2): print((comb(n+1,i)-comb(x+y,i-1))%(10**9+7))
for i in range(x+y+2,n+2): print(comb(n+1,i))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from math import factorial
n = int(input())
print(n)
a = [int(i) for i in input().split()]
twice = Counter(a).most_common(1)[0][0]
x,y = (i for i,j in enumerate(a) if j == twice)
num,y = n+1,n-y
X,Y = factorial(x),factorial(y)
for i in range(2,x+y+2):
	num = num*(n+2-i)//i
	ans,numx,numy = num,1,1
	for j in range(max(0,i-y-1),min(i,x+1)):
		if j==0: ans -= Y//(factorial(i-1)*factorial(y-i+1))
		elif j==i-1: ans -= X//(factorial(j)*factorial(x-j))
		else: ans -= (X//(factorial(j)*factorial(x-j)))*(Y//(factorial(i-j-1)*factorial(y-i+j+1)))
	print(ans%(10**9+7))
for i in range(x+y+2,n+2):
	num = num*(n+2-i)//i
	print(num%(10**9+7))

Fixed submission:
def comb(n,k):
	if n<k or n==0: return 0
	elif k==0: return 1
	else: return f[n]*p[k]*p[n-k]%(10**9+7)
from collections import Counter
n = int(input())
print(n)
a = [int(i) for i in input().split()]
twice = Counter(a).most_common(1)[0][0]
x,y = (i for i,j in enumerate(a) if j == twice)
num,y,f,p = 1,n-y,[1],[1]
for i in range(1,n+2):
	f.append(f[-1]*i%(10**9+7))
	p.append(pow(f[-1],10**9+5,10**9+7))
for i in range(2,x+y+2): print((comb(n+1,i)-comb(x+y,i-1))%(10**9+7))
for i in range(x+y+2,n+2): print(comb(n+1,i))