#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> v(n);
for(int i=0; i<n; i++){
cin >> v[i];
}
sort(v.begin(),v.end);
int m;
cin >> m;
while(m--){
string cmd;
cin >> cmd;
if(cmd == "COUNT"){
int x;
cin >> x;
int cnt = count(v.begin(),v.end(),x);
cout << cnt;
}
else if(cmd == "FIND"){
int x;
cin >> x;
int c = binary_search(v.begin(),v.end(),x);
cout << c;
}
else if(cmd == "LOWER"){
int x;
cin >> x;
int cc = lower_bound(v.begin(),v.end(),x) - v.begin();
cout << cc;
}
else if(cmd == "MAX"){
cout << v.back();
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: