ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 108 ms):
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k,t,n,m;
int main()
{
	cin>>t;
	while(t--)
	{
		ll l,r;
		cin>>l>>r;
		if(r-l==2)
		{
			cout<<l<<' '<<l+1<<' '<<l+2<<'\n';
			continue;
		}
		ll x=0,y=0,z=0;
		ll lr[40],rl[40],c1=0,c2=0;
		while(r)
		{
			lr[++c1]=r%2;
			r/=2;
			rl[++c2]=l%2;
			l/=2;
		}
		ll q=pow(2,c1-1);
		for(i=c1;i>=1;i--)
		{
			if(lr[i]==rl[i])
			{
				c1--;
				c2--;
				if(lr[i]==1)
				{
				x+=q;
				y+=q;
				z+=q;
				}
				q/=2;
			}
			else break;
		}
		x+=q;
		z+=q-1;
		for(i=c2;i>=1;i--)
		{
			if(rl[i]==1)
			{
				y+=q;
			}
			q/=2;
		}
		if(z==y) y+=2;
		cout<<x<<' '<<y<<' '<<z<<'\n';
	}
}

Solution 2 (runtime: 77 ms):
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;

#define rep(i, s, n) for (long long int i = s; i < n; i++)
#define revrep(i, n, s) for (long long int i = n - 1; i >= s; i--)
#define pb push_back
#define nl '\n'
#define ll long long int
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define psi pair<string, int>
#define p_q priority_queue
#define minheap p_q<int, vi<int>, greater<int>>
#define maxheap p_q<int>
#define umap unordered_map
#define inf 1e9
#define longinf 1e18
#define fir first
#define sec second
#define vi vector
#define qu queue
#define l_b lower_bound
#define u_b upper_bound
#define yes cout << "YES" << nl
#define no cout << "NO" << nl
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()

const ll N = 1e5 + 10;
const ll INF = LLONG_MAX >> 1;
const ll mod = 1e9 + 7;

ll query(ll l, ll r)
{
    ll x;
    cout << "? " << l << " " << r << endl;
    cin >> x;
    return x;
}
ll pwr(ll a, ll b)
{
    a %= mod;
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = (res * 1LL * a) % mod;
        a = (a * 1LL * a) % mod;
        b >>= 1;
    }
    return res;
}

void solve()
{
    ll l, r;
    cin >> l >> r;
    ll x = -1, k = 0;
    for (ll i = 31; i >= 0; i--)
    {
        if (((l >> i) & 1LL) != ((r >> i) & 1LL))
        {
            x = i;
            break;
        }
        k += (((l >> i) & 1LL) << i);
    }
    ll a = k, b = k, c;
    for (ll i = x - 1; i >= 0; i--)
        a += (1LL << i);
    b += (1LL << x);
    if (l != a and l != b)
        c = l;
    else if (r != a and r != b)
        c = r;
    else
        c = l + 1;
    // ll val = (a ^ b) + (b ^ c) + (c ^ a);
    // cout << val << nl;
    cout << a << " " << b << " " << c << nl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: c++17 

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

const int N = 60;
int n;
ll a[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int T;
	cin >> T;
	while (T--) {
		cin >> n;
		for (int i = 1; i <= n; i++) cin >> a[i];
		ll ans = -1e18;
		int now = n;
		for (int i = 1; i <= n; i++) {
			ll sum = 0;
			for (int i = 1; i <= now; i++) sum += a[i];
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans,	abs(sum));
			for (int i = 1; i < now; i++) a[i] = a[i+1] - a[i];
			now --;
		}
		cout << ans << '\n';
	}
	
	return 0;
}

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

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        long long int s=0, m=0;
        long long int arr[n];
        for(int i=0; i<n; i++){
            cin >> arr[i];
            m += arr[i];
        }
        for(int i=0; i<(n-1); i++){
            s=0;
            for(int j=0; j<(n-1-i); j++){
                arr[j] -= arr[j+1];
                s += arr[j];
            }
            m = max(m, s);
            m = max(m, -s);
        }
        cout << m << endl;
    }
}
Problem: 2050C - Uninteresting Number
Language: c++17 

Solution 1 (runtime: 78 ms):
#include <iostream>
#include <string>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int a[10];
        for (int i = 0; i < 10; i++) {
            a[i] = 0;  // Initialize the count array to 0
        }
        for (int i = 0; i < s.length(); i++) {
            if (s[i] >= '0' && s[i] <= '9') {
                a[s[i] - '0']++; 
            }
        }
        long long sum = 0;
        for (int i = 0; i < 10; i++)
        {
            sum += a[i]*i;
        }
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
            continue;
        }
        if (sum % 3 == 1)
        {   
            if (a[2] >= 1)
            {
                sum += 2;
                a[2]--;
            }
            else
            {
                cout << "NO" << endl;
                continue;
            }
        }
        else if (sum % 3 == 2)
        {

            if (a[2] >= 2)
            {
                sum += 4;
                a[2]-= 2;
            }
            else
            {
                cout << "NO" << endl;
                continue;
            }
        }
        if (sum % 9 == 0)
        {
            cout << "YES" << endl;
            continue;
        }
        else if (sum % 9 == 6)
        {
            if (a[2] >= 3)
            {
                sum += 6;    
                a[2] -= 3; 
            }
            else if (a[3] >= 2)
            {
                cout << "YES" << endl;
                continue;
            }
            else
            {
                cout << "NO" << endl;
                continue;
            }
        }
        if (sum % 9 == 3)
        {
            if (a[2] >= 3)
            {
                cout << "YES" << endl;
                continue;
            }
            if (a[3] >= 1)
            {
                cout << "YES" << endl;
                continue;
            }
            else
            {
                cout << "NO" << endl;
                continue;
            }
        }
    }
}


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

using namespace std;

long long get_sum(long long sum){
    while(sum > 9){
        long long n = sum;
        sum = 0;
        while(n > 0){
            sum += n%10;
            n /= 10;
        }
    }
    return sum;
}

void solve(string s){
    long long arr[s.size()];
    long long sum = 0;
    int two = 0,three = 0;
    for(int i = 0;i < s.size();i++){
        arr[i] = s[i] - '0';
        sum += arr[i];
        if(arr[i] == 2)two++;
        else if(arr[i] == 3)three++;
    }
    sum = get_sum(sum);
    for(int i = 0;i < min(10,two + 1);i++){
        for(int j = 0;j < min(10,three + 1);j++){
            if((sum + i*2 + j*6)%9 == 0){
                cout << "YES\n";
                return;
            }
        }
    }
    cout << "NO\n";
    return;
}


int main(){
    int t;
    cin >> t;
    while(t--){
        string s;
        cin >> s;
        solve(s);
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 124 ms):
//! Bismillahi-Rahamanirahim.
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define str string
#define vll vector<ll>
// vector<vector<ll>> a(n,vector<ll>(n,v));
// priority_queue <int, vector<int>, greater<int>> pq;
#define pl pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define sz(n) (ll)(n).size()
#define sp ' '
#define sfor(i, s, n, m) for (ll i = s; i < n; i += m)
#define refor(i, n, s, m) for (ll i = n - 1; i >= s; i -= m)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define eps 1e-12
#define mod 1000000007
#define MAX 100007
#define inf 1000000000000000000
#define pi (2 * acos(0))
#define torad(x) ((x) * ((2 * acos(0)) / 180.0))
#define todeg(x) ((x) * (180.0 / (2 * acos(0))))
#define fixangle(x) ((x) > 1 ? 1 : (x) < -1 : (x))
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define endl "\n"
#define mem(x, y) memset(&x[0], y, sizeof(x))
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define ub(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define lb(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define fast() ios_base::sync_with_stdio(0);
#define fast1() cin.tie(0);cout.tie(0);
//-------------------------------------------------------------------------//

int main()
{
    fast();
//    fast1();
    ll test = 1, cas = 1;
    cin >> test;
    while (test--)
    {
        ll n,f=1;
        cin >> n;
        vll a(n,0);
        sfor(i,0,n,1)
        {
            cin >> a[i];
        }
        sfor(i,0,n-1,1)
        {
            if(a[i]>a[i+1])
            {
                f=0;
                break;
            }
            else if(a[i]<a[i+1])
            {
                a[i+1]-=a[i];
            }
            else
            {
                i++;
            }
        }
        if(!f)
            no;
        else
            yes;
    }
    return 0;
}


Solution 2 (runtime: 124 ms):
#include<iostream>
#include<vector>
#include<deque>
#include<string>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<utility>
#include<set>
#include<fstream>
#include<map>
#include<stack>
#include <queue>
#define ll long long
#define lpi(i , n) for(int i = 0 ; i < n ; i++)
#define vi vector<int>
#define dvi vector<vector<int>>
#define srti(p) p.begin() , p.end()
#define ends "\n"
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
  fst;
  ll t ;
  cin >> t;
  while (t--)
  {
    ll x;
    cin >> x;
    vector<ll>p(x);
   for(ll i = 0 ; i < x ;i++)
    {
      cin >> p[i];
    }
    int f = 0;
    for(ll i = 0 ; i < x-1 ;i++)
    {
      if(p[i] < p[i+1])
      {
        p[i+1] -= p[i];
        p[i] = 0;
      }
      else if(p[i] > p[i+1])
      {
        f= 1;
      }
      else{
        p[i]=0;
        p[i+1]=0;
        i++;
      }
    }
    if(p[x-2] > p[x-1] || f)
    {
      cout << "NO" << ends;
    }
    else{
      cout << "YES" << ends;
    }
  
  }
  
  
}
Problem: 2052A - Adrenaline Rush
Language: c++17 

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

#ifdef DEBUG
#include <debug.h>
#else
#define dbg(x...)
#endif


using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pil = std::pair<int, ll>;
using pll = std::pair<ll, ll>;
using pli = std::pair<ll, int>;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;
typedef std::vector<pii> vpii;
typedef std::vector<pil> vpil;
typedef std::vector<pli> vpli;
typedef std::vector<pll> vpll;
typedef std::vector<bool> vb;

#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int) (x).size()
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= b; i--)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define nl cout << "\n"
#define ins insert
#define RET return









void solve() {

}

int main() {
        ios::sync_with_stdio(false), cin.tie(nullptr);
        int n;
        cin >> n;
        vector<int> c(n);
        for (int i = 0; i < n; i++) cin >> c[i];
        vector<pair<int, int>> ans;
        for (int i = n; i >= 1; i--) {
                for (int j = i - 1; j >= 1; j--) ans.push_back({i, j});
        }
        vector<int> a(n);
        for (int i = 0; i < n; i++) a[i] = n-i;
        for (int i = 0; i < n; i++) {
                int j = i;
                while (j < n && a[j] != c[i]) {
                        j++;
                }
                while (j - 1 >= i) {
                        ans.push_back({a[j], a[j-1]});
                        swap(a[j], a[j-1]);
                        j--;
                }
        }

        cout << ans.size() << "\n";
        for (auto [x, y] : ans) cout << x << " " << y << "\n";
}


Solution 2 (runtime: 218 ms):
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long

const int N = 1005;
int n, mp[N], dmp[N], a[N], pos[N];
bool vis[N];

inline void init()
{
	cin >> n;
	for (int i = 1; i <= n; i++) a[i] = i;

	for (int i = 1; i <= n; i++)
	{
		int x; cin >> x;
		mp[x] = i;
		dmp[i] = x;
	}

	for (int i = 1; i <= n; i++) a[i] = mp[i], pos[a[i]] = i;
}

inline void solve()
{
	if (n == 1)
	{
		cout << 0 << endl;
		return;
	}

	vector<pair<int, int>> ans;

	for (int i = n; i >= 1; i--)
	{
		int tar = n-i+1;
		if (pos[i] == tar)
		{
			continue;
		}

		for (int j = pos[i]-1; j >= tar; j--)
		{
			ans.emplace_back(dmp[a[j+1]], dmp[a[j]]);
			swap(pos[a[j]], pos[a[j+1]]);
			swap(a[j], a[j+1]);
		}
	}

	for (int i = 1; i <= n; i++)
		for (int j = i+1; j <= n; j++)
			ans.emplace_back(dmp[i], dmp[j]);

	cout << ans.size() << endl;
	for (auto pt : ans)
		cout << pt.first << " " << pt.second << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	init();
	solve();

	return 0;
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 108 ms):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
 
void solve(){
    int n,l,r;
    cin>>n>>l>>r;
    vector<int>v;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    vector<int>lrr,rrr;
    lrr=v;
    rrr=v;
    sort(lrr.begin(),lrr.begin()+r);
    sort(rrr.begin()+l-1,rrr.end());
    int ans1=0,ans2=0;
    for(int i=l;i<=r;i++){
        ans1+=lrr[i-l];
        ans2+=rrr[i-1];
    }
    cout<<min(ans1,ans2)<<endl;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int tc;
  cin>>tc;
  for(int i=0;i<tc;i++)solve();
  return 0;
}


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

#include <queue>

#include <set>





#define mod 1000000007

#define ll long long int

#define ull unsigned long long int

#define ld long double

#define pb push_back

#define eb emplace_back

#define mkp make_pair

#define pii pair<int, int>

#define pll pair<long long int, long long int>

#define fi first

#define sc second

#define String string

#define no cout<<"NO\n";

#define yes cout<<"YES\n";

#define countIntBit(x) __builtin_popcount(x)

#define countLLBit(x) __builtin_popcountll(x)

#define gcd(x,y) __gcd((ull)x,(ull)y)





using namespace std;



static int aQWEs = []()-> int {

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    return 0;

}();



ll sqrt(ll p) {

    ll low = 1, high = p, mid;



    while (low < high) {

        mid = (low + high + 1) / 2;

        if (mid * mid > p) {

            high = mid - 1;

        } else {

            low = mid;

        }

    }

    return low;

}





ll power(ll a,ll p,ll m = mod) {

    a %= m;

    ll val = 1;

    while (p > 0) {

        if (p & 1) {

            val = (val * a) % m;

        }

        a = (a * a) % m;

        p >>= 1;

    }

    return (val);

}



//====================================================



ll sum(priority_queue<int> pq) {

    ll sum=0;

    while (!pq.empty()) {

        sum += pq.top();

        pq.pop();

    }

    return sum;

}



int main() {

    ll i, j;



    int T = 1;

    cin >> T;

    while (T--) {

        int n,l,r;

        cin >> n>>l>>r;

        l--;

        r--;

        vector<int> v(n);

        priority_queue<int> pqLeft;

        priority_queue<int> pqRight;

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

            cin>>v[i];

            if (i>=l && i<=r){

                pqLeft.push(v[i]);

                pqRight.push(v[i]);

            }

        }



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

            if(pqLeft.top() > v[i]) {

                pqLeft.pop();

                pqLeft.push(v[i]);

            }

        }

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

            if(pqRight.top() > v[i]) {

                pqRight.pop();

                pqRight.push(v[i]);

            }

        }

        cout<<min(sum(pqLeft), sum(pqRight))<<endl;

    }

}
Problem: 2063B - Subsequence Update
Language: c++17 

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



using namespace std;



#define MOD 666013

#define int long long

#define NMAX 100005

#define pb push_back



vector <int> v, aux;



signed main()

{

    int tt;

    cin >> tt;

    while (tt--) {

      ///fac un merge 1->r, si unul l->n si aleg cele mai mici (r-l+1)

        int n, l, r, s = 0, ans = LONG_LONG_MAX;

        cin >> n >> l >> r;

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

            int x;

            cin >> x;

            v.pb(x);

        }

        l--, r--;

        for (int i = 0; i <= r; i++) aux.pb(v[i]);

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

        if (!aux.empty())

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

                s += aux[i];

        ans = min(ans, s);



        aux.clear(), s = 0;



        for (int i = l; i < v.size(); i++)

            aux.pb(v[i]);

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

        if (!aux.empty())

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

             s += aux[i];

        ans = min(ans, s);

        cout << ans << '\n';

        v.clear();

        aux.clear();

    }

    return 0;

}



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

using namespace std;

long long t,n,l,r,a[1000005],ans,maxx,minn;

bool flag;

int main()

{

	cin>>t;

	while(t--)

	{

		cin>>n>>l>>r;

		ans=0;

		maxx=0;

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

		{

			cin>>a[i];

			if(i>=l&&i<=r)

			{

				maxx+=a[i];

			}

		}

		sort(a+1,a+l);

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

		sort(a+l,a+r+1);

		for(int i=r;i>=l;i--)

		{

			long long cnt=0;

			flag=0;

			if(l-1>r-i)

			{

				flag=1;

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

				{

					cnt+=a[j];

				}

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

				{

					cnt+=a[j];

				}

				maxx=min(maxx,cnt);

			}

			if(n-r>r-i)

			{

				cnt=0;

				flag=1;

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

				{

					cnt+=a[j];

				}

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

				{

					cnt+=a[j];

				}

				maxx=min(maxx,cnt);

			}

			if(!flag)

			{

				break;

			}

		}

		cout<<maxx<<endl;

	}

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 108 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(a) (a).begin(), (a).end()
#define pb(x) push_back(x)
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define show(a)                        \
    for (int i = 0; i < a.size(); i++) \
    cout << a[i] << " "
#define vec vector<ll>
#define yes cout << "YES\n";
#define no cout << "NO\n";

ll MOD = 1000000007;
// 169236

bool compair(const pair<ll, ll> a, const pair<ll, ll> b)
{
    return a.second < b.second;
}
bool isPrime(ll a)
{
    for (ll i = 2; i * i <= a; i++)
    {
        if (a % i == 0)
        {
            return 0;
        }
    }
    return 1;
}
long long binpow(long long a, long long b)

{
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
pair<vector<ll>,vector<ll>> fun(vector<ll>v){
    vector<ll>v1=v;
    reverse(all(v1));
    return make_pair(v,v1);
}
ll sum(vector<int>v){
        vector<ll> v1;
        for (int i = 1; i < v.size(); i++)
        {
            v1.pb(v[i] - v[i - 1]);
        }
        ll p = accumulate(all(v1), 0ll);
        return p;
}
void solve()
{
    int n;
    cin >> n;
    vector<ll> v;
    fr(i, 0, n)
    {
        int ai;
        cin >> ai;
        v.pb(ai);
    }
    fr(i,0,n-1){
       ll a= min(v[i+1],v[i]);
       v[i]=v[i]-a;
       v[i+1]=v[i+1]-a;
       if(v[i+1]<v[i]){
            cout<<"NO\n";
            return;
       }

    }
    cout<<"YES\n";
 
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}


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

using ll = long long;
void solve(){
    int n; 
    cin>>n;
    vector<int> a(n);
    for(auto& num:a) cin>>num;

    for(int i=1;i<n;i++){
        if(a[i-1]>a[i]){
            cout<<"NO\n"; return;
        }
        a[i]-=a[i-1];
    }
    cout<<"YES\n";
}
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: 61 ms):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<vector<long long int>> a;
        vector<long long int> b(n,0);
        long long int ans=0;
        for(int i=0;i<n;i++){
            cin>>b[i];
            ans+=b[i];
        }
        a.push_back(b);
        if(n==1){cout<<b[0]<<endl;continue;}
        
        for(int j=1;j<n;j++){
            vector<long long int> temp(n-j);
            for(int i=0;i<n-j;i++){
                temp[i]=a[j-1][i+1]-a[j-1][i];
 
            }
            long long int sum=0;
            a.push_back(temp);
            for(int i=0;i<n-j;i++){
                sum+=temp[i];

            }
            ans=max(abs(sum),ans);
        }
        cout<<ans<<endl;
    }
}

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


signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t;cin >> t;
    while (t --) {
        int n;
        cin >> n;
        vector<int> arr(n + 1, 0);
        for (int i = 1; i <= n; ++i) {
            cin >> arr[i];
        }
        int ans = -1e18;

        for (int i = 1; i <= n; i++){
            int sum = 0;
            for (int i = 1; i <= arr.size() - 1; i++) sum = (sum + arr[i]) ;
            if (i == 1) ans = max(ans, sum);
            else ans = max(ans, max(sum, ( - sum) ));
            for (int i = 1; i < arr.size() - 1; i++)
                arr[i] = (arr[i + 1] - arr[i]) ;
            arr.pop_back();
        }

        cout << ans << '\n';

    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 186 ms):
#include<iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    vector<long long> ans;
    while(t--){
        int n,l,r,x;
        cin>>n>>l>>r;
        vector<int> vec(n,0);
        vector<int> help(n,0);
        for(int i=0;i<n;i++){
            cin>>x;
            vec[i]=x;
            help[i]=x;
        }
        sort(vec.begin(), vec.begin()+r);
        sort(help.begin()+(l-1), help.end());
        int i=0, j=l-1;
        long long sum1=0, sum2=0;
        while(i<=(r-l)) sum1+=vec[i++];
        while(j<r) sum2+=help[j++];
        ans.push_back(min(sum1, sum2));
        
    }
    for(auto num:ans) cout<<num<<endl;
    return 0;
}


Solution 2 (runtime: 483 ms):
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
#define lint long long

lint read(){
	lint x=0;int f=1;char c=getchar();
	while(c<'0' or c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' and c<='9'){x=x*10+c-48;c=getchar();}
	return x*f;
}

const int N=1e5+5;
int times;
int n,l,r;
lint a[N],b[N];
lint f,d;
lint ans;

int main(){
	times=read();
	while(times--){
		n=read(),l=read(),r=read();
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		f=d=0;
		for(int i=1;i<=n;i++){
			a[i]=b[i]=read();
		}
		sort(a+1,a+1+r);
		sort(b+l,b+1+n);
		for(int i=1;i<=r-l+1;i++){
			f+=a[i];
//			cout<<"f:"<<f<<" ";
		}
		for(int i=l;i<=r;i++){
			d+=b[i];
//			cout<<"d:"<<d<<endl;
		}
		ans=min(f,d);
		printf("%lld\n",ans);
	}
	return 0;
}