#include <iostream>
#include <vector>
using namespace std;
// Function to perform binary search on the sorted array
bool binarySearch(const vector<int>& arr, int target) {
int low = 0;
int high = arr.size() - 1;
while (low <= high) {
int mid = low + (high - low) / 2;
if (arr[mid] == target) {
return true;
}
if (arr[mid] < target) {
low = mid + 1;
} else {
high = mid - 1;
}
}
return false;
}
int main() {
int n, k;
cin >> n >> k;
// Input the first array (sorted)
vector<int> firstArray(n);
for (int i = 0; i < n; ++i) {
cin >> firstArray[i];
}
// Input the second array (numbers to search for)
vector<int> secondArray(k);
for (int i = 0; i < k; ++i) {
cin >> secondArray[i];
}
// For each element in the second array, perform binary search on the first array
for (int i = 0; i < k; ++i) {
if (binarySearch(firstArray, secondArray[i])) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLy8gRnVuY3Rpb24gdG8gcGVyZm9ybSBiaW5hcnkgc2VhcmNoIG9uIHRoZSBzb3J0ZWQgYXJyYXkKYm9vbCBiaW5hcnlTZWFyY2goY29uc3QgdmVjdG9yPGludD4mIGFyciwgaW50IHRhcmdldCkgewogICAgaW50IGxvdyA9IDA7CiAgICBpbnQgaGlnaCA9IGFyci5zaXplKCkgLSAxOwogICAgCiAgICB3aGlsZSAobG93IDw9IGhpZ2gpIHsKICAgICAgICBpbnQgbWlkID0gbG93ICsgKGhpZ2ggLSBsb3cpIC8gMjsKICAgICAgICAKICAgICAgICBpZiAoYXJyW21pZF0gPT0gdGFyZ2V0KSB7CiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoYXJyW21pZF0gPCB0YXJnZXQpIHsKICAgICAgICAgICAgbG93ID0gbWlkICsgMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBoaWdoID0gbWlkIC0gMTsKICAgICAgICB9CiAgICB9CiAgICAKICAgIHJldHVybiBmYWxzZTsKfQoKaW50IG1haW4oKSB7CiAgICBpbnQgbiwgazsKICAgIGNpbiA+PiBuID4+IGs7CiAgICAKICAgIC8vIElucHV0IHRoZSBmaXJzdCBhcnJheSAoc29ydGVkKQogICAgdmVjdG9yPGludD4gZmlyc3RBcnJheShuKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICAgICAgY2luID4+IGZpcnN0QXJyYXlbaV07CiAgICB9CiAgICAKICAgIC8vIElucHV0IHRoZSBzZWNvbmQgYXJyYXkgKG51bWJlcnMgdG8gc2VhcmNoIGZvcikKICAgIHZlY3RvcjxpbnQ+IHNlY29uZEFycmF5KGspOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBrOyArK2kpIHsKICAgICAgICBjaW4gPj4gc2Vjb25kQXJyYXlbaV07CiAgICB9CiAgICAKICAgIC8vIEZvciBlYWNoIGVsZW1lbnQgaW4gdGhlIHNlY29uZCBhcnJheSwgcGVyZm9ybSBiaW5hcnkgc2VhcmNoIG9uIHRoZSBmaXJzdCBhcnJheQogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBrOyArK2kpIHsKICAgICAgICBpZiAoYmluYXJ5U2VhcmNoKGZpcnN0QXJyYXksIHNlY29uZEFycmF5W2ldKSkgewogICAgICAgICAgICBjb3V0IDw8ICJZRVMiIDw8IGVuZGw7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY291dCA8PCAiTk8iIDw8IGVuZGw7CiAgICAgICAgfQogICAgfQoKICAgIHJldHVybiAwOwp9Cg==