ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: c++17 

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

#define all(x)  (x).begin(),(x).end()
#define Y cout<<"YES\n"
#define N cout<<"NO\n"
#define read(v,n) for(int i=0;i<n;i++)\
        {cin>>v[i];}
#define show(v) for(int i=0;i<v.size();i++)\
        {cout<<v[i]<<" ";}\
        cout<<endl
#define mod 1000000007 
int const T=1e5+7;
void solve()
{
    string s;
    cin>>s;
    int tw=0,thr=0;
    ll cnt=0;
    for(int i=0;i<s.size();i++)
    {
        cnt+=(s[i]-'0');
        if(s[i]=='2')
        tw++;
        if(s[i]=='3')
        thr++;
    }
    //cout<<cnt<<" "<<tw<<" "<<thr<<endl;
    if(cnt%9==0)
    {
        Y;
        return;
    }
    else
    {
        int t=(9-(cnt%9));
        if((t==1) && ((tw>4) || (tw>1 && thr>0)))
        Y; 
        else if((t==2) && (tw>0))
        Y;
        else if((t==3) && ((tw>5) || (thr>0 && tw>2) || (thr>1)))
        Y;
        else if((t==4) && (tw>1))
        Y;
        else if((t==5) && ((tw>6) || (thr>0 && tw>3) || (thr>1 && tw>0)))
        Y;
        else if((t==6) && ((tw>2) || (thr>0)))
        Y;
        else if((t==7) && ((tw>7) || (thr>0 && tw>4) || (thr>1 && tw>1)))
        Y;
        else if(t==8 && ((tw>3) || (tw>0 && thr>0)))
        Y;
        else
        N;
    }
}   
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE 
    freopen("input.txt","r",stdin); 
    freopen("error.txt","w",stderr); 
    freopen("output.txt","w",stdout); 
    #endif
    int t=1;
    cin >> t;
    while(t--)
    {
        solve();
    }
}
//ceil a/b is (a+b-1)/b

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



#define ll long long

#define mod 1000000007

#define INF 1e9



using namespace std;



void input1(vector<ll>& num, ll n){

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

}



void input2(vector<vector<ll> >& num, int n, int m) {

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

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

            cin >> num[i][j];

        }

    }

}



void solve() {

	string s;

	cin >> s;

	int dem2 = 0;

	int dem3 = 0;

	ll tong = 0;

	vector<int> num(s.length());

	for(int i=0;i<s.length();++i){

		num[i] = s[i]-'0';

		if(num[i]!=2&&num[i]!=3){

			tong+=num[i];

		}else if(num[i]==2){

			++dem2;

		}else if(num[i]==3){

			++dem3;

		}

	} 

	vector<ll> hai(dem2+1);

	vector<ll> ba(dem3+1);

	hai[0] = 2*dem2;

	ba[0] = 3*dem3;

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

		hai[i] = hai[0]+2*i;

	}

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

		ba[i] = ba[0]+6*i;

	}

	string ans = "NO";

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

		for(int j=0;j<=dem3;++j){

			ll w = hai[i]+ba[j]+tong;

			if(w%9==0){

				ans = "YES";

				break;

			}

		}

		if(ans=="YES"){

			break;

		}

	}

	cout << ans << endl;

}



int main() {

	ios::sync_with_stdio(false);

	int tt; cin >> tt; for (int i = 0; i < tt; i++) {solve();}

	//solve();

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

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

using namespace std;

const int inf = 1e9 + 1;

void ckmin(int& a, int& b){
	if (a > b){
		a -= b;
		b = 0;
	} else if (a < b){
		b -= a;
		a = 0;
	} else{
		a = 0;
		b = 0;
	}
}

void solve(){
	int n; cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++){
		int num; cin >> num;
		arr[i] = num;
	}

	if (arr[0] > arr[1]){
		cout << "NO" << endl;
		return;
	}

	for (int i = 1; i < n - 1; i++){
		ckmin(arr[i - 1], arr[i]);
		if (arr[i] > arr[i + 1]){
			cout << "NO" << endl;
			return;
		}
		if (i > 1 && arr[i - 1] < arr[i - 2]){
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

int main(){

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

	return 0;
}

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

using namespace std;

#define int long long

#define tt() int t; cin >> t; while(t--)

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

#define pb push_back

#define sz(a) ((int)a.size())

#define F first

#define S second

#define __lcm(a,b) (a*b)/__gcd(a,b)

using vi = vector<int>;

using pii = pair<int, int>; 

#define yes cout << "YES\n"

#define no cout << "NO\n"

#define sp ' '

#define endl '\n'

#define rep1(a,n) for (int i = a; i < (n); ++i)

#define rep2(i,a,b) for(int i = a; i <= b ; ++i)

istream& operator>>(istream& is, vector<int>& v) {

for (auto& element : v) is >> element; return is;}

void solve() {

    int n; cin >> n;

    vi v(n);

    cin >> v;

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

        int k = min(v[i],v[i+1]);

        v[i]-=k;

        v[i+1]-=k;

    }

    if(is_sorted(all(v))){

        yes;

    }

    else{

        no;

    }

}



int32_t main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    tt()

    solve();

    return 0;

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

Solution 1 (runtime: 92 ms):
#include <iostream>
#include<iomanip>
#include<climits>
// INT_MAX LLONG_MAX
#include <vector>
#include<array>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define endl "\n"
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ffor(i,a,b) for(int i=(a);i<=(b);i++)
#define rfor(i,a,b) for(int i=(a);i>=(b);i--)
#define fios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define DEBUG cout<<">>>>"<<endl;
using vi=vector<int>;
template<size_t N>
using ai = array<int, N>;
using pii=pair<int,int>;
typedef long long LL;
const int inf=1e18;
const int CJR=998244353;
const int HY_Spark=1e9+7;

// 仅操作一次
void solve(){
	int n,l,r;
	cin>>n>>l>>r;
	vi a(n+1);
	ffor(i,1,n){
		cin>>a[i];
	}
	vi b(n+1),c(n+1);
	ffor(i,1,n){
		if(i<=r){
			b[i]=a[i];
		}
		if(i>=l){
			c[i-l+1]=a[i];
		}
		
	}
	sort(b.begin()+1,b.begin()+1+r);
	sort(c.begin()+1,c.begin()+1+n-l+1);
	int ans1=0,ans2=0;
	ffor(i,1,r-l+1){
		ans1+=b[i];
		ans2+=c[i];
	}
	cout<<min(ans1,ans2)<<endl;
}



signed main(){
    fios;
    int _=1;
    cin>>_;
    while(_--){
        solve();
    }
}

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

void solve() {
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> arr(n);
    
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    
    vector<int> brr = arr;
    sort(brr.begin(), brr.begin() + r);
   
    int p = r - l + 1;
    long long ans = LLONG_MAX;
    long long current_sum = 0;

    for(int i = 0; i < p; i++) {
        current_sum += brr[i];
    }
    ans = min(ans, current_sum);
    sort(arr.begin() + (l - 1), arr.end());
    current_sum = 0;
    for(int i = l - 1; i < l + p - 1; i++) { 
        current_sum += arr[i];
    }
    ans = min(ans, current_sum);
    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 1358 ms):
// Aitijhya Modak

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

struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};

void solution()
{
	int n;
	cin >> n;

	vector<int> arr(n);
	unordered_set<int> st1, st2;
	vector<int> vec;

	for (int i = n; i >= 1; i--)
	{
		vec.push_back(i);
		st1.insert(i);
	}

	for (auto &x : arr)
	{
		cin >> x;
		st2.insert(x);
	}

	vector<vector<int>> output;
	for (int i : vec)
	{
		st1.erase(i);

		for (int j = i - 1; j >= 1; j--)
		{
			if (st1.find(j) != st1.end())
				output.push_back({i, j});
		}
	}

	for (int i : arr)
	{
		st2.erase(i);

		for (int j = i + 1; j <= n; j++)
		{
			if (st2.find(j) != st2.end())
				output.push_back({i, j});
		}
	}

	cout << output.size() << endl;
	for (auto &v : output)
		cout << v[0] << " " << v[1] << endl;
	return;
}

int main()
{
	// int t;
	// cin >> t;
	// while (t--)
	solution();
}


Solution 2 (runtime: 218 ms):
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1005;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vector<int> c(n+1), v(n+1), p(n+1), e(n+1);
	for(int i = 1; i <= n; i++){

		cin >> c[i];
		e[c[i]] = i;
		v[i] = i;
		p[i] = i;
	}


	auto get = [&](){
		for(int i = 1; i <= n; i++) cout << v[i] << ' ';
		cout << '\n';
	};

	vector<pair<int,int>> ans;
	for(int i = n; i > 0; i--){

		int a = c[i]; //value of car that ends at position i
		int j = p[a]; //position of car a in array v

		while(j > 1){
			ans.push_back({v[j], v[j-1]}); // car at position j (a) overtakes the one ahead of it.

			swap(p[v[j]], p[v[j-1]]); //swap the positions of car v[j] (a) and the car ahead of it (v[j-1])
			swap(v[j], v[j-1]); // swap the values in the array
			//get();
			j--;
		}

		//important: keep going back while the ending position of current car e[a] is bigger than next car 
		while(j < n && e[a] > e[v[j+1]]){
			ans.push_back({v[j+1], v[j]});

			swap(p[v[j]], p[v[j+1]]); //swap the positions of car v[j] (a) and the car behind it j+1
			swap(v[j], v[j+1]); // swap the values in the array
			//get();
			j++;
		}
	}



	cout << ans.size() << '\n';
	for(int i = 0; i < (int)ans.size(); i++) cout << ans[i].first << ' ' << ans[i].second << '\n';
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 77 ms):
// Source: https://usaco.guide/general/io

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




void solve(){
	int l,r;
	cin>>l>>r;
	int k= 31 - __builtin_clz(r^l);
	int 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();
	}
}


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

using ll = long long;

const int maxN = 2e5+5;
int MOD = 1e9 + 7;

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

    ll tt;
    cin >> tt;
    while(tt--) {
        ll l,r;
        cin >> l >> r;

        ll a=0,b=0,c=0;

        for(ll i = 30; i >= 0; i--) {
            if(a+(1<<i) <= r && a+(1<<i) > l) {
                a+= 1<<i;
                break;
            }
            else if(a+(1<<i) < r) a+=1<<i;

        }
        b=a-1;
        if(b-1 >= l) c = b-1;
        else if(a+1 <= r) c = a+1;
        cout << a << " " << b << " " << c << "\n";


    }

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

Solution 1 (runtime: 46 ms):
#include <bits/stdc++.h>
using namespace std;
void solve() {
    int n;
  cin >> n;
vector<long long> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
 long long ans = accumulate(a.begin(), a.end(), 0LL);
    for (int i = 1; i < n; i++) {
        vector<long long> b(a.size() - 1);
        for (int j = 0; j < b.size(); j++) {
            b[j] = a[j + 1] - a[j];
        }
      ans=max(ans,abs(accumulate(b.begin(), b.end(), 0LL)));
        a = b;
    }
    cout << ans <<endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) solve();
  
}

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=5e5+10;
int v[maxn], ini[maxn], fim[maxn];
void solve(){
   int n, resp=0, sum=0; cin >> n;
   for(int i=1;i<=n;i++){
       cin >> v[i];
       sum+=v[i];
   }
   if(n==1){
       cout << v[1] << endl;
       return;
   }
   resp=max(sum,abs(v[n]-v[1]));
   for(int i=n-1;i>=1;i--){
       for(int j=1;j<=i;j++) v[j]=v[j+1]-v[j];
       resp=max(resp,abs(v[i]-v[1]));
   }
   cout << resp << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int 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>
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define getrand(l, r) uniform_int_distribution<int>(l, r)(rng)
 
const int mod = 1000000007;
const int oo = 1000000010;
const int N = 200010;

string str;

void solve(){
    cin >> str;
    int n = str.size();
    for(int i = 0; i < n; ++i){
        char mx = str[i];
        int idx = i;
        for(int j = 1; i + j < n && j < 10; ++j){
            if(str[i + j] - j > mx){
                mx = str[i + j] - j;
                idx = i + j;
            }
        }
        for(int j = idx; j > i; --j){
            str[j]--;
            swap(str[j], str[j - 1]);
        }
    }
    cout << str << '\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1; 
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Solution 2 (runtime: 61 ms):
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    vector<set<int>> numSets(10);
    for (int i = 0; i < t; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < s.size(); j++)
        {
            int index = j;
            for (int k = 1; k < 10 && j + k < s.size(); k++)
                if (s[index] - index + j < s[j + k] - k)
                    index = j + k;
            for (int k = index; k > j; k--)
                swap(s[k], s[k - 1]);
            s[j] = s[j] - index + j;
        }
        cout << s << "\n";
    }
}
Problem: 2050D - Digital string maximization
Language: c++17 

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

void solve(string &s) {
    bool swapped = true;
    while (swapped) {
        swapped = false;
        for (int i = 1; i < s.length(); i++) {
            if (s[i] > '0' && s[i] - 1 > s[i - 1]) {
                swap(s[i], s[i - 1]);   // Swap the current digit with the left neighbor
                s[i - 1]--;            // Decrease the digit that moved to the left
                swapped = true;        // Mark as swapped to continue processing
            }
        }
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        solve(s);
        cout << s << endl;
    }
    return 0;
}

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

void solve() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int best = s[i] - '0', pos = i;
        for (int j = i; j < min(i + 10, (int) s.size()); j++) {
            if (s[j] - '0' - (j - i) > best) {
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s << "\n";
}

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

Solution 1 (runtime: 93 ms):
#include <iostream>

using namespace std;

#define ll long long

const int MXN = 200000;

ll a[MXN];

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

    for(int i = 0; i < n; i++)
        cin >> a[i];
    
    bool sorted = true;
    for(int i = 1; i < n; i++)
        if(a[i - 1] > a[i])
        {
            sorted = false;
            break;
        }
    if(sorted)
    {
        cout << "YES" << '\n';
        return;
    }

    for(int i = 0; i < n - 1; i++)
    {
        int diff = min(a[i], a[i + 1]);
        
        a[i] -= diff;
        a[i + 1] -= diff;

        if(!a[i + 1] && a[i] != a[i + 1])
        {
            cout << "NO" << '\n';
            return;
        }
    }

    cout << "YES" << '\n';
}

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

    int tc;
    cin >> tc;

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

    return 0;
}


Solution 2 (runtime: 358 ms):
// Source: https://usaco.guide/general/io



#include <bits/stdc++.h>

using namespace std;



int main() {

	int t;

    cin >> t;



    while (t--) 

    {

        int n;

        cin >> n;



        int a[n];



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

        {

            cin >> a[i];

        }



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

        {

            int sub = min(a[i], a[i + 1]);

            a[i] -= sub;

            a[i + 1] -= sub;

        }



        int possible = true;

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

        {

            if (a[i] < a[i - 1]) 

            {

                possible = false;

                break;

            }

        }



        if (possible) cout << "YES" << '\n';

        else cout << "NO" << '\n';

    }

}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 280 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 
int solve(){
    int n,k,temp;
    cin>>n>>k;
    map<int, int> m;
 
    for(int i=0;i<n;i++){
        cin>>temp;
        m[temp]++;
    }
    vector<int> v;
    for(auto x:m){
        v.push_back(x.second);
    }
    sort(v.begin(),v.end());
    int ans=v.size();
    // cout<<"ans "<<ans<<endl;
 
    if(k==0){
        cout<<ans<<endl;
        return 0;
    }
 
    for(int i=0;i<v.size();i++){
        k-=v[i];
        if(k<0){
            break;
        }
        ans--;
    }
    cout<<max(ans,1)<<endl;
    return 0;
}
int main()
{
    int testCase=1;
    cin>>testCase;
    while(testCase--){
        solve();
    }
    return 0;
}

Solution 2 (runtime: 125 ms):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        
        int x;
        map<int,int> cnt;
        vector<int> a;

        for(int i=1;i<=n;i++)cin>>x,cnt[x]++;
        for(auto c:cnt)a.push_back(c.second);

        int m=a.size();
        sort(a.begin(),a.end());
        int flag=1;
        
        for(int i=0;i<m;i++)
        {
            
            if(a[i]<=k)k-=a[i];
            else{
                cout<<m-i<<endl;
                flag=0;
                break;
            }
        }
        if(flag){
            cout<<1<<endl;
        }
    }
    return 0;
}
// #include<bits/stdc++.h>
// using namespace std;
// int T,n,k,x;
// map<int,int> t;
// vector<int> a;
// int main(){
// 	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
// 	cin>>T;
// 	while(T--){
// 		cin>>n>>k;
// 		t.clear(),a.clear();
// 		for(int i=1;i<=n;i++) cin>>x,t[x]++;
// 		for(auto c:t) a.push_back(c.second);
// 		sort(a.begin(),a.end());
// 		int m=a.size(),flag=0;
// 		for(int i=0;i<m;i++){
// 			if(k>=a[i]) k-=a[i];
// 			else{
// 				cout<<m-i<<endl;
// 				flag=1;
// 				break;
// 			}
// 		}
// 		if(!flag) cout<<1<<endl;
// 	}
// 	return 0;
// }
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 61 ms):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 2010
int t,al,bl,cl,suma[N],sumb[N],dp[N][N];
char a[N],b[N],c[N];
int work()
{
    al = strlen(a + 1);
    bl = strlen(b + 1);
    cl = strlen(c + 1);

    suma[al + 1] = sumb[bl + 1] = 0;
    for(int i = al;i >= 1;--i) suma[i] = suma[i + 1] + (a[i] != c[cl - al + i]);
    for(int i = bl;i >= 1;--i) sumb[i] = sumb[i + 1] + (b[i] != c[cl - bl + i]);

    for(int i = 0;i <= al;++i)
        for(int j = 0;j <= bl;++j) dp[i][j] = 1e15;
    dp[0][0] = 0;

    for(int i = 0;i < al;++i)
        for(int j = 0;j < bl;++j) {
            dp[i + 1][j] = min(dp[i + 1][j],dp[i][j] + (a[i + 1] != c[i + j + 1])); 
            dp[i][j + 1] = min(dp[i][j + 1],dp[i][j] + (b[j + 1] != c[i + j + 1])); 
        }

    int ans = 1e15;
    for(int i = 1;i <= al;++i) ans = min(ans,dp[i - 1][bl] + suma[i]);
    for(int i = 1;i <= bl;++i) ans = min(ans,dp[al][i - 1] + sumb[i]);
    return ans;
}
signed main()
{
    ios::sync_with_stdio(false);

    cin>>t;
    while(t--) {
        cin>>a + 1>>b + 1>>c + 1;
        cout<<work()<<endl;
    }

    return 0;
}

Solution 2 (runtime: 1250 ms):
//OMI_14
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define faster                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

// unordered_map<ll, ll> mp;
// mp.reserve(1024);
// mp.max_load_factor(1);
const int mx=2001;
string a,b,c;
int dp[mx+1][mx+1];

int na,nb;


int func(int i,int j){
     if(i==na && j==nb)return 0;
     if(dp[i][j]!=-1)return dp[i][j];
     int x=INT_MAX;
     int y=INT_MAX;
    if(i<na){
        if(c[i+j]!=a[i]){
            x=func(i+1,j)+1;
        }else
        {
            x=func(i+1,j);
        }
        
    }
    if(j<nb){
        if(c[i+j]!=b[j]){
            y=func(i,j+1)+1;
        }else
        {
            y=func(i,j+1);
        } 
    }
    return dp[i][j]=min(x,y);
}

int main() {
    faster;
    // freopen("input.txt","r",stdin);
    // freopen("output1.txt","w",stdout);

    int t;
    cin>>t;
    while (t--)
    {
        
     
       cin>>a>>b>>c;
        na=a.size(),nb=b.size();
        memset(dp,-1,sizeof(dp));
   
        cout<<func(0,0)<<"\n";
    
        
    }
    
    //  fclose(stdin);
    //  fclose(stdout);
    
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: c++17 

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

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		vector<long long int> a;
		long long int x;
		long long int mxsum = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> x;
			a.push_back(x);
			mxsum += x;
		}

		while (a.size() > 1)
		{
			for (int i = 0; i < a.size() - 1; i++)
			{
				a[i] = a[i + 1] - a[i];
			}
			a.pop_back();
			long long int sum = 0;
			for (auto it : a)
			{
				sum += it;
			}
			
			mxsum = max(abs(sum), mxsum);
		}
		mxsum = max(mxsum, a[0]);
		cout << mxsum << endl;
	}
}


Solution 2 (runtime: 62 ms):
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int t;
	cin>>t;
	vector<long long>arr(1010);
	long long sum=0;
	long long ans=-1e18;
	while(t--)
	{
		ans=-1e18;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>arr[i];
		
		int temp=n;
		for(int g=1;g<=n;g++)
		{
			sum=0;
			if(g!=1)
			{
				for(int i=1;i<=temp;i++)
				{
					if(i+1<=temp)
					arr[i]=arr[i+1]-arr[i];
				}
				temp--;
			}
		
		for(int i=1;i<=temp;i++)
				{
					sum+=arr[i];
				}
				if(g==1)ans=max(ans,sum);
				else
				ans = max(ans,max(sum,-sum));
				
			
		}
		
		cout<<ans<<endl;
		
		
		
	}
	//1 -4  5
	//
	//-5 9      5 -9
	//         -4
	//-14
	
	return 0;
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<iostream>
#include<algorithm>
#include<vector> 
using namespace std;
typedef long long ll;
#define endl '\n'
//const int num=2e5+5;

void solve(){
	ll n,l,r,sum=0;
	cin>>n>>l>>r;
	l--;
	r--;
	vector<ll>v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
		if(i>=l&&i<=r){
			sum+=v[i];
		}
	}
	sort(v.begin(),v.begin()+l);
	sort(v.begin()+l,v.begin()+r+1);
	sort(v.begin()+r+1,v.end());
	ll ans1=sum,ans2=sum;
	for(int i=0,j=r;i<l&&j>=l;i++,j--){
		if(v[j]>=v[i]){
			ans1-=v[j]-v[i];
		}else{
			break;
		}
	}
	for(int i=r+1,j=r;i<n&&j>=l;i++,j--){
		if(v[j]>=v[i]){
			ans2-=v[j]-v[i];
		}else{
			break;
		}
	}
	cout<<min(ans1,ans2)<<endl;
	return;
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t=1;
	cin>>t;
	
	while(t--){
		solve();
	}
	return 0;
}

Solution 2 (runtime: 171 ms):
#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();

    }





}