Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

p = int(input())
aaa = list(map(int, input().split()))

bins = [1]
for i in range(1, p):
    bins.append(bins[-1] * (p - i) * pow(i, p - 2, p) % p)
bins = np.array(bins, dtype=np.int32)

coefs = np.zeros(p, dtype=np.int32)

for i, a in enumerate(aaa):
    if a == 0:
        continue

    coefs[0] += 1

    pows = [1]
    for _ in range(1, p):
        pows.append(pows[-1] * -i % p)
    pows.reverse()
    pows = np.array(pows, dtype=np.int32)

    coefs = (coefs - bins * pows) % p

print(*coefs)


Fixed submission:
p = int(input())
aaa = list(map(int, input().split()))

coefs = [0] * p
coefs[0] = sum(aaa)
invs = [pow(x, p - 2, p) for x in range(p + 1)]
for i, a in enumerate(aaa):
    if a == 0:
        continue

    b = 1
    c = 1
    for j in range(p - 1, -1, -1):
        coefs[j] = (coefs[j] - b * c) % p
        b = -b * i % p
        c = c * j * invs[p - j] % p

print(*coefs)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

p = int(input())
aaa = list(map(int, input().split()))

q = p - 2
m = np.arange(p + 1, dtype=np.int32)
r = np.ones(p + 1, dtype=np.int32)
while q:
    if q & 1:
        r = r * m % p
    m = m * m % p
    q >>= 1

coefs = [0] * p
coefs[0] = sum(aaa)
for i, a in enumerate(aaa):
    if a == 0:
        continue
    b = 1
    for j in range(p - 1, -1, -1):
        coefs[j] = (coefs[j] - b) % p
        b = -b * i * j * r[p - j] % p

print(*coefs)


Fixed submission:
p = int(input())
aaa = list(map(int, input().split()))

coefs = [0] * p
coefs[0] = sum(aaa)
invs = [pow(x, p - 2, p) for x in range(p + 1)]
for i, a in enumerate(aaa):
    if a == 0:
        continue

    b = 1
    c = 1
    for j in range(p - 1, -1, -1):
        coefs[j] = (coefs[j] - b * c) % p
        b = -b * i % p
        c = c * j * invs[p - j] % p

print(*coefs)

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

coefs = [0] * p
coefs[0] = sum(aaa)
invs = [pow(x, p - 2, p) for x in range(p + 1)]
for i, a in enumerate(aaa):
    if a == 0:
        continue
    b = 1
    for j in range(p - 1, -1, -1):
        coefs[j] = (coefs[j] - b) % p
        b = -b * i * j * invs[p - j] % p

print(*coefs)


Fixed submission:
p = int(input())
aaa = list(map(int, input().split()))

coefs = [0] * p
coefs[0] = sum(aaa)
invs = [pow(x, p - 2, p) for x in range(p + 1)]
for i, a in enumerate(aaa):
    if a == 0:
        continue

    b = 1
    c = 1
    for j in range(p - 1, -1, -1):
        coefs[j] = (coefs[j] - b * c) % p
        b = -b * i % p
        c = c * j * invs[p - j] % p

print(*coefs)

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

coefs = [0] * p
coefs[0] = sum(aaa)
invs = [pow(x, p - 2, p) for x in range(p + 1)]
for i, a in enumerate(aaa):
    if a == 0:
        continue

    b = 1
    c = 1
    for j in range(p - 1, -1, -1):
        coefs[j] = (coefs[j] - b * c) % p
        b = -b * i % p
        c = c * j * invs[p - j] % p

print(*coefs)


Fixed submission:
p = int(input())
aaa = list(map(int, input().split()))

coefs = [0] * p
coefs[0] = sum(aaa)
invs = [pow(x, p - 2, p) for x in range(p + 1)]
for i, a in enumerate(aaa):
    if a == 0:
        continue

    b = 1
    c = 1
    for j in range(p - 1, -1, -1):
        coefs[j] = (coefs[j] - b * c) % p
        b = -b * i % p
        c = c * j * invs[p - j] % p

print(*coefs)