Language: C++

#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
template<class T> void cmin(T &a, const T&b) { if (a > b)a = b; }
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
vi a(400), b(400),ca(400);
ll mod = 1000000007;
template <class T>
inline void hash_combine(size_t & seed, const T & v) {
	hash<T> hasher;
	seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
namespace std {
	namespace
	{

	template<typename S, typename T> struct hash<pair<S, T>> {
		inline size_t operator()(const pair<S, T> & v) const {
			size_t seed = 0;
			hash_combine(seed, v.first);
			hash_combine(seed, v.second);
			return seed;
		}
	};
	// Recursive template code derived from Matthieu M.
	template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1>
	struct HashValueImpl
	{
		static void apply(size_t& seed, Tuple const& tuple)
		{
			HashValueImpl<Tuple, Index - 1>::apply(seed, tuple);
			hash_combine(seed, std::get<Index>(tuple));
		}
	};

	template <class Tuple>
	struct HashValueImpl<Tuple, 0>
	{
		static void apply(size_t& seed, Tuple const& tuple)
		{
			hash_combine(seed, std::get<0>(tuple));
		}
	};
}

template <typename ... TT>
struct hash<std::tuple<TT...>>
{
	size_t
		operator()(std::tuple<TT...> const& tt) const
	{
		size_t seed = 0;
		HashValueImpl<std::tuple<TT...> >::apply(seed, tt);
		return seed;
	}

}; }
umap<ti3, ll> memo;
ll pow(ll base, ll i,ll mod) {
	ll a=1;
	while (i) {
		if (i & 1) {
			a *= base;
			a %= mod;
		}
		base *= base;
		base %= mod;
		i/=2;
	}
	return a;
}
ll f(int l,int n,int c) {
	auto it = memo.find(ti3(l, n, c));
	if (memo.end() != it)return it->second;
	if (n == 1) {
		ll buf = 0;
		for (int j = a[l]; j <= b[l]; j++)buf += pow(j, c, mod);
		return buf % mod;
	}
	ll buf = 0;
	rep(i, c + 1) {
		buf += f(l, n / 2, i) * f(l + n / 2, n - n / 2, c - i);
		buf %= mod;
	}
	memo[ti3(l, n, c)] = buf;
	return buf;
}
int main() {
	int n, c;
	cin >> n >> c;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	vi ca(n);
	ca[0] = c;
	ll sum = 0;
	cout << f(0,n,c) << endl;
}

Compiler output:
a.cc:45:49: error: specialization of 'template<class _Tp> struct std::hash' in different namespace [-fpermissive]
   45 |         template<typename S, typename T> struct hash<pair<S, T>> {
      |                                                 ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_bvector.h:65,
                 from /usr/include/c++/14/vector:67,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note:   from definition of 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:46:64: error: definition of 'std::size_t std::hash<std::pair<_T1, _T2> >::operator()(const std::pair<_T1, _T2>&) const' is not in namespace enclosing 'std::hash<std::pair<_T1, _T2> >' [-fpermissive]
   46 |                 inline size_t operator()(const pair<S, T> & v) const {
      |                                                                ^~~~~