Could You Please Review The Code

#include <bits/stdc++.h>
using namespace std;
int binary_mode(int *arr,int n,long long int low,long long int high,long long int prev_mid,long long int students,long long int ans)
{
long long int count=1;
if(low>high)
{
return prev_mid;
}

long long int mid=(low+high)/2;

//cout<<“mid val”<<mid<<endl;
long long int sum=0;
for(int i=0;i<n;i++)
{
if((sum+arr[i])>mid)
{
sum=0;
count++;
}
sum+=arr[i];
}

if(count>students)
{
    //cout<<"yes"<<endl;
    return binary_mode(arr,n,mid+1,high,prev_mid,students,ans);
}

if(prev_mid>mid)
{
//cout<<“inside”;
prev_mid=max(mid,ans);
}
return binary_mode(arr,n,low,mid-1,prev_mid,students,ans);
}
int main()
{
int test;
cin>>test;
while(test–) //cout<<“yes”<<endl;

{
    int n;
    int s;
    cin>>n>>s;
    int *arr=new int[n];
    //stable_sort(arr,arr+n);
    long long int low=0;
    long long int high=0;
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    stable_sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        //cin>>arr[i];
        if(i==0)
        {
            low=arr[i];
        }
        high+=arr[i];
        //cout<<arr[i]<<" ";
    }
    //cout<<low<<" "<<high<<endl;
    long long int prev_mid=INT_MAX;
int val=binary_mode(arr,n,low,high,prev_mid,s,arr[n-1]);
cout<<val<<endl;
}

}

Pls add some comments to your code so that I could understand it well.