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

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

#define ull unsigned long long int
#define ll long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define cv(x) vector<long long int> x
#define cvn(x, n, val) vector<long long int> x(n, val)
#define fl(i, x) for( int i = 0; i < x; i++ )
#define pv(v) for( auto i: v){ cout<<i<<'	';}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        cvn(v, n, 0);
        ll sum = 0;
        fl(i, n){
            cin>>v[i];
            sum += v[i];
        }
        while(v.size() > 1){
            //now replacing the array with difference of elements
            // cout<<"v size is: "<<v.size()<<endl;
            ll sum1 = 0;
            cv(temp);
            for( int i = 1; i < v.size(); i++ ){
                temp.pb(v[i] - v[i-1]);
                sum1 += (v[i] - v[i-1]);
            }
            sum = max(sum, abs(sum1));
            v = temp;
        }
        cout<<sum<<endl;
    }
    return 0;
}

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

using namespace std;

void operate(vector<long long> &a, int l, int n) {
    for (int i = n - 1; i > l; i--) {
        a[i] = a[i] - a[i - 1];
    }
}

long long sum(vector<long long> &a, int l, int n) {
    long long acc = 0;
    for (int i = l; i < n; i++) {
        acc += a[i];
    }
    return acc;
}

int main() {
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        vector<long long> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }

        int count = 1;
        long long best = sum(a, 0, n);

        for (int l = 0; l < n - 1; l++) {
            operate(a, l, n);
            long long curr = sum(a, l + 1, n);
            best = max(best, curr);
            if (count % 2 == 1) {
                best = max(best, -curr);
            }
        }
        cout << best << '\n';
    }
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 265 ms):
#include<bits/stdc++.h>
#define memclear(a) memset(a,0,sizeof(a))
using namespace std;
const int inf=0x3f3f3f3f;
using ll=long long;
int num[200050];
void solve(string s){
	int n=s.length();
	memclear(num);
	int i,j,maxn,maxi;
	for(i=0;i<n;i++){
		num[i]=s[i]-'0';
	}
	for(i=0;i<n;i++){
		maxn=num[i];
		maxi=i;
		for(int j=i+1;j<i+9&&j<=n;j++){
			int m=j-i;
			if(num[j]-m>maxn){
				maxn=num[j]-m;
				maxi=j;
			}
		}
		if(maxi!=i){
			for(int k=maxi;k>=i+1;k--){
				num[k]=num[k-1];
			}
			num[i]=maxn;
		}
	}
	for(int i=0;i<n;i++) cout<<num[i];
	cout<<"\n";
}
int main(){
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  int t;
  cin>>t;
  while(t--){
		string s;
	  cin>>s;
	  solve(s);
	}
  return 0;
}


Solution 2 (runtime: 93 ms):
#include<bits/stdc++.h>
#define ll long long
#define nl endl
const ll mod = 1e9+7;
using namespace std;
# define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define mkpr make_pair
#define fir first
#define sec second

bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){//increasing order
    return (a.second < b.second);
}
int nCr(int n, int r) {
    double sum = 1;
    for (ll i = 1; i <= r; i++) {
        sum = sum * (n - r + i) / i;
    }
    return sum;
}
 
ll gcd(ll x,ll y){//where x>y
    if (y == 0) return x; 
    return gcd(y,x%y);
}

ll binexp(int a, int b, int m) {
    ll result = 1;  // result should be long long
    while (b > 0) {
        if (b & 1) {
            result = (result * a) % m;
        }
        a = (1ll*(a) * a) % m;  // cast a to long long to prevent overflow
        b >>= 1;  // use compound assignment
    }
    return result;
}
 
ll power(int x, unsigned int y){
    ll temp;
    if (y == 0) return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0) return temp * temp;
    else return x * temp * temp;
}

int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        for (int i = 0; i < s.size(); ++i)
        { 
            int ind=i;
            char suhani=s[i];
            for (int j = 0; i+j <s.size() && j<=9; ++j)
            {
                if(s[i+j]-j>suhani)
                {
                      suhani=s[i+j]-j;
                ind=i+j;
                  
                }
            }

            for (int k = ind; k > i; k--)
                
        {
            s[k]=s[k-1];
        }
        s[i]=suhani;
        }
        cout<<s<<nl;

    
    }

}
Problem: 2049B - pspspsps
Language: c++17 

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

using namespace std;

void solve(void)

{

	int n;cin>>n;

	string s;cin>>s;

	int snum=0,pnum=0;

	bool pj=1;int posp,poss;

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

	{

		if(pj&&s[i]=='p')

		{

			posp=i;

			pj=0;

		}

		if(s[i]=='s')

		{

			snum++;

			poss=i;

		}

		if(s[i]=='p')

			pnum++;

	} 

	if(snum!=0&&pnum!=0&&posp<poss)

	{

		cout<<"NO\n";

		return ;

	}

	if(snum>1&&pnum>1)

	{

		cout<<"NO\n";

		return;

	}

	if(snum==1&&pnum==1&&(s[0]=='s'||s[n-1]=='p'))

	{

		cout<<"YES\n";

		return;

	}

	if(snum==1&&pnum!=0&&s[0]!='s')

	{

		cout<<"NO\n";

		return;

	}

	if(pnum==1&&snum!=0&&s[n-1]!='p')

	{

		cout<<"NO\n";

		return;

	}

//	cout<<posp<<" "<<poss<<endl;

	cout<<"YES\n";

}

signed main(void)

{

	ios::sync_with_stdio(0);

	cin.tie(0);cout.tie(0);

	int t;cin>>t;

	while(t--)

	{

		solve();

	}

}

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

using namespace std;



int main() {

	// your code goes here

	int t;

	cin>>t;

	while(t--)

	{

	    int n;

	    cin>>n;

	    

	   string s;

	   cin>>s;

	   

	   bool a = false;

	   bool b = true;

	   bool c = false;

	   

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

	   {

	       if(s[i]=='p' && s[i+1]=='s')

	       {

	           b = false;

	           break;

	       }

	       

	   

	   }

	   

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

	   {

	       if((s[i]=='.' || s[i]=='s') && s[i+1]=='s')

	       {

	           a = true;

	       }

	       

	       if(s[i] =='p' && (s[i+1]=='.' || s[i+1]=='p'))

	       {

	           c = true;

	       }

	   }

	   

	   if(a&c)

	   {

	       b = false;

	   }

	   

	   if(b)

	   {

	       cout<<"YES"<<endl;

	   }

	   

	   else

	   {

	       cout<<"NO"<<endl;

	   }

	    

	}

}
Problem: 2050E - Three Strings
Language: c++17 

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

int answer(int n, int m, string &a, string &b, string &c, vector<vector<int>> &dp)
{
    if (n <= 0 && m <= 0)
        return 0;

    if (dp[n][m] != -1)
        return dp[n][m];

    int mini = INT_MAX;
    if (n > 0)
    {
        int x = n - 1, y = m - 1;
        mini = (a[x] != c[x + y + 1]) + answer(n - 1, m, a, b, c, dp);
    }

    if (m > 0)
    {
        int x = n - 1, y = m - 1;
        mini = min(mini, (b[y] != c[x + y + 1]) + answer(n, m - 1, a, b, c, dp));
    }

    // cout << n << " " << m << " "<<mini<<endl;
    return dp[n][m] = mini;
}

void solve()
{
    string a, b, c;
    cin >> a >> b >> c;

    int n = a.size(), m = b.size();

    vector<vector<int>> dp(n + 1, vector<int>(m + 1, -1));

    cout << answer(n, m, a, b, c, dp) << endl;
}

signed main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Solution 2 (runtime: 93 ms):
#include <bits/stdc++.h>
#define MOD 1000000007
#define loop(i, a, b) for (int i = a; i < b; i++)
#define append push_back
#define vi vector<int>
#define mi map<int, int>
#define sortv(a) sort(a.begin(), a.end())
#define int long long

typedef unsigned long long ull;

using namespace std;

void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

// <-----------SidZRed-------------->
// <----Why are you reading this---->

signed main() {
    fast_io();

    int t;
    cin >> t;

    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;

        int n = a.length(), m = b.length(), k = c.length();

        // DP table: dp[x][i] -> min changes for first x chars of c using first i chars of a
        vector<vector<int>> dp(k + 1, vector<int>(n + 1, INT_MAX));
        dp[0][0] = 0; 

        for (int x = 1; x <= k; x++) {
            if (x <= m) {
                dp[x][0] = dp[x - 1][0] + (c[x - 1] != b[x - 1]);
            }
        }

        for (int i = 1; i <= n; i++) {
            if (i <= k) {
                dp[i][i] = dp[i - 1][i - 1] + (c[i - 1] != a[i - 1]);
            }
        }

        for (int x = 1; x <= k; x++) {
            for (int i = 0; i <= min(x, n); i++) {
                int j = x - i; 
                if (j > m) continue; 

                if (j > 0 && x - 1 >= 0) {
                    dp[x][i] = min(dp[x][i], dp[x - 1][i] + (c[x - 1] != b[j - 1]));
                }

                if (i > 0 && x - 1 >= 0) {
                    dp[x][i] = min(dp[x][i], dp[x - 1][i - 1] + (c[x - 1] != a[i - 1]));
                }
            }
        }

        int ans = INT_MAX;
        for (int i = 0; i <= n; i++) {
            ans = min(ans, dp[k][i]);
        }

        cout << ans << endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 187 ms):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t-->0){
        long long int n,l,r;
        cin>>n>>l>>r;
        vector<long long int>v(n);
        vector<long long int>a,b;
        long long int g=(r-l)+1;
        for(long long int i=0;i<n;i++){
            cin>>v[i];
        }
        for(long long int i=l-1;i<n;i++){
            a.push_back(v[i]);
        }
        for(long long int i=0;i<r;i++){
            b.push_back(v[i]);
        }
        sort(a.begin(),a.end());
        sort(b.begin(),b.end());
        long long int ans1=0;
        long long int ans2=0;
        long long int ans=0;
        for(int i=0;i<g;i++){
            ans1+=(a[i]);
        }
        for(int i=0;i<g;i++){
            ans2+=(b[i]);
        }
        cout<<min(ans1,ans2)<<endl;
    }
}

Solution 2 (runtime: 202 ms):
//================================================================================

//===========================( اللهم صّلِ وسَلّمْ عَلۓِ نَبِيْنَا مُحَمد ﷺ )=======================

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

#include <bits/stdc++.h>



void fastIO();





#define For(index,start,end) for(LI index {start} ; index < end ; ++index)

#define Loop(end)            for(LI i {0} ; i < end ; ++i)

#define CFor(i,container)    for(const auto& i : container)

#define RFor(i,container)    for(auto& i : container)

#define F first

#define S second



#define print(container)     for(const auto& x : container)cout << x << ' ';cout << '\n';



using namespace std;

typedef unsigned long long int ULLI;

typedef unsigned long int ULI;

typedef long long int LLI;

typedef long int LI;



void solve(){

    int n, l, r;

    cin >> n >> l >> r;



    vector<long> left(r) , right(n - l + 1);

    RFor(x,left)cin >> x;

    for(int i {l-1}, j {} ; i < r ;  i++ , j++){

        right.at(j) = left.at(i);

    }



    for(int i{r-l+1} ; i < right.size() ; i++){

        cin >> right.at(i);

    }



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

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



    long long ans1{}, ans2{};

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

        ans1 += left.at(i);

        ans2 += right.at(i);

    }



    cout << min(ans1,ans2);

}



int main() {

    int t {1};

    cin >> t;

    for(;t--;cout << '\n')solve();



    return 0;

}



/*---------------------------------------------------

 

	   Welcome to my program!

 

	　　 ∧＿∧       

	　 ( 　･ω･)

	＿(__つ/￣￣￣￣/  

	　　＼/　　　　 /  

	　　　　￣￣￣￣

		   Let's write Code!

 

---------------------------------------------------*/

void fastIO() {

    std::cin.tie(nullptr)->sync_with_stdio(false);

}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 62 ms):
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin >> a >> b >> c;
    int n=a.size(),m=b.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)for(int j=0;j<=m;j++) dp[i][j]=1e9;
    dp[0][0]=0;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
        {
            if(!i&&!j) continue;
            if(i) dp[i][j]=dp[i-1][j]+(a[i-1]!=c[i+j-1]);
            if(j) dp[i][j]=min(dp[i][j],dp[i][j-1]+(b[j-1]!=c[i+j-1]));
        }
    cout << dp[n][m] << endl;
}
signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
    return 0;
}

Solution 2 (runtime: 484 ms):
#include <bits/stdc++.h>
#define MAX
using namespace std;
using ll = long long;
#define FIND(x) (vis.find(x) != vis.end())
#define KEY(p1, p2) ((p2)*(na+1) + (p1))
#define FINDKEY(p1, p2) (FIND(KEY((p1), (p2))))

int na, nb;
string a, b, c;

/*
7
a
b
cb
ab
cd
acbd
ab
ba
aabb
xxx
yyy
xyxyxy
a
bcd
decf
codes
horse
codeforces
egg
annie
egaegaeg
*/

int dfs(int p1, int p2, int i, unordered_map<int, int>& vis)
{
    // dfs() ----- 在当前情形下 最少还需要变几个字符
    // i一定等于p1+p2 记忆化不需要考虑i
    if (FINDKEY(p1, p2)) {
        return vis[KEY(p1, p2)];
    }
    if (i == na + nb - 1) {
        if (p1 < na) {
            return vis[KEY(p1, p2)] = (a[p1] == c[i] ? 0 : 1);
        }
        else {
            return vis[KEY(p1, p2)] = (b[p2] == c[i] ? 0 : 1);
        }
    }
    int d = 0x3f3f3f3f;
    if (p1 < na) {
        d = dfs(p1+1, p2, i+1, vis) + (a[p1] == c[i] ? 0 : 1);
    }
    if (p2 < nb) {
        d = min(d, dfs(p1, p2+1, i+1, vis) + (b[p2] == c[i] ? 0 : 1));
    }
    return vis[KEY(p1, p2)] = d;
}

void solve()
{
    cin >> a >> b >> c;
    na = a.length(); nb = b.length();
    // vector<vector<vector<int>>> vis(na + 1, vector<vector<int>>(nb + 1, vector<int>(na + nb + 1, 0)));
    unordered_map<int, int> vis;
    cout << dfs(0, 0, 0, vis) << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // freopen("in.txt", "r", stdin);
    
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    system("pause");
    return 0;
}
Problem: 2050E - Three Strings
Language: c++17 

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

int helper1(vector<vector<int>>& dp,string& s1, string& s2, string& s3, int i, int j){
    if(i>=s1.size() && j>=s2.size()){
        return 0;
    }
    if(i>=s1.size()){
        int ind=i+j; int count=0;
        for(int k=j; k<s2.size(); k++){
            if(s2[k]!=s3[ind])count++;
            ind++;
        }
        return count;
    }
    if(j>=s2.size()){
        int ind=i+j; int count=0;
        for(int k=i; k<s1.size(); k++){
            if(s1[k]!=s3[ind])count++;
            ind++;
        }
        return count;
    }
    if(dp[i][j]!=-1)return dp[i][j];
    int ans1=1e5,ans2=1e5;
    if(s1[i]==s3[i+j] && s2[j]==s3[i+j]){
        ans1=helper1(dp,s1,s2,s3,i+1,j);
        ans2=helper1(dp,s1,s2,s3,i,j+1);
    }
    else if(s1[i]==s3[i+j]){
        ans1=helper1(dp,s1,s2,s3,i+1,j);
        ans2=1+helper1(dp,s1,s2,s3,i,j+1);
    }
    else if(s2[j]==s3[i+j]){
        ans2=helper1(dp,s1,s2,s3,i,j+1);
        ans1=1+helper1(dp,s1,s2,s3,i+1,j);
    }
    else{
        ans1=1+helper1(dp,s1,s2,s3,i+1,j);
        ans2=1+helper1(dp,s1,s2,s3,i,j+1);
    }
    return dp[i][j]=min(ans1,ans2);
}

void solve(){
    string s1,s2,s3; cin>>s1>>s2>>s3;
    int n=s1.size(); int m=s2.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1,-1));
    int ans=helper1(dp,s1,s2,s3,0,0);
    cout<<ans<<endl;
}
int main(){
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
    int t;
    cin>>t;
    while(t--){
        solve();
    }
}

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

string a,b,c;
int f[1010][1010],g[2010];//f[i][j]表示a选前i个，b选前j个的最大匹配长度 
int main(){
	ios::sync_with_stdio(0);
	int T;cin>>T;
	while(T--){
		cin>>a>>b>>c;
		int la=a.length(),lb=b.length();
		int lc=la+lb;
		a=' '+a,b=' '+b,c=' '+c;
		memset(f,0,sizeof(f));
		for(int i=0;i<=la;i++){
			for(int j=0;j<=lb;j++){
				if(i>=1)f[i][j]=f[i-1][j]+(a[i]==c[i+j]);
				if(j>=1) f[i][j]=max(f[i][j],f[i][j-1]+(b[j]==c[i+j]));
//				cout<<f[i][j]<<' ';
			}
//			cout<<endl;
		}
		cout<<lc-f[la][lb]<<endl;
	}
	return 0;
}
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<bits/stdc++.h>
using namespace std;
 
const int maxn = (int)2e3+5;
int t, f[maxn][maxn];
string a, b, c;
 
int main()
{
    cin >> t;
    while(t--)
    {
        cin >> a >> b >> c;
        int la = a.length();
        int lb = b.length();
        int lc = la + lb;
        a = " " + a;
        b = " " + b;
        c = " " + c;
        
        for (int i = 0; i <= la; i++)
            for (int j = 0; j <= lb; j++)
                f[i][j] = 0;
        
        for (int i = 0; i <= la; i++)
        {
            for (int j = 0; j <= lb; j++)
            {
                if (i == 0 && j == 0) continue;
                
                if (i == 0)
                {
                    f[i][j] = f[i][j - 1] + (b[j] != c[i + j]);
                }
                else if (j == 0)
                {
                    f[i][j] = f[i - 1][j] + (a[i] != c[i + j]);
                }
                else
                {
                    f[i][j] = min(f[i - 1][j] + (a[i] != c[i + j]), f[i][j - 1] + (b[j] != c[i + j]));   
                }
            }
        }
        
        cout << f[la][lb] << '\n';
    }
}

Solution 2 (runtime: 390 ms):
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int INF = 10000000;
int memo[1001][1001];

string a, b, c;

int solve(int x, int y) {
  if (x == a.size() && y == b.size()) return 0;

  if (memo[x][y] != -1)
    return memo[x][y];


  int ans = INF;
  if (x < a.size()) ans = min(ans, (a[x] != c[x+y] ? 1 : 0) + solve(x+1, y));
  if (y < b.size()) ans = min(ans, (b[y] != c[x+y] ? 1 : 0) + solve(x, y+1));
  return memo[x][y] = ans;
}

int main() {
  int n;
  cin >> n;
  while (n--) {
    cin >> a >> b >> c;
    for (int i = 0; i < 1001; i++) {
      for (int j = 0; j < 1001; j++) {
        memo[i][j] = -1;
      }
    }
    cout << solve(0, 0) << endl;
  }
  return 0;
}
Problem: 2050E - Three Strings
Language: c++17 

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

using namespace std;


void solve() {
    string a, b, c;
    cin >> a >> b >> c;
    int an = a.length();
    int bn = b.length();
    int cn = an + bn;

    int dp[an+1][bn+1];

    for (int i = 0; i <= an; i++) {
        for (int j = 0; j <= bn; j++) {
            dp[i][j] = -1;
        }
    }

    dp[0][0] = 0;

    for (int i = 1; i <= an; i++) {
        dp[i][0] = dp[i-1][0] + (a[i-1]==c[i-1] ? 0 : 1);
    }
    for (int j = 1; j <= bn; j++) {
        dp[0][j] = dp[0][j-1] + (b[j-1]==c[j-1] ? 0 : 1);
    }

    for (int i = 1; i <= (an); i++) {
        for (int j = 1; j <= (bn); j++) {
            int p1 = dp[i-1][j];
            p1 += a[i-1]==c[i+j-1] ? 0 : 1;
            int p2 = dp[i][j-1];
            p2 +=  b[j-1]==c[i+j-1] ? 0 : 1;
            // cout << (a[i-1]==c[i+j-1] ? 0 : 1) << ' ' << dp[i-1][j] << endl;
            // cout << ((int)dp[i-1][j] + (int)a[i-1]==c[i+j-1] ? 0 : 1) << endl;
            dp[i][j] = min(p1, p2);
            
        }
    }

    //for (int i = 0; i <= an; i++) for (int j = 0; j <= bn; j++) cout << i << ' ' << j << ' ' << dp[i][j] << endl;
    
    cout << dp[an][bn] << endl;
}

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

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

const int N = 1e3 + 2;
int dp[N][N] = { { 0 } };

string a, b, c;

int n; // length of a
int m; // length of b

int f(int i, int j) {
  if (i == 0 && j == 0) return 0;
  if (dp[i][j] != 0) return dp[i][j];
  int choose_a = INT_MAX, choose_b = INT_MAX;
  if (i > 0) choose_a = (a[i - 1] == c[i + j - 1] ? 0 : 1) + f(i - 1, j);
  if (j > 0) choose_b = (b[j - 1] == c[i + j - 1] ? 0 : 1) + f(i, j - 1);
  return dp[i][j] = min(choose_a, choose_b);
}

void solve() {
  cin >> a >> b >> c;
  n = a.length();
  m = b.length();
  memset(dp, 0, sizeof(dp));
  cout << f(n, m) << endl;
}

int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
Problem: 2050C - Uninteresting Number
Language: c++17 

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

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

string check(int total, int threes, int twos) {
	if(total%9==0) {
		return "YES\n";
	} else {
		for(int x=min(10,threes); x>=0; x--) {
			for(int y=min(10,twos); y>=0; y--) {
				if((total+(6*x + y*2))%9==0) {
					return "YES\n";
				}
			}
		}
	}
	return "NO\n";
}

int main() {
	int n; cin >> n;

	for(int i=0; i<n; i++) {
		string k; cin >> k;
		
		int total = 0;
		int threes = 0;
		int twos = 0;
		for(char j : k) {
			int digit = j - '0';
			if(digit==3) threes++;
			if(digit==2) twos++;
			total=(total+digit)%9;
		}
		cout << check(total, threes, twos);
		
	}
}

Solution 2 (runtime: 1671 ms):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int f(char a){
    if(a=='0'){
        return 0;
    }
    if(a=='1'){
        return 1;
    }
    if(a=='2'){
        return 2;
    }
    if(a=='3'){
        return 3;
    }
    if(a=='4'){
        return 4;
    }
    if(a=='5'){
        return 5;
    }
    if(a=='6'){
        return 6;
    }
    if(a=='7'){
        return 7;
    }
    if(a=='8'){
        return 8;
    }
    if(a=='9'){
        return 9;
    }
    
}
int main(){
    int t;
    cin>>t;
    for(int y=0;y<t;y++){
        string q;
        cin>>q;
        int s=0, n=0, m=0;

        for(int i=0;i<q.size();i++){
            s+=f(q[i]);
            
            if(f(q[i])==2){
                n++;
            }
            if(f(q[i])==3){
                m++;
            }
        }
        int h=0;
        for(int a=0;a<=n;a++){
            for(int b=0;b<=m;b++){
                
                if((s+2*a+6*b) % 9==0){
                    
                    h=1;
                    break;
                }
            }
        }
        if(h==0){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
        }

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

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

int parent[2005];
int sizes[2005];
void make(int a) {
    parent[a] = a;
    sizes[a] = 1;
}

int find(int u) {
    if(parent[u] == u) return u;
    return parent[u] = find(parent[u]);
}

void Union(int a, int b) {
    a = find(a);
    b = find(b);
    if(a != b) {
        if(sizes[a] < sizes[b]) {
            swap(a, b);
        }
        parent[b] = a;
        sizes[a] += sizes[b]; 
    }
}




int32_t main() {
    int t = 1;
    cin>>t;
    while(t--) {
        int n,m;
        cin>>n;
        vector<int> v(n + 1, 0);
        for(int i = 1; i <= n; i++) {
            cin>>v[i];
        }
        for(int i = 1; i < n; i++) {
            int temp = min(v[i],v[i+1]);
            v[i] = v[i] - temp;
            v[i+1] = v[i+1] - temp;
        }
        for(int i = 1; i <= n; i++) {
            // cout<<v[i]<<" ";
        }
        if(is_sorted(v.begin(),v.end()))
        cout<<"YES\n";
        else cout<<"NO\n";
    }
    
    return 0;
}

Solution 2 (runtime: 109 ms):
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;

void run(){
    int n; cin>>n;
    int a[n];

    for(int& vl: a) cin>>vl;

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

        } else {
            cout << "NO" << '\n';
            return;
        }
    }

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

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

    int tt; cin>>tt;
    while(tt--){
        run();
    }
}