Added binary search using lower_bound, and replaced mergesort functionaliy with sort as it performs consistently better