ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        vector<long long> v(n);
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> v[i];
            sum += v[i];
        }
        while (v.size() != 1) {
            vector<long long> v1(v.size() - 1);
            for (int i = 0; i < (int) v.size() - 1; ++i) {
                v1[i] = v[i + 1] - v[i];
            }
            sum = max(sum, abs(accumulate(v1.begin(), v1.end(), 0LL)));
            v = v1;
        }
        cout << sum << '\n';
    }
}

Code 2:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        vector<long long> v(n);
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> v[i];
        }
        while (v.size() != 1) {
            vector<long long> v1;
            for (int i = 0; i < (int) v.size() - 1; ++i) {
                v1.push_back(v[i + 1] - v[i]);
            }
            sum = max(sum, abs(accumulate(v1.begin(), v1.end(), 0LL)));
            v = v1;
        }
        cout << sum << '\n';
    }
}

Answer: 1
Problem: 2062C - Cirno and Operations
Language: c++23 

Code 1:
﻿#include<iomanip>
#include<cstring>
#include<vector>
#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
using namespace std;




int main() {
	int t;
	cin >> t;
	long long ans = 0;
	for (int l = 0; l < t; l++) {
		int n;
		cin >> n;
		long long ans = -1e18;
		long long sum = 0;
		vector<long long> a;
		a.resize(n);
		for (int i = 0; i < n;i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n;i++) {
			long long sum = 0;
			for (int j = 0; j < n - i;j++) {
				sum += a[j];
			}
			if (n == 1 || n == 2) {
				ans = sum;
				continue;
			}
			ans = max(ans, max(sum, -sum));
			for (int j = 0; j < n - i - 1;j++) {
				a[j] = a[j + 1] - a[j];
			}
		}
		cout << ans << endl;


	}

}


Code 2:
﻿#include<iomanip>
#include<cstring>
#include<vector>
#include<iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
using namespace std;




int main() {
	int t;
	cin >> t;
	long long ans = 0;
	for (int l = 0; l < t; l++) {
		int n;
		cin >> n;
		long long ans = -1e18;
		long long sum = 0;
		vector<long long> a;
		a.resize(n);
		for (int i = 0; i < n;i++) {
			cin >> a[i];
		}
		for (int i = 0; i < n;i++) {
			long long sum = 0;
			for (int j = 0; j < n - i;j++) {
				sum += a[j];
			}
			if (i == 0) {
				ans = max(ans,sum);
			}
			else {
				ans = max(ans, max(sum, -sum));
			}
			for (int j = 0; j < n - i - 1;j++) {
				a[j] = a[j + 1] - a[j];
			}
		}
		cout << ans << endl;


	}

}


Answer: 2
Problem: 2062C - Cirno and Operations
Language: c++20 

Code 1:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>

using namespace std;

class Newbie {
public:
    void solveOne() {

    }

    void solveTwo() {
        int t;
        cin >> t;
        while (t--) {
            int n;
            cin >> n;
            long long A[n];
            long long ans = 0;
            for (long long &x: A) {
                cin >> x;
                ans += x;
            }
            int tmpN = n;
            while (tmpN > 1) {
                reverse(A, A + tmpN);
                long long sum = 0;
                for (int i = 0; i < tmpN - 1; ++i) {
                    A[i] = (A[i + 1] - A[i]);
                }
                tmpN--;
                sum = accumulate(A, A + tmpN, 0LL);
                ans = max({ans, sum, -sum});
            }
            cout << ans << "\n";
        }
    }
};


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout.tie(nullptr);
    Newbie solver;
    solver.solveTwo();
    return 0;
}


Code 2:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>

using namespace std;

class Newbie {
public:
    void solveOne() {

    }

    void solveTwo() {
        int t;
        cin >> t;
        while (t--) {
            int n;
            cin >> n;
            vector<int> A(n);
            long long ans = 0;
            for (int &x: A) {
                cin >> x;
                ans += x;
            }
            while (A.size() > 1) {
                reverse(A.begin(), A.end());
                long long sum = 0;
                for (int i = 0; i < A.size() - 1; ++i) {
                    A[i] = (A[i + 1] - A[i]);
                }
                A.pop_back();
                sum = accumulate(A.begin(), A.end(), 0LL);
                ans = max({ans, sum, -sum});
            }
            cout << ans << "\n";
        }
    }
};


int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout.tie(nullptr);
    Newbie solver;
    solver.solveTwo();
    return 0;
}


Answer: 1
Problem: 2062C - Cirno and Operations
Language: c++17 

Code 1:
#include "bits/stdc++.h"
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define int long long

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const char nl = '\n';
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

void solve() {
	int n; cin >> n;
	vector<int> v(n); for (auto &x : v) cin >> x;

	int ans = accumulate(all(v), 0);

	while (sz(v) > 1) {
		ans = max(ans, abs(v[0] - v.back()));

		for (int i = 0; i < sz(v) - 1; i++)
			v[i] = v[i + 1] - v[i];
		v.pop_back();

		ans = max(ans, abs(v[0] - v.back()));
	}

	cout << ans << nl;
}

int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0);

	int t; cin >> t;
	while(t--) {
		solve();
	}

	return 0;
}


Code 2:
#include "bits/stdc++.h"
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define int long long

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const char nl = '\n';
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

void solve() {
	int n; cin >> n;
	vector<int> v(n); for (auto &x : v) cin >> x;

	int ans = accumulate(all(v), 0LL);

	while (sz(v) > 1) {
		for (int i = 0; i < sz(v) - 1; i++)
			v[i] = v[i + 1] - v[i];
		v.pop_back();

		ans = max(ans, abs(v[0] - v.back()));
	}

	cout << ans << nl;
}

int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0);

	int t; cin >> t;
	while(t--) {
		solve();
	}

	return 0;
}


Answer: 1
Problem: 2063B - Subsequence Update
Language: c++17 

Code 1:
#include<iostream>

#include<algorithm>

#include<iomanip>

#include<cmath>

#include<math.h>

#include <vector>

#include <map>

#include <set>

#include<string>

#include <cstring>

#include <stack>

#include<queue>



using namespace std;

#define int long long

typedef pair<int,int> PII;

typedef vector<int> vi;

typedef vector<char> vc;



const int N =2e5+10, INF = 0x3f3f3f3f,mod=1e9+7;

int a[N],b[N];

int dx[]={-1,-1,1,1};

int dy[]={1,-1,1,-1};



void solve() {

	int n,l,r;

	cin>>n>>l>>r;

	int idx1 = 1,idx = 1;

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

		int x;cin>>x;

		if(i<=r){

			a[idx1++] = x;

		}

		if(i>=l){

			b[idx++] = x;

		}

	} 

	int len = r-l+1;

	

	sort(a+1,a+idx1);

	sort(b+1,b+idx);

	int sum1 = 0,sum2 = 0;

	for(int i = 1;i<=len;i++){

		sum1+=a[i];

		sum2+=b[i];

	}

	

	cout<<min(sum1,sum2)<<'\n';

}



signed main(){

	ios::sync_with_stdio(false);

	cin.tie(0);



	int t=1;



	cin>>t;

	while(t--){

		solve();

	}

    return 0;

}





Code 2:
#include<iostream>

#include<algorithm>

#include<iomanip>

#include<cmath>

#include<math.h>

#include <vector>

#include <map>

#include <set>

#include<string>

#include <cstring>

#include <stack>

#include<queue>



using namespace std;

#define int long long

typedef pair<int,int> PII;

typedef vector<int> vi;

typedef vector<char> vc;



const int N =2e5+10, INF = 0x3f3f3f3f,mod=1e9+7;

int a[N];

int dx[]={-1,-1,1,1};

int dy[]={1,-1,1,-1};



void solve() {

	int n,l,r;

	cin>>n>>l>>r;

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

		cin>>a[i];

	} 

	int len = r-l+1;

	if(l==r){

		cout<<0<<'\n';

		return ; 

	}

	sort(a+1,a+1+n);

	int sum = 0;

	for(int i = 1;i<=len;i++){

		sum+=a[i];

	}

	

	cout<<sum<<'\n';

}



signed main(){

	ios::sync_with_stdio(false);

	cin.tie(0);



	int t=1;



	cin>>t;

	while(t--){

		solve();

	}

    return 0;

}





Answer: 1
Problem: 2063B - Subsequence Update
Language: c++23 

Code 1:
#include <bits/stdc++.h>

#define vi vector<int>

#define vll vector<ll>

#define vvi vector<vector<int>>

#define vvii vector<vector<pair<int,int>>>

#define it vector<int>::iterator

#define ii pair<int,int>

#define fori(i,ini,fim) for(int i=ini;i<fim;i++)

#define s second

#define f first

#define pb push_back

#define all(x) x.begin(),x.end()

#define teto(x,y) ((x+y-1)/y)

#define dbgv(v) cout<< #v << " = ";for(auto e:v)cout<<e<<",";cout<<endl

#define dbg(x) cout << #x << " = " << x <<endl



typedef long long ll;

const int INF = 0x3f3f3f3f;

const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MAX = 2e6+10;



const int MOD = 26;



using namespace std;



void fun(){

    ll n, l, r; cin >> n >> l >> r;

	vll v1, v2;



	fori( i, 0, n ){

		ll a; cin >> a;

		if( i < r ) v1.pb(a);

		if( l <=l ) v2.pb(a);

	}



	sort(all(v1));

	sort(all(v2));



	ll sumv1 = 0;

	ll sumv2 = 0;



	fori( i, 0, r - l + 1 ) sumv1 += v1[i];

	fori( i, 0, r - l + 1 ) sumv2 += v2[i];



	cout << min( sumv1, sumv2 ) << endl;	





}



int main(){

	ios_base::sync_with_stdio(false);cin.tie(NULL);

	int TC;cin>>TC;

	while (TC--)fun();

	return 0;

}





Code 2:
#include <bits/stdc++.h>

#define vi vector<int>

#define vll vector<ll>

#define vvi vector<vector<int>>

#define vvii vector<vector<pair<int,int>>>

#define it vector<int>::iterator

#define ii pair<int,int>

#define fori(i,ini,fim) for(int i=ini;i<fim;i++)

#define s second

#define f first

#define pb push_back

#define all(x) x.begin(),x.end()

#define teto(x,y) ((x+y-1)/y)

#define dbgv(v) cout<< #v << " = ";for(auto e:v)cout<<e<<",";cout<<endl

#define dbg(x) cout << #x << " = " << x <<endl



typedef long long ll;

const int INF = 0x3f3f3f3f;

const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MAX = 2e6+10;



const int MOD = 26;



using namespace std;



void fun(){

    ll n, l, r; cin >> n >> l >> r;

	vll v1, v2;



	fori( i, 0, n ){

		ll a; cin >> a;

		if( i <= r -1 ) v1.pb(a);

		if( l - 1 <=i ) v2.pb(a);

	}



	sort(all(v1));

	sort(all(v2));



	ll sumv1 = 0;

	ll sumv2 = 0;



	fori( i, 0, r - l + 1 ) sumv1 += v1[i];

	fori( i, 0, r - l + 1 ) sumv2 += v2[i];



	cout << min( sumv1, sumv2 ) << endl;	





}



int main(){

	ios_base::sync_with_stdio(false);cin.tie(NULL);

	int TC;cin>>TC;

	while (TC--)fun();

	return 0;

}





Answer: 2
Problem: 2063B - Subsequence Update
Language: c++17 

Code 1:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

void solve(){

    ll n,l,r;

    cin>>n>>l>>r;

    vector<ll>a(n);

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

        cin>>a[i];

    }

   vector<ll>v1(a.begin(),a.begin()+r);

   vector<ll>v2(a.begin()+l-1,a.end());

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

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

    ll d=(r-l+1);

    ll sum1=0;

    ll sum2=0;

    for(ll i=0;i<d;i++){

        sum1 +=v1[i];

        sum2 +=v2[i];

    }

    cout<<min(sum1,sum2)<<endl;

   

}



int main() {

    ll t;

    cin>>t;

    while(t--){

        solve();

    }





}

Code 2:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

void solve(){

    ll n,l,r;

    cin>>n>>l>>r;

    vector<ll>a(n);

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

        cin>>a[i];

    }

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

    ll d=(r-l+1);

    ll sum=0;

    for(ll i=0;i<d;i++){

        sum +=a[i];

    }

    cout<<sum<<endl;

   

}



int main() {

    ll t;

    cin>>t;

    while(t--){

        solve();

    }





}

Answer: 1
Problem: 2063B - Subsequence Update
Language: c++23 

Code 1:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using ll=long long;
using ld=long double;
using namespace std;



int main() {
    int t;cin>>t;
    while(t--){
        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());
        ll ans=0;
        for(int i=0;i<=r-l;i++){
            ans+=v[i];

        }
        cout<<ans<<endl;
    }
}


Code 2:
#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <queue>

using ll=long long;

using ld=long double;

using namespace std;







int main() {

    int t;cin>>t;

    while(t--){

        int n,l,r;cin>>n>>l>>r;

        l--;

        vector<ll> v(n);



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

            cin>>v[i];



        }

        vector<ll> brr = v, crr = v;

        sort(brr.begin()+l,brr.end());

        sort(crr.begin(),crr.begin()+r,greater<ll>());



        ll ans1=0,ans2=0;

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

            ans1+=brr[i];

            ans2+=crr[i];

        }

        cout<<min(ans1,ans2)<<endl;

    }

}



Answer: 2
Problem: 2063B - Subsequence Update
Language: c++17 

Code 1:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    //t test case
    int t;
    cin>>t;
    while(t--){
    int n,l,r;
    cin>>n>>l>>r;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.begin()+l-1);
    sort(a.begin()+l-1,a.begin()+r);
    sort(a.end()-n+r,a.end());
    int sum1=0;
    int sum2=0;
    int i=0;
    int j=r-1;
    // for(int i=0;i<n;i++){
    //     cout<<a[i]<<" ";
    // }
    while(a[j]>a[i] && i<l-1){
        sum1+=a[j]-a[i];
        i++;
        j--;
    }
    i=r-1;
    j=r;
    while(a[i]>a[j] && j<n){
        sum2+=a[i]-a[j];
        i--;
        j++;
    }
    int sumf=0;
    for(int i=l-1;i<r;i++){
        sumf+=a[i];
    }
    // cout<<sum1<<" "<<sum2<<endl;
    cout<<sumf-max(sum1,sum2)<<endl;
    }
}

Code 2:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    //t test case
    int t;
    cin>>t;
    while(t--){
    int n,l,r;
    cin>>n>>l>>r;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.begin()+l-1);
    sort(a.begin()+l-1,a.begin()+r);
    sort(a.end()-n+r,a.end());
    long long int sum1=0;
    long long int sum2=0;
    int i=0;
    int j=r-1;
    // for(int i=0;i<n;i++){
    //     cout<<a[i]<<" ";
    // }
    while(a[j]>a[i] && i<l-1 && j>=l-1){
        sum1+=a[j]-a[i];
        i++;
        j--;
    }
    i=r-1;
    j=r;
    while(a[i]>a[j] && j<n && i>=l-1){
        sum2+=a[i]-a[j];
        i--;
        j++;
    }
    long long int sumf=0;
    for(int i=l-1;i<r;i++){
        sumf+=a[i];
    }
    // cout<<sum1<<" "<<sum2<<endl;
    cout<<sumf-max(sum1,sum2)<<endl;
    }
}

Answer: 2
Problem: 2063B - Subsequence Update
Language: c++17 

Code 1:
#include <bits/stdc++.h>

using namespace std;

int main(){

    int k;

    cin >> k;

    while(k--){

    int n,l,r;

    cin >> n >> l >> r;

    vector<long long int>arr1(n,0);

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

    priority_queue<long long int,vector<long long int>,greater<long long int>>q;

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

        q.push(arr1[i]);

    }

    long long int sum = 0;

    long long int sum1 = 0;

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

        sum+=q.top();

        q.pop(); 

    }

    while(!q.empty())q.pop();

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

        q.push(arr1[i]);

    }

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

        sum1+=q.top();

        q.pop(); 

    }

    cout << min(sum,sum1) << endl;

    }

}

Code 2:
#include <bits/stdc++.h>

using namespace std;

int main(){

    int k;

    cin >> k;

    while(k--){

    int n,l,r;

    cin >> n >> l >> r;

    vector<long long int>arr1(n,0);

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

    priority_queue<long long int,vector<long long int>,greater<long long int>>q;

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

        q.push(arr1[i]);

    }

    long long int sum = 0;

    long long int sum1 = 0;

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

        sum+=q.top();

        q.pop(); 

    }

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

        q.push(arr1[i]);

    }

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

        sum1+=q.top();

        q.pop(); 

    }

    cout << min(sum,sum1) << endl;

    }

}

Answer: 1
Problem: 2063B - Subsequence Update
Language: c++20 

Code 1:
#include<bits/stdc++.h>

using namespace std;

void solve(){   

    long long n,l,r;

    long long ans=0,s=0;

    cin>>n>>l>>r;

    int a[n],c[n];

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

	cin>>a[i];

	c[i]=a[i];

}

    sort(a,a+r);

    sort(c+l-1,c+n);

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

    	s+=a[i];

	}

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

        ans+=c[i];

    }

    cout<<min(ans,s)<<endl;

}

int main(){

	int T;

	cin>>T;

	while(T--)solve();

    return 0;

} 

Code 2:
#include<bits/stdc++.h>

using namespace std;

void solve(){   

    long long n,l,r;

    long long ans=0,s=0;

    cin>>n>>l>>r;

    int a[n],c[n];

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

	cin>>a[i];

	c[i]=a[i];

}

    sort(a,a+r);

    sort(c+l-1,c+n);

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

    	s+=a[i];

    	ans+=c[i];

	}

    cout<<min(ans,s)<<endl;

}

int main(){

	int T;

	cin>>T;

	while(T--)solve();

    return 0;

} 

Answer: 1
Problem: 2063B - Subsequence Update
Language: c++20 

Code 1:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, l, r;
		cin >> n >> l >> r;
		vector<int> a(n + 1);
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		auto b = a;
		LL  sum1 = 0, sum2 = 0;
		sort(a.begin() + 1, a.begin() + r + 1);
		for (int i = 1; i <= r-l+1; i++) {
			sum1 += a[i];
		}
		sort(b.begin()  + l, b.end());
		for (int i = l; i <= r; i++) {
			sum2 += b[i];
		}
		//cout << sum1 <<' '<< sum2;
		LL ans = min(sum1, sum2);
		cout << ans << endl;
	}

	return 0;
}

Code 2:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, l, r;
		cin >> n >> l >> r;
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		auto b = a;
		int sum1 = 0, sum2 = 0;
		sort(a.begin(), a.begin() + r-1);
		for (int i = 0; i < r-l; i++) {
			sum1 += a[i];
		}
		sort(b.begin()  + l-1, b.end());
		for (int i = l-1; i < r; i++) {
			sum2 += b[i];
		}
		//cout << sum1 <<' '<< sum2;
		int ans = min(sum1, sum2);
		cout << ans << endl;
	}

	return 0;
}

Answer: 1
Problem: 2063B - Subsequence Update
Language: c++20 

Code 1:
#include<bits/stdc++.h>

#define ll long long

using namespace std;



ll func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r);

sort(s.begin()+l-1LL,s.end());



ll sum1=0,sum2=0;

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

    sum1+=v[i];

    }

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

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}

Code 2:
#include<bits/stdc++.h>

#define ll long long

using namespace std;



int func(){

 ll n,l,r;

 cin>>n>>l>>r;

 vector<ll>v(n);

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

     cin>>v[i];

 }

 vector<ll>s(n);

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

     s[i]=v[i];

 }

sort(v.begin(),v.begin()+r);

sort(s.begin()+l-1,s.end());



ll sum1=0,sum2=0;

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

    sum1+=v[i];

    }

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

        sum2+=s[i];

    }

    return min(sum1,sum2);

}



int main(){

    ll t;cin>>t;

    while(t--){

        cout<<func()<<endl;

    }

}

Answer: 1
Problem: 2063B - Subsequence Update
Language: c++20 

Code 1:
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

#define inv(x) ksm(x, mod - 2)

#define int long long

#define NO cout << "NO" << endl

#define YES cout << "YES" << endl

#define No cout << "No" << endl

#define Yes cout << "Yes" << endl

#define lowbit(x) ((x) & (-x))

#define mem(a, b) memset(a, b, sizeof(a))

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

// const int mod = 998244353;

const int mod = 1e9 + 7;

const int inf = 1e18;

double logn(int n,double x){return log(x)/log(n);}

int ksm(int a, int b){int ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans;}

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<pair<int, int>, int> piii;

const int N = 2e5 + 5;

int dx[4] = {0, 1, -1, 0};

int dy[4] = {1, 0, 0, -1};

void solve()

{

	int n;

	cin >> n;

	int l, r;

	cin >> l >> r;

	vector<int> a(n + 1);

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

		cin >> a[i];

	sort(a.begin() + 1, a.end());

	int g = r - l + 1;

	int sum = 0;

	for (int i = 1; i <= g;i++)

		sum += a[i];

	cout << sum << endl;

}	

signed main(){

	cin.tie(0);

	cout.tie(0);

	ios::sync_with_stdio(false);

	int t;

	t = 1;

	cin >> t;

	while (t--)

		solve();

}

Code 2:
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

#define inv(x) ksm(x, mod - 2)

#define int long long

#define NO cout << "NO" << endl

#define YES cout << "YES" << endl

#define No cout << "No" << endl

#define Yes cout << "Yes" << endl

#define lowbit(x) ((x) & (-x))

#define mem(a, b) memset(a, b, sizeof(a))

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

// const int mod = 998244353;

const int mod = 1e9 + 7;

const int inf = 1e18;

double logn(int n,double x){return log(x)/log(n);}

int ksm(int a, int b){int ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans;}

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<pair<int, int>, int> piii;

const int N = 2e5 + 5;

int dx[4] = {0, 1, -1, 0};

int dy[4] = {1, 0, 0, -1};

void solve()

{

	int n;

	cin >> n;

	int l, r;

	cin >> l >> r;

	vector<int> a(n + 1);

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

		cin >> a[i];

	priority_queue<int> s;

	for (int i = l; i <= r;i++)

		s.push(a[i]);

	for (int i = 1; i < l;i++)

	{

		if(s.top()>a[i])

			s.pop(), s.push(a[i]);

	}

	int minn = 0;

	while(s.size())

		minn += s.top(), s.pop();

		for (int i = l; i <= r;i++)

		s.push(a[i]);

		for (int i = r + 1;i<=n;i++)

		if(s.top()>a[i])

			s.pop(), s.push(a[i]);

		int sum = 0;

		while(s.size())

			sum += s.top(), s.pop();

		minn = min(minn, sum);

		cout << minn << endl;

}	

signed main(){

	cin.tie(0);

	cout.tie(0);

	ios::sync_with_stdio(false);

	int t;

	t = 1;

	cin >> t;

	while (t--)

		solve();

}

Answer: 2