#include <stdio.h>
#include <stdlib.h>
int BinarySearch(int* arr, int size, int toFind) {
int left = 0;
int right = size - 1;
while (left <= right) {
int mid = (left + right) / 2;
if (arr[mid] > toFind) {
right = arr[mid] - 1;
}
else if (arr[mid] < toFind) {
left = arr[mid] + 1;
}
else {
return mid;
}
}
return -1;
}