stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<algorithm>

using std::scanf;

using std::printf;

using std::memset;

struct node

{

  long long data;

  int id;

  bool operator< (const node& o) const

  { return this->data < o.data;}

};



typedef long long llong;

const int maxn = 200010;



llong treeset[maxn];

llong end[maxn];

node rec[maxn];

llong n;

llong k;



inline int lowbit(int x)

{ return x&(-x);}



void add(int x, llong d)

{

  while(x <= n)

  {

    treeset[x] += d;

    x += lowbit(x);

  }

}



llong sum(int x)

{

  llong ans = 0;

  while(x)

  {

    ans += treeset[x];

    x -= lowbit(x);

  }

  return ans;

}



int main()

{

  llong tmp;

  llong ans = 0;

  scanf("%lld%lld", &n, &k);

  memset(rec, 0, sizeof(rec));

  for(int i = 1; i <= n; ++i)

  {

    scanf("%lld", &tmp);

    rec[i].data = rec[i-1].data +tmp-k;

    rec[i].id = i;

  }

  std::sort(rec+1, rec+1+n);

  end[rec[1].id] = 1;

  for(int i = 2; i <= n; ++i)

  {

    if(rec[i].data != rec[i-1].data)

    { end[rec[i].id] = i;}

    else

    { end[rec[i].id] = end[rec[i-1].id];}

  }

  for(int i = 1; i <= n; ++i)

  {

    add(end[i], 1);

    ans += sum(n) - sum(end[i]);

  }

  for(int i = 1; i <= n; ++i)

  {

    if(rec[i].data < 0)

    { ++ans;}

  }

  ans = n*(n+1)/2 - ans;

  printf("%lld\n", ans);

}


// Faster C++ solution for the same problem (measured speedup: 3.403711476827693x):
#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;



struct BIT{

    int N;

    LL a[MAX_N];



    void clear(int n){

        N = n;

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

    }

    int lowbit(int x){

        return x & (-x);

    }

    void update(int x){

        for (;x <= N;x += lowbit(x))

            a[x]++;

    }

    LL sum(int x)

    {

        LL ret = 0LL;

        for (; x; x -= lowbit(x))

            ret += a[x];

        return ret;

    }

} tree;



LL b[MAX_N],s[MAX_N];

map<LL,int> mp;



int main()

{

    int n, m, x;

    scanf("%d%d",&n,&m);



    mp.clear();

    tree.clear(n);

    LL ans = 0LL;



    for (int i=1;i<=n;i++){

        scanf("%d",&x);

        s[i] = s[i - 1] + x - m;

        if (s[i] < 0) ans++;

        b[i] = s[i];

    }

    sort(b+1,b+n+1);



    for (int i=1;i<=n;i++)

       if (mp[b[i]] == 0) mp[b[i]] = i;



    for (int i=n;i>=1;i--){

        x = mp[s[i]];

        ans += tree.sum(x);

        tree.update(x+1);

    }

    printf("%lld\n",1LL * n * (n + 1) / 2 - ans);

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<set>

#include<queue>

#include<map>

using namespace std;

long long s[200005],ts[200005],in[200005];

void p(int pos)

{

	while(pos<=200003)

	{

		in[pos]+=1;

		pos+=pos&(-pos);

	}

	

}

long long sum(int n)

{

	long long sum=0;

	while(n>0)

	{

		sum+=in[n];

		n-=n&(-n);

	}

	return sum;

}

int main()

{



	int n,k,x;

	long long ans=0;

	memset(s,0,sizeof(s));

	scanf("%d%d",&n,&k);

	for(int i=1;i<=n;i++)  	

	{

		scanf("%d",&x),s[i]=x-k+s[i-1],ts[i]=s[i];

		if(s[i]>=0)

		ans++;

		}

	sort(ts+1,ts+1+n);

	int size=unique(ts+1,ts+1+n)-ts+1;

	for(int i=1;i<=n;i++)   s[i]=lower_bound(ts+1,ts+1+size,s[i])-ts;

	memset(in,0,sizeof(in));

	for(int i=1;i<=n;i++)

		{

			ans+=sum(s[i]);

			p(s[i]);

		}

	

	printf("%lld\n",ans);

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 4.218901053959288x):
#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;



struct BIT{

    int N;

    LL a[MAX_N];



    void clear(int n){

        N = n;

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

    }

    int lowbit(int x){

        return x & (-x);

    }

    void update(int x){

        for (;x <= N;x += lowbit(x))

            a[x]++;

    }

    LL sum(int x)

    {

        LL ret = 0LL;

        for (; x; x -= lowbit(x))

            ret += a[x];

        return ret;

    }

} tree;



LL b[MAX_N],s[MAX_N];

map<LL,int> mp;



int main()

{

    int n, m, x;

    scanf("%d%d",&n,&m);



    mp.clear();

    tree.clear(n);

    LL ans = 0LL;



    for (int i=1;i<=n;i++){

        scanf("%d",&x);

        s[i] = s[i - 1] + x - m;

        if (s[i] < 0) ans++;

        b[i] = s[i];

    }

    sort(b+1,b+n+1);



    for (int i=1;i<=n;i++)

       if (mp[b[i]] == 0) mp[b[i]] = i;



    for (int i=n;i>=1;i--){

        x = mp[s[i]];

        ans += tree.sum(x);

        tree.update(x+1);

    }

    printf("%lld\n",1LL * n * (n + 1) / 2 - ans);

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<algorithm>

using std::scanf;

using std::printf;

using std::memset;

struct node

{

  long long data;

  int id;

  bool operator< (const node& o) const

  { return this->data < o.data;}

};



typedef long long llong;

const int maxn = 200010;



llong treeset[maxn];

llong end[maxn];

node rec[maxn];

llong n;

llong k;



inline int lowbit(int x)

{ return x&(-x);}



void add(int x, llong d)

{

  while(x <= n)

  {

    treeset[x] += d;

    x += lowbit(x);

  }

}



llong sum(int x)

{

  llong ans = 0;

  while(x)

  {

    ans += treeset[x];

    x -= lowbit(x);

  }

  return ans;

}



int main()

{

  llong tmp;

  llong ans = 0;

  scanf("%lld%lld", &n, &k);

  memset(rec, 0, sizeof(rec));

  for(int i = 1; i <= n; ++i)

  {

    scanf("%lld", &tmp);

    rec[i].data = rec[i-1].data +tmp-k;

    rec[i].id = i;

  }

  std::sort(rec+1, rec+1+n);

  end[rec[1].id] = 1;

  for(int i = 2; i <= n; ++i)

  {

    if(rec[i].data != rec[i-1].data)

    { end[rec[i].id] = i;}

    else

    { end[rec[i].id] = end[rec[i-1].id];}

  }

  for(int i = 1; i <= n; ++i)

  {

    add(end[i], 1);

    ans += sum(n) - sum(end[i]);

  }

  for(int i = 1; i <= n; ++i)

  {

    if(rec[i].data < 0)

    { ++ans;}

  }

  ans = n*(n+1)/2 - ans;

  printf("%lld\n", ans);

}


// Faster C++ solution for the same problem (measured speedup: 3.403711476827693x):
#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;



struct BIT{

    int N;

    LL a[MAX_N];



    void clear(int n){

        N = n;

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

    }

    int lowbit(int x){

        return x & (-x);

    }

    void update(int x){

        while (x <= N){

            a[x]++;

            x += lowbit(x);

        }

    }

    LL sum(int x)

    {

        LL ret = 0LL;

        while (x){

            ret += a[x];

            x -= lowbit(x);

        }

        return ret;

    }

} tree;



LL b[MAX_N],s[MAX_N];

map<LL,int> mp;



int main()

{

    int n, m, x;

    scanf("%d%d",&n,&m);



    mp.clear();

    tree.clear(n);

    LL ans = 0LL;



    for (int i=1;i<=n;i++){

        scanf("%d",&x);

        s[i] = s[i - 1] + x - m;

        if (s[i] < 0) ans++;

        b[i] = s[i];

    }

    sort(b+1,b+n+1);



    for (int i=1;i<=n;i++)

       if (mp[b[i]] == 0) mp[b[i]] = i;



    for (int i=n;i>=1;i--){

        x = mp[s[i]];

        ans += tree.sum(x);

        tree.update(x+1);

    }

    printf("%lld\n",1LL * n * (n + 1) / 2 - ans);

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<set>

#include<queue>

#include<map>

using namespace std;

long long s[200005],ts[200005],in[200005];

void p(int pos)

{

	while(pos<=200003)

	{

		in[pos]+=1;

		pos+=pos&(-pos);

	}

	

}

long long sum(int n)

{

	long long sum=0;

	while(n>0)

	{

		sum+=in[n];

		n-=n&(-n);

	}

	return sum;

}

int main()

{



	int n,k,x;

	long long ans=0;

	memset(s,0,sizeof(s));

	scanf("%d%d",&n,&k);

	for(int i=1;i<=n;i++)  	

	{

		scanf("%d",&x),s[i]=x-k+s[i-1],ts[i]=s[i];

		if(s[i]>=0)

		ans++;

		}

	sort(ts+1,ts+1+n);

	int size=unique(ts+1,ts+1+n)-ts+1;

	for(int i=1;i<=n;i++)   s[i]=lower_bound(ts+1,ts+1+size,s[i])-ts;

	memset(in,0,sizeof(in));

	for(int i=1;i<=n;i++)

		{

			ans+=sum(s[i]);

			p(s[i]);

		}

	

	printf("%lld\n",ans);

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 4.218901053959288x):
#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;



struct BIT{

    int N;

    LL a[MAX_N];



    void clear(int n){

        N = n;

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

    }

    int lowbit(int x){

        return x & (-x);

    }

    void update(int x){

        while (x <= N){

            a[x]++;

            x += lowbit(x);

        }

    }

    LL sum(int x)

    {

        LL ret = 0LL;

        while (x){

            ret += a[x];

            x -= lowbit(x);

        }

        return ret;

    }

} tree;



LL b[MAX_N],s[MAX_N];

map<LL,int> mp;



int main()

{

    int n, m, x;

    scanf("%d%d",&n,&m);



    mp.clear();

    tree.clear(n);

    LL ans = 0LL;



    for (int i=1;i<=n;i++){

        scanf("%d",&x);

        s[i] = s[i - 1] + x - m;

        if (s[i] < 0) ans++;

        b[i] = s[i];

    }

    sort(b+1,b+n+1);



    for (int i=1;i<=n;i++)

       if (mp[b[i]] == 0) mp[b[i]] = i;



    for (int i=n;i>=1;i--){

        x = mp[s[i]];

        ans += tree.sum(x);

        tree.update(x+1);

    }

    printf("%lld\n",1LL * n * (n + 1) / 2 - ans);

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<algorithm>

using std::scanf;

using std::printf;

using std::memset;

struct node

{

  long long data;

  int id;

  bool operator< (const node& o) const

  { return this->data < o.data;}

};



typedef long long llong;

const int maxn = 200010;



llong treeset[maxn];

llong end[maxn];

node rec[maxn];

llong n;

llong k;



inline int lowbit(int x)

{ return x&(-x);}



void add(int x, llong d)

{

  while(x <= n)

  {

    treeset[x] += d;

    x += lowbit(x);

  }

}



llong sum(int x)

{

  llong ans = 0;

  while(x)

  {

    ans += treeset[x];

    x -= lowbit(x);

  }

  return ans;

}



int main()

{

  llong tmp;

  llong ans = 0;

  scanf("%lld%lld", &n, &k);

  memset(rec, 0, sizeof(rec));

  for(int i = 1; i <= n; ++i)

  {

    scanf("%lld", &tmp);

    rec[i].data = rec[i-1].data +tmp-k;

    rec[i].id = i;

  }

  std::sort(rec+1, rec+1+n);

  end[rec[1].id] = 1;

  for(int i = 2; i <= n; ++i)

  {

    if(rec[i].data != rec[i-1].data)

    { end[rec[i].id] = i;}

    else

    { end[rec[i].id] = end[rec[i-1].id];}

  }

  for(int i = 1; i <= n; ++i)

  {

    add(end[i], 1);

    ans += sum(n) - sum(end[i]);

  }

  for(int i = 1; i <= n; ++i)

  {

    if(rec[i].data < 0)

    { ++ans;}

  }

  ans = n*(n+1)/2 - ans;

  printf("%lld\n", ans);

}


// Faster C++ solution for the same problem (measured speedup: 1.7722573316453643x):
#include <iostream>

#include <cstring>

#include <algorithm>

using namespace std;

const int N = 2e5 + 10;

int t[N];

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

void add(int x){

    while(x<N){

        t[x]++;

        x+=lowbit(x);

    }

}

long long sum(int x){

    long long ans=0;

    while(x){

        ans+=t[x];

        x-=lowbit(x);

    }

    return ans;

}

struct node{int id;long long val;};

node arr[N];

bool comp(node p1,node p2){

    return p1.val<p2.val;

}

int num[N];

int main(){

    std::ios::sync_with_stdio(false);

    int n,k;

    while(cin>>n>>k){

        memset(t,0,sizeof(t));

        long long a;

        arr[0].id = 0;

        arr[0].val = 0;

        for(int i=1;i<=n;i++){

            arr[i].id = i;

            cin>>a;

            arr[i].val = a-k;

        }

        for(int i=1;i<=n;i++){

            arr[i].val += arr[i-1].val;

        }

        sort(arr,arr+n+1,comp);

        for(int i=0;i<=n;i++){

            if(i>0&&arr[i].val==arr[i-1].val)num[arr[i].id] = num[arr[i-1].id];

            else num[arr[i].id] = i+1;

        }

        long long ans = 0;

        for(int i=0;i<=n;i++){

            int x = num[i];

            ans += sum(x);

            add(x);

        }

        cout<<ans<<endl;

    }

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<set>

#include<queue>

#include<map>

using namespace std;

long long s[200005],ts[200005],in[200005];

void p(int pos)

{

	while(pos<=200003)

	{

		in[pos]+=1;

		pos+=pos&(-pos);

	}

	

}

long long sum(int n)

{

	long long sum=0;

	while(n>0)

	{

		sum+=in[n];

		n-=n&(-n);

	}

	return sum;

}

int main()

{



	int n,k,x;

	long long ans=0;

	memset(s,0,sizeof(s));

	scanf("%d%d",&n,&k);

	for(int i=1;i<=n;i++)  	

	{

		scanf("%d",&x),s[i]=x-k+s[i-1],ts[i]=s[i];

		if(s[i]>=0)

		ans++;

		}

	sort(ts+1,ts+1+n);

	int size=unique(ts+1,ts+1+n)-ts+1;

	for(int i=1;i<=n;i++)   s[i]=lower_bound(ts+1,ts+1+size,s[i])-ts;

	memset(in,0,sizeof(in));

	for(int i=1;i<=n;i++)

		{

			ans+=sum(s[i]);

			p(s[i]);

		}

	

	printf("%lld\n",ans);

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 2.19671331582263x):
#include <iostream>

#include <cstring>

#include <algorithm>

using namespace std;

const int N = 2e5 + 10;

int t[N];

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

void add(int x){

    while(x<N){

        t[x]++;

        x+=lowbit(x);

    }

}

long long sum(int x){

    long long ans=0;

    while(x){

        ans+=t[x];

        x-=lowbit(x);

    }

    return ans;

}

struct node{int id;long long val;};

node arr[N];

bool comp(node p1,node p2){

    return p1.val<p2.val;

}

int num[N];

int main(){

    std::ios::sync_with_stdio(false);

    int n,k;

    while(cin>>n>>k){

        memset(t,0,sizeof(t));

        long long a;

        arr[0].id = 0;

        arr[0].val = 0;

        for(int i=1;i<=n;i++){

            arr[i].id = i;

            cin>>a;

            arr[i].val = a-k;

        }

        for(int i=1;i<=n;i++){

            arr[i].val += arr[i-1].val;

        }

        sort(arr,arr+n+1,comp);

        for(int i=0;i<=n;i++){

            if(i>0&&arr[i].val==arr[i-1].val)num[arr[i].id] = num[arr[i-1].id];

            else num[arr[i].id] = i+1;

        }

        long long ans = 0;

        for(int i=0;i<=n;i++){

            int x = num[i];

            ans += sum(x);

            add(x);

        }

        cout<<ans<<endl;

    }

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<set>

#include<queue>

#include<map>

using namespace std;

long long s[200005],ts[200005],in[200005];

void p(int pos)

{

	while(pos<=200003)

	{

		in[pos]+=1;

		pos+=pos&(-pos);

	}

	

}

long long sum(int n)

{

	long long sum=0;

	while(n>0)

	{

		sum+=in[n];

		n-=n&(-n);

	}

	return sum;

}

int main()

{



	int n,k,x;

	long long ans=0;

	memset(s,0,sizeof(s));

	scanf("%d%d",&n,&k);

	for(int i=1;i<=n;i++)  	

	{

		scanf("%d",&x),s[i]=x-k+s[i-1],ts[i]=s[i];

		if(s[i]>=0)

		ans++;

		}

	sort(ts+1,ts+1+n);

	int size=unique(ts+1,ts+1+n)-ts+1;

	for(int i=1;i<=n;i++)   s[i]=lower_bound(ts+1,ts+1+size,s[i])-ts;

	memset(in,0,sizeof(in));

	for(int i=1;i<=n;i++)

		{

			ans+=sum(s[i]);

			p(s[i]);

		}

	

	printf("%lld\n",ans);

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 1.2390782824885929x):
#include <algorithm>

#include <iostream>

#include <cstring>

#include <cstdio>

#include <cmath>

#include <map>

using namespace std;



int n;

long long m;

long long sum[300000];

long long c[300000];

long long d[300000];



int lowbit(int x){

	return x & -x;

}



void update(int x){

	while (x<=n+10){

		c[x]+=1;

		x+=lowbit(x);

	}

}



int query(int x){

	int s=0;

	while (x>0){

		s+=c[x];

		x-=lowbit(x);

	}

	return s;

}



struct o_O{

	long long b;

	int d;

}p[600000];



bool cmp(o_O a,o_O b){

	return a.b<b.b;

}



int main(){

	scanf("%d%lld",&n,&m);

	long long w;

	sum[0]=0;

	for (int i=1;i<=n;i++){

		scanf("%lld",&w);

		sum[i]=sum[i-1]+w;

	}

	for (int i=0;i<=n;i++){

		sum[i]=sum[i]-m*i;

		p[i].b=sum[i];

		p[i].d=i;

	}

	sort(p,p+n+1,cmp);

	sum[p[0].d]=1;

	int n1=1;

	for (int i=1;i<=n;i++){

		if (p[i].b==p[i-1].b){

			sum[p[i].d]=n1;

		}else {

			n1++;

			sum[p[i].d]=n1;

		}

	}

	memset(c,0,sizeof(c));

	long long ans=0;

	for (int i=0;i<=n;i++){

		ans+=query(sum[i]);

		update(sum[i]); 

	}

	printf("%lld",ans);

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<algorithm>

using std::scanf;

using std::printf;

using std::memset;

struct node

{

  long long data;

  int id;

  bool operator< (const node& o) const

  { return this->data < o.data;}

};



typedef long long llong;

const int maxn = 200010;



llong treeset[maxn];

llong end[maxn];

node rec[maxn];

llong n;

llong k;



inline int lowbit(int x)

{ return x&(-x);}



void add(int x, llong d)

{

  while(x <= n)

  {

    treeset[x] += d;

    x += lowbit(x);

  }

}



llong sum(int x)

{

  llong ans = 0;

  while(x)

  {

    ans += treeset[x];

    x -= lowbit(x);

  }

  return ans;

}



int main()

{

  llong tmp;

  llong ans = 0;

  scanf("%lld%lld", &n, &k);

  memset(rec, 0, sizeof(rec));

  for(int i = 1; i <= n; ++i)

  {

    scanf("%lld", &tmp);

    rec[i].data = rec[i-1].data +tmp-k;

    rec[i].id = i;

  }

  std::sort(rec+1, rec+1+n);

  end[rec[1].id] = 1;

  for(int i = 2; i <= n; ++i)

  {

    if(rec[i].data != rec[i-1].data)

    { end[rec[i].id] = i;}

    else

    { end[rec[i].id] = end[rec[i-1].id];}

  }

  for(int i = 1; i <= n; ++i)

  {

    add(end[i], 1);

    ans += sum(n) - sum(end[i]);

  }

  for(int i = 1; i <= n; ++i)

  {

    if(rec[i].data < 0)

    { ++ans;}

  }

  ans = n*(n+1)/2 - ans;

  printf("%lld\n", ans);

}


// Faster C++ solution for the same problem (measured speedup: 3.4418161686053144x):
#include<bits/stdc++.h>

using namespace std;

#define mod 1000000007

#define MOD(x) ((x)%mod)

int n;

long long mean;

long long a[200005]; 

long long s[200005]; 

long long temp[200005]; 

long long ans;

void merge(int l,int r)

{

	int m=(l+r)/2;

	int h1=l,h2=m+1;

	int t1=m,t2=r;

	if(h1<t1) merge(h1,t1);

	if(h2<t2) merge(h2,t2);

	for(int i=l;i<=r;i++)	

	{

		if(h1<=t1&&h2<=t2)

		{

			if(s[h1]>s[h2])

			{

				temp[i]=s[h1++];

			}

			else

			{

				temp[i]=s[h2++];

				ans+=t1-h1+1;

			}

		}

		else if(h1<=t1)

		{

			temp[i]=s[h1++];

		}

		else

		{

			temp[i]=s[h2++];

		}

	}

	for(int i=l;i<=r;i++)

		s[i]=temp[i];

}

int main()

{

	scanf("%d%lld",&n,&mean);

	for(int i=1;i<=n;i++)

	{

		scanf("%lld",&a[i]);

		a[i]-=mean;

		s[i]=s[i-1]+a[i];

	}

	merge(1,n);

	for(int i=1;i<=n;i++)

		if(s[i]>=0) ans++;

	printf("%lld",ans);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<cstdio>

#include<set>

#include<queue>

#include<map>

using namespace std;

long long s[200005],ts[200005],in[200005];

void p(int pos)

{

	while(pos<=200003)

	{

		in[pos]+=1;

		pos+=pos&(-pos);

	}

	

}

long long sum(int n)

{

	long long sum=0;

	while(n>0)

	{

		sum+=in[n];

		n-=n&(-n);

	}

	return sum;

}

int main()

{



	int n,k,x;

	long long ans=0;

	memset(s,0,sizeof(s));

	scanf("%d%d",&n,&k);

	for(int i=1;i<=n;i++)  	

	{

		scanf("%d",&x),s[i]=x-k+s[i-1],ts[i]=s[i];

		if(s[i]>=0)

		ans++;

		}

	sort(ts+1,ts+1+n);

	int size=unique(ts+1,ts+1+n)-ts+1;

	for(int i=1;i<=n;i++)   s[i]=lower_bound(ts+1,ts+1+size,s[i])-ts;

	memset(in,0,sizeof(in));

	for(int i=1;i<=n;i++)

		{

			ans+=sum(s[i]);

			p(s[i]);

		}

	

	printf("%lld\n",ans);

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 4.2661318270127175x):
#include<bits/stdc++.h>

using namespace std;

#define mod 1000000007

#define MOD(x) ((x)%mod)

int n;

long long mean;

long long a[200005]; 

long long s[200005]; 

long long temp[200005]; 

long long ans;

void merge(int l,int r)

{

	int m=(l+r)/2;

	int h1=l,h2=m+1;

	int t1=m,t2=r;

	if(h1<t1) merge(h1,t1);

	if(h2<t2) merge(h2,t2);

	for(int i=l;i<=r;i++)	

	{

		if(h1<=t1&&h2<=t2)

		{

			if(s[h1]>s[h2])

			{

				temp[i]=s[h1++];

			}

			else

			{

				temp[i]=s[h2++];

				ans+=t1-h1+1;

			}

		}

		else if(h1<=t1)

		{

			temp[i]=s[h1++];

		}

		else

		{

			temp[i]=s[h2++];

		}

	}

	for(int i=l;i<=r;i++)

		s[i]=temp[i];

}

int main()

{

	scanf("%d%lld",&n,&mean);

	for(int i=1;i<=n;i++)

	{

		scanf("%lld",&a[i]);

		a[i]-=mean;

		s[i]=s[i-1]+a[i];

	}

	merge(1,n);

	for(int i=1;i<=n;i++)

		if(s[i]>=0) ans++;

	printf("%lld",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <algorithm>

using namespace std;

const int N = 2e5 + 10;

int t[N];

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

void add(int x){

    while(x<N){

        t[x]++;

        x+=lowbit(x);

    }

}

long long sum(int x){

    long long ans=0;

    while(x){

        ans+=t[x];

        x-=lowbit(x);

    }

    return ans;

}

struct node{int id;long long val;};

node arr[N];

bool comp(node p1,node p2){

    return p1.val<p2.val;

}

int num[N];

int main(){

    std::ios::sync_with_stdio(false);

    int n,k;

    while(cin>>n>>k){

        memset(t,0,sizeof(t));

        long long a;

        arr[0].id = 0;

        arr[0].val = 0;

        for(int i=1;i<=n;i++){

            arr[i].id = i;

            cin>>a;

            arr[i].val = a-k;

        }

        for(int i=1;i<=n;i++){

            arr[i].val += arr[i-1].val;

        }

        sort(arr,arr+n+1,comp);

        for(int i=0;i<=n;i++){

            if(i>0&&arr[i].val==arr[i-1].val)num[arr[i].id] = num[arr[i-1].id];

            else num[arr[i].id] = i+1;

        }

        long long ans = 0;

        for(int i=0;i<=n;i++){

            int x = num[i];

            ans += sum(x);

            add(x);

        }

        cout<<ans<<endl;

    }

}


// Faster C++ solution for the same problem (measured speedup: 1.9420521541360651x):
#include<bits/stdc++.h>

using namespace std;

#define mod 1000000007

#define MOD(x) ((x)%mod)

int n;

long long mean;

long long a[200005]; 

long long s[200005]; 

long long temp[200005]; 

long long ans;

void merge(int l,int r)

{

	int m=(l+r)/2;

	int h1=l,h2=m+1;

	int t1=m,t2=r;

	if(h1<t1) merge(h1,t1);

	if(h2<t2) merge(h2,t2);

	for(int i=l;i<=r;i++)	

	{

		if(h1<=t1&&h2<=t2)

		{

			if(s[h1]>s[h2])

			{

				temp[i]=s[h1++];

			}

			else

			{

				temp[i]=s[h2++];

				ans+=t1-h1+1;

			}

		}

		else if(h1<=t1)

		{

			temp[i]=s[h1++];

		}

		else

		{

			temp[i]=s[h2++];

		}

	}

	for(int i=l;i<=r;i++)

		s[i]=temp[i];

}

int main()

{

	scanf("%d%lld",&n,&mean);

	for(int i=1;i<=n;i++)

	{

		scanf("%lld",&a[i]);

		a[i]-=mean;

		s[i]=s[i-1]+a[i];

	}

	merge(1,n);

	for(int i=1;i<=n;i++)

		if(s[i]>=0) ans++;

	printf("%lld",ans);

	return 0;

}