HackerEarth Bus Journey problem solution

In this HackerEarth Bus Journey problem solution, It is a lovely day in Astana, Kazakhstan, and our friend Mahamba is headed to the international exhibition EXPO2017. The route to the main pavilion consists of N bus stops, and Mahamba will leave the bus at the Nth stop. Additionally, the bus has M seats and can support an infinite number of standing people. Mahamba is sitting on the bus already, and it is approaching the first bus stop. By pure luck, he knows that ai adults will enter and bi sitting adults will leave on the ith bus stop for every 1 <= i < N (if there are no sitting adults, no one will leave). He also knows that people leave and only then do new people come in. As Mahamba is a schoolboy, he must give his place to an adult person. If a sitting person leaves the bus, a standing adult will take his place. After there are no standing adults left on the bus and there is a vacant place, he can finally sit down. Mahamba now wants to know how many stops he will ride standing up, as it is a very tiring experience.

HackerEarth Bus Journey problem solution.

`#include <bits/stdc++.h>#define F first#define S second#define EPS 1e-9#define endl '\n'#define PI acos(-1)   #define LL long long#define PB push_back#define MP make_pair#define PPB pop_back#define PF push_front#define PPF pop_front#define MOD 1000000007#define PLL pair<LL, LL>#define PII pair<int, int>#define sz(a) (int)a.size()#define ULL unsigned long long#define all(v) v.begin(), v.end()using namespace std;  inline void boost() {  ios_base::sync_with_stdio(0);  cin.tie(0), cout.tie(0);}const int MXN = 1e5 + 5;LL m, sit, stnd, a[MXN], b[MXN];int n, ans; int main () {  boost();    cin >> n >> m;  for (int i = 1;i < n; i++) {    cin >> a[i] >> b[i];    sit -= b[i];    stnd += a[i];    while (sit < m && stnd > 0)      stnd--, sit++;    if (sit == m)      ans++;  }  cout << ans;  return 0;}`