#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); long long 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),S2(n2); 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; }