Language: C++

import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		int[] ar = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
		
		int[] dp = new int[100005];
		dp[0] = 0;
		
		for (int i=1; i<=n; i++) {
			
			int min = Integer.MAX_VALUE;
			for (int j=0; j<ar.length; j++) {
				if (i >= ar[j]) {
					min = Math.min(min, Math.min(dp[i-1]+1, dp[i-ar[j]]+1));
				}
			}
			dp[i] = min;
			
		}
		
		System.out.println(dp[n]);
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:16: error: 'Scanner' does not name a type
    4 |         static Scanner sc = new Scanner(System.in);
      |                ^~~~~~~
a.cc:5:15: error: expected ':' before 'static'
    5 |         public static void main(String[] args) {
      |               ^~~~~~~
      |               :
a.cc:5:33: error: 'String' has not been declared
    5 |         public static void main(String[] args) {
      |                                 ^~~~~~
a.cc:5:42: error: expected ',' or '...' before 'args'
    5 |         public static void main(String[] args) {
      |                                          ^~~~
a.cc:27:2: error: expected ';' after class definition
   27 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:7:25: error: 'sc' was not declared in this scope
    7 |                 int n = sc.nextInt();
      |                         ^~
a.cc:8:20: error: structured binding declaration cannot have type 'int'
    8 |                 int[] ar = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
      |                    ^~
a.cc:8:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:8:20: error: empty structured binding declaration
a.cc:8:23: error: expected initializer before 'ar'
    8 |                 int[] ar = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
      |                       ^~
a.cc:10:20: error: structured binding declaration cannot have type 'int'
   10 |                 int[] dp = new int[100005];
      |                    ^~
a.cc:10:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:10:20: error: empty structured binding declaration
a.cc:10:23: error: expected initializer before 'dp'
   10 |                 int[] dp = new int[100005];
      |                       ^~
a.cc:11:17: error: 'dp' was not declared in this scope
   11 |                 dp[0] = 0;
      |                 ^~
a.cc:15:35: error: 'Integer' was not declared in this scope
   15 |                         int min = Integer.MAX_VALUE;
      |                                   ^~~~~~~
a.cc:16:41: error: 'ar' was not declared in this scope; did you mean 'char'?
   16 |                         for (int j=0; j<ar.length; j++) {
      |                                         ^~
      |                                         char
a.cc:18:47: error: 'Math' was not declared in this scope
   18 |                                         min = Math.min(min, Math.min(dp[i-1]+1, dp[i-ar[j]]+1));
      |                                               ^~~~
a.cc:25:17: error: 'System' was not declared in this scope
   25 |                 System.out.println(dp[n]);
      |                 ^~~~~~