Language: C++

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define NumofDigits(n)   ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
ll arr[maxn],suf[maxn],x;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n>>x;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int cnt=0;
    for(int i=0;i<n-1;i++)
    {
        suf[i]=arr[i]+arr[i+1];
        while(suf[i]>x)
        {
           arr[i]=max(0*1ll,arr[i]-1);
           arr[i+1]=max(0*1ll,arr[i+1]-1);
           suf[i]=max(0*1ll,suf[i]-1);
           cnt++;
        }
    }
    cout<<cnt;
}


Compiler output:
a.cc:9:17: error: '__gnu_pbds' is not a namespace-name
    9 | using namespace __gnu_pbds;
      |                 ^~~~~~~~~~
a.cc:10:9: error: 'tree' does not name a type
   10 | typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
      |         ^~~~
a.cc: In function 'void File()':
a.cc:24:31: error: 'stdin' was not declared in this scope
   24 |     freopen("input.txt", "r", stdin);
      |                               ^~~~~
a.cc:1:1: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define loop(i,n) for(int i = 0;i < int(n);i++)
a.cc:24:5: error: 'freopen' was not declared in this scope
   24 |     freopen("input.txt", "r", stdin);
      |     ^~~~~~~
a.cc: At global scope:
a.cc:27:1: error: 'll' does not name a type; did you mean 'all'?
   27 | ll arr[maxn],suf[maxn],x;
      | ^~
      | all
a.cc: In function 'int main()':
a.cc:30:5: error: 'ios_base' has not been declared
   30 |     ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
      |     ^~~~~~~~
a.cc:30:34: error: 'cin' was not declared in this scope
   30 |     ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
      |                                  ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define loop(i,n) for(int i = 0;i < int(n);i++)
a.cc:30:45: error: 'cout' was not declared in this scope
   30 |     ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
      |                                             ^~~~
a.cc:30:45: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:13: error: 'x' was not declared in this scope
   32 |     cin>>n>>x;
      |             ^
a.cc:34:14: error: 'arr' was not declared in this scope
   34 |         cin>>arr[i];
      |              ^~~
a.cc:38:9: error: 'suf' was not declared in this scope
   38 |         suf[i]=arr[i]+arr[i+1];
      |         ^~~
a.cc:38:16: error: 'arr' was not declared in this scope
   38 |         suf[i]=arr[i]+arr[i+1];
      |                ^~~
a.cc:41:19: error: 'max' was not declared in this scope; did you mean 'maxn'?
   41 |            arr[i]=max(0*1ll,arr[i]-1);
      |                   ^~~
      |                   maxn