Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
 
mod = 998244353 
U, S, *A = map(int, read().split())

dp = [[[0]*3 for i in range(3001)] for i in range(3001)]

dp[0][0][0] = 1;
for i in range(U):
    for j in range(S+1):
        dp[i+1][j][0] += dp[i][j][0]%mod
        dp[i+1][j][1] += dp[i+1][j][0] + dp[i][j][1]%mod
        dp[i+1][j][2] += dp[i+1][j][1] + dp[i][j][2]%mod
        if j - A[i] >= 0:
            dp[i+1][j][1] += dp[i][j-A[i]][0]%mod + dp[i][j-A[i]][1]%mod
            dp[i+1][j][2] += dp[i][j-A[i]][0]%mod + dp[i][j-A[i]][1]%mod
    
    
print(dp[U][S][2])

Fixed submission:
def main():
  import sys
  read = sys.stdin.buffer.read
  r = 998244353
  U, S, *A = map(int, read().split())
  import copy
  ans = 0
  f = [0]*3010
  for a in A:
      c = copy.copy(f)
      f = [0]*a+c[:-a]
      f = [x+y for x,y in zip(f,c)]
      f[0] += 1
      f[a] += 1
      ans += f[S]
  ans %= r
  print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  import sys
  read = sys.stdin.buffer.read
  r = 998244353
  U, S, *A = map(int, read().split())
  import copy
  ans = 0
  f = [0]*3010
  for a in A:
      c = copy.deepcopy(f)
      f = [0]*a+c[:-a]
      f = [x+y for x,y in zip(f,c)]
      f[0] += 1
      f[a] += 1
      ans += f[S]
  ans %= r
  print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
  import sys
  read = sys.stdin.buffer.read
  r = 998244353
  U, S, *A = map(int, read().split())
  import copy
  ans = 0
  f = [0]*3010
  for a in A:
      c = copy.copy(f)
      f = [0]*a+c[:-a]
      f = [x+y for x,y in zip(f,c)]
      f[0] += 1
      f[a] += 1
      ans += f[S]
  ans %= r
  print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read

r = 998244353
 
n, s, *As = map(int, read().split())
import copy
answer = 0
f = [0]*3001
for A in As:
    c = copy.deepcopy(f)
    t = [0]*A
    f = t+c
    f = f[:-A]
    f = [x+y for x,y in zip(f,c)]
    f[0] += 1
    f[A] += 1
    answer += f[s]

answer %= r
print(answer)

Fixed submission:
def main():
  import sys
  read = sys.stdin.buffer.read
  r = 998244353
  U, S, *A = map(int, read().split())
  import copy
  ans = 0
  f = [0]*3010
  for a in A:
      c = copy.copy(f)
      f = [0]*a+c[:-a]
      f = [x+y for x,y in zip(f,c)]
      f[0] += 1
      f[a] += 1
      ans += f[S]
  ans %= r
  print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read

MOD = 998244353
 
N, S, *As = map(int, read().split())
import copy
answer = 0
f = [0]*3010
for A in As:
    c = copy.deepcopy(f)
    t = [0]*A
    f = t+c
    f = f[:-A]
    f = [x+y for x,y in zip(f,c)]
    f[0] += 1
    f[A] += 1
    #f %= MOD
    answer += f[S]

answer %= MOD
print(answer)

Fixed submission:
def main():
  import sys
  read = sys.stdin.buffer.read
  r = 998244353
  U, S, *A = map(int, read().split())
  import copy
  ans = 0
  f = [0]*3010
  for a in A:
      c = copy.copy(f)
      f = [0]*a+c[:-a]
      f = [x+y for x,y in zip(f,c)]
      f[0] += 1
      f[a] += 1
      ans += f[S]
  ans %= r
  print(ans)
if __name__ == '__main__':
    main()