criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

#pragma GCC optimize("O3")
#pragma GCC target("avx, avx2")
#pragma GCC optimize("unroll-loopss")
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define ld double
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

const int N = 3e5 + 7;

void solve() {
    int n, p;
    string s;
    cin >> n >> p >> s;
    int dp[2][p];
    loop(i, p)
        dp[0][i] = dp[1][i] = 0;
    dp[0][(s[0] - '0') % p] = 1;
    int ans = dp[0][0];
    loop1(i, n - 1) {
        loop(j, p)
            dp[1][(j * 10 + (s[i] - '0')) % p] += dp[0][j];
        ++dp[1][(s[i] - '0') % p];
        loop(j, p) {
            dp[0][j] = dp[1][j];
            dp[1][j] = 0;
        }
        ans += dp[0][0];
    }
    cout << ans;
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Compiler output:
cc1plus: error: attribute 'target' argument ' avx2' is unknown
cc1plus: error: attribute 'target' argument ' avx2' is unknown
a.cc:22:37: warning: bad option '-funroll-loopss' to pragma 'optimize' [-Wpragmas]
   22 | #pragma GCC optimize("unroll-loopss")
      |                                     ^
a.cc:43:12: warning: bad option '-funroll-loopss' to attribute 'optimize' [-Wattributes]
   43 | void solve() {
      |            ^
a.cc:65:13: warning: bad option '-funroll-loopss' to attribute 'optimize' [-Wattributes]
   65 | signed main() {
      |             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, p; cin >> n >> p;
  string s; cin >> s;

  if(10 % p == 0){
    int ans = 0;
    for(int i = 0; i < n; i++){
      if((s[i]-'0') % p == 0){
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  reverse(s.begin(),s.end());
  vector<int> imos(n+1, 0);
  int ten = 1;
  for(int i = 0; i < n; i++){
    int t = (s[i]-'0') * ten % p;
    imos[i+1] = (imos[i] + t) % p;
    ten = ten * 10 % p // 2 != 002 honsitu
  }

  map<int, int> mp;
  int ans = 0;
  mp[0] = 1;
  for(int i = 1; i <= n; i++){
    ans += mp[imos[i]];
    mp[imos[i]]++;
  }
  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:23: error: expected ';' before '}' token
   30 |     ten = ten * 10 % p // 2 != 002 honsitu
      |                       ^
      |                       ;
   31 |   }
      |   ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }

int main(void)
{
    
    ll n,p;
    string s;
    cin>>n>>p;
    cin>>s;
    ll dp[n+1];
    dp[0]=1;
    dp[1]=10;
    ll ans;
    for(int i =2;i<=n;i++)
     dp[i] = ((dp[i-1]%p)*(10%p))%p;
     if(p==2 || p ==5){
         ans = 0;
    for(int i =0;i<n;i++)
    {
        if((s[i]-'0')%p==0)
        ans+=(i+1);
    }
    cout<<ans<<endl;
    return 0;
     }
     ans=0;
     ll cou[p];
     for(int i=0;i<p;i++)count[i]=0;
     count[0]=1;
     ll cur = 0;ll val;
     for(int i =0 ;i<n;i++)
     {
         cur=((cur%p)*(10%p))%p;
         cur+=(s[i]-'0');
         cur=cur%p;
         val = ((cur%p)*dp[n-1-i])%p;
         cou[val]++;
     }
     for(int i =0;i<p;i++)
     ans+=(cou[i]*(cou[i]-1))/2;
     cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'long long int modExp(long long int, long long int)':
a.cc:9:72: error: 'MOD' was not declared in this scope
    9 |         ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
      |                                                                        ^~~
a.cc:16:1: error: a function-definition is not allowed here before '{' token
   16 | {
      | ^
a.cc:54:2: error: expected '}' at end of input
   54 | }
      |  ^
a.cc:5:30: note: to match this '{'
    5 | ll modExp(ll base, ll power) {
      |                              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define M 1000000007

ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }

int main(void)
{
    #define ll long long int
    ll n,p;
    string s;
    cin>>n>>p;
    cin>>s;
    ll dp[n+1];
    dp[0]=1;
    dp[1]=10;
    ll ans;
    for(int i =2;i<=n;i++)
     dp[i] = ((dp[i-1]%p)*(10%p))%p;
     if(p==2 || p ==5){
         ans = 0;
    for(int i =0;i<n;i++)
    {
        if((s[i]-'0')%p==0)
        ans+=(i+1);
    }
    cout<<ans<<endl;
    return 0;
     }
     ans=0;
     ll cou[p];
     for(int i=0;i<p;i++)count[i]=0;
     count[0]=1;
     ll cur = 0;ll val;
     for(int i =0 ;i<n;i++)
     {
         cur=((cur%p)*(10%p))%p;
         cur+=(s[i]-'0');
         cur=cur%p;
         val = ((cur%p)*dp[n-1-i])%p;
         cou[val]++;
     }
     for(int i =0;i<p;i++)
     ans+=(cou[i]*(cou[i]-1))/2;
     cout<<ans<<endl;
}

Compiler output:
a.cc:5:1: error: 'll' does not name a type
    5 | ll modExp(ll base, ll power) {
      | ^~
a.cc:5:1: note: the macro 'll' had not yet been defined
a.cc:17:13: note: it was later defined here
   17 |     #define ll long long int
      |             ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
int main(void)
{
    #define ll long long int
    ll n,p;
    string s;
    cin>>n>>p;
    cin>>s;
    ll dp[n+1];
    dp[0]=1;
    dp[1]=10;
    ll ans;
    for(int i =0;i<=n;i++)
     dp[i] = ((dp[i-1]%p)*(10%p))%p;
     if(p==2 || p ==5){
         ans = 0;
    for(int i =0;i<n;i++)
    {
        if((s[i]-'0')%p==0)
        ans+=(i+1);
    }
    cout<<ans<<endl;
    return 0;
     }
     ans=0;
     ll cou[p];
     for(int i=0;i<p;i++)count[i]=0;
     count[0]=1;
     ll cur = 0;ll val;
     for(int i =0 ;i<n;i++)
     {
         cur=((cur%p)*(10%p))%p;
         cur+=(s[i]-'0');
         cur=cur%p;
         val = ((cur%p)*dp[(n-i-1)])%p;
         cou[val]++;
     }
     for(int i =0;i<p;i++)
     ans+=(cou[i]*(cou[i]-1))/2;
     cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:31: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   29 |      for(int i=0;i<p;i++)count[i]=0;
      |                               ^
a.cc:30:11: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   30 |      count[0]=1;
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
int main(void)
{
    #define ll long long int
    ll n,p;
    string s;
    cin>>n>>p;
    cin>>s;
    ll dp[n+1];
    dp[0]=0;
    dp[1]=10;
    ll ans;
    for(int i =0;i<=n;i++)
     dp[i] = ((dp[i-1]%M)*(10%M))%M;
     if(p==2 || p ==5){
         ans = 0;
    for(int i =0;i<n;i++)
    {
        if((s[i]-'0')%p==0)
        ans+=(i+1);
    }
    cout<<ans;
    return 0;
     }
     ll count = 1;
     ll cur = 0;ll val;
     for(int i =0 ;i<n;i++)
     {
         cur=((cur%M)*(10%M))%M;
         cur+=(s[i]-'0');
         cur=cur%M;
         val = ((cur%M)*dp[(n-i-1)])%M;

Compiler output:
a.cc: In function 'int main()':
a.cc:34:40: error: expected '}' at end of input
   34 |          val = ((cur%M)*dp[(n-i-1)])%M;
      |                                        ^
a.cc:30:6: note: to match this '{'
   30 |      {
      |      ^
a.cc:34:40: error: expected '}' at end of input
   34 |          val = ((cur%M)*dp[(n-i-1)])%M;
      |                                        ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
int main(void)
{
    #define ll long long int
    ll n,p;
    string s;
    cin>>n>>p;
    cin>>s;
    ll dp[n+1];
    dp[0]=0;
    dp[1]=10;
    ll ans;
    for(int i =0;i<=n;i++)
     dp[i] = ((dp[i-1]%M)*(10%M))%M;
     if(p==2 || p ==5){
         ans = 0;
    for(int i =0;i<n;i++)
    {
        if((s[i]-'0')%p==0)
        ans+=(i+1);
    }
    cout<<ans;
    return 0;
     }
     ll count = 1;
     ll cur = 0;ll val;
     for(int i =0 ;i<n;i++)
     {
         cur=((cur%M)*(10%M))%M;
         cur+=(s[i]-'0');
         cur=cur%M;
         val = ((curr%M)*dp[(n-i-1)])%M;
         if(val == 0)
         count++;
     }
     ans = count*(count-1)/2;
     cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:18: error: 'curr' was not declared in this scope; did you mean 'cur'?
   34 |          val = ((curr%M)*dp[(n-i-1)])%M;
      |                  ^~~~
      |                  cur
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,p; cin>>n>>p;
	string s; cin>>s;
	int sum = 0, q=1, ans=0;
	map <int,int> m;
	m[0]++;
	for(int i=n-1;i>=0;i--)
	{
	    sum = (sum + (s[i]-'0')*(q%p))%p;
	    ans+=mp[sum];
	    mp[sum]++;
	    q*=10; q%=p;
	    
	}
	cout<<ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:20: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   23 |             ans+=mp[sum];
      |                    ^
a.cc:24:15: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   24 |             mp[sum]++;
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi  acos(-1)
const int w=2e5+5;
const ll mod=1e9+7;
char a[w];
ll dp[2][w];
int c[w];
map<int,int> ma;
int main()
{
    int i,j;
    int n,m;
    cin>>n>>m;
    scanf("%s",a+1);
    if(m<=1000)
    {
        ll ans=0;
        for(i=1;i<=n;i++)
        {
            for(j=0;j<m;j++)
                dp[0][j]=dp[1][j],dp[1][j]=0;
            int x=(a[i]-'0')%m;
            dp[1][x]++;
            for(j=0;j<m;j++)
                dp[1][(j*10+x)%m]+=dp[0][j];
            ans+=dp[1][0];
        }
        cout<<ans<<endl;
    }
    else
    {
        int x=0,u=1;
        ma[0]++;
        for(i=n-1;i>=1;i--)
        {
            int aa=a[i]-'0';
            x=(x+aa*u%m)%m;
            ans+=ma[x];
            ma[x]++;
            u=u*10%m;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |             ans+=ma[x];
      |             ^~~
      |             abs
a.cc:45:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |         cout<<ans<<endl;
      |               ^~~
      |               abs
Language: C++

S = []
S.append(input("S"))
Q = int(input("Q"))
query = []
for i in range(Q) :
    query.append(input())
    if query[i] == "1" : #Ti = 1 reverse
        S[0], S[len(S)-1] = S[len(S)-1], S[0]
    else : #Ti = 2 str +
        T, F, C = query[i].split()
        if F == "1" :#Fi = 1 str + top
            S.insert(0, C)
        else :#Fi = 2 str + end
            S.append(C)
print(''.join(S))

Compiler output:
a.cc:7:26: error: stray '#' in program
    7 |     if query[i] == "1" : #Ti = 1 reverse
      |                          ^
a.cc:9:12: error: stray '#' in program
    9 |     else : #Ti = 2 str +
      |            ^
a.cc:11:22: error: stray '#' in program
   11 |         if F == "1" :#Fi = 1 str + top
      |                      ^
a.cc:13:15: error: stray '#' in program
   13 |         else :#Fi = 2 str + end
      |               ^
a.cc:15:7: error: empty character constant
   15 | print(''.join(S))
      |       ^~
a.cc:1:1: error: 'S' does not name a type
    1 | S = []
      | ^
Language: C++

//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=5e5+5;
map<int,int>mark;
char s[maxm];
int n,p;
signed main(){
    cin>>n>>p;
    scanf("%s",s+1);
    int ans=0;
    if(p==2||p==5){
        for(int i=1;i<=n;i++){
            if((s[i]-'0')%p==0){
                ans+=i;
            }
        }
    }else{
//        int base=1;
//        int sum=0;
//        mark[0]=1;
//        for(int i=n;i>=1;i--){
//            sum=(sum+(s[i]-'0')*base)%p;
//            ans+=mark[sum];
//            mark[sum]++;
//            base=base*10%p;
//        }
        int sum=0;
        mark[0]=1;
        for(int i=1;i<=n;i++){
            sum(sum*10+s[i]-'0')%p;
            ans+=mark[sum];
            mark[sum]++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:67:16: error: 'sum' cannot be used as a function
   67 |             sum(sum*10+s[i]-'0')%p;
      |             ~~~^~~~~~~~~~~~~~~~~
Language: C++

//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=2e5+5;
map<int,int>mark;
char s[maxm];
int n,p;
signed main(){
    cin>>n>>p;
    scanf("%s",s+1);
    int ans=0;
    if(p==2||p==5){
        for(int i=1;i<=n;i++){
            if((s[i]-'0')%p){
                ans++;
            }
        }
    }else{
        int sum=0;
        int ten=1;
        for(int i=n;i>=1;i--){
            sum+=(s[i]-'0')*t;
            sum%=p;
            ans+=mark[sum];
            mark[sum]++;
            t=t*10%p;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:58:29: error: 't' was not declared in this scope
   58 |             sum+=(s[i]-'0')*t;
      |                             ^
Language: Java

import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int mod=0;
		int n=in.nextInt();
		int p=in.nextInt();
		String s=in.next();
		int [] r=new int [p];
		int ans=0;
		int pow=1;
		for(int i=n-1;i>=0;i--)
		{
			int t=s.charAt(i)-'0';
			if(p==2||p==5)
			{
					if(t%p==0)
					{
						ans=ans+i+1;
					}
			}
			else
			{
				mod=(mod+t*pow)%p;
				pow=(pow*10)%p
				if(mod==0)
					ans++;
				ans=ans+r[mod];
				r[mod]++;
			}
		}
		System.out.println(ans);
	}
}
	

Compiler output:
Main.java:29: error: ';' expected
				pow=(pow*10)%p
				              ^
1 error
Language: C++

#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char s[maxn];
ll n,p,cnt[maxn];

int main()
{
	n=read(); p=read(); scanf("%s",s+1);
	ll nw=0;
	for(int i=n;i>=1;i--)
	{
		nw=(nw*10+s[i]-'0')%p;
		ans+=cnt[nw]; cnt[nw]++;
	}
	cout<<ans+cnt[0]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |                 ans+=cnt[nw]; cnt[nw]++;
      |                 ^~~
      |                 abs
a.cc:29:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |         cout<<ans+cnt[0]<<endl;
      |               ^~~
      |               abs
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  if (p == 2) {
  	long long ans = 0;
    for (int i = n -1; ~i; --i) {
    	if (s[i] & 1) continue;
      	ans += i;
    }
    cout << ans << '\n';
    return 0;
  }
  if (p == 5) {
    long long ans = 0;
    for (int i = n - 1; ~i; --i) {
      if (s[i] == '0' || s[i] == '5')
        ans += i;
    }
    cout << ans << '\n';
    return 0;
  }
  vector<int> cnt(10000);
  int pw = 1, val = 0;
  for (int i = n - 1; ~i; --i) {
  	int val += pw * (s[i] - '0');
    val %= p;
    ++cnt[val];
    pw *= 10;
    pw %= p;
  }
  pw = 1; val = 0;
  long long ans = 0;
  for (int i = n - 1; ~i; --i) {
    val += pw * (s[i] - '0');
    val %= p;
  	ans += --cnt[val];
    pw *= 10;
    pw %= p;
  }
  cout << ans << '\n';
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: expected initializer before '+=' token
   31 |         int val += pw * (s[i] - '0');
      |                 ^~
Language: C++

N,P = list(map(int,input().split()))
S = input()
# print(N)
U = [0]

for i in range(1,N+1):
    u = int(S[:i])%P
    U.append(u)
    
# print(U)

c = 0
for i in range(P):
    m = U.count(i)
    # print(i,m)
    c += m*(m-1)//2
print(c)

Compiler output:
a.cc:3:3: error: invalid preprocessing directive #print
    3 | # print(N)
      |   ^~~~~
a.cc:10:3: error: invalid preprocessing directive #print
   10 | # print(U)
      |   ^~~~~
a.cc:15:7: error: invalid preprocessing directive #print
   15 |     # print(i,m)
      |       ^~~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N,P = list(map(int,input().split()))
      | ^
Language: Java

import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int p = scan.nextInt();
		char[] s = scan.nextLine().toCharArray();
		int[][] dp = new int[n][p];
		
		long count = 0;
		dp[0][transpile(s[0]) % p] = 1;
		count += dp[0][0];
		
		for(int i = 1;i < n;i ++) {
			int num = transpile(s[i]);
			for
		}
	}
	
	public static int transpile(char c) {
		return c - '0';
	}
}

Compiler output:
Main.java:20: error: '(' expected
			for
			   ^
Main.java:21: error: illegal start of expression
		}
		^
2 errors
Language: C++

#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
  int n, p; cin >> n >> p;
  string s; cin >> s;
  ll ans = 0;
  ll x = 1;
  map<int, int> mp;
  vector<int> d(n+1, 0);
  vector<int> cnt(p, 0);
  
  if(p == 2 || p == 5){
    for(int i = 0; i < n; i++){
      if((s[i]-'0') % p == 0) ans += i+1;
    }
  }
  else{
    for(int i = n-1; i >= 0; i--){
      int a = (d[i+1]+(s[i]-'0') * x) % p;
      map[a]++;
      x = x * 10 % p;
    }
    ans = map[0];
    for(int i = 0; i < p; i++){
      ans += map[i] * (map[i]-1) >> 1;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'map' was not declared in this scope
   12 |   map<int, int> mp;
      |   ^~~
a.cc:3:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    2 | #include <vector>
  +++ |+#include <map>
    3 | #include <string>
a.cc:12:7: error: expected primary-expression before 'int'
   12 |   map<int, int> mp;
      |       ^~~
Language: C++

#include <bits/stdc++.h>
#define per(i,a,n) for(int i=a;i<=n;i++)
#define ls l+mid>>1
#define rs mid+1+r>>1
using namespace std;
typedef  long long ll;
int vp[10010];
char s[2e5+10];
int main()
{
  int n,p;
  cin>>n>>p;
  ll ans=0;
  scanf("%s",s+1);
  ll kk=1,an=0;
  vp[0]=1;
  if(p==2||p==5){
    for(int i=n;i>=1;i--){
        if((s[i]-'0')%p==0)
            ans+=i;
    }
    cout<<ans<<endl;
  }
  else{
    for(int i=n;i>=1;i--){
         an=an+((s[i]-'0')*kk)%p;
         an%=p;
         ans+=vp[an];
         vp[an]++;
         kk=kk*10%p;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Compiler output:
a.cc:8:11: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    8 | char s[2e5+10];
      |        ~~~^~~
a.cc:8:11: error: could not convert '(2.0e+5 + (double)10)' from 'double' to 'long unsigned int'
    8 | char s[2e5+10];
      |        ~~~^~~
      |           |
      |           double
a.cc:8:11: error: size of array 's' has non-integral type 'double'
Language: C++



#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;cin>>n>>k;
    string s;
    cin>>s;
    ll int cnt = 0;
    ll int a[n+2];
    ll int mul = 1;
    if(k == 2 || k == 5){
        for (size_t i = 0; i < n; i++) {
            if((s[i] == '0' || (s[i]-'0') == k){
                cnt += (i+1);
            }
        }
        cout<<cnt<<"\n";
    }
    else{
        reverse(s.begin(),s.end());
           for (size_t i = 0; i < n; i++) {
               a[i] = ((s[i] - '0')*mul) % k;
               mul = (mul*10) % k;
           }
           ll int mod[k+2];
           memset(mod , 0, sizeof(mod));
           ll int prefix = 0;
           for (size_t i = 0; i < n; i++) {
               prefix += a[n-(i+1)];
               mod[ ((prefix % k) + k) % k ]++;
           }
           for (size_t i = 0; i < k; i++) {
               if(mod[i] > 1){
                   cnt += ((ll)mod[i]*(mod[i]-1))/2;
               }
           }
           cnt += mod[0];
           cout<<cnt<<"\n";
       }

    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:48: error: expected ')' before '{' token
   36 |             if((s[i] == '0' || (s[i]-'0') == k){
      |               ~                                ^
      |                                                )
a.cc:39:9: error: expected primary-expression before '}' token
   39 |         }
      |         ^
Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
 
ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}
 
ll mul(ll A, ll B) {
    return (A*B)%MOD;
}
 
ll add(ll A, ll B) {
    return (A+B)%MOD;
}
 
ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}
 
ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    int N; cin >> N; int P; cin >> P;
    string S; cin >> S;
    if (P == 5 || P == 2) {
        ll ans = 0;
        F0R(i, N) {
            if ((S[i] - '0') % P == 0) {
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
 
    ll counts[P]; F0R(i, P) counts[i] = 0;
    counts[0] = 0;
    int cur = 0;
    MOD = P;
    F0R(i, N) {
        cur *= 10; cur += S[i] - '0'; cur %= MOD;
        int val = modExp(10, N-1-i) * cur; val %= MOD;
        counts[val]++;
    }
 
    ll ans = 0;
    F0R(i, P) ans += (counts[i] * (counts[i] - 1)) / 2;
    ans+=count[0];
    cout << ans << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:111:15: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  111 |     ans+=count[0];
      |               ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5+1;

int a[maxn], ls[maxn];
long long dp[maxn];
int n, p;

int bp(int x, int k) {
  if (!k) return 1;
  if (k % 2) return (x * bp(x, k - 1)) % p;
  return bp((x * x) % p, k / 2);
}

signed main() {
  cin >> n >> p;
  string s; cin >> s;
  for (int i = 0; i < n; i++)
    a[i] = s[i] - '0';
  long long ans = 0;
  if (10 % p == 0) {
    for (int i = 0; i < n; i++)
      if (a[i] % p == 0)
        ans += i + 1;
    cout << ans;
    return 0;
  }
  for (int i = 0; i < p; i++)
    ls[i] = -1; 
  int din = bp(10, p - 2);
  int cp = 1;
  for (int i = 1; i < n; i++)
    cp = (cp * 10) % p;
  int cx = 0;
  for (int i = 0; i < n; i++)
    cx = (cx * 10 + a[i]) % p;
  for (int i = 0; i < n; i++) {
    int px = cx; ls[px] = i;
    cx = ((cx - cp * a[i]) % p + p) % p;
    if (ls[cx] > 0)
      dp[i] = dp[ls[cx] - 1] + 1;
    else if (ls[cx] == 0) 
      dp[i] = 1;
    ans += dp[i];
    cp = (cp * din) % p;
  }
  cout << ans;


Compiler output:
a.cc: In function 'int main()':
a.cc:49:15: error: expected '}' at end of input
   49 |   cout << ans;
      |               ^
a.cc:17:15: note: to match this '{'
   17 | signed main() {
      |               ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
#define ull unsigned long long
 
int main() {
    int N;
    int P;
    string S;
    cin >> N >> P;
    cin >> S;
    int counter = 0;
 
    for (int i = 1; i <= S.size(); i++) {
        for (int j = 0; j <= S.size() - i; j++) {
            string S1 = S.substr(j, i);
            ll k= stoull(S1);
            if (k % P == 0) counter++;
        }
    }
 
    cout << counter << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: 'll' was not declared in this scope; did you mean 'ull'?
   17 |             ll k= stoull(S1);
      |             ^~
      |             ull
a.cc:18:17: error: 'k' was not declared in this scope
   18 |             if (k % P == 0) counter++;
      |                 ^
Language: Java

import java.math.BigInteger;
import java.util.Scanner;

public class Sub {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		BigInteger p = new BigInteger(scanner.next());
		String s = scanner.next();

		int count = 0;

		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n + 1; j++) {
				if (new BigInteger(s.substring(i, j)).remainder(p).equals(BigInteger.ZERO))
					count++;
			}
		}
		System.out.println(count);

	}

}


Compiler output:
Main.java:4: error: class Sub is public, should be declared in a file named Sub.java
public class Sub {
       ^
1 error
Language: Java

import java.math.BigInteger;
import java.util.Random;
import java.util.Scanner;

public class Sub {
	public static void main(String[] args) {
		Random random = new Random();

		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		BigInteger p = new BigInteger(scanner.next());
		String s = scanner.next();

		int count = 0;

		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n + 1; j++) {
				if (new BigInteger(s.substring(i, j)).remainder(p).equals(BigInteger.ZERO))
					count++;
			}
		}
		System.out.println(count);

	}

}


Compiler output:
Main.java:5: error: class Sub is public, should be declared in a file named Sub.java
public class Sub {
       ^
1 error
Language: Java

package abc.abc158.e;

import java.math.BigInteger;
import java.util.Random;
import java.util.Scanner;

public class Sub {
	public static void main(String[] args) {
		Random random = new Random();

		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		BigInteger p = new BigInteger(scanner.next());
		String s = scanner.next();

		int count = 0;

		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n + 1; j++) {
				if (new BigInteger(s.substring(i, j)).remainder(p).equals(BigInteger.ZERO))
					count++;
			}
		}
		System.out.println(count);

	}

}


Compiler output:
Main.java:7: error: class Sub is public, should be declared in a file named Sub.java
public class Sub {
       ^
1 error
Language: C++

// author: @Vitalosa

#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<< (ostream &f, const vector<T> &a){
    for(int i = 0; i < a.size()-1; ++i){ f << a[i] << ' '; }
    f << *(a.end()-1);
    return f;
}

template <typename T>
ostream& operator<< (ostream &f, const vector< vector<T> > &a){
    for(int i = 0; i < a.size()-1; ++i){ f << a[i] << endl; }
    f << *(a.end()-1);
    return f;
}

template <typename T>
istream& operator>> (istream &f, vector<T> &a){
    for(auto &el : a){ f >> el; }
    return f;
}

#define maxN 500500

#define int long long 

char arr[maxN];

int cnt[maxN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,p;
    cin>>n>>p;
    for (int i=1; i<=n; ++i){
        cin>>arr[i];
    }
    int st=1;
    int sum=0;
    int ans=0;
    for (int i=n; i>0; --i){
        sum+=st*(arr[i]-'0');
        st*=10;
        st%=p;
        sum%=p;
        ans+=cnt[sum];
        if (sum%p==0) ++ans;
        cnt[sum]++;
    }
    cout<<ans<<"\n";
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define int long long
using namespace std;

const int INF = 0x3f3f3f3f;
const int N=1e6+10;

int cnt[N];

signed main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	string s;
	int n,p,ans=0;
	cin>>n>>p>>s;
	if(p==2||p==5) {
		for(i=0; i<n; i++)
			if((s[i]-'0')%p==0) ans+=i+1;
	} else {
		int t=1,sum=0;
		cnt[0]=1;
		for(int i=n-1; i>=0; i--) {
			sum=(sum+(s[i]-'0')*t)%p;
			ans+=cnt[sum];
			cnt[sum]++;
			t=t*10%p;
		}

	}

	cout<<ans<<endl;




	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:52:21: error: 'i' was not declared in this scope
   52 |                 for(i=0; i<n; i++)
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
char s[200005];
int cnt[10010];
int main()
{
	int n,p;cin>>n>>p>>s;
	int t=0,x=1;cnt[0]=1;
	long long sum;
		if(p==2||p==5)
	{for(int i=n-1;i>=1;--i)
	
		if((s[i]-'0')%p==0) sum+=(i+1);
}
	else { 
		for(int i=n-1;i>=0;--i)
		{
		t=(t+(s[j]-'0')*x)%p;
		x=x*10%p;
		sum+=cnt[t];
		cnt[t]++;
		}
	}
cout<<sum;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:25: error: 'j' was not declared in this scope
   18 |                 t=(t+(s[j]-'0')*x)%p;
      |                         ^
Language: C++

#include <bits/stdc++.h>

// #define fi first
#define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;


int main(){
  ll n,p,ans;
  ans = 0;
  cin>>n>>p;

  string s;
  cin>>s;

  //sort(ALL(s));
  vector<int> v(n+1);
  v[n] = 0;
  int keta = 1;

  if(10%p==0) {
    rep(i, n){
      if((s[i]-'0')%p==0) ans+=i+1;
    }
    cout << ans <<endl;
    return 0;
  }

  map<int, int> m;
  for(int i=n-1;i>=0;i--){
    v[i] =  ((s[i] - '0') * keta) % p ;
    v[i] = (v[i]+v[i+1] )% p;
    //cout << v[i] <<endl;
    m[v[i]]++;
    keta *=10; keta  %= p;
  }
  //m[0]++;
  for(map<int,int>::iterator mi=m.begin();mi!=m.end();mi++){
    //rep(i,p+1){
  //cout  <<"# "  <<mi->second<<endl;   keta = ke   keta = keta * 10 % p;ta * 10 % p;

    if(mi->se>1) ans += mi->se*(mi->se-1)/2;
  }
  //  cout << ans <<endl;

  
  if m[0]>1 {ans += m[0];}


  cout << ans <<endl;

}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:64:6: error: expected '(' before 'm'
   64 |   if m[0]>1 {ans += m[0];}
      |      ^
      |      (
Language: C++

#include <bits/stdc++.h>

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;


int main(){
  ll n,p,ans;
  ans = 0;
  cin>>n>>p;

  string s;
  cin>>s;

  vector<int> v(n+1);
  v[n] = 0;
  int keta = 1;

  if(10%p==0) {
    rep(i, n){
      if((s[i]-'0')%p==0) ans+=i+1;
    }
    cout << ans <<endl;
    return 0;
  }

  map<int, int> m;
  for(int i=n-1;i>=0;i--){
    v[i] =  ((s[i] - '0') * keta) % p ;
    v[i] = (v[i]+v[i+1] )% p;
    //cout << v[i] <<endl;
    m[v[i]]++;
    keta *=10; keta  %= p;
  }
  //m[0]++;
  for(map<int,int>::iterator mi=m.begin();mi!=m.end();mi++){
    //rep(i,p+1){
  //cout  <<"# "  <<mi->second<<endl;   keta = ke   keta = keta * 10 % p;ta * 10 % p;

    if(mi->se>1) ans += mi->se*(mi->se-1)/2;
  }
  //  cout << ans <<endl;

  ans += m[0];


  cout << ans <<endl;

}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:58:12: error: 'struct std::pair<const int, int>' has no member named 'se'
   58 |     if(mi->se>1) ans += mi->se*(mi->se-1)/2;
      |            ^~
a.cc:58:29: error: 'struct std::pair<const int, int>' has no member named 'se'
   58 |     if(mi->se>1) ans += mi->se*(mi->se-1)/2;
      |                             ^~
a.cc:58:37: error: 'struct std::pair<const int, int>' has no member named 'se'
   58 |     if(mi->se>1) ans += mi->se*(mi->se-1)/2;
      |                                     ^~
Language: C++

#include <bits/stdc++.h>

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;


int main(){
  ll n,p,ans;
  ans = 0;
  cin>>n>>p;

  string s;
  cin>>s;

  vector<int> v(n+1);
  v[n] = 0;
  int keta = 1;

  if(10%p==0) {
    rep(i, n){
      if((s[i]-'0')%p==0) ans+=i+1;
    }
    cout << ans <<endl;
    return 0;
  }

  map<int, int> m;
  for(int i=n-1;i>=0;i--){
    v[i] =  ((s[i] - '0') * keta) % p ;
    v[i] = (v[i]+v[i+1] )% p;
    //cout << v[i] <<endl;
    m[v[i]]++;
    keta *=10; keta  %= p;
  }
  m[0]++;
  rep(i,n){
  //cout  <<"# "  <<mi->second<<endl;   keta = ke   keta = keta * 10 % p;ta * 10 % p;

    if(m[i]->second>1) ans += m[i]->second*(m[i]->second-1)/2;
  }
  //  cout << ans <<endl;

  //ans += m[0];


  cout << ans <<endl;

}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:57:12: error: base operand of '->' is not a pointer
   57 |     if(m[i]->second>1) ans += m[i]->second*(m[i]->second-1)/2;
      |            ^~
a.cc:57:35: error: base operand of '->' is not a pointer
   57 |     if(m[i]->second>1) ans += m[i]->second*(m[i]->second-1)/2;
      |                                   ^~
a.cc:57:49: error: base operand of '->' is not a pointer
   57 |     if(m[i]->second>1) ans += m[i]->second*(m[i]->second-1)/2;
      |                                                 ^~
Language: C++

#include <bits/stdc++.h>

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;


int main(){
  ll n,p,ans;
  ans = 0;
  cin>>n>>p;

  string s;
  cin>>s;

  vector<int> v(n+1);
  v[n] = 0;
  int keta = 1;

  if(10%p==0) {
    rep(i, n){
      if((s[i]-'0')%p==0) ans+=i+1;
    }
    cout << ans <<endl;
    return 0;
  }

  map<int, int> m;
  for(int i=n-1;i>=0;i--){
    v[i] =  ((s[i] - '0') * keta) % p ;
    v[i] = (v[i]+v[i+1] )% p;
    //cout << v[i] <<endl;
    m[v[i]]++;
    keta *=10; keta  %= p;
  }
  m[0]++;
  rep(i,n){
  //cout  <<"# "  <<mi->second<<endl;   keta = ke   keta = keta * 10 % p;ta * 10 % p;

    if(mi[i]->second>1) ans += mi[i]->second*(mi[i]->second-1)/2;
  }
  //  cout << ans <<endl;

  //ans += m[0];


  cout << ans <<endl;

}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:57:8: error: 'mi' was not declared in this scope; did you mean 'i'?
   57 |     if(mi[i]->second>1) ans += mi[i]->second*(mi[i]->second-1)/2;
      |        ^~
      |        i
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, b, n) for (int i = b; i < (n); i++)

int main()
{
  int n,p;
  cin >> n >> p;
  string s;
  cin >> s;
  
  int anser = 0;
  
  rep(i, 0, n)
  {
    string tes = "";
    
    tes += s[i];
    
  	if (atoi(tes.c_str()) % p == 0) anser++;
    //cout << tes << endl;
    
    rep(ii, i, n)
  	{
      	tes += s[ii];
      
  		//cout << tes << endl;
  		if (atoi(tes.c_str()) % p == 0) anser++;
    }
  }
  
  string a = "33883322005544116655"
  cout << atoi(s.c_str()) << endl;
  cout << anser << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:3: error: expected ',' or ';' before 'cout'
   33 |   cout << atoi(s.c_str()) << endl;
      |   ^~~~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll N, ll mod){
  if (N == 0) return 1;
  else{
    if (N % 2 == 0) return Pow(A * A % mod, N / 2, mod) % mod;
    else return (A % mod) * Pow(A * A % mod, N / 2, mod) % mod;
  }
}

void solve(){
    int N, P; cin >> N >> P;
  string S; cin >> S;

  if (P == 2 || P == 5){
    ll ans = 0;
    for (ll i = 0; i < N; i++){
      int now = S[i] - '0';
      if (now % P == 0){
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  ll DP[N + 1] = {};
  
  for (int i = N - 1; i >= 0; i--){
    ll now = S[i] - '0';
    now *= Pow(10, N - 1 - i, P);
    DP[i] = (DP[i + 1] + now) % P;
  }

  ll cnt[N] ={};
  for (int i = 0; i < N + 1; i++){
    cnt[DP[i]]++;
  }

  ll ans = 0;
  for (int i = 0; i < N + 1; i++){
    ans += cnt[DP[i]] - 1;
    cnt[DP[i]]--;
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:51:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   51 |     return 0;
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main(void){
  int N, P, ans=0;
  string S;
  cin >> N >> P;
  cin >> S;
  int Snum[N+1];
  
  for(int i=0; i<N+1; i++) Snum[i]= atoi(S.substr(j,1).c_str());
 
  if(P==2 || P==5){
    for(int i=0; i<N; i++){
      for(int j=i; j<N; j++){
        if((Snum[i]%P)==0){
          ans++;
        }
      }
    }
    cout << ans;
    return 0;
  }
  
  long long int amari[N+1];//ここにあまりをためる
  long long int pre_amari;//繰り下がり
  for(int i=0; i<N+1; i++){//i~N桁目をPで割り、あまりをためる
  						 //繰り下がりも考慮
    pre_amari=0;
    for(int j=i; j<N+1; j++){
      pre_amari = 10*(Snum[j] + pre_amari)%P;//繰り下が
    }
    amari[i] = pre_amari;
  }
  
  //割り切れるものを探す
  for(int i=0; i<N+1; i++){
    for(int j=i+1; j<N+1; j++){
      if(amari[j]==amari[i]){
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:51: error: 'j' was not declared in this scope
   11 |   for(int i=0; i<N+1; i++) Snum[i]= atoi(S.substr(j,1).c_str());
      |                                                   ^
Language: C++

// Contest: AtCoder Beginner Contest 158 (https://atcoder.jp/contests/abc158)
// Problem: E: Divisible Substring (https://atcoder.jp/contests/abc158/tasks/abc158_e)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

int ma[10000], mpa[10000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, p; string s; cin >> n >> p >> s;
    ll cnt = 0;
    int *m = ma, *mp = mpa;

    trav(c, s) {
        memset(m, 0, 40000);
        rep(i, p)
            m[(i * 10 + (c - '0')) % p] += mp[i];
        m[(c - '0') % p]++;
        cnt += m[0];
        swap(m, mp);
    }

    cout << cnt << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:92:9: error: 'memset' was not declared in this scope
   92 |         memset(m, 0, 40000);
      |         ^~~~~~
a.cc:42:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   41 | #   include <variant>
  +++ |+#include <cstring>
   42 | #endif