For this Question: Given an array A of size N, find the count of pairs of indices <b>i</b> and <b>j</b> such that <b>1 <= i < j <= N</b> and the <b>mean</b> of elements at these indices is at least <b>K</b>.
More formally, you have to find the number of indices <b>i</b> and <b>j</b> such that <b>1 <= i < j <= N</b> and (A<sub>i</sub> + A<sub>j</sub>)/2 >= KFirst line of the input contains two integers N and K.
The second line contains N space seperated integers A<sub>i</sub>

Constraints:
1 <= N <= 10<sup>5</sup>
1 <= K <= 10<sup>9</sup>
1 <= A<sub>i</sub> <= 10<sup>9</sup>Print the number of pairs satisfying the above condition in array A.Sample Input:
5 6
4 7 8 2 5

Sample Output:
4

Explaination:
The following pairs of indices satisfy the condition (1-based indexing)
(1, 3) -> (4 + 8)/2 = 6
(2, 3) -> (7 + 8)/2 = 7.5
(2, 5) -> (7 + 5)/2 = 6
(3, 5) -> (8 + 5)/2 = 6.5
There are no more pairs of indices that satisfy the above condition., I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define int long long
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using T = pair<int, int>;

typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;

void solve() {
    int n, k;
    cin >> n >> k;
    assert(1 <= n <= 1e5);
    assert(1 <= k <= 1e9);
    vector<int> a(n);
    for (auto &i : a) cin >> i, assert(1 <= i <= 1e9);
    sort(all(a));
    int ans = 0;
    int req_sum = 2 * k;
    for (int i = 0; i < n; i++) {
        int x = req_sum - a[i];
        x = max(x, (int)0);
        int l = i + 1, r = n - 1, ind = n;
        while (l <= r) {
            int m = (l + r) / 2;
            if (a[m] >= x) {
                r = m - 1;
                ind = m;
            } else
                l = m + 1;
        }
        ans += n - ind;
    }
    cout << ans;
}

signed main() {
    fast int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
        if (i != t) cout << endl;
    }
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?