Buggy python submission (verdict: Time Limit Exceeded):
def main():
    mod = 998244353
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    div2 = pow(2, mod - 2, mod)
    m = 0
    for a in A:
        for i in reversed(range(a, min(S, a + m) + 1)):
            dp[i] = dp[i] + dp[i - a] * div2
        m += a
    return dp[S] % mod

print(main())


Fixed submission:
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    return solve(N, S, A)

def solve(N, S, A):
    mod = 998244353
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    div2 = pow(2, mod - 2, mod)
    m = 0
    for a in A:
        m += a
        for i in reversed(range(a, min(S, m) + 1)):
            dp[i] = (dp[i] + dp[i - a] * div2) % mod
    return dp[S]

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def moddiv(a, b, mod):
    inverted_b = pow(b, mod-2, mod)
    return (a*inverted_b) % mod

def main():
    mod = 998244353
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    for a in A:
        for i in reversed(range(a, S + 1)):
            dp[i] = dp[i] + moddiv(dp[i - a], 2, mod)
    return dp[S] % mod

print(main())


Fixed submission:
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    return solve(N, S, A)

def solve(N, S, A):
    mod = 998244353
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    div2 = pow(2, mod - 2, mod)
    m = 0
    for a in A:
        m += a
        for i in reversed(range(a, min(S, m) + 1)):
            dp[i] = (dp[i] + dp[i - a] * div2) % mod
    return dp[S]

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def moddiv(a, b, mod):
    inverted_b = pow(b, mod-2, mod)
    return (a*inverted_b) % mod
def main():
    mod = 998244353
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    for a in A:
        for i in reversed(range(a, S + 1)):
            dp[i] = (dp[i] + moddiv(dp[i - a], 2, mod)) % mod
    return dp[S]

print(main())


Fixed submission:
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    return solve(N, S, A)

def solve(N, S, A):
    mod = 998244353
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    div2 = pow(2, mod - 2, mod)
    m = 0
    for a in A:
        m += a
        for i in reversed(range(a, min(S, m) + 1)):
            dp[i] = (dp[i] + dp[i - a] * div2) % mod
    return dp[S]

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def moddiv(a, b, mod):
    inverted_b = pow(b, mod-2, mod)
    return (a*inverted_b) % mod
def main():
    mod = 998244353
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    for a in A:
        for i in reversed(range(a, S + 1)):
            dp[i] = (dp[i] + moddiv(dp[i - a], 2, mod)) % mod
    return dp[S]

print(main())


Fixed submission:
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    return solve(N, S, A)

def solve(N, S, A):
    mod = 998244353
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    div2 = pow(2, mod - 2, mod)
    m = 0
    for a in A:
        m += a
        for i in reversed(range(a, min(S, m) + 1)):
            dp[i] = (dp[i] + dp[i - a] * div2) % mod
    return dp[S]

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    mod = 998244353
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [{} for _ in range(S + 1)]
    dp[0][0] = 1
    for a in A:
        for i in reversed(range(a, S + 1)):
            for k, v in dp[i - a].items():
                dp[i][k + 1] = dp[i].get(k + 1, 0) + v
    r = 0
    for k, v in dp[S].items():
        r += pow(2, N - k, mod) * v
        r %= mod
    return r

print(main())


Fixed submission:
def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    return solve(N, S, A)

def solve(N, S, A):
    mod = 998244353
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, mod)
    div2 = pow(2, mod - 2, mod)
    m = 0
    for a in A:
        m += a
        for i in reversed(range(a, min(S, m) + 1)):
            dp[i] = (dp[i] + dp[i - a] * div2) % mod
    return dp[S]

print(main())