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

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

#define ll long long int
int main()
{
    ll x,y,i,j,k,p,q,n,m;

    cin>>n>>p;
    ll mark[p+1];
    memset(mark,0,sizeof mark);
    string str;
    cin>>str;

    if(__gcd(p,10ll) != 1){
        ll ans=0;+
        for(i=0;str[i];i++) if((str[i] - '0')%p==0) ans+=(i+1);
        cout<<ans<<'\n';
        return 0;
    }

    ll last=0;
    for(i=0;i<n;i++){
        ll x=(last*10ll + (str[i] - '0'));
        ll rem=x % p;
        ++mark[rem], last=rem;
    }

    ll ans=0;
    for(i=0;i<p;i++){
        if(!i){
            x=mark[i];
        }
        else x=mark[i]-1;
        if(x>0) ans+=(((x+1)*x)/2);
    }

    cout<<ans<<'\n';
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: expected primary-expression before 'for'
   17 |         for(i=0;str[i];i++) if((str[i] - '0')%p==0) ans+=(i+1);
      |         ^~~
a.cc:17:22: warning: ignoring return value of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   17 |         for(i=0;str[i];i++) if((str[i] - '0')%p==0) ans+=(i+1);
      |                      ^
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:1265:7: note: declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:17:27: error: expected ';' before ')' token
   17 |         for(i=0;str[i];i++) if((str[i] - '0')%p==0) ans+=(i+1);
      |                           ^
      |                           ;
Language: C++

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

int main() {
  int n,p;
  string s;
  cin >> n >> p >> s;
  ll ans;
  if (p == 2 || p == 5) {
    rep(i, n) {
      if (ctoi(s.at(n-i-1)) == 0) {
        ans += n - i;
      }
    }
  } else {
    map<int,int> MP;
    int num;
    rep(i,n) {
      num += (ctoi(s.at(n-i-1)) * 10 ** i) % p;
      num %= p;
      ans += map[num];
      if (num == 0) {
        ans++;
      }
      map[num] += 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'ctoi' was not declared in this scope; did you mean 'atoi'?
   13 |       if (ctoi(s.at(n-i-1)) == 0) {
      |           ^~~~
      |           atoi
a.cc:21:15: error: 'ctoi' was not declared in this scope; did you mean 'atoi'?
   21 |       num += (ctoi(s.at(n-i-1)) * 10 ** i) % p;
      |               ^~~~
      |               atoi
a.cc:21:39: error: invalid type argument of unary '*' (have 'int')
   21 |       num += (ctoi(s.at(n-i-1)) * 10 ** i) % p;
      |                                       ^~~
a.cc:23:17: error: missing template arguments before '[' token
   23 |       ans += map[num];
      |                 ^
a.cc:27:16: error: expected initializer before '+=' token
   27 |       map[num] += 1;
      |                ^~
a.cc:27:16: error: expected ';' before '+=' token
Language: C++

#include <bits/stdc++.h>

using namespace std;

unsigned long long ans = 0;

int n, p;
string s;

void dfs(int a, int idx, bool sw){

    // 割れるかどうか
    //printf("a(%d) idx(%d) sw(%d)\n", a, idx, sw);
    a %= p;
    if(a == 0 && sw) ++ans;
    //printf("adiv(%d)\n", a);

    if(idx == s.size()){
        return;
    }

    // とる場合
    dfs(a*10+(int(s[idx] - '0')), idx + 1, true);

    // とらない場合
    if(sw == false) dfs(0, idx + 1, sw); // これまで取っていないので0しかない
}

int main(){
    cin.tie(0);
    ios::sync_without_stdio(false);
    cin >> n >> p;
    cin.ignore();
    cin >> s;
    cin.ignore();

    dfs(0, 0, false);
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:10: error: 'sync_without_stdio' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
   31 |     ios::sync_without_stdio(false);
      |          ^~~~~~~~~~~~~~~~~~
Language: C++

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

int c[10005];
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(i=0;i<S.length();i++)if((S[i]-'0')%P==0)count+=(i+1);
    }
    else{
        for(i=0;i<S.length();i++){
            tmp=(tmp*10+(S[i]-'0'))%P;
            c[tmp]++;
        }
        count=c[0];
        for(i=0;i<P;i++)count+=c[i]*(c[i]-1)/2;
    }
    cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'i' was not declared in this scope
   14 |         for(i=0;i<S.length();i++)if((S[i]-'0')%P==0)count+=(i+1);
      |             ^
a.cc:17:13: error: 'i' was not declared in this scope
   17 |         for(i=0;i<S.length();i++){
      |             ^
a.cc:22:13: error: 'i' was not declared in this scope
   22 |         for(i=0;i<P;i++)count+=c[i]*(c[i]-1)/2;
      |             ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <map>
 
using namespace std;
 
typedef long long ll;
 
int mod;
int sub(int i, int j) { return ((i -= j) < 0 ? i += mod : i); }
int add(int i, int j) { return ((i += j) < mod ? i : i -= mod); }
int mult(int i, int j) { return (ll) i * j % mod; }
 
int A[200000];
int box[100000];
 
int main() {
    cin.tie(NULL) -> sync_with_stdio(false);
    int n; cin >> n >> mod;
    string line; cin >> line;
    reverse(line.begin(), line.end());
    for(char& c : line)
        c -= 48;
    
    if(mod == 2 || mod == 5) {
        ll mx = 0;
        for(int i = 0; i < n; ++i)
            if(line[i] % mod == 0)
                mx += n - i;
                
        cout << mx;
        return 0;
    }
     
    int r = 1;
    A[0] = line[0] % mod;
    for(int i = 1; i < n; ++i) {
        r = mult(r, 10);
        A[i] = add(mult(r, line[i]), A[i - 1]);
    }
    
    for(int i = 0; i < n; ++i)
        box[A[i]] += 1;
    
    int rx = 0;
    r = 1;
    ll res = box[0];
    for(int i = 0; i < p; ++i)
        res += (ll) box[i] * (box[i] - 1) / 2;
    
    cout << res;
    return 0;
}

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

        int s = atoi(S.substr(i, 1).c_str());
        int m = (s * pow10 + curr) % P;
        if (residual.count(m) == 0) {
            residual.insert(make_pair(m, 0LL));
        }
        residual[m] += 1;
        curr = m;


Compiler output:
a.cc:1:22: error: 'S' was not declared in this scope
    1 |         int s = atoi(S.substr(i, 1).c_str());
      |                      ^
a.cc:1:31: error: 'i' was not declared in this scope
    1 |         int s = atoi(S.substr(i, 1).c_str());
      |                               ^
a.cc:1:17: error: 'atoi' was not declared in this scope
    1 |         int s = atoi(S.substr(i, 1).c_str());
      |                 ^~~~
a.cc:2:22: error: 'pow10' was not declared in this scope
    2 |         int m = (s * pow10 + curr) % P;
      |                      ^~~~~
a.cc:2:30: error: 'curr' was not declared in this scope
    2 |         int m = (s * pow10 + curr) % P;
      |                              ^~~~
a.cc:2:38: error: 'P' was not declared in this scope
    2 |         int m = (s * pow10 + curr) % P;
      |                                      ^
a.cc:3:9: error: expected unqualified-id before 'if'
    3 |         if (residual.count(m) == 0) {
      |         ^~
a.cc:6:9: error: 'residual' does not name a type
    6 |         residual[m] += 1;
      |         ^~~~~~~~
a.cc:7:9: error: 'curr' does not name a type
    7 |         curr = m;
      |         ^~~~
Language: C

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

typedef pair<int, int> P;
ll modnum = 1e9+7;

const int MAX_N = 2*1e5+5;

ll dp[MAX_N][100];

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    rep(i, MAX_N) rep(j, 100) dp[i][j] = 0;

    reverse(s.begin(), s.end());


    // 10と素でない素数
    ll ans = 0;
    if(p == 2 || p == 5) {
        rep(i, n) {
            int now = s[i]-'0';
            if(now%p == 0) ans += n-i;
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> sum(n+1, 0);
    rep(i, n) {
        ll now = s[i]-'0';
        now *= modpow(10, i, p);
        now %= p;
        sum[i+1] = sum[i] + now;
        sum[i+1] %= p;
    }
    map<int, int> mp;
    rep(i, n+1) {
        mp[sum[i]]++;
    }

    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second > 1) ans += (itr->second)*(itr->second-1)/2;
    }

    cout << ans << endl;

    return 0;
}

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

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll main(){
    ll n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    ll ans=0;
    reverse(s.begin(),s.end());
    if(p==2){
        for(ll i=0;i<n;i++){
            if((s[i]-'0')%2==0){
                ans += n-i;
            }
        }
    }else if(p==5){
        for(ll i=0;i<n;i++){
            if((s[i]-'0')%5==0){
                ans += n-i;
            }
        }
    }else{
        ll k = 1;
        vector<ll> a(n);
        for(ll i=0;i<n;i++){
            a[i] = (s[i]-'0')*k%p;
            k = k*10%p;
        }
        vector<ll> cum(n+1);
        cum[0] = 0;
        for(ll i=0;i<n;i++){
            cum[i+1] = (cum[i] + a[i])%p;
        }
        vector<ll> t(p);
        for(ll i=0;i<=n;i++){
            t[cum[i]]++;
        }
        for(ll i=0;i<p;i++){
            ans += (ll)t[i]*(t[i]-1)/2;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc:21:1: error: '::main' must return 'int'
   21 | ll main(){
      | ^~
Language: Java

import java.util.*;
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 res = 0;
      if(p == 2 || p == 5) {
          for(int i = s.length() - 1; i >= 0; i--) {
            if(s.charAt(i) == '0' || (s.charAt(i) - '0') % p == 0)
                res += (i + 1);
          }
          return res;
      }
      Map<Integer, Integer> prefixCnt = new HashMap<>();
      prefixCnt.put(0, 1);
      int fac = 1; 
      int cur = 0;
      
      for(int i = s.length() - 1; i >= 0; i--) {
        cur = (cur + (s.charAt(i) - '0') * fac) % p;
        fac = (fac * 10) % p;
        if(prefixCnt.containsKey(cur)) {
          res += prefixCnt.get(cur);
          prefixCnt.put(cur, prefixCnt.get(cur) + 1);
        } else
          prefixCnt.put(cur, 1);
      }
      System.out.println(res);
  }
}

Compiler output:
Main.java:15: error: incompatible types: unexpected return value
          return res;
                 ^
1 error
Language: C++

/**********************************************************************
File    .cpp
Author  Takahiro Yamazaki
**********************************************************************/
/**********************************************************************
Include Libraries
**********************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)
/**********************************************************************
Declare variables
**********************************************************************/
/**********************************************************************
Declare instance
**********************************************************************/
/**********************************************************************
Proto_type_Declare functions
**********************************************************************/

/**********************************************************************
Main
**********************************************************************/
int main() {
  ll ans = 0;
  ll n,p;
  cin >> n >> p;
  string s;
  cin >> s;
  reverse(s.begin(), s.end());

  map<ll, ll> mp;
  mp[0] = 1;
  ll now = 0, sum = 0, ten = 1,a,b;
  if (p == 2 || p == 5) {
    each(e,s){
      if ((e - '0')%p == 0) {
        ans++;
      }
    }
    cout << ans << '\n';
    return 0;
  }
  each(e, s) {
    b = ((e - '0') * ten) % p;
    now = (now + b) % p;
    ten *= 10;
    ten %= p;
    mp[now]++;
  }
  ll ans = 0;
  each(e, mp) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << '\n';
  return 0;

}
/**********************************************************************
Functions
**********************************************************************/


Compiler output:
a.cc: In function 'int main()':
a.cc:59:6: error: redeclaration of 'll ans'
   59 |   ll ans = 0;
      |      ^~~
a.cc:33:6: note: 'll ans' previously declared here
   33 |   ll ans = 0;
      |      ^~~
Language: C++

a,b= map(int, input().split())
n = int(input())
countArray = [0] * b
count = 0
countArray[0] += 0
nums = 0


for i in range(a):
    nums = nums + int(str(n)[a-1-i])*pow(10,i,b)
    countArray[nums % b] += 1
    if nums % b == 0:
        count +=1

for i in countArray:
    count += (i * (i - 1)) // 2
print(count)

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

N, P = map(int, input().split())
S = input()

# do shakutori
#以下が an mod p を求めるソースコードです.
def power_func(a, n, p):
    res = 1 #これは答え
    while n > 0:
        if n & 1:
            res = res * a % p
        a = a * a % p #1が立っているかどうかに関わらず次のaの累乗を用意しておく
        n = n >> 1
    return res

Q = [0]
for i in range(len(S)-1, -1, -1):
    pow = len(S) - i - 1
    Q.append((Q[-1] + power_func(10, pow, P) * int(S[i])) % P)
# print(Q)

import collections
dct = dict(collections.Counter(Q))
# print(dct)
ans = 0
for val in dct.values():
    ans += val * (val - 1) // 2
print(ans)



Compiler output:
a.cc:4:3: error: invalid preprocessing directive #do
    4 | # do shakutori
      |   ^~
a.cc:5:2: error: invalid preprocessing directive #\U00004ee5\U00004e0b\U0000304c
    5 | #以下が an mod p を求めるソースコードです.
      |  ^~~~~~
a.cc:7:13: error: stray '#' in program
    7 |     res = 1 #これは答え
      |             ^
a.cc:11:23: error: stray '#' in program
   11 |         a = a * a % p #1が立っているかどうかに関わらず次のaの累乗を用意しておく
      |                       ^
a.cc:19:3: error: invalid preprocessing directive #print
   19 | # print(Q)
      |   ^~~~~
a.cc:23:3: error: invalid preprocessing directive #print
   23 | # print(dct)
      |   ^~~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N, P = map(int, input().split())
      | ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	long long n, p;
	string s;
	long long ans = 0;
	cin >> n >> p >> s;
	if (p == 2) {
		for (long long i = 0; i < n; i++) {
			if (int(s[i] - '0') % 2 == 0) {
				ans += i + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}
	if (p == 5) {
		for (long long i = 0; i < n; i++) {
			if (int(s[i] - '0') % 5 == 0) {
				ans += i + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}
	long long co[10000] = { 0 };
	long long sum = 0;
	for (int i = n - 1; i >= 0; i--) {
		long long c = long long(s[i] - '0');
		long long x = n - i - 1;
		long long a = 10;
		while (x > 0) {
			if ((x & 1) == 1) {
				c = c * a % p;
			}
			a = a * a % p;
			x >>= 1;
		}
		sum = (sum + c) % p;
		co[sum % p]++;
	}
	co[0]++;
	for (int j = 0; j < 10000; j++) {
		ans += co[j] * (co[j] - 1) / 2;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:31: error: expected primary-expression before 'long'
   43 |                 long long c = long long(s[i] - '0');
      |                               ^~~~
Language: C++

n, p = map(int, input().split())
s = list(map(int, list(input())))[::-1]

sum = 0
cnt = [0] * p
cnt[0] = 1
n = len(s)
for i in range(n):
    d = s[i] * pow(10, i, p)
    sum = (sum + d) % p
    cnt[sum] += 1

ans = 0
if p in [2, 5]:
    if p == 2:
        ok_list = [0, 2, 4, 6, 8]
    if p == 5:
        ok_list = [0, 5]

    for i in range(n):
        d = s[i]
        if d in ok_list:
            ans += n - i
           
else:
    for i in range(p):
        ans += cnt[i] * (cnt[i]-1) // 2


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 <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
  ll n, p;
  cin >> n >> p;
  string s;
  cin >> s;

  if (p == 2 || p == 5)
  {
    ll ans = 0;
    for (ll i = s.size() - 1; i >= 0; i--)
    {
      ll digit = s.at(i) - '0';
      if (digit % p == 0)
      {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  reverse(s.begin(), s.end());
  vector<ll> acc = {};
  map<ll, ll> cnts = {};
  cnts[0] = 1; // 範囲外を選択する場合を考慮

  ll d = 1;
  for (ll i = 0; i < s.size(); i++)
  {
    ll digit = s.at(i) - '0';
    if (i == 0)
    {
      ll val = digit % p;
      acc.push_back(val);
      if (cnts.count(val) > 0)
        cnts[val]++;
      else
        cnts[val] = 1;

      d *= 10;
      d %= p;

      continue;
    }
    else
    {
      ll val = d * digit + acc[i - 1];
      val %= p;
      acc.push_back(val);
      if (cnts.count(val) > 0)
        cnts[val]++;
      else
        cnts[val] = 1;

      d *= 10;
      d %= p;
    }
  }

  ll ans = 0;
  for (ll x : cnts)
  {
    if (x.second > 0)
    {
      ans += x.second * (x.second - 1) / 2;
    }
  }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:67:15: error: cannot convert 'std::pair<const long long int, long long int>' to 'll' {aka 'long long int'} in initialization
   67 |   for (ll x : cnts)
      |               ^~~~
a.cc:69:11: error: request for member 'second' in 'x', which is of non-class type 'll' {aka 'long long int'}
   69 |     if (x.second > 0)
      |           ^~~~~~
a.cc:71:16: error: request for member 'second' in 'x', which is of non-class type 'll' {aka 'long long int'}
   71 |       ans += x.second * (x.second - 1) / 2;
      |                ^~~~~~
a.cc:71:28: error: request for member 'second' in 'x', which is of non-class type 'll' {aka 'long long int'}
   71 |       ans += x.second * (x.second - 1) / 2;
      |                            ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, p; cini >> n >> p;
  string s; cin >> s;
  v1i v(n+1, 0), u(p-1, 1);
  rep(i, p-2){
    u[i+1] = u[i]*10;
    u[i+1] %= p;
  }
  rrep(i, n){
    v[i] = v[i+1] + u[(n-i-1)%(p-1)]*(s[i]-'0');
    v[i] %= p;
  }
  map<int, lint> m;
  rep(i, n+1) m[v[i]]++;
  lint a = 0;
  rep(i, p) a += m[i] * (m[i]-1) / 2;
  cout << a << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:13: error: 'cini' was not declared in this scope
   31 |   int n, p; cini >> n >> p;
      |             ^~~~
Language: C++

#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

	int N, P;
	string S;
	cin >> N >> P >> S;
	int ans = 0;
	if(P == 2){
		rep(i,N){
			if(S[i] == '0' || S[i] == '2' || S[i] == '4' || S[i] == '6' || S[i] == '8') ans += i+1;
		}
	}
	else if(P == 5){
		rep(i,N){
			if(s[i] == '0' || s[i] == '5') ans += i+1;
		}
	}
	else{
		map<int, int> mp{};
		int num = 0, kai = 1;
		mp[0]++;
		for(int i=N-1;i>=0;i--){
			num += (S[i]-'0') * kai;
			num %= P;
			mp[num]++;
			kai = (kai * 10) % P;
		}
		for(auto p : mp){
			int n = p.second;
			ans += n * (n-1) / 2;
		}
	}
	cout << ans <<endl;
}

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

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

#define int long long

signed 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 (int(s[i] - '0') % p == 0)
				ans += i + 1;
		}
		cout << ans << '\n';
	}
	else {
		vector < int > pref(n + 1, 0);
		map < int, int > prefs;
		prefs[0] = 1;
		for (int i = 0; i < n; ++i) {
			pref[i + 1] = (pref[i] * 10 + int(s[i] - '0')) % p;
			++prefs[suff[i]];
		}
		long long ans = 0;
		for (auto pr: prefs) 
			ans += (((long long) pr.second) * (((long long) pr.second) - 1LL)) / 2;
		cout << ans << '\n';
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
a.cc:14:29: note: in expansion of macro 'int'
   14 |                         if (int(s[i] - '0') % p == 0)
      |                             ^~~
a.cc:14:29: error: expected ')' before 'long'
   14 |                         if (int(s[i] - '0') % p == 0)
      |                            ~^
      |                             )
a.cc:4:13: error: expected primary-expression before 'long'
    4 | #define int long long
      |             ^~~~
a.cc:24:55: note: in expansion of macro 'int'
   24 |                         pref[i + 1] = (pref[i] * 10 + int(s[i] - '0')) % p;
      |                                                       ^~~
a.cc:24:54: error: expected ')' before 'long'
   24 |                         pref[i + 1] = (pref[i] * 10 + int(s[i] - '0')) % p;
      |                                       ~              ^
      |                                                      )
a.cc:25:33: error: 'suff' was not declared in this scope
   25 |                         ++prefs[suff[i]];
      |                                 ^~~~
Language: C++

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

int main(){
  int i,N,P;
  cin >> N >> P;
  vector<int> S(N);
  for(i=0; i<N; i++){
    scanf("%1d",&S[i]);
  }
  long long ans=0;
  if(P == 2 || P == 5){
    for(i=0; i<N; i++){
      if(ans[i]%P == 0) ans += i+1;
    }
    cout << ans;
  }
  else{
    vector<long long> ret(P,0);
    vector<int> digit_ret(N);
    long long tmp=1;
    for(i=0; i<N; i++){
      digit_ret[i] = tmp;
      tmp = (tmp*10)%P;
    }
    tmp = 0;
    for(i=N-1; i>=0; i--){
      tmp = (tmp + S[i]*digit_ret[N-i-1])%P;
      ret[tmp]++;
    }
    for(i=0; i<P; i++){
      tmp = ret[i];
      ans += tmp*(tmp-1)/2;
    }
    cout << ans+ret[0];
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: invalid types 'long long int[int]' for array subscript
   14 |       if(ans[i]%P == 0) ans += i+1;
      |             ^
Language: C++

#include <iostream>
#include <map>
using namespace std;

void print(map<long long, long long> mp){
    map<long long, long long>::iterator it;
    int sum=0;
    for(it=mp.begin();it!=mp.end();it++){
        sum+=*it.second*(*it.second-1)/2;
    }
    cout << sum << endl;
}

int main(){
    long long n, a, sum=0;
    cin >> n;
    map<long long, long long> mp;
    mp[sum]++;
    for(int i=1;i<=n;i++){
        cin >> a;
        sum+=a;
        mp[sum]++;
    }
    print(mp);
    return 0;
}

Compiler output:
a.cc: In function 'void print(std::map<long long int, long long int>)':
a.cc:9:18: error: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} has no member named 'second'
    9 |         sum+=*it.second*(*it.second-1)/2;
      |                  ^~~~~~
a.cc:9:30: error: 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} has no member named 'second'
    9 |         sum+=*it.second*(*it.second-1)/2;
      |                              ^~~~~~
Language: C++

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

long long N;
string S;
int P;

long long solve(){
    if(P==2||P==5){
        long long res=0;
        for(int i=0;i<N;i++) if((S[N-i-1]-'0')%P==0) res+=N-i
        return res;
    }
    vector<long long> val(P, 0);
    long long tenfactor=1;
    long long cur=0;
    valu[cur]++;

    for(int i=0;i<N;i++){
        cur=(cur+(S[N-i-1]-'0')*tenfactor)%P;
        tenfactor=(tenfactor*10)%P;
        val[cur]++;
    }
    long long res=0;
    for(int p=0;p<P;p++) res+=val[p]*(val[p]-1)/2;
    return res;
}

int main(){
    cin >> N >> P >> S;
    cout << solve() << endl;
}


Compiler output:
a.cc: In function 'long long int solve()':
a.cc:11:62: error: expected ';' before 'return'
   11 |         for(int i=0;i<N;i++) if((S[N-i-1]-'0')%P==0) res+=N-i
      |                                                              ^
      |                                                              ;
   12 |         return res;
      |         ~~~~~~                                                
a.cc:17:5: error: 'valu' was not declared in this scope; did you mean 'val'?
   17 |     valu[cur]++;
      |     ^~~~
      |     val
Language: C++

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

int main() {
  int N, P, s = 0;
  cin >> N >> P >> S;
  char S[N];
  scanf("%s", &S);
  vector<int> s(N+1), t(N);
  for(int i=0;i<N;i++) {
    t(i) = stoi(S[i]);
    for(int j=0;j<i;j++)
      s(i+1) += t(j) * (int)pow(10, j);
  }
  for(int i=1;i<=N;i++) {
    for(int j=0;j<i;j++) {
      if((s(i)-s(j))/(int)pow(10,j)%P == 0)
        s++;
    }
  }
  cout << s << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:20: error: 'S' was not declared in this scope
    6 |   cin >> N >> P >> S;
      |                    ^
a.cc:9:15: error: conflicting declaration 'std::vector<int> s'
    9 |   vector<int> s(N+1), t(N);
      |               ^
a.cc:5:13: note: previous declaration as 'int s'
    5 |   int N, P, s = 0;
      |             ^
a.cc:11:6: error: no match for call to '(std::vector<int>) (int&)'
   11 |     t(i) = stoi(S[i]);
      |     ~^~~
a.cc:13:8: error: 's' cannot be used as a function
   13 |       s(i+1) += t(j) * (int)pow(10, j);
      |       ~^~~~~
a.cc:13:18: error: no match for call to '(std::vector<int>) (int&)'
   13 |       s(i+1) += t(j) * (int)pow(10, j);
      |                 ~^~~
a.cc:17:12: error: 's' cannot be used as a function
   17 |       if((s(i)-s(j))/(int)pow(10,j)%P == 0)
      |           ~^~~
a.cc:17:17: error: 's' cannot be used as a function
   17 |       if((s(i)-s(j))/(int)pow(10,j)%P == 0)
      |                ~^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#include "../Algo/NumberTheory/modulo.h"


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, p;
    cin >> n >> p;
    ModuloOps mod(p);
    string s;
    cin >> s;
    long long ans = 0;
    if (p == 2 || p == 5) {
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0) {
                ans += i+1;
            }
        }
    } else {
        vector<int> cnt(p);
        cnt[0] = 1;
        auto inv10 = mod.inv(10);
        long long mul = 1;
        long long cur = 0;
        for (int i = 0; i < n; i++) {
            cur = mod.add(10*cur, s[i] - '0');
            auto need = mod.mul(mul, cur);
            ans += cnt[need];
            cnt[need]++;
            mul = mod.mul(mul, inv10);
        }
    }
    cout << ans << endl;
}



Compiler output:
a.cc:5:10: fatal error: ../Algo/NumberTheory/modulo.h: No such file or directory
    5 | #include "../Algo/NumberTheory/modulo.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,p;
    cin>>n>>p;
    string s; cin>>s;
    if(p == 2 || p == 5) return 3/0
    REV(s);
    ll tmp  = 0;
    map<ll,ll> mp;
    ll ans = 0;
    mp[0]++;
    ll ten = 1;
    FOR(i,0,n){
        tmp += ten*(s[i] - '0');
        tmp%=p;
        ans += mp[tmp];
        mp[tmp]++;
        ten *= 10;
        ten%=p;
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:34: warning: division by zero [-Wdiv-by-zero]
   27 |     if(p == 2 || p == 5) return 3/0
      |                                 ~^~
a.cc:27:36: error: expected ';' before 'reverse'
   27 |     if(p == 2 || p == 5) return 3/0
      |                                    ^
      |                                    ;
Language: C++

#include <iostream>
#include <vector>
#include <string>

int main()
{
  int N, P;
  std::string S;
  std::cin >> N >> P >> S;
  std::vector<int> modP(P, 0);

  long long tmp, ans = 0, now = 0, dig10 = 1;
  if (P == 2 || P == 5)
  {
    for (int i = S.size()-1; i >= 0; i--)
    {
      now = S[i] - '0'
      if (now % P == 0) ans += i+1;
    }
  }
  else
  {
    for (int i = S.size()-1; i >= 0; i--)
    {
      tmp = (S[i] - '0') * dig10;
      now += tmp;
      now %= P;
      modP.at(now)++;
      ans += modP.at(now);
      dig10 *= 10;
      dig10 %= P;
    }
  }
  std::cout << ans << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:23: error: expected ';' before 'if'
   17 |       now = S[i] - '0'
      |                       ^
      |                       ;
   18 |       if (now % P == 0) ans += i+1;
      |       ~~
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<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int a,b;
  cin >> a >> b;
  string st;
  cin >> st;
  int c=0;
  vector<int> s(a);
  rep(i,n) s[i]=st[i]-'0';
  map<int,int> mp;
  int ans=0;
  if(b==2) {
      rep(i,a) {
          if(s[i]%2==0) {
              if(i==0) ans++;
              else ans+=i+1;
          }
      }
      pt(ans);
      return 0;
  }
  if(b==5) {
      rep(i,a) {
          if(s[i]==0 || s[i]==5) {
              if(i==0) ans++;
              else ans+=i+1;
          }
      }
      pt(ans);
      return 0;
  }
  if(b==10) {
      rep(i,a) {
          if(s[i]==0) {
              if(i==0) ans++;
              else ans+=i+1;
          }
      }
      pt(ans);
      return 0;
  }
  rep(i,a) {
      c+=a[i]*pow(10,i);
      mp[c%b]++;
  }
  rep(i,b) {
      int d=mp[i];
      if(d==0) ans+=mp[i];
      if(mp[i]>1) ans+=mp[i]*(mp[i]-1);
  }
  pt(ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'n' was not declared in this scope
   23 |   rep(i,n) s[i]=st[i]-'0';
      |         ^
a.cc:3:39: note: in definition of macro 'rep'
    3 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |                                       ^
a.cc:57:11: error: invalid types 'int[int]' for array subscript
   57 |       c+=a[i]*pow(10,i);
      |           ^
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<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  int c=0;
  map<int,int> mp;
  int ans=0;
  if(b==2) {
      rep(i,a) {
          if(s[i]%2==0) {
              if(i==0) ans++;
              else ans+=i+1;
          }
      }
      pt(ans);
      return 0;
  }
  if(b==5) {
      rep(i,a) {
          if(s[i]==0 || s[i]==5) {
              if(i==0) ans++;
              else ans+=i+1;
          }
      }
      pt(ans);
      return 0;
  }
  if(b==10) {
      rep(i,a) {
          if(s[i]==0) {
              if(i==0) ans++;
              else ans+=i+1;
          }
      }
      pt(ans);
      return 0;
  }
  rep(i,a) {
      c+=a[i]*pow(10,i);
      mp[c%b]++;
  }
  rep(i,b) {
      int d=mp[i];
      if(d==0) ans+=mp[i];
      if(mp[i]>1) ans+=mp[i]*(mp[i]-1);
  }
  pt(ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:11: error: invalid types 'int[int]' for array subscript
   55 |       c+=a[i]*pow(10,i);
      |           ^
Language: C++

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

int main() {
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    if (10%p == 0) {
        ll ans = 0;
        rep(r, n) {
            if ((s[r]-'0') % p == 0){
                ans += r+1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> d(n+1);
    int ten = 1;
    for (int i = n-1; i >=0; --i){
        int a = (s[i]-'0') * ten % p;
        d[i] = (d[i+1]+a) % p;
        ten *= 10; ten %= p;
    }
    vector<int> cnt(p):
    for (int i = n; i >= 0; --i){
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'll' was not declared in this scope
   11 |         ll ans = 0;
      |         ^~
a.cc:14:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |                 ans += r+1;
      |                 ^~~
      |                 abs
a.cc:17:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |         cout << ans << endl;
      |                 ^~~
      |                 abs
a.cc:28:23: error: expected ',' or ';' before ':' token
   28 |     vector<int> cnt(p):
      |                       ^
a.cc:29:21: error: 'i' was not declared in this scope
   29 |     for (int i = n; i >= 0; --i){
      |                     ^
a.cc:33:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<stack>
#include<list>
#include<set>

using namespace std;

#define DEBUG_FLAG

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#ifdef DEBUG_FLAG
    #define dbgout(fmt, ...) fprintf(stderr, "\033[1;33mDEBUG(%s:%d):\t\033[0m" fmt, __func__, __LINE__, ##__VA_ARGS__)
#else
    #define dbgout(fmt, ...) 
#endif

int modRess[10001];

int main(void)
{
    int N, P;
    scanf("%d%d", &N, &P);
    char str[N+10];
    int ans = 0, base = 1, modr = 0;
    scanf("%s", str);
    modRess[0] = 1;
    if (P == 2 || P == 5) {
        for(int i=0; i < N; i++)
		    if((str[i]-'0') % P == 0) ans+=(i+1);
        }
    } else {
        for (int i = N-1; i >= 0; i--) {
            modr += (str[i] - '0') * base;
            modr %= P;
            ans += modRess[modr];
            modRess[modr]++;
            base *= 10;
            base %= P;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Compiler output:
a.cc:38:7: error: expected unqualified-id before 'else'
   38 |     } else {
      |       ^~~~
a.cc:49:11: error: expected constructor, destructor, or type conversion before '(' token
   49 |     printf("%d\n", ans);
      |           ^
a.cc:50:5: error: expected unqualified-id before 'return'
   50 |     return 0;
      |     ^~~~~~
a.cc:51:1: error: expected declaration before '}' token
   51 | }
      | ^
Language: C++

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

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

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

	// 各桁の数値のMODをとる
	vector<int> d(N+1);
	int ten = 1;
	for (int i = N - 1; i >= 0; i--) {
		int num = (S[i] - '0') * ten;
		d[i] = num % P;
		ten *= 10;
		ten %= P;
	}

	// 累積和をとる
	for (int i = N - 1; i >= 0; i--) {
		d[i] += d[i+1];
		d[i] %= P;
	}

	int ans = 0;
	map<int, int> mp;
	mp[0] = 1;
	for (int i = N - 1; i >= 0; i--) {
		ans += mp[d[i]];
		mp[d[i]]++;
	}

	cout << ans << endl;
}

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

#include <stdio.h>
#include <map>
using namespace std;
char txt[200001];
int dp[2][10001];
map<int,int> mdp[2];
int main(){
	int N,P;scanf("%d %d\n",&N,&P);
	scanf("%s",txt);
	long long sum = 0;
	if(P<400){
		for(int i=0;i<N;i++){
		int nxt = i%2;
		int cnt=1-i%2;
		int d = txt[i]-'0';
		for(int j=0;j<P;j++) dp[nxt][j]=0;
		for(int j=0;j<P;j++){
			dp[nxt][(10*j+d)%P]+=dp[cnt][j];
		}
		dp[nxt][d%P]++;
		sum += dp[nxt][0];
		}
		printf("%lld",sum);
	}
	else{
		for(int i=0;i<N;i++){
		int nxt = i%2;
		int cnt=1-i%2;
		int d = txt[i]-'0';
		mdp[nxt].clear();
		for(auto it = mdp[cnt].begin();it!=mdp[cnt].end();++it){
			auto j = it->first;
			auto x = it->second;
			\mdp[nxt][(10*j+d)%P]+=x;
		}
		mdp[nxt][d%P]++;
		sum += mdp[nxt][0];
		printf("%lld\n",sum);
		}
		printf("%lld",sum);
	}
}

Compiler output:
a.cc:34:25: error: stray '\' in program
   34 |                         \mdp[nxt][(10*j+d)%P]+=x;
      |                         ^
Language: C++

#include <stdio.h>
#include <map>
using namespace std;
char txt[200001];
int dp[2][10001];
map<int,int> mdp[2];
int main(){
	int N,P;scanf("%d %d\n",&N,&P);
	scanf("%s",txt);
	long long sum = 0;
	if(P<400){
		for(int i=0;i<N;i++){
		int nxt = i%2;
		int cnt=1-i%2;
		int d = txt[i]-'0';
		for(int j=0;j<P;j++) dp[nxt][j]=0;
		for(int j=0;j<P;j++){
			dp[nxt][(10*j+d)%P]+=dp[cnt][j];
		}
		dp[nxt][d%P]++;
		sum += dp[nxt][0];
		}
		printf("%lld",sum);
	}
	else{
		for(int i=0;i<N;i++){
		int nxt = i%2;
		int cnt=1-i%2;
		int d = txt[i]-'0';
		mdp[nxt].clear();
		for(auto it = mdp.begin();it!=mdp.end();++it){
			auto j = it->first;
			auto x = it->second;
			mdp[nxt][(10*j+d)%P]+=x;
		}
		dp[nxt][d%P]++;
		sum += dp[nxt][0];
		}
		printf("%lld",sum);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:35: error: request for member 'begin' in 'mdp', which is of non-class type 'std::map<int, int> [2]'
   31 |                 for(auto it = mdp.begin();it!=mdp.end();++it){
      |                                   ^~~~~
a.cc:31:51: error: request for member 'end' in 'mdp', which is of non-class type 'std::map<int, int> [2]'
   31 |                 for(auto it = mdp.begin();it!=mdp.end();++it){
      |                                                   ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, p;
  string s;
  
  int num, count;
  
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j <= n - i; j++) {
      num = stoi(substr(i, j));
      cout << num << endl;
    }
  }
  return 0;
}
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: 'substr' was not declared in this scope; did you mean 'strstr'?
   13 |       num = stoi(substr(i, j));
      |                  ^~~~~~
      |                  strstr
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using ll =long long;
using namespace std;


int main(){
	int n, k,q,ans=0;
	cin >> n >> k >>q;
	
	auto f = [&](int query,int num) {
		rep(i,num){ 
			if (query % k == 0)ans++;
			query /= 10;
		}
	};
	
	rep(i,n-1){
		f(q,n-i);
		int a = pow(10, n - 1 - i);
		while (q > a)q -= a;
	}
	f(q,1);
	cout << ans << endl;
	
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: 'pow' was not declared in this scope
   26 |                 int a = pow(10, n - 1 - i);
      |                         ^~~
Language: C++

/// hi_im_manh :D
#include <bits/stdc++.h>
#define reset(a,n) memset(a,0,(n+1)*sizeof(int))
#define endl "\n"
#define llmin LLONG_MIN
#define llmax LLONG_MAX
#define intmax INT_MAX
#define intmin INT_MIN
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define duckman "TASK"

#define input freopen(duckman".inp", "r", stdin);
#define output freopen(duckman".out", "w", stdout);

#define nmax 22000
using namespace std;


int main()
{
    fast;
//    input;
//    output;

    ll n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if (p == 2) {
        for (ll i = 0; i < n; ++i) {
            if (s[i] == '0' || s[i] == '2') {
                ans += i+1;
            }
        }
    }
    else if (p == 5) {
        for (ll i = 0; i < n; ++i) {
            if (s[i] == '0' || s[i] == '5') {
                ans += i+1;
            }
        }
    }
    else {
        ll a[p] = {0};
        a[0] = 1;
        ll num = 0, tens = 1;
        for (ll i = n-1; ~i; --i) {
            num = (num+(s[i]-'0')*tens)%p;
            ans += a[num];
            ++ans[num];
            tens = (tens*10)%p;
        }
    }
    cout << ans;
    return 0;
}
/*

*/


Compiler output:
a.cc: In function 'int main()':
a.cc:52:18: error: invalid types 'long long int[long long int]' for array subscript
   52 |             ++ans[num];
      |                  ^
Language: C++

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

#define int long long

int n, p;
ll val[10101];
string s;

int main()
{
    cin >> n >> p >> s;
    if(p == 2 || p == 5)
    {
        ll res = 0;
        rep(i, n)
        {
            if((s[i] - '0') % p == 0)
            {
                res += (long)(i + 1);
            }
        }
        cout << res << endl;
        return 0;
    }

    int sum = 0, cur = 1;
    for (int i = n - 1; i >= 0; i--)
    {
        sum += (cur * (s[i] - '0'));
        sum %= p;
        val[sum]++;
        cur *= 10;
        cur %= p;
    }

    int res = val[0];
    rep(i, p)
    {
        res += (long)((val[i] * (val[i] - 1)) / 2);
    }
    cout << res << endl;

    
    return 0;
}

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

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if( m==0 || n==m){
		return 1;
	}
	if(n<m || n<=0 || m<0){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


//


////////////////////////////////////////////////////////////////////




int main() {
ll n,p;
cin>>n>>p;
string s;
cin>>s;

ll d[n+2];
for(ll i=1;i<=n;i++){
    char l=s[i-1];
    d[i]=(ll)(l-'0');
}

for(int i=1;i<=n;i++){
    d[i]%=p;
}

ll ans=0;


if(p==2){
    for(ll i=1;i<=n;i++){
        if(d[i]%2==0){
ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

if(p==5){
    for(ll i=1;i<=n;i++){
        if(d[i]%5==0){
ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


ll now=1;
for(ll i=1;i<=n;i++){
if(i>=2){
    now*=10;
    now%=p;
}
d[n+1-i]*=now;
d[n+1-i]%=p;
}

d[n+1]=0;
for(ll i=n;i>=1;i--){
    d[i]=d[i]+d[i+1];
    d[i]%=p;
}

ll rem[p];

for(int i=0;i<p;i++){
    rem[i]=0;
}

for(int i=1;i<=n+1;i++){
    rem[d[i]]++;
}

ans=0;

for(int i=0;i<p;i++){
if(rem[i]<=1{continue;}
ll val=rem[i]*(rem[i]-1)/2;
ans+=val;
}

cout<<ans<<endl;
return 0;



}



Compiler output:
a.cc: In function 'int main()':
a.cc:164:13: error: expected ';' before '{' token
  164 | if(rem[i]<=1{continue;}
      |             ^
      |             ;
a.cc:165:27: error: expected ')' before ';' token
  165 | ll val=rem[i]*(rem[i]-1)/2;
      |                           ^
      |                           )
a.cc:164:3: note: to match this '('
  164 | if(rem[i]<=1{continue;}
      |   ^
a.cc:166:6: error: 'val' was not declared in this scope
  166 | ans+=val;
      |      ^~~