#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M,Q; cin >> N >> M >> Q; int A[N],B[N]; for(int i=0; i> A[i] >> B[i]; int n2 = 1< inf) break; } } long long answer = 0; for(int i=0; i0; k=(k-1)&i){ if(S[k] > M) continue; int left = i-k; if(S[left] > Q) continue; answer = max(answer,S2[i]); break; } } cout << answer << endl; }