// class Solution {
// public int maxValue(int n, int index, int maxSum) {
// int max = 0;
// int total = 0;
// int tmpMax = maxSum;
// while (tmpMax % n != 0) {
// tmpMax--;
// }
// max = tmpMax / n;
// int left = index - 0;
// int right = n - 1 - index;
// while (total<=maxSum) {
// int l = max>left?left:max-1;
// int r = max>right?right:max-1;
// total = max*(r+l+1)-(r*(r+1)+l*(l+1))/2+(right-r>0?right-r:0)+(left-l>0?left-l:0);
// max++;
// }
// return max-2;
// }
// }
const aa = (a,b,c) => {
let max = 0;
let total = 0;
let temmax = c;
while (temmax % a != 0) {
temmax--
}
max = temmax/a;
let left = b - 0;
let right = a - 1 - b ;
while (total<=c){
let l = max > left ? left : max -1;
let r = max>right?right:max-1;
total = max*(r+l+1)-(r*(r+1)+l*(l+1))/2+(right-r>0?right-r:0)+(left-l>0?left-l:0);
max++
}
return max-2
}
console.log(aa(836957079,415524470, 861031803))
const bb = (a,b,c) => {
let max = 0;
let total = 0;
let temmax = c;
// while (temmax % a != 0) {
// temmax--
// }
max = parseInt(temmax/a);
let left = b - 0;
let right = a - 1 - b ;
while (total<=c){
let l = max > left ? left : max -1;
let r = max>right?right:max-1;
total = max*(r+l+1)-(r*(r+1)+l*(l+1))/2+(right-r>0?right-r:0)+(left-l>0?left-l:0);
max++
}
return max-2
}