Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Memory limit exceeded on test 4):
#include <iostream>
#include<string.h>
#include<math.h>
#include<vector>
#include<algorithm>
#include <numeric>
#include <set>
#include <unordered_map>
using namespace std;
#define ll long long 

#define vl vector<ll>
#define vs vector<string>
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
void solve();

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

void solve(){
    string digits;
    cin>>digits;
    ll count2=0;
    ll count3=0;
    ll basesum=0;
    vl digitslist;
    for (char c:digits){
        digitslist.push_back(c-'0');
        basesum+=c-'0';
        if ((c-'0')==2){
            count2+=1;
        }
        else if ((c-'0')==3){
            count3+=1;
        }
    }
    if (basesum%9==0){cout<<"yes"<<endl;return;}
    vector <vl> dp(count2+1,vector<ll>(count3+1,0));
    for (ll i=0;i<=count2;i++){
        for (ll j=0;j<=count3;j++){
            if (i-1<0 && j-1<0){
                dp[i][j]=basesum%9;
                if (basesum==0){cout<<"yes"<<endl;return;}
            }
            else if (i-1<0 && j-1>=0){
                dp[i][j]=(dp[i][j-1]+6)%9;
                if (dp[i][j]==0){cout<<"yes"<<endl;return;}
            }
            else if (i-1>=0 && j-1<0){
                dp[i][j]=(dp[i-1][j]+2)%9;
                if (dp[i][j]==0){cout<<"yes"<<endl;return;}
            }
            else{
                dp[i][j] = (dp[i-1][j-1]+8)%9;
                if (dp[i][j]==0){cout<<"yes"<<endl;return;}
            }
            
        }
    }
    cout<<"no"<<endl;
    return;
}

Submission (verdict: Memory limit exceeded on test 4):
#include <iostream>
#include<string.h>
#include<math.h>
#include<vector>
#include<algorithm>
#include <numeric>
#include <set>
#include <unordered_map>
using namespace std;
#define ll long long 

#define vl vector<ll>
#define vs vector<string>
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
void solve();

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

void solve(){
    string digits;
    cin>>digits;
    ll count2=0;
    ll count3=0;
    ll basesum=0;
    vl digitslist;
    for (char c:digits){
        basesum+=c-'0';
        if ((c-'0')==2){
            count2+=1;
        }
        else if ((c-'0')==3){
            count3+=1;
        }
    }
    
    if (basesum%9==0){cout<<"yes"<<endl;return;}
    vector <vl> dp(count2+1,vector<ll>(count3+1,0));
    for (ll i=0;i<=count2;i++){
        for (ll j=0;j<=count3;j++){
            if (i-1<0 && j-1<0){
                dp[i][j]=basesum%9;
                if (basesum==0){cout<<"yes"<<endl;return;}
            }
            else if (i-1<0 && j-1>=0){
                dp[i][j]=(dp[i][j-1]+6)%9;
                if (dp[i][j]==0){cout<<"yes"<<endl;return;}
            }
            else if (i-1>=0 && j-1<0){
                dp[i][j]=(dp[i-1][j]+2)%9;
                if (dp[i][j]==0){cout<<"yes"<<endl;return;}
            }
            else{
                dp[i][j] = (dp[i-1][j-1]+8)%9;
                if (dp[i][j]==0){cout<<"yes"<<endl;return;}
            }
            
        }
    }
    cout<<"no"<<endl;
    return;
}