Language: C++

// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
// const MOD: i64 = 1000000007;
const MOD: i64 = 998244353;

use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuuu() -> (usize, usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(unused_macros)]
macro_rules! debug {


    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(dead_code)]
fn vector_accumulation(vec: &Vec<i64>) -> Vec<i64> {
    let mut res = Vec::new();
    let size = vec.len();
    res.push(0);
    for i in 0..size {
        res.push(vec[i]);
    }
    for i in 0..size {
        res[i + 1] += res[i];
    }
    res
}

#[allow(dead_code)]
pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
#[allow(dead_code)]
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
#[allow(dead_code)]
/// (gcd, x, y)
pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (gcd, x, y) = extgcd(b, a % b);
        (gcd, y, x - (a / b) * y)
    }
}
#[allow(dead_code)]
/// x ^ n % m
pub fn mod_pow(x: u64, n: u64, m: u64) -> u64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
#[allow(dead_code)]
pub fn mod_inverse(a: u64, m: u64) -> u64 {
    let (_, x, _) = extgcd(a as i64, m as i64);
    ((m as i64 + x) as u64 % m) % m
}
#[allow(dead_code)]
pub fn fact_table(len: usize, m: u64) -> Vec<u64> {
    let mut res = vec![1; len + 1];
    for i in 1..len + 1 {
        res[i] = (i as u64 * res[i - 1]) % m;
    }
    res
}
#[allow(dead_code)]
/// Factorial and Inverse factorial table
pub fn fact_inv_table(size: usize, m: u64) -> (Vec<u64>, Vec<u64>) {
    let mut fact = vec![1; size];
    let mut fact_inv = vec![1; size];
    for i in 2..size {
        fact[i] = fact[i - 1] * i as u64 % m;
        fact_inv[i] = m - ((m / i as u64) * fact_inv[(m % i as u64) as usize] % m);
    }
    for i in 1..size {
        fact_inv[i] = fact_inv[i - 1] * fact_inv[i] % m;
    }
    (fact, fact_inv)
}
#[allow(dead_code)]
/// (a mod p, e when n! = a p\^e)
pub fn mod_fact(n: u64, p: u64, fact: &[u64]) -> (u64, u64) {
    if n == 0 {
        (1, 0)
    } else {
        let (a, b) = mod_fact(n / p, p, fact);
        let pow = b + n / p;
        if n / p % 2 != 0 {
            (a * (p - fact[(n % p) as usize]) % p, pow)
        } else {
            (a * fact[(n % p) as usize] % p, pow)
        }
    }
}
#[allow(dead_code)]
/// C(n, k) % p
pub fn mod_comb(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    if n < k {
        0
    } else {
        let (a1, e1) = mod_fact(n, p, fact);
        let (a2, e2) = mod_fact(k, p, fact);
        let (a3, e3) = mod_fact(n - k, p, fact);
        if e1 > e2 + e3 {
            0
        } else {
            a1 * mod_inverse(a2 * a3 % p, p) % p
        }
    }
}
#[allow(dead_code)]
/// H(n, k) % p
pub fn mod_comb_repetition(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    mod_comb(n - 1 + k, n - 1, p, fact)
}

macro_rules! mint {
    (a :expr ) => {
        Mint::new({ a })
    };
}
#[derive(Copy, Clone)]
pub struct Mint(i64);
impl Mint {
    fn new(x: i64) -> Self {
        Mint(x.rem_euclid(MOD))
    }
    fn pow(self, n: usize) -> Self {
        match n {
            0 => Mint::new(1),
            _ => {
                let mut a = self.pow(n >> 1);
                a *= a;
                if n & 1 == 1 {
                    a *= self;
                }
                a
            }
        }
    }
    fn inv(self) -> Self {
        self.pow((MOD - 2) as usize)
    }
}
impl std::ops::Neg for Mint {
    type Output = Mint;
    fn neg(self) -> Self::Output {
        Self::new(-self.0)
    }
}
impl std::ops::AddAssign<Mint> for Mint {
    fn add_assign(&mut self, rhs: Self) {
        self.0 += rhs.0;
        self.0 %= MOD;
    }
}
impl std::ops::AddAssign<i64> for Mint {
    fn add_assign(&mut self, rhs: i64) {
        *self += Mint::new(rhs);
    }
}
impl std::ops::AddAssign<usize> for Mint {
    fn add_assign(&mut self, rhs: usize) {
        *self += Mint::new(rhs as i64);
    }
}
impl<T> std::ops::Add<T> for Mint
where
    Mint: std::ops::AddAssign<T>,
{
    type Output = Self;
    fn add(self, other: T) -> Self {
        let mut res = self;
        res += other;
        res
    }
}
impl std::ops::SubAssign<Mint> for Mint {
    fn sub_assign(&mut self, rhs: Self) {
        self.0 -= rhs.0;
        if self.0 < 0 {
            self.0 += MOD;
        }
    }
}
impl std::ops::SubAssign<i64> for Mint {
    fn sub_assign(&mut self, rhs: i64) {
        *self -= Mint::new(rhs);
    }
}
impl std::ops::SubAssign<usize> for Mint {
    fn sub_assign(&mut self, rhs: usize) {
        *self -= Mint::new(rhs as i64);
    }
}
impl<T> std::ops::Sub<T> for Mint
where
    Mint: std::ops::SubAssign<T>,
{
    type Output = Self;
    fn sub(self, other: T) -> Self {
        let mut res = self;
        res -= other;
        res
    }
}
impl std::ops::MulAssign<Mint> for Mint {
    fn mul_assign(&mut self, rhs: Self) {
        self.0 *= rhs.0;
        self.0 %= MOD;
    }
}
impl std::ops::MulAssign<i64> for Mint {
    fn mul_assign(&mut self, rhs: i64) {
        *self *= Mint::new(rhs);
    }
}
impl std::ops::MulAssign<usize> for Mint {
    fn mul_assign(&mut self, rhs: usize) {
        *self *= Mint::new(rhs as i64);
    }
}
impl<T> std::ops::Mul<T> for Mint
where
    Mint: std::ops::MulAssign<T>,
{
    type Output = Self;
    fn mul(self, other: T) -> Self {
        let mut res = self;
        res *= other;
        res
    }
}
impl std::ops::DivAssign<Mint> for Mint {
    fn div_assign(&mut self, rhs: Self) {
        *self *= rhs.inv();
    }
}
impl std::ops::DivAssign<i64> for Mint {
    fn div_assign(&mut self, rhs: i64) {
        *self /= Mint::new(rhs);
    }
}
impl std::ops::DivAssign<usize> for Mint {
    fn div_assign(&mut self, rhs: usize) {
        *self /= Mint::new(rhs as i64);
    }
}
impl<T> std::ops::Div<T> for Mint
where
    Mint: std::ops::DivAssign<T>,
{
    type Output = Self;
    fn div(self, other: T) -> Self {
        let mut res = self;
        res /= other;
        res
    }
}
impl std::fmt::Display for Mint {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
impl std::ops::Deref for Mint {
    type Target = i64;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl std::ops::DerefMut for Mint {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

fn solve() {
    let (n, k) = readuu();
    let mut data: Vec<(usize, usize)> = vec![(0, 0); 0];
    for i in 0..k {
        let (a, b) = readuu();
        data.push((a, b));
    }
    let mut dp = vec![Mint(0); n + 1];
    dp[0] = Mint(1);
    dp[1] -= Mint(1);

    for i in 0..n - 1 {
        let ways = dp[i];
        for j in 0..k {
            let l = min(n, i + data[j].0);
            let r = min(n, i + data[j].1 + 1);
            // println!("{} {} {} ", l, r, ways);
            dp[l] += ways;
            dp[r] -= ways;
        }
        let xx = dp[i];
        dp[i + 1] += xx;
        // dp[i + 1] %= Min998244353;
    }

    // let dp2 = vector_accumulation(&dp);
    // println!("{:?}", dp);
    println!("{}", dp[n - 1]);
    return;
}
fn main() {
    solve()
}


Compiler output:
a.cc:20:2: error: invalid preprocessing directive #[
   20 | #[allow(dead_code)]
      |  ^
a.cc:26:2: error: invalid preprocessing directive #[
   26 | #[allow(dead_code)]
      |  ^
a.cc:33:2: error: invalid preprocessing directive #[
   33 | #[allow(dead_code)]
      |  ^
a.cc:35:6: error: too many decimal points in number
   35 |     (0..n).map(|_| read_vec()).collect()
      |      ^~~~
a.cc:38:2: error: invalid preprocessing directive #[
   38 | #[allow(dead_code)]
      |  ^
a.cc:48:2: error: invalid preprocessing directive #[
   48 | #[allow(dead_code)]
      |  ^
a.cc:59:2: error: invalid preprocessing directive #[
   59 | #[allow(dead_code)]
      |  ^
a.cc:71:2: error: invalid preprocessing directive #[
   71 | #[allow(dead_code)]
      |  ^
a.cc:84:2: error: invalid preprocessing directive #[
   84 | #[allow(unused_macros)]
      |  ^
a.cc:89:10: error: invalid preprocessing directive #[
   89 |         #[cfg(debug_assertions)]
      |          ^
a.cc:97:2: error: invalid preprocessing directive #[
   97 | #[allow(dead_code)]
      |  ^
a.cc:102:14: error: too many decimal points in number
  102 |     for i in 0..size {
      |              ^~~~~~~
a.cc:105:14: error: too many decimal points in number
  105 |     for i in 0..size {
      |              ^~~~~~~
a.cc:111:2: error: invalid preprocessing directive #[
  111 | #[allow(dead_code)]
      |  ^
a.cc:119:2: error: invalid preprocessing directive #[
  119 | #[allow(dead_code)]
      |  ^
a.cc:123:2: error: invalid preprocessing directive #[
  123 | #[allow(dead_code)]
      |  ^
a.cc:133:2: error: invalid preprocessing directive #[
  133 | #[allow(dead_code)]
      |  ^
a.cc:148:2: error: invalid preprocessing directive #[
  148 | #[allow(dead_code)]
      |  ^
a.cc:153:2: error: invalid preprocessing directive #[
  153 | #[allow(dead_code)]
      |  ^
a.cc:156:14: error: too many decimal points in number
  156 |     for i in 1..len + 1 {
      |              ^~~~~~
a.cc:161:2: error: invalid preprocessing directive #[
  161 | #[allow(dead_code)]
      |  ^
a.cc:166:14: error: too many decimal points in number
  166 |     for i in 2..size {
      |              ^~~~~~~
a.cc:170:14: error: too many decimal points in number
  170 |     for i in 1..size {
      |              ^~~~~~~
a.cc:175:2: error: invalid preprocessing directive #[
  175 | #[allow(dead_code)]
      |  ^
a.cc:190:2: error: invalid preprocessing directive #[
  190 | #[allow(dead_code)]
      |  ^
a.cc:206:2: error: invalid preprocessing directive #[
  206 | #[allow(dead_code)]
      |  ^
a.cc:217:2: error: invalid preprocessing directive #[
  217 | #[derive(Copy, Clone)]
      |  ^
a.cc:356:47: warning: missing terminating ' character
  356 |     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      |                                               ^
a.cc:356:47: error: missing terminating ' character
  356 |     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:375:14: error: too many decimal points in number
  375 |     for i in 0..k {
      |              ^~~~
a.cc:383:14: error: too many decimal points in number
  383 |     for i in 0..n - 1 {
      |              ^~~~
a.cc:385:18: error: too many decimal points in number
  385 |         for j in 0..k {
      |                  ^~~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::cmp::*;
      | ^~~
a.cc:4:1: error: 'use' does not name a type
    4 | use std::collections::*;
      | ^~~
a.cc:5:1: error: 'use' does not name a type
    5 | use std::fs::File;
      | ^~~
a.cc:6:1: error: 'use' does not name a type
    6 | use std::io::prelude::*;
      | ^~~
a.cc:7:1: error: 'use' does not name a type
    7 | use std::io::*;
      | ^~~
a.cc:8:1: error: 'use' does not name a type
    8 | use std::vec;
      | ^~~
a.cc:10:10: error: found ':' in nested-name-specifier, expected '::'
   10 | const INF: i64 = 1223372036854775807;
      |          ^
      |          ::
a.cc:10:7: error: 'INF' does not name a type
   10 | const INF: i64 = 1223372036854775807;
      |       ^~~
a.cc:11:15: error: found ':' in nested-name-specifier, expected '::'
   11 | const MEM_SIZE: usize = 202020;
      |               ^
      |               ::
a.cc:11:7: error: 'MEM_SIZE' does not name a type
   11 | const MEM_SIZE: usize = 202020;
      |       ^~~~~~~~
a.cc:13:10: error: found ':' in nested-name-specifier, expected '::'
   13 | const MOD: i64 = 998244353;
      |          ^
      |          ::
a.cc:13:7: error: 'MOD' does not name a type
   13 | const MOD: i64 = 998244353;
      |       ^~~
a.cc:15:1: error: 'use' does not name a type
   15 | use std::cmp::*;
      | ^~~
a.cc:16:1: error: 'use' does not name a type
   16 | use std::collections::*;
      | ^~~
a.cc:17:1: error: 'use' does not name a type
   17 | use std::io::stdin;
      | ^~~
a.cc:18:1: error: 'use' does not name a type
   18 | use std::io::stdout;
      | ^~~
a.cc:19:1: error: 'use' does not name a type
   19 | use std::io::Write;
      | ^~~
a.cc:21:1: error: 'fn' does not name a type
   21 | fn read<T: std::str::FromStr>() -> T {
      | ^~
a.cc:27:1: error: 'fn' does not name a type
   27 | fn read_vec<T: std::str::FromStr>() -> Vec<T> {
      | ^~
a.cc:34:1: error: 'fn' does not name a type
   34 | fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
      | ^~
a.cc:39:1: error: 'fn' does not name a type
   39 | fn readii() -> (i64, i64) {
      | ^~
a.cc:49:1: error: 'fn' does not name a type
   49 | fn readuu() -> (usize, usize) {
      | ^~
a.cc:60:1: error: 'fn' does not name a type
   60 | fn readuuu() -> (usize, usize, usize) {
      | ^~
a.cc:72:1: error: 'fn' does not name a type
   72 | fn readuuuu() -> (usize, usize, usize, usize) {
      | ^~
a.cc:85:1: error: 'macro_rules' does not name a type
   85 | macro_rules! debug {
      | ^~~~~~~~~~~
a.cc:98:1: error: 'fn' does not name a type
   98 | fn vector_accumulation(vec: &Vec<i64>) -> Vec<i64> {
      | ^~
a.cc:112:1: error: 'pub' does not name a type
  112 | pub fn gcd(a: u64, b: u64) -> u64 {
      | ^~~
a.cc:120:1: error: 'pub' does not name a type
  120 | pub fn lcm(a: u64, b: u64) -> u64 {
      | ^~~
a.cc:125:1: error: 'pub' does not name a type
  125 | pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
      | ^~~
a.cc:135:1: error: 'pub' does not name a type
  135 | pub fn mod_pow(x: u64, n: u64, m: u64) -> u64 {
      | ^~~
a.cc:149:1: error: 'pub' does not name a type
  149 | pub fn mod_inverse(a: u64, m: u64) -> u64 {
      | ^~~
a.cc:154:1: error: 'pub' does not name a type
  154 | pub fn fact_table(len: usize, m: u64) -> Vec<u64> {
      | ^~~
a.cc:163:1: error: 'pub' does not name a type
  163 | pub fn fact_inv_table(size: usize, m: u64) -> (Vec<u64>, Vec<u64>) {
      | ^~~
a.cc:177:1: error: 'pub' does not name a type
  177 | pub fn mod_fact(n: u64, p: u64, fact: &[u64]) -> (u64, u64) {
      | ^~~
a.cc:192:1: error: 'pub' does not name a type
  192 | pub fn mod_comb(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
      | ^~~
a.cc:208:1: error: 'pub' does not name a type
  208 | pub fn mod_comb_repetition(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
      | ^~~
a.cc:212:1: error: 'macro_rules' does not name a type
  212 | macro_rules! mint {
      | ^~~~~~~~~~~
a.cc:218:1: error: 'pub' does not name a type
  218 | pub struct Mint(i64);
      | ^~~
a.cc:219:1: error: 'impl' does not name a type
  219 | impl Mint {
      | ^~~~
a.cc:240:1: error: 'impl' does not name a type
  240 | impl std::ops::Neg for Mint {
      | ^~~~
a.cc:246:1: error: 'impl' does not name a type
  246 | impl std::ops::AddAssign<Mint> for Mint {
      | ^~~~
a.cc:252:1: error: 'impl' does not name a type
  252 | impl std::ops::AddAssign<i64> for Mint {
      | ^~~~
a.cc:257:1: error: 'impl' does not name a type
  257 | impl std::ops::AddAssign<usize> for Mint {
      | ^~~~
a.cc:262:1: error: 'impl' does not name a type
  262 | impl<T> std::ops::Add<T> for Mint
      | ^~~~
a.cc:273:1: error: 'impl' does not name a type
  273 | impl std::ops::SubAssign<Mint> for Mint {
      | ^~~~
a.cc:281:1: error: 'impl' does not name a type
  281 | impl std::ops::SubAssign<i64> for Mint {
      | ^~~~
a.cc:286:1: error: 'impl' does not name a type
  286 | impl std::ops::SubAssign<usize> for Mint {
      | ^~~~
a.cc:291:1: error: 'impl' does not name a type
  291 | impl<T> std::ops::Sub<T> for Mint
      | ^~~~
a.cc:302:1: error: 'impl' does not name a type
  302 | impl std::ops::MulAssign<Mint> for Mint {
      | ^~~~
a.cc:308:1: error: 'impl' does not name a type
  308 | impl std::ops::MulAssign<i64> for Mint {
      | ^~~~
a.cc:313:1: error: 'impl' does not name a type
  313 | impl std::ops::MulAssign<usize> for Mint {
      | ^~~~
a.cc:318:1: error: 'impl' does not name a type
  318 | impl<T> std::ops::Mul<T> for Mint
      | ^~~~
a.cc:329:1: error: 'impl' does not name a type
  329 | impl std::ops::DivAssign<Mint> for Mint {
      | ^~~~
a.cc:334:1: error: 'impl' does not name a type
  334 | impl std::ops::DivAssign<i64> for Mint {
      | ^~~~
a.cc:339:1: error: 'impl' does not name a type
  339 | impl std::ops::DivAssign<usize> for Mint {
      | ^~~~
a.cc:344:1: error: 'impl' does not name a type
  344 | impl<T> std::ops::Div<T> for Mint
      | ^~~~
a.cc:355:1: error: 'impl' does not name a type
  355 | impl std::fmt::Display for Mint {
      | ^~~~
a.cc:359:1: error: expected declaration before '}' token
  359 | }
      | ^
a.cc:360:1: error: 'impl' does not name a type
  360 | impl std::ops::Deref for Mint {
      | ^~~~
a.cc:366:1: error: 'impl' does not name a type
  366 | impl std::ops::DerefMut for Mint {
      | ^~~~
a.cc:372:1: error: 'fn' does not name a type
  372 | fn solve() {
      | ^~
a.cc:402:1: error: 'fn' does not name a type
  402 | fn main() {
      | ^~