Language: C++

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<vector>

#include<cstddef>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
constexpr i64 MAX = 10000000;
constexpr i64 MOD = 1000000007;
i64 fac[MAX], finv[MAX], inv[MAX];

template<i64 modulus>
class modcal {

public:
    i64 a;

    constexpr modcal(const i64 x = 0) noexcept: a(x % modulus) {}

    constexpr i64 &value() noexcept { return a; }

    constexpr const i64 &value() const noexcept { return a; }

    constexpr modcal operator+(const modcal rhs) const noexcept {
        return modcal(*this) += rhs;
    }

    constexpr modcal operator-(const modcal rhs) const noexcept {
        return modcal(*this) -= rhs;
    }

    constexpr modcal operator*(const modcal rhs) const noexcept {
        return modcal(*this) *= rhs;
    }

    constexpr modcal operator/(const modcal rhs) noexcept {
        return modcal(*this) /= rhs;
    }

    constexpr modcal &operator+=(const modcal rhs) noexcept {
        a += rhs.a;
        if (a >= modulus) {
            a -= modulus;
        }
        return *this;
    }

    constexpr modcal &operator-=(const modcal rhs) noexcept {
        if (a < rhs.a) {
            a += modulus;
        }
        a -= rhs.a;
        return *this;
    }

    constexpr modcal &operator*=(const modcal rhs) noexcept {
        a = a * rhs.a % modulus;
        return *this;
    }

    constexpr modcal &operator/=(modcal rhs) noexcept {
        i64 exp = modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    void COMninit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % modulus;
            inv[i] = MOD - inv[modulus % i] * (modulus / i) % modulus;
            finv[i] = finv[i - 1] * inv[i] % modulus;
        }
    }

    i64 COMn(i64 n, i64 k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % modulus) % modulus;
    }

    constexpr modcal<1000000007> modpow(const modcal<1000000007> &a, i64 n) {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }

    i64 modinv(i64 x) {//xy = 1となるyのうちMOD以下になるものを返す
        i64 m = MOD;
        i64 u = 1, v = 0;
        while (m) {
            i64 t = x / m;
            x -= t * m;
            swap(x, m);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        return u;
    }
};

using modc = modcal<998244353>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 n,k;
cin >> n >> k;
vectroe<i32> imos(n + 1);
rep(i,k){
    i32 l,r;
    cin >> l >> r;
    imos[l]++;
    imos[r + 1]--;
}
vector<i32> rec;
rep(i,n){
    imos[i + 1] += imos[i];
    if(imos[i + 1])rec.emplace_back(i + 1);
}
vector<vector<modc>> dp(rec.size(),vector<modc> (n + 1));
rep(i,rec.size()){
    dp[i][1] = 1;
}
rep(i,rec.size()){
    for(i32 j = rec[i] + 1; j <= n; j++)
    if(i == 0){
        dp[i][j] = dp[j - rec[i]];
    }else{
        dp[i][j] = dp[i][j - rec[i]] + dp[i - 1][j - rec[i]] + dp[i- 1][j];
    }
}
cout << dp[rec.size()][n] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:134:1: error: 'vectroe' was not declared in this scope
  134 | vectroe<i32> imos(n + 1);
      | ^~~~~~~
a.cc:134:12: error: expected primary-expression before '>' token
  134 | vectroe<i32> imos(n + 1);
      |            ^
a.cc:134:14: error: 'imos' was not declared in this scope
  134 | vectroe<i32> imos(n + 1);
      |              ^~~~
a.cc:153:33: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<modcal<998244353> > >, std::vector<modcal<998244353> > >::value_type' {aka 'std::vector<modcal<998244353> >'})
  153 |         dp[i][j] = dp[j - rec[i]];
      |                                 ^
a.cc:22:7: note: candidate: 'constexpr modcal<998244353>& modcal<998244353>::operator=(const modcal<998244353>&)'
   22 | class modcal {
      |       ^~~~~~
a.cc:22:7: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<modcal<998244353> > >, std::vector<modcal<998244353> > >::value_type' {aka 'std::vector<modcal<998244353> >'} to 'const modcal<998244353>&'
a.cc:22:7: note: candidate: 'constexpr modcal<998244353>& modcal<998244353>::operator=(modcal<998244353>&&)'
a.cc:22:7: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<modcal<998244353> > >, std::vector<modcal<998244353> > >::value_type' {aka 'std::vector<modcal<998244353> >'} to 'modcal<998244353>&&'
a.cc:158:6: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'})
  158 | cout << dp[rec.size()][n] << endl;
In file included from /usr/include/c++/14/iostream:41,
                 from a.cc:4:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  116 |       operator<<(__ostream_type& (*__pf)(__ostream_type&))
      |       ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
  116 |       operator<<(__ostream_type& (*__pf)(__ostream_type&))
      |                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
  125 |       operator<<(__ios_type& (*__pf)(__ios_type&))
      |       ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
  125 |       operator<<(__ios_type& (*__pf)(__ios_type&))
      |                  ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  135 |       operator<<(ios_base& (*__pf) (ios_base&))
      |       ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'std::ios_base& (*)(std::ios_base&)'
  135 |       operator<<(ios_base& (*__pf) (ios_base&))
      |                  ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  174 |       operator<<(long __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'long int'
  174 |       operator<<(long __n)
      |                  ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  178 |       operator<<(unsigned long __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'long unsigned int'
  178 |       operator<<(unsigned long __n)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  182 |       operator<<(bool __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'bool'
  182 |       operator<<(bool __n)
      |                  ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
   96 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'short int'
   97 |     operator<<(short __n)
      |                ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  189 |       operator<<(unsigned short __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'short unsigned int'
  189 |       operator<<(unsigned short __n)
      |                  ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
  110 |     basic_ostream<_CharT, _Traits>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'int'
  111 |     operator<<(int __n)
      |                ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  200 |       operator<<(unsigned int __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'unsigned int'
  200 |       operator<<(unsigned int __n)
      |                  ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  211 |       operator<<(long long __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'long long int'
  211 |       operator<<(long long __n)
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
  215 |       operator<<(unsigned long long __n)
      |       ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<modcal<998244353> >, modcal<998244353> >::value_type' {aka 'modcal<998244353>'} to 'long long unsigned int'
  215 |       operator<<(unsigned long long __n)
      |                  ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostr