Buggy python submission (verdict: Time Limit Exceeded):
p=int(input())
A=list(map(int,input().split()))
cmb=[0]*p
cmb[0]=1
for i in range(1,p):
  cmb[i]=cmb[i-1]*(p-i)*pow(i,p-2,p)%p
ans=[0]*p
for i in range(p):
  if A[i]==1:
    b=1
    ans[0]=ans[0]+1
    for j in range(p):
      ans[p-j-1]=(ans[p-j-1]-cmb[j]*b)%p
      b=b*(-i)%p
for i in range(p-1):
  print(ans[i],end=" ")
print(ans[p-1])



Fixed submission:
p=int(input())
A=list(map(int,input().split()))
cmb=[0]*p
cmb[0]=1
for i in range(1,p):
  cmb[i]=cmb[i-1]*(p-i)*pow(i,p-2,p)%p
ans=[0]*p
for i in range(p):
  if A[i]==1:
    b=1
    ans[0]=ans[0]+1
    for j in range(p):
      ans[p-j-1]=(ans[p-j-1]-cmb[j]*b)%p
      b=b*(-i)%p
for i in range(p-1):
  print(ans[i],end=" ")
print(ans[p-1])

Buggy python submission (verdict: Time Limit Exceeded):
p=int(input())
A=list(map(int,input().split()))

def comb(n,k,p):
  """power_funcを用いて(nCk) mod 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=factorial(n) %p
  b=factorial(k) %p
  c=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):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

  
def power_func(x,y,z):
  bi=str(format(y,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %z
    if bi[i]=="1":
      res=(res*x) %z
  return res
C=[]
for i in range(p):
  C.append(comb(p-1,i,p))


B=[0]*p
if A[0]==0:
  for i in range(p):
    if A[i]==1:
      for j in range(p):
        B[j]=B[j]+(-1)**(j+1)*C[j]*(i**(p-j-1)%p)
        #B[j]=B[j]+(-1)**(j+1)*C[j]*power_func(i,p-j-1,p)
      B[0]=B[0]+1
else:
  B[0]=1
  for i in range(1,p):
    if A[i]==0:
      for j in range(p):
        B[j]=B[j]-(-1)**(j+1)*C[j]*(i**(p-j-1)%p)
        #B[j]=B[j]-(-1)**(j+1)*C[j]*power_func(i,p-j-1,p)
      B[0]=B[0]-1
for i in range(p-1):
  print(B[i]%p,end=" ")
print(B[-1]%p)

Fixed submission:
p=int(input())
A=list(map(int,input().split()))
cmb=[0]*p
cmb[0]=1
for i in range(1,p):
  cmb[i]=cmb[i-1]*(p-i)*pow(i,p-2,p)%p
ans=[0]*p
for i in range(p):
  if A[i]==1:
    b=1
    ans[0]=ans[0]+1
    for j in range(p):
      ans[p-j-1]=(ans[p-j-1]-cmb[j]*b)%p
      b=b*(-i)%p
for i in range(p-1):
  print(ans[i],end=" ")
print(ans[p-1])

Buggy python submission (verdict: Time Limit Exceeded):
p=int(input())
A=list(map(int,input().split()))

def comb(n,k,p):
  """power_funcを用いて(nCk) mod 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=factorial(n) %p
  b=factorial(k) %p
  c=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):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

  
def power_func(x,y,z):
  bi=str(format(y,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %z
    if bi[i]=="1":
      res=(res*x) %z
  return res
C=[]
for i in range(p):
  C.append(comb(p-1,i,p))


B=[0]*p
if A[0]==0:
  for i in range(p):
    if A[i]==1:
      for j in range(p):
        B[j]=B[j]+(-1)**(j+1)*C[j]*power_func(i,p-j-1,p)
      B[0]=B[0]+1
else:
  B[0]=1
  for i in range(1,p):
    if A[i]==0:
      for j in range(p):
        B[j]=B[j]-(-1)**(j+1)*C[j]*power_func(i,p-j-1,p)
      B[0]=B[0]-1
for i in range(p-1):
  print(B[i]%p,end=" ")
print(B[-1]%p)

Fixed submission:
p=int(input())
A=list(map(int,input().split()))
cmb=[0]*p
cmb[0]=1
for i in range(1,p):
  cmb[i]=cmb[i-1]*(p-i)*pow(i,p-2,p)%p
ans=[0]*p
for i in range(p):
  if A[i]==1:
    b=1
    ans[0]=ans[0]+1
    for j in range(p):
      ans[p-j-1]=(ans[p-j-1]-cmb[j]*b)%p
      b=b*(-i)%p
for i in range(p-1):
  print(ans[i],end=" ")
print(ans[p-1])