===== ISTEM =====
Solve the following programming task.

TASK: Binary Search in a Sorted List

Write a function 'binary_search(arr, target)' that searches for target in a sorted integer list arr in O(log n) time. It must return the index if found, and -1 otherwise.

STARTER CODE (python):
def binary_search(arr: list[int], target: int) -> int:
    # Write your code here
    pass


RULES:
- Keep the function name and signature EXACTLY as given.
- Return working code only. No explanations.
- Put the code in a single ``` block.
- Try to solve it first. If you genuinely cannot, write only this single
  line instead of producing faulty code: CANNOT_SOLVE

===== HAM YANIT =====
```python
def binary_search(arr: list[int], target: int) -> int:
    lo, hi = 0, len(arr) - 1
    while lo <= hi:
        mid = (lo + hi) // 2
        if arr[mid] == target:
            return mid
        elif arr[mid] < target:
            lo = mid + 1
        else:
            hi = mid - 1
    return -1
```