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