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: 1.3048104052270293x):
#include<iostream>

#include<algorithm>

#include<cmath>

#include<string.h>

#include<cstdio>

#include<map>

using namespace std;

typedef long long ll;

const int MAX=200000+10; 

int n,k;

ll a[MAX];

ll b[MAX];

ll s[MAX];

map<ll, int>mp;

int lowbit(int x)

{

    return (x&-x);

}

 

void modify(int x,int num)

{

    while(x<=n+1){

        a[x]+=(long long)num;

        x+=lowbit(x);

    }

}

 

long long sum(int x)

{

    long long ans=0;

    while(x>0){

        ans+=a[x];

        x-=lowbit(x);

    }

    return ans;

}

 

int main()

{

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

    s[0]=0;b[0]=0;

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

        int x;

        scanf("%d",&x);

        s[i]=s[i-1]+(long long)(x-k);

        b[i]=s[i];

    }

    sort(b,b+1+n);

    int tot=0;

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

        if(!mp.count(b[i]))mp[b[i]]=++tot; 

    long long cnt=0;

    memset(a,0,sizeof(a));

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

        cnt+=sum(mp[s[i]]);

        modify(mp[s[i]],1);

    }

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

    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: 1.6173127573550896x):
#include<iostream>

#include<algorithm>

#include<cmath>

#include<string.h>

#include<cstdio>

#include<map>

using namespace std;

typedef long long ll;

const int MAX=200000+10; 

int n,k;

ll a[MAX];

ll b[MAX];

ll s[MAX];

map<ll, int>mp;

int lowbit(int x)

{

    return (x&-x);

}

 

void modify(int x,int num)

{

    while(x<=n+1){

        a[x]+=(long long)num;

        x+=lowbit(x);

    }

}

 

long long sum(int x)

{

    long long ans=0;

    while(x>0){

        ans+=a[x];

        x-=lowbit(x);

    }

    return ans;

}

 

int main()

{

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

    s[0]=0;b[0]=0;

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

        int x;

        scanf("%d",&x);

        s[i]=s[i-1]+(long long)(x-k);

        b[i]=s[i];

    }

    sort(b,b+1+n);

    int tot=0;

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

        if(!mp.count(b[i]))mp[b[i]]=++tot; 

    long long cnt=0;

    memset(a,0,sizeof(a));

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

        cnt+=sum(mp[s[i]]);

        modify(mp[s[i]],1);

    }

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

    return 0;

}
// Slower C++ solution:
#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;

} 

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

#include<algorithm>

#include<cmath>

#include<string.h>

#include<cstdio>

#include<map>

using namespace std;

typedef long long ll;

const int MAX=200000+10; 

int n,k;

ll a[MAX];

ll b[MAX];

ll s[MAX];

map<ll, int>mp;

int lowbit(int x)

{

    return (x&-x);

}

 

void modify(int x,int num)

{

    while(x<=n+1){

        a[x]+=(long long)num;

        x+=lowbit(x);

    }

}

 

long long sum(int x)

{

    long long ans=0;

    while(x>0){

        ans+=a[x];

        x-=lowbit(x);

    }

    return ans;

}

 

int main()

{

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

    s[0]=0;b[0]=0;

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

        int x;

        scanf("%d",&x);

        s[i]=s[i-1]+(long long)(x-k);

        b[i]=s[i];

    }

    sort(b,b+1+n);

    int tot=0;

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

        if(!mp.count(b[i]))mp[b[i]]=++tot; 

    long long cnt=0;

    memset(a,0,sizeof(a));

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

        cnt+=sum(mp[s[i]]);

        modify(mp[s[i]],1);

    }

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

    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.3168897654050897x):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace __gnu_pbds;

using namespace std;



template<typename T>

using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define loop(i,n) for(int i = 0;i < int(n);i++)

#define rloop(i,n) for(int i = int(n);i >= 0;i--)

#define range(i,a,b) for(int i = int(a);i <= int(b);i++)

#define SZ(c) int(c.size())

#define ALL(c) c.begin(), c.end()

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int,int> > vii;

typedef long long ll;

typedef pair<int, int> pii;





int main()

{



#ifndef ONLINE_JUDGE

	//freopen("in.in", "r", stdin);

	//freopen("out.in", "w", stdout);

#endif

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);



    long long ans = 0;

	long long n, k;

	cin >> n >> k;

	vector<long long> pref(n+1);

	Tree<pair<ll,int> > ms;

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

		int num;

		cin >> num;

		pref[i] = pref[i-1] + num;

		ms.insert({pref[i-1] - k * (i - 1),i});

        ans += ms.order_of_key({pref[i] - i * k + 1 , -1});

	}

	cout << ans << endl;



    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.1112855253455765x):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace __gnu_pbds;

using namespace std;



template<typename T>

using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define loop(i,n) for(int i = 0;i < int(n);i++)

#define rloop(i,n) for(int i = int(n);i >= 0;i--)

#define range(i,a,b) for(int i = int(a);i <= int(b);i++)

#define SZ(c) int(c.size())

#define ALL(c) c.begin(), c.end()

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int,int> > vii;

typedef long long ll;

typedef pair<int, int> pii;





int main()

{



#ifndef ONLINE_JUDGE

	//freopen("in.in", "r", stdin);

	//freopen("out.in", "w", stdout);

#endif

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);



    long long ans = 0;

	long long n, k;

	cin >> n >> k;

	vector<long long> pref(n+1);

	Tree<pair<ll,int> > ms;

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

		int num;

		cin >> num;

		pref[i] = pref[i-1] + num;

		ms.insert({pref[i-1] - k * (i - 1),i});

        ans += ms.order_of_key({pref[i] - i * k + 1 , -1});

	}

	cout << ans << endl;



    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.8715621632247323x):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace __gnu_pbds;

using namespace std;



template<typename T>

using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define loop(i,n) for(int i = 0;i < int(n);i++)

#define rloop(i,n) for(int i = int(n);i >= 0;i--)

#define range(i,a,b) for(int i = int(a);i <= int(b);i++)

#define SZ(c) int(c.size())

#define ALL(c) c.begin(), c.end()

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int,int> > vii;

typedef long long ll;

typedef pair<int, int> pii;





int main()

{



#ifndef ONLINE_JUDGE

	//freopen("in.in", "r", stdin);

	//freopen("out.in", "w", stdout);

#endif

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);



    long long ans = 0;

	long long n, k;

	cin >> n >> k;

	vector<long long> pref(n+1);

	Tree<pair<ll,int> > ms;

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

		int num;

		cin >> num;

		pref[i] = pref[i-1] + num;

		ms.insert({pref[i-1] - k * (i - 1),i});

        ans += ms.order_of_key({pref[i] - i * k + 1 , -1});

	}

	cout << ans << endl;



    return 0;

}
// Slower C++ solution:
#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;

} 

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace __gnu_pbds;

using namespace std;



template<typename T>

using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define loop(i,n) for(int i = 0;i < int(n);i++)

#define rloop(i,n) for(int i = int(n);i >= 0;i--)

#define range(i,a,b) for(int i = int(a);i <= int(b);i++)

#define SZ(c) int(c.size())

#define ALL(c) c.begin(), c.end()

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int,int> > vii;

typedef long long ll;

typedef pair<int, int> pii;





int main()

{



#ifndef ONLINE_JUDGE

	//freopen("in.in", "r", stdin);

	//freopen("out.in", "w", stdout);

#endif

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);



    long long ans = 0;

	long long n, k;

	cin >> n >> k;

	vector<long long> pref(n+1);

	Tree<pair<ll,int> > ms;

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

		int num;

		cin >> num;

		pref[i] = pref[i-1] + num;

		ms.insert({pref[i-1] - k * (i - 1),i});

        ans += ms.order_of_key({pref[i] - i * k + 1 , -1});

	}

	cout << ans << endl;



    return 0;

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

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<map>

using namespace std;

 

const int MAXN=200005;

 

int n,k;

long long a[MAXN],s[MAXN],b[MAXN];

map<long long,int> mp;

 

int lowbit(int x)

{

    return (x&-x);

}

 

void modify(int x,int num)

{

    while(x<=n+1){

        a[x]+=(long long)num;

        x+=lowbit(x);

    }

}

 

long long sum(int x)

{

    long long ans=0;

    while(x>0){

        ans+=a[x];

        x-=lowbit(x);

    }

    return ans;

}

 

int main()

{

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

    s[0]=0;b[0]=0;

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

        int x;

        scanf("%d",&x);

        s[i]=s[i-1]+(long long)(x-k);

        b[i]=s[i];

    }

    sort(b,b+1+n);

    int tot=0;

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

        if(!mp.count(b[i]))mp[b[i]]=++tot; 

    long long cnt=0;

    memset(a,0,sizeof(a));

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

        cnt+=sum(mp[s[i]]);

        modify(mp[s[i]],1);

    }

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

    return 0;

} 

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace __gnu_pbds;

using namespace std;



template<typename T>

using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define loop(i,n) for(int i = 0;i < int(n);i++)

#define rloop(i,n) for(int i = int(n);i >= 0;i--)

#define range(i,a,b) for(int i = int(a);i <= int(b);i++)

#define SZ(c) int(c.size())

#define ALL(c) c.begin(), c.end()

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int,int> > vii;

typedef long long ll;

typedef pair<int, int> pii;





int main()

{



#ifndef ONLINE_JUDGE

	//freopen("in.in", "r", stdin);

	//freopen("out.in", "w", stdout);

#endif

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);



    long long ans = 0;

	long long n, k;

	cin >> n >> k;

	vector<long long> pref(n+1);

	Tree<pair<ll,int> > ms;

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

		int num;

		cin >> num;

		pref[i] = pref[i-1] + num;

		ms.insert({pref[i-1] - k * (i - 1),i});

        ans += ms.order_of_key({pref[i] - i * k + 1 , -1});

	}

	cout << ans << endl;



    return 0;

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

#include<algorithm>

#include<cmath>

#include<string.h>

#include<cstdio>

#include<map>

using namespace std;

typedef long long ll;

const int MAX=200000+10; 

int n,k;

ll a[MAX];

ll b[MAX];

ll s[MAX];

map<ll, int>mp;

int lowbit(int x)

{

    return (x&-x);

}

 

void modify(int x,int num)

{

    while(x<=n+1){

        a[x]+=(long long)num;

        x+=lowbit(x);

    }

}

 

long long sum(int x)

{

    long long ans=0;

    while(x>0){

        ans+=a[x];

        x-=lowbit(x);

    }

    return ans;

}

 

int main()

{

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

    s[0]=0;b[0]=0;

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

        int x;

        scanf("%d",&x);

        s[i]=s[i-1]+(long long)(x-k);

        b[i]=s[i];

    }

    sort(b,b+1+n);

    int tot=0;

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

        if(!mp.count(b[i]))mp[b[i]]=++tot; 

    long long cnt=0;

    memset(a,0,sizeof(a));

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

        cnt+=sum(mp[s[i]]);

        modify(mp[s[i]],1);

    }

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

    return 0;

} 

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace __gnu_pbds;

using namespace std;



template<typename T>

using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define loop(i,n) for(int i = 0;i < int(n);i++)

#define rloop(i,n) for(int i = int(n);i >= 0;i--)

#define range(i,a,b) for(int i = int(a);i <= int(b);i++)

#define SZ(c) int(c.size())

#define ALL(c) c.begin(), c.end()

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int,int> > vii;

typedef long long ll;

typedef pair<int, int> pii;





int main()

{



#ifndef ONLINE_JUDGE

	//freopen("in.in", "r", stdin);

	//freopen("out.in", "w", stdout);

#endif

	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);



    long long ans = 0;

	long long n, k;

	cin >> n >> k;

	vector<long long> pref(n+1);

	Tree<pair<ll,int> > ms;

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

		int num;

		cin >> num;

		pref[i] = pref[i-1] + num;

		ms.insert({pref[i-1] - k * (i - 1),i});

        ans += ms.order_of_key({pref[i] - i * k + 1 , -1});

	}

	cout << ans << endl;



    return 0;

}