criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;


int main(int argc, char** argv) {
    long long N, K;

    cin >> N >> K;

    vector<long long> a(N), a_sum(N+1);

	for (int i = 0; i < N; i++) 
		cin >> a[i];
	
	a_sum[0] = 0;

	for (int i = 1; i <= N; i++)
		a_sum[i] = a_sum[i - 1] + a[i - 1] - K;

	int ans = 0;
	int n_sqrt = int(sqrt(N)) + 1;

	vector<long long> a_sum_sorted;

	int n_sorted = int(N / n_sqrt) * n_sqrt;
	a_sum_sorted = vector<long long>(a_sum.begin(), a_sum.begin() + n_sorted);
	sort(a_sum_sorted.begin(), a_sum_sorted.end());

	for (int j = N; j >= 1; j--) {
		if (j % n_sqrt == 0) {
			n_sorted -= n_sqrt;
			a_sum_sorted = vector<long long>(a_sum.begin(), a_sum.begin() + n_sorted);
			sort(a_sum_sorted.begin(), a_sum_sorted.end());
		}
		// ソート済の部分は2分探索で
		ans += upper_bound(a_sum_sorted.begin(), a_sum_sorted.end(), a_sum[j]) - a_sum_sorted.begin();

		// ソートしていない部分はナイーブに
		for (int i = j - 1; i >= n_sorted; i--) {
			ans += a_sum[j] >= a_sum[i];
		}
	}

	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:24:26: error: 'sqrt' was not declared in this scope; did you mean 'n_sqrt'?
   24 |         int n_sqrt = int(sqrt(N)) + 1;
      |                          ^~~~
      |                          n_sqrt
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, int> lli;
typedef vector<lli> vlli;

int bit[100010], N;

//0--iまでの和
int sum(int i){
  ans=0;
  while(i>0){
    ans+=bits[i];
    i-=i&-i;
  }
  return ans;
}

int add(int i, int x){
  while(i<=n){
    bits[i]+=x;
    i+=i&-i;
  }
}

int main(){
  int N, K;cin>>N>>K;
  vll a;
  for (int i=0;i<N;++i){
    int a_;cin>>a_;a.push_back(a_-K);
  }
  vll cumsum(N+1);
  cumsum[0]=0;
  for (int i=0;i<N;++i){
    cumsum[i+1]=cumsum[i]+a[i];
  }

  vlli c(N);
  for (int i=0;i<N;++i){
    c[i]=make_pair(cumsum[i+1], i);
  }

  sort(c.begin(), c.end());

  vll d(N);
  for (int i=0;i<N;++i){
    d[c[i].second]=i;
  }

  ll ans=0;
  for(int j=0;j<N;++j){
    ans+=sum(d[j]);
    add(d[j], 1);
  }

  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int sum(int)':
a.cc:14:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |   ans=0;
      |   ^~~
      |   abs
a.cc:16:10: error: 'bits' was not declared in this scope; did you mean 'bit'?
   16 |     ans+=bits[i];
      |          ^~~~
      |          bit
a.cc: In function 'int add(int, int)':
a.cc:23:12: error: 'n' was not declared in this scope
   23 |   while(i<=n){
      |            ^
a.cc:24:5: error: 'bits' was not declared in this scope; did you mean 'bit'?
   24 |     bits[i]+=x;
      |     ^~~~
      |     bit
a.cc:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
   27 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <set>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int bit[11234567], bit_n;

int bit_sum(int i)
{
    int s = 0;
    while (i > 0)
    {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void bit_add(int i, int x)
{
    while (i <= bit_n)
    {
        bit[i] += x;
        i += i & -i;
    }
}

int main()
{
    int n;
    ll k, a[212345];

    cin >> n >> k;
    REP(i, n)
    {
        cin >> a[i];
        a[i] -= k;
    }

    set<ll> num;

    ll sum[212345];
    sum[0] = 0;
    num.insert(0);
    REP(i, n)
    {
        sum[i + 1] = sum[i] + a[i];
        num.insert(sum[i + 1]);
    }

    vector<ll> nv;

    for (ll i : num)
        nv.push_back(i);

    SORT(nv);

    map<ll, int> mp;

    REP(i, nv.size())
    mp[nv[i]] = i;

    for (int i = 0; i <= n; i++)
        sum[i] = mp[sum[i]];

    memset(bit, 0, sizeof(bit));
    bit_n = nv.size();

    ll res = 0;

    for (int i = 0; i <= n; i++)
    {
        res += bit_sum(sum[i] + 1);
        bit_add(sum[i] + 1, 1);
    }

    cout << res << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:82:5: error: 'memset' was not declared in this scope
   82 |     memset(bit, 0, sizeof(bit));
      |     ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    9 | #include <set>
  +++ |+#include <cstring>
   10 |
Language: C++

#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<iomanip>
#define sqr(x) (x)*(x)
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define long long long long
using namespace std;
int n,i,j,rt,cnt,l[200005],r[200005],sz[200005],rnd[200005];
long long ans,m,a[200005],val[200005];
int nwnd(int x)
{
	cnt++;
	l[cnt]=r[cnt]=0;
	sz[cnt]=1;val[cnt]=x;rnd[cnt]=rand()*32768+rand();
	return cnt;
}
void pushup(long long x)
{
	sz[x]=1+sz[l[x]]+sz[r[x]];
}
void split(long long x,long long y,long long &sl,long long &sr)
{
	if (!x)
	{
		sl=sr=0;
		return;
	}
	if (val[x]<=y)
	{
		split(r[x],y,r[x],sr);
		sl=x;
		pushup(x);
		return;
	}
	else
	{
		split(l[x],y,sl,l[x]);
		sr=x;
		pushup(x);
		return;
	}
}
long long merge(long long x,long long y)
{
	if (!x||!y) return x+y;
	if (rnd[x]>rnd[y])
	{
		r[x]=merge(r[x],y);
		pushup(x);
		return x;
	}
	else
	{
		l[y]=merge(x,l[y]);
		pushup(y);
		return y;
	}
}
int main()
{
	cin>>n>>m;
	fz1(i,n)
	{
		cin>>a[i];
		a[i]-=m;
		a[i]+=a[i-1];
	}
	rt=nwnd(0);
	fz1(i,n)
	{
		long long t1,t2;
		split(rt,a[i],t1,t2);
		ans+=sz[t1];
		rt=merge(merge(t1,nwnd(a[i])),t2);
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void split(long long int, long long int, long long int&, long long int&)':
a.cc:46:33: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'int'
   46 |                 split(r[x],y,r[x],sr);
      |                              ~~~^
a.cc:37:47: note:   initializing argument 3 of 'void split(long long int, long long int, long long int&, long long int&)'
   37 | void split(long long x,long long y,long long &sl,long long &sr)
      |                                    ~~~~~~~~~~~^~
a.cc:53:36: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'int'
   53 |                 split(l[x],y,sl,l[x]);
      |                                 ~~~^
a.cc:37:61: note:   initializing argument 4 of 'void split(long long int, long long int, long long int&, long long int&)'
   37 | void split(long long x,long long y,long long &sl,long long &sr)
      |                                                  ~~~~~~~~~~~^~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010
using namespace std;
int n,k,
long long ans=0,aux[N],sum[N];
long long tree[N<<2];
int lowbit(int x)
{
	return x&-x;
}
long long getsum(int x)
{
	long long ans=0;
	for(int i=x;i;i-=lowbit(i))
	ans+=tree[i];
	return ans;
}
void add(int x,int k)
{
	for(int i=x;i<=n;i+=lowbit(i))
	tree[i]+=k;
}

int main()
{
	memset(sum,0,sizeof(sum));
	memset(aux,0,sizeof(aux));
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		sum[i]=sum[i-1]+x-k;
		aux[i]=sum[i];
	}
	sort(aux+1,aux+1+n);
	int m=unique(aux+1,aux+1+n)-aux;
	for(int i=0;i<=n;i++)
	sum[i]=lower_bound(aux+1,aux+1+m,sum[i])-aux+1;
	for(int i=0;i<=n;i++)
	{
		ans+=getsum(sum[i]);
		add(sum[i],1);
	}
	printf("%lld\n",ans);
	
}

Compiler output:
a.cc:8:1: error: expected unqualified-id before 'long'
    8 | long long ans=0,aux[N],sum[N];
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:16: error: 'sum' was not declared in this scope
   29 |         memset(sum,0,sizeof(sum));
      |                ^~~
a.cc:30:16: error: 'aux' was not declared in this scope
   30 |         memset(aux,0,sizeof(aux));
      |                ^~~
a.cc:45:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |                 ans+=getsum(sum[i]);
      |                 ^~~
      |                 abs
a.cc:48:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   48 |         printf("%lld\n",ans);
      |                         ^~~
      |                         abs
Language: C++

#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

random_device rnd;
mt19937 mt(rnd());

class Myset {
  Myset *lch, *rch;
  LL value;
  LL size;
  Myset* update() {
    this->size = sz(this->lch) + 1 + sz(this->rch);
    return this;
  }
  Myset* _push(Myset *ch) {
    if (ch->value == this->value) {
      ++this->size;
      this->push(ch->lch);
      this->push(ch->rch);
    } else if(ch->value < this->value) {
      !this->lch ?
        this->lch = ch :
        this->lch = this->lch->push(ch);
    } else {
      !this->rch ?
        this->rch = ch :
        this->rch = this->rch->push(ch);
    }
    return this->update();
  }
public:
  static int sz(Myset *s) { return !s ? 0 : s->size; }
  Myset() : lch(NULL), rch(NULL), value(0), size(1), pri(mt()) {}
  Myset(LL v) : lch(NULL), rch(NULL), value(v), size(1), pri(mt()) {}
  Myset* push(Myset *s) {
    if(!this || !s) return !this ? s : this;
    uniform_int_distribution<> r(1, this->size + s->size);
    if(r(mt) <= this->size) { return this->_push(s); }
    else { return s->_push(this); }
  }
  LL count_le(LL x) {
    if(!this) return 0;
    if(this->value <= x) {
      return sz(this->lch) + 1
        + this->rch->count_le(x);
    } else {
      return this->lch->count_le(x);
    }
  }
  void dump(int d = 0) {
    if(lch) lch->dump(d+1);
    cout << d << " " << this->size << " " << this->value << endl;
    if(rch) rch->dump(d+1);
  }
};

Myset pool[262144];

int main(void)
{
  int n;
  LL k;
  cin >> n >> k;
  vector<LL> a(n);
  REP(i, n) { cin >> a[i]; a[i] -= k; }
  LL sum = 0ll;
  LL answer = 0ll;
  pool[n] = Myset(0);
  Myset* root = &pool[n];
  REP(i, n) {
    sum += a[i];
    answer += root->count_le(sum);
    pool[i] = Myset(sum);
    root = root->push(&pool[i]);
  }
  cout << answer << endl;
  return 0;
}


Compiler output:
a.cc: In constructor 'Myset::Myset()':
a.cc:37:54: error: class 'Myset' does not have any field named 'pri'
   37 |   Myset() : lch(NULL), rch(NULL), value(0), size(1), pri(mt()) {}
      |                                                      ^~~
a.cc: In constructor 'Myset::Myset(LL)':
a.cc:38:58: error: class 'Myset' does not have any field named 'pri'
   38 |   Myset(LL v) : lch(NULL), rch(NULL), value(v), size(1), pri(mt()) {}
      |                                                          ^~~
Language: C++

#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 2e5 + 5;

int n, k, a[N], used[N], cnt = 0;
long long f[N], bit[N];
vector <pair <long long, int> > comp;

void update (int x, int val) {
    for (int i = x; i < N; i += i & -i) bit[i] += val;
}

long long get (int x) {
    long long ans = 0;
    for (int i = x; i > 0; i -= i & -i) ans += bit[i];
    return ans;
}

int main(){
    scanf("%lld %lld", &n, &k);
    long long ans = 0;

    f[0] = 0;
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] + a[i];
    for (int i = 1; i <= n; i++) comp.push_back(make_pair(f[i] - k * i, i));
    comp.push_back(make_pair(0, 0));

    sort(comp.begin(), comp.end());
    used[comp[0].second] = ++cnt;
    for (int i = 1; i < comp.size(); i++) {
        if (comp[i].first > comp[i - 1].first) used[comp[i].second] = ++cnt;
        else used[comp[i].second] = cnt;
    }

    for (int i = 1; i <= n; i++) {
        update(used[i - 1], 1);
        ans += get(used[i]);
    }

    printf("%lld", ans);
    return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll
ll cnt=0;
void fun(ll length,ll k)
{
    ll sum=0;
    ll num=0;
    ll flag=-1,flag1=1;
    ll n=pow((float)2,length);
    for(int i=0; i<n; i++)
    {
        sum=0;
        num=0;
        flag=-1;
        flag1=1;
        ll temp=i;
        for(int j=0; j<length; j++)
        {
            if(temp&1)
            {
                if(flag==-1)
                {
                    flag=j;
                    sum+=a[j];
                    num++;
                }
                else if(j==flag+1)
                {
                    flag++;
                    sum+=a[j];
                    num++;
                }
                else
                {
                    flag1=0;
                    break;
                }
            }
            temp=temp>>1;
        }

        if(flag1&&num&&sum/num>=k)
        {
            cnt++;
        }
    }
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll i,j,k,m,n;
    cin>>n>>k;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    fun(n,k);
    cout<<cnt<<endl;
    return 0;
}


Compiler output:
a.cc:3:12: error: 'long long long' is too long for GCC
    3 | #define ll long long
      |            ^~~~
a.cc:6:1: note: in expansion of macro 'll'
    6 | ll cnt=0;
      | ^~
a.cc:3:17: error: 'long long long' is too long for GCC
    3 | #define ll long long
      |                 ^~~~
a.cc:6:1: note: in expansion of macro 'll'
    6 | ll cnt=0;
      | ^~
a.cc: In function 'void fun(long long int, long long int)':
a.cc:27:26: error: 'a' was not declared in this scope
   27 |                     sum+=a[j];
      |                          ^
a.cc:33:26: error: 'a' was not declared in this scope
   33 |                     sum+=a[j];
      |                          ^
a.cc: In function 'int main()':
a.cc:59:14: error: 'a' was not declared in this scope
   59 |         cin>>a[i];
      |              ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=200005;
ll num[maxn],a[maxn],ans;
int n,rank[maxn],f[maxn],k,ky;
inline int read(){
	int x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar());
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x;
}
inline void update(int x,int y){ for(;x<=ky;x+=x&-x) f[x]+=y;}
inline int query(int x){ int an=0; for(;x;x-=x&-x) an+=f[x]; return an;}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) a[i]=read()-k;
	for(int i=1;i<=n;i++){
	    a[i]+=a[i-1],num[i]=a[i];
	    if(a[i]>=0) ans++;
	}
	sort(num+1,num+n+1);
	ky=unique(num+1,num+n+1)-num-1;
	for(int i=1;i<=n;i++) rank[i]=lower_bound(num+1,num+ky+1,a[i])-num;
	for(int i=1;i<=n;i++) ans+=(ll)query(rank[i]),update(rank[i],1);
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:31: error: reference to 'rank' is ambiguous
   24 |         for(int i=1;i<=n;i++) rank[i]=lower_bound(num+1,num+ky+1,a[i])-num;
      |                               ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:6:7: note:                 'int rank [200005]'
    6 | int n,rank[maxn],f[maxn],k,ky;
      |       ^~~~
a.cc:25:46: error: reference to 'rank' is ambiguous
   25 |         for(int i=1;i<=n;i++) ans+=(ll)query(rank[i]),update(rank[i],1);
      |                                              ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:6:7: note:                 'int rank [200005]'
    6 | int n,rank[maxn],f[maxn],k,ky;
      |       ^~~~
a.cc:25:62: error: reference to 'rank' is ambiguous
   25 |         for(int i=1;i<=n;i++) ans+=(ll)query(rank[i]),update(rank[i],1);
      |                                                              ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:6:7: note:                 'int rank [200005]'
    6 | int n,rank[maxn],f[maxn],k,ky;
      |       ^~~~
Language: C++

#include<iostream>
#define MAX 200002
#define MAX_A 1000000002
using namespace std;

int a[MAX];
int l[MAX / 2 + 2], r[MAX / 2 + 2];

long long Merge(int a[], int n, int left, int mid, int right) {
	int i, j;
	long long cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++) {
		l[i] = a[left + i];
	}
	for (i = 0; i < n2; i++) {
		r[i] = a[mid + i];
	}
	l[n1] = MAX_A; r[n2] = MAX_A;
	i = 0; j = 0;
	for (int k = left; k < right; k++) {
		if (l[i] < r[j]) {
			a[k] = l[i];
			i++;
		}
		else {
			a[k] = r[j];
			j++;
			cnt += n1 - i;
		}
	}
	return cnt;
}
long long MergeSort(int A[], int n, int left, int right) {
	int mid;
	long long v1, v2, v3;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		v1 = MergeSort(A, n, left, mid);
		v2 = MergeSort(A, n, mid, right);
		v3 = Merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else { return 0; }
}

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[i] = x - k;
	}
	for (int i = 1; i < n; i++) {
		a[i] = a[i - 1] + a[i];
	}
	reverse(a, a + n);
	a[n] = 0;
	for (int i = 0; i < n; i++) {
	}
	cout << MergeSort(a, n+1, 0, n+1) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:9: error: 'reverse' was not declared in this scope
   59 |         reverse(a, a + n);
      |         ^~~~~~~
Language: C++

#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
typedef long long LL;
LL c[maxn], a[maxn], b[maxn];
int n, k;
int lowbit(int x) { return x & (-x); }
LL query(int x) { LL ret=0; while (x) ret += c[x], x -= lowbit(x); return ret; }
void add(int x) { while (x <= tot) ++c[x], x += lowbit(x); }
int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]), a[i] -= k;
    for (int i = 1; i <= n; ++i) b[i] = (a[i] += a[i-1]);
    b[n+1] = 0;
    sort(b+1, b+2+n);
    int tot = unique(b+1, b+2+n) - (b+1);

    LL ans=0;
    a[0] = 0;
    for (int i = 0; i <= n; ++i) {
        int p = lower_bound(b+1, b+1+tot, a[i]) - b;
        ans += query(p);
        add(p);
    }
    printf("%lld\n", ans);
    return 0;
}


Compiler output:
a.cc: In function 'void add(int)':
a.cc:9:31: error: 'tot' was not declared in this scope
    9 | void add(int x) { while (x <= tot) ++c[x], x += lowbit(x); }
      |                               ^~~
Language: C++

#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int long long

using namespace std;

const int N = 2e5 + 5;

int n, k;
long long ar[N], b[N];

long long ans;

void Merge_sort(int l, int r)
{
    if (l == r)
        return;

    int md = (l + r) >> 1;

    int i = l, j = md + 1;

    Merge_sort(l, md);
    Merge_sort(md + 1, r);

    for (int e = l; e <= r; e++)
    {
        if ( i <= md && ( j > r || ar[i] <= ar[j] ) )
        {
            ans += ;
            b[e] = ar[i++];
        }
        else
            b[e] = ar[j++];
    }
    for (int e = l; e <= r; e++)
        ar[e] = b[e];
}

main ()
{
    cin >> n >> k;

    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &ar[i]), ar[i] -= k;
        ar[i] += ar[i - 1];
    }
    Merge_sort(0, n);

    cout << ans;
}


Compiler output:
a.cc: In function 'void Merge_sort(long long int, long long int)':
a.cc:49:20: error: expected primary-expression before ';' token
   49 |             ans += ;
      |                    ^
a.cc: At global scope:
a.cc:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   59 | main ()
      | ^~~~
Language: C++

80 75 73 93 73 73 10101 97 -1 -1 114 -1 10113 118

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 80 75 73 93 73 73 10101 97 -1 -1 114 -1 10113 118
      | ^~
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int const N = 200 * 1000 + 16;
 
int a[N];
int n, k;
 
struct node {
  static mt19937 rd(time(0));
  ll x;
  int s = 1;
  int y = rd();
 
  node* l = 0;
  node* r = 0;
 
  node(ll v) {
    x = v;
  }
 
  ~node() {
    delete l;
    delete r;
  }
 
  node* upd() {
    s = 1;
    s += l ? l->s : 0;
    s += r ? r->s : 0;
    return this;
  }
};
 
struct treap {
  node* root = 0;
 
  ~treap() {
    delete root;
  }
 
  node* join(node* l, node* r) {
    if(not l) return r;
    if(not r) return l;
 
    if(l->y < r->y) {
      l->r = join(l->r, r);
      return l->upd();
    } else {
      r->l = join(l, r->l);
      return r->upd();
    }
  }
 
  pair<node*,node*> split(node* p, ll x) {
    if(not p) return make_pair(nullptr,nullptr);
 
    if(x < p->x) {
      auto t = split(p->l, x);
      p->l = t.second;
      t.second = p->upd();
      return t;
    } else {
      auto t = split(p->r, x);
      p->r = t.first;
      t.first = p->upd();
      return t;
    }
  }
 
  void insert(ll x) {
    auto t = split(root, x);
    root = join(t.first, join(new node(x), t.second));
  }
 
  int query(ll x) {
    auto t = split(root, x);
    int cnt = t.first ? t.first->s : 0;
    root = join(t.first, t.second);
    return cnt;
  }
};
 
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
 
  cin >> n >> k;
  copy_n(istream_iterator<int>(cin), n, a);
 
  treap t;
  t.insert(0);
  ll ans = 0;
  ll sum = 0;
  for(int i = 0; i < n; ++i) {
    sum += a[i];
    ll v = sum - 1ll * i * k - k;
    ans += t.query(v);
    t.insert(sum - 1ll * (i+1) * k);
  }
 
  cout << ans << endl;
}

Compiler output:
a.cc:12:21: error: 'time' is not a type
   12 |   static mt19937 rd(time(0));
      |                     ^~~~
a.cc:12:26: error: expected ')' before numeric constant
   12 |   static mt19937 rd(time(0));
      |                         ~^
      |                          )
a.cc:12:26: error: expected ')' before numeric constant
   12 |   static mt19937 rd(time(0));
      |                    ~     ^
      |                          )
a.cc:12:25: error: expected ';' at end of member declaration
   12 |   static mt19937 rd(time(0));
      |                         ^
      |                          ;
a.cc:12:26: error: expected unqualified-id before numeric constant
   12 |   static mt19937 rd(time(0));
      |                          ^
a.cc:15:13: error: cannot convert 'std::mt19937' {aka 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>'} to 'int' in initialization
   15 |   int y = rd();
      |           ~~^~
      |             |
      |             std::mt19937 {aka std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>}
Language: C

#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;
const int MAX_N = 200000 +10;

int f[MAX_N][20];
int query(int i,int j)
{
    int k = log2(j-i+1);
    return max(f[i][k],f[j-(1 << k)+1][k]);
}
int main()
{
    int n,m,x;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) scanf("%d",&f[i][0]);
    for (int j = 1; j < 19; ++j)
        for(int i = 1; i <= n; ++i)
            if(i + (1 << j) - 1 <= n)
                f[i][j] = max(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]);
    int L,R,mid,ans = 0;
    for (int i=1;i<=n;i++){
        L = i; R = n;
        while (L<=R){
            mid = (L + R) >> 1;
            if (query(i,mid)>=m) R = mid-1;
            else L = mid+1;
        }
        //printf("%d %d\n",i,L);
        ans += n-L+1;
    }
    printf("%d\n",ans);
}


Compiler output:
main.c:1:9: fatal error: cstdio: No such file or directory
    1 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
map<ll,int> t;
int cnt;
const int N=2e5+5;
int n;ll k,a[N]={0},as[N];
int bit[N]={0};
void add(int x,int val) {
    while(x<cnt) bit[x]+=val,x+=x&-x;
}
int sum(int x) {
    int s=0;while(x) s+=bit[x],x-=x&-x;return s;
}
int main() {
    scanf("%d%lld",&n,&k);
    t.clear();
    for(int i=1;i<=n;i++) scanf("%lld",a+i),a[i]-=k,a[i]+=a[i-1],as[i]=a[i];
    ll ans=0;
    sort(as+1,as+1+n);
    cnt=1;
    for(int i=1;i<=n;i++) if(!t.count(as[i])) t[as[i]]=cnt++;
    for(int i=1;i<=n;i++) {
        if(a[i]>=0) ans++;
        ans+=sum(t[a[i]]);
        add(t[a[i]],1);a
    }
    printf("%lld\n",ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:25: error: expected ';' before '}' token
   29 |         add(t[a[i]],1);a
      |                         ^
      |                         ;
   30 |     }
      |     ~
Language: Java

import java.util.*;

public class TaskE { // Main
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long k = scanner.nextLong();
		long[] a = new long[n];
		for(int i = 0; i < n; i ++) {
			a[i] = scanner.nextLong() - k;
		}
		long[] sum = new long[n];
		int count = 0;
		for(int i = 0; i < n; i ++) {
			sum[i] = a[i];
			if(sum[i] >= 0) {
				count ++;
			}
			for(int j = i + 1; j < n; j ++) {
				sum[j] = sum[j-1] + a[j];
				if(sum[j] >= 0) {
					count ++;
				}
			}
		}
		System.out.println(count);
				
		scanner.close();
	}
}

Compiler output:
Main.java:3: error: class TaskE is public, should be declared in a file named TaskE.java
public class TaskE { // Main
       ^
1 error
Language: C++

#include<iostream>
using namespace std;

int main() {
	int n=0,k=0,r=0;
	int a[2*(10^5)];
	cin >> n >> k;

	}
	cout << r << endl;
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:20: warning: result of '10^5' is 15; did you mean '1e5'? [-Wxor-used-as-pow]
    6 |         int a[2*(10^5)];
      |                    ^
      |                  ---
      |                  1e
a.cc:6:18: note: you can silence this warning by using a hexadecimal constant (0xa rather than 10)
    6 |         int a[2*(10^5)];
      |                  ^~
      |                  0xa
a.cc: At global scope:
a.cc:10:9: error: 'cout' does not name a type
   10 |         cout << r << endl;
      |         ^~~~
a.cc:11:9: error: expected unqualified-id before 'return'
   11 |         return 0;
      |         ^~~~~~
a.cc:13:1: error: expected declaration before '}' token
   13 | }
      | ^
Language: C++

#include<iostream>
using namespace std;

int main() {
	int n=0,k=0,r=0;
	int a[2e50];
	cin >> n>>k;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; ++i) {
		int z = 0;
		for (int j = i; j < n; ++j)
		{
			z += a[j];
			if (z / (j+1-i) >= k) {
				++r;
			}
		}
	}
	cout << r << endl;
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:15: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    6 |         int a[2e50];
      |               ^~~~
a.cc:6:15: error: could not convert '2.0000000000000002e+50' from 'double' to 'long unsigned int'
    6 |         int a[2e50];
      |               ^~~~
      |               |
      |               double
a.cc:6:15: error: size of array 'a' has non-integral type 'double'
Language: Java

/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class TaskE {
  static long[] t;
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    long k = Long.parseLong(s[1]);
    long[] arr = new long[n];
    Pair[] pairs = new Pair[n+1];
    long arrSum = 0;
    for (int i=0; i<n; i++) {
      arr[i] = Long.parseLong(br.readLine());
      arrSum += arr[i];
      pairs[i] = new Pair(i, arrSum-(i+1)*k);
    }
    pairs[n] = new Pair(-1,0);
    Arrays.sort(pairs);

    //System.out.println(Arrays.toString(pairs));
    FT1 ft = new FT1(n+1);
    long sum = 0;
    for (int i=0; i<n+1; i++) {
      Pair p = pairs[i];
      ft.add(p.index+2, 1);
      long prev = sum;
      sum += ft.sum(1,p.index+1);
      //System.out.println(ft.print());
      //System.out.println("Added: "+(sum-prev)+" on insert of: "+p);
    }
    System.out.println(sum);

  }
}
class Pair implements Comparable<Pair> {
  int index;
  long val;
  Pair(int i, long v) {
    index = i;
    val = v;
  }
  public int compareTo(Pair p2) {
    if (val==p2.val)
      return index-p2.index;
    return (int)(val-p2.val);
  }
  public String toString() {
    return "["+val+","+index+"]";
  }
}
class FT1 {
  int[] arr;
  FT1(int n) {
    arr = new int[n+1];
  }
  int sum(int i, int j) {
    return sum(j)-sum(i-1);
  }
  int sum(int i) {
    int sum=0;
    while (i>0) {
      sum+=arr[i];
      i-=i&-i;
    }
    return sum;
  }
  void add(int i, int delta) {
    if (i<=0)
      return;
    while(i<arr.length) {
      arr[i] += delta;
      i+=i&-i;
    }
  }
  String print() {
    String[] s = new String[arr.length-1];
    for (int i=0; i<s.length; i++) {
      s[i] = ""+ sum(i+1,i+1);
    }
    return String.join(", ",s);
  }
}


Compiler output:
Main.java:8: error: class TaskE is public, should be declared in a file named TaskE.java
public class TaskE {
       ^
1 error
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = 2e5 + 10;
struct TnT {
    int pos;
    ll val;
}nn[M];
struct node {
    int l , r;
    ll sum;
}T[M << 2];
bool cmp(TnT a , TnT b) {
    if(a.val == b.val) return a.pos < b.pos;
    return a.val < b.val;
}
void push_up(int i) {
    T[i].sum = T[i << 1].sum + T[(i << 1) | 1].sum;
}
void build(int i , int l , int r) {
    int mid = (l + r) >> 1;
    T[i].l = l , T[i].r = r , T[i].sum = 0;
    if(l == r) return ;
    build(i << 1 , l , mid);
    build((i << 1) | 1 , mid + 1 , r);
    push_up(i);
}
void update(int i , int pos) {
    int mid = (T[i].l + T[i].r) >> 1;
    if(T[i].l == pos && T[i].r == pos) {
        T[i].sum++;
        return ;
    }
    if(mid < pos) update((i << 1) | 1 , pos);
    else update(i << 1 , pos);
    push_up(i);
}
ll query(int i , int l , int r) {
    int mid = (T[i].l + T[i].r) >> 1;
    if(T[i].l == l && T[i].r == r) {
        return T[i].sum;
    }
    push_up(i);
    if(mid < l) return query((i << 1) | 1 , l , r);
    else if(mid >= r) return query(i << 1 , l , r);
    else {
        return query(i << 1 , l , mid) + query((i << 1) | 1 , mid + 1 , r);
    }
}
int main() {
    ll n , k , a;
    scanf("%lld%lld" ,  &n , &k);
    for(int i = 1 ; i <= n ; i++) {
        scanf("%lld" , &a);
        a -= k;
        nn[i].pos = i;
        nn[i].val = nn[i - 1].val + a;
    }
    sort(nn + 1 , nn + 1 + n , cmp);
    ll ans = 0;
    build(1 , 1 , (int)n);
    for(int i = 1 ; i <= n ; i++) {
        update(1 , nn[i].pos);
        if(nn[i].val >= 0) ans++;
        if(nn[i].pos - 1 == 0) continue;
        ans += query(1 , 1 , nn[i].pos - 1);
    }
    printf("%lld\n" , ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   61 |     sort(nn + 1 , nn + 1 + n , cmp);
      |     ^~~~
      |     short
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

lint n, k;
vector<lint> a(1, 0), zip;
map<lint, lint> unzip;

lint bit[202020];
lint sum(int i) {
	i++;
	lint s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x) {
	i++;
	while (i <= n) {
		bit[i] += x;
		i += i & -i;
	}
}

int main() {
	cin >> n >> k;
	rep(i, n) a.pb(in() - k);

	for (int i = 1; i <= n; ++i) {
		a[i] += a[i - 1];
	}

	for (int i = 0; i <= n; ++i) {
		zip.pb(a[i]);
	}

	sort(all(zip));
	zip.erase(unique(all(zip)), zip.end());
	for (int i = 0; i < zip.size(); ++i) {
		unzip[zip[i]] = i;
	}
	for (int i = 0; i <= n; ++i) {
		a[i] = unzip[a[i]];
	}

	lint ans = 0;
	for (int i = 0; i <= n; ++i) {
		ans += sum(a[i]);
		add(a[i], 1);
	}

	//print(zip);
	//print(a);

	cout << ans << endl;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=2e5+10;
typedef long long LL;
#define x first
#define y second

int n;
LL k;
LL a[maxn];
pair<LL,int> sum[maxn];
int rank[maxn];
LL ans,bit[maxn];

int lowbit(int p)
{
	return p&(-p);
}

LL search(int p)
{
	LL ans=0;
	while(p>0)
	{
		ans+=bit[p];
		p-=lowbit(p);
	}
	return ans;
}

void add(int p)
{
	while(p<=n)
	{
		bit[p]++;
		p+=lowbit(p);
	}
	return;
}

int main()
{
	scanf("%d%lld",&n,&k);
	ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",a[i]);
		a[i]-=k;
		sum[i].x=sum[i-1].x+a[i];
		sum[i].y=i;
		if (sum[i].x>0) ans++; 
	}
	sort(sum+1,sum+n+1);
	
	for(int i=1;i<=n;i++)
	    rank[sum[i].y]=i;
	
	for(int i=1;i<=n;i++)
	{
		ans+=search(rank[i]-1);
		add(rank[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:13: error: reference to 'rank' is ambiguous
   57 |             rank[sum[i].y]=i;
      |             ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:13:5: note:                 'int rank [200010]'
   13 | int rank[maxn];
      |     ^~~~
a.cc:61:29: error: reference to 'rank' is ambiguous
   61 |                 ans+=search(rank[i]-1);
      |                             ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:13:5: note:                 'int rank [200010]'
   13 | int rank[maxn];
      |     ^~~~
a.cc:62:21: error: reference to 'rank' is ambiguous
   62 |                 add(rank[i]);
      |                     ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:13:5: note:                 'int rank [200010]'
   13 | int rank[maxn];
      |     ^~~~
Language: C++

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	LL K;
	cin >> N >> K;
	vector<LL> A(N);
	//値から欲しい平均値を引く
	for(int i=0;i<N;++i){
		cin >> A[i];
		A[i] -= K;
	}

	//累積和を取る
	vector<LL> sum(N);
	sum[0] = A[0];
	for(int i=1;i<N;++i){
		sum[i] = sum[i-1] + A[i];
	}

	//累積和に対して座標圧縮する。
	vector<LL> B = sum;
	B.push_back( 0 );//基準を入れておく
	UNIQUE(B);
	vector<int> sumC(N);//圧縮されたindex+1に値を変える
	for(int i=0;i<N;++i){
		int index = lower_bound(B.begin(),B.end(),sum[i]) - B.begin();
		sumC[i] = index + 1;
	}
	int size = B.size();
	BITree BIT(size);
	
	//基準の値
	int index = lower_bound(B.begin(),B.end(),0) - B.begin();
	BIT.add(index+1,1);//0の分
	
	LL ans = 0;
	for(int i=0;i<N;++i){
		LL res = BIT.sum( sumC[i] );
		ans += res;
		BIT.add(sumC[i],1);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Compiler output:
a.cc: In function 'void solve()':
a.cc:68:9: error: 'UNIQUE' was not declared in this scope
   68 |         UNIQUE(B);
      |         ^~~~~~
a.cc:75:9: error: 'BITree' was not declared in this scope
   75 |         BITree BIT(size);
      |         ^~~~~~
a.cc:79:9: error: 'BIT' was not declared in this scope
   79 |         BIT.add(index+1,1);//0の分
      |         ^~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;

int main(void){
    int N, K, a;
    cin >> N >> K;
    vector<int> vec(N, 0);
    for(int i = 0; i < N; i ++)
    {
        cin >> a;
        vec[i] = a - K;
    }
    long long sum;
    long long count = 0;
    for(int i = 0; i < N; i ++)
    {
        sum = 0;
        sum_comp = 0;
        for(int j = 0; j < N - i; j ++)
        {
            sum += vec[i + j];
            if(sum >= 0)
            {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'sum_comp' was not declared in this scope
   19 |         sum_comp = 0;
      |         ^~~~~~~~
Language: C++

#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

struct Node{
    Node *l = nullptr, *r = nullptr;
    int value, cnt = 1;
    Node(int value): value(value) { }
};
struct Sorted {
    Node* root = nullptr;
    ll added = 0;
    void insert(int num){
        added -= num;
        num += added;
        Node* n = root;
        if(!root){ root = new Node(num); return; }
        while(n){
            // prints(n);
            if(n->value <= num){
                n->cnt++;
                if(!n->r){ n->r = new Node(num); break; }
                n = n->r;
            }else{
                // n->cnt++;
                if(!n->l){ n->l = new Node(num); break; }
                n = n->l;
            }
        }
        // n = new Node(num);
    }
    int beq(int num){
        num += added;
        Node* n = root;
        int acc = 0;
        while(n){
            if(n->value > num){
                acc += n->cnt;
                n = n->l;
            }else if(n->value == num){
                return n->cnt + acc;
            }else{
                n = n->r;
            }
        }
        return acc;
    }
    // int add(int num){
    //     added += num;
    // }
};

int main(){
    int n, k;
    cin >> n >> k;
    Sorted sorted;
    vector<int> as(n);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        cin >> as[i];
    }
    reverse(as.begin(), as.end());
    for(int i = 0; i < n; i++){
        int a = as[i];
        a -= k;
        // ans += sorted.beq(- a);
        // sorted.add(a);
        sorted.insert(a);
        ans += sorted.beq(0);
        printd(ans);
        printd(sorted.added);
        printBTree(sorted.root);
    }
    cout << ans << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:96:9: error: 'printBTree' was not declared in this scope; did you mean 'printArr'?
   96 |         printBTree(sorted.root);
      |         ^~~~~~~~~~
      |         printArr
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int N = 0, K = 0;
    int ans = 0;
    cin >> N >> K;
    vector<double> v(N);
    for (int i = 0; i < N;i++){
        cin >> v[i];
    }
    for (int i = 0; i < N;i++){
        double sum = 0;
        double c = 0;
        for (int j = i; j < N;j++){
            sum += v[i];
            c++;
            if(sum/c=>K)
                ans++;
        }
    }
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:22: error: expected primary-expression before '>' token
   21 |             if(sum/c=>K)
      |                      ^
Language: C++

#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

template<typename T>
using v = vector<T>;

int main() {
	int N, K;
	cin >> N >> K;
	vll a(N);
	vll sum(N + 1);
	sum[0] = 0;
	rep(i, N) {
		cin >> a[i];
		a[i] -= K;
		sum[i + 1] = sum[i] + a[i];
	}

	vll pre;
	ll ans = 0;
	rep(i, N + 1) {
		ans += upper_bound(all(pre), sum[i]) - pre.begin();
		pre.insert(lower_bound(all(pre, sum[i]), sum[i]), sum[i]);
		/*
		rep(j, pre.size()) {
			cout << pre[j] << ' ';
		}cout << endl;
		*/
	}
	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc:63:55: error: macro "all" passed 2 arguments, but takes just 1
   63 |                 pre.insert(lower_bound(all(pre, sum[i]), sum[i]), sum[i]);
      |                                                       ^
a.cc:12:9: note: macro "all" defined here
   12 | #define all(a) a.begin(),a.end()
      |         ^~~
a.cc: In function 'int main()':
a.cc:63:40: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   63 |                 pre.insert(lower_bound(all(pre, sum[i]), sum[i]), sum[i]);
      |                                        ^~~
      |                                        std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

long long d,ans,p[20]={1},dx1[20],dx2[20];

vector<long long> v;

void dfs(int nw,int num,vector<pair<long long,long long> >&w,long long val,long long cnt)

{

	if(nw==num)	{

		w.push_back(make_pair(val,cnt));

		return;

	}

	for(int i=-9;i<10;++i)

	 if(nw==0) dfs(nw+1,num,w,val+v[nw]*i,cnt*dx2[i+10]);

	 else dfs(nw+1,num,w,val+v[nw]*i,cnt*dx1[i+10]);

}

long long solve(int l)

{

	v.clear();

	for(int i=0;l-1-i>i;++i)

	 v.push_back(p[l-1-i]-p[i]);

	vector<pair<long long,long long> > v1,v2;

	dfs(0,(v.size()+1)/2,v1,0,1);

	dfs((v.size()+1)/2,v.size(),v2,0,1);

	long long tot=0;

	map<long long,long long> mp;

	for(int i=0;i<v2.size();++i)

	 mp[v2[i].first]+=v2[i].second;

	for(int i=0;i<v1.size();++i)

	 tot+=mp[v1[i].first+d]*v1[i].second;

	if(l%2) tot*=10;

	return tot;

}

int main()

{

	cin>>d;

	if(d%9)

	{

		cout<<0;

		return 0;

	}

	for(int i=1;i<20;++i) p[i]=p[i-1]*10;

	for(int i=0;i<10;++i)

	 for(int j=0;j<10;++j)

	 {

	 	++dx1[i-j+10];

	 	if(i) ++dx2[i-j

Compiler output:
a.cc: In function 'int main()':
a.cc:89:32: error: expected ']' at end of input
   89 |                 if(i) ++dx2[i-j
      |                                ^
      |                                ]
a.cc:89:32: error: expected ';' at end of input
   89 |                 if(i) ++dx2[i-j
      |                                ^
      |                                ;
a.cc:89:32: error: expected '}' at end of input
a.cc:85:10: note: to match this '{'
   85 |          {
      |          ^
a.cc:89:32: error: expected '}' at end of input
   89 |                 if(i) ++dx2[i-j
      |                                ^
a.cc:65:1: note: to match this '{'
   65 | {
      | ^