#include<bits/stdc++.h>
using namespace std;
int main() {
int a[1000];
int l,t,s;
cin>>l;
if(l==0)
return 0;
for(int i=0;i<l;i++)
{
cin>>a[i];
}
int index=0;
cin>>t;
sort(a,a+l);
for(int i=0;i<l;i++)
{ s=t-a[i];
if(binary_search(a+i,a+l,s))
{
auto it=lower_bound(a+i,a+l,s);
index=it-a;
cout<<a[i]<<" and "<<a[index]<<endl;
}
}
return 0;
I am failing first test case only. whats wrong with the code? am i missing an edge case?