ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: Python 3

Previous submission (verdict: Wrong answer on test 1):
import heapq

n = int(input())
for _ in range(n):
    l, k = map(int, input().split())
    input_str = input()
    arr = list(map(int, input_str.split()))

    #先排序
    arr.sort()

    # 优先级队列存储不同的数字有几组
    pq = []
    curnum = 1

    for i in range(1, l):
        if arr[i] == arr[i - 1]:
            curnum += 1
        else:
            heapq.heappush(pq, curnum)
            curnum = 1
    heapq.heappush(pq, curnum)

    #依次pop出含有最少相同数字的那一组
    while k > 0 and len(pq) > 1:
        minnum = heapq.heappop(pq)
        secondnum = heapq.heappop(pq)
        if minnum > k:
            break
        k -= minnum
        heapq.heappush(pq,minnum + secondnum)
        
    print(len(pq))


Submission (verdict: Wrong answer on test 1):
n = int(input())
for _ in range(n):
    l, k = map(int, input().split())
    input_str = input()
    arr = list(map(int, input_str.split()))

    # 先排序
    arr.sort()

    # 存储不同的数字有几组
    count = []
    curnum = 1

    for i in range(1, l):
        if arr[i] == arr[i - 1]:
            curnum += 1
        else:
            count.append(curnum)
            curnum = 1
    count.append(curnum)

    count.sort()
    sum = 0
    ans = len(count)
    for c in count:
        sum += c
        if k >= sum:
            ans -= 1
        else:
            break
    print(ans)
Problem: 2057B - Gorilla and the Exam
Language: Python 3

Previous submission (verdict: Runtime error on test 1):
import heapq

n = int(input())
for _ in range(n):
    l, k = map(int, input().split())
    input_str = input()
    arr = list(map(int, input_str.split()))

    #先排序
    arr.sort()

    # 优先级队列存储不同的数字有几组
    pq = []
    curnum = 1

    for i in range(1, l):
        if arr[i] == arr[i - 1]:
            curnum += 1
        else:
            heapq.heappush(pq, curnum)
            curnum = 1
    heapq.heappush(pq, curnum)

    #依次pop出含有最少相同数字的那一组
    while k > 0 and len(pq) > 1:
        minnum = heapq.heappop(pq)
        secondnum = heapq.heappop(pq)
        if minnum > k:
            break
        k -= minnum
        heapq.heappush(minnum + secondnum)
        
    print(len(pq))

Submission (verdict: Wrong answer on test 1):
import heapq

n = int(input())
for _ in range(n):
    l, k = map(int, input().split())
    input_str = input()
    arr = list(map(int, input_str.split()))

    #先排序
    arr.sort()

    # 优先级队列存储不同的数字有几组
    pq = []
    curnum = 1

    for i in range(1, l):
        if arr[i] == arr[i - 1]:
            curnum += 1
        else:
            heapq.heappush(pq, curnum)
            curnum = 1
    heapq.heappush(pq, curnum)

    #依次pop出含有最少相同数字的那一组
    while k > 0 and len(pq) > 1:
        minnum = heapq.heappop(pq)
        secondnum = heapq.heappop(pq)
        if minnum > k:
            break
        k -= minnum
        heapq.heappush(pq,minnum + secondnum)
        
    print(len(pq))
Problem: 2057B - Gorilla and the Exam
Language: Python 3


Submission (verdict: Runtime error on test 1):
import heapq

n = int(input())
for _ in range(n):
    l, k = map(int, input().split())
    input_str = input()
    arr = list(map(int, input_str.split()))

    #先排序
    arr.sort()

    # 优先级队列存储不同的数字有几组
    pq = []
    curnum = 1

    for i in range(1, l):
        if arr[i] == arr[i - 1]:
            curnum += 1
        else:
            heapq.heappush(pq, curnum)
            curnum = 1
    heapq.heappush(pq, curnum)

    #依次pop出含有最少相同数字的那一组
    while k > 0 and len(pq) > 1:
        minnum = heapq.heappop(pq)
        secondnum = heapq.heappop(pq)
        if minnum > k:
            break
        k -= minnum
        heapq.heappush(minnum + secondnum)
        
    print(len(pq))
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll maxSum(vector<int> a){
    if(a.size() == 1) return a[0];

    ll sum = a[0];
    vector<int> b, c;
    for(int i = 1; i < a.size(); i++){
        sum += a[i]; b.push_back(a[i] - a[i - 1]);
    }

    for(int i = b.size() - 1; i >= 0; i--) c.push_back(-b[i]);

    return max(sum, max(maxSum(b), maxSum(c)));
}

void solve(){
    int n, tmp;
    cin >> n;

    vector<int> a;
    for(int i = 0; i < n; i++){
        cin >> tmp; a.push_back(tmp);
    }

    cout << maxSum(a) << endl;
}

int main(){
    int t;
    cin >> t;

    while(t--){
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll maxSum(vector<int> a){
    if(a.size() == 1) return a[0];

    ll sum = a[0];
    vector<int> b, c;
    for(int i = 1; i < a.size(); i++){
        sum += a[i]; b.push_back(a[i] - a[i - 1]);
    }

    for(int i = b.size() - 1; i >= 0; i--) c.push_back(-b[i]);

    return max(sum, max(maxSum(b), maxSum(c)));
}

void solve(){
    int n, tmp;
    cin >> n;

    vector<int> a;
    for(int i = 0; i < n; i++){
        cin >> tmp; a.push_back(tmp);
    }

    cout << maxSum(a) << endl;
}

int main(){
    int t;
    cin >> t;

    while(t--){
        solve();
    }
}

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

map<vector<int>, ll> memo;

ll maxSum(vector<int> a){
    if(a.size() == 1) return a[0];
    if(memo.find(a) != memo.end()) return memo[a];

    ll sum = a[0];
    vector<int> b, c;
    for(int i = 1; i < a.size(); i++){
        sum += a[i]; b.push_back(a[i] - a[i - 1]);
    }

    for(int i = b.size() - 1; i >= 0; i--) c.push_back(-b[i]);

    memo[a] = max({sum, maxSum(b), maxSum(c)});
    return memo[a];
}

void solve(){
    int n, tmp;
    cin >> n;

    vector<int> a;
    for(int i = 0; i < n; i++){
        cin >> tmp; a.push_back(tmp);
    }

    cout << maxSum(a) << endl;
}

int main(){
    int t;
    cin >> t;

    while(t--){
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

map<vector<int>, ll> memo;

ll maxSum(vector<int> a){
    if(a.size() == 1) return a[0];
    if(memo.find(a) != memo.end()) return memo[a];

    ll sum = a[0];
    vector<int> b, c;
    for(int i = 1; i < a.size(); i++){
        sum += a[i]; b.push_back(a[i] - a[i - 1]);
    }

    for(int i = b.size() - 1; i >= 0; i--) c.push_back(-b[i]);

    memo[a] = max({sum, maxSum(b), maxSum(c)});
    return memo[a];
}

void solve(){
    int n, tmp;
    cin >> n;

    vector<int> a;
    for(int i = 0; i < n; i++){
        cin >> tmp; a.push_back(tmp);
    }

    cout << maxSum(a) << endl;
}

int main(){
    int t;
    cin >> t;

    while(t--){
        solve();
    }
}

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

map<vector<ll>, ll> memo;

ll maxSum(vector<ll> a){
    if(a.size() == 1) return a[0];
    if(memo.find(a) != memo.end()) return memo[a];

    ll sum = a[0];
    vector<ll> b, c;
    for(ll i = 1; i < a.size(); i++){
        sum += a[i]; b.push_back(a[i] - a[i - 1]);
    }

    for(ll i = b.size() - 1; i >= 0; i--) c.push_back(-b[i]);

    memo[a] = max({sum, maxSum(b), maxSum(c)});
    return memo[a];
}

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

    vector<ll> a;
    for(int i = 0; i < n; i++){
        cin >> tmp; a.push_back(tmp);
    }

    cout << maxSum(a) << endl;
}

int main(){
    int t;
    cin >> t;

    while(t--){
        solve();
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
int main(){
   ll t,ans=0;
   cin>>t;
   string n;
   for(ll i=0; i<t; i++){
      cin>>n;
      ll m=n.size();
      ans=0;
      map<char, ll> map;
      for(ll i=0; i<m; i++){
         ans+=(n[i]-48);
         if(n[i]=='2'){
            map['2']++;
         }
         else if(n[i]=='3'){
            map['3']++;
         }
      }
      ans=ans%9;
      if(ans==0){
         cout<<"YES"<<"\n";
         continue;         
      }
      else if(ans==1){
         if(map['2']>=4){
            cout<<"YES"<<"\n";
            continue;
         }
         else if(map['3']>=1 && map['2']>=1){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==2){
         if(map['3']>=2 && map['2']>=2){
            cout<<"YES"<<"\n";
            continue;
         }
         if(map['2']>=8){
            cout<<"YES"<<"\n";
            continue;
         }
         if(map['3']>=1 && map['2']>=5){
            cout<<"YES"<<"\n";
            continue;            
         }
      }
      else if(ans==3){
         if(map['3']>=1){
            cout<<"YES"<<"\n";
            continue;            
         }
         else if(map['2']>=3){
            cout<<"YES"<<"\n";
            continue;            
         }
      }
      else if(ans==4){
         if(map['3']>=2 && map['2']>=1){
            cout<<"YES"<<"\n";
            continue;            
         }
         else if(map['2']>=7){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==5){
         if(map['2']>=2){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==6){
         if(map['3']>=2 ||map['2']>=6 ){
            cout<<"YES"<<"\n";
            continue;
         }
         else if(map['3']>=1 && map['2']>=3){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==7){
         if(map['2']>=1){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      else if(ans==8){
         if(map['2']>=5){
            cout<<"YES"<<"\n";
            continue;
         }
         else if(map['3']>=1 && map['2']>=2){
            cout<<"YES"<<"\n";
            continue;
         }
      }
      cout<<"NO"<<"\n";
   }
   return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 400005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
      ans += v[i];
    }
    vector<int> iniv = v;
    for (int x = 0; x < 2; x++)
    {
      v = iniv;
      while (v.size() > 1)
      {
        vector<int> nv(v.size() - 1);
        reverse(v.begin(), v.end());
        int sum = 0;
        for (int i = 0; i + 1 < v.size(); i++)
        {
          nv[i] = v[i + 1] - v[i];
          sum += nv[i];
        }
        ans = max(ans, sum);
        swap(v, nv);
      }
      reverse(iniv.begin(), iniv.end());
    }
    cout << ans << endl;
  }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 400005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
      ans += v[i];
    }
    while (v.size() > 1)
    {
      vector<int> nv(v.size() - 1);
      reverse(v.begin(), v.end());
      int sum = 0;
      for (int i = 0; i + 1 < v.size(); i++)
      {
        nv[i] = v[i + 1] - v[i];
        sum += nv[i];
      }
      ans = max(ans, abs(sum));
      swap(v, nv);
    }
    cout << ans << endl;
  }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 400005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
      ans += v[i];
    }
    while (v.size() > 1)
    {
      vector<int> nv(v.size() - 1);
      reverse(v.begin(), v.end());
      int sum = 0;
      for (int i = 0; i + 1 < v.size(); i++)
      {
        nv[i] = v[i + 1] - v[i];
        sum += nv[i];
      }
      ans = max(ans, sum);
      swap(v, nv);
    }
    cout << ans << endl;
  }
}

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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 400005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
      ans += v[i];
    }
    vector<int> iniv = v;
    for (int x = 0; x < 2; x++)
    {
      v = iniv;
      while (v.size() > 1)
      {
        vector<int> nv(v.size() - 1);
        reverse(v.begin(), v.end());
        int sum = 0;
        for (int i = 0; i + 1 < v.size(); i++)
        {
          nv[i] = v[i + 1] - v[i];
          sum += nv[i];
        }
        ans = max(ans, sum);
        swap(v, nv);
      }
      reverse(iniv.begin(), iniv.end());
    }
    cout << ans << endl;
  }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<pi, int>
#define fir first
#define sec second
#define MAXN 400005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
      ans += v[i];
    }
    while (v.size() > 1)
    {
      vector<int> nv(v.size() - 1);
      reverse(v.begin(), v.end());
      int sum = 0;
      for (int i = 0; i + 1 < v.size(); i++)
      {
        nv[i] = v[i + 1] - v[i];
        sum += nv[i];
      }
      ans = max(ans, sum);
      swap(v, nv);
    }
    cout << ans << endl;
  }
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 200005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n, l, r;
    cin >> n >> l >> r;
    l--, r--;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
      cin >> v[i];
    sort(v.begin(), v.end());
    int ans = 1e18;
    {
      vector<int> v2;
      for (int i = 0; i <= r; i++)
        v2.pb(v[i]);
      sort(v2.begin(), v2.end());
      int curr = 0;
      for (int i = 0; i < (r - l + 1); i++)
        curr += v2[i];
      ans = min(ans, curr);
    }
    {
      vector<int> v2;
      for (int i = n - 1; i >= l; i--)
        v2.pb(v[i]);
      sort(v2.begin(), v2.end());
      int curr = 0;
      for (int i = 0; i < (r - l + 1); i++)
        curr += v2[i];
      ans = min(ans, curr);
    }
    cout << ans << endl;
  }
}
// eu nao tinha lido o exactly once :)

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 200005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n, l, r;
    cin >> n >> l >> r;
    l--, r--;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
      cin >> v[i];
    int ans = 1e18;
    {
      vector<int> v2;
      for (int i = 0; i <= r; i++)
        v2.pb(v[i]);
      sort(v2.begin(), v2.end());
      int curr = 0;
      for (int i = 0; i < (r - l + 1); i++)
        curr += v2[i];
      ans = min(ans, curr);
    }
    {
      vector<int> v2;
      for (int i = n - 1; i >= l; i--)
        v2.pb(v[i]);
      sort(v2.begin(), v2.end());
      int curr = 0;
      for (int i = 0; i < (r - l + 1); i++)
        curr += v2[i];
      ans = min(ans, curr);
    }
    cout << ans << endl;
  }
}
// eu nao tinha lido o exactly once :)
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 200005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < (r - l + 1); i++)
      ans += v[i];
    cout << ans << endl;
  }
}

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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 200005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n, l, r;
    cin >> n >> l >> r;
    l--, r--;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
      cin >> v[i];
    sort(v.begin(), v.end());
    int ans = 1e18;
    {
      vector<int> v2;
      for (int i = 0; i <= r; i++)
        v2.pb(v[i]);
      sort(v2.begin(), v2.end());
      int curr = 0;
      for (int i = 0; i < (r - l + 1); i++)
        curr += v2[i];
      ans = min(ans, curr);
    }
    {
      vector<int> v2;
      for (int i = n - 1; i >= l; i--)
        v2.pb(v[i]);
      sort(v2.begin(), v2.end());
      int curr = 0;
      for (int i = 0; i < (r - l + 1); i++)
        curr += v2[i];
      ans = min(ans, curr);
    }
    cout << ans << endl;
  }
}
// eu nao tinha lido o exactly once :)
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 200005
#define mod 998244353

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--)
  {
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < (r - l + 1); i++)
      ans += v[i];
    cout << ans << endl;
  }
}