Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Compilation error):
#include <bits/stdc++.h>/*
                                      ....:::::::::^^^^^^^^^^^::::::...
                        .:^~!7?YY5PPGGGGBBGBBGGGPPPPPGPPPPP555PGGGPPGGGGGGGGGY!.
                  :~?YPB######BGGP55YJ?777~^......::^^::::. ^^^:.    ...::^!JG&&5^
              ^?PB#G5Y?^:^^:::::::^^^^^^^^::.. .!!!~!!!!~  .^^~!!!^:.         :?#@5:
           :Y#&BY~.  ?!  .:^~!!!!!!!!!!!!~~^::. ::~~~~~~~::::~77!~^:^~~^.        7@&7
          7@&Y^       :!??J??????7!~:.           7#7~^^^^^:. .^!??!:^~~^:~~:      ^B@Y
         !@B.       ^5Y7^.      ..!^:.          ^G^              :^~^!!?7^:^~^     .P@G.
        .#@~       ^J^            ^7            7:   .^!7?????7!^.   :7~:!~  .       5@#^
       ^G@?        .   .^~~!~^^.   !.             ~YB&&&BP&@@@@@@&BP7. .              7&@J:
     !P@B~     . .: !5B&GGGGB@@&BP7^.          ^JBB5?~:.^Y@@@@@@@@B#&&Y:.^^:.      .:^:!#@&5~
   !B@B7..^.   ~^.^ ~?YPPGGB#@@@@@@@#GPY~     7&@#^^!JPB#BPY5YY5PGGPPGG?:!^~^. ..::::..:!5GG&B?.
  ~@&7..:7:               .::^~~!75@@@Y~.      ^?GBGPY7~.   !5J!:       .^^7YPGBPPGGBB5!  :!!Y@#7
  Y@!!^ ~J^PGPGPYYPJ!^:.::.       ^@@P                       ~P&&#GPYY5GB##G5?~:^.  :7B@B~    ^G@5
  5@~Y^ P:^5?~:.^.Y&@&&#&&~     .~P@G:          .              .^~7???7!^:   :?B@#7.   ?@&^     G@7
  7@JY?~#~     Y&: .::^~~~   .!5#@G!           .GBBBPJ^J::....          .^?P#&#55@@#Y^  #@J     7@Y
  :&&7P^~?~   7@@B.       ^?P&@@#~         .:^^~7J??B@J!!7!!~^^:  .:~7YG##GJ!:  P@B55J~^&@7  :  5@?
   7@#7~  J7 :&&&@B^   ^!???7?5B@B!.      ^7J5PB##:~@@~    .:~7J5GB#B#&7^.    ^P@B.    ?@Y :J^.5@G.
    ?@&!  ^~ Y@JY@#&57^:        ^JBBGPPJ.        . J5?!?YPBBBGPY?!^.^B5  .~?5#@@G:     JJ ^?^7#@Y.
     !&@~   .#@@@Y7@@GBBPY?!~^:..  ^?5P~:^^~!7J5PGB###&@&7^:      ^Y&@G5GBB55@@5.      !! ^J#@G~
      5@G   :&@@G ^@5  :P@555PPPPPBBP55PP5#@BYJ?7!~^:.^&&:  .^!JP#@@@@@5~..?&&7          J@@P~
      7@&:  :&@@P?J@Y: .#B       .&P..    Y@?        ..P@P5B&@@@&GY!?@7  !#@5:         ^B@5:
      !@&:  .&@@@@@@@&GG@#YYJ??77J@Y!77777G@5~7?Y5PG#&@@@@&#PY7^.    P57G@P^          7@@!
      !@&:   P@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&#G5?~?@?         :5@&Y^           Y@#^
      !@&.   ~@#5&@#G@@#&@@@@@@@@@@@@@@@&&BG#@Y!~^.      B@!    :!5#&G7.           ~B@P:
      7@B     5@BY@5 J@P^!G@@5???7B@P^^^:.  7@~          ~@&~^JG&&P?:            ~P@#!
      ?@P      J&&@Y::?@P. 7@B:   !@#.      ^@?     ..:^~7&@&BPJ~.  :.   .:   :?B@B7
      P@Y       .!YPGBB&@&5!P@&J^.:#@5^~~~!7?@G?YPPGB#BBP5?~:. ..:~^^:.:~^:^?G&&5~
      P@!       .^.  .:^^!7???JYYJ?Y5555555YJJ?77!!^^..   .^~!~^.:^^::.^75B&BY~.
      P&:  .J^   ^?J~        ::^^^~~!!!~^^^^:      .^~~~^.^~~~^: :^!JGB#GY!:
      G#    ^5Y^   :!~:^^^^!!!!!!!!!~~~~!!~~~^^.:~???!^  :::^~7YGB#G5?^.
      G@^     ~?7^::::^^^^^~~~~~~~~~~^^^. .^~!!7!~^:.   :!YG#&B5?~.
      ?@#^       .:^^~~~~~~~~~~~~^^^::..           .^75B##P?~.
       7&@Y:                              .:^!7JYPBBBPJ!:
        .J#&BY!^.               .:^~7?YPGB#BBG5Y?!^.
           ^?5BBBG5YYYJJJYYY5PPGBBBGP5J?!~:.
*/
#define ll long long
#define yes cout << "yes" << endl
#define no cout << "no" << endl
using namespace std;
#define fast() ios_base::sync_with_stdio(false);
double  pi=3.1415926535897932384626433832795;
int is_prime(ll n)
{
    for(ll i = 2; i <= sqrt(n); i++)
    {
        if(n%i==0)
        {
            return false;
        }
    }
    return true;
}
int sumOfDigits(ll n)
{
    ll sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
int checkPalindrome(string str)
{
    ll len = str.length();
    for (ll i = 0; i < len / 2; i++)
    {
        if (str[i] != str[len - i - 1])
            return false;
    }
    return true;
}
int main(){fast()
    int t;
    cin>>t;
    while(t--){
    string s;
    cin >> s;
    int s = 0;
    int l = 0, r = 0;
    for (int i = 0; i < s.size(); i++) {
        s += int(s[i] - '0');

        if (int(s[i] - '0') == 2) {
            l += 1;
        }
        else if (int(s[i] - '0') == 3) {
            r += 1;
        }
    }
    if (s % 9 == 0) {
        cout << "YES" << endl;
        return 0;
    }
    int c;
    for (int i = 0; i <= min(8, l); i++) {
        for (int j = 0; j <= min(8, r); j++) {
            c = s + 2 * i + 6 * j;

            if (c % 9 == 0) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    }
    return 0;
}