Doubt in Starter 142 - LENGTHX

Can anyone tell me where its failing. I cant see the testcase as I dont have the pro membership. Also whats wrong with this approach

#include "bits/stdc++.h"
#define ll long long
using namespace std;

ll power(ll b, ll e) 
{
    ll res = 1LL;
    
    while(e > 0LL) 
    {
        if(e & 1LL) 
        {
            res *= b;
        }
        
        b *= b;
        e >>= 1;
    }
    
    return res;
}


void solve()
{
	ll n, x;
	cin >> n >> x;

	vector<pair<ll, ll>> arr(n);
	vector<ll> a(n);

	for(int i = 0; i  < n; ++i)	
		cin >> arr[i].first, arr[i].second = i;

	sort(arr.begin(), arr.end());
	for(int i = 0; i < n; ++i)
		a[i] = arr[i].first;
		
	ll cnt = 0LL;
	ll smol = power(10LL, x - 1LL);
	ll large = power(10LL, x) - 1LL;
	

	
	for(ll i = 0; i < n; ++i)
	{
		ll low = smol - a[i];
		ll high = large - a[i];
		// cout << "For index " << i << ' ' << low << " & " << high << '\n';
	
		ll l = lower_bound(a.begin() + i+1, a.end(), low) - a.begin();
		ll r = upper_bound(a.begin() + i+1, a.end(), high) - a.begin();
		// cout << l << ' ' << r << '\n';
		while(l < r)
		{
			ll ori_l = max(arr[l].second, arr[i].second);
			ll ori_i = min(arr[l].second, arr[i].second);
			// cout << arr[i].second << ' ' << arr[l].second << '\n'; 
			cnt += (n - ori_l) * (ori_i+1) * 1LL;
			
			l++;
		}
	}
	
	cout << cnt << '\n';
}
 
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
 
	int t;
	cin >> t;
 
	while(t--)
	{
    	solve();
	}
 
	return 0;
}