Language: C++


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main implements Runnable { // クラス名はMain1

	static int mod = 1000000000 + 7; //10^9+7

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); // 16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			/**
			 * 表示系
			 *   System.out.println();
			 *   System.out.println("i:" + i + " ,j:" + j);
			 *   System.out.println(Arrays.toString(A));
			 *
			 * Sort (Arrays)
			 *  Integer[] A = new Integer[N];
			 *    Desc : Arrays.sort(A , Collections.reverseOrder());
			 *    Asc  : Arrays.sort(A);
			 *
			 * 定義系
			 *   int[] s = new int[M];
			 *   ArrayDeque<Integer> deq= new ArrayDeque<>();//先頭と末尾への要素の追加・先頭と末尾の要素の取り出しと削除が定数時間
			 *   ArrayList<Integer> arr = new ArrayList<Integer>();//定数時間
			 *   HashMap<Integer,Integer> hm = new HashMap<>(); //定数時間
			 *
			 *   //要素の追加と、最小の要素の取り出しと削除が対数時間
			 *   PriorityQueue<Integer> pq = new PriorityQueue<>();//昇順
			 *   PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder()); //逆順。降順
			 *
			 *   TreeSet<Integer> ts = new TreeSet<>();//対数時間(重複はできない)
			 *
			 * 文字系
			 *   String S = sc.nextLine().trim();
			 *   for (char i = 'a'; i <= 'z'; i++) {}
			 *   S.substring(1,2);//あいうえお → い
			 *   S.substring(0,1); // 1文字目をとりたいとき
			 *   文字列のSort
			 *    String sorted = S.chars().sorted().collect(StringBuilder::new,StringBuilder::appendCodePoint, StringBuilder::append) .toString();
			 */
			// long l = sc.nextLong();
			//int N = sc.nextInt();
			//int[] A = new int[N];
			int N = sc.nextInt();
			String S = sc.nextLine().trim();
			char[] s = new char[N];
			//TreeSet<String> ts = new TreeSet<>();

			for (int i = 0; i < N; i++) {
				s[i] = S.charAt(i);
			}

			int ans = 0;
			for (int i = 0; i <= 999; i++) {

				String str = String.valueOf(i);
				String paddingStr = str.format("%03d", i);

				char c1 = paddingStr.charAt(0);
				char c2 = paddingStr.charAt(1);
				char c3 = paddingStr.charAt(2);

				boolean c1b = false;
				boolean c2b = false;
				boolean c3b = false;
				inve: for (int j = 0; j < N; j++) {
					if (c2b && s[j] == c3) {
						c3b = true;
						break inve;
					}
					if (c1b && s[j] == c2) {
						c2b = true;
					}
					if (s[j] == c1) {
						c1b = true;
					}
				}
				if (c1b && c2b && c3b) {
					ans++;
					//ts.add(paddingStr);
					//System.out.println(paddingStr + " " + c1 + " " + c2 + " " + c3 + " " + c1b + " " + c2b + " " + c3b);
				}

			}

			System.out.println(ans);
			//System.out.println(ts.size());

		} catch (ArithmeticException ae) {
			ae.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public static long comb(long a, long b) {
		if (a < b)
			return 0;
		long res = 1;
		long inv = pow(fact(Math.min(b, a - b)), mod - 2);
		for (long i = a; i > a - Math.min(b, a - b); i--) {
			res *= i;
			res %= mod;
		}
		res *= inv;
		res %= mod;
		return res;
	}

	public static long pow(long x, long n) {
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1) {
				res *= x;
				res %= mod;
			}
			x *= x;
			x %= mod;
			n >>= 1;
		}
		return res;
	}

	public static long fact(long n) {
		long res = 1;
		while (n > 0) {
			res *= n;
			res %= mod;
			n--;
		}
		return res;
	}

	// 下記はオーバーフローでExceptionをキャッチするよう
	private long multiple(long a, long b) {
		long ans = 0;
		try {
			ans = Math.multiplyExact(a, b);
			return ans;
		} catch (ArithmeticException ae) {
			throw new ArithmeticException();
		}
	}

	private int multiple(int a, int b) {
		int ans = 0;
		try {
			ans = Math.multiplyExact(a, b);
			return ans;
		} catch (ArithmeticException ae) {
			throw new ArithmeticException();
		}
	}

	private long add(long a, long b) {
		long ans = 0;
		try {
			ans = Math.addExact(a, b);
			return ans;
		} catch (ArithmeticException ae) {
			throw new ArithmeticException();
		}
	}

	private int add(int a, int b) {
		int ans = 0;
		try {
			ans = Math.addExact(a, b);
			return ans;
		} catch (ArithmeticException ae) {
			throw new ArithmeticException();
		}
	}

	/*
	 * HashmapのSort
	 * hmはhashmap
	 * keyvalは"key" or "val"を指定して
	 * ascdescは"asc" or "desc"を指定して
	 */
	private List<Entry<Integer, Integer>> sortHashMapValue(HashMap<Integer, Integer> hm, String keyval,
			String ascdesc) {
		// 1.Map.Entryのリストを作成する
		List<Entry<Integer, Integer>> list_entries = new ArrayList<Entry<Integer, Integer>>(hm.entrySet());

		// 2.比較関数Comparatorを使用してMap.Entryの値を比較する(昇順)
		Collections.sort(list_entries, new Comparator<Entry<Integer, Integer>>() {
			public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
				if (keyval.equals("val")) {
					if (ascdesc.equals("asc")) {
						// 昇順(value)
						return obj1.getValue().compareTo(obj2.getValue());
					} else {
						// 降順(value)
						return obj2.getValue().compareTo(obj1.getValue());
					}
				} else {
					if (ascdesc.equals("asc")) {
						// 昇順(value)
						return obj1.getKey().compareTo(obj2.getKey());
					} else {
						// 降順(value)
						return obj2.getKey().compareTo(obj1.getKey());
					}
				}
			}
		});
		/*
		// 3. ループで要素順に値を取得する
		for (Entry<Integer, Integer> entry : list_entries) {
			System.out.println(entry.getKey() + " : " + entry.getValue());
		}
		*/
		return list_entries;
	}
}

class Exm implements Comparable<Exm> {

	public int a;
	public int b;

	@Override
	public int compareTo(Exm o) {

		//return this.a - o.a;//昇順
		// return o.a - this.a;//降順

		//複数項目で並び替え。aの降順、aが同じならbの降順
		if (this.a == o.a) {
			return o.b - this.b;
		} else {
			return o.a - this.a;
		}
	}

}

// 高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Compiler output:
a.cc:241:9: error: stray '@' in program
  241 |         @Override
      |         ^
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.BufferedReader;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.io.IOException;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.io.InputStream;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.io.InputStreamReader;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import java.util.ArrayList;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import java.util.Collections;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
    8 | import java.util.Comparator;
      | ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
    9 | import java.util.HashMap;
      | ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: 'import' does not name a type
   10 | import java.util.List;
      | ^~~~~~
a.cc:10:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:11:1: error: 'import' does not name a type
   11 | import java.util.Map.Entry;
      | ^~~~~~
a.cc:11:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:12:1: error: 'import' does not name a type
   12 | import java.util.StringTokenizer;
      | ^~~~~~
a.cc:12:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:14:1: error: expected unqualified-id before 'public'
   14 | public class Main implements Runnable { // クラス名はMain1
      | ^~~~~~
a.cc:236:22: error: expected initializer before 'Comparable'
  236 | class Exm implements Comparable<Exm> {
      |                      ^~~~~~~~~~
a.cc:259:16: error: expected ':' before 'BufferedReader'
  259 |         private BufferedReader reader = null;
      |                ^~~~~~~~~~~~~~~
      |                :
a.cc:259:17: error: 'BufferedReader' does not name a type
  259 |         private BufferedReader reader = null;
      |                 ^~~~~~~~~~~~~~
a.cc:260:16: error: expected ':' before 'StringTokenizer'
  260 |         private StringTokenizer tokenizer = null;
      |                ^~~~~~~~~~~~~~~~
      |                :
a.cc:260:17: error: 'StringTokenizer' does not name a type
  260 |         private StringTokenizer tokenizer = null;
      |                 ^~~~~~~~~~~~~~~
a.cc:262:15: error: expected ':' before 'FastScannerMain1'
  262 |         public FastScannerMain1(InputStream in) {
      |               ^~~~~~~~~~~~~~~~~
      |               :
a.cc:262:44: error: expected ')' before 'in'
  262 |         public FastScannerMain1(InputStream in) {
      |                                ~           ^~~
      |                                            )
a.cc:267:15: error: expected ':' before 'String'
  267 |         public String next() {
      |               ^~~~~~~
      |               :
a.cc:267:16: error: 'String' does not name a type
  267 |         public String next() {
      |                ^~~~~~
a.cc:278:15: error: expected ':' before 'String'
  278 |         public String nextLine() {
      |               ^~~~~~~
      |               :
a.cc:278:16: error: 'String' does not name a type
  278 |         public String nextLine() {
      |                ^~~~~~
a.cc:289:15: error: expected ':' before 'long'
  289 |         public long nextLong() {
      |               ^~~~~
      |               :
a.cc:293:15: error: expected ':' before 'int'
  293 |         public int nextInt() {
      |               ^~~~
      |               :
a.cc:297:15: error: expected ':' before 'double'
  297 |         public double nextDouble() {
      |               ^~~~~~~
      |               :
a.cc:301:15: error: expected ':' before 'int'
  301 |         public int[] nextIntArray(int n) {
      |               ^~~~
      |               :
a.cc:301:19: error: expected unqualified-id before '[' token
  301 |         public int[] nextIntArray(int n) {
      |                   ^
a.cc:308:15: error: expected ':' before 'long'
  308 |         public long[] nextLongArray(int n) {
      |               ^~~~~
      |               :
a.cc:308:20: error: expected unqualified-id before '[' token
  308 |         public long[] nextLongArray(int n) {
      |                    ^
a.cc:314:2: error: expected ';' after class definition
  314 | }
      |  ^
      |  ;
a.cc: In member function 'long int FastScannerMain1::nextLong()':
a.cc:290:24: error: 'Long' was not declared in this scope; did you mean 'long'?
  290 |                 return Long.parseLong(next());
      |                        ^~~~
      |                        long
a.cc:290:39: error: 'next' was not declared in this scope
  290 |                 return Long.parseLong(next());
      |                                       ^~~~
a.cc: In member function 'int FastScannerMain1::nextInt()':
a.cc:294:24: error: 'Integer' was not declared in this scope
  294 |                 return Integer.parseInt(next());
      |                        ^~~~~~~
a.cc:294:41: error: 'next' was not declared in this scope
  294 |                 return Integer.parseInt(next());
      |                                         ^~~~
a.cc: In member function 'double FastScannerMain1::nextDouble()':
a.cc:298:24: error: 'Double' was not declared in this scope; did you mean 'double'?
  298 |                 return Double.parseDouble(next());
      |                        ^~~~~~
      |                        double
a.cc:298:43: error: 'next' was not declared in this scope
  298 |                 return Double.parseDouble(next());
      |                                           ^~~~