Problem: 2050C - Uninteresting Number
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.*;
public class practice {
    public static boolean unintrestingNumber(String n){
        int count = 0;
        HashMap<Integer,Integer> check = new HashMap<>();
        check.put(2,0);
        check.put(3,0);
        if (Long.parseLong(n)%9 == 0){
            return true;
        }
        for(int i = 0; i<n.length();i++){
            String Snum = String.valueOf(n.charAt(i));
            int num = Integer.parseInt(Snum);
            count+=num;
            if (check.containsKey(num)){
                check.put(num,check.get(num)+1);
            }
        }
        int newSum = count;
        int count2 = 1;
        while (newSum%9!=0){
            if (check.get(2)>0&& count2%3!=0){
                newSum+=2;
                check.put(2,check.get(2)-1);
                count2 ++;
            }
            else if (count2 %3 == 0 && check.get(3)>0 && check.get(2)>0){
                check.put(3,check.get(3)-1);
                newSum+=2;
                count2 = 1;
                check.put(2,check.get(2)+2);
            }
            else if (check.get(3)<=0 && check.get(2)>0){
                newSum+=2;
                check.put(2,check.get(2)-1);
            }
            else if (check.get(3)>0 && check.get(2)<=0){
                newSum+=6;
                check.put(3,check.get(3)-1);
            }
            else{
                break;
            }

        } 
        return newSum%9==0;   
    }
    
    public static void main(String[] args){
        Scanner myScan = new Scanner(System.in);
        int testcases = myScan.nextInt();
        for (int i = 0; i<=testcases; i++){
            String test = myScan.nextLine();
            if (!"".equals(test)){
                if(unintrestingNumber(test)){
                    System.out.println("YES");
                }
                else{
                    System.out.println("NO");
                }
            }
        }
    }
}


Submission (verdict: Runtime error on test 3):
import java.util.*;
public class practice {
    public static boolean unintrestingNumber(String n){
        int count = 0;
        HashMap<Integer,Integer> check = new HashMap<>();
        check.put(2,0);
        check.put(3,0);
        if (Long.parseLong(n)%9 == 0){
            return true;
        }
        for(int i = 0; i<n.length();i++){
            String Snum = String.valueOf(n.charAt(i));
            int num = Integer.parseInt(Snum);
            count+=num;
            if (check.containsKey(num)){
                check.put(num,check.get(num)+1);
            }
        }
        int newSum = count;
        int count2 = 1;
        // while (newSum%9!=0){
        //     if (check.get(2)>0&& count2%3!=0){
        //         newSum+=2;
        //         check.put(2,check.get(2)-1);
        //         count2 ++;
        //     }
        //     else if (count2 %3 == 0 && check.get(3)>0 && check.get(2)>0){
        //         check.put(3,check.get(3)-1);
        //         newSum+=2;
        //         count2 = 1;
        //         check.put(2,check.get(2)+2);
        //     }
        //     else if (check.get(3)<=0 && check.get(2)>0){
        //         newSum+=2;
        //         check.put(2,check.get(2)-1);
        //     }
        //     else if (check.get(3)>0 && check.get(2)<=0){
        //         newSum+=6;
        //         check.put(3,check.get(3)-1);
        //     }
        //     else{
        //         break;
        //     }

        // } 
        for (int i = 0; i <= Math.min(9, check.get(2)); i++) {
            for (int j = 0; j <= Math.min(9, check.get(3)); j++) {
                if ((newSum + i * 2 + j * 6) % 9 == 0) {
                    return true; 
                }
            }
        }
        return false;
    }
    
    public static void main(String[] args){
        Scanner myScan = new Scanner(System.in);
        int testcases = myScan.nextInt();
        for (int i = 0; i<=testcases; i++){
            String test = myScan.nextLine();
            if (!"".equals(test)){
                if(unintrestingNumber(test)){
                    System.out.println("YES");
                }
                else{
                    System.out.println("NO");
                }
            }
        }
    }
}