Language: C++

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

Compiler output:
a.cc:12:18: error: in-class initialization of static data member 'std::mt19937 node::rd' of non-literal type
   12 |   static mt19937 rd = mt19937(time(0));
      |                  ^~
a.cc:12:38: error: call to non-'constexpr' function 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mersenne_twister_engine(result_type) [with _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253; result_type = long unsigned int]'
   12 |   static mt19937 rd = mt19937(time(0));
      |                                      ^
In file included from /usr/include/c++/14/random:48,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:179,
                 from a.cc:1:
/usr/include/c++/14/bits/random.h:647:7: note: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mersenne_twister_engine(result_type) [with _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253; result_type = long unsigned int]' declared here
  647 |       mersenne_twister_engine(result_type __sd)
      |       ^~~~~~~~~~~~~~~~~~~~~~~