ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector <int> v(n);
        set <int> st;
        for (int i=0; i<n; i++) {
            cin >> v[i];
            st.insert(v[i]);
        }
        if (st.size() == 1) {
            cout << "yes\n";
            continue;
        }
        int mn = INT_MAX, pos = -1;
        for (int i=2; i<n; i ++) {
            int diff = abs(v[i] - v[i-2]);
            if (diff > 0 && diff % 2 == 0 && diff < mn) {
                mn = diff;
                pos = i;
            }
        }
        if (pos == -1) {
            cout << "no\n";
            continue;
        }
        //cout << pos << " ";
        int target;
        if (v[pos] > v[pos - 2]) target = v[pos] - mn/2;
        else target = v[pos] + mn/2;
        int tot = 0;
        for (int num: v) {
            tot += num - target;
        }
        if (tot == 0) cout << "yes\n";
        else cout << "no\n";
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector <ll> v(n);
        set <ll> st;
        for (int i=0; i<n; i++) {
            cin >> v[i];
            st.insert(v[i]);
        }
        if (st.size() == 1) {
            cout << "yes\n";
            continue;
        }
        ll mn = INT_MAX;
        int pos = -1;
        for (int i=2; i<n; i ++) {
            ll diff = abs(v[i] - v[i-2]);
            if (diff > 0 && diff % 2 == 0 && diff < mn) {
                mn = diff;
                pos = i;
            }
        }
        if (pos == -1) {
            cout << "no\n";
            continue;
        }
        //cout << pos << " ";
        ll target;
        if (v[pos] > v[pos - 2]) target = v[pos] - mn/2;
        else target = v[pos] + mn/2;
        ll tot = 0;
        for (ll num: v) {
            tot += num - target;
        }
        if (tot == 0) cout << "yes\n";
        else cout << "no\n";
    }
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int od = 0, ev = 0;
        for (int i=0; i<n; i++) {
            int x;
            cin >> x;
            if (i%2 == 0) ev += x;
            else od += x;
        }
        int eve = n / 2, ode = n / 2;
        if (n%2 != 0) eve ++;
        if (ev % eve == 0 && od % ode == 0 && ev / eve == od / ode) cout << "yes\n";
        else cout << "no\n";
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        ll od = 0, ev = 0;
        for (int i=0; i<n; i++) {
            int x;
            cin >> x;
            if (i%2 == 0) ev += x;
            else od += x;
        }
        ll eve = n / 2, ode = n / 2;
        if (n%2 != 0) eve ++;
        if (ev % eve == 0 && od % ode == 0 && ev / eve == od / ode) cout << "yes\n";
        else cout << "no\n";
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        if(r==2 || r == 3){
          cout << r << " " << r-1 << " " << r-2 << endl;
          continue;
        }
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t);
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        if(r==2 || r == 3){
          cout << r << " " << r-1 << " " << r-2 << endl;
          continue;
        }
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t)*x[i];
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        if(r==2 || r == 3){
          cout << r << " " << r-1 << " " << r-2 << endl;
          continue;
        }
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t)*x[i];
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        long long l1 = l;
        if(r-l == 2){
          cout << r << " " << r-1 << " " << r-2 << endl;
          continue;
        }
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t)*x[i];
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        if(a-2 < l){
          cout << a << " " << a-1 << " " << a+1 << endl;
          continue;
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t);
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t);
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        if(r==2 || r == 3){
          cout << r << " " << r-1 << " " << r-2 << endl;
          continue;
        }
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t);
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        long long l1 = l;
        if(r-l == 2){
          cout << r << " " << r-1 << " " << r-2 << endl;
          continue;
        }
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t)*x[i];
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        if(a-2 < l){
          cout << a << " " << a-1 << " " << a+1 << endl;
          continue;
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long t;
    cin >> t;
    while(t--){
        long long l,r;
        cin >> l >> r;
        long long l1 = l;
        if(r-l == 2){
          cout << r << " " << r-1 << " " << r-2 << endl;
          continue;
        }
        vector<long long> y;
        long long n = 0;
        while(r>0){
            y.push_back(r%2);
            r /= 2;
            n += 1;
        }
        reverse(y.begin(), y.end());
        long long t = n-1;
        vector<long long> x(n,0);
        while(l>0){
            x[t] = (l%2);
            l /= 2;
            t -= 1;
        }
        long long a = 0;
        t = n-1;
        for(long long i = 0; i<n; i++){
            if(x[i] == y[i]){
                a += pow(2, t)*x[i];
                t--;
            }
            else{
              a += pow(2,t);
              break;
            }
        }
        if(a-2 < l1){
          cout << a << " " << a-1 << " " << a+1 << endl;
          continue;
        }
        cout << a << " " << a-1 << " " << a-2 << endl;
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>

using namespace std;
// Use of data structure so will do after learning more about the STL :)

int main(){
	ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
	int n,k,  count=0;
	cin>>n>>k;
	map<int, int> mp;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		if(mp.find(a)==mp.end()) mp[a] = 1;
		else mp[a]++;
	}
	vector<int> v;
	for(auto it:mp){
		v.push_back(it.second);
	}
	sort(v.begin(), v.end());
	for(auto it:v){
		if(it>k)break;
		k-=it;
		count++;
	}
	cout<<max(v.size()-count,1)<<"\n";
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;
// Use of data structure so will do after learning more about the STL :)

int main(){
	ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
	int n,k,  count=0;
	cin>>n>>k;
	map<int, int> mp;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		if(mp.find(a)==mp.end()) mp[a] = 1;
		else mp[a]++;
	}
	vector<int> v;
	for(auto it:mp){
		v.push_back(it.second);
	}
	sort(v.begin(), v.end());
	for(auto it:v){
		if(it>k)break;
		k-=it;
		count++;
	}
	cout<<max((int)v.size()-count,1)<<"\n";
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;
// Use of data structure so will do after learning more about the STL :)

int main(){
	ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
	int n,k,  count=0;
	cin>>n>>k;
	map<int, int> mp;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		if(mp.find(a)==mp.end()) mp[a] = 1;
		else mp[a]++;
	}
	vector<int> v;
	for(auto it:mp){
		v.push_back(it.second);
	}
	sort(v.begin(), v.end());
	for(auto it:v){
		if(it>=k)break;
		k-=it;
		count++;
	}
	cout<<v.size()-count<<"\n";
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;
// Use of data structure so will do after learning more about the STL :)

int main(){
	ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
	int n,k,  count=0;
	cin>>n>>k;
	map<int, int> mp;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		if(mp.find(a)==mp.end()) mp[a] = 1;
		else mp[a]++;
	}
	vector<int> v;
	for(auto it:mp){
		v.push_back(it.second);
	}
	sort(v.begin(), v.end());
	for(auto it:v){
		if(it>=k)break;
		k-=it;
		count++;
	}
	cout<<v.size()-count<<"\n";
    }
    return 0;
}


Submission (verdict: Compilation error):
#include <bits/stdc++.h>

using namespace std;
// Use of data structure so will do after learning more about the STL :)

int main(){
	ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
	int n,k,  count=0;
	cin>>n>>k;
	map<int, int> mp;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		if(mp.find(a)==mp.end()) mp[a] = 1;
		else mp[a]++;
	}
	vector<int> v;
	for(auto it:mp){
		v.push_back(it.second);
	}
	sort(v.begin(), v.end());
	for(auto it:v){
		if(it>k)break;
		k-=it;
		count++;
	}
	cout<<max(v.size()-count,1)<<"\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
int indexcount(string &s)
{
    int i = 0;
    for (i = s.size() - 1; i > 0; i--)
    {
        if (s[i] > s[i - 1]&&s[i] - s[i - 1] != 1)
        {

            if (i == 1 && s[i] - s[i - 1] == 1)
            {
                return -1;
            }
            else
            {
                return i;
            }
        }
    }

    return -1;
}
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
       while(indexcount(s)!=-1)
       {
        int p=indexcount(s);
         s[p]=s[p]-1;
         swap(s[p],s[p-1]);
       }
       cout<<s<<endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
int indexcount(string &s)
{
    int i = 0;
    for (i = s.size() - 1; i > 0; i--)
    {
        if (s[i] > s[i - 1]&&s[i] - s[i - 1] != 1)
        {

            if (i == 1 && s[i] - s[i - 1] == 1)
            {
                return -1;
            }
            else
            {
                return i;
            }
        }
    }

    return -1;
}
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
       while(indexcount(s)!=-1)
       {
        int p=indexcount(s);
         s[p]=s[p]-1;
         swap(s[p],s[p-1]);
       }
       cout<<s<<endl;
    }
}

Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
long long indexcount(string &s)
{
    long long i = 0;
    for (i = s.size() - 1; i > 0; i--)
    {
        if (s[i] > s[i - 1]&&s[i] - s[i - 1] != 1)
        {
                return i;
        }
    }

    return -1;
}
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
       long long p=indexcount(s);
       while(p!=-1)
       {
        
         s[p]=s[p]-1;
         swap(s[p],s[p-1]);
        p=indexcount(s);
       }
       cout<<s<<endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
long long indexcount(string &s)
{
    long long i = 0;
    for (i = s.size() - 1; i > 0; i--)
    {
        if (s[i] > s[i - 1]&&s[i] - s[i - 1] != 1)
        {
                return i;
        }
    }

    return -1;
}
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
       long long p=indexcount(s);
       while(p!=-1)
       {
        
         s[p]=s[p]-1;
         swap(s[p],s[p-1]);
        p=indexcount(s);
       }
       cout<<s<<endl;
    }
}

Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    int p = -1;
    while (t--)
    {
        string s;
        cin >> s;
        for (int i = s.size() - 1; i > 0; i--)
        {
            if (s[i] > s[i - 1] && s[i] - s[i - 1] != 1)
            {
                p = i;
                break;
            }
        }
        while (p != -1)
        {

            s[p] = s[p] - 1;
            swap(s[p], s[p - 1]);
             p = -1;
                for (long long i = s.size() - 1; i > 0; i--)
                {
                    if (s[i] > s[i - 1] && s[i] - s[i - 1] != 1)
                    {
                        p = i;
                        break;
                    }
                }
               
            }
             cout << s << endl;
        }
        
    }
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    int p = -1;
    while (t--)
    {
        string s;
        cin >> s;
        for (int i = s.size() - 1; i > 0; i--)
        {
            if (s[i] > s[i - 1] && s[i] - s[i - 1] != 1)
            {
                p = i;
                break;
            }
        }
        while (p != -1)
        {

            s[p] = s[p] - 1;
            swap(s[p], s[p - 1]);
             p = -1;
                for (long long i = s.size() - 1; i > 0; i--)
                {
                    if (s[i] > s[i - 1] && s[i] - s[i - 1] != 1)
                    {
                        p = i;
                        break;
                    }
                }
               
            }
             cout << s << endl;
        }
        
    }


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    int p = -1;
    while (t--)
    {
        string s;
        cin >> s;
        
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] < s[i + 1])
            {
                int j = i;
                while (j >= 0 && (s[j] < s[j + 1] - 1))
                {
                    s[j + 1] = s[j + 1] - 1;
                    swap(s[j], s[j + 1]);
                    j--;
                }
            }
        }

        cout << s << endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define MAXN 10000001
int spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        spf[i] = i;
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<int> getFactorization(int x)
{
    vector<int> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
void debug(vector<int> v){
    for(auto j: v){
        cout << j << " " ;
    }
    cout << endl;
}
int gcd(int a, int b){
    return __gcd(a, b);
}
int lcm(int a, int b){
    return ((a*b)/(gcd(a, b)));
}
int getBit(int num, int i) {
    // Shift 1 to the left by i positions to create a mask
    int mask = 1 << i;

    // Perform bitwise AND with the mask to get the bit at position i
    int result = (num & mask) >> i;

    return result;
}
void build(vector<int>& segtree, vector<int>&a, int low, int high, int index){
        if(low==high){
            segtree[index] = a[low]; return;
        }
        int mid = (low+high)/2;
        build(segtree,a, low, mid, 2*index+1);
        build(segtree,a, mid+1, high, 2*index+2);
        segtree[index] = segtree[2*index+1]&segtree[2*index+2];
    }
int query(vector<int>& segtree, int low, int high, int index, int queryl, int queryr) {
    // No overlap: Return a default value (0)
    if (queryl > high || queryr < low) {
        return -1;
    }
    // Complete overlap: Return the value in the current segment
    if (queryl <= low && queryr >= high) {
        return segtree[index];
    }
    // Partial overlap: Recurse into both left and right children
    int mid = (low + high) / 2;
    int left_result = query(segtree, low, mid, 2 * index + 1, queryl, queryr);
    int right_result = query(segtree, mid + 1, high, 2 * index + 2, queryl, queryr);
    return (left_result & right_result);
}
int mexx(vector<int> &arr, int N)
{
    //taken fron GFG

  // sort the array
  sort(arr.begin(), arr.end());

  int mex = 0;
  for (int idx = 0; idx < N; idx++)
  {
    if (arr[idx] == mex)
    {
      // Increment mex
      mex += 1;
    }
  }

  // Return mex as answer
  return mex;
}
int ceiling(int a, int b) {
    if(a % b == 0) {
        return a/b;
    }
    return (a/b + 1);
}
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int k = r-l+1;
    int sum = 0;
    sort(a, a+n);
    for(int i = 0; i < k; i++) {
        sum += a[i];
    }
    cout << sum << endl;
}
int32_t main()
{
    int t;
    //t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
}