This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> ti;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ld,ld> pld;
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front
#define ff first
#define ss second
#define MOD (ll)(1000000007)
#define INF (ll) (1e18)
#define all(v) (v).begin(),(v).end()
const int nx[8] = {0, 0, 1, -1,1,1,-1,-1}, ny[8] = {1, -1, 0, 0,1,-1,1,-1}; //East, West, South, North+
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;}
ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
////////////******SOLUTION******\\\\\\\\\\\
const int MAX_R = 1e5 + 4;
ll X[MAX_R] ;
ll b;
ll pref[MAX_R];
ll n;
bool test(ll x)
{
    for(ll i = 0; i<= n-x; i ++)
    {
        ll cent = i + x/2;
        ll pos = X[cent];
        ll tot = pos*(cent-i) - (pref[cent]-pref[i]);
        tot += pref[i+x]-pref[cent]-pos*(i+x-cent);
        if(tot <= b)
        {
            //cout << x << ' ' << i << ' ' << pos << ' ' << tot << '\n';
            return 1;
        }
    }
    return 0;
}
int besthub(int R, int L, int XX[], ll B)
{
    ll ans = 1;
    b = B;
    n = R;
    pref[0] = 0;
    for(int i = 0; i< R; i ++)
    {
        X[i] = XX[i];
        pref[i+1] = pref[i] + X[i];
    }
    int debut = 1;
    int fin = R;
    while(debut <= fin)
    {
        int mid = (debut+fin)/2;
        if(test(mid))
        {
            ans = mid;
            debut = mid + 1;
        }
        else
            fin = mid - 1;
    }
    //if(ans == 243)
        //cout << R << ' ' << L << ' ' << B << '\n';
    return ans;
}
// CHANGE YOUR APPROACH YEHDIK
Compilation message (stderr)
ricehub.cpp:24:1: warning: multi-line comment [-Wcomment]
   24 | ////////////******SOLUTION******\\\\\\\\\\\
      | ^| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |