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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vll;
typedef pair<ll,ll> pll; 

void solve()
{
    int t;
    cin>>t;

    while (t --) 
    {
        int n;
        cin>>n;
        vi a(n);
        for (int i = 0;i < n;i ++) cin>>a[i];
        
        ll ans = accumulate(a.begin(), a.end(), 0LL);
        vll coef = {1};
        for (int i = 0;i < n - 1;i ++) {
            ll first = 0, last = 0;
            for (int j = 0;j < coef.size();j ++) {
                first += coef[j] * a[i - j];
                last += coef[j] * a[n - 1 - j];
            }
            ans = max({ans, first - last, last - first});
            vll new_coef = {1};
            for (int j = 1;j < coef.size();j ++) {
                new_coef.push_back(coef[j] - coef[j - 1]);
            }
            new_coef.push_back(-coef.back());
            coef = new_coef;
        }
        if (n >= 2) {
            ll ele = 0;
            for (int i = 0;i < coef.size();i ++) {
                ele += coef[i] * a[n - 1 - i];
            }
            ans = max(ans, abs(ele));
        }
        cout<<ans<<endl;
    }
}

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


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

#define IOS ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define in_ freopen("input.txt", "r", stdin);
#define all(a) a.begin(), a.end()
#define cout2(a) for(int i = 0; i < a.size(); ++ i) cout << a[i] << " "; cout << "\n";
#define cout1(a, s, e) for(int i = s; i < e; ++ i) cout << a[i] << " "; cout << "\n";
#define debug1(x) cout << x << "!!!\n";
#define debug2(x) cout << x << "###\n";

typedef long long ll;
const int N = 200005, mod = 998244353;
typedef pair<int,int> PII;
 
#define x1 first
#define y1 second

void deal() {

       int n;
       cin >> n;
       vector<ll> a(n);
       for(int i = 0; i < n; ++ i) cin >> a[i];
       
       ll ans = 0;
       
       int now = n;
       for(int i = 0; i < n; ++ i) {
       	 ll sum = 0;
       	 for(int j = 0; j < now; ++ j) sum += a[j];
       	 if(i == 0) ans = sum;
       	 else ans = max(ans, abs(sum));
       	 
       	 for(int j = 0; j < now - 1; ++ j) a[j] = a[j + 1] - a[j];
       	 
       	 -- now;
	   }
        
        cout << ans << "\n";
        
} 

int main() {
	
	#ifndef ONLINE_JUDGE
	in_;
//	freopen("out.txt", "w", stdout); 
	#endif
	
	IOS;
	
	int t;
	cin >> t;
	while(t --)
	 deal();
     
	return 0;
}  

/*
       /\_/\
      (= ._.)
       />  \>  !!!!!!     
       author :: fly
	        
*/
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 187 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define  pb push_back
void _() {
	int n,l,r;
	cin >> n >> l >> r;
	l--;
	r--;
	vector<int>v(n);
	vector<int>b,cur;
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int sum = 0,sum1 = 0;
	vector<int>a1,a2,a3;
	for(int i = 0; i < n; i++) {
		if(i < l) {
			a1.pb(v[i]);
		}
		else if(i > r) {
			a3.pb(v[i]);
		}
		else {
			a2.pb(v[i]);
			sum += v[i];
		}
	}
	sort(a1.begin(),a1.end());
	sort(a2.rbegin(),a2.rend());
	sort(a3.begin(),a3.end());
	sum1 = sum;
	for(int i = 0; i < min(a1.size(),a2.size()); i++) {
		if(a2[i] >= a1[i]) {
			sum = sum - a2[i] + a1[i];
		}
	}
	for(int i = 0; i < min(a3.size(),a2.size()); i++) {
		if(a2[i] >= a3[i]) {
			sum1 = sum1 - a2[i] + a3[i];
		}
	}
	cout << min(sum1,sum) << endl;
}
signed main() {
	int t = 1;
	cin >> t;
	while(t--) {
		_();
	}
	return 0;
}


Solution 2 (runtime: 78 ms):


#include <bits/stdc++.h> 

#define ll long long 

using namespace std;

 

const int MAX_N = 1e5;

 

vector<vector<int>> adj(MAX_N,vector<int>());

vector<bool> processed(MAX_N,0);

 

void setIO(string s) {

	freopen((s + ".in").c_str(), "r", stdin);

	freopen((s + ".out").c_str(), "w", stdout);

} 

 

ll gcd(ll y,ll z){

	if(z == 0) return y;

	return gcd(z,y%z);

}

 

vector<int> dist(1e5);





bool comp(int a, int b) {

    return a > b;

}

 

void solve(){

	

	int n; cin >> n;

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

	vector<int> first(0);

	vector<int> second(0);

	vector<int> third(0);

	l--; r--;

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

		int x; cin >> x;

		first.push_back(x);

	}

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

		int x; cin >> x;

		second.push_back(x);

	}

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

		int x; cin >> x;

		third.push_back(x);

	}

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

	sort(second.begin(),second.end(),comp);

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

	ll res1 = 0;

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

		if(i<first.size() && i < second.size()) res1 += min(first[i], second[i]);

		else if (i>=first.size()) res1+= second[i];

		else res1+= first[i];

	}

	ll res2 = 0;

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

		if(i<third.size() && i < second.size()) res2 += min(third[i], second[i]);

		else if (i>=third.size()) res2 += second[i];

		else res2+= third[i];

	}

	//cout << res1 << "\n" << res2 << "\n";

	cout << min(res1,res2);

}

 

int main(){

    ios::sync_with_stdio(0);

    cin.tie(nullptr);

    cout << fixed << setprecision(8);

 

	int t = 1;

	cin >> t;

	while(t--) {

		solve();

		cout << "\n";

	}

}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef complex<long double> cd;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef char ch;
typedef string str;

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

#include <bits/extc++.h>
using namespace __gnu_pbds;

using indexed_set = tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>;

#pragma GCC target("popcnt,lzcnt")

#define pb push_back
#define elif else if
#define sz(C) (ll) C.size()
#define all(C) C.begin(), C.end()
#define flip(C) reverse(all(C))
#define ssort(C) sort(all(C))
#define rsort(C) sort(all(C), greater<>())
// #define x first
// #define y second

#define FOR(x, e) for (ll x = 0; x < (ll)e; x++)
#define FOR1(x, e) for (ll x = 1; x < (ll)e; x++)
#define FORR(x, e) for (ll x = (ll)e - 1; x >= 0; x--)

#ifdef LOCAL
#include "tester.cpp"
#define main test_main
extern istringstream fin;
extern ostringstream fout;
string test_file_name = "tests";
#define cin fin
#define cout fout
#endif

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

    ll t; cin >> t;
    while (t--) {
        ll l, r; cin >> l >> r;
        ll mx = 0;
        while (r / (1LL << mx) * (1LL << mx) > l) mx++;
        mx--;
        ll a = r / (1LL << mx) * (1LL << mx), b = a - 1, c = b;
        while (mx >= 0) {
            if (b - (1LL << mx) >= l) b -= (1LL << mx);
            mx--;
        }
        if (b == c) b = a + 1;
        cout << a << ' ' << b << ' ' << c << '\n';
        // cout << (a ^ b) + (b ^ c) + (c ^ a) << '\n';
    }

    return 0;
}

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

using namespace std;

void Solve() {
  int l, r, k; cin >> l >> r;
  for (int i = 30; ~i; --i) {
    if ((l ^ r) & (1 << i)) {
      k = i;
      break;
    }
  }
  int a, b, c;
  int tmp = (l >> k + 1) << k + 1;
  a = (1 << k) - 1 + tmp; b = a + 1; c = l;
  if (a == c) c = r;
  printf("%d %d %d\n", a, b, c);
}

int main() {
  int cases; cin >> cases;
  while (cases--) {
    Solve();
  }
  return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

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

int mod=1e9+7;

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

	while(t--){
		int l,r;
        cin>>l>>r;
        int x,z, ans=0;

        for(int i=30; i>=0; i--){
            int b1=0, b2=0;

            if(l & (1LL<<i)) b1=1; 
            if(r & (1LL<<i)) b2=1; 

            if(b1==b2){
                ans+=b1 * (1LL<<i);
            }

            else{
                x=ans+ (1LL<<i);
                break;
            }
        }

        for(int i=r; i>=l; i--){
            if(i!=x && i!=x-1){
                z=i;
                break;
            } 
        }

        cout<<x<<" "<<x-1<<" "<<z<<endl;
	}
	
	return 0;
}

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)

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

    int k;

    for (int i = 30; i >= 0; i--)
    {
        // cout << i << " " << (l & (1 << i)) << " " << (r & (1 << i)) << "\n";
        if ((l & (1 << i)) != (r & (1 << i)))
        {
            k = i;
            break;
        }
    }

    ll x = 0;
    for (int i = 30; i >= k; i--)
    {
        if (r & (1 << i))
            x += (1 << i);
    }
    ll y = x - 1;
    ll z = l;
    while (true)
    {
        if (z != x && z != y)
        {
            cout << x << " " << y << " " << z << "\n";
            return;
        }
        z++;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: c++17 

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



int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    

    int t;
    cin >> t;

    while (t--) {
        int n;
        cin>>n;
        vector<long long int>a(n);
        long long int maxi = 0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            maxi +=a[i];
        }
        
        for(int i=0;i<n;i++){
            if(i==n-1) maxi = max(maxi,a[i]);
            else maxi=max({maxi,a[i]-a[n-1],-a[i]+a[n-1]});
            for(int j=n-1;j>i;j--)
            a[j]-=a[j-1];
        }
        cout<<maxi<<endl;

    }

    return 0;
}


Solution 2 (runtime: 46 ms):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    vector<long  long >v(n);
     long long  ans =0;
    for(int i=0;i<n;i++){cin >> v[i]; ans += v[i];}
   
    // ans = abs(ans);
    int j = n;
    while(j>1){
        vector<long long>pre(j-1);
    for(int i=1;i<j;i++){
        pre[i-1] = (v[i]) - (v[i-1]);
    }
    long long sum = 0;
    for(int i=1;i<j;i++){
         v[i-1] = (pre[i-1]);
        sum += v[i-1];
    }
    ans = max(ans,abs(sum));
    j--;
    }
    cout << ans << endl;
}
int main()
{   
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    
    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;
        int k2 = k;
        int a[n];
        for(int i = 0; i < n; i++)
            cin >> a[i];
        sort(a, a + n);
        vector <int> e {1};
        for(int i = 1; i < n; i++)
        {
            if(a[i] == a[i - 1]) e.back()++;
            else e.push_back(1);
        }
        int ans = e.size();
        sort(e.begin(), e.end());
        for(auto x : e)
        {
            if(k >= x)
            {
                ans--;
                k -= x;
            }
        }
        if(k2 >= (n - 1)) ans = 1;
        std::cout << ans << '\n';
    }
    return 0;
}

Solution 2 (runtime: 249 ms):
#include <bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
	int t;
	cin>>t;
	while(t--){
		long long n,m;
		cin>>n>>m;
		mp.clear();
		for(int i=1;i<=n;i++){
			int a;
			cin>>a;
			mp[a]++;
		}
		multiset<int>st;
		for(auto b:mp)
			st.insert(b.second);
		int ans=st.size();
		for(int a:st){
			if(m>=a)ans--,m-=a;
		}cout<<max(1,ans)<<'\n';
	}
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 468 ms):
#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>
#else
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <set>
#include <string>
#include <iomanip>
#include <map>
#endif
// Resubmission
#define ll long long
#define ull unsigned long long
#define NPRIMES (int)2e7
using namespace std;
FILE* stream;

vector<ull> PRIMES;
void sieve() {
    cout << "sieve" << endl;
    vector<bool> isPrime(NPRIMES, true);
    for (ull i = 3; i * i <= NPRIMES; i+=2) {
        if (isPrime[i]) {
            for (ull j = i * i; j < NPRIMES; j += i) {
                isPrime[j] = false;
            }
        }
    }
    PRIMES.push_back(2);
    for (int i = 3; i < isPrime.size(); i+=2) if (isPrime[i]) PRIMES.push_back(i);
    cout << "sieve-" << endl;
}

template <typename T>
vector<T> primeFactor(T x) {
    vector<T> res;
    T p = 2;
    T i = 0;
    while (p * p <= x) {
        if (x % p == 0) {
            res.push_back(p);
            x /= p;
            p = 2;
            i = 0;
        }
        else {
            i += 1;
            if (i >= PRIMES.size()) break;
            p = PRIMES[i];
        }
    }
    res.push_back(x);
    return res;
}

void solve() {
    int n, k; cin >> n >> k;
    map<ull, int> fr;
    vector<ull> a(n); for (int i = 0; i < n; i++) {
        cin >> a[i]; 
        fr[a[i]]++;
    }

    set<ull> s;
    sort(a.begin(), a.end(), [&fr](ull a, ull b) { if (fr[a] != fr[b]) return fr[a] < fr[b]; return a < b; });
    for (int i = k; i < n; i++) {
        s.insert(a[i]);
    }
    cout << max(s.size(), (size_t)1) << endl;
}

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

#ifdef _DEBUG
    freopen_s(&stream, "inp.txt", "r", stdin);
#endif // ONLINE_JUDGE
    int t; cin >> t; while (t--)
        solve();
}

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

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

   vector<int> arr(n);


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

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


   vector<int> cnt={1};
   for(int i=1;i<n;i++){
      if(arr[i]==arr[i-1])cnt.back()++;
      else cnt.emplace_back(1);
   }

   

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

   for(int i=0;i<cnt.size()-1;i++){
     if(cnt[i]>k){
       cout<<cnt.size()-i<<endl;
return;     }
     k-=cnt[i];
   }

   cout<<1<<endl;

}

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

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

    return 0;
}
Problem: 2049C - MEX Cycle
Language: c++17 

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

#define x first

#define y second

using namespace std;

#define int long long

typedef pair<int, int> PII;

typedef long long LL;

const int N = 2e5+10;

const int mod = 998244353;

const int p = 1e9 + 7;

int a[N];

void solve(){

   int n, x, y;

	cin >> n >> x >> y;

	a[x] = 1, a[y] = 0;

	int t1 = abs(x-y)-1, t2 = n - 2 - t1;

	if(x > y)swap(x, y);

	int st = x+1;

	

		for(int i = 1; i <= t1/2; i ++) {

			a[st] = 0;

			a[st+1] = 1;

			st+=2;

		}

	if(t1%2)a[st] = 2;

		st = y+1;

		if(st > n)st-=n;

	for(int i = 1; i <= t2/ 2; i ++){

		if(st > n)st-=n;

		a[st] = 1;

		if(st+1 > n)st-=n;

			a[st+1] = 0;

			st+=2;	

	}

	if(st > n)st-=n;

	if(t2%2)a[st] = 2;

	for(int i = 1; i <= n; i++)cout << a[i] <<' ';

	cout <<endl;

}

signed main() {

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    return 0;

}

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

using namespace std;



#define int long long



const int MOD = 1e9 + 7;



void print(vector<int>&v){

    for(auto &a:v)cout<<a<<" ";

    cout<<endl;

}



int mex(int a,int b,int c){

    for(int i=0;i<=(max(max(a,b),c))+1;i++){

        if(a!=i&&b!=i&&c!=i){

            return i;

        }

    }

}

int mexx(int a,int b){

    for(int i=0;i<=(max(a,b))+1;i++){

        if(a!=i&&b!=i){

            return i;

        }

    }

}



void solve(){

    int n,x,y;

    cin>>n>>x>>y;

    vector<int>v(n+1);

    if(x>y)swap(x,y);



    int k=0;

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

        v[i]=k;

        if(k==0)k=1;

        else k=0;

    }

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

        v[i]=k;

        if(k==0)k=1;

        else k=0;

    }



    if(n%2==1||(y-x)%2==0){

        v[x]=2;

    }



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

        cout<<v[i]<<" ";

    }cout<<endl;

}



int32_t main(){

    

    ios_base::sync_with_stdio(false);

    cin.tie(0);



    int t;

    cin>>t;



    while(t--){

        solve();

    }



    return 0;

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

Solution 1 (runtime: 46 ms):
// Created by Rishi Sharma (@rishisharmapro) on 05-02-2025 at 13:10
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())

const ll MOD = 1e9 + 7;
const ll INF = 1e18;

void solve() {
    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++) cin >> a[i];

    ll maxSum = accumulate(a, a+n, 0ll), sum = 0;
    
    while(--n) {
        sum = 0;
        for(int i = 0; i < n; i++) {
            a[i] = a[i+1] - a[i];
            sum += a[i];
        }
        // cout << sum << " ";
        sum = max(sum, -1 * sum);
        maxSum = max(maxSum, sum);
    }
    maxSum = max(maxSum, (ll)a[0]);

    cout << maxSum << endl;
}

int main() {
    // problem: https://codeforces.com/contest/2062/problem/C
    fast_io;
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

#define ll long long
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define YN(f)   cout<<((f) ? "YES":"NO")<<"\n"


ll const mod = 1e9+7;
int N = 5e5+5;
vector<ll> fac,inv;
ll power(ll a,ll b){
    if(b==0)    return 1;
    ll tmp = power(a,b/2);
    if(b%2==0)  return (tmp*tmp)%mod;
    else    return (((tmp*tmp)%mod)*a)%mod;
}
ll ncr(ll n,ll r){
    if(r>n) return 0;
    return (((fac[n]*inv[r])%mod)*inv[n-r])%mod;
}
void init_facts(){
    fac.resize(N);
    inv.resize(N);
    fac[0] = 1;
    for(int i=1;i<N;i++)    fac[i] = (fac[i-1]*i)%mod;
    for(int i=0;i<N;i++)    inv[i] = power(fac[i],mod-2)%mod;
}
ll gcd(ll a,ll b){return b==0 ? a:gcd(b,a%b);}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
/*----------------------------------------------------------------------------------------------------------------------------------*/

void solve(int T){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(auto &x:a)  cin>>x;
    ll ans = accumulate(a.begin(),a.end(),0);
    for(int i=0;i<n-1;i++){
        ll temp = 0;
        for(int j=0;j<a.size()-1;j++){
            a[j] = a[j+1]-a[j];
            temp += a[j];
        }
        a.pop_back();
        ans = max(ans,abs(temp));
    }
    cout<<ans<<"\n";
}

/*----------------------------------------------------------------------------------------------------------------------------------*/
int main()                                                                                
{  
    ios_base::sync_with_stdio(false);                         
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    cin>>t;
    for(int _=1;_<=t;_++){
        solve(_);
    }
    #ifndef ONLINE_JUDGE
        cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
Problem: 2063B - Subsequence Update
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,l,r;

         cin>>n>>l>>r;

         l--;

         r--;



         

         vector<long long >a;

      

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

         {

            long long l;

            cin>>l;

            a.push_back(l);

         }

         vector<long long>b;

         vector<long long>c;

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

         {

            b.push_back(a[i]);

         }

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

         {

            c.push_back(a[i]);

         }

         long long ans=0;



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

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

         long long sum1=0;

         long long sum2=0;

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

         {

            sum1+=b[i];

            sum2+=c[i];



         }

         ans=min(sum1,sum2);

         

       cout<<ans<<endl;

     

       }





         



       













           



        

      

    return 0;



}

      

        



        

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

using namespace std;

#define ll long long

void solve() {

    ll n,l,r;

    cin >> n >> l >> r;

    vector<ll> arr(n+1);

    ll sum = 0;

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

        cin >> arr[i];

    }

    vector<ll> before, after;

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

        before.push_back(arr[i]);

    }

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

    ll ans = LLONG_MAX, size = r-l+1;

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

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

    ll sum1 = 0;

    for (ll i=0; i<size; i++) sum1+=before[i];

    ans = min(ans,sum1);

    sum1 = 0;

    for (ll i=0; i<size; i++) sum1+=after[i];

    ans = min(ans, sum1);

    cout << ans << endl;

}

int main() {

    ll t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2050D - Digital string maximization
Language: c++17 

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



#define ll long long int

#define fr(a, b) for (ll i = a; i < b; i++)

#define fa(a, b) for (ll i = a; i >= b; i--)

using namespace std;



int main()

{

ios_base::sync_with_stdio(false);

cin.tie(NULL);

int t;

cin >> t;

while (t--)

{

string s;

cin >> s;

int n = s.size();

bool m= true;



while (m) {

m = false;

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

int c = s[i] - '0';

int n = s[i + 1] - '0';



if (c < n - 1) {

s[i] = (n - 1) + '0';

s[i + 1] = c + '0';

m = true;

}

}

}



cout << s << endl;

}

return 0;

}

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

using namespace std;



#define fastio ios::sync_with_stdio(0);cin.tie(0)



int main()

{

fastio;

long long t,n,i,j;

string s;

char cur;

cin>>t;

while(t--)

{

cin>>s;

n=s.size();

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

{

cur=s[i];

for(j=i-1;j>=0;j--)

{

if(cur<=s[j]+1)

break;

s[j+1]=s[j];

s[j]=(char)(cur-1);

cur--;

if(cur=='0')

break;

}

}

cout<<s<<"\n";

}

}