Language: C++

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


//Debug
string to_string(const string& s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
	res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
	if (!first) {
	  res += ", ";
	}
	first = false;
	res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) false
#endif


double PI=3.141592653589793;

const int mx=1<<18,mvn=1e5;
unordered_map<int,int> proc[mx];
int va[mx],w[mx];

void solve(){
	int n,q;
	cin >> n;
	int bs=10;
	forse(i,1,n+1) cin >> va[i] >> w[i];

	forse(i,1,n+1){
		int bsiz=log2(i);
		map<int,int> cur;
		if(i==1||bsiz==bs){
			cur[0]=0;
			cur[w[i]]=va[i];
			proc[i]=cur;
			continue;
		}

		cur=proc[i/2];
		for(auto v:proc[i/2]){
			int vn=v.fi+w[i],val=v.se+va[i];
			if(vn<=mvn) cur[vn]=max(cur[vn],val);
		}
		int bval=-1;
		for(auto v:cur){
			if(v.se<=bval) continue;
			bval=v.se;
			proc[i][v.fi]=v.se;
		}	
	}

//	forse(i,1,n+1){
//		debug(i,proc[i]);
//	}

	cin >> q;
	while(q--){
		int v,l;
		cin >> v >> l;
		int bsiz=log2(v);
		if(bsiz>=bs){
			int pr=v>>(bsiz-bs+1);
			int out=0;
			for(auto u:proc[v]){
				if(l<u.fi) break;
				out=max(out,u.se+(--proc[pr].upper_bound(l-u.fi))->se);
			}	
			cout << out << '\n';
		}else cout << (--proc[v].upper_bound(l))->se << '\n';
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forse(c,1,T+1){
		//	cout << "Case #" << cid << ": ";
		solve();
	}
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:81:33: error: no match for 'operator=' (operand types are 'std::unordered_map<int, int>' and 'std::map<int, int>')
   81 |                         proc[i]=cur;
      |                                 ^~~
In file included from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/unordered_map.h:279:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  279 |       operator=(const unordered_map&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:279:17: note:   no known conversion for argument 1 from 'std::map<int, int>' to 'const std::unordered_map<int, int>&'
  279 |       operator=(const unordered_map&) = default;
      |                 ^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:283:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  283 |       operator=(unordered_map&&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:283:17: note:   no known conversion for argument 1 from 'std::map<int, int>' to 'std::unordered_map<int, int>&&'
  283 |       operator=(unordered_map&&) = default;
      |                 ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:297:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(std::initializer_list<typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type>) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type = std::pair<const int, int>]'
  297 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:297:46: note:   no known conversion for argument 1 from 'std::map<int, int>' to 'std::initializer_list<std::pair<const int, int> >'
  297 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:85:29: error: no match for 'operator=' (operand types are 'std::map<int, int>' and 'std::unordered_map<int, int>')
   85 |                 cur=proc[i/2];
      |                             ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_map.h:331:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  331 |       operator=(const map&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:331:17: note:   no known conversion for argument 1 from 'std::unordered_map<int, int>' to 'const std::map<int, int>&'
  331 |       operator=(const map&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:335:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::map<_Key, _Tp, _Compare, _Alloc>&&) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  335 |       operator=(map&&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:335:17: note:   no known conversion for argument 1 from 'std::unordered_map<int, int>' to 'std::map<int, int>&&'
  335 |       operator=(map&&) = default;
      |                 ^~~~~
/usr/include/c++/14/bits/stl_map.h:349:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::initializer_list<std::pair<const _Key, _Val> >) [with _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]'
  349 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:349:46: note:   no known conversion for argument 1 from 'std::unordered_map<int, int>' to 'std::initializer_list<std::pair<const int, int> >'
  349 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:112:62: error: 'class std::unordered_map<int, int>' has no member named 'upper_bound'
  112 |                                 out=max(out,u.se+(--proc[pr].upper_bound(l-u.fi))->se);
      |                                                              ^~~~~~~~~~~
a.cc:115:42: error: 'class std::unordered_map<int, int>' has no member named 'upper_bound'
  115 |                 }else cout << (--proc[v].upper_bound(l))->se << '\n';
      |                                          ^~~~~~~~~~~