Buggy python submission (verdict: Runtime Error):
import numba

@numba.jit
def main():
    n, s = list(map(int, input().split()))
    a = list(map(int, input().split()))
    dp = [[None] * (s+1) for _ in range(n+1)]
    M = 998244353


    for j in range(s+1):
        dp[0][j] = 0
    for i in range(n+1):
        dp[i][0] = i+1

    for i in range(1,n+1):
        for j in range(1, s+1):
            dp[i][j] = dp[i-1][j]
            if j-a[i-1]>=0:
                dp[i][j] += dp[i-1][j-a[i-1]]
            dp[i][j] %= M
    total = 0
    for i in range(n+1):
        total += dp[i][s]
    return total%M
if __name__=="__main__":
    print(main())

Fixed submission:


n, s = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [[None] * (s+1) for _ in range(n+1)]
M = 998244353


for j in range(s+1):
    dp[0][j] = 0
for i in range(n+1):
    dp[i][0] = i+1

for i in range(1,n+1):
    for j in range(1, s+1):
        dp[i][j] = dp[i-1][j]
        if j-a[i-1]>=0:
            dp[i][j] += dp[i-1][j-a[i-1]]
        dp[i][j] %= M
print(sum((dp[i][s] for i in range(n+1)))%M)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,s = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
# t[i][j] : 0<=r<...,<l=iについて和がsになるようなf(r,l)の和
# t = [[0]*(s+1) for _ in range(n)]
t = np.zeros((n, s+1), dtype="int64")
if a[0]<=s:
    t[0,a[0]] = 1
for i in range(n):
    t[i,0] = i+2
for i in range(1,n):
    for j in range(1,s+1):
        tt = t[i-1,j]
        if j-a[i]>=0:
            tt += t[i-1,j-a[i]]
        t[i,j] = tt
print(t[:,s].sum()%998244353)

Fixed submission:


n, s = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [[None] * (s+1) for _ in range(n+1)]
M = 998244353


for j in range(s+1):
    dp[0][j] = 0
for i in range(n+1):
    dp[i][0] = i+1

for i in range(1,n+1):
    for j in range(1, s+1):
        dp[i][j] = dp[i-1][j]
        if j-a[i-1]>=0:
            dp[i][j] += dp[i-1][j-a[i-1]]
        dp[i][j] %= M
print(sum((dp[i][s] for i in range(n+1)))%M)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,s = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
# t[i][j] : 0<=r<...,<l=iについて和がsになるようなf(r,l)の和
# t = [[0]*(s+1) for _ in range(n)]
t = np.zeros((n, s+1), dtype="int64")
if a[0]<=s:
    t[0,a[0]] = 1
for i in range(n):
    t[i,0] = i+2
for i in range(1,n):
    for j in range(1,s+1):
        tt = t[i-1,j]
        if j-a[i]>=0:
            tt += t[i-1,j-a[i]]
        t[i,j] = tt
print(t[:,s].sum()%998244353)

Fixed submission:


n, s = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [[None] * (s+1) for _ in range(n+1)]
M = 998244353


for j in range(s+1):
    dp[0][j] = 0
for i in range(n+1):
    dp[i][0] = i+1

for i in range(1,n+1):
    for j in range(1, s+1):
        dp[i][j] = dp[i-1][j]
        if j-a[i-1]>=0:
            dp[i][j] += dp[i-1][j-a[i-1]]
        dp[i][j] %= M
print(sum((dp[i][s] for i in range(n+1)))%M)

Buggy python submission (verdict: Time Limit Exceeded):
# fp = open("input/21")
# input = fp.readline
n,s = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
# t[i][j] : 0<=r<...,<l=iについて和がsになるようなf(r,l)の和
t = [[0]*(s+1) for _ in range(n)]
if a[0]<=s:
    t[0][a[0]] = 1
for i in range(n):
    t[i][0] = i+2
for i in range(1,n):
    for j in range(1,s+1):
        tt = t[i-1][j]
        if j-a[i]>=0:
            tt += t[i-1][j-a[i]]
        t[i][j] = tt
print(sum(t[i][s] for i in range(n))%998244353)

Fixed submission:


n, s = list(map(int, input().split()))
a = list(map(int, input().split()))
dp = [[None] * (s+1) for _ in range(n+1)]
M = 998244353


for j in range(s+1):
    dp[0][j] = 0
for i in range(n+1):
    dp[i][0] = i+1

for i in range(1,n+1):
    for j in range(1, s+1):
        dp[i][j] = dp[i-1][j]
        if j-a[i-1]>=0:
            dp[i][j] += dp[i-1][j-a[i-1]]
        dp[i][j] %= M
print(sum((dp[i][s] for i in range(n+1)))%M)