ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: c++17 

Solution 1 (runtime: 358 ms):
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,temp,sum0,sum1,k;
signed main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>temp;
        sum0=0;
        sum1=0;
        for(int j=0;j<temp;j++){
            cin>>k;
            if(j%2==0){
                sum0+=k;
            }
            else{
                sum1+=k;
            }
        }
        if(temp%2==0&&sum0/(temp/2)==sum1/(temp/2)&&sum0%(temp/2)==0&&sum1%(temp/2)==0){
            cout<<"YES\n";
        }
        else if(temp%2==1&&sum0/(temp/2+1)==sum1/(temp/2)&&sum0%(temp/2+1)==0&&sum1%(temp/2)==0){
            cout<<"YES\n";
        }
        else{
            cout<<"NO\n";
        }
    }
}

Solution 2 (runtime: 343 ms):
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define _test int _TEST; cin >> _TEST; while (_TEST--)
#define ll long long
#define all(a) (a).begin(), (a).end()



void solve() {
  ll n;
  cin>>n;
  vector<ll>a(n);
  for(int i = 0; i < n; i++)
  {
    cin>>a[i];
  }
  ll even=0,odd=0;
  ll n1=0,n2=0;
  for(int i = 0; i < n; i++)
  {
    if(i&1){
      even+=a[i];
      n1++;
    }else{
      odd+=a[i];
      n2++;
    }
  }
  if(even%n1==0 && odd%n2==0 && even/n1==odd/n2) cout<<"YES\n";
  else cout<<"NO\n";
}
int main() {
  _test { 
solve();
 }
  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>

using namespace std;

#define rep(i,j,a) for(int i=j;i<a;i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> pi;
typedef unordered_map<int,int> umii;
typedef vector<int> vi;




void solve(){
	int n,k,container;
	cin>>n>>k;
	vector<int> arr(n),frequency(1,1);
	int minimum_operaiton = 0;

	rep(i,0,n){
		cin>>arr[i];
	}

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

	rep(i,1,n){
		if(arr[i] == arr[i-1]){
			frequency.back()++;
		}else{
			frequency.emplace_back(1);
		}
	}

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


	rep(i,0,frequency.size()){
		if(frequency[i] < k){
			k-= frequency[i];
			frequency[i] = 0;
		}else{
			frequency[i] = frequency[i] - k;
			k = 0;
			break;
		}
	}

	rep(i,0,frequency.size()){
		if(frequency[i] > 0){
			minimum_operaiton++;
		}
	}


	if(minimum_operaiton == 0)
		minimum_operaiton++;

	cout<<minimum_operaiton<<"\n";
}

int main(){
	int tc;

	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	cin>>tc;

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

	return 0;
}

Solution 2 (runtime: 234 ms):
from random import getrandbits

RANDOM = getrandbits(32)

class Wrapper(int):
    def __init__(self, x):
        int.__init__(x)
    def __hash__(self):
        return super(Wrapper, self).__hash__() ^ RANDOM
    
from collections import Counter
t = int(input())
for _ in range(t):
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    c = Counter()
    for i in a:
        c[Wrapper(i)] += 1
    l = sorted(c.values())[::-1]
    ans = len(l)
    while k > 0:
        k -= l.pop()
        if k >= 0:
            ans -= 1
    print (max(1,ans))
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define int long long 
const int t = 1e4 + 3;
int a[t], b[t],fa[t],s[t];
signed main() {
	int T;
	cin >> T;
	while (T--) {
		int n;
		int sum = 0;
		int ma = -1e10;
		cin >> n;
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			sum += a[i];
		}
		if (n == 1) {
			cout << a[1] <<endl;
			continue;
		}
		ma = sum;
		while (n) {
			int res = 0;
			for (int i = 1; i < n; i++) {
				b[i] = a[i + 1] - a[i];
				res += b[i];
			}
			n--;
			ma = max(ma, abs(res));
			for (int i = 1; i <= n; i++) {
				a[i] = b[i];
			}
		}
		cout << ma << endl;
		
	}
	return 0;
}

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int Maxn = 55;

int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        ll a[Maxn];
        ll ans = -50000;
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        for (int i = n - 1; i >= 0; i--) {
            ll sum = 0;
            for (int j = 0; j <= i; j++) {
                sum += a[j];
            }
            if (i == n - 1) {
                ans = max(ans, sum);
            }
            else {
                ans = max(ans, max(sum, -sum));
            }
            for (int j = 0; j < i; j++) {
                a[j] = a[j + 1] - a[j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 77 ms):
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        cin >> t; 
        while(t--)
        {
            string s;
            cin>>s;
            int n = s.size();
            vector<int>a(4 , 0);
            int sum = 0;
            for(int i = 0;i<n;i++)
            {
               int d = (int)s[i]-48;
               sum+=d;
               if(d<=3)
               {
                 a[d]++;
               }
            }
            if(sum%9!=0)
            {
                int f = -1;
                for(int i = 0;i<=a[2];i++)
                {
                    for(int j = 0;j<=a[3];j++)
                    {
                        int news = sum + 2*i + 6 *j;
                        if(news%9==0)
                        {
                            f = 1;
                            cout<<"YES"<<endl;
                            break;
                        }  
                    }
                    if(f==1) break;
                }
                if(f==-1)
                {
                    cout<<"NO"<<endl;
                }
            }
            else
            {
                cout<<"YES"<<endl;
            }
        }

        return 0;
    }
    

Solution 2 (runtime: 77 ms):
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int T; cin >> T;
    while(T--) {
        string s; cin >> s;
        int N = s.size();
        vector<vector<bool>> dp(N+1, vector<bool>(9, false));
        dp[0][0] = true;
        for (int i = 0; i < N; ++i) {
            int cur_digit = s[i] - '0';

            for (int j = 0; j < 9; ++j) {
                dp[i+1][j] = dp[i+1][j] | dp[i][(j+9-cur_digit)%9];
                if (cur_digit <= 3) {
                    int digit_sq = cur_digit * cur_digit;
                    dp[i+1][j] = dp[i+1][j] | dp[i][(j+9-digit_sq)%9];
                }
            }
        }
        cout << (dp[N][0] ? "YES\n" : "NO\n");
    }
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 46 ms):
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define psi pair<string,int>
#define mp make_pair
#define pii pair<int,int>
#define yes cout << "Yes\n"
#define no cout << "No\n"
using namespace std;
const int N = 1e6;
const ll M = 998244353;
const int inf = -1e9;
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int _;cin >> _;
    while(_ --)
    {
        int l,r;cin >> l >> r;
        int tl = l,tr = r;
        int a = 0,b = 0,c = 0;
        int ans = 0;
        for(int i = 29;i >= 0;i --)
        {
            if((1 << i) <= tl)
            {
                tl -= (1 << i);
                tr -= (1 << i);
                a += (1 << i);
                b += (1 << i);
                c += (1 << i);
            }
            else if((1 << i) <= tr)
            {
                a += (1 << i);
                b += (1 << i) - 1;
                c += (1 << i) - 2;
                if(c < l)c = a + 1;
                break;
            }
        }
        cout << a << " " << b << " " << c << '\n';
    }
}


Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;
 
void solve() {
    long long l, r;
    cin>>l>>r;
    int k=31-__builtin_clz(l^r);
    long long a=l|((1<<k)-1),b=a+1,c=(a==l?r:l);
    cout<<a<<" "<<b<<" "<<c<<endl;
}
 
int main() {
	int t;
    cin >> t;
    while (t--)
	{
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#include <iostream>
using namespace std;
using ll = long long;

int main(){
    ll t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        ll ans=0;
        ll arr[51];
        for(ll i=1;i<=n;++i){
            cin >> arr[i];
            ans+=arr[i];
        }
        while(n>1){
            ans=max(ans,abs(arr[n]-arr[1]));
            for(ll i=1;i<n;i++){
                arr[i]=arr[i+1]-arr[i];
            }
            --n;
        }
        cout << ans << endl;
    }
}

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))

using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;

int log2(int x){
  int k = 0;
  while(((x >> k) & 1) == 0) k++;
  return 1 << k;
}
void solve() {
  int n; cin >> n;
  long long a[n]; for(long long &it : a) cin >> it;
  long long mx = accumulate(a, a + n, 0LL);
  for(int i = n - 1; i > 0 ; i--){
    for(int j = 0; j < i; j++) 
      a[j] = a[j + 1] - a[j];
    long long sum = accumulate(a, a + i, 0LL);
    mx = max({mx, sum, -sum});
  } 
  cout << mx << '\n';
}


int main(){
  int t = 1; 
  cin >> t;
  while(t--) solve();
  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 203 ms):
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin >> t;
    vector<int> ansvec;
    while (t--)
    {
        int n, k;
        cin >> n >> k;
        map<int, int> freq;
        int temp;
        vector<int> f;
        for (int i = 0; i < n; i++)
        {
            cin >> temp;
            freq[temp]++;
        }
        for (auto &x : freq)
            f.push_back(x.second);
        sort(f.begin(), f.end());
        temp = 0;
        int ans = f.size();
        while (k >= f[temp] && ans > temp)
        {
            k -= f[temp];
            temp++;
        }
        ans = ans - temp;
        ans = max(1, ans);
        ansvec.push_back(ans);
    }
    for (int &i : ansvec)
        cout << i << endl;
    return 0;
}


Solution 2 (runtime: 265 ms):
#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int temp = k;
        vector<int>v(n);
        map<int,int>m;
        vector<int>v2(n);
        for(int i=0;i<v.size();i++){
            cin>>v[i];
            m[v[i]]++;
        }
        int max = m[v[0]];
        // int idx = v[0];
        for(auto i:m){
            if(i.second>max){
                max = i.second;
                // idx = i.first;
            }
            // max = i.second;
        }
        // m[idx] = 0;
        // if (temp == 0){

        //     cout<<m.size()<<endl;
        //     continue;
        // }
        for(auto i:m){
            v2.push_back(i.second);
        }
        sort(v2.begin(),v2.end());

        for(int i=0;i<v2.size();i++){
            if(k>=v2[i]){
                k = k - v2[i];
                v2[i] = 0;
            }
        }
        // k = temp;
        int count = 0;
        for(int i=0;i<v2.size();i++){
            if(v2[i] != 0) count++;
        }
        
        // for(int i=0;i<v2.size();i++){
        //     cout<<v2[i]<<" ";
        // }cout<<endl;
        if(count == 0){
            cout<<1<<endl;
        }

        else if(m.size() == temp && n == temp ){
            cout<<1<<endl;
        }
        else{
            cout<<(count)<<endl;
        }
        
   
}
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 62 ms):
#include<bits/stdc++.h>
using namespace std;
int T,n,m,f[1001][1001];
char a[2000],b[2000],c[3000];
int main(){
	scanf("%d",&T);
	while(T --){
		scanf("%s%s%s",a + 1,b + 1,c + 1);
		n = strlen(a + 1),m = strlen(b + 1);
		for(int i = 1;i <= m;i ++) f[0][i] = f[0][i - 1] + (b[i] != c[i]);
		for(int i = 1;i <= n;i ++) f[i][0] = f[i - 1][0] + (a[i] != c[i]);
		for(int i = 1;i <= n;i ++) for(int j = 1;j <= m;j ++) f[i][j] = min(f[i - 1][j] + (a[i] != c[i + j]),f[i][j - 1] + (b[j] != c[i + j]));
		printf("%d\n",f[n][m]);
	}
	return 0;
}


Solution 2 (runtime: 93 ms):
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>
#include <chrono>
using namespace std;
#ifndef ONLINE_JUDGE
#include "DebugTemplate.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif
using ll = long long;
#define int long long // remove when using pbds!!
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = (int)2e3 + 7;
int dp[MAXN][MAXN]; // dp[i][j]
// Represents the minimum number of changes
// For c[0.....i] -> using first j charecters from a
// and rest from the string b
const int INF = 2e3 + 7;

void solve() {
    string a, b;
    cin >> a >> b;
    string c;
    cin >> c;
    int n = (int)c.size();
    int m = (int)a.size();
    for (int i = 0 ; i <= n ; i++) { // take care of indexes
        for (int j = 0; j <= n ; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0; // no changes for empty string
    // What's possible dp[i][j] -> first i chars using j chars from a
    for (int i = 1; i <= (int)b.size() ; i ++) {
        if ( c[i - 1] == b[i - 1]) {
            dp[i][0] = dp[i - 1][0];
        }
        else {
            dp[i][0] = dp[i - 1][0] + 1;
        }
    }
    for (int i = 1 ; i <= n ; i++) {
        for (int j = 1 ; j <= m ; j++) {
            // dp[i][j]
            // three cases => equal -> Ok
            // not equal -> either of the string is possible
            dp[i][j] = min({dp[i][j], dp[i - 1][j] + 1, dp[i - 1][j - 1] + 1});
            if ( c[i - 1] == a[j - 1] ) {
                dp[i][j] = min(dp[i - 1][j - 1], dp[i][j]);
            }
            if ( c[i - 1] == b[i - j - 1]) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    cout << dp[n][m] << endl;
}

signed main() {
    auto begin = std::chrono::high_resolution_clock::now();

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 202 ms):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> a(n);
        for(int i=0;i<n;i++)
        cin>>a[i];
        vector<int> counts;
        int cnt=1;
        sort(a.begin(),a.end());
        for(int i=1;i<n;i++){
            if(a[i]==a[i-1]){
                cnt++;
            }
            else{
                counts.push_back(cnt);
                cnt=1;
            }
        }
        counts.push_back(cnt);
        sort(counts.begin(),counts.end());
        int sum=0;
        int op=0;
        for(int i=0;i<counts.size();i++){
            if(sum+counts[i]<=k){
                sum+=counts[i];
            }
            else{
                op=counts.size()-i;
                break;
            }
        }
        if(op){
            cout<<op<<endl;
        }
        else
        cout<<1<<endl;
    }
}

Solution 2 (runtime: 265 ms):
#include <bits/stdc++.h>
using namespace std;

void solve();

int main(){

    int a;

    cin >> a;

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

    return 0;

}

bool cmp(pair<int,int>a, pair<int,int>b){
    return b.second < a.second;
}

void solve(){

    int a,b;
    cin >> a >> b;

    map<int,int> freq;
    

    for(int i = 0; i<a;i++){
        int x;
        cin >> x;
        freq[x]++; 
    }

    vector<pair<int,int>> sorted_freq(freq.begin(),freq.end());

    sort(sorted_freq.begin(), sorted_freq.end(),cmp);

    while(b--){
        sorted_freq[sorted_freq.size()-1].second--;
        sorted_freq[0].second++;
        if(sorted_freq[sorted_freq.size()-1].second==0){
            sorted_freq.erase(sorted_freq.end());
        }
    }

    cout << sorted_freq.size() << endl;
    
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 171 ms):
#include <bits/stdc++.h>
using namespace std;

 
int main(){

    int t;
    cin >> t;

    while(t--){
        int n,l,r;
        cin >> n >> l >>r;
        vector<int> v(n, 0);
        for (int i = 0; i < n;i++){ 
        cin >> v[i];
        }
        vector<int> v2 = v;
        vector<int> v3 = v;
        sort(v2.begin(), v2.begin() + r );
        sort(v3.begin() +l-1, v3.end()  );
        long long sum1 = 0;
        for (int i = 0; i < (r - l + 1);i++){
            sum1 += v2[i];
        }
        long long sum2 = 0;
        for (int i = l-1; i < r;i++){
            sum2 += v3[i];
        }

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

Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long

void Test() {
    ll n, l, r;
    cin >> n >> l >> r;
    vector<ll> left;
    vector<ll> right;
    for(ll i=1; i<=n; i++){
        ll x;
        cin >> x;
        if(i<l)
            left.push_back(x);
        else if(i>r)
            right.push_back(x);
        else{
            left.push_back(x);
            right.push_back(x);
        }
    }
    sort(left.begin(), left.end());
    sort(right.begin(), right.end());
    ll i = 0;
    ll m = r-l+1;
    ll ls = 0, rs = 0;
    while(m--){
        ls += left[i];
        rs += right[i];
        i++;
    }
    if(ls < rs){
        cout << ls << endl;
    }
    else 
        cout << rs << endl;
}

int main() {
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    ll t;
    cin >> t;
    while(t--) {
        Test();
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 265 ms):
#include <bits/stdc++.h>
using namespace std;

#define int long long

void permute(vector<int>&a, vector<pair<int, int>>&v, int n, int idx, int num){
    //cout << num << " " << idx << "\n";
    for (int i = idx+1; i<n; i++){
        v.push_back({a[i], num});
        a[i-1] = a[i];
        a[i] = num;
    }
    for (int i = n-1; i>= (num); i--){
        v.push_back({a[i], a[i-1]});
        swap(a[i], a[i-1]);
    }
    /*
    for (int i = n-2; i>=(num); i++){
        a[i+1] = a[i];
        a[i] = num;
        v.push_back({num, a[i+1]});
    }
    */
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i<n; i++){
        cin >> a[i];
    }
    vector<pair<int, int>> v;
    for (int i = 1; i<=n; i++){
        for (int j = 0; j<n; j++){
            if (a[j] == i){
                permute(a, v, n, j, i);
                break;
            }
        }
        
    }
    reverse(v.begin(), v.end());
    cout << v.size() << "\n";
    for (auto& c : v){
        cout << c.second << " " << c.first << "\n";
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Solution 2 (runtime: 1156 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100000
#define MOD 1000000007

void solve(){
    ll n;
    cin>>n;
    vector<ll>L(n);
    vector<pair<ll,ll>>A;
    for(ll i=0;i<n;i++){
        cin>>L[i];
    }
    for(ll i=0;i<n-1;i++){
        vector<ll>v1;
        vector<ll>v2;
        for(ll j=i+1;j<n;j++){
            if(L[j]>L[i]){
                v1.push_back(L[j]);
            }else{
                v2.push_back(L[j]);
            }
        }
        sort(v1.begin(),v1.end());
        sort(v2.begin(),v2.end(),greater<ll>());
        for(ll j=0;j<v1.size();j++){
            A.push_back({v1[j],L[i]});
        }
        ll size1=v1.size();
        for(ll j=size1-1;j>=0;j--){
            A.push_back({L[i],v1[j]});
        }
        for(ll j=0;j<v2.size();j++){
            A.push_back({L[i],v2[j]});
        }
    }
    cout<<A.size()<<endl;
    for(auto x:A){
        cout<<x.first<<" "<<x.second<<endl;
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll t=1;
    //cin >> t;
    while (t--) solve();
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;

int main(){
	int tt;
	cin >>tt;
	while(tt--){
		string str;
		cin >>str;
		int count =0;
		for (int i =0; i<str.size();i++){
				if (str[i]<(str[i+1]-1)){
					swap(str[i],--str[i+1]);
					i=max(-1,i-2);
				}
			}
		cout << str << endl;
	}
}

Solution 2 (runtime: 1984 ms):
#include <iostream>
#include<string.h>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define ll long long
long long gcd(long long a, long long b) {return b == 0 ? a : gcd(b, a % b);}
long long lcm(int a, int b) {return (a / gcd(a, b)) * b;}
int main() {
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        for(int i=0;i<s.length();i++){
            int val=-1,ind=-1;
            int si=s[i]-'0';
            for(int j=i+1;j<min((int)s.length(),i+10);j++){
                int sj=s[j]-'0';
                if(s[j]=='0')
                continue;
                if(sj-(j-i)>si){
                    val=sj-(j-i);
                    ind=j;
                    si=val;
                }
                // cout<<i<<" "<<j<<" "<<val<<" "<<ind<<endl;
            }
            if(ind!=-1){
                s.erase(ind,1);
            s.insert(i,to_string(val));
            }
            
            // cout<<s<<" as"<<endl;
        }
        cout<<s<<endl;
    }
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<long long> vll;

void solve() {
    ll n, l, r;
    cin >> n >> l >> r;

    vll a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    vll la, ra;
    
    for(int i=0; i<r; i++){
        la.push_back(a[i]);
    }
    sort(la.begin(), la.end());
    
    for(int j=l-1; j<n; j++){
        ra.push_back(a[j]);
    }
    sort(ra.begin(), ra.end());

    ll lsum = 0, rsum = 0;
    for (int i = 0; i < (r - l + 1); i++) {
        lsum += la[i];
    }
    for (int j = 0; j < (r - l + 1); j++) {
        rsum += ra[j];
    }
    cout << min(lsum, rsum) << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    return 0;
}

Solution 2 (runtime: 93 ms):
/*

    चंद्रहासोज्जवलकरा शार्दूलवरवाहना। कात्यायनी शुभं दध्यादेवी दानवघातिनि।।:



    ॐ देवी कात्यायन्यै नम:

*/

#include<bits/stdc++.h>



#define int     long long int



using namespace std;



void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> v, u;

    int x;

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

    {

        cin >> x;

        if ((i+1) >= l)

            v.push_back(x);

        if ((i+1) <= r)

            u.push_back(x);

    }

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

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

    int s1 = 0, s2 = 0;

    for (int i = 0; i < r -l +1  &&  i < v.size(); i++)

    {

        s1 += v[i];

        s2 += u[i];

    }

    cout << min(s1, s2) << '\n';

}







int32_t main()

{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



    int t=1;

    cin>>t;

    while(t--)

        solve();



}