Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

P = int(input())
A = list(map(int, input().split()))

# コンビネーション
mod = P
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 10**5 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = [0]*P
for j, a in enumerate(A):
    if a == 1:
        ans[0] = (ans[0] + 1) % P
        for k in range(P):
            ans[P-1-k] = (ans[P-1-k] - cmb(P-1, k) * pow(j, k, P) * (-1)**k) % P
print(*ans)

Fixed submission:
import sys
input = sys.stdin.readline


def main():
    P = int(input())
    A = list(map(int, input().split()))

    # コンビネーション
    mod = P
    def cmb(n, r, mod=mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    NN = 10**5 # 使うデータによって変える
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, NN + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    ans = [0]*P
    for j, a in enumerate(A):
        if a == 1:
            ans[0] = (ans[0] + 1) % P
            t = 1
            for k in range(P):
                ans[P-1-k] = (ans[P-1-k] - cmb(P-1, k) * t) % P
                t = t * (-j) % P
    print(*ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

P = int(input())
A = list(map(int, input().split()))

# コンビネーション
mod = P
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 10**5 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = [0]*P
for j, a in enumerate(A):
    if a == 1:
        ans[0] = (ans[0] + 1) % P
        for k in range(P):
            ans[P-1-k] = (ans[P-1-k] - cmb(P-1, k) * pow(j, k, P) * (-1)**k) % P
print(*ans)

Fixed submission:
import sys
input = sys.stdin.readline


def main():
    P = int(input())
    A = list(map(int, input().split()))

    # コンビネーション
    mod = P
    def cmb(n, r, mod=mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    NN = 10**5 # 使うデータによって変える
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, NN + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    ans = [0]*P
    for j, a in enumerate(A):
        if a == 1:
            ans[0] = (ans[0] + 1) % P
            t = 1
            for k in range(P):
                ans[P-1-k] = (ans[P-1-k] - cmb(P-1, k) * t) % P
                t = t * (-j) % P
    print(*ans)


if __name__ == "__main__":
    main()