Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import jit
     
MOD = 998244353
N, K = list(map(int, input().split()))
     
dp = np.zeros(N+1, dtype=np.int64)
mv = np.zeros(N+1, dtype=np.int64)
for i in range(K):
    l, r = list(map(int, input().split()))
    for j in range(l, r+1):
        mv[j] = 1

@jit(nopython=True)
def shift_and_add(dp, mv, i):
    for i in range(1, N+1):
        dp += np.concatenate((np.zeros(i+1, dtype=np.int64), mv[1:N-i+1]*dp[i]))
        dp %= MOD
            
dp[1] = 1
shift_and_add(dp, mv, i)
     
print(dp[N])


Fixed submission:
MOD = 998244353
N, K = list(map(int, input().split()))

a = [0] * (N+1)
f = [0] * (N+1)
mv = list()
for i in range(K):
    mv.append(list(map(int, input().split())))

def solve(N, a, f):
    for i in range(1, N+1):
        f[i] = (f[i-1] + a[i]) % MOD
        for j in range(len(mv)):
            l, r = mv[j]
            if i+l < N+1: a[i+l] = (a[i+l] + f[i]) % MOD
            if i+r+1 < N+1: a[i+r+1] = (a[i+r+1] - f[i]) % MOD

a[1] = 1
mv.sort()
solve(N, a, f)

print(a[N])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import jit
     
MOD = 998244353
N, K = list(map(int, input().split()))
     
dp = np.zeros(N+1, dtype=np.int64)
mv = np.zeros(N+1, dtype=np.int64)
for i in range(K):
    l, r = list(map(int, input().split()))
    for j in range(l, r+1):
        mv[j] = 1

@jit
def shift_and_add(dp, mv, i):
    for i in range(1, N+1):
        dp += np.concatenate((np.zeros(i+1, dtype=np.int64), mv[1:N-i+1]*dp[i]))
        dp %= MOD
            
dp[1] = 1
shift_and_add(dp, mv, i)
     
print(dp[N])


Fixed submission:
MOD = 998244353
N, K = list(map(int, input().split()))

a = [0] * (N+1)
f = [0] * (N+1)
mv = list()
for i in range(K):
    mv.append(list(map(int, input().split())))

def solve(N, a, f):
    for i in range(1, N+1):
        f[i] = (f[i-1] + a[i]) % MOD
        for j in range(len(mv)):
            l, r = mv[j]
            if i+l < N+1: a[i+l] = (a[i+l] + f[i]) % MOD
            if i+r+1 < N+1: a[i+r+1] = (a[i+r+1] - f[i]) % MOD

a[1] = 1
mv.sort()
solve(N, a, f)

print(a[N])

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353
N, K = list(map(int, input().split()))

dp = [0] * (N+1)
mv = list()
for i in range(K):
    l, r = list(map(int, input().split()))
    for j in range(l, r+1):
        mv.append(j)

def solve(N, dp, mv):
    for i in range(1, N+1):
        for j in range(len(mv)):
            if i+mv[j]>N: break
            if dp[i] == 0: continue
            dp[i+mv[j]] = (dp[i+mv[j]] + dp[i]) % MOD

dp[1] = 1
mv.sort()
solve(N, dp, mv)

print(dp[N])


Fixed submission:
MOD = 998244353
N, K = list(map(int, input().split()))

a = [0] * (N+1)
f = [0] * (N+1)
mv = list()
for i in range(K):
    mv.append(list(map(int, input().split())))

def solve(N, a, f):
    for i in range(1, N+1):
        f[i] = (f[i-1] + a[i]) % MOD
        for j in range(len(mv)):
            l, r = mv[j]
            if i+l < N+1: a[i+l] = (a[i+l] + f[i]) % MOD
            if i+r+1 < N+1: a[i+r+1] = (a[i+r+1] - f[i]) % MOD

a[1] = 1
mv.sort()
solve(N, a, f)

print(a[N])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

MOD = 998244353
N, K = list(map(int, input().split()))

dp = np.zeros(N+1, dtype=np.int64)
mv = np.zeros(N+1, dtype=np.int64)
for i in range(K):
    l, r = list(map(int, input().split()))
    for j in range(l, r+1):
        mv[j] = 1

def shift_and_add(dp, mv, m, i):
    dp += np.concatenate((np.zeros(i+1, dtype=np.int64), mv[1:N-i+1]*m))
    dp %= MOD
        
dp[1] = 1
for i in range(1, N+1):
    m = dp[i]
    shift_and_add(dp, mv, m, i)

print(dp[N])


Fixed submission:
MOD = 998244353
N, K = list(map(int, input().split()))

a = [0] * (N+1)
f = [0] * (N+1)
mv = list()
for i in range(K):
    mv.append(list(map(int, input().split())))

def solve(N, a, f):
    for i in range(1, N+1):
        f[i] = (f[i-1] + a[i]) % MOD
        for j in range(len(mv)):
            l, r = mv[j]
            if i+l < N+1: a[i+l] = (a[i+l] + f[i]) % MOD
            if i+r+1 < N+1: a[i+r+1] = (a[i+r+1] - f[i]) % MOD

a[1] = 1
mv.sort()
solve(N, a, f)

print(a[N])

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

MOD = 998244353
N, K = list(map(int, input().split()))

dp = np.zeros(N+1, dtype=np.int64)
mv = np.zeros(N+1, dtype=np.int64)
for i in range(K):
    l, r = list(map(int, input().split()))
    for j in range(l, r+1):
        mv[j] = 1

@jit(nopython=True)
def shift_and_add(dp, mv, m, i):
    dp += np.concatenate((np.zeros(i+1, dtype=np.int64), mv[1:N-i+1]*m))
    dp %= MOD
        
dp[1] = 1
for i in range(1, N+1):
    m = dp[i]
    shift_and_add(dp, mv, m, i)

print(dp[N])


Fixed submission:
MOD = 998244353
N, K = list(map(int, input().split()))

a = [0] * (N+1)
f = [0] * (N+1)
mv = list()
for i in range(K):
    mv.append(list(map(int, input().split())))

def solve(N, a, f):
    for i in range(1, N+1):
        f[i] = (f[i-1] + a[i]) % MOD
        for j in range(len(mv)):
            l, r = mv[j]
            if i+l < N+1: a[i+l] = (a[i+l] + f[i]) % MOD
            if i+r+1 < N+1: a[i+r+1] = (a[i+r+1] - f[i]) % MOD

a[1] = 1
mv.sort()
solve(N, a, f)

print(a[N])

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353
N, K = list(map(int, input().split()))

dp = [0] * (N+1)

mvlst = list()
for i in range(K):
    l, r = list(map(int, input().split()))
    for j in range(l, r+1):
        mvlst.append(j)

dp[1] = 1
for i in range(1, N+1):
    for j in range(len(mvlst)):
        if i-mvlst[j]<1: continue
        dp[i] += dp[i-mvlst[j]]
        dp[i] = dp[i] % MOD

print(dp[N] % MOD)


Fixed submission:
MOD = 998244353
N, K = list(map(int, input().split()))

a = [0] * (N+1)
f = [0] * (N+1)
mv = list()
for i in range(K):
    mv.append(list(map(int, input().split())))

def solve(N, a, f):
    for i in range(1, N+1):
        f[i] = (f[i-1] + a[i]) % MOD
        for j in range(len(mv)):
            l, r = mv[j]
            if i+l < N+1: a[i+l] = (a[i+l] + f[i]) % MOD
            if i+r+1 < N+1: a[i+r+1] = (a[i+r+1] - f[i]) % MOD

a[1] = 1
mv.sort()
solve(N, a, f)

print(a[N])