criyle/codenet-compile-errors huggingface dataset:
Language: Java

package abc158;

import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc158/submissions/10645244 にも参考
 */
public class ProblemE {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), p = scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			// 文字列を数字に変換
			int[] s2 = new int[n];
			IntStream.range(0, n).forEach(i -> s2[i] = s[i] - '0');
			int[] m = new int[p];
			long answer = 0L;
			int now = 0;
			int digit = 1;
			m[0] = 1;
			for (int i = n - 1; i >= 0; i--) {
				now += s2[i] * digit;
				now %= p;
				answer += m[now];
				m[now]++;
				digit *= 10;
				digit %= p;
			}
			System.out.println(answer);
		}
	}
}


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

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

map<long long,int> s;
long long d[100010], m[100010], po[100010];

int main() {
	ios::sync_with_stdio(false);
	int n,p; cin >> n >> p;
	string st; cin >> st;
	for (int i = n; i > 0; i--) d[i] =st[i-1]-'0';
	
	long long ans = 0;
	if (p == 2) {
		for (int i = 0; i < n; i++) if (!(d[i]&1)) ans += i+1;
		cout << ans << "\n";
		return 0;
	}
	else if (p == 5) {
		for (int i = 0; i < n; i++) if ((d[i] == 0) || (d[i] == 5)) ans += i+1;
		cout << ans << "\n";
		return 0;
	}
	
	s[0]++;	
	po[n] = 1;
	for (int i = n-1; i > 0; i--) po[i] = po[i+1] * 10 % p;
	for (int i = n; i > 0; i--) {
		m[i] = (m[i+1] + d[i] * po[i]) % p;	
		s[m[i]]++;
	}
	long long ans = 0;
	for (int i = n+1; i > 1; i--) {
		s[m[i]]--;
		auto it = s.find(m[i]);
		if (it != s.end()) ans += it->second;
	}
	cout << ans << "\n";
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:19: error: redeclaration of 'long long int ans'
   32 |         long long ans = 0;
      |                   ^~~
a.cc:13:19: note: 'long long int ans' previously declared here
   13 |         long long ans = 0;
      |                   ^~~
Language: C++

#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

// 繰り返し2乗法
// 計算量 O(logn)
template <typename T>
constexpr T pow(T a, int n, int p) {
	T ret = 1;
	while(n != 0) {
		if(n % 2) {
			ret *= a;
			ret %= p;
		}
		a *= a;
		a %= p;
		n /= 2;
	}
	return ret;
}

int main() {
	int n, p;
	string s;
	cin >> n >> p;
	cin >> s;
	if(p == 2 || p == 5) {
		ll result = 0;
		REP(i, n) {
			if(s[i] - '0' == p) {
				result += i + 1
			};
		}
		return 0;
	}

	ll result = 0;
	vector<ll> u(n + 1);
	unordered_map<int, int> cnt;
	u[0] = 0;
	cnt[0] = 1;
	REP(i, n) {
		u[i + 1] = u[i] + (s[n - i - 1] - '0') * pow(10, i, p);
		u[i + 1] %= p;
		result += cnt[u[i + 1]];
		cnt[u[i + 1]]++;
		// cout << "u[" << i + 1 << "] = " << u[i + 1] << '\t' << "cnt["
		//	 << u[i + 1] << "] = " << cnt[u[i + 1]] << '\t'
		//	 << "result = " << result << endl;
	}
	cout << result << endl;
	return 0;
}


Compiler output:
a.cc:2:10: fatal error: boost/optional.hpp: No such file or directory
    2 | #include <boost/optional.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
long N,P,cnt[10101],T[2<<17],ans,mod,i;
string s;
int main(){
	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{
		T[N-1]=1;
		for(i=N-1;i--;)T[i]=T[i+1]*10%P;
		cnt[0]=1;
		for(i=0;i<N;i++){
			mod=((s[i]-'0'+mod)*T[i])%P;
			ans+=cnt[mod]++;
		}
	}
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: expected '}' before 'else'
   12 |         else{
      |         ^~~~
a.cc:7:23: note: to match this '{'
    7 |         if(P==2||P==5){for(i=0;i<N;i++){
      |                       ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, p; cin >> n >> p;
	string s; cin >> s;
	if (p == 2 || p == 5) {
		long long ans = 0;
		for (int i = 0; i < n; ++i)
			if ((s[i] - '0') % p == 0) ans += i + 1;
		cout << ans << endl;
		return 0;
	}
	vector<int> mul(n);
	mul[0] = 1;
	for (int i = 1; i < n; ++i) mul[i] = mul[i - 1] * 10 % p;
	vector<int> dp(n + 1);
	dp[n] = 0;
	for (int i = n - 1; i >= 0; --i)
		dp[i] = (dp[i + 1] + (s[i] - '0') * mul[n - i - 1]) % p;
	vector<int> m(p + 1);
	long long ans = 0;
	for (int i = n - 1; i >= 0; --i) {
        ++m[dp[i]]
		ans += m[dp[i]];
	}
	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:19: error: expected ';' before 'ans'
   26 |         ++m[dp[i]]
      |                   ^
      |                   ;
   27 |                 ans += m[dp[i]];
      |                 ~~~
Language: C++


#include <bits/stdc++.h>

using namespace std;
using LL = long long;
const int N = 1024 + 2e5;
const int INF = INT32_MAX - 1;
const double EPS = 1E-9;

int a[N];
int n, m;

const int M = 10000;
LL dp[N][M];
string s;

int p;

void dfs(int i, int r) {
    dfs(i + 1, (r + (s[i] - '0')) % p);
}

int main() {
    ios_base::sync_with_stdio(false);

#ifdef CF_DEBUG
    freopen("../cf/input.txt", "r", stdin);
#endif

    int p;
    cin >> n >> p;
    string s;
    cin >> s;
//    for(int j=0;j<M;++j){
//        dp[0][j]=1;
//    }
    for (int i = 1; i <= n; ++i) {
        dp[i][(s[i-1]-'0')%p]+=1;
        for (int j = 0; j < p; ++j) {
            LL v = (j * 10 + (s[i-1]-'0')) % p;
            dp[i][v] += dp[i - 1][j];
//            cout<<i<<" "<<v<<" "<<dp[i][v]<<"\n";
        }
//        for(int j=0;j<p;++j){
//
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<"\n";
    }
    LL res = 0;
    for (int i = 1; i <= n; ++i) {
//        cout<<dp[i][0]<<endl;
        res += dp[i][0];
    }
    cout << res;

    return 0;
}

Compiler output:
/tmp/ccIlDf1J.o: in function `dfs(int, int)':
a.cc:(.text+0x19): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccIlDf1J.o
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccIlDf1J.o
/tmp/ccIlDf1J.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x2b0): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccIlDf1J.o
a.cc:(.text+0x2c9): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccIlDf1J.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n, p;
	string s;
	cin >> n >> p >> s;
	int ans = 0;
	map<int, int> m;
	if(p <= 100) {
		for(int i = 0; i < n; ++i) {
			// Just s[i]
			int use = (s[i] - '0') % p;
			if(use == 0) {
				++ans;
			}
			// New map
			map<int, int> nm;
			for(auto it: m) {
				int r1 = (10 * it.first + use) % p;
				if(r1 == 0) {
					ans += it.second;
				}
				nm[r1] += it.second;
			}

			++nm[use];
			m = nm;
		}
		cout << ans;
	}
	else {
		vector<int> pre(n);
		int ten = 1;
		for(int i = n-1; i >= 0; --i) {
			pre[i] = (ten * (s[i] - '0')) % p;
			ten = (ten * 10) % p;
		}
		for(int i = 1; i < n; ++i) pre[i] = (pre[i] + pre[i-1]) % p;
		m[0] = 1;
		for(int i = 0; i < n; ++i) {
			ans += m[pre[i]];
			++m[pre[i]];
		}
		cout << ans;
	}
	return 0;
}


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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(LL i = 0; i < n; i++)
#define REP(i,a,b) for(LL i=a;i<b;i++)
#define rep1(i,b) for(LL i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((LL)(x).size())
#define F first
#define S second
typedef tree<LL,null_type,less<LL>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

LL bin(LL a,LL p)
{
	if(a==0)
		return 1;
	else if(a==1)
		return 10%p;
	LL x = bin(a/2,p)%p;
	x = (x*1ll*x)%p;
	if(a%2)
		return (10*1ll*x)%p;
	else
		return (x)%p;
}

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
		
	LL t=1;
	//cin>>t;
	while(t--){
		LL n,p;
		string s;
		cin>>n>>p>>s;
		if(p==2 || p==5)
			{	int ans=0;
				for(int i=0;i<n;i++)
					{
						if((s[i]-'0')%P==0)
							ans = ans+i+1;
					}
				cout<<ans<<'\n';
				return 0;
			}
		vector <LL> v(s.size(),0);
		for(LL i=0;i<s.size();i++)
				{
					v[i]=bin(n-i-1,p);
					v[i] = ((s[i]-'0')*1ll*v[i])%p;
					//cout<<v[i]<<"\n";
				}
		vector <LL> pre(n+1,0);
		vector <LL> m(p,0);
		m[0]=1;
		long long int c=0;
		long long  ans=0;
		for(LL i=0;i<n;i++)
			{
                pre[i+1]=(pre[i]+v[i])%p;
                //cout<<pre[i+1]<<" "<<m[pre[i+1]]<<'\n';
               	ans = ans+m[((pre[i+1]%p))%p];
                if(v[i]==0 && (s[i]-'0')%p!=0)
                	c+=1;
                ++m[(pre[i+1])%p];
			}
		//cout<<c<<'\n';
		cout<<ans<<'\n';
	}



return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:63: error: 'P' was not declared in this scope
   54 |                                                 if((s[i]-'0')%P==0)
      |                                                               ^
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(LL i = 0; i < n; i++)
#define REP(i,a,b) for(LL i=a;i<b;i++)
#define rep1(i,b) for(LL i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((LL)(x).size())
#define F first
#define S second
typedef tree<LL,null_type,less<LL>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

LL bin(LL a,LL p)
{
	if(a==0)
		return 1;
	else if(a==1)
		return 10%p;
	LL x = bin(a/2,p)%p;
	x = (x*1ll*x)%p;
	if(a%2)
		return (10*1ll*x)%p;
	else
		return (x)%p;
}

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif		
	LL t=1;
	//cin>>t;
	while(t--){
		LL n,p;
		string s;
		cin>>n>>p>>s;
		if(p==2 || p==5)
			{	int ans=0;
				for(int i=0;i<n;i++)
					{
						if((s[i]-'0')%P==0)
							ans = ans+i+1;
					}
				cout<<ans<<'\n';
				return 0;
			}
		vector <LL> v(s.size(),0);
		for(LL i=0;i<s.size();i++)
				{
					v[i]=bin(n-i-1,p);
					v[i] = ((s[i]-'0')*1ll*v[i])%p;
					//cout<<v[i]<<"\n";
				}
		vector <LL> pre(n+1,0);
		vector <LL> m(p,0);
		m[0]=1;
		long long int c=0;
		long long  ans=0;
		for(LL i=0;i<n;i++)
			{
                pre[i+1]=(pre[i]+v[i])%p;
                //cout<<pre[i+1]<<" "<<m[pre[i+1]]<<'\n';
               	ans = ans+m[((pre[i+1]%p))%p];
                if(v[i]==0 && (s[i]-'0')%p!=0)
                	c+=1;
                ++m[(pre[i+1])%p];
			}
		//cout<<c<<'\n';
		cout<<ans<<'\n';
	}



return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:63: error: 'P' was not declared in this scope
   59 |                                                 if((s[i]-'0')%P==0)
      |                                                               ^
Language: C++

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

long long main(){
  long long N,P;
  string S;
  cin>>N>>P>>S;
  if(P==2){
    long long ans=0;
    for(long long i=0;i<N;i++){
      if((S.at(i)-'0')%2==0){
        ans+=i+1;
      }
    }
    cout<<ans<<endl;
  }else if(P==5){
    long long ans=0;
    for(long long i=0;i<N;i++){
      if((S.at(i)-'0')%5==0){
        ans+=i+1;
      }
    }
    cout<<ans<<endl;
  }else{
    vector<long long> s(N),a(N),count(P,0);
    long long res=1;
    for(long long i=0;i<N;i++){
      a.at(i)=res;
      res*=10;
      res%=P;
      s.at(i)=S.at(i)-'0';
    }
    reverse(s.begin(),s.end());
    long long x=0;
    for(long long i=0;i<N;i++){
      x+=a.at(i)*s.at(i);
      x%=P;
      count.at(x)++;
    }

    long long ans=count.at(0)*(count.at(0)+1)/2;
    for(long long i=1;i<P;i++){
      ans+=count.at(i)*(count.at(i)-1)/2;
    }
    cout<<ans<<endl;
  }
}


Compiler output:
cc1plus: error: '::main' must return 'int'
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];
    for(int j=0;j<P;j++)dp[j]=0;
    for(int j=N-1;j>=0;j--){
        tmp = (S[j] - '0') + tmp * 10;
        tmp %= P;
        dp[tmp]++;
    }
    for(int j=1;j<P;j++)count += dp[j]*(dp[j]-1)/2;
    count += dp[j]*(dp[j]+1)/2;
    }
    cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'j' was not declared in this scope
   25 |     count += dp[j]*(dp[j]+1)/2;
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int d[200005],f[200005],n,p,ans;
map<int,int> num;
qpow(int a,int b){
	int res=1;
	while(b){
		if(b&1) res=res*a%p;
		b=b/2;
		a=a*a%p;
	}
	return res%p;
}
int main(){
	cin>>n>>p;
	string s;
	cin>>s;
	s=" "+s;
	for(int i=1;i<=n;i++){
		f[i]=(f[i-1]+qpow(10,n-i)%p*(s[i]-'0')%p)%p;
	}
	for(int i=n;i>=1;i--){
		d[i]=(d[i+1]+(s[i]-'0')%p*qpow(10,n-i)%p)%p;
		num[d[i]]++;
	}
	num[0]++;
	for(int i=1;i<=n;i++){
		num[d[i]]--;
		ans+=num[(d[1]-f[i-1]+p)%p];
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc:6:1: error: ISO C++ forbids declaration of 'qpow' with no type [-fpermissive]
    6 | qpow(int a,int b){
      | ^~~~
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];
    for(int j=0;j<P;j++)dp[j]=0;
    for(int j=N-1;j>=0;j--){
        tmp = (S[i] - '0') + tmp * 10;
        tmp %= P;
        dp[tmp]++;
    }
    for(int j=0;j<P;j++)count += dp[j]*(dp[j]+1)/2;
    }
    cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:18: error: 'i' was not declared in this scope
   20 |         tmp = (S[i] - '0') + tmp * 10;
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long cheng(int a)
{
	int cnt=1;
	for (int i=0;i<a;i++)
		cnt*=10;
	return cnt;
}
int main()
{
	int a,b,ans=0;
	string c;
	cin>>a>>b>>c;
	for (int i=0;i<a;i++)
		for (int n=i;n<a;n++)
		{
			string d=substring(i,n);
			int cnt=0;
			for (int m=0;;m++)
				cnt=cnt+(d[m]-'0')*cheng(m);
			if (cnt%b==0)
				ans++;
		}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:34: error: 'substring' was not declared in this scope
   18 |                         string d=substring(i,n);
      |                                  ^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//vi rui;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,p;cin>>n>>p;
  string s;
  cin>>s;
  vi rui(n+1);
  reverse(ALL(s));
  //cout<<s<<endl;
  if(false){
    ll ans = 0;
    for(int i=0;i<n;i++){
      string ss ="";
      ll su = 0;
      ll kake = 1;
      //ll ans = 0;
      for(int j=i;j<n;j++){
	su += (s[j]-'0')*kake;
	kake *= 10;
	kake%=p;
	su%=p;
	if(su == 0)ans++;
	//cout<<su<<endl;
      }
    }
    cout<<ans<<endl;
  }else{
    ll kake = 1;
    for(int i=0;i<n;i++){
      rui[i+1] = rui[i]+(s[i]-'0')*kake;
      kake *= 10;
      kake %= p;
      rui[i+1] %= p;
      //   cout<<rui[i+1]<<endl;
    }
    ll now = -1;
    for(int i=0;i<=n;i++){
      if(now == rui[i] && now != 0){
	rui[i] = -llINF;	
      }else{
	now = rui[i];
      }
    }
    sort(ALL(rui));
    map<ll,ll>cnt;
    ll now = -1;
    for(int i=0;i<=n;i++){
	cnt[rui[i]]++;
    }
    ll ans = 0;
    for(auto a:cnt){
      if(a.F != -llINF)
      ans += a.S*(a.S-1)/2;
      // break;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:8: error: redeclaration of 'long long int now'
   63 |     ll now = -1;
      |        ^~~
a.cc:53:8: note: 'long long int now' previously declared here
   53 |     ll now = -1;
      |        ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, p;
    ll dp10[300000], dpS[300000];
    ll kosu[10001];
    MEMSET(kosu, 0);
    string S;
    cin>>N>>p;
    cin>>S;
    dp10[0]=1; dpS[0]=(S[N-1]-'0')%p;
    //cout<<dpS[0]<<endl;
    rep(i, N){
        ll th=S[N-i-1]-'0';
        //cout<<th<<endl;
        if(i==0) continue;
        dp10[i]=(dp10[i-1]*10)%p;
        dpS[i]=(dpS[i-1]+th*dp10[i])%p;
        //cout<<dpS[i]<<sp<<dp10[i]<<endl;
    }
    rep(i, N){
        kosu[dpS[i]]++;
    }
    cpp_int count=0;
    rep(i, p){
        count+=(kosu[i]*(kosu[i]-1))/2;
        //cout<<i<<":"<<sp<<kosu[i]<<endl;
    }
    count+=kosu[0];
    cout<<count<<endl;
    return 0;
}


Compiler output:
a.cc:18:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory
   18 | #include <boost/multiprecision/cpp_dec_float.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int main() {
  int N, P;
  string S;
  
  cin >> N >> P >> S;
  
  int numS = stoi(S);
  int imax = numS / P;
  
  int ans = 0;
  
  while(){
    int numX = P * i;
    string x = to_string(numX);
    
    int lenP = (int)(x.length());
    
    for (int j = 0; j <= N - lenP; j++){
      int lenQ = lenP + j;
      string y = x;
      for (int k = 0; k < j; k++){
        y = "0" + y;
      }
      for (int k = 0; k < N - lenQ; k++){
        if( regex_match(begin(S)+k , begin(S) + k + lenQ , regex(y)) ){
          ans++;
        }
      }
    }
    
  }

  
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: expected primary-expression before ')' token
   15 |   while(){
      |         ^
a.cc:16:20: error: 'i' was not declared in this scope
   16 |     int numX = P * i;
      |                    ^
Language: C++

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

int main() {
 int N,P,S,sss;
  int p=0;
  vector<int> SS(N);
  for(int i=0;i<N;i++){
     SS.at(i)=sss%pow(10,N-i);
  }
  for(int j=0;j<N;j++){
  for(int i=0;i<SS.at(j).size();i++){
    sss=SS.at(j)/pow(10,i+1);
    if(sss%P==0){
     p++; 
    }
  }
  }
  cout<<p<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: invalid operands of types 'int' and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%'
    9 |      SS.at(i)=sss%pow(10,N-i);
      |               ~~~^~~~~~~~~~~~
      |               |      |
      |               int    __gnu_cxx::__promote<double>::__type {aka double}
a.cc:12:26: error: request for member 'size' in 'SS.std::vector<int>::at(((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   12 |   for(int i=0;i<SS.at(j).size();i++){
      |                          ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
ll a[1000000];
int main() 
{
    ll n,k;
    cin>>n>>k;
    ll p=k;
  string s;
 cin>>s;
 ll i=0;
 while(i<=n-1)
 {
     ll g=int(s[i])-48;
     cout<<g<<"\n";
     a[i]=g;
     
     i++;
 }

ll b[p+1]={0};
i=0;
while(i<=p-1)
{
    
    if(a[0]%p==i)
    {
        b[i]=1;
    }
    else
    {
        b[i]=0;
    }
    
    i++;
    
}
j=1; ll c[p+1]={0};
while(j<=n-1)
{   
    i=0;
    while(i<=p-1)
    {
        c[i]=0;
        
        i++;
    }
    
    i=0;
    while(i<=p-1)
    {
//    b[i]///
  c[(i*10 + a[j])%p]+=b[i];
  c[a[j]%p]+=1;
  i++;
    }
    i=0;
    while(i<=p-1)
    {
        b[i]=c[i];
        i++;
    }j++;
    
}

cout<<b[0];

return 0;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:1: error: 'j' was not declared in this scope
   40 | j=1; ll c[p+1]={0};
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, p;
    ll dp10[300000], dpS[300000];
    ll kosu[10001];
    MEMSET(kosu, 0);
    string S;
    cin>>N>>p;
    cin>>S;
    dp10[0]=1; dpS[0]=(S[N-1]-'0')%p;
    //cout<<dpS[0]<<endl;
    rep(i, N){
        ll th=S[N-i-1]-'0';
        //cout<<th<<endl;
        if(i==0) continue;
        dp10[i]=(dp10[i-1]*10)%p;
        dpS[i]=(dpS[i-1]+th*dp10[i])%p;
        //cout<<dpS[i]<<sp<<dp10[i]<<endl;
    }
    rep(i, N){
        kosu[dpS[i]]++;
    }
    bint count=0;
    rep(i, p){
        count+=(kosu[i]*(kosu[i]-1))/2;
        //cout<<i<<":"<<sp<<kosu[i]<<endl;
    }
    count+=kosu[0];
    cout<<count<<endl;
    return 0;
}


Compiler output:
a.cc:18:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory
   18 | #include <boost/multiprecision/cpp_dec_float.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
  int N, P, count = 0;
  string S, test;
  cin >> N >> P >> S;
  int a, b, c;
  b = pow(10,P.size()-1);
  for(int i=0;i<n;i++){
    for(int j=i+b, j<n;j++){
      rep(k,i-j) test.at(k) = k+i;
      c = atoi(test.c_str());
      if(c % P == 0)count++;
    }
  }
  cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: request for member 'size' in 'P', which is of non-class type 'int'
   10 |   b = pow(10,P.size()-1);
      |                ^~~~
a.cc:11:17: error: 'n' was not declared in this scope
   11 |   for(int i=0;i<n;i++){
      |                 ^
a.cc:12:21: error: expected ';' before '<' token
   12 |     for(int j=i+b, j<n;j++){
      |                     ^
      |                     ;
a.cc:12:21: error: expected primary-expression before '<' token
Language: C++

#include<bits/stdc++.h>
#include<string.h>

using namespace std;

#define rep(i,n) for(int i=0; i< n; i++)

long double cutString(string s,int start, int end)
{
	long double answer = 0;
	string ans = "";
//	cout<< "start"<< start << endl;
//	cout<< "end"<< end<<endl;
	for(int i = start; i<end;i++)
	{
		ans += s[i];
	}
//	cout<<"s"<<ans<<endl;
    answer = stoull(ans, nullptr); 
//	cout<< answer<<endl;
	return answer;
}

int main(){
	int n,p;
	string s;
	cin >> n >> p;
	cin >> s;
	
	int start = 0;
	int end = 1;
	int count = 0;
	while(start != n){
		if(cutString(s, start, end) % p == 0)
			count++;
		end++;
		
		if(end > n){
			start++;
			end = start+1;
		}
			
	}
	cout<<count;
//	cout<< n<<p;
//	cout<< s;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:45: error: invalid operands of types 'long double' and 'int' to binary 'operator%'
   34 |                 if(cutString(s, start, end) % p == 0)
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
      |                             |                 |
      |                             long double       int
Language: C++

#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

const int INF = 1e9 + 7;
int q;

int main() {
//	INIT
	int n, p;
	long long ans = 0;
//	char s[200005];
	int s[200005];
	scanf("%d %d", &n, &p);
	getchar();
	for (int i = 0; i < n; ++i) {
		char c = getchar();
		s[i] = c - '0';
	}
	
	for (int i = 0; i < n; ++i) {
		cnt = (cnt * 10 + (s[j])) % p;
		if (cnt == 0) {
			++ans;		
		}
		int cnt2 = cnt;
		for (int j = i; j >=0; --j) {
			cnt2 = (cnt2 * 10 + (s[j])) % p;
				if (cnt2 == 0) {
				++ans;		
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   29 |                 cnt = (cnt * 10 + (s[j])) % p;
      |                 ^~~
      |                 int
a.cc:29:38: error: 'j' was not declared in this scope
   29 |                 cnt = (cnt * 10 + (s[j])) % p;
      |                                      ^
Language: C++

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

string s;
int ans;
void divide(int i , int j) {
    int wa = 0;
    int rank = 1;
    for(int k = j; k >=i; --k) {
        string tmp;
        tmp = s[k];
        wa += rank * stoi(tmp);
    }
    if(wa %p==0) ans++;

}
int main(void) {
    int n,p ; cin >> n >> p;
    cin >> s;

    ans ++;

    for(int i =0; i < (int)s.size() - 1; ++i)
    for(int j = i+1; j < (int)s.size(); ++j) {
        divide(i,j);
    }

    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'void divide(int, int)':
a.cc:19:12: error: 'p' was not declared in this scope
   19 |     if(wa %p==0) ans++;
      |            ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
ll a[1000000];
int main() 
{
    ll n,k;
    cin>>n>>k;
  string s;
 cin>>s;
 ll i=0;
 while(i<=n-1)
 {
     ll g=int(s[i])-48;
     cout<<g<<"\n";
     a[i]=g;
     
     i++;
 }

ll b[p+1]={0};
i=0;
while(i<=p-1)
{
    
    if(a[0]%p==i)
    {
        b[i]=1;
    }
    else
    {
        b[i]=0;
    }
    
    i++;
    
}
j=1; ll c[p+1]={0};
while(j<=n-1)
{   
    i=0;
    while(i<=p-1)
    {
        c[i]=0;
        
        i++;
    }
    
    i=0;
    while(i<=p-1)
    {
//    b[i]///
  c[(i*10 + a[j])%p]+=b[i];
  c[a[j]%p]+=1;
  i++;
    }
    i=0;
    while(i<=p-1)
    {
        b[i]=c[i];
        i++;
    }j++;
    
}

cout<<b[0];

return 0;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:6: error: 'p' was not declared in this scope
   22 | ll b[p+1]={0};
      |      ^
a.cc:29:9: error: 'b' was not declared in this scope
   29 |         b[i]=1;
      |         ^
a.cc:33:9: error: 'b' was not declared in this scope
   33 |         b[i]=0;
      |         ^
a.cc:39:1: error: 'j' was not declared in this scope
   39 | j=1; ll c[p+1]={0};
      | ^
a.cc:45:9: error: 'c' was not declared in this scope
   45 |         c[i]=0;
      |         ^
a.cc:54:3: error: 'c' was not declared in this scope
   54 |   c[(i*10 + a[j])%p]+=b[i];
      |   ^
a.cc:54:23: error: 'b' was not declared in this scope
   54 |   c[(i*10 + a[j])%p]+=b[i];
      |                       ^
a.cc:61:9: error: 'b' was not declared in this scope
   61 |         b[i]=c[i];
      |         ^
a.cc:61:14: error: 'c' was not declared in this scope
   61 |         b[i]=c[i];
      |              ^
a.cc:67:7: error: 'b' was not declared in this scope
   67 | cout<<b[0];
      |       ^
Language: C++

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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

/* vector<int> A(N); 
    vector<pair<int, int> > tasks; ＃ソートした場合、１つ目でソート
　tie(b, a) = p.at(i); #pairを分割
    tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
　xの二乗:  pow(x, 2.0) 
    小さい順: sort(v.begin(), v.end());
    大きい順: reverse(v.begin(), v.end());
    int: -2,147,483,648 ～ 2,147,483,647
    ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int>> data(3, vector<int>(4));
*/
 
int main() {
  
  ll N,P,S, B, C, count=0, ans=0;
  string D, E;
  cin >> N >> P >> S;
  vector<ll> A(S/P); 
  ll pos, si=S.size();
  
  rep(i, S/P){
  	A.at(i)=P*(i+1);
    D=to_string(A.at(i));
    pos = S.find(D);
    while (pos != npos) {
        count++;
        pos = str.find(subStr, pos + si);
    }
  }
  
  cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:16: error: request for member 'size' in 'S', which is of non-class type 'll' {aka 'long long int'}
   27 |   ll pos, si=S.size();
      |                ^~~~
a.cc:32:13: error: request for member 'find' in 'S', which is of non-class type 'll' {aka 'long long int'}
   32 |     pos = S.find(D);
      |             ^~~~
a.cc:33:19: error: 'npos' was not declared in this scope; did you mean 'pos'?
   33 |     while (pos != npos) {
      |                   ^~~~
      |                   pos
a.cc:35:15: error: 'str' was not declared in this scope; did you mean 'std'?
   35 |         pos = str.find(subStr, pos + si);
      |               ^~~
      |               std
a.cc:35:24: error: 'subStr' was not declared in this scope
   35 |         pos = str.find(subStr, pos + si);
      |                        ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll mod;
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n>>mod;
    string s;cin>>s;
    if(gcd(mod,10)==1){
        vvi v(mod);
    vi t(n);
    ll sum=0;
    ll k=1,ans=0;
    for(ll i=n-1;i>=0;i--){
        sum+=(s[i]-'0')*k;
        k*=10;
        k%=mod;
        sum%=mod;
        v[sum].pb(n-1-i);
        t[n-1-i]=sum;
        if(sum==0)ans++;
    }
    rep(i,mod)ans+=(v[i].size()*(v[i].size()-1))/2;
    out(ans);
    }
    else{
    vvi v(mod);
    vi t(n);
    ll sum=0;
    rep(i,n){
        sum*=10;
        sum+=s[i]-'0';
        sum%=mod;
        v[sum].pb(i);
        t[i]=sum;
    }
    ll ans=0;
    rep(i,n){
        ans+=lb(v[t[i]],i);
        if(t[i]==0)ans++;
    }
    out(ans);
}

    }
}

Compiler output:
a.cc:75:1: error: expected declaration before '}' token
   75 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, p;
    ll dp10[300000], dpS[300000];
    ll kosu[10001];
    MEMSET(kosu, 0);
    string S;
    cin>>N>>p;
    cin>>S;
    dp10[0]=1; dpS[0]=(S[N-1]-'0')%p;
    //cout<<dpS[0]<<endl;
    rep(i, N){
        ll th=S[N-i-1]-'0';
        //cout<<th<<endl;
        if(i==0) continue;
        dp10[i]=(dp10[i-1]*10)%p;
        dpS[i]=(dpS[i-1]+th*dp10[i])%p;
        //cout<<dpS[i]<<sp<<dp10[i]<<endl;
    }
    rep(i, N){
        kosu[dpS[i]]++;
    }
    Bint count=0;
    rep(i, p){
        count+=(kosu[i]*(kosu[i]-1))/2;
        //cout<<i<<":"<<sp<<kosu[i]<<endl;
    }
    count+=kosu[0];
    cout<<count<<endl;
    return 0;
}


Compiler output:
a.cc:18:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory
   18 | #include <boost/multiprecision/cpp_dec_float.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int N, P;
string input;
int S[200003];
int MOD[2][10002];
int mm, mm2;

int main()
{
	cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(false);
	cin >> N >> P;
	cin >> input;
	long long ans = 0;
	bool f = 1;
	for (int i = 0; i < N; i++) S[i] = input[i] - 48;

	for (int i = 0; i < N; i++) {
		
		for (int j = 0; j < P; j++) {
			if (MOD[f][j]) {
				mm2 = (j * 10 + S[i]) % P;
				if (!mm2) {
					ans += MOD[f][j];
				}
				MOD[f ^ 1][mm2] += MOD[f][j];
			}
		}
		memset(MOD[f], 0, sizeof(MOD[f]));
		mm = S[i] % P;
		if (!mm) ans++;
		MOD[f ^ 1][mm]++;
		f ^= 1;
	}

	cout << ans << '\n';

}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: 'memset' was not declared in this scope
   32 |                 memset(MOD[f], 0, sizeof(MOD[f]));
      |                 ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define got(container,num) get<num-1>(container)
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m

using namespace std;
const int INF=LLONG_MAX-1e10;
const int maxn=1e6+1e5;
//const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int mo_num;
main()
{
    IOS
    cin>>n>>mo_num;
    string k;
    cin>>k;
    int base=1;
    int have=0;
    a[0]++;
    reverse(all(k));
    fa(i,k)
    {
        int val=i-'0';
        ans+=a[mod(mod((mod(val)*base)+have)];
        a[mod(mod((mod(val)*base)+have)]++;
        have=mod(mod((mod(val)*base)+have);
        base=mod(base*10);
    }
    out(ans)
    return 0;
}

Compiler output:
a.cc:73:2: error: unterminated argument list invoking macro "mod"
   73 | }
      |  ^
a.cc:53:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   53 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:66:16: error: 'mod' was not declared in this scope
   66 |         ans+=a[mod(mod((mod(val)*base)+have)];
      |                ^~~
a.cc:66:19: error: expected ']' at end of input
   66 |         ans+=a[mod(mod((mod(val)*base)+have)];
      |                   ^
      |                   ]
a.cc:66:19: error: expected '}' at end of input
a.cc:64:5: note: to match this '{'
   64 |     {
      |     ^
a.cc:66:19: error: expected '}' at end of input
   66 |         ans+=a[mod(mod((mod(val)*base)+have)];
      |                   ^
a.cc:54:1: note: to match this '{'
   54 | {
      | ^
Language: C++

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

int main() {
  int N, P;
  string S;
  cin >> N >> P >> S;
  
  int count = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i+1; j < N; j++) {
      string s = S.substr(i, j-i+1);
      for (int k = 0; k < s.size()-1; k++) {
        if (s.at(k) == '0') s = s.substr(1, s.size()-1);
        else break;
      }
      if (atoi(s)%P == 0) count++;
    }
  }
  cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   17 |       if (atoi(s)%P == 0) count++;
      |                ^
      |                |
      |                std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
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],Pcoset=1,tcoset=0;
    char c;
    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;
    }    
    sort(a,a+N);
    long int nn=0;
    for (int j=1;j<N;j++){
        if (a[j]!=a[j-1]){
            nn=nn+1;
        }
    }
    cout<<nn<<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);
      |     ^~~~
      |     short
Language: C++

n, p = map(int, input().split())
s = str(input())
ans = 0
np = len(str(p))
if p == 2:
    for i in range(n):
        if int(s[i]) % 2 == 0:
            ans += i + 1
elif p == 5:
    for i in range(n):
        if int(s[i]) % 5 == 0:
            ans += i + 1
elif np == 1:
    for i in range(np - 1, n - 1):
        for j in range(1, i - np + 1):
            if i == j == 0 or i == j - 1 == 0:
                print(int(s[0]) % p)
                if int(s[0]) % p == 0:
                    ans += 1
            elif int(s[j::i]) % p == 0:
                print(int(s[0]) % p)
                ans += 1
else:
    for i in range(np, n - 1):
        for j in range(0, i - np + 1):
            if int(s[j::i]) % p == 0:
                ans += 1
print(ans)


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, p = map(int, input().split())
      | ^
Language: C++

#include <iostream>
#include <map>
using namespace std;
long long pow(long long i, long long P);

long long main(void){
  long N,P;
  string _S;
  cin>>N>>P;
  cin>>_S;


  if(P==2 or P==5){
    long long retval=0;
    for(long long i=0;i<N;i++){
      if((_S[i]-'0')%P==0){
        retval+=(i+1);
      }
    }
    cout<<retval<<endl;
    return 0;
  }



  map<long long,long long>d;
  for(long long i=0;i<P;i++){
    d[i]=0;
  }
  d[0]=1;
  long long S=0;
  for(long long i=0;i<N;i++){
    S+=pow(i+1,P)*(_S[N-i-1]-'0');
    d[S%P]=d[S%P]+1;
  }
  long long retval=0;
  for(long long i=0;i<P;i++){
    if(d[i]>0){
      retval+=(d[i]-1)*d[i]/2;
    }
  }
  cout<<retval<<endl;
  return 0;
  return 0;
}

long long pow(long long i,long long P){
  if(i==0) return 1;
  else if(i%2==0){
    return (pow(i/2,P)*pow(i/2,P))%P;
  }
  else{
    return (10*pow(i-1,P))%P;
  }
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: Java


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();
    sc.close();

    BigInteger p = BigInteger.valueOf(P);
    long ans = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N + 1; j++) {
        BigInteger d = new BigInteger(S.substring(i, j));
        if (d.remainder(p).intValue() == 0) ans++;
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:4: error: cannot find symbol
    Scanner sc = new Scanner(System.in);
    ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
    Scanner sc = new Scanner(System.in);
                     ^
  symbol:   class Scanner
  location: class Main
Main.java:10: error: cannot find symbol
    BigInteger p = BigInteger.valueOf(P);
    ^
  symbol:   class BigInteger
  location: class Main
Main.java:10: error: cannot find symbol
    BigInteger p = BigInteger.valueOf(P);
                   ^
  symbol:   variable BigInteger
  location: class Main
Main.java:14: error: cannot find symbol
        BigInteger d = new BigInteger(S.substring(i, j));
        ^
  symbol:   class BigInteger
  location: class Main
Main.java:14: error: cannot find symbol
        BigInteger d = new BigInteger(S.substring(i, j));
                           ^
  symbol:   class BigInteger
  location: class Main
6 errors
Language: Java

vimport 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();
        int k = 0;
        String str = sc.next();
        if (P < 10) {
            for (int i = 0; i <= N; i++) {
                for (int j = 0; j <= N; j++) {
                    if (j <= i) {
                    } else {
                        long a = Integer.parseInt(str.substring(i, j));
                        if (a % P == 0) {
                            k = k + 1;
                        }

                    }
                }
            }
            System.out.println(k);
        } /*else if (9 < P || P < 100) {
            for (int i = 0; i <= N; i++) {
                for (int j = 0; j < N; j++) {
                    if (j <= i) {
                    } else {
                        long a = Integer.parseInt(str.substring(i, j + 1));
                        if (a % P == 0) {
                            k = k + 1;
                        }

                    }
                }
            }
            System.out.println(k);


        } else if (99 < P || P < 1000) {
            for (int i = 0; i <= N; i++) {
                for (int j = 0; j < N - 1; j++) {
                    if (j <= i) {
                    } else {
                        long a = Integer.parseInt(str.substring(i, j + 2));
                        if (a % P == 0) {
                            k = k + 1;
                        }

                    }
                }
            }
            System.out.println(k);
        } else if (999 < P || P <= 10000) {
            for (int i = 0; i <= N; i++) {
                for (int j = 0; j < N-2; j++) {
                    if (j <= i) {
                    } else {
                        long a = Integer.parseInt(str.substring(i, j + 3));
                        if (a % P == 0) {
                            k = k + 1;
                        }

                    }
                }
            }
            System.out.println(k);*/
        }

    }


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
vimport java.util.Scanner;
^
1 error