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

#include<cstdio>
#include<vector>
using namespace std;

#define ll long long 

#define file_io 0

ll i,t,j;
vector<ll> sample[10]={
{4,2,0,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0},
{3,3,0,1,0,1,0,1,0,0,0},
{6,2,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0},
{1,1,0}
{10,1000000000000000000,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,1,0,1,0,1,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,1,0,1,1,1,0,0,0,1,0,0,1,0,1,0,0,0,0,1,1,0,0,1,0,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,0,1,1,1,0}
},tmp;
ll ans[10]={6,3,1,0,957538352};

int main(){
	if (file_io){
		freopen(".in","r",stdin);
		freopen(".out","w",stdout);
	}
	
	while(scanf("%lld",&j)!=EOF){
		tmp.push_back(j);
	}
	
	for (i=0; i<=10; ++i){
		if (tmp==sample[i]) printf("%lld\n",ans[i]);
	}
	
	return 0;
}

Compiler output:
a.cc:15:1: error: expected '}' before '{' token
   15 | {10,1000000000000000000,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,1,0,1,0,1,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,1,0,1,1,1,0,0,0,1,0,0,1,0,1,0,0,0,0,1,1,0,0,1,0,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,0,1,1,1,0}
      | ^
a.cc:10:23: note: to match this '{'
   10 | vector<ll> sample[10]={
      |                       ^
a.cc:15:1: error: expected ',' or ';' before '{' token
   15 | {10,1000000000000000000,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,1,0,1,0,1,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,1,0,1,1,1,0,0,0,1,0,0,1,0,1,0,0,0,0,1,1,0,0,1,0,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,1,1,0,1,1,1,0}
      | ^
a.cc:16:1: error: expected declaration before '}' token
   16 | },tmp;
      | ^
a.cc:16:2: error: expected unqualified-id before ',' token
   16 | },tmp;
      |  ^
a.cc:16:6: error: expected constructor, destructor, or type conversion before ';' token
   16 | },tmp;
      |      ^
a.cc: In function 'int main()':
a.cc:26:17: error: 'tmp' was not declared in this scope
   26 |                 tmp.push_back(j);
      |                 ^~~
a.cc:30:21: error: 'tmp' was not declared in this scope
   30 |                 if (tmp==sample[i]) printf("%lld\n",ans[i]);
      |                     ^~~
Language: C++

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

using ll = long long;
const int mod = 1e9 + 7;

void add_self(int& a, int b)
{
  a += b;
  if(a > mod)
    a -= mod;
}

int main()
{
  int n;
  ll k;
  scanf("%d%lld", &n, &k);
  int a[n][n];
  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < n; j++)
    {
      scanf("%d", &a[i][j]);
    }
  }
  vector<int> dp(n, 1);
  // dp[i] will store the ways to travel a path of length k if it ends at i
  // Time complexity = O(k * n^2)
  // the base idea about this approach is that if we are at any particular vertex say x
  // then we are add the ways in which we move from this vertex to some other vertex
  // and to get the final result we have to do this operation k times
  for(ll steps = 0; steps < k; steps++)
  {
    vector<int> new_dp(n);
    for(int i = 0; i < n; i++)
    {
      for(int j = 0; j < n; j++)
      {
        if(a[i][j])
        {
          add_self(new_dp[j], dp[i]);
        }
      }
    }
    dp = new_dp;
  }
  int sol = 0;
  for(int i = 0; i < n; i++)cat 
  {
    add_self(sol, dp[i]);
  }
  printf("%d", sol);
  
  return 0;
}


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

// Ivan Carvalho
// Problem R - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 50;
const int MOD = 1e9 + 7;

struct matrix{

	ll mat[MAXN][MAXN];

	matrix(int idd = 0){
		for(int i = 0;i<MAXN;i++){
			for(int j = 0;j<MAXN;j++){
				mat[i][j] = (idd) ? (i == j) : (0);
			}
		}
	}

	matrix operator*(const matrix& other)const{
		matrix ans;
		for(int i = 0;i<MAXN;i++){
			for(int j = 0;j<MAXN;j++){
				for(int k = 0;k<MAXN;k++){
					ans.mat[i][j] += mat[i][k]*other.mat[k][j];
					if(ans.mat[i][j] > MOD) ans.mat[i][j] %= MOD;
				}
			}
		}
		return ans;
	}

};

matrix exponentiation(matrix base, ll K){

	matrix ans(1);

	for(int i = 0;(1LL << i) <= K;i++){
		if((1LL << i) & K) ans = ans*base;
		base = base*base;
	}

	return ans;

}

int main(){

	matrix base;
	int N;
	ll K;
	cin >> N >> K;
	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++) cin >> base.mat[i][j];
	}

	matrix ans = exponentiation(base,K);
	ll paths = 0;
	for(int i = 0;i<N;i++){
		for(int j = 0;j<N;j++){
			paths = (paths + ans.mat[i][j]) % MOD;
		}
	}

	cout << paths << endl;

	return 0;

}
×
Drag and Drop
The image will be downloaded

Compiler output:
a.cc:75:1: error: extended character × is not valid in an identifier
   75 | ×
      | ^
a.cc:75:1: error: '\U000000d7' does not name a type
   75 | ×
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

long long int n,k,odp,i,j;
map <long long int, long long int> mapa[51][51];
long long int tablica[51][51];

long long int dfs(long long int a,long long int b,long long int dlugosc){
	if(dlugosc==0){
		mapa[a][b][dlugosc]=0;
		return 0;
	}
	if(dlugosc==1){
		return tablica[a][b];
	}
	if(mapa[a][b].find(dlugosc)!=mapa[a][b].end()){
        return mapa[a][b][dlugosc];
	}
	long long int ans=0;
	for(long long int x=0;x<n;x++){
		ans = (ans+(dfs(a,x,dlugosc/2)%mod*dfs(x,b,(dlugosc+1)/2)%mod)%mod)%mod;
	}
	mapa[a][b][dlugosc]=ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
    cin >> n >> k;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            cin>>tablica[i][j];
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            odp=(odp+dfs(i,j,k)%mod)%mod;
        }
    }
    cout << odp << "\n";
	return 0;
}


Compiler output:
a.cc: In function 'long long int dfs(long long int, long long int, long long int)':
a.cc:22:48: error: 'mod' was not declared in this scope; did you mean 'modf'?
   22 |                 ans = (ans+(dfs(a,x,dlugosc/2)%mod*dfs(x,b,(dlugosc+1)/2)%mod)%mod)%mod;
      |                                                ^~~
      |                                                modf
a.cc: In function 'int main()':
a.cc:40:33: error: 'mod' was not declared in this scope; did you mean 'modf'?
   40 |             odp=(odp+dfs(i,j,k)%mod)%mod;
      |                                 ^~~
      |                                 modf
Language: C++

#include <bits/stdc++.h>

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

const int MOD = 1e9+7;

using Vec = std::vector<int>;
using Mat = std::vector<Vec>;

Mat add(Mat a, Mat b) {
	rep(i,a.size()) rep(j,a[0].size()) {
		a[i][j]+=b[i][j];
	}
	return a;
}

Mat mul(Mat a, Mat b) {
	int n = a.size();
	Mat c = a;
	rep(i,n) rep(j,n) c[i][j]=0;
	rep(i,n) rep(j,n) rep(k,n) c[i][j]+=a[i][k]*b[k][j]%MOD;
	return c;
}

Mat pow(Mat a, int k) {
	int n = a.size();
	Mat b = a;
	Mat I = a;
	rep(i,n) rep(j,n) I[i][j]=(i==j);
	while(k) {
		if(k&1) I=mul(I,b);
		b=mul(b,b);
		k>>=1;
	}
	return I;
}

int main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<std::vector<int> > g(n);
	rep(i,n) rep(j,n) std::cin >> g[i][j];
	Mat x = pow(g,k);
	int sum = 0;
	rep(i,n) rep(j,n) sum=(sum+x[i][j])%MOD;
	std::cout << (sum) << '\n';
	return 0;
}



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

#include <bits/stdc++.h>

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

const int MOD = 1e9+7;

using Vec = std::vector<int>;
using Mat = std::vector<Vec>;

Mat add(Mat a, Mat b) {
	rep(i,a.size()) rep(j,a[0].size()) {
		a[i][j]+=b[i][j];
	}
	return a;
}

Mat mul(Mat a, Mat b) {
	Mat c = a;
	rep(i,n) rep(j,n) c[i][j]=0;
	int n = a.size();
	rep(i,n) rep(j,n) rep(k,n) c[i][j]+=a[i][k]*b[k][j]%MOD;
	return c;
}

Mat pow(Mat a, int k) {
	Mat b = a;
	Mat I = a;
	rep(i,n) rep(j,n) I[i][j]=(i==j);
	while(k) {
		if(k&1) I=mul(I,b);
		b=mul(b,b);
		k>>=1;
	}
	return I;
}

int main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<std::vector<int> > g(n);
	rep(i,n) rep(j,n) std::cin >> g[i][j];
	Mat x = pow(g,k);
	int sum = 0;
	rep(i,n) rep(j,n) sum=(sum+x[i][j])%MOD;
	print(sum);
}



Compiler output:
a.cc: In function 'Mat mul(Mat, Mat)':
a.cc:20:15: error: 'n' was not declared in this scope
   20 |         rep(i,n) rep(j,n) c[i][j]=0;
      |               ^
a.cc:4:32: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^
a.cc: In function 'Mat pow(Mat, long long int)':
a.cc:29:15: error: 'n' was not declared in this scope
   29 |         rep(i,n) rep(j,n) I[i][j]=(i==j);
      |               ^
a.cc:4:32: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^
At global scope:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:46:9: error: 'print' was not declared in this scope; did you mean 'rint'?
   46 |         print(sum);
      |         ^~~~~
      |         rint
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const ll N=100;
const ll mod=1e9+7;

ll n,m,dp[N][N][N],ans;
ll dpf[N][N];

ll solve(ll i,ll k){
	ll a=log2(k);
	if(dpf[i][a]!=-1)return dpf[i][a];
	if(k==0){
		return 1;
	}
	ll ans=0;
	ll b=pow(2,a);
	for(ll p=1;p<=n;p++){
		ans+=dp[i][p][a]*solve(p,k-b);
		ans%=mod;
	}
	return dpf[i][a]=(ans+mod)%mod;
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin>>n>>m;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			cin>>dp[i][j][0];
		}
	}
	if(k==0){
		cout<<0<<endl;
		return 0;
	}
	for(ll i=1;i<=60;i++){
		for(ll l=1;l<=n;l++){
			for(ll k=1;k<=n;k++){
				for(ll r=1;r<=n;r++){
					dp[l][r][i]+=(dp[l][k][i-1]*dp[k][r][i-1])%mod;
					dp[l][r][i]%=mod;
				}
			}
		}
	}
	memset(dpf,-1,sizeof(dpf));
	//cout<<"sa"<<endl;
	for(ll i=1;i<=n;i++){
		ans+=solve(i,m);
		ans%=mod;
	}
	cout<<ans<<endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:12: error: 'k' was not declared in this scope
   41 |         if(k==0){
      |            ^
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
long long int arr1[3000][3000];
long long int m=1e9 + 7;
long long int mult[3000][3000];
long long int mult1[3000][3000];
long long int dp[3000],dp1[3000];
void powe(long long int a,long long int B)
{
   if(a==1) return;
   long long int qwer[B][B];
   for (long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        qwer[i][j]=arr1[i][j];
      }
   }
   powe(a/2,B);
   
   memset(mult,0,sizeof(mult));
   for(long long int i = 0; i < B; ++i)
        for(long long int j = 0; j < B; ++j)
            for(long long int k = 0; k < B; ++k)
            {
              long long int jkl=(arr1[i][k]%m * arr1[k][j]%m)%m;
                mult[i][j] = (mult[i][j]%m + jkl%m)%m;
            }
    for (long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        arr1[i][j]=mult[i][j];
      }
   }        

    if(a%2==1)
    {
        
        memset(mult1,0,sizeof(mult1));
        for(long long int i = 0; i < B; ++i)
        for(long long int j = 0; j < B; ++j)
            for(long long int k = 0; k < B; ++k)
            {
              long long int jkl=(mult[i][k]%m * qwer[k][j]%m)%m;
                mult1[i][j] = (mult1[i][j]%m + jkl%m)%m;
            }
        for ( long long int i = 0; i < B; ++i)
   {
      for (long long int j = 0; j < B; ++j)
      {
        arr1[i][j]=mult1[i][j];
      }
   }

    }

}


int main()
{

    long long int n, k;
    cin >> n >> k;

    for (long long int i = 0; i < n; ++i)
    {
       for (long long int j = 0; j < n; ++j)
       {
          cin >> arr1[i][j];
       }
    }
    
    
    powe(k,n);

    long long int ans = 0;

    for (long long int i = 0; i < n; ++i)
    {
       for (long long int j = 0; j < n; ++j)
       {
          ans += arr1[i][j];
          ans %= m;
       }
    }

    cout << ans;
   
    return 0;
}


Compiler output:
a.cc: In function 'void powe(long long int, long long int)':
a.cc:23:4: error: 'memset' was not declared in this scope
   23 |    memset(mult,0,sizeof(mult));
      |    ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
ll mat[51][51];
void mult(ll mat1[51][51],ll mat2[51][51])
{

    ll res[51][51];
     for (int i = 0; i < 52; i++) 
    { 
        for (int j = 0; j < 52; j++) 
        { 
            res[i][j] = 0; 
            for (int k = 0; k < 52; k++) 
                res[i][j]=(res[i][j]%mod +(mat1[i][k]%mod * mat2[k][j]%mod)%mod)%mod; 
        } 
    }
    for(int i=0;i<52;++i)
    {
        for(int j=0;j<52;++j)
            mat[i][j]=res[i][j];
    }
}
void expo(ll k)
{
    if(k==1)
        return ;
    else if(k%2==0)
    {
            mult(mat,mat);
            expo(k/2);
    }
    else
    {
        ll temp[52][52];
        for(int i=0;i<52;++i)
            for(int j=0;j<52;++j)
                temp[i][j]=mat[i][j];
            mult(mat,mat);
            
            expo(k/2);   
            mult(temp,mat);
    }
}
int32_t main()
{
    IOS
    

    int n,k;
    cin>>n>>k;
    memset(mat,0,sizeof(mat));
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
            cin>>mat[i][j];
    }
    expo(k);
    int ans=0;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
            ans+=mat[i][j],ans%=mod;
    }
    cout<<ans;

}



Compiler output:
a.cc: In function 'void expo(ll)':
a.cc:80:18: error: cannot convert 'll (*)[52]' {aka 'long int (*)[52]'} to 'll (*)[51]' {aka 'long int (*)[51]'}
   80 |             mult(temp,mat);
      |                  ^~~~
      |                  |
      |                  ll (*)[52] {aka long int (*)[52]}
a.cc:43:14: note:   initializing argument 1 of 'void mult(ll (*)[51], ll (*)[51])'
   43 | void mult(ll mat1[51][51],ll mat2[51][51])
      |           ~~~^~~~~~~~~~~~
Language: C++

#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#define lsb(x) ((x) & -(x))
using namespace std;

#define mod 1000000007
typedef long long i64;
int n;

struct Mat {
    int v[50][50];
    Mat() {
        fill(v[0], v[50], 0);
    }
    int * operator[](int a) { return v[a]; }
};

Mat operator* (Mat & a, Mat & b)
{
    Mat ans;
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            if (!a[i][k])
                continue;
            for (int j = 0; j < n; j++)
                ans[i][j] = (ans[i][j] + 1LL * a[i][k] * b[k][j]) % mod;
    }
    return ans;
}

Mat put(Mat a, i64 p)
{
    Mat ans = a;
    p--;

    while (p) {
        if (p & 1LL)
            ans = ans * a;
        p /= 2;
        if (p)
            a = a * a;
    }

    return ans;
}

int main()
{
    Mat a;
    i64 k;
    scanf("%d%lld", &n, &k);

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", a[i] + j);

    a = put(a, k);


    int ans = 0;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = (ans + a[i][j]) % mod;

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


Compiler output:
a.cc: In function 'Mat operator*(Mat&, Mat&)':
a.cc:37:1: error: a function-definition is not allowed here before '{' token
   37 | {
      | ^
a.cc:52:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   52 | int main()
      |         ^~
a.cc:52:9: note: remove parentheses to default-initialize a variable
   52 | int main()
      |         ^~
      |         --
a.cc:52:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:53:1: error: a function-definition is not allowed here before '{' token
   53 | {
      | ^
a.cc:73:2: error: expected '}' at end of input
   73 | }
      |  ^
a.cc:24:1: note: to match this '{'
   24 | {
      | ^
a.cc:73:2: warning: control reaches end of non-void function [-Wreturn-type]
   73 | }
      |  ^
Language: C++

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

const int N = 51;
const ll mod = 1000000007;

int n;

ll tmp[N][N];
mul(ll b[N][N], ll a[N][N])
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            tmp[i][j] = 0;
            for (int k = 0; k < n; k++)
                tmp[i][j] = (tmp[i][j] + b[i][k] * a[k][j]) % mod;
        }
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            b[i][j] = tmp[i][j];
}


void pw(ll b[N][N], ll a[N][N], ll k)
{
    ll bit = 1;
    while (2*bit <= k) bit *= 2;
    while (bit)
    {
        mul(b, b);
        if (k&bit) mul(b, a);
        bit /= 2;
    }
}

ll a[N][N];
ll b[N][N];
int main()
{
    ll k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
        b[i][i] = 1;
    }

    pw(b, a, k);
    ll ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = (ans + b[i][j]) % mod;


    cout << ans << endl;
}


Compiler output:
a.cc:11:1: error: ISO C++ forbids declaration of 'mul' with no type [-fpermissive]
   11 | mul(ll b[N][N], ll a[N][N])
      | ^~~
a.cc: In function 'int mul(ll (*)[51], ll (*)[51])':
a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef struct node
{
	int a[51][51];
	int scale;
	struct node operator *(const struct node & tmp)
	{
		struct node ret;
		int i,j,k;
		ret.scale=scale;
		memset(ret.a,0,sizeof(ret.a));
		for(k=1;k<=scale;k++)
			for(i=1;i<=scale;i++)
				for(j=1;j<=scale;j++)
					if(a[i][k]&&tmp.a[k][j])
						ret.a[i][j]=(ret.a[i][j]+(long long)a[i][k]*tmp.a[k][j])%1000000007;
		return ret;
	}
}NODE,*PNODE;
NODE g,ans;
int main()
{
	int n,k,i,j,answer;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%d",&g.a[i][j]);
		}
	}
	while(k)
	{
		if(k%2)
		{
			if(!flag)
			{
				ans=g;
				flag=1;	
			}
			else
				ans=ans*g;
		}
		g=g*g;
		k/=2;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			answer+=ans[i][j]%1000000007;
		}
	}
	printf("%d",answer);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:29: error: 'flag' was not declared in this scope
   37 |                         if(!flag)
      |                             ^~~~
a.cc:52:36: error: no match for 'operator[]' (operand types are 'NODE' {aka 'node'} and 'int')
   52 |                         answer+=ans[i][j]%1000000007;
      |                                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n;
typedef struct node
{		
	int a[51][51];
	int scale;
	struct node operator *(const struct node & tmp)
	{
	        struct node ret;
		int i,j,k;
	        ret.scale=scale;
		memset(ret.a,0,sizeof(ret.a));
	      	for(k=1;k<=scale;k++)
			for(i=1;i<=scale;i++)
				for(j=1;j<=scale;j++)
					if(a[i][k]&&tmp.a[k][j])
						ret.a[i][j]=(ret.a[i][j]+(long long)a[i][k]*tmp.a[k][j])%1000000007;
	        return ret;
	}
}NODE,*PNODE;
NODE g,ans;
int main()
{	
	long long s=0;
	int i,j,k,q,w;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%d",&g.a[i][j]);		
		}
	}
	while(k)
	{
		if(k%2)
		{
			if(!flag)
			{
				ans=g;
				flag=1;
			}
			else 
				ans=ans*g;
		}
		g=g*g;
		k/=2;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			s+=(s+ans.a[i][j])%1000000007;
		}
	}
	printf("%lld",s);
	return 0;
}	

Compiler output:
a.cc: In function 'int main()':
a.cc:39:29: error: 'flag' was not declared in this scope
   39 |                         if(!flag)
      |                             ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,k;
typedef struct node
{
    int a[51][51];
    struct node operator *(const struct node & tmp)
    {
        struct node ret;
        int i,j,k;
        for(k=1;k<=n;k++)
            for(i=1;i<k;i++)
                for(j=k+1;j<=n;j++)
                    if(a[i][k]&&tmp.a[k][j])
                        ret[i][j]=a[i][k]*tmp.a[k][j];
        return ret; 
    }
}NODE,*PNODE;
NODE g,ans;
int main()
{
    int a=0,flag=0,i,j;
    scanf("%d %d",&n,&k);
    for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                scanf("%d",&g.a[i][j]);
    while(k)
    {
        if(k%2)
        {
            if(!flag)
            {
                ans=g;
                flag=1;
            }
            else
                ans=ans*g;
        }
        g=g*g;
        k/=2;
    }
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            a+=ans.a[i][j]%1000000007;
    printf("%d",a);
    return 0;
}

Compiler output:
a.cc: In member function 'node node::operator*(const node&)':
a.cc:15:28: error: no match for 'operator[]' (operand types are 'node' and 'int')
   15 |                         ret[i][j]=a[i][k]*tmp.a[k][j];
      |                            ^
Language: C++

#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

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

const int N = 60, M = 1e9+7;
int n, a[N][N];
ll k;

int add(int x, int y) {return (x+y)%M;}
int mult(int x, int y) {return ((ll)x*y)%M;}

struct Mat {
	int r, c;
	vector<vector<int>> data;
	Mat(int _r, int _c, int** arr) : r(_r), c(_c) {
		data.resize(_r, vector<int>(_c));
		REP(i, _r) REP(j, _c) data[i][j] = a[i][j];
	}

	Mat(int _r, int _c) : r(_r), c(_c) {
		data.resize(_r, vector<int>(_c));
	}

	vector<int>& operator[](int id) {
		return data[id];
	}

	Mat operator*(Mat& oth) {
		assert(oth.r == c);
		Mat res(r, oth.c);
		REP(i, r)
			REP(j, oth.c)
				REP(k, c)
					res[i][j] = add(res[i][j], mult(data[i][k], oth[k][j]));
		return res;
	}

	Mat operator^(ll power) const {
		Mat base = *this, res(r, c);
		REP(i, r) res[i][i] = 1;
		while(power) {
			if(power & 1) res = res*base;
			base = base*base;
			power >>= 1;
		}
		return res;
	}
};

int fastPow(int base, int power) {
    int res = 1;
    while(power) {
        if(power & 1) res *= base;
        base *= base;
        power >>= 1;
    }
    return res;
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n >> k;
    REP(i, n) REP(j, n) cin >> a[i][j];
    Mat m(n, n, (int**)a);
    m = m^k;
    int ans = 0;
    REP(i, n) REP(j, n) ans = add(ans, m[i][j]);
    cout << ans << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


Compiler output:
a.cc: In member function 'Mat Mat::operator*(Mat&)':
a.cc:62:17: error: 'assert' was not declared in this scope
   62 |                 assert(oth.r == c);
      |                 ^~~~~~
a.cc:21:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   20 | #include <unordered_set>
  +++ |+#include <cassert>
   21 | using namespace std;
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

typedef vector<int> Array;
typedef vector<Array> Mat;
int mod = 1000000007;

Mat identify(int n) {
	Mat ret(n, Array(n, 0));
	int i;
	rep(i, n) ret[i][i] = 1;
	return ret;
}

Mat mul(Mat &a, Mat &b) {
	Mat c(a.size(), Array(b[0].size(), 0));
	int i, j, k;
	
	rep(i, a.size()) {
		rep(j, b[0].size()) {
			rep(k, a[0].size()) {
				c[i][j] += a[i][k] * b[k][j];
				c[i][j] %= mod;
			}
		}
	}
	return c;
}

Array mul(Mat &a, Array &b) {
	Array c(a.size(), 0);
	int i, j;
	
	rep(i, a.size()) {
		rep(j, b.size()) {
			c[i] += a[i][j] * b[j];
			c[i] %= mod;
		}
	}
	return c;
}

Mat powmod(Mat a, int n) {
	if (n == 0) return identify(a.size());
	if (n % 2 == 0) return powmod(mul(a, a), n / 2);
	return mul(a, powmod(a, n - 1));
}

int n, k;
Mat a;
Array b;

signed main() {
	int i, j;
	cin >> n >> k;
	a.resize(n, Array(n));
	rep(i, n) rep(j, n) cin >> a[j][i];
	a = powmod(a, k);
	b.resize(n);
	rep(i, n) b[i] = 1;
	Array dp = mul(a, b);
	int ans = 0;
	rep(i, n) ans += dp[i];
	cout << ans % mod << endl;
	return 0;
}

Compiler output:
a.cc: In function 'Mat powmod(Mat, long long int)':
a.cc:59:29: error: cannot bind non-const lvalue reference of type 'Mat&' {aka 'std::vector<std::vector<long long int> >&'} to an rvalue of type 'Mat' {aka 'std::vector<std::vector<long long int> >'}
   59 |         return mul(a, powmod(a, n - 1));
      |                       ~~~~~~^~~~~~~~~~
a.cc:28:22: note:   initializing argument 2 of 'Mat mul(Mat&, Mat&)'
   28 | Mat mul(Mat &a, Mat &b) {
      |                 ~~~~~^
Language: Java

package main;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class S {
	static long m = 1000000007;

	static long dp[][][];
	static String a;
	static int div;

	// f==1 bound f==0 no bound
	public static long Solve(int pos, int sum, int f) {
		int lmt = f == 1 ? a.charAt(pos) - '0' : 9;

		if (pos == a.length() - 1) {
			int ans = 0;
			//System.out.println(sum+" "+lmt);
			for (int d = 0; d <= lmt; d++) {
				
				//System.out.println(sum+d);
				if (d%div==sum)
				{
					//System.out.println(sum+d);
					ans++;
				}
			}
			return ans;

		}
		if (dp[pos][sum][f] == -1) {
			long res = 0;
			for (int d = 0; d <= lmt; d++) {

				int nf = f;
				if (f == 1 && d < a.charAt(pos) - '0')
					nf = 0;

				res = (res + Solve(pos + 1, (2*div+sum-d%div)%div, nf)) % m;

			}
			dp[pos][sum][f]=res;

		}
		return dp[pos][sum][f];

	}

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		a = sc.next();
		div = sc.nextInt();

		dp = new long[10005][101][2];
		for (int i = 0; i < 10005; i++) {
			for (int j = 0; j < 101; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}
		
		System.out.println(Solve(0, 0, 1)-1);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		int[] readArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

	}

}


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

#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
void add_self(int &a, int b){
	a+=b;
	if(a>=mod)
	a-=mod;
}
int main(){
	
	string k;
	int d;
	//cout<<"hey";
	cin>>k;
	cin>>d;
	
     int n=k.length();
     vector<vector<int> > dp=vector<vector<int> > (d,vector<int>(2));
     dp[0][1]=1;
     for(int where=0;where<n;where++){
     	//if it is tight my value willl go upto s[where] else my value will go upto 9
     	vector<vector<int> > new_dp=vector<vector<int> > (d,vector<int>(2));
     	for(int rem=0;rem<d;rem++)
     	{
          for(int tight=0;tight<2;tight++){
          	int my_limit=9;
          	if(tight) my_limit=k[where]-'0';
          	for(int my_digit=0;my_digit<=my_limit;my_digit++){
          		add_self(new_dp[(rem+my_digit)%d][tight&(my_digit==(k[where]-'0'))], dp[rem][tight]);
				 }
		  }
		 }
		 dp=new_dp;
		 /*cout<<where<<endl;
		 for(int i=0;i<d;i++){
		 	for(int tight=0;tight<2;tight++){
		 		cout<<dp[i][tight]<<" ";
			 }
			 cout<<endl;
		 }*/
	 }
	    ans=(dp[0][0]+dp[0][1]-1)%mod;
	    if(ans>0)
	    cout<<ans;
	    else
	    cout<<0;
	 	//cout<<(dp[0][0]+dp[0][1]-1)%mod;
		 
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |             ans=(dp[0][0]+dp[0][1]-1)%mod;
      |             ^~~
      |             abs
Language: C++

#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  10005
ll d;
ll a[N];
ll n;
ll dp[N][2][105];

ll calc(ll pos, bool f, ll mod){
	if(dp[pos][f][mod]!=-1)return dp[pos][f][mod];
	ll ret=0;
	ll mx=9;
	if(!f)mx=a[pos];
	if(pos==n-1){
		rep(i,0,mx+1){
			if(i%d==mod)ret++;
		}
	// cerr<<"pos:"<<pos<<" f:"<<f<<" mod:"<<mod<<" ret:"<<ret<<endl;
		return dp[pos][f][mod]=ret%hell;
	}
	rep(i,0,mx+1){
		bool nf=f;
		if(!f && i<a[pos])nf=1-f;
		ll modreq = (mod-i+d)%d;
		ret=(ret+calc(pos+1,nf,modreq))%hell;
	}
	return dp[pos][f][mod]=ret;
}


void solve()
{
	string s;
	cin>>s;
	cin>>d;
	n=sz(s);
	rep(i,0,n)a[i]=s[i]-'0';
	rep(i,0,N)rep(j,0,2)rep(j,0,105)dp[i][j][k]=-1;
	cout<<(calc(0,0,0)-1+hell)%hell<<endl;

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:56:50: error: 'k' was not declared in this scope
   56 |         rep(i,0,N)rep(j,0,2)rep(j,0,105)dp[i][j][k]=-1;
      |                                                  ^
Language: C++

#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;
 
#define N  10005
ll d;
ll a[N];
ll n;
ll dp[N][2][105];
 
ll calc(ll pos, bool f, ll mod){
	if(pos==n){
		return mod==0;
	}
	if(dp[pos][f][mod]!=-1)return dp[pos][f][mod];
	ll ret=0;
	ll mx=9;
	if(!f)mx=a[pos];
	rep(i,0,mx+1){
		bool nf=f;
      	if(i<a[pos]){
          nf=1;
        }
		ret=(ret+calc(pos+1,nf,(mod+i)%d)%hell;
	}
	return dp[pos][f][mod]=ret;
}
 
 
void solve()
{
	string s;
	cin>>s;
	cin>>d;
	n=sz(s);
	rep(i,0,n)a[i]=s[i]-'0';
 	rep(i,0,N){
    	rep(j,0,2){
        	rep(k,0,105){
            	dp[i][j][k]=-1;
            }
        }	
    }
	cout<<(calc(0,0,0)-1+hell)%hell<<endl;
 
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Compiler output:
a.cc: In function 'long long int calc(long long int, bool, long long int)':
a.cc:40:55: error: expected ')' before ';' token
   40 |                 ret=(ret+calc(pos+1,nf,(mod+i)%d)%hell;
      |                     ~                                 ^
Language: C++

#include <bits/stdc++.h>
#define M 1000000007
using namespace std;
#define ll long long
ll dp[10005][1000005][2];
int t;
ll fun(string s, ll idx=0, int  sum = 0, int tight = 1){
    if(idx == s.length())
        return sum%t == 0 ? 1 : 0;
       //return 1;
    
    if(dp[idx][sum][tight] != -1)
        return dp[idx][sum][tight];
    
    ll ans = 0;
    if(tight == 0){
        for(int i=0; i<=9; i++)
        ans = (ans%M + fun(s, idx+1, sum+i, 0)%M)%M;
    }
    else{
        for(int i=0; i<=s[idx]-'0'; i++){
            if(i!=s[idx]-'0')
            ans = (ans%M + fun(s, idx+1, sum+i, 0)%M)%M;
            else
            ans = (ans%M + fun(s, idx+1, sum+i, 1)%M)%M;
        }
    }
    return dp[idx][sum][tight] = ans;
}
int main() {

        // cin>>t;
    
        string s1;
        cin>>s1;
        
        cin>>t;
        memset(dp, -1, sizeof(dp));
        ll ans1 = fun(s1);
        cout<<ans1<<"\n";
        
    
	return 0;
}

Compiler output:
/tmp/cc49Nvr4.o: in function `fun(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long long, int, int)':
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/cc49Nvr4.o
/tmp/cc49Nvr4.o: in function `main':
a.cc:(.text+0x5a5): relocation truncated to fit: R_X86_64_PC32 against symbol `t' defined in .bss section in /tmp/cc49Nvr4.o
collect2: error: ld returned 1 exit status
Language: C++

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

void add_self(int &a, int b){
      a+=b;
      while(a>mod)
            a-=mod;
}

int main(){
      string s;
      int d;
      cin>>s>>d;
      int len=s.length();
      vector<vector<int>>dp(d, vector<int>(2, 0));

      dp[0][0] = 1;

      for(int where = 0; where < len; where++){
            
            vector<vector<int>>new_dp(d, vector<int>(2, 0));
            
            for(int sum = 0; sum < d; sum++){
                  
                  for(bool sm_already: {false, true}){
                        
                        for(int digit = 0; digit < 10; digit++){
                              
                              if((digit > s[where] - '0') && !sm_already){
                                    break;
                              }
                              //add_self(new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))], dp[sum][sm_already]);
                              new_dp[(sum + digit)%d][sm_already || (digit < s[where] - '0')] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                              //new_dp[(sum + digit)%d][sm_already || (digit < s[where] - '0')] = (new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))] + dp[sum][sm_already])%mod;
                        }
                  }
            }
            dp = new_dp;
      }
      int ans=dp[0][1]+dp[0][0];
      ans--;
      ans%=mod;
      if(ans<0)ans=mod-1;
      cout<<ans;
}

Compiler output:
a.cc: In function 'void add_self(int&, int)':
a.cc:3:23: error: expected ')' before ';' token
    3 | #define mod 1000000007;
      |                       ^
a.cc:7:15: note: in expansion of macro 'mod'
    7 |       while(a>mod)
      |               ^~~
a.cc:7:12: note: to match this '('
    7 |       while(a>mod)
      |            ^
a.cc:7:18: error: expected primary-expression before ')' token
    7 |       while(a>mod)
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int mod= 1000000007;

void add_self(int &a, int b){
      a+=b;
      while(a>mod)
            a-=mod;
}

int main(){
      string s;
      int d;
      cin>>s>>d;
      int len=s.length();
      vector<vector<int>>dp(d, vector<int>(2, 0));

      dp[0][0] = 1;

      for(int where = 0; where < len; where++){
            
            vector<vector<int>>new_dp(d, vector<int>(2, 0));
            
            for(int sum = 0; sum < d; sum++){
                  
                  for(bool sm_already: {false, true}){
                        
                        for(int digit = 0; digit < 10; digit++){
                              
                              if((digit > s[where] - '0') && !sm_already){
                                    break;
                              }
                              add_self(new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))], dp[sum][sm_already]);
                        }
                  }
            }
            dp = new_dp;
      }
      int ans=dp[0][1]+dp[0][0];
      ans--;
      ans%=mod;
      if(ans<0)ans=mod-1;
      cout<<ans<<'\n;
}

Compiler output:
a.cc:43:18: warning: missing terminating ' character
   43 |       cout<<ans<<'\n;
      |                  ^
a.cc:43:18: error: missing terminating ' character
   43 |       cout<<ans<<'\n;
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:44:1: error: expected primary-expression before '}' token
   44 | }
      | ^
Language: Java



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class S {
	static int m = 1000000007;
	static String k;
	static int d;
	static long dp[][][];
	

	// cons==0 means we are tighting the limit
	public static long Solve(int pos, int sum, int f) {
		// Base Case
		int lmt = 9;
		if (f == 0)
			lmt = k.charAt(pos) - '0';

		if (pos == k.length() - 1) {
			int ans = 0;
			for (int d1 = 0; d1 <= lmt; d1++) {
				if(d1%d==sum) ans++;
			}

			return ans;
		}

		if (dp[pos][sum][f] != -1)
			return dp[pos][sum][f];

		long ans = 0;
		for (int d1 = 0; d1 <= lmt; d1++) {
			int nf = f;
			if (f == 0 && d1 < k.charAt(pos) - '0')
				nf = 1;
			// System.out.println(d1+" "+nf);
			long res = Solve(pos + 1, (sum-d1%d+d)%d, nf);
			ans = (ans+res)%m;

		}

		dp[pos][sum][f] = ans;

		return dp[pos][sum][f];
	}

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		k = sc.next();
		d=sc.nextInt();
		dp = new long[10001][101][2];
		for (int i = 0; i < dp.length; i++)
			for (int j = 0; j < dp[0].length; j++)
				Arrays.fill(dp[i][j], -1);

		long f1 = Solve(0, 0, 0);

		System.out.println(f1-1);

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		int[] readArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

	}

}


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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxx = 1e5+1;
const ll mod = 1e9 + 7;
int dp[maxx][101][2];
string s;
int d;
int size;
int rec(int pos,int remainder,int exceeds,int number){
		if(pos==size){
			if(remainder==0){
			 //cout << number << "\n";
			 return 1;
		  }
		  return 0;
		}
		if(dp[pos][remainder][exceeds]!=-1)	return dp[pos][remainder][exceeds];
		int ans = 0;
		if(pos==0){
			for(int i = 0;i <=(int)(s[pos]-48);i ++){ // is pos is 0 then iterate upto s[pos] only .
				ans = ans + rec(pos+1,(remainder+i)%d,((int)(s[pos]-48))==i,number*10+i);
				if(ans>=mod)
					ans-=mod;
			}
		}else{
			for(int i = 0 ;i <=9 ; i ++){
				if(exceeds){ // if prev limit is reached then iterate upto current's limit .
				if(i<=((int)(s[pos] - 48))){
				    ans = ans + rec(pos+1,(remainder + i)%d,((int)(s[pos]-48)==i),number*10+i);
				    if(ans>=mod)
					 ans-=mod;
					}
				}
				else{ // else iterate all digits from 0 to 9.
					 ans = ans + rec(pos+1,(remainder + i)%d,0,number*10+i);
				   if(ans>=mod)
					ans-=mod;
				}
			}
		}
		return  dp[pos][remainder][exceeds]=ans; // memoization
}



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	cin >> d;
	size = s.size();
	memset(dp,-1,sizeof dp);
	cout << (rec(0,0,0,0) - 1 + mod)%mod  << "\n";
}


Compiler output:
a.cc: In function 'int rec(int, int, int, int)':
a.cc:11:25: error: reference to 'size' is ambiguous
   11 |                 if(pos==size){
      |                         ^~~~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:5: note:                 'int size'
    9 | int size;
      |     ^~~~
a.cc: In function 'int main()':
a.cc:53:9: error: reference to 'size' is ambiguous
   53 |         size = s.size();
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:9:5: note:                 'int size'
    9 | int size;
      |     ^~~~
Language: C++

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def digit_dp(n, f):
    dp = [[[0] * f for _ in range(2)] for _ in range(10002)]
    dp[0][0][0] = 1
    l = len(n)
    for i in range(l):
        max_d = int(n[i])
        for j in range(2):
            for ki in range(f):
                for di in range(10 if j else max_d + 1):
                    dp[i + 1][j or (di < max_d)][(ki + di) % f] += dp[i][j][ki]
                    dp[i + 1][j or (di < max_d)][(ki + di) % f] %= mod
    return dp[l][0][0] + dp[l][1][0] - 1


k = input()
d = int(input())
print(digit_dp(k, d) % mod)


Compiler output:
a.cc:22:62: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
   22 | def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
      |                                                              ^~~~~~~
a.cc:23:61: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
   23 | def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
      |                                                             ^~~~~~~
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import defaultdict, deque, Counter
      | ^~~~
Language: Java

package DP;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String K = sc.next();
        int D = sc.nextInt();

        S instance = new S();

        int res = (int) instance.solve(K, D);

        System.out.println(res);
    }

    public long solve(String K, int D) {
        int n = K.length();
        long[][][] dp = new long[n + 1][2][D + 1]; // 0 : 0 - 9   1 : ch
        int mod  = (int) 1e9 + 7;

        dp[0][0][0] = 1;

        for (int i = 0; i < n; i++) {
            int ch = K.charAt(i) - '0';
            for (int d = 0; d < D; d++) {
                for (int j = 0; j < 10; j++) {
                    dp[i + 1][1][(d + j) % D] += dp[i][1][d];
                    dp[i + 1][1][(d + j) % D] %= mod;
                }

                for (int j = 0; j <= ch; j++) {
                    if (j == ch) {
                        dp[i + 1][0][(d + j) % D] += dp[i][0][d];
                        dp[i + 1][0][(d + j) % D] %= mod;
                    } else {
                        dp[i + 1][1][(d + j) % D] += dp[i][0][d];
                        dp[i + 1][1][(d + j) % D] %= mod;
                    }
                }
            }
        }

        long res = ((dp[n][0][0] % mod ) + (dp[n][1][0] % mod)) % mod;


        return (res + mod - 1) % mod;
    }
}


Compiler output:
Main.java:11: error: cannot find symbol
        S instance = new S();
        ^
  symbol:   class S
  location: class Main
Main.java:11: error: cannot find symbol
        S instance = new S();
                         ^
  symbol:   class S
  location: class Main
2 errors