Language: C++

#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
using namespace std;
const int size=2e6+10;
const int INF=1e9;
typedef long long LL;
//LL tree[size];
LL a[size];
LL b[size];
//int lowbit(int x)
//{
//    return x&(-x);
//}
//void update(int x)
//{
//    while(x<size)
//    {
//        tree[x]+=1;
//        x+=lowbit(x);
//    }
//}
//LL ask(int x)
//{
//    LL sum=0;
//    while(x)
//    {
//       sum+=tree[x];
//       x-=lowbit(x);
//    }
//    return sum;
//}
struct node
{
    int l,r;
    LL sum;
}tree[size];
//void build(int l,int r,int rt)
//{
//    int mid=(l+r)>>1;
//    tree[rt].l=l,tree[rt].r=r,tree[rt].sum=0;
//    if(l==r) return ;
//    build(l,mid,rt*2);
//    build(mid+1,r,rt*2+1);
//}
void pushdown(int rt)
{
    tree[rt].sum=tree[rt*2].sum+tree[rt*2+1].sum;
}
void update(int pos,int l,int r,int rt)
{
    if(l==r)
    {
        tree[rt].sum++; return ;
    }
    int mid=(l+r)>>1;
    if(pos<=mid) update(pos,l,mid,rt*2);
    else update(pos,mid+1,r,rt*2+1);
    pushdown(rt);
}
LL ask(int l,int r,int rt)
{
    if(l>r) return 0;
    if(l>=tree[rt].l&&r>=tree[rt].r)
        return tree[rt].sum;
   LL sum=0;
   int mid=(l+r)>>1;
   if(l<=mid) sum+=ask(l,mid,rt*2);
   if(r>mid) sum+=ask(mid+1,r,rt*2+1);
   return sum;
}
int main()
{
   int n;LL p;
   while(scanf("%d%lld",&n,&p)!=EOF)
   {
       memset(tree,0,sizeof(tree));
     build(1,n+1,1);
     LL ans=0;
     for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
     for(int i=1;i<=n;i++)
     {
         b[i]-=p;
         b[i]=b[i]+b[i-1];
         if(b[i]>=0) ans++;
         a[i-1]=b[i];
     }
     sort(a,a+n);
     int cnt=unique(a,a+n)-a;
     build(1,n,1);
     for(int i=1;i<=n;i++)
     {
          int temp=lower_bound(a,a+cnt,b[i])-a+1;
          LL pri=ask(1,temp+1,1);
          ans+=pri;
//          printf("pri=%d\n",pri);
          update(temp,1,n,1);
     }
//     out(1,n,1);
     printf("%lld\n",ans);
   }
}


Compiler output:
a.cc:16:6: error: reference to 'size' is ambiguous
   16 | LL a[size];
      |      ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:12:11: note:                 'const int size'
   12 | const int size=2e6+10;
      |           ^~~~
a.cc:17:6: error: reference to 'size' is ambiguous
   17 | LL b[size];
      |      ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:12:11: note:                 'const int size'
   12 | const int size=2e6+10;
      |           ^~~~
a.cc:44:7: error: reference to 'size' is ambiguous
   44 | }tree[size];
      |       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:12:11: note:                 'const int size'
   12 | const int size=2e6+10;
      |           ^~~~
a.cc: In function 'void pushdown(int)':
a.cc:55:5: error: 'tree' was not declared in this scope; did you mean 'free'?
   55 |     tree[rt].sum=tree[rt*2].sum+tree[rt*2+1].sum;
      |     ^~~~
      |     free
a.cc: In function 'void update(int, int, int, int)':
a.cc:61:9: error: 'tree' was not declared in this scope; did you mean 'free'?
   61 |         tree[rt].sum++; return ;
      |         ^~~~
      |         free
a.cc: In function 'LL ask(int, int, int)':
a.cc:71:11: error: 'tree' was not declared in this scope; did you mean 'free'?
   71 |     if(l>=tree[rt].l&&r>=tree[rt].r)
      |           ^~~~
      |           free
a.cc: In function 'int main()':
a.cc:84:15: error: 'tree' was not declared in this scope; did you mean 'free'?
   84 |        memset(tree,0,sizeof(tree));
      |               ^~~~
      |               free
a.cc:85:6: error: 'build' was not declared in this scope
   85 |      build(1,n+1,1);
      |      ^~~~~
a.cc:87:42: error: 'b' was not declared in this scope
   87 |      for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
      |                                          ^
a.cc:90:10: error: 'b' was not declared in this scope
   90 |          b[i]-=p;
      |          ^
a.cc:93:10: error: 'a' was not declared in this scope
   93 |          a[i-1]=b[i];
      |          ^
a.cc:95:11: error: 'a' was not declared in this scope
   95 |      sort(a,a+n);
      |           ^
a.cc:100:40: error: 'b' was not declared in this scope
  100 |           int temp=lower_bound(a,a+cnt,b[i])-a+1;
      |                                        ^