Language: C++

import java.util.Arrays;
import java.util.Scanner;

class Main{
	static long N,P;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		//DPっぽい
		N=sc.nextLong();
		P=sc.nextLong();
		String s=sc.next();
		long[][] renDP = new long[(int)N][(int)P];		//剰余のテーブル
		long cut= 0;
		for(int i=0; i<N; i++) {
			Arrays.fill(renDP[i],0);
		}
		renDP[0][(s.charAt(0)-'0')% ((int)P)] ++;
		if(N == 1) {
			//
		}
		else {
			for(int i=1; i<N; i++) {
				int num = s.charAt(i)-'0';
				for(int j=0; j<P; j++) {
					renDP[i][((int)((j*10 + num)% P))] += renDP[i-1][j];
					if(j  == 0) {
						cut +=renDP[i-1][j];
					}
				}
				renDP[i][(int)(num % P)]++;
			}
		}
		pl(renDP[(int)N-1][0] + cut);
		//output(renDP);
		//output(cutDP);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}public static void p(Object o) {
		System.out.print(o);
	}
	/*public static void output(long[][] a) {
		for(int j=0; j<P; j++) {
			for(int i = 0 ; i < N ; i++) {
				p(a[i][j]+" ");
			}
			pl(a[N][j]);
		}
	}*/
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Arrays;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:15: error: expected ':' before 'static'
    6 |         public static void main(String[] args) {
      |               ^~~~~~~
      |               :
a.cc:6:33: error: 'String' has not been declared
    6 |         public static void main(String[] args) {
      |                                 ^~~~~~
a.cc:6:42: error: expected ',' or '...' before 'args'
    6 |         public static void main(String[] args) {
      |                                          ^~~~
a.cc:37:15: error: expected ':' before 'static'
   37 |         public static void pl(Object o) {
      |               ^~~~~~~
      |               :
a.cc:37:31: error: 'Object' has not been declared
   37 |         public static void pl(Object o) {
      |                               ^~~~~~
a.cc:39:16: error: expected ':' before 'static'
   39 |         }public static void p(Object o) {
      |                ^~~~~~~
      |                :
a.cc:39:31: error: 'Object' has not been declared
   39 |         }public static void p(Object o) {
      |                               ^~~~~~
a.cc:50:2: error: expected ';' after class definition
   50 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:7:17: error: 'Scanner' was not declared in this scope
    7 |                 Scanner sc=new Scanner(System.in);
      |                 ^~~~~~~
a.cc:9:19: error: 'sc' was not declared in this scope
    9 |                 N=sc.nextLong();
      |                   ^~
a.cc:11:17: error: 'String' was not declared in this scope
   11 |                 String s=sc.next();
      |                 ^~~~~~
a.cc:12:21: error: structured binding declaration cannot have type 'long int'
   12 |                 long[][] renDP = new long[(int)N][(int)P];              //剰余のテーブル
      |                     ^~
a.cc:12:21: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:12:21: error: empty structured binding declaration
a.cc:12:23: error: expected initializer before '[' token
   12 |                 long[][] renDP = new long[(int)N][(int)P];              //剰余のテーブル
      |                       ^
a.cc:15:25: error: 'Arrays' was not declared in this scope
   15 |                         Arrays.fill(renDP[i],0);
      |                         ^~~~~~
a.cc:15:37: error: 'renDP' was not declared in this scope
   15 |                         Arrays.fill(renDP[i],0);
      |                                     ^~~~~
a.cc:17:17: error: 'renDP' was not declared in this scope
   17 |                 renDP[0][(s.charAt(0)-'0')% ((int)P)] ++;
      |                 ^~~~~
a.cc:17:27: error: 's' was not declared in this scope
   17 |                 renDP[0][(s.charAt(0)-'0')% ((int)P)] ++;
      |                           ^
a.cc: In static member function 'static void Main::pl(int)':
a.cc:38:17: error: 'System' was not declared in this scope
   38 |                 System.out.println(o);
      |                 ^~~~~~
a.cc: In static member function 'static void Main::p(int)':
a.cc:40:17: error: 'System' was not declared in this scope
   40 |                 System.out.print(o);
      |                 ^~~~~~