bool binary_search(int q){ int p=0, k=n+1; while(p+1 < k){ int sr = (p+k)/2; if(a[sr] < q) p = sr; else k = sr; } return a[k] == q; }