Help me in solving DSAAGP1094 problem

My issue

While submitting the code ,its showing that contest problem are not accepting answers. I have completed the entire course, it’s 99% completed only this is the problem in which I’m facing problem. Please look into this issue.

My code

int search_insert_position(int arr[], int n, int k) {
    int left = 0, right = n - 1;

    // Binary search to find the correct position or the target itself
    while (left <= right) {
        int mid = left + (right - left) / 2;
        
        if (arr[mid] == k) {
            return mid; // Target found at index 'mid'
        }
        else if (arr[mid] < k) {
            left = mid + 1; // Search in the right half
        }
        else {
            right = mid - 1; // Search in the left half
        }
    }

    // If we exit the loop, it means the target was not found
    // The 'left' pointer will be at the correct insertion position
    return left;
}

Learning course: Data structures & Algorithms lab
Problem Link: https://www.codechef.com/learn/course/muj-dsa-c/MUJDSAC20A/problems/DSAAGP1094