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)]
dp[0][0] = 1
for i in range(N):
    for s in range(S+1):
        if s-A[i] >= 0:
            dp[i+1][s] = (dp[i][s] * 2 + dp[i][s-A[i]]) % MOD
        else:
            dp[i+1][s] = dp[i][s] * 2 % MOD
print(dp[N][S])



Fixed submission:

def solve(N,S,A):
    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    mod = 998244353
    for i, a in enumerate(A, 1):
        for s in range(S+1):
            if s-a >= 0:
                dp[i][s] = (dp[i-1][s] * 2 + dp[i-1][s-a]) % mod
            else:
                dp[i][s] = dp[i-1][s] * 2 % mod
    print(dp[N][S])

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

Buggy python submission (verdict: Time Limit Exceeded):

def solve(N,S,A):
    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    mod = 998244353
    for i, a in enumerate(A, 1):
        for s in range(S+1):
            if s-a >= 0:
                dp[i][s] = (dp[i-1][s] * 2 + dp[i-1][s-a]) % mod
            else:
                dp[i][s] = dp[i-1][s] * 2 % mod
    print(dp[N][S])

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


Fixed submission:

def solve(N,S,A):
    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    mod = 998244353
    for i, a in enumerate(A, 1):
        for s in range(S+1):
            if s-a >= 0:
                dp[i][s] = (dp[i-1][s] * 2 + dp[i-1][s-a]) % mod
            else:
                dp[i][s] = dp[i-1][s] * 2 % mod
    print(dp[N][S])

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

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353
def part_sum(a,A):
  
  #初期化
  N=len(a)
  dp=[[[0 for i in range(N+1)] for i in range(A+1)] for j in range(N+1)]
  dp[0][0][0]=1

  #DP
  for i in range(N):
    for j in range(A+1):
      for k in range(N):
        if a[i]<=j: #i+1番目の数字a[i]を足せるかも
            dp[i+1][j][k+1]=dp[i][j-a[i]][k]+ dp[i][j][k+1]% MOD
        else: #入る可能性はない
            dp[i+1][j][k]=dp[i][j][k]%MOD
  return dp[N][A]



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

ans = 0
sm = part_sum(A,S)
for n in range(N+1):
    p = pow(2,N-n,MOD)
    ans += p*sm[n]
    ans %= MOD
print (ans)

Fixed submission:

def solve(N,S,A):
    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    mod = 998244353
    for i, a in enumerate(A, 1):
        for s in range(S+1):
            if s-a >= 0:
                dp[i][s] = (dp[i-1][s] * 2 + dp[i-1][s-a]) % mod
            else:
                dp[i][s] = dp[i-1][s] * 2 % mod
    print(dp[N][S])

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

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353
def part_sum(a,A):
  
  #初期化
  N=len(a)
  dp=[[[0 for i in range(N+1)] for i in range(A+1)] for j in range(N+1)]
  dp[0][0][0]=1

  #DP
  for i in range(N):
    for j in range(A+1):
      for k in range(N):
        if a[i]<=j: #i+1番目の数字a[i]を足せるかも
            dp[i+1][j][k+1]=dp[i][j-a[i]][k]+ dp[i][j][k+1]% MOD
        else: #入る可能性はない
            dp[i+1][j][k]=dp[i][j][k]%MOD
  return dp[N][A]



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

ans = 0
sm = part_sum(A,S)
for n in range(N+1):
    p = pow(2,N-n,MOD)
    ans += p*sm[n]
    ans %= MOD
print (ans)

Fixed submission:

def solve(N,S,A):
    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    mod = 998244353
    for i, a in enumerate(A, 1):
        for s in range(S+1):
            if s-a >= 0:
                dp[i][s] = (dp[i-1][s] * 2 + dp[i-1][s-a]) % mod
            else:
                dp[i][s] = dp[i-1][s] * 2 % mod
    print(dp[N][S])

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