ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int main() {
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];}
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0,ma=INT_MIN;
        for(int i=0;i<n;i++){
            sum+=arr[i];
        }
        for(int i=1;i<=(n-1);i++){
            for(int j=0;j<(n-i);j++){
            arr[j]=(arr[j+1]-arr[j]);}
            long long k;
            if(i!=(n-1)){
                k=abs(arr[0]-arr[n-i-1]);
            }
            else{
                k=abs(arr[0]);
            }
            ma=max(k,ma);
        }
        ma=max(ma,sum);
        cout<<ma<<endl;
    }

    return 0;
}

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

int main() {
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];}
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0,ma=INT_MIN;
        for(int i=0;i<n;i++){
            sum+=arr[i];
        }
        long long f=abs((arr[n-1]-arr[0]));
        ma=max(f,ma);
        for(int i=1;i<=(n-1);i++){
            for(int j=0;j<(n-i);j++){
            arr[j]=(arr[j+1]-arr[j]);}
            long long k;
            if(i!=(n-1)){
                k=abs(arr[0]-arr[n-i-1]);
            }
            else{
                k=abs(arr[0]);
            }
            ma=max(k,ma);
        }
        ma=max(ma,sum);
        cout<<ma<<endl;
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int main() {
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];}
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0,ma=INT_MIN;
        for(int i=0;i<n;i++){
            sum+=arr[i];
        }
        sum=abs(sum);
        for(int i=1;i<=(n-1);i++){
            for(int j=0;j<(n-i);j++){
            arr[j]=(arr[j+1]-arr[j]);}
            long long k=abs((arr[0]-arr[n-i-1]));
            ma=max(ma,k);
        }
        ma=max(ma,sum);
        cout<<ma<<endl;
    }

    return 0;
}

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

int main() {
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];}
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0,ma=INT_MIN;
        for(int i=0;i<n;i++){
            sum+=arr[i];
        }
        sum=abs(sum);
        for(int i=1;i<=(n-1);i++){
            for(int j=0;j<(n-i);j++){
            arr[j]=(arr[j+1]-arr[j]);}
            long long k;
            if(i!=(n-1)){
                k=abs(arr[0]-arr[n-i-1]);
            }
            else{
                k=abs(arr[0]);
            }
            ma=max(k,ma);
        }
        ma=max(ma,sum);
        cout<<ma<<endl;
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

int main() {
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];}
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0,ma=INT_MIN;
        for(int i=0;i<n;i++){
            sum+=arr[i];
        }
        sum=abs(sum);
        for(int i=1;i<=(n-1);i++){
            for(int j=0;j<(n-i);j++){
            arr[j]=(arr[j+1]-arr[j]);}
            long long k=abs((arr[0]-arr[n-i-1]));
            ma=max(ma,k);
        }
        ma=max(ma,sum);
        cout<<ma<<endl;
    }

    return 0;
}
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;

int main() {
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];}
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0,ma=INT_MIN;
        for(int i=0;i<n;i++){
            sum+=arr[i];
        }
        sum=abs(sum);
        for(int i=1;i<=(n-1);i++){
            for(int j=0;j<(n-i);j++){
            arr[j]=(arr[j+1]-arr[j]);}
            long long k;
            if(i!=(n-1)){
                k=abs(arr[0]-arr[n-i-1]);
            }
            else{
                k=abs(arr[0]);
            }
            ma=max(k,ma);
        }
        ma=max(ma,sum);
        cout<<ma<<endl;
    }

    return 0;
}

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

int main() {
    int t;
    cin>>t;
    while(t--){
        long long n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];}
        if(n==1){
            cout<<arr[0]<<endl;
            continue;
        }
        long long sum=0,ma=INT_MIN;
        for(int i=0;i<n;i++){
            sum+=arr[i];
        }
        for(int i=1;i<=(n-1);i++){
            for(int j=0;j<(n-i);j++){
            arr[j]=(arr[j+1]-arr[j]);}
            long long k;
            if(i!=(n-1)){
                k=abs(arr[0]-arr[n-i-1]);
            }
            else{
                k=abs(arr[0]);
            }
            ma=max(k,ma);
        }
        ma=max(ma,sum);
        cout<<ma<<endl;
    }

    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define ll long long int



void yes()

{

    cout << "YES" << endl;

}



void no()

{

    cout << "NO" << endl;

}



void read(vector<ll> &arr, int n)

{

    for (int i = 0; i < n; i++)

    {

        cin >> arr[i];

    }

}



ll mex(vector<ll> arr, int n)

{

    ll x = 0;

    sort(arr.begin(), arr.end());

    for (int i = 0; i < n; i++)

    {

        if (arr[i] < (x))

        {

            continue;

        }

        else if (arr[i] == x)

        {

            x++;

        }

        else

        {

            break;

        }

    }



    return x;

}



void read_vecOfPairs(vector<pair<ll, ll>> &arr, int n)

{

    for (int i = 0; i < n; i++)

    {

        ll x, y;

        cin >> x >> y;

        arr[i].first = x;

        arr[i].second = y;

    }

}



void print_arr(vector<ll> &arr, int n)

{

    for (int i = 0; i < n; i++)

    {

        cout << arr[i] << ' ';

    }

    cout << endl;



    return;

}



void print_2darr(vector<vector<ll>> &arr, int n, int m)

{

    for (int i = 0; i < n; i++)

    {

        for (int j = 0; j < m; j++)

        {

            cout << arr[i][j] << ' ';

        }

        cout << endl;

    }



    return;

}



// takes O(nlogn)

vector<ll> frequencySort(vector<ll> &nums)

{

    unordered_map<ll, ll> freq;

    for (ll num : nums)

    {

        freq[num]++;

    }



    sort(nums.begin(), nums.end(), [&](ll a, ll b)

         {

        if (freq[a] == freq[b]) {

            return a > b;

        }

        return freq[a] < freq[b]; });



    return nums;

}



// currently set to min first and max second;

bool sortComparator(const pair<int, int> &a, const pair<int, int> &b)

{

    if (a.first == b.first)

    {

        return (a.second > b.second);

    }

    return (a.first < b.first);

}



// Kadane algo

ll maxSubarraySum(vector<ll> &arr)

{

    ll res = arr[0];

    ll maxEnding = arr[0];



    for (int i = 1; i < arr.size(); i++)

    {

        maxEnding = max(maxEnding + arr[i], arr[i]);

        res = max(res, maxEnding);

    }

    return res;

}



ll factorial(int n)

{

    if (n == 0 || n == 1)

        return 1;

    return (long long int)n * factorial(n - 1);

}

void solve()

{

    int n,x,y;

    cin>>n>>x>>y;



    vector<ll> ans(n,0);

    for(int i=0;i<n;i++){

        if(i%2){

            ans[i]=1;

        }

    }

    if(n%2){

        ans[n-1]=2;



        if((x+y)%2==0){

            //same parity

            if(x!=1 && x!=(n-1)){

                ans[x-1]=2;

            }

            else{

                ans[y-1]=2;

            }

        }

        print_arr(ans,n);

    }

    else{

        if((x+y)%2==0){

            ans[x-1]=2;

        }



        print_arr(ans,n);

    }

    return;

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n; cin >> n;
    vector<int>v(n + 1),c(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
        v[c[i]] = i + 1;
    }
    vector<pair<int, int>>ans;
    for(int i = n; i > 0; i--){
        for(int j = i + 1; j <= n; j++){
            if(v[i] < v[j]){
                ans.push_back({j, i});
            }
        }
        for(int j = n; j > i; j--){
            if(v[i] < v[j]){
                ans.push_back({i, j});
            }
        }
    }
    for(int i = n; i > 0; i--){
        for(int j = i + 1; j <= n; j++){
            if(v[i] > v[j]){
                ans.push_back({j, i});
            }
        }
    }

    cout << ans.size() << endl;
    for(auto k : ans) cout << k.first << " " << k.second << endl;

}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}

Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n; cin >> n;
    vector<int>v(n + 1),c(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
        v[c[i]] = i + 1;
    }
    vector<pair<int, int>>ans;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(v[i] < v[j]) ans.push_back({j, i});
        }
        for(int j = n; j > i; j--){
            if(v[i] < v[j]) ans.push_back({i, j});
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(v[i] > v[j]) ans.push_back({j, i});
        }
    }

    cout << ans.size() << endl;
    for(auto k : ans) cout << k.first << " " << k.second << endl;

}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n;
    cin >> n;
    vector<int>c(n);
    cin >> c;

    vector<pair<int,int>>res;
    for(int i = 0; i < n; i++){
        int j = i - 1;
        while(j >= 0){
            if(c[i] > c[j]){
                res.push_back({c[i], c[j]});
                res.push_back({c[j], c[i]});
            }
            else res.push_back({c[i], c[j]});
            j--;
        }
    }

    cout << res.size() << endl;
    for(auto [x, y] : res) cout << x << " " << y << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n; cin >> n;
    vector<int>v(n + 1),c(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
        v[c[i]] = i + 1;
    }
    vector<pair<int, int>>ans;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(v[i] < v[j]) ans.push_back({j, i});
        }
        for(int j = n; j > i; j--){
            if(v[i] < v[j]) ans.push_back({i, j});
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(v[i] > v[j]) ans.push_back({j, i});
        }
    }

    cout << ans.size() << endl;
    for(auto k : ans) cout << k.first << " " << k.second << endl;

}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}

Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n; cin >> n;
    vector<int>c(n); cin >> c;
    vector<int>ft(n + 1, 0);
    vector<pair<int, int>>res;
    for(int i = 1; i <= n; i++){
        ft[c[i - 1]] = i;
        for(int j = 1; j < i; j++){
            res.push_back({i, j});
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j < i; j++){
            if(ft[i] > ft[j]) res.push_back({j, i});
        }
    }

    cout << res.size() << endl;
    for(auto k : res) cout << k.first << " " << k.second << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n;
    cin >> n;
    vector<int>c(n);
    cin >> c;

    vector<pair<int,int>>res;
    for(int i = 0; i < n; i++){
        int j = i - 1;
        while(j >= 0){
            if(c[i] > c[j]){
                res.push_back({c[i], c[j]});
                res.push_back({c[j], c[i]});
            }
            else res.push_back({c[i], c[j]});
            j--;
        }
    }

    cout << res.size() << endl;
    for(auto [x, y] : res) cout << x << " " << y << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}

Submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n; cin >> n;
    vector<int>v(n + 1),c(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
        v[c[i]] = i + 1;
    }
    vector<pair<int, int>>ans;
    for(int i = n; i > 0; i--){
        for(int j = i + 1; j <= n; j++){
            if(v[i] < v[j]){
                ans.push_back({j, i});
            }
        }
        for(int j = n; j > i; j--){
            if(v[i] < v[j]){
                ans.push_back({i, j});
            }
        }
    }
    for(int i = n; i > 0; i--){
        for(int j = i + 1; j <= n; j++){
            if(v[i] > v[j]){
                ans.push_back({j, i});
            }
        }
    }

    cout << ans.size() << endl;
    for(auto k : ans) cout << k.first << " " << k.second << endl;

}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n; cin >> n;
    vector<int>c(n); cin >> c;
    vector<int>ft(n + 1, 0);
    vector<pair<int, int>>res;
    for(int i = 1; i <= n; i++){
        ft[c[i - 1]] = i;
        for(int j = 1; j < i; j++){
            res.push_back({i, j});
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j < i; j++){
            if(ft[i] > ft[j]) res.push_back({j, i});
        }
    }

    cout << res.size() << endl;
    for(auto k : res) cout << k.first << " " << k.second << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define debug(...) 42
#ifndef ONLINE_JUDGE
#include"mydebug.h"
#endif
#define int long long
#define all(x) begin(x),end(x)
#define endl "\n"
const int N = 2e5;
const int mod = 1e9+7;
const int inf = 1e18;
using namespace std;
template<class T>ostream &operator<<(ostream &os,vector<T>&v){for(auto &c:v)os<<c<<" ";return os;}
template<class T>istream &operator>>(istream &is,vector<T>&v){for(auto i=0;i<v.size();i++)is>>v[i];return is;}
void solve(){
    int n; cin >> n;
    vector<int>c(n);
    for(int i = 0; i < n; i++) cin >> c[i], --c[i];
    vector<int>b(n);
    iota(b.begin(), b.end(), 0);
    vector<pair<int, int>>res;
    for(int i = 0; i < n; i++){
        int x = find(b.begin(), b.end(), c[i]) - b.begin();
        for(int j = x; j < n - 1; j++){
            res.push_back({b[j + 1], b[j]});
            swap(b[j + 1], b[j]);
        }
        for(int j = n - 1; j > i; j--){
            res.push_back({b[j], b[j - 1]});
            swap(b[j], b[j - 1]);
        }
    }

    cout << res.size() << endl;
    for(auto [x, y] : res) cout << x + 1 << " " << y + 1 << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    {
      solve();
    }
 return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;

void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    vector<int> arr(n, 0);
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<int> a1;
    vector<int> a2;
    for(int i=0;i<r;i++) a1.push_back(arr[i]);
    for(int i=l-1;i<n;i++) a2.push_back(arr[i]);
    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());
    int s1=0, s2=0;
    for(int i=0;i<r-l+1;i++){
        s1 += a1[i];
        s2 += a2[i];
    }
    cout<<min(s1, s2)<<endl;
}
int main()
{
    fastio;
    int n;
    cin>>n;
    while(n--) solve();
    return 0;
}

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

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;

void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    l--;
    r--;
    vector<int> arr(n, 0);
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<int> a1;
    vector<int> a2;
    
    for(int i=0;i<=r;i++) a1.push_back(arr[i]);
    for(int i=l;i<n;i++) a2.push_back(arr[i]);

    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());

    int s1=0, s2=0;

    for(int i=0;i<r-l+1;i++){
        s1 += a1[i];
        s2 += a2[i];
    }
    cout<<min(s1, s2)<<endl;
}
int main()
{
    fastio;
    int n;
    cin>>n;
    while(n--) solve();
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;

void solve(){
    int n, l, r;
    cin>>n>>l>>r;
    l--;
    r--;
    vector<int> arr(n, 0);
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<int> a1;
    vector<int> a2;
    
    for(int i=0;i<=r;i++) a1.push_back(arr[i]);
    for(int i=l;i<n;i++) a2.push_back(arr[i]);

    sort(a1.begin(), a1.end());
    sort(a2.begin(), a2.end());

    int s1=0, s2=0;

    for(int i=0;i<r-l+1;i++){
        s1 += a1[i];
        s2 += a2[i];
    }
    cout<<min(s1, s2)<<endl;
}
int main()
{
    fastio;
    int n;
    cin>>n;
    while(n--) solve();
    return 0;
}

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



#define fastio                        \

    ios_base::sync_with_stdio(false); \

    cin.tie(NULL)



#define endl "\n"



using namespace std;



void solve(){

    int n, l, r;

    cin>>n>>l>>r;

    l--;

    r--;

    vector<int> arr(n, 0);

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

    vector<int> a1;

    vector<int> a2;



    for(int i=0;i<=r;i++) a1.push_back(arr[i]);

    for(int i=l;i<n;i++) a2.push_back(arr[i]);



    sort(a1.begin(), a1.end());

    sort(a2.begin(), a2.end());



    long long s1=0, s2=0;



    for(int i=0;i<r-l+1;i++){

        s1 += a1[i];

        s2 += a2[i];

    }

    cout<<min(s1, s2)<<endl;

}

int main()

{

    fastio;

    int n;

    cin>>n;

    while(n--) solve();

    return 0;

}