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

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

	vector<int> U(P, 0);
	U[0]++;
	int ans = 0;

	int t = stoi(S.substr(N - 1, 1)) % P;
	U[t]++;
	int x = 1;
	for (int i = N - 2; i >= 0; i--) {
		x = (x * 10) % P;
		t = (t + stoi(S.substr(i, 1)) * x) % P;
		ans += U[t];
		U[t]++;
	}

	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: 'cin' was not declared in this scope
    3 |         cin >> N >> P;
      |         ^~~
a.cc:4:9: error: 'string' was not declared in this scope
    4 |         string S;
      |         ^~~~~~
a.cc:5:16: error: 'S' was not declared in this scope
    5 |         cin >> S;
      |                ^
a.cc:7:9: error: 'vector' was not declared in this scope
    7 |         vector<int> U(P, 0);
      |         ^~~~~~
a.cc:7:16: error: expected primary-expression before 'int'
    7 |         vector<int> U(P, 0);
      |                ^~~
a.cc:8:9: error: 'U' was not declared in this scope
    8 |         U[0]++;
      |         ^
a.cc:11:17: error: 'stoi' was not declared in this scope
   11 |         int t = stoi(S.substr(N - 1, 1)) % P;
      |                 ^~~~
a.cc:21:9: error: 'cout' was not declared in this scope
   21 |         cout << ans << endl;
      |         ^~~~
a.cc:21:24: error: 'endl' was not declared in this scope
   21 |         cout << ans << endl;
      |                        ^~~~
Language: C++

#include<iostream>

using namespace std;

int main() {
  int n, p;
  cin >> n >> p;
  int ans(0), mods[p] = {};
  char arr[i];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  mods[0] = 1;
  int x(0), p2(1);
  for (int i = n - 1; i >= 0; --i) {
    x = (x + p2 * (arr[i] - '0')) % p;
    ans += mods[x]++;
    p2 = (p2 * 10) % p;
  }
  cout << ans << '\n';
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: 'i' was not declared in this scope
    9 |   char arr[i];
      |            ^
a.cc:10:38: error: 'arr' was not declared in this scope
   10 |   for (int i = 0; i < n; ++i) cin >> arr[i];
      |                                      ^~~
a.cc:14:20: error: 'arr' was not declared in this scope
   14 |     x = (x + p2 * (arr[i] - '0')) % p;
      |                    ^~~
Language: C++

#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

const long long mod=1e9+7;
long long inverseMod(long long x,long long mod);
long long nCr(long long n,long long r,long long mod){
    //when r is lesser and is greater
    long long res=1;
    if(r>n-r)r=n-r;
    long long div=1;
    for(long long  i=0;i<r;i++){
        res=(res*(n-i))%mod;
    }

    for(long long i=1;i<=r;i++){
        div=(div*i)%mod;
    }
    return (res*inverseMod(div,mod))%mod;
}


long long power(long long x,long long n,long long mod){
//(x^n)%mod
long long result=1;

    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

long long inverseMod(long long x,long long mod){

return power(x,mod-2,mod);
}


int main()
{
    slowanddetermined

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

        map<long long ,long long >mp;
        mp[0]=1;
        long long a;
        long long last=0;
        long long pow=1;
        long long value=0;
        for(int i=n-1;i>=0;i--){
            value=(value+pow*(s[i]-'0'))%p;
            mp[value]++;
            pow=(pow*10)%p;
        }
        for(auto i:mp){
            ans+=(i.second*(i.second-1))/2;
        }
        //ans+=mp[0];



    }
    cout<<ans;





    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:29: error: expected primary-expression before '==' token
   58 |             if((s[i]-'0')%5)==0)ans+=i+1;
      |                             ^~
Language: C

#include <bits/stdc++.h>

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);

//FILE *fi=freopen("1.inp","r",stdin);
//FILE *fo=freopen("1.out","w",stdout);
int n;
long long p;
string s;
long long d[100001];
long long ans;
int main()
{
    cin>>n>>p;
    cin>>s;
    s='.'+s;
    long long cur = 0;
    long long x = 1;
    long long cnt=0;
    if(p==5||p==2)
    {
        for(int i=n;i>=1;i--)
        {
            cnt+=((s[i]-'0')%p)==0;
            ans+=cnt;
        }
        cout<<ans;
        return 0;
    }
    d[0]=1LL;
    for(int i=n;i>=1;i--)
    {
        cur = (((s[i]-'0') * x % p) + cur) % p;
        x*=10;
        x%=p;
        ans+=d[cur];
        d[cur]++;
    }
    cout<<ans;
    return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

typedef long long ll;
typedef pair<int,int> pii;

int cnt[10000], cnt[200001][10];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, p;
    string s;
    cin >> n >> p >> s;
    int rem = 0;
    cnt[0] = 1;
    reverse(s.begin(), s.end());
    ll ans = 0, a1 = 0, a2 = 0;
    for (int i = 0; i < n; i++) {
        rem *= 10;
        rem += s[i] - '0';
        rem %= p;
        ans += cnt[rem];
        cnt[rem]++;
        if (i != 0)
            for (int j = 0; j < 10; j++)
                cnt[i][j] = cnt[i-1][j];
        cnt[i][s[i]-'0']++;
        a1 += cnt[i][0] + cnt[i][2] + cnt[i][4] + cnt[i][6] + cnt[i][8];
        a2 += cnt[i][0] + cnt[i][5];
    }
    if (p == 2)
        cout << a1;
    else if (p == 5)
        cout << a2;
    else
        cout << ans;

    return 0;
}


Compiler output:
a.cc:7:17: error: conflicting declaration 'int cnt [200001][10]'
    7 | int cnt[10000], cnt[200001][10];
      |                 ^~~
a.cc:7:5: note: previous declaration as 'int cnt [10000]'
    7 | int cnt[10000], cnt[200001][10];
      |     ^~~
a.cc: In function 'int main()':
a.cc:31:23: error: invalid types 'int[int]' for array subscript
   31 |                 cnt[i][j] = cnt[i-1][j];
      |                       ^
a.cc:31:37: error: invalid types 'int[int]' for array subscript
   31 |                 cnt[i][j] = cnt[i-1][j];
      |                                     ^
a.cc:32:15: error: invalid types 'int[int]' for array subscript
   32 |         cnt[i][s[i]-'0']++;
      |               ^
a.cc:33:21: error: invalid types 'int[int]' for array subscript
   33 |         a1 += cnt[i][0] + cnt[i][2] + cnt[i][4] + cnt[i][6] + cnt[i][8];
      |                     ^
a.cc:33:33: error: invalid types 'int[int]' for array subscript
   33 |         a1 += cnt[i][0] + cnt[i][2] + cnt[i][4] + cnt[i][6] + cnt[i][8];
      |                                 ^
a.cc:33:45: error: invalid types 'int[int]' for array subscript
   33 |         a1 += cnt[i][0] + cnt[i][2] + cnt[i][4] + cnt[i][6] + cnt[i][8];
      |                                             ^
a.cc:33:57: error: invalid types 'int[int]' for array subscript
   33 |         a1 += cnt[i][0] + cnt[i][2] + cnt[i][4] + cnt[i][6] + cnt[i][8];
      |                                                         ^
a.cc:33:69: error: invalid types 'int[int]' for array subscript
   33 |         a1 += cnt[i][0] + cnt[i][2] + cnt[i][4] + cnt[i][6] + cnt[i][8];
      |                                                                     ^
a.cc:34:21: error: invalid types 'int[int]' for array subscript
   34 |         a2 += cnt[i][0] + cnt[i][5];
      |                     ^
a.cc:34:33: error: invalid types 'int[int]' for array subscript
   34 |         a2 += cnt[i][0] + cnt[i][5];
      |                                 ^
Language: C++

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

int main()
{
    int n, p, s;
    char x[1];
    vector<int> md;
    vector<int> d;
    scanf("%d %d\n", &n, &p);
    vector<int> c(p, 0);
    string xx;
    cin >> xx;
    // cout << xx << endl;
    int ans;
    if (p % 10 == 0)
    {
        rep(i, n)
        {
            if (xx[i] - '0' % p == 0)
            {
                ans += i + 1;
            }
        }
    }
    else
    {
        int ten = 1;
        vector<int> c(p, 0);
        c[0]++;
        int s = 0;
        rep(i, n)
        {
            s += (xx[n - i - 1] - '0') * ten % p;
            s %= p;
            c[s]++;
            ten *= 10;
            ten %= p;
        }
        rep(i, p)
        {

            ans += c[i] * (c[i] - 1) / 2;
        }
    }
    cout << ans << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:48:25: error: expected '}' at end of input
   48 |     cout << ans << endl;
      |                         ^
a.cc:7:1: note: to match this '{'
    7 | {
      | ^
Language: C++

#include <bits/stdc++.h>
#include <string.h>
using namespace std;
 
int check_num(string s,int p){
    int count = 0;
    if (s.size() == 1) {
        if (stoi(s) % p == 0){
            return 1;
        } else {
            return 0;
        }
    }
    for(int i = 0; i < s.size(); i++){
        string part = s.substr(0,i+1);
        if (stoi(part) % p == 0){
            count += 1;
        }
    }
    return check_num(s.substr(1),p)+count;
}
 
int main() {
    int n,p;
    string s;
    cin >> n >> p;
    cin >> s;
    int count = check_num(s,p);
    cout << count << endl;
}
#include <iostream>
#include <string.h>
using namespace std;

int check_num(string s,int p){
    int count = 0;
    if (s.size() == 1) {
        if (stoi(s) % p == 0){
            return 1;
        } else {
            return 0;
        }
    }
    for(int i = 0; i < s.size(); i++){
        string part = s.substr(0,i+1);
        if (stoi(part) % p == 0){
            count += 1;
        }
    }
    return check_num(s.substr(1),p)+count;
}
 
int main() {
    int n,p;
    string s;
    cin >> n >> p;
    cin >> s;
    int count = check_num(s,p);
    cout << count << endl;
}
提出情報
提出日時

Compiler output:
a.cc:35:5: error: redefinition of 'int check_num(std::string, int)'
   35 | int check_num(string s,int p){
      |     ^~~~~~~~~
a.cc:5:5: note: 'int check_num(std::string, int)' previously defined here
    5 | int check_num(string s,int p){
      |     ^~~~~~~~~
a.cc:53:5: error: redefinition of 'int main()'
   53 | int main() {
      |     ^~~~
a.cc:23:5: note: 'int main()' previously defined here
   23 | int main() {
      |     ^~~~
a.cc:61:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
   61 | 提出情報
      | ^~~~~~~~
Language: Java

import java.util.Scanner;
public class Main {
  public static void main (String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int P = sc.nextInt();
    String S = sc.next();
    long ans = 0;
    if(p==2||p==5){
      for(int i = N-1; i >= 0; i--){
        if((S.charAt(i)-'0')%p==0){
          ans+=i+1;
        }
      }
    } else {
      int amari[] = new int[P];
      int jouyo = 0;
      int kurai = 1;
      for(int i = N-1; i >= 0; i--){
        jouyo = (jouyo + (S.charAt(i)-'0')*kurai)%p;
        kurai *= 10;
        amari[jouyo]++;
      }
      ans = amari[0];
      for(int i = 0; i < P; i++){
        ans += amari[i]*(amari[i]-1)/2;
      }
    }
    System.out.println(ans);
    return;
  }
}

Compiler output:
Main.java:9: error: cannot find symbol
    if(p==2||p==5){
       ^
  symbol:   variable p
  location: class Main
Main.java:9: error: cannot find symbol
    if(p==2||p==5){
             ^
  symbol:   variable p
  location: class Main
Main.java:11: error: cannot find symbol
        if((S.charAt(i)-'0')%p==0){
                             ^
  symbol:   variable p
  location: class Main
Main.java:20: error: cannot find symbol
        jouyo = (jouyo + (S.charAt(i)-'0')*kurai)%p;
                                                  ^
  symbol:   variable p
  location: class Main
4 errors
Language: Java

import java.util.Scanner;
public class Main {
  public static void main (String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int P = sc.nextInt();
    String S = sc.next();
    long ans = 0;
    if(p==2||p==5){
      for(int i = N-1; i >= 0; i--){
        if((S.charAt(i)-'0')%p==0){
          ans+=i+1
        }
      }
    } else {
      int amari[] = new int[P];
      int jouyo = 0;
      int kurai = 1;
      for(int i = N-1; i >= 0; i--){
        jouyo = (jouyo + (S.charAt(i)-'0')*kurai)%p;
        kurai *= 10;
        amari[jouyo]++;
      }
      ans = amari[0];
      for(int i = 0; i < P; i++){
        ans += amari[i]*(amari[i]-1)/2;
      }
    }
    System.out.println(ans);
    return;
  }
}

Compiler output:
Main.java:12: error: ';' expected
          ans+=i+1
                  ^
1 error
Language: Java

import java.util.Scanner;
public class Main {
  public static void main (String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int P = sc.nextInt();
    String S = sc.next();
    long ans = 0;
    if(p==2||p==5){
      for(int i = N-1; i >= 0; i--){
        if((S.charAt(i)-'0')%p==0){
          ans+=i+1
        }
      }
    } else {
      int amari[] = new int[P];
      int jouyo = 0;
      int kurai = 1;
      for(int i = N-1; i >= 0; i--){
        jouyo = (jouyo + (S.charAt(i)-'0')*kurai)%p;
        kurai *= 10;
        amari[jouyo]++;
      }
      ans = amari[0];
      for(int i = 0; i < P; i++){
        ans += amari[i]*(amari[i]-1)/2
      }
    }
    System.out.println(ans);
    return;
  }
}

Compiler output:
Main.java:12: error: ';' expected
          ans+=i+1
                  ^
Main.java:26: error: ';' expected
        ans += amari[i]*(amari[i]-1)/2
                                      ^
2 errors
Language: Java

#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF=1<<30;


int main(void) {

    int N,P; cin>>N>>P;
    string S; cin>>S;
    ll ans = 0;
    if(P==2 || P==5){
        for (int i = 0; i < N; ++i) {
            if((S[i]-'0')%P==0)ans += i+1;
        }
    }else{
        map<int, int> mp;
        mp[0]=1;
        reverse(S.begin(), S.end());
        int sum = 0;
        int base = 1;
        for (int i = 0; i < N; ++i) {
            sum += (S[i]-'0') * base;
            sum %= P;
            ans += mp[sum];
            mp[sum]++;
            base *= 10;
            base %= P;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#define _LIBCPP_DEBUG 0
^
Main.java:1: error: class, interface, enum, or record expected
#define _LIBCPP_DEBUG 0
        ^
Main.java:2: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:4: error: class, interface, enum, or record expected
typedef long long int ll;
^
Main.java:5: error: unnamed classes are a preview feature and are disabled by default.
ll MOD = 1e9 + 7;
^
  (use --enable-preview to enable unnamed classes)
Main.java:11: error: not a statement
    int N,P; cin>>N>>P;
                   ^
Main.java:12: error: not a statement
    string S; cin>>S;
                 ^
Main.java:34: error: not a statement
    cout<<ans<<endl;
             ^
Main.java:9: error: <identifier> expected
int main(void) {
             ^
9 errors
Language: C++

#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
///#include<bits/stdc++.h> (for gcc? Necessary for atcoder.)
///#include<bitset/stdc++.h>  (??))
using namespace std;

int main(){
    long int N,P;
    string S,Ssub;
    cin>>N>>P;
    cin>>S;
    int c=0;
    if (P==2){
        for (int i=0;i<N;i++){
            if (stoi(S.substr(i,1))%2==0) c+=1;
        }
        cout<<c<<endl;
    }
    else if (P==5){
        for (int i=0;i<N;i++){
            if (stoi(S.substr(i,1))%5==0) c+=1;
        }
        cout<<c<<endl;
    }
    else{
        int a[N+1],Pcoset=1,tcoset=0;
        for (int i=0;i<N;i++){
            tcoset+=(stoi(S.substr(N-1-i,1))*Pcoset)%P;
            Pcoset=(Pcoset*10)%P;
            a[i]=tcoset%P;
        }    
        a[N]=0;
        sort(a,a+N+1);
        long int nn,n1=0,n2=0,ntot=0;
        for (int j=1;j<N+1;j++){
            if (a[j]!=a[j-1]){
                n1=n2;
                n2=j;
                nn=n2-n1;
                ntot+=nn*(nn-1)/2;
            }
        }   
        ntot+=(N+1-n2)*(N-n2)/2;
        cout<<ntot<<endl;
        }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   35 |         sort(a,a+N+1);
      |         ^~~~
      |         short
Language: C++

#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;

int main(){
    long int N,P;
    string S,Ssub;
    cin>>N>>P;
    cin>>S;
    int a[N+1],Pcoset=1,tcoset=0;
    for (int i=0;i<N;i++){
        tcoset+=(stoi(S.substr(N-1-i,1))*Pcoset)%P;
        Pcoset=(Pcoset*10)%P;
        a[i]=tcoset%P;
    }    
    a[N]=0;
    sort(a,a+N+1);
    long int nn,n1=0,n2=0,ntot=0;
    for (int j=1;j<N+1;j++){
        if (a[j]!=a[j-1]){
            n1=n2;
            n2=j;
            nn=n2-n1;
            ntot+=nn*(nn-1)/2;
        }
    }
    ntot+=(N+1-n2)*(N-n2)/2;
    cout<<ntot<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |     sort(a,a+N+1);
      |     ^~~~
      |     short
Language: C++

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


int32_t main(){

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

   long long ans = 0;

   vector<int> freq(p);
   for (int i = 0; i < n; ++i)
   {
      int curr = s[i] - '0';
      vector<int> tmp(p);
      for (int j = 0; j < p; ++j)
      {
         int neww = ((j * 10) % p + curr) % p; 
         tmp[neww] += freq[j];
      }
      freq = tmp;
      freq[curr%p]++;
      ans += freq[0];
      tr(i, freq, ans, freq[0]);
   }

   cout<<ans;
   return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:26:7: error: 'tr' was not declared in this scope; did you mean 'tm'?
   26 |       tr(i, freq, ans, freq[0]);
      |       ^~
      |       tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
string s;
int transition[10][10101], n, p;
ll ans;
int dp[2][10101];
ll modpow(ll x, ll y)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
 
int32_t main()
{
    usecppio
    cin >> n >> p >> s;
    int inv = modpow(10, p-2);
    if (p < 10)
    {
        for (int j = 0; j<10; j++)
            for (int i = 0; i<p; i++)
                transition[j][i] = ((i*10)+j)%p;
        int r = 0;
        for (int i = 0; i<n; i++)
        {
            int u = s[i]-'0';
            r = 1-r;
            memset(dp[r],0,sizeof(dp[r]));
            for (int j = 0; j<p; j++)
            {
                int k = transition[u][j];
                dp[r][k] += dp[1-r][j];
            }
            dp[r][transition[u][0]]++;
            ans += dp[r][0];
        }
        cout << ans << '\n';
    }
    else
    {
        for (int j = 0; j<10; j++)
            for (int i = 0; i<p; i++)
                transition[j][i] = (((i-j+p)%p)*(inv))%p;
        int r = 0;
        for (int i = 0; i<n; i++)
        {
            register int u = s[i]-'0';
            r = 1-r;
            for (int j = 0; j<p; j++)
            {
                int k = transition[u][j];
                dp[r][j] = dp[1-r][k];
            }
            dp[r][u]++;
            ans += dp[r][0];
        }
        cout << ans << '\n';
    }
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:25:5: error: 'usecppio' was not declared in this scope
   25 |     usecppio
      |     ^~~~~~~~
a.cc:57:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   57 |             register int u = s[i]-'0';
      |                          ^
Language: Java

import java.util.Scanner;
public class Main {
  public static void main (String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int P = sc.nextInt();
    String S = sc.next();
    StringBuffer sb = new StringBuffer(S);
    int ans = 0;
    int num;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N - i; j++){
        num = Integer.parseInt(sb.substring(i, N-j))
        if(num%P==0) ans++;
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:13: error: ';' expected
        num = Integer.parseInt(sb.substring(i, N-j))
                                                    ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,p;
string s;
map<int,int> mp;  //存余数和对应的个数 
ll ans=0;
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("input.txt","r",stdin);
	cin>>n>>p>>s;
	if(p==2 or p==5)
	{
		int pt=p;
		if((s[i]-'0')%pt==0) ans+=i+1;
	}
	else
	{
		mp[0]++;
		int num=0;
		int m=1;
		for(int i=n-1;~i;i--)
		{
			num=(num+(s[i]-'0')*m)%p;
			ans+=mp[num];
			mp[num]++;
			m=(m*10)%p;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:23: error: 'i' was not declared in this scope
   16 |                 if((s[i]-'0')%pt==0) ans+=i+1;
      |                       ^
Language: C++

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

long long str2int(string s){
    int l=s.length();
    long long i=0;
    for(int j=0;j<l;j++){
        i+=(long long)((int)(s[j]-'0')*(long long)pow(10,l-j-1));
    }
    return i;
}


int main(){
    long long N,P;
    cin >>N>>P;
    string s;
    cin>>s;
    int count=0;
    int l=1;
    for(int i=0;i<N-l;i++){
        for(int j=i+l;j<=N;j++){
            string s2;
            s2 =s.substr(i,j-i);
            long long a
            a=str2int(s2);
            cout<<a<<endl;
            if(a%P==0){
               count++;
                
            }
        }
    }
     

    cout<<count<<endl;
    
    return 0;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:13: error: expected initializer before 'a'
   28 |             a=str2int(s2);
      |             ^
a.cc:29:19: error: 'a' was not declared in this scope
   29 |             cout<<a<<endl;
      |                   ^
Language: C++

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

int n,p;
string s;


void solve() {
  ll tmp = 0;
  map<ll,ll> mp;
  deque<ll> deq;
  rep(i,n) {
    tmp *= 10LL;
    tmp += (ll)( s[i]-'0' );
    tmp %= (ll)p;
    ++mp[tmp];
    deq.pb(tmp);
  }

  ll ans = 0;
  tmp = 0;
  
  rep(i,n) {
    
    int v = ( p - tmp ) % p;
    //assert( ( v + need ) % p == 0 );

    if( mp.count(v) ) {
      ans += mp[v];
    }
    assert(mp.count(deq.front));
    --mp[deq.front()];
    deq.pop_front();
    tmp *= 10LL;
    tmp += (ll)( s[i]-'0' );
    tmp %= (ll)p;
    
  }
  cout << ans << endl;
}

int main() {

  cin >> n >> p;

  cin >> s;
  solve();
  return 0;
}


Compiler output:
In file included from /usr/include/c++/14/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106,
                 from a.cc:1:
a.cc: In function 'void solve()':
a.cc:49:20: error: no matching function for call to 'std::map<long long int, long long int>::count(<unresolved overloaded function type>)'
   49 |     assert(mp.count(deq.front));
      |            ~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_map.h:1270:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
 1270 |         count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
      |         ^~~~~
/usr/include/c++/14/bits/stl_map.h:1270:9: note:   template argument deduction/substitution failed:
a.cc:49:20: note:   couldn't deduce template parameter '_Kt'
   49 |     assert(mp.count(deq.front));
      |            ~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1264:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; size_type = long unsigned int; key_type = long long int]'
 1264 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/14/bits/stl_map.h:1264:29: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const std::map<long long int, long long int>::key_type&' {aka 'const long long int&'}
 1264 |       count(const key_type& __x) const
      |             ~~~~~~~~~~~~~~~~^~~
Language: C++

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

int n,p;
string s;


void solve() {
  ll tmp = 0;
  map<ll,ll> mp;
  deque<ll> deq;
  rep(i,n) {
    tmp *= 10LL;
    tmp += (ll)( s[i]-'0' );
    tmp %= (ll)p;
    ++mp[tmp];
    deq.pb(tmp);
  }

  ll ans = 0;
  tmp = 0;
  
  rep(i,n) {
    
    int v = ( p - tmp ) % p;
    //assert( ( v + need ) % p == 0 );

    if( mp.count(v) ) {
      ans += mp[v];
    }
    assert(mp.count(deq.front);
    --mp[deq.front()];
    deq.pop_front();
    tmp *= 10LL;
    tmp += (ll)( s[i]-'0' );
    tmp %= (ll)p;
    
  }
  cout << ans << endl;
}

int main() {

  cin >> n >> p;

  cin >> s;
  solve();
  return 0;
}


Compiler output:
a.cc:67:2: error: unterminated argument list invoking macro "assert"
   67 | }
      |  ^
a.cc: In function 'void solve()':
a.cc:49:5: error: 'assert' was not declared in this scope
   49 |     assert(mp.count(deq.front);
      |     ^~~~~~
a.cc:2:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    1 | #include<bits/stdc++.h>
  +++ |+#include <cassert>
    2 | 
a.cc:49:11: error: expected '}' at end of input
   49 |     assert(mp.count(deq.front);
      |           ^
a.cc:41:12: note: to match this '{'
   41 |   rep(i,n) {
      |            ^
a.cc:49:11: error: expected '}' at end of input
   49 |     assert(mp.count(deq.front);
      |           ^
a.cc:26:14: note: to match this '{'
   26 | void solve() {
      |              ^
Language: C++

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
copnst string NO  = "";

typedef long long ll;

int n,p;
string s;


void solve() {
  ll tmp = 0;
  map<ll,ll> mp;
  deque<ll> deq;
  rep(i,n) {
    tmp *= 10LL;
    tmp += (ll)( s[i]-'0' );
    tmp %= (ll)p;
    ++mp[tmp];
    deq.pb(tmp);
  }

  ll ans = 0;
  tmp = 0;
  
  rep(i,n) {
    
    int v = ( p - tmp ) % p;
    //assert( ( v + need ) % p == 0 );

    if( mp.count(v) ) {
      ans += mp[v];
    }
    
    --mp[deq.front()];
    deq.pop_front();
    tmp *= 10LL;
    tmp += (ll)( s[i]-'0' );
    tmp %= (ll)p;
    
  }
  cout << ans << endl;
}

int main() {

  cin >> n >> p;

  cin >> s;
  solve();
  return 0;
}


Compiler output:
a.cc:18:1: error: 'copnst' does not name a type; did you mean 'const'?
   18 | copnst string NO  = "";
      | ^~~~~~
      | const
Language: C++

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

int n,p;
string s;


void solve() {
  ll tmp = 0;
  map<ll,ll> mp;
  deque<ll> deq;
  rep(i,n) {
    tmp *= 10LL;
    tmp += (ll)( s[i]-'0' );
    tmp %= (ll)p;
    ++mp[tmp];
    deq.pb(tmp);
  }

  ll ans = 0;
  tmp = 0;
  
  rep(i,n) {
    if( debug ) {
      cout << "* " << i << "-th (" << s[i] << "):" << endl;
    }
    int v = ( p - tmp ) % p;
    //assert( ( v + need ) % p == 0 );

    if( mp.count(v) ) {
      ans += mp[v];
    }
    
    --mp[deq.front()];
    deq.pop_front();
    tmp *= 10LL;
    tmp += (ll)( s[i]-'0' );
    tmp %= (ll)p;
    
  }
  cout << ans << endl;
}

int main() {

  cin >> n >> p;

  cin >> s;
  solve();
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:42:9: error: 'debug' was not declared in this scope
   42 |     if( debug ) {
      |         ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std; 
int main()
{
	int q,flip=0;
	string s,a,b;
	cin>>s>>q;
	for(int i=0;i<q;i++)
	{
		int t;
		cin>>t;
		if(t==1)
			flip++;
		else
		{
			int f;
			char c;
			cin>>f>>c;
			f--;
			if(f^(flip%2))
				b.push_back(c);
			else
				a.push_back(c);
		}
	}
	reverse(all(a));
	s=a+s+b;
	if(flip%2)
		reverse(all(s));
	cout<<s<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   26 |         reverse(all(a));
      |                 ^~~
      |                 std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: Java

#include <cstdio>
using namespace std;
int N,P,cur,t=1,cnt[10010],i;char S[200010];long long ans;
int main()
{
    scanf("%d%d%s",&N,&P,S);
    if(P==2||P==5){
        for(i=0;i<N;i++)if((S[i]-'0')%P==0)ans+=i+1;
    }else{、
    /*
    类似dp
    记录下由s[i]到字符串末尾形成的这个数字%p的余数，如果之前有cnt个串也等于这个余数
    那么相减之后就%p为0，因此ans+=cnt
    */
        cnt[0]=1;
        for(i=N-1;i>=0;i--){
            (cur+=(S[i]-'0')*t)%=P;
            ans+=cnt[cur]++;
            t=t*10%P;
        }
    }
    printf("%lld",ans);
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <cstdio>
^
Main.java:1: error: class, interface, enum, or record expected
#include <cstdio>
         ^
Main.java:3: error: class, interface, enum, or record expected
int N,P,cur,t=1,cnt[10010],i;char S[200010];long long ans;
^
Main.java:3: error: class, interface, enum, or record expected
int N,P,cur,t=1,cnt[10010],i;char S[200010];long long ans;
                             ^
Main.java:3: error: class, interface, enum, or record expected
int N,P,cur,t=1,cnt[10010],i;char S[200010];long long ans;
                                            ^
Main.java:9: error: illegal character: '\u3001'
    }else{?
          ^
Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
int main()
^
  (use --enable-preview to enable unnamed classes)
Main.java:6: error: illegal start of expression
    scanf("%d%d%s",&N,&P,S);
                      ^
8 errors
Language: C++


void E_Divisible_String(void) {

	int N, P;
	cin >> N >> P;

	string S1;
	cin >> S1;

	vector<int>S2(N);
	for (int loop = 0; loop < N; loop++) {
		S2[loop] = (int)S1[loop] - (int)'0';
	}

	int counter = 0;
	int num = 0;

	for (int start = 0; start < N; start++) {
		for (int end = start; end < N; end++) {

			num = 0;
			for (int loop = start; loop <= end; loop++) {
				num = (num * 10 + S2[loop]) % P;
			}
			if (num == 0) counter++;
		}
	}

	cout << counter << flush;
	return;
}


Compiler output:
a.cc: In function 'void E_Divisible_String()':
a.cc:5:9: error: 'cin' was not declared in this scope
    5 |         cin >> N >> P;
      |         ^~~
a.cc:7:9: error: 'string' was not declared in this scope
    7 |         string S1;
      |         ^~~~~~
a.cc:8:16: error: 'S1' was not declared in this scope
    8 |         cin >> S1;
      |                ^~
a.cc:10:9: error: 'vector' was not declared in this scope
   10 |         vector<int>S2(N);
      |         ^~~~~~
a.cc:10:16: error: expected primary-expression before 'int'
   10 |         vector<int>S2(N);
      |                ^~~
a.cc:12:17: error: 'S2' was not declared in this scope
   12 |                 S2[loop] = (int)S1[loop] - (int)'0';
      |                 ^~
a.cc:23:51: error: 'S2' was not declared in this scope
   23 |                                 num = (num * 10 + S2[loop]) % P;
      |                                                   ^~
a.cc:29:9: error: 'cout' was not declared in this scope
   29 |         cout << counter << flush;
      |         ^~~~
a.cc:29:28: error: 'flush' was not declared in this scope
   29 |         cout << counter << flush;
      |                            ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,P;cin >> N >> P;
  string S;cin >> S;
  if(P==2 || P==5){
    ll sum = 0;
    rep(i,N){
      if((S[i]-'0')%P==0)sum += i+1;
    }
    cout << sum << endl;
    return 0;
  }

  int m10 = 1;
  int U = 0;
  vector<ll> v(P,0);
  ll ans = 0;
  v[0] = 1;
  per(i,N){
    int x = S[i] - '0';
    U += x*m10;
    U %= P;
    ans += v[U];
    ++v[U];
    m10 *= 10;
    m10 %= P;
  }
  cout << ans << endl;
  return 0;
}
    ++v[U];


Compiler output:
a.cc:63:5: error: expected unqualified-id before '++' token
   63 |     ++v[U];
      |     ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n;
const long long D=1e9+7;
long long gcd(long long x,long long y){
    if(y==0)return x;
    return gcd(y,x%y);
}
long long ans=0;
long long P;
long long s[200005];
long long t[200005];
int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n>>P;
    int i;
    cin>>a+1;
    for(i=1 ; i<=n ; i++)a[i]-='0';
    if(P==2){
        for(i=1 ; i<=n ; i++){
            if(a[i]%2==0)ans+=i;
        }
    }
    else if(P==5){
        for(i=1 ; i<=n ; i++)
            if(a[i]==5 || a[i]==0)ans+=i;

    }
    else{
        t[n]=1;
        for(i=n-1; i>=1 ; i--){
            t[i]=t[i+1]*10%P;
        }
        for(i=1 ;i<=n ; i++){
            s[i]=(s[i-1]+t[i]*a[i])%P;
            check[s[i]]++;
        }
        check[0]++;
        for(i=0 ; i<P ; i++)
            ans+=check[i]*(check[i]-1)/2;

    }


    cout<<ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: 'a' was not declared in this scope
   19 |     cin>>a+1;
      |          ^
a.cc:38:13: error: 'check' was not declared in this scope
   38 |             check[s[i]]++;
      |             ^~~~~
a.cc:40:9: error: 'check' was not declared in this scope
   40 |         check[0]++;
      |         ^~~~~
Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define RREP(i, a, b) for (int i = (a); i >= (b); --i)

using namespace std;
using ll = long long;

ll solve_1 (int N, int P, vector<int> S) {
  ll cnt = 0;

  RREP(i, N - 1, 0)
    if (S[i] % P == 0) cnt += i + 1;

  return cnt;
}

ll solve_2 (int N, int P, vector<int> S) {
  ll cnt = 0;
  vector<int> table(P, 0);
  int U_i = 0;
  int ten = 1;

  // 2.
  // この1は、U_i自体が（つまりiから最右端までの列が）割り切れる場合をカウントするために使われる。
  table[0] = 1;
  print_array(table.data(), table.size());

  RREP(i, N - 1, 0) {
    U_i = (U_i + S[i] * ten) % P;

    // 1.
    // table[U_i]には（具体的なjがどこかという情報は落ちているものの）U_{j+1} ≡ U_i であるようなjの個数が保存されている。
    // そのようなjを右端、iを左端とする列はPで割り切れる。
    // なぜならば、 U_{j+1} ≡ U_i より U - U_{j+1} はPで割り切れるため、解説PDFのいう条件が成り立つからである。
    cnt += table[U_i];

    table[U_i]++;
    ten = (ten * 10) % P;
  }

  return cnt;
}

/**
 * main
 */
int main () {
  int N, P; cin >> N >> P;
  string S_; cin >> S_;

  vector<int> S(N);
  REP(i, 0, N) S[i] = (S_[i] - '0') % P;

  cout << ((P == 2 || P == 5) ? solve_1(N, P, S) : solve_2(N, P, S))
       << '\n';
}


Compiler output:
a.cc: In function 'll solve_2(int, int, std::vector<int>)':
a.cc:29:3: error: 'print_array' was not declared in this scope
   29 |   print_array(table.data(), table.size());
      |   ^~~~~~~~~~~
Language: C++

using namespace std;

int main(int argc, const char *argv[])
{
  int n, p;
  string s;
  cin >> n >> p >> s;
  int result = 0;
  for (int i = 0; i < s.size(); i++) {
    for(int j = 1; j < s.size() - i + 1; j++) {
      int a = stoi(s.substr(i, j));
      if (a % p == 0) {
        result++;
      }
    }
  }
  
  cout << result << "\n";
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:6:3: error: 'string' was not declared in this scope
    6 |   string s;
      |   ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> n >> p >> s;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:7:20: error: 's' was not declared in this scope
    7 |   cin >> n >> p >> s;
      |                    ^
a.cc:11:15: error: 'stoi' was not declared in this scope
   11 |       int a = stoi(s.substr(i, j));
      |               ^~~~
a.cc:11:15: note: 'std::stoi' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:18:3: error: 'cout' was not declared in this scope
   18 |   cout << result << "\n";
      |   ^~~~
a.cc:18:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: Java

/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class E
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int P = Integer.parseInt(st.nextToken());
         String input = infile.readLine();
         int[] arr = new int[N];
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(input.charAt(i)+"");
         long[] count = new long[P];
         long res = 0L;
         int coef = 1;
         int curr = 0;
         for(int i=N-1; i >= 0; i--)
         {
            curr += coef*arr[i];
            curr %= P;
            res += count[curr];
            if(curr == 0)
               res++;
            count[curr]++;
            coef *= 10;
            coef %= P;
         }
         System.out.println(res);
      }
   }

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

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,p,t=0;
	string s;
	cin>>n>>p;
	cin>>s;
	ll ans=0;
	if(p==5)
	{
		for(int i=0;i<n;i++)
		{
			if((s[i]-'0')%p==0)ans+=(i+1);
		}
	}
	else if(p==2)
	{
		for(int i=0;i<n;i++)
		{
			if((s[i]-'0')%p==0)ans+=(i+1);
		}
	}
	else
	{	map<int, int> mp;
		mp[0]++;int p2=1;
		for(int i=n-1;i>=0;i--)
		{
			t=(t+(s[i]-'0')*p2)%p;
			ans=ans+mp[t];
			mp[t]++;
			p2=(p2*10)%p;
		}
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'll' was not declared in this scope
    9 |         ll ans=0;
      |         ^~
a.cc:14:44: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |                         if((s[i]-'0')%p==0)ans+=(i+1);
      |                                            ^~~
      |                                            abs
a.cc:21:44: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |                         if((s[i]-'0')%p==0)ans+=(i+1);
      |                                            ^~~
      |                                            abs
a.cc:30:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |                         ans=ans+mp[t];
      |                         ^~~
      |                         abs
a.cc:35:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |         cout<<ans;
      |               ^~~
      |               abs
Language: C++

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

int main(){
    string S;
    int N;
    int P;
    int tmp = 0;
    long long int count = 0;
    cin >> N >> P;
    cin >> S;
    if(P==2 || P==5){
        for(int j=0;j<N;j++){
            if((S[j] - '0')%P==0)count += (j+1);
    }}
    else{
    int dp[P+10];
    int u = 1;
    for(int j=0;j<P;j++)dp[j]=0;
    for(int j=N-1;j>=0;j--){
        tmp = (S[j] - '0')*u + tmp;
        tmp %= P;
        dp[tmp]++;
        u = (u*10)%P;
        count += dp[tmp];
    }
    cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:2: error: expected '}' at end of input
   28 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 2e5 + 7;
const double pi = acos(-1);

int main(){
	int n,p;
	scanf("%d %d",&n,&p);
	string s;
	cin >> s;
	ll ans = 0;
	if(p == 2){
		ll m = 0;
		for(int i = 0;i < s.size();i++){
			if(s[i]=='2'||s[i]=='0'||s[i]=='4'||s[i]=='6'||s[i]=='8'){
				m += (i+1);
			}
		}
		ans = m;
	}else if(p == 5){
		ll m = 0;
		for(int i = 0;i < s.size();i++){
			if(s[i]=='5'||s[i]=='0'){
				m += (i+1);
			}
		}
		ans = m;
	}else{
		map<ll,ll> mp;
		mp[0]++;
		ll num = 0;
		ll r = 1;
		for(int i = n-1;i >=0;i--){
			num += (s[i] - '0') * r;
			ll k = num % p;
			ans += mp[k];
			mp[t]++;
			r = r * 10 % p;
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:28: error: 't' was not declared in this scope
   39 |                         mp[t]++;
      |                            ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n, p;
   cin >> n >> p;
   string s;
   cin >> s;
   if (10 % p) {
      llong ans = 0;
      rep(i, 0, n) {
         if ((s[i] - '0') % p == 0)){
            ans += i+1;
         }
      }
      cout << ans << endl;
      return 0;
   }
   vector<int> d(n + 1);
   int ten = 1;
   rrep(i, n - 1, 0) {
      int a = (s[i] - '0') * ten % p;
      d[i] = (d[i + 1] + a) % p;
      ten *= 10;
      ten %= p;
   }
   vector<int> cnt(p);
   llong ans = 0;
   rep(i, n, 0) {
      ans += cnt[d[i]];
      cnt[d[i]]++;
   }
   cout << ans << endl;
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:36: error: expected primary-expression before ')' token
   19 |          if ((s[i] - '0') % p == 0)){
      |                                    ^
Language: C++

#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//modint
template<typename T> T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		T t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

class modint {
public:
	ll val;
	ll mod;
	modint(ll a,ll m) {
		mod = m;
		val = a % mod;
	}
	modint operator+(const modint& r) {
		return modint((this->val + r.val) % mod,mod);
	}
	modint operator-(const modint& r) {
		return modint((this->val - r.val) % mod + ((this->val - r.val) % mod < 0) * mod,mod);
	}
	modint operator*(const modint& r) {
		return modint((((this->val % mod) * (r.val % mod))) % mod,mod);
	}
	modint& operator+=(const modint& r) {
		*this = *this + r;
		return *this;
	}
	modint& operator-=(const modint& r) {
		*this = *this - r;
		return *this;
	}
	modint& operator*=(const modint& r) {
		*this = *this * r;
		return *this;
	}

	modint operator/(const modint& r) {
		return modint(this->val * modinv(r.val, mod) % mod, mod);
	}
	modint& operator/=(const modint& r) {
		*this = *this / r;
		return *this;
	}
};

modint modpow(modint x, int k) {
	if (k == 0)return modint(1, x.mod);
	if (k % 2 == 0) return modpow(x * x, k / 2);
	else return x * modpow(x, k - 1);
}



int main() {
	int N, P;
	cin >> N >> P;
	string S;
	cin >> S;
  	assert(P != 2 && P != 5)
	vector<modint> md(N, modint(0, P));
	md[0] = modint(S[0] - '0', P);
	for (int i = 1; i < N; i++) {
		md[i] = md[i - 1] + modint(S[i] - '0', P) / modpow(modint(10,P),i);
	}
	
	vector<int> cnt(P, 0);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		cout << md[i].val << " ";
		if (md[i].val == 0) {
			ans++;
		}
			ans += cnt[md[i].val];
			cnt[md[i].val]++;
	}
	cout << endl;
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:9: error: expected ';' before 'vector'
   78 |         vector<modint> md(N, modint(0, P));
      |         ^~~~~~
a.cc:79:9: error: 'md' was not declared in this scope
   79 |         md[0] = modint(S[0] - '0', P);
      |         ^~