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

def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))

    dp = [0]*(s+1)
    dp[0] = 1
    mod = 998244353

    for i in range(n):
        for j in range(s, -1, -1):
            if dp[j] and j + a[i] <= s:
                dp[j+a[i]] += dp[j]
                dp[j+a[i]] %= mod
            dp[j] *= 2
            dp[j] %= mod

    print(dp[s])
    
    
    
if __name__ == "__main__":
    main()


Fixed submission:
def main():
  n, s = map(int, input().split())
  a = [int(x) for x in input().split()]
  mod = 998244353
  
  dp = [[0]*(s+1) for _ in range(n+1)]
  dp[0][0] = 1
  for i in range(1, n+1):
    for j in range(s, -1, -1):
      dp[i][j] += dp[i-1][j]*2
      dp[i][j] %= mod
      if dp[i-1][j] and j+a[i-1] <= s:
        dp[i][j+a[i-1]] += dp[i-1][j]
        dp[i][j+a[i-1]] %= mod

  print(dp[n][s])
  
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n, s = map(int, input().split())
  a = [int(x) for x in input().split()]
  mod = 998244353
  
  dp = [[0]*(s+1) for _ in range(n+1)]
  dp[0][0] = 1
  for i in range(1, n+1):
    for j in range(s, -1, -1):
      dp[i][j] += dp[i-1][j]*2
      dp[i][j] %= mod
      if dp[i-1][j] and j+a[i-1] <= s:
        dp[i][j+a[i-1]] += dp[i-1][j]
        dp[i][j+a[i-1]] %= mod

  print(dp[n][s])
  
  
if __name__ == "__main__":
  main()

Fixed submission:
def main():
  n, s = map(int, input().split())
  a = [int(x) for x in input().split()]
  mod = 998244353
  
  dp = [[0]*(s+1) for _ in range(n+1)]
  dp[0][0] = 1
  for i in range(1, n+1):
    for j in range(s, -1, -1):
      dp[i][j] += dp[i-1][j]*2
      dp[i][j] %= mod
      if dp[i-1][j] and j+a[i-1] <= s:
        dp[i][j+a[i-1]] += dp[i-1][j]
        dp[i][j+a[i-1]] %= mod

  print(dp[n][s])
  
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    input = sys.stdin.readline
    n, s = map(int, input().split())
    a = [int(x) for x in input().split()]
    a.sort(reverse=True)
    mod = 998244353
    
    dp = [dict() for _ in range(s+1)]
    
    judge = dict()
    for i in range(n):
        for j in range(s-1, -1, -1):
            if dp[j] != judge and a[i]+j <= s:
                for k, v in dp[j].items():
                    if k+1 in dp[a[i]+j]:
                        dp[a[i]+j][k+1] = (v+dp[a[i]+j][k+1])%mod
                    else:
                        dp[a[i]+j][k+1] = v%mod
            if j == 0 and a[i] <= s:
                if 1 in dp[a[i]]:
                    dp[a[i]][1] = (dp[a[i]][1]+1)%mod
                else:
                    dp[a[i]][1] = 1
    
    ans = 0
    count = 1
    for k in range(n, 0, -1):
        if k in dp[s]:
            ans += (count*dp[s][k])%mod
            ans %= mod
        count *= 2
        count %= mod
    
    print(ans)
    

if __name__ == "__main__":
    main()

Fixed submission:
def main():
  n, s = map(int, input().split())
  a = [int(x) for x in input().split()]
  mod = 998244353
  
  dp = [[0]*(s+1) for _ in range(n+1)]
  dp[0][0] = 1
  for i in range(1, n+1):
    for j in range(s, -1, -1):
      dp[i][j] += dp[i-1][j]*2
      dp[i][j] %= mod
      if dp[i-1][j] and j+a[i-1] <= s:
        dp[i][j+a[i-1]] += dp[i-1][j]
        dp[i][j+a[i-1]] %= mod

  print(dp[n][s])
  
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    input = sys.stdin.readline
    n, s = map(int, input().split())
    a = [int(x) for x in input().split()]
    mod = 998244353
    
    dp = [dict() for _ in range(s+1)]
    
    judge = dict()
    for i in range(n):
        for j in range(s-1, -1, -1):
            if dp[j] != judge:
                if a[i]+j <= s:
                    for k, v in dp[j].items():
                        if k+1 in dp[a[i]+j]:
                            key = (v+dp[a[i]+j][k+1])%mod
                            dp[a[i]+j][k+1] = key
                        else:
                            dp[a[i]+j][k+1] = v
            if j == 0:
                if a[i] <= s:
                    if 1 in dp[a[i]]:
                        key = (dp[a[i]][1]+1)%mod
                        dp[a[i]][1] = key 
                    else:
                        dp[a[i]][1] = 1
    
    ans = 0
    count = 1
    for k in range(n, 0, -1):
        if k in dp[s]:
            ans += (count*dp[s][k])%mod
            ans %= mod
        count *= 2
        count %= mod
    
    print(ans)
    

if __name__ == "__main__":
    main()

Fixed submission:
def main():
  n, s = map(int, input().split())
  a = [int(x) for x in input().split()]
  mod = 998244353
  
  dp = [[0]*(s+1) for _ in range(n+1)]
  dp[0][0] = 1
  for i in range(1, n+1):
    for j in range(s, -1, -1):
      dp[i][j] += dp[i-1][j]*2
      dp[i][j] %= mod
      if dp[i-1][j] and j+a[i-1] <= s:
        dp[i][j+a[i-1]] += dp[i-1][j]
        dp[i][j+a[i-1]] %= mod

  print(dp[n][s])
  
  
if __name__ == "__main__":
  main()