stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

vector<bool> bs(2);

void f(int n)

  {if (n <= 1) return;

  bs.resize(n + 1, true);

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

    if (bs[i]) for (int j = i + i; j <= n; j += i) bs[j] = false;}

int main()

  {int N; cin >> N;

  f(55555);

  int c = 0;

  for (int j = 2; j <= 55555 and c < N; ++j)

    if (bs[j] and j % 5 == 1) {++c; cout << j << (c == N ? "\n" : " ");}}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

bool f(int64_t n)

  {if (n <= 1) return false;

  for (auto i = 2LL; i * i <= n; ++i) if (!(n % i)) return false;

  return true;}

int main()

  {int N; cin >> N;

  for (int i = 2; i <= 55555 and N; ++i)

    if (f(i) and i % 5 == 1) {--N; cout << i << (N ? " " : "\n");}}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	int mx = 55556;

	vector<bool> a(mx);

	fill(a.begin(), a.end(), true);

	a[0] = a[1] = false;

	for(int i = 2; i < mx; i++) {

		if(a[i]) {

			for(int j = i * 2; j < mx; j += i) {

				a[j] = false;

			}

		}

	}

	vector<int> p;

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

		if(a[i]) {

			p.push_back(i);

		}

	}

	int n;

	cin >> n;

	int cnt = 0;

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

		if(p[i] % 5 == 1) {

			cout << p[i] << " ";

			cnt++;

		}

		if(cnt == n) {

			cout << endl;

			return 0;

		}

	}

	return 0;	

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	int n;

	cin >> n;

	int cnt = 0;

	for(int i = 2; i < 55556; i++) {

		for(int j = 2; j * j <= i; j++) {

			if(i % j == 0) {

				goto NEXT;

			}

		}

		if(i % 5 == 1) {

			cout << i << " ";

			cnt++;

		}

		if(cnt == n) {

			cout << endl;

			return 0;

		}

		NEXT:;

	}

	return 0;	

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define MAXN 95555

using namespace std;



vector<int> Prime;

int flag[MAXN];

void siv() {

  Prime.push_back(2);

  for(int i = 4 ; i <= MAXN ; i += 2) flag[i] = 1;

  for(int i = 3 ; i * i <= MAXN ; i += 2) {

    if(!flag[i]) {

      for(int j = i * i , k = (i * 2) ; j <= MAXN ; j += k) {

        flag[j] = 1;

      }

    }

  }

  for(int i = 3 ; i < MAXN ; i += 2) {

    if(!flag[i]) {

      Prime.push_back(i);

    }

  }

}



int main()

{

  siv();

  int n;

  cin >> n;

  for(int i = 0 , ans = 0 ; i < Prime.size() && ans != n ; i++) {

    if(Prime[i] % 5 == 1) ans++ , printf("%d ", Prime[i]);

    //if(Prime[i] % 5 == 2) ans++ , printf("%d ", Prime[i]);

    //if(Prime[i] % 5 == 3) ans++ , printf("%d ", Prime[i]);

    //if(Prime[i] % 5 == 4) ans++ , printf("%d ", Prime[i]);

  }

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

#define maxn 200005

#define inf 0x3f3f3f3f

using namespace std;

typedef long int ll;

bool prime[60000];

int ans[60000], p;

int main()

{

    for (int i = 2; i < 60000; ++i){

        if (!prime[i]) for (int j = 2; j * i < 60000; ++j) prime[j * i] = 1;

    }

    int n;

    scanf("%d", &n);

    for (int i = 2; i <= 55555; ++i) if (!prime[i] && i % 5 == 1) ans[++p] = i;

    for (int i = 1; i < n; ++i) printf("%d ", ans[i]);

    printf("%d\n", ans[n]);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

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

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

template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}

template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}



vector<int> sieve(int n){

    vector<bool> is_prime(n+1, true);

    vector<int> p;

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

        if(is_prime[i]) {

            for(int j=2*i; j<=n; j+=i){

                is_prime[j] = false;

            }

            p.emplace_back(i);

        }

    }

    return p;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    int n; cin>>n;

    vector<int> p = sieve(55555);

    int cnt = 0;

    for(auto a : p){

        if(a % 5 == 1){

            cout<<a<<" ";

            cnt++;

        }

        if(cnt == n) break;

    }

    cout<<endl;

    return 0;

}

// abc096_d

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

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

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

template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}

template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}



bool isPrime(int x){

    int i;

    if(x < 2)return 0;

    else if(x == 2) return 1;

    if(x%2 == 0) return 0;

    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;

    return 1;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    int n; cin>>n;

    int cnt = 0;

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

        if(isPrime(i) && i%5==1){

            cout<<i<<" ";

            cnt++;

        } 

        if(cnt==n) break;

    }

    cout<<endl;

    return 0;

}

// abc096_d

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;  

}  


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

}


// Optimized solution to the same problem (faster):
#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;  

}  


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <vector>

#include <iostream>

using namespace std;



typedef long long int LL;

const LL INF=1000000000000000ll;

const int maxn=100000*64;

struct ACM

{

    struct Node

    {

        LL val;

        int lson,rson;

    }seg[maxn];

    int sz;

    int newnode()

    {

        sz++;

        seg[sz].val=0;

        seg[sz].rson=-1;

        seg[sz].lson=-1;

        return sz;

    }

    void init()

    {

        sz=-1;

    }

    void update(int &root,LL l,LL r,LL val)

    {

        if(root==-1) root=newnode();

        seg[root].val++;

        if(l==r) return ;

        LL mid=(l+r)>>1;

        if(val<=mid) update(seg[root].lson,l,mid,val);

        else update(seg[root].rson,mid+1,r,val);

    }

    LL query(int root,LL l,LL r,LL ql,LL qr)

    {

        if(root==-1) return 0;

        if(l==ql&&r==qr) return seg[root].val;

        LL mid=(l+r)>>1;

        if(qr<=mid) return query(seg[root].lson,l,mid,ql,qr);

        else if(ql>mid) return query(seg[root].rson,mid+1,r,ql,qr);

        else return query(seg[root].lson,l,mid,ql,mid)+query(seg[root].rson,mid+1,r,mid+1,qr);

    }

    /**

    void debug(int i)

    {

        if(i==-1) return ;

        printf("node=%d val=%lld lson=%d rson=%d\n",i,seg[i].val,seg[i].lson,seg[i].rson);

        debug(seg[i].lson),debug(seg[i].rson);

    }

    */

}AC;



int main()

{

    int n,k,root=-1;

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

    LL sum=0,ans=0;

    AC.init();

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

    {

        int num;

        scanf("%d",&num);

		num-=k;

        AC.update(root,-INF,INF,sum);

        sum+=num;

        ans+=AC.query(root,-INF,INF,-INF,sum);

    }

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

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long ll;



const int MAX_N = 200000;



ll cnt = 0ll;

int n;

ll K, a[MAX_N + 10], s[MAX_N + 10], b[MAX_N + 10], t[MAX_N + 10];



void merge_sort(ll* A, int x, int y, ll* T) {

    if (y - x > 1) {

        int m = x + (y - x) / 2;

        int p = x, q = m, i = x;

        merge_sort(A, x, m, T);

        merge_sort(A, m, y, T);

        while (p < m || q < y) {

            if (q >= y || (p < m && A[p] <= A[q])) T[i++] = A[p++];

            else { T[i++] = A[q++]; cnt += m - p; }

        }

        for (i = x; i < y; i++) A[i] = T[i];

    }

}



int main() {

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

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

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

        s[i] = a[i] + (i ? s[i - 1] : 0);

        b[i] = (i ? s[i - 1] : 0) - K * i;

    }

    b[n] = s[n - 1] - n * K;

    merge_sort(b, 0, n + 1, t);

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define maxn 200010

#define lowb(x) (x & (-x))

int t[maxn], n, c[maxn], d[maxn];

long long a[maxn], b[maxn];

void add(int x) {

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

		t[i]++;

	}

}

long long query(int x) {

	long long s = 0;

	for (int i = x; i > 0; i -= lowb(i)) {

		s += t[i];

	}

	return s;

}

int cmp(int i, int j) {

	return b[i] < b[j];

}

int main()

{

	int k;

	

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

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

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

	}

	b[0] = 0;

	c[0] = 0;

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

		c[i] = i;

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

	}

	stable_sort(c, c + n + 1, cmp);

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

		d[c[i]] = i + 1;

	}

	long long s = 0;

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

		s += query(d[i]);

		add(d[i]);

	}

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

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long ll;



const int MAX_N = 200000;



ll cnt = 0ll;

int n;

ll K, a[MAX_N + 10], s[MAX_N + 10], b[MAX_N + 10], t[MAX_N + 10];



void merge_sort(ll* A, int x, int y, ll* T) {

    if (y - x > 1) {

        int m = x + (y - x) / 2;

        int p = x, q = m, i = x;

        merge_sort(A, x, m, T);

        merge_sort(A, m, y, T);

        while (p < m || q < y) {

            if (q >= y || (p < m && A[p] <= A[q])) T[i++] = A[p++];

            else { T[i++] = A[q++]; cnt += m - p; }

        }

        for (i = x; i < y; i++) A[i] = T[i];

    }

}



int main() {

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

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

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

        s[i] = a[i] + (i ? s[i - 1] : 0);

        b[i] = (i ? s[i - 1] : 0) - K * i;

    }

    b[n] = s[n - 1] - n * K;

    merge_sort(b, 0, n + 1, t);

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds; 

using namespace std;

template<class T> using rset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 



using ll = long long;

using db = double;

using vi = vector<int>;

const int maxn = 1000000; 



ll n, k; 

ll a[maxn], s[maxn]; 

rset<pair<ll,int>> S; 



int main() {

	cin>>n>>k; 

	s[0] = 0; 

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

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

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

	}

	S.insert({s[0],0}); 

	ll ans = 0; 

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

		S.insert({s[i],i}); 

		ans += S.order_of_key({s[i],i});

	}

	cout<<ans<<endl; 

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long ll;



const int MAX_N = 200000;



ll cnt = 0ll;

int n;

ll K, a[MAX_N + 10], s[MAX_N + 10], b[MAX_N + 10], t[MAX_N + 10];



void merge_sort(ll* A, int x, int y, ll* T) {

    if (y - x > 1) {

        int m = x + (y - x) / 2;

        int p = x, q = m, i = x;

        merge_sort(A, x, m, T);

        merge_sort(A, m, y, T);

        while (p < m || q < y) {

            if (q >= y || (p < m && A[p] <= A[q])) T[i++] = A[p++];

            else { T[i++] = A[q++]; cnt += m - p; }

        }

        for (i = x; i < y; i++) A[i] = T[i];

    }

}



int main() {

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

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

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

        s[i] = a[i] + (i ? s[i - 1] : 0);

        b[i] = (i ? s[i - 1] : 0) - K * i;

    }

    b[n] = s[n - 1] - n * K;

    merge_sort(b, 0, n + 1, t);

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

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

    }

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

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long ll;



const int MAX_N = 200000;



ll cnt = 0ll;

int n;

ll K, a[MAX_N + 10], s[MAX_N + 10], b[MAX_N + 10], t[MAX_N + 10];



void merge_sort(ll* A, int x, int y, ll* T) {

    if (y - x > 1) {

        int m = x + (y - x) / 2;

        int p = x, q = m, i = x;

        merge_sort(A, x, m, T);

        merge_sort(A, m, y, T);

        while (p < m || q < y) {

            if (q >= y || (p < m && A[p] <= A[q])) T[i++] = A[p++];

            else { T[i++] = A[q++]; cnt += m - p; }

        }

        for (i = x; i < y; i++) A[i] = T[i];

    }

}



int main() {

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

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

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

        s[i] = a[i] + (i ? s[i - 1] : 0);

        b[i] = (i ? s[i - 1] : 0) - K * i;

    }

    b[n] = s[n - 1] - n * K;

    merge_sort(b, 0, n + 1, t);

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

    return 0;

}

// Fastest known solution for this problem: