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

#include<stdio.h>

#include<string.h>

#include<math.h>

#include<queue>

#include<algorithm>

#define N 200500

#define LL long long

#define mem(a,b) memset(a,b,sizeof(a));

using namespace std;

LL sum[N],t[N];

LL tree[N];

int n,k,a,m,nn;

void add(int x)

{

    while(x<=nn)

    {

        tree[x]++;

        x+=x&-x;

    }

}

LL query(int x)

{

    LL num=0;

    while(x)

    {

        num+=tree[x];

        x-=x&-x;

    }

    return num;

}

int main()

{

    mem(t,0);

    mem(tree,0);

    mem(sum,0);

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

    nn=n+10;

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

    {

        scanf("%d",&a);

        t[i]=sum[i]=sum[i-1]+a-k;

    }

    sort(t,t+n+1);

    m=unique(t,t+n+1)-t;

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

        sum[i]=lower_bound(t,t+m+1,sum[i])-t+1;

    LL ans=0;

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

    {

        ans+=query(sum[i]);

        add(sum[i]);

    }

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

}


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

using namespace std;

long long aa;bool bb;char ch;

long long scan()

{

	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');

	ch=='-'?(bb=1,aa=0):(bb=0,aa=ch-48);

	while(ch=getchar(),(ch>='0'&&ch<='9'))

		aa=aa*10+ch-48;

	return (bb?(-aa):(aa));

} 

//用树状数组求逆序数  

long long Length;

struct Node  

{  

    long long data;  

    long long pos;  

};  

Node seq[200010];  

long long TreeArray[200010]; 



long long LowBit(long long num)  

{  

    return num&(num^(num-1));  

}  

long long cmp(Node num1,Node num2)  

{  

	if(num2.data==num1.data)

		return num1.pos<num2.pos;

    return num1.data>num2.data;  

}  

long long sum(long long pos)  

{  

    long long result=0;  

    while (pos)  

    {  

        result+=TreeArray[pos];  

        pos-=LowBit(pos);  

    }  

    return result;  

}  

void INC(long long pos)  

{  

    while(pos<=Length)  

    {  

        TreeArray[pos]++;  

        pos+=LowBit(pos);  

    }  

}  

void insertNum(long long &reverseNum)  

{  

    for (long long i=1;i<=Length;i++)  

    {  

        reverseNum+=sum(seq[i].pos); 

        //cout<<i<<" "<<seq[i].data<<"\t"<<seq[i].pos<<"\t"<<reverseNum<<endl;

        INC(seq[i].pos);   

    }  

}  

long long n,k;

long long arr[200010];

int main()  

{  

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

	Length=n+1;

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

		arr[i]=scan()-k;

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

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

	seq[1].data=0;

	seq[1].pos=1;

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

    {  

        seq[i+1].data=-arr[i];  

    	

        seq[i+1].pos=i+1; 

    }  

    

    //从大到小排序

    sort(seq+1,seq+Length+1,cmp);

    

    //for(int i=1;i<=Length;i++)  

	//	cout<<seq[i].data<<" "<<seq[i].pos<<endl;

	//cout<<endl;

    long long reverseNum=0;  

    insertNum(reverseNum); 

    cout<<reverseNum<<endl;

    return 0;  

}
// Slower C++ solution:
#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.473249838857516x):
#include<iostream>

#include<stdio.h>

#include<vector>

#include<cmath>

#include<queue>

#include<string.h>

#include<map>

#include<set>

#include<algorithm>

#define ll long long

#define pi pair < ll,ll >

#define mp(a,b) make_pair(a,b)

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

#define N 300004

#define INF 1e9+7



using namespace std;



ll n,k,ar[N],ans,cnt;

ll sum[N];

ll seg[4*N];

vector < ll > vals;

map < ll,ll > mapper;



ll get_sum(ll i,ll j)

{

    if(i == 0)

        return sum[j];



    return sum[j] - sum[i-1];

}



ll query(ll low,ll high,ll pos,ll slow)

{

    if(high <= slow)

        return seg[pos];

    if(low > slow)

        return 0;



    ll mid = (low+high)/2;



    return query(low,mid,pos*2+1,slow)+query(mid+1,high,pos*2+2,slow);

}



void update(ll low,ll high,ll pos,ll slow)

{

    if(low == slow && low == high)

    {

        seg[pos]++;

        return;

    }

    if(low > slow || high < slow)

        return;



    ll mid = (low+high)/2;



    update(low,mid,pos*2+1,slow);

    update(mid+1,high,pos*2+2,slow);

    seg[pos] = seg[pos*2+1] + seg[pos*2+2];

    return;

}



int main()

{

    ios_base::sync_with_stdio(false);



    cin >> n >> k;



    rep(i,0,n)

    {

        cin >> ar[i];



        ar[i] -= k;



        if(i == 0)

            sum[i] = ar[i];

        else

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



        vals.push_back(sum[i]);

    }



    vals.push_back(0);

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



    rep(i,0,vals.size())

    {

        if(!mapper[vals[i]])

        {

            mapper[vals[i]] = cnt;

            cnt++;

        }

    }



    update(0,cnt,0,mapper[0]);



    rep(i,0,n)

    {

   //     cout << sum[i] << " " << mapper[sum[i]] << " " << query(0,cnt,0,mapper[sum[i]]) << endl;

        ans += query(0,cnt,0,mapper[sum[i]]);

        update(0,cnt,0,mapper[sum[i]]);

    }



    cout << ans;



    return 0;

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

#include<stdio.h>

#include<string.h>

#include<math.h>

#include<queue>

#include<algorithm>

#define N 200500

#define LL long long

#define mem(a,b) memset(a,b,sizeof(a));

using namespace std;

LL sum[N],t[N];

LL tree[N];

int n,k,a,m,nn;

void add(int x)

{

    while(x<=nn)

    {

        tree[x]++;

        x+=x&-x;

    }

}

LL query(int x)

{

    LL num=0;

    while(x)

    {

        num+=tree[x];

        x-=x&-x;

    }

    return num;

}

int main()

{

    mem(t,0);

    mem(tree,0);

    mem(sum,0);

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

    nn=n+10;

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

    {

        scanf("%d",&a);

        t[i]=sum[i]=sum[i-1]+a-k;

    }

    sort(t,t+n+1);

    m=unique(t,t+n+1)-t;

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

        sum[i]=lower_bound(t,t+m+1,sum[i])-t+1;

    LL ans=0;

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

    {

        ans+=query(sum[i]);

        add(sum[i]);

    }

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

}


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

#include<stdio.h>

#include<vector>

#include<cmath>

#include<queue>

#include<string.h>

#include<map>

#include<set>

#include<algorithm>

#define ll long long

#define pi pair < ll,ll >

#define mp(a,b) make_pair(a,b)

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

#define N 300004

#define INF 1e9+7



using namespace std;



ll n,k,ar[N],ans,cnt;

ll sum[N];

ll seg[4*N];

vector < ll > vals;

map < ll,ll > mapper;



ll get_sum(ll i,ll j)

{

    if(i == 0)

        return sum[j];



    return sum[j] - sum[i-1];

}



ll query(ll low,ll high,ll pos,ll slow)

{

    if(high <= slow)

        return seg[pos];

    if(low > slow)

        return 0;



    ll mid = (low+high)/2;



    return query(low,mid,pos*2+1,slow)+query(mid+1,high,pos*2+2,slow);

}



void update(ll low,ll high,ll pos,ll slow)

{

    if(low == slow && low == high)

    {

        seg[pos]++;

        return;

    }

    if(low > slow || high < slow)

        return;



    ll mid = (low+high)/2;



    update(low,mid,pos*2+1,slow);

    update(mid+1,high,pos*2+2,slow);

    seg[pos] = seg[pos*2+1] + seg[pos*2+2];

    return;

}



int main()

{

    ios_base::sync_with_stdio(false);



    cin >> n >> k;



    rep(i,0,n)

    {

        cin >> ar[i];



        ar[i] -= k;



        if(i == 0)

            sum[i] = ar[i];

        else

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



        vals.push_back(sum[i]);

    }



    vals.push_back(0);

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



    rep(i,0,vals.size())

    {

        if(!mapper[vals[i]])

        {

            mapper[vals[i]] = cnt;

            cnt++;

        }

    }



    update(0,cnt,0,mapper[0]);



    rep(i,0,n)

    {

   //     cout << sum[i] << " " << mapper[sum[i]] << " " << query(0,cnt,0,mapper[sum[i]]) << endl;

        ans += query(0,cnt,0,mapper[sum[i]]);

        update(0,cnt,0,mapper[sum[i]]);

    }



    cout << ans;



    return 0;

}
// Slower C++ solution:
#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.495539827360275x):
#include <bits/stdc++.h> 

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define int long long

#define ld double

#define fi first

#define se second

#define pb push_back

#define pii pair<int,int>

#define all(x) (x).begin(), (x).end()

const int MOD =1e9+7;

int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}

const int N=2*1e5+2,M=20;

typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set s;

int32_t main(){

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	#ifdef LOCAL

	freopen("input.txt", "r", stdin);

	// freopen("out10.txt","w",stdout);

	#endif

	int n,k;

	cin>>n>>k;

	int a[n];

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

	{

		cin>>a[i];

	}

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

	s.insert({0-(-1)*k,-1});

	int ans=0;

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

	{

		int x=a[i]-k*i;

		int get=s.order_of_key({x+1,-1e12});

		ans+=get;

		// cout<<get<<" ";

		s.insert({x,i});

	}

	cout<<ans;

}

// i, j

// (10-0)/(1)>=26

// (sum[j]-sum[i])/(j-i)>=k

// sum[j]-sum[i]>=k*j-k*i

// sum[j]-k*j>=sum[i]-k*i

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

#include<stdio.h>

#include<string.h>

#include<math.h>

#include<queue>

#include<algorithm>

#define N 200500

#define LL long long

#define mem(a,b) memset(a,b,sizeof(a));

using namespace std;

LL sum[N],t[N];

LL tree[N];

int n,k,a,m,nn;

void add(int x)

{

    while(x<=nn)

    {

        tree[x]++;

        x+=x&-x;

    }

}

LL query(int x)

{

    LL num=0;

    while(x)

    {

        num+=tree[x];

        x-=x&-x;

    }

    return num;

}

int main()

{

    mem(t,0);

    mem(tree,0);

    mem(sum,0);

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

    nn=n+10;

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

    {

        scanf("%d",&a);

        t[i]=sum[i]=sum[i-1]+a-k;

    }

    sort(t,t+n+1);

    m=unique(t,t+n+1)-t;

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

        sum[i]=lower_bound(t,t+m+1,sum[i])-t+1;

    LL ans=0;

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

    {

        ans+=query(sum[i]);

        add(sum[i]);

    }

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

}


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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

#define int long long

#define ld double

#define fi first

#define se second

#define pb push_back

#define pii pair<int,int>

#define all(x) (x).begin(), (x).end()

const int MOD =1e9+7;

int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}

const int N=2*1e5+2,M=20;

typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set s;

int32_t main(){

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	#ifdef LOCAL

	freopen("input.txt", "r", stdin);

	// freopen("out10.txt","w",stdout);

	#endif

	int n,k;

	cin>>n>>k;

	int a[n];

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

	{

		cin>>a[i];

	}

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

	s.insert({0-(-1)*k,-1});

	int ans=0;

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

	{

		int x=a[i]-k*i;

		int get=s.order_of_key({x+1,-1e12});

		ans+=get;

		// cout<<get<<" ";

		s.insert({x,i});

	}

	cout<<ans;

}

// i, j

// (10-0)/(1)>=26

// (sum[j]-sum[i])/(j-i)>=k

// sum[j]-sum[i]>=k*j-k*i

// sum[j]-k*j>=sum[i]-k*i

//
// Slower C++ solution:
#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.4710659168848883x):
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#include <chrono>



using namespace __gnu_pbds;

using namespace std;



#define ll long long int

#define pi pair<ll,ll>

#define ordered_set tree<pi, null_type,less<pi >, rb_tree_tag,tree_order_statistics_node_update>

// order_of_key (val): returns the no. of values less than val

// find_by_order (k): returns the kth largest element.(0-based)



#define ld long double

#define ff first

#define ss second

#define pb push_back

#define pii pair<ll,pi >

#define ppi pair<pi,ll>

#define ppp pair<pi,pi >

#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 

#define all(X) X.begin(),X.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



// for pair comparison function(ascending order) use return (i1.ff < i2.ff);



/* string operations :

   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]

   __builtin_popcount(n) : no. of set bits in n.

*/



const int M = (1<<20)+5;

const int md = 1e9+7;



priority_queue<ll,vector<ll >,greater<ll > > pq;



ll pwr(ll a,ll n,ll m)

{

	ll p=1;

	while(n>0)

	{

		if(n%2==1)

			p=(p*a)%m;

		a=(a*a)%m;

		n=n/2;

	}

	return p;

}



ordered_set os;

ll sm[M];



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);



	ll n,k,ans = 0,i,t;



	cin >> n >> k;

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

	{

		cin >> t;

		sm[i] = sm[i-1]+t;

	}



	os.insert(pi(0,0));



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

	{

		ans += os.order_of_key(pi(sm[i]-k*i,i));

		os.insert(pi(sm[i]-k*i,i));

	}



	cout << ans << "\n";

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

#include<stdio.h>

#include<string.h>

#include<math.h>

#include<queue>

#include<algorithm>

#define N 200500

#define LL long long

#define mem(a,b) memset(a,b,sizeof(a));

using namespace std;

LL sum[N],t[N];

LL tree[N];

int n,k,a,m,nn;

void add(int x)

{

    while(x<=nn)

    {

        tree[x]++;

        x+=x&-x;

    }

}

LL query(int x)

{

    LL num=0;

    while(x)

    {

        num+=tree[x];

        x-=x&-x;

    }

    return num;

}

int main()

{

    mem(t,0);

    mem(tree,0);

    mem(sum,0);

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

    nn=n+10;

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

    {

        scanf("%d",&a);

        t[i]=sum[i]=sum[i-1]+a-k;

    }

    sort(t,t+n+1);

    m=unique(t,t+n+1)-t;

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

        sum[i]=lower_bound(t,t+m+1,sum[i])-t+1;

    LL ans=0;

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

    {

        ans+=query(sum[i]);

        add(sum[i]);

    }

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

}


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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#include <chrono>



using namespace __gnu_pbds;

using namespace std;



#define ll long long int

#define pi pair<ll,ll>

#define ordered_set tree<pi, null_type,less<pi >, rb_tree_tag,tree_order_statistics_node_update>

// order_of_key (val): returns the no. of values less than val

// find_by_order (k): returns the kth largest element.(0-based)



#define ld long double

#define ff first

#define ss second

#define pb push_back

#define pii pair<ll,pi >

#define ppi pair<pi,ll>

#define ppp pair<pi,pi >

#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 

#define all(X) X.begin(),X.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



// for pair comparison function(ascending order) use return (i1.ff < i2.ff);



/* string operations :

   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]

   __builtin_popcount(n) : no. of set bits in n.

*/



const int M = (1<<20)+5;

const int md = 1e9+7;



priority_queue<ll,vector<ll >,greater<ll > > pq;



ll pwr(ll a,ll n,ll m)

{

	ll p=1;

	while(n>0)

	{

		if(n%2==1)

			p=(p*a)%m;

		a=(a*a)%m;

		n=n/2;

	}

	return p;

}



ordered_set os;

ll sm[M];



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);



	ll n,k,ans = 0,i,t;



	cin >> n >> k;

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

	{

		cin >> t;

		sm[i] = sm[i-1]+t;

	}



	os.insert(pi(0,0));



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

	{

		ans += os.order_of_key(pi(sm[i]-k*i,i));

		os.insert(pi(sm[i]-k*i,i));

	}



	cout << ans << "\n";

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

#include<stdio.h>

#include<string.h>

#include<math.h>

#include<queue>

#include<algorithm>

#define N 200500

#define LL long long

#define mem(a,b) memset(a,b,sizeof(a));

using namespace std;

LL sum[N],t[N];

LL tree[N];

int n,k,a,m,nn;

void add(int x)

{

    while(x<=nn)

    {

        tree[x]++;

        x+=x&-x;

    }

}

LL query(int x)

{

    LL num=0;

    while(x)

    {

        num+=tree[x];

        x-=x&-x;

    }

    return num;

}

int main()

{

    mem(t,0);

    mem(tree,0);

    mem(sum,0);

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

    nn=n+10;

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

    {

        scanf("%d",&a);

        t[i]=sum[i]=sum[i-1]+a-k;

    }

    sort(t,t+n+1);

    m=unique(t,t+n+1)-t;

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

        sum[i]=lower_bound(t,t+m+1,sum[i])-t+1;

    LL ans=0;

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

    {

        ans+=query(sum[i]);

        add(sum[i]);

    }

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

}


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

}

ll sum(int x)

{

	ll ans=0;

	while(x>0)

	{

		ans+=a[x];

		x-=lowbit(x);

	}

	return ans;

}

void inite(int x,int num)//维护前缀数组a 

{

    while(x<=n+1){

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

        x+=lowbit(x);

    }

}

int main()

{

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

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

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

	{	

		int t;

		scanf("%d",&t);

		s[i]=s[i-1]+(long long)(t-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;

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

	ll res=0;

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

	{

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

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

	}

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

return 0;

}
// Slower C++ solution:
#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.472221790585355x):
#include <bits/stdc++.h>

using namespace std;



#define int long long

#define fi first

#define se second

#define sz(x) (int)(x).size()

#define all(x) (x).begin(), (x).end()

#define yn(x) ((x) ? "YES" : "NO")



typedef pair <int, int> ii;

typedef pair <int, ii> iii;



const int siz = 2e5 + 10;

const int SIZ = 2e5 + 10;

const int mod = 1e9 + 7;

const int maxx = 2e9;

const int MAXX = 1e18;

const string file = "data";



int n;

int psum[siz];



void compress() {

    vector <ii> data; /// value, index;

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

        data.push_back(ii(psum[i], i));

    }



    sort (all(data));



    int num = 0, prv = MAXX;

    for (auto &x : data) {

        if (x.fi != prv) {

            prv = x.fi;

            num++;

        }

        psum[x.se] = num;

    }

}



int fen[SIZ];



void updatePos(int index, int value) {

    for (int i = index; i < SIZ; i += i & (-i)) {

        fen[i] += value;

    }

}



int getSum(int index) {

    int sum = 0;

    for (int i = index; i > 0; i -= i & (-i)) {

        sum += fen[i];

    }

    return sum;

}



int32_t main() {

    ios::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);



//    freopen ((file + ".inp").c_str(), "r", stdin);

//    freopen ((file + ".out").c_str(), "w", stdout);



    int k;

    cin >> n >> k;



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

        int a;

        cin >> a;



        psum[i] = psum[i - 1] + a - k;

    }



    compress();



    int ans = 0;

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

        ans += getSum(psum[i]);

        updatePos(psum[i], 1);

    }



    cout << ans << "\n";



//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";



    return 0;

}