Language: C++

#include <bits/stdc++.h>
using namespace std;
const int size=1e5+10;
const int INF=1e9;
int tree[size];
int a[size];
typedef long long LL;
int lowbit(int x)
{
    return x&(-x);
}
void update(int x)
{
    while(x<size)
    {
        tree[x]+=1;
        x+=lowbit(x);
    }
}
int ask(int x)
{
    int sum=0;
    while(x)
    {
       sum+=tree[x];
       x-=lowbit(x);
    }
    return sum;
}
LL b[size];
int main()
{
   int T;
   scanf("%d",&T);
   while(T--)
   {
       memset(tree,0,sizeof(tree));
     LL p,ans=0;int n; scanf("%d",&n);
     for(int i=1;i<=n;i++)
     {
         scanf("%lld",&b[i]);
     }
     scanf("%lld",&p);
     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;
     int temp=lower_bound(a,a+cnt,b[1])-a+n;;
     update(temp);
     for(int i=2;i<=n;i++)
     {
          temp=lower_bound(a,a+cnt,b[i])-a+n;
          ans+=ask(temp);
          update(temp);
     }
     printf("%lld\n",ans);
//     printf("%d\n",)
//    for(int i=0;i<cnt;i++)
//        printf("%d ",a[i]);
//      printf("%d\n",ans);

   }
}




Compiler output:
a.cc:5:10: error: reference to 'size' is ambiguous
    5 | int tree[size];
      |          ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/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:3:11: note:                 'const int size'
    3 | const int size=1e5+10;
      |           ^~~~
a.cc:6:7: error: reference to 'size' is ambiguous
    6 | int a[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:3:11: note:                 'const int size'
    3 | const int size=1e5+10;
      |           ^~~~
a.cc: In function 'void update(int)':
a.cc:14:13: error: reference to 'size' is ambiguous
   14 |     while(x<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:3:11: note:                 'const int size'
    3 | const int size=1e5+10;
      |           ^~~~
a.cc:16:9: error: 'tree' was not declared in this scope; did you mean 'free'?
   16 |         tree[x]+=1;
      |         ^~~~
      |         free
a.cc: In function 'int ask(int)':
a.cc:25:13: error: 'tree' was not declared in this scope; did you mean 'free'?
   25 |        sum+=tree[x];
      |             ^~~~
      |             free
a.cc: At global scope:
a.cc:30:6: error: reference to 'size' is ambiguous
   30 | 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:3:11: note:                 'const int size'
    3 | const int size=1e5+10;
      |           ^~~~
a.cc: In function 'int main()':
a.cc:37:15: error: 'tree' was not declared in this scope; did you mean 'free'?
   37 |        memset(tree,0,sizeof(tree));
      |               ^~~~
      |               free
a.cc:41:24: error: 'b' was not declared in this scope
   41 |          scanf("%lld",&b[i]);
      |                        ^
a.cc:46:11: error: 'b' was not declared in this scope
   46 |           b[i]-=p;
      |           ^
a.cc:49:10: error: 'a' was not declared in this scope
   49 |          a[i-1]=b[i];
      |          ^
a.cc:52:11: error: 'a' was not declared in this scope
   52 |      sort(a,a+n);
      |           ^
a.cc:54:35: error: 'b' was not declared in this scope
   54 |      int temp=lower_bound(a,a+cnt,b[1])-a+n;;
      |                                   ^