Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353

Pre = [[[] for _ in range(S+1)] for _ in range(N+1)]

Pre[0][0] = [0]

for i, a in enumerate(A):
    for j in range(S+1):
        if len(Pre[i][j]) > 0:
            Pre[i + 1][j] += Pre[i][j]
            if a + j <= S:
                for n in Pre[i][j]:
                    Pre[i + 1][j + a].append(n + 1)
ans = 0
Ans = Counter(Pre[N][S])
for key, value in Ans.items():
    ans += pow(2, N - key, mod) * value
    ans %= mod

print(ans % mod)

Fixed submission:
import numpy as np

N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
f = np.zeros(3100, np.int64)

ans = 0
f[0] = 1
for a in A:
    g = f.copy()
    f[a:] += g[:-a]
    f += g
    f %= mod

print(f[S])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353

Pre = [[Counter() for _ in range(S+1)] for _ in range(N+1)]

Pre[0][0][0] = 1

for i, a in enumerate(A):
    for j in range(S+1):
        if len(Pre[i][j]) > 0:
            Pre[i + 1][j] += Pre[i][j]
        if a + j <= S:
            for key, value in Pre[i][j].items():
                Pre[i + 1][j + a][key + 1] += value
ans = 0
for key, value in Pre[N][S].items():
    ans += pow(2, N - key, mod) * value
    ans %= mod

print(ans % mod)

Fixed submission:
import numpy as np

N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
f = np.zeros(3100, np.int64)

ans = 0
f[0] = 1
for a in A:
    g = f.copy()
    f[a:] += g[:-a]
    f += g
    f %= mod

print(f[S])

Buggy python submission (verdict: Time Limit Exceeded):
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353

Pre = [[[] for _ in range(S+1)] for _ in range(N+1)]

Pre[0][0].append(0)

for i, a in enumerate(A):
    for j in range(S+1):
        Pre[i + 1][j] += Pre[i][j]
        if a + j <= S:
            for p in Pre[i][j]:
                Pre[i + 1][j + a].append(p + 1)
ans = 0
for L in Pre[N][S]:
    ans += pow(2, N - L, mod)
    ans %= mod

print(ans % mod)

Fixed submission:
import numpy as np

N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
f = np.zeros(3100, np.int64)

ans = 0
f[0] = 1
for a in A:
    g = f.copy()
    f[a:] += g[:-a]
    f += g
    f %= mod

print(f[S])

Buggy python submission (verdict: Time Limit Exceeded):
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353

DP = [[0] * (S+1) for _ in range(N+1)]
Pre = [[[] for _ in range(S+1)] for _ in range(N+1)]

DP[0][0] = 1
Pre[0][0].append([-1])

for i, a in enumerate(A):
    for j in range(S+1):
        b = DP[i][j]
        if b > 0:
            DP[i + 1][j] += DP[i][j]
            for P in Pre[i][j]:
                Pre[i+1][j].append(P)
        if a + j <= S:
            DP[i + 1][j + a] += DP[i][j]
            for P in Pre[i][j]:
                Pre[i + 1][j+a].append(P + [i])
ans = 0
for L in Pre[N][S]:
    ans += pow(2, N - len(L) + 1, mod)
    ans %= mod

print(ans % mod)

Fixed submission:
import numpy as np

N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
f = np.zeros(3100, np.int64)

ans = 0
f[0] = 1
for a in A:
    g = f.copy()
    f[a:] += g[:-a]
    f += g
    f %= mod

print(f[S])