Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    MOD = 998244353
    N, S = inpl()
    A = sorted(inpl())
    dp = [{} for _ in range(N + 1)]
    dp[0][0] = 1
    for i, a in enumerate(A):
        for j in range(min(S - a, i), -1, -1):
            for k, v in dp[j].items():
                if k + a > S:
                    continue
                if k + a not in dp[j + 1]:
                    dp[j + 1][k + a] = v
                else:
                    dp[j + 1][k + a] = v + dp[j + 1][k + a]
    # print(dp)

    p2 = [0] * (N + 1)
    p2[0] = 1
    for i in range(1, N + 1):
        p2[i] = (p2[i - 1] * 2) % MOD

    ans = 0
    for i in range(1, N + 1):
        if S in dp[i]:
            ans = (ans + dp[i][S] * p2[N - i]) % MOD
    print(ans)
    return


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import OrderedDict
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    MOD = 998244353
    N, S = inpl()
    A = sorted(inpl())
    dp = {}
    dp[0] = 1
    for i, a in enumerate(A):
        # print(i, dp)
        ks = sorted(dp.keys())
        for k in ks[::-1]:
            # print(k)
            if k + a <= S:
                if k + a in dp:
                    dp[k + a] = (dp[k] + dp[k + a]) % MOD
                else:
                    dp[k + a] = dp[k]
            dp[k] = (dp[k] * 2) % MOD
    # print(dp)
    print(0 if S not in dp else dp[S])
    return


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    MOD = 998244353
    N, S = inpl()
    A = inpl()
    dp = [{} for _ in range(N + 1)]
    dp[0][0] = 1
    for i, a in enumerate(A):
        for j in range(i, -1, -1):
            for k, v in dp[j].items():
                if k + a > S:
                    continue
                if k + a not in dp[j + 1]:
                    dp[j + 1][k + a] = v
                else:
                    dp[j + 1][k + a] = v + dp[j + 1][k + a]
    # print(dp)

    p2 = [0] * (N + 1)
    p2[0] = 1
    for i in range(1, N + 1):
        p2[i] = (p2[i - 1] * 2) % MOD

    ans = 0
    for i in range(1, N + 1):
        if S in dp[i]:
            ans = (ans + dp[i][S] * p2[N - i]) % MOD
    print(ans)
    return


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import OrderedDict
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    MOD = 998244353
    N, S = inpl()
    A = sorted(inpl())
    dp = {}
    dp[0] = 1
    for i, a in enumerate(A):
        # print(i, dp)
        ks = sorted(dp.keys())
        for k in ks[::-1]:
            # print(k)
            if k + a <= S:
                if k + a in dp:
                    dp[k + a] = (dp[k] + dp[k + a]) % MOD
                else:
                    dp[k + a] = dp[k]
            dp[k] = (dp[k] * 2) % MOD
    # print(dp)
    print(0 if S not in dp else dp[S])
    return


if __name__ == '__main__':
    main()