Language: C++

#include <iostream>
#include <vector>

long long modinv(long long n, long long MOD) {
	long long a = MOD, u = 1, v = 0;
	while (a) {
		long long t = n / a;
		n -= t * a; std::swap(n, a);
		u -= t * v; std::swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template<long long MOD> struct modint {
	long long value;
	void f() {
		value %= MOD;
		if (value < 0) value += MOD;
	}
	modint(long long n) : value(n) {f();}
	modint<MOD> operator+(modint<MOD> right) {modint<MOD> ret = (this -> value) + right.value; return ret;}
	modint<MOD> operator-(modint<MOD> right) {modint<MOD> ret = (this -> value) - right.value; return ret;}
	modint<MOD> operator*(modint<MOD> right) {modint<MOD> ret = (this -> value) * right.value; return ret;}
	modint<MOD> operator/(modint<MOD> right) {modint<MOD> ret = (this -> value) * modinv(right.value, MOD); return ret;}
	modint<MOD> operator+=(modint<MOD> right) {return *this = *this + right;}
	modint<MOD> operator-=(modint<MOD> right) {return *this = *this - right;}
	modint<MOD> operator*=(modint<MOD> right) {return *this = *this * right;}
	modint<MOD> operator/=(modint<MOD> right) {return *this = *this / right;}
	bool operator<(modint<MOD> right) {return ((this -> value) < right.value);}
	bool operator>(modint<MOD> right) {return ((this -> value) > right.value);}
	bool operator==(modint<MOD> right) {return ((this -> value) == right.value);}
	bool operator!=(modint<MOD> right) {return ((this -> value) != right.value);}
	bool operator<=(modint<MOD> right) {return ((this -> value) <= right.value);}
	bool operator>=(modint<MOD> right) {return ((this -> value) >= right.value);}
	modint<M>& operator++() {*this += 1; return *this;}
	modint<M> operator++(int) {*this += 1; return *this - 1;}
	modint<M>& operator--() {*this -= 1; return *this;}
	modint<M> operator--(int) {*this -= 1; return *this + 1;}
};
template<long long MOD> modint<MOD> operator+(long long left, modint<MOD> right) {return right + left;}
template<long long MOD> modint<MOD> operator-(long long left, modint<MOD> right) {return right * -1 + left;}
template<long long MOD> modint<MOD> operator*(long long left, modint<MOD> right) {return right * left;}
template<long long MOD> modint<MOD> operator/(long long left, modint<MOD> right) {
	return modinv(right.value, MOD) * (left % MOD);
}

template<long long MOD> modint<MOD> modpow(modint<MOD> a, long long n) {
	if (n == 0) return 1;
	if (a == 0) return 0;
	modint<MOD> ret = a;
	long long cnt = 1;
	while (cnt * 2 <= n) {
		ret *= ret;
		cnt *= 2;
	}
	return ret * modpow<MOD>(a, n - cnt);
}

long long modpow(long long a, long long n, long long MOD) {
	if (n == 0) return 1;
	if (a == 0) return 0;
	long long ret = a % MOD, cnt = 1;
	while (cnt * 2 <= n) {
		ret *= ret; ret %= MOD;
		cnt *= 2;
	}
	return ret * modpow(a, n - cnt, MOD) % MOD;
}

std::vector<long long> factorial;
std::vector<long long> factorial_inv;

template<long long P> void make_table(int n) {
	factorial.resize(n + 1, 1);
	factorial_inv.resize(n + 1, 1);
	for (int i = 1; i <= n; i++) factorial[i] = factorial[i - 1] * i % P;
	factorial_inv[n] = modinv(factorial[n], P);
	for (int i = n - 1; i >= 0; i--) factorial_inv[i] = factorial_inv[i + 1] * (i + 1) % P;
}

template<long long P> modint<P> permutation(int n, int r) {
	if (n <= factorial.size()) return factorial[n] * factorial_inv[n - r];
	std::cerr << "attention : factorial table is not constructed" << std::endl;
	r = std::min(r, n - r);
	modint<P> ret = 1;
	for (int i = 0; i < r; i++) ret *= n - i;
	return ret;
}

template<long long P> modint<P> combination(int n, int r) {
	if (n <= factorial.size()) return permutation<P>(n, r) * factorial_inv[r];
	std::cerr << "attention : factorial table is not constructed" << std::endl;
	r = std::min(r, n - r);
	modint<P> ret = 1;
	for (int i = 0; i < r; i++) {
		ret *= n - i;
		ret /= i + 1;
	}
	return ret;
}

template<long long MOD> std::ostream& operator<<(std::ostream& os, const modint<MOD>& target) {
	os << target.value;
	return os;
}

int main() {
	constexpr int P = 1000000007;
	int s;
	std::cin >> s;
	modint<P> ans = 0;
	make_table<P>(2000);
	for (int i = 1; i * 3 <= s; i++) {
		ans += combination<P>(s - i * 3 + i - 1, i - 1);
	}
	std::cout << ans << '\n';
}

Compiler output:
a.cc:37:16: error: 'M' was not declared in this scope
   37 |         modint<M>& operator++() {*this += 1; return *this;}
      |                ^
a.cc:37:17: error: template argument 1 is invalid
   37 |         modint<M>& operator++() {*this += 1; return *this;}
      |                 ^
a.cc:38:16: error: 'M' was not declared in this scope
   38 |         modint<M> operator++(int) {*this += 1; return *this - 1;}
      |                ^
a.cc:38:17: error: template argument 1 is invalid
   38 |         modint<M> operator++(int) {*this += 1; return *this - 1;}
      |                 ^
a.cc:39:16: error: 'M' was not declared in this scope
   39 |         modint<M>& operator--() {*this -= 1; return *this;}
      |                ^
a.cc:39:17: error: template argument 1 is invalid
   39 |         modint<M>& operator--() {*this -= 1; return *this;}
      |                 ^
a.cc:40:16: error: 'M' was not declared in this scope
   40 |         modint<M> operator--(int) {*this -= 1; return *this + 1;}
      |                ^
a.cc:40:17: error: template argument 1 is invalid
   40 |         modint<M> operator--(int) {*this -= 1; return *this + 1;}
      |                 ^