stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int N=200005;



int a[N],n,num;

ll ans=0;



int main(){

	scanf("%d",&n);

	for(int i=1;i<=n;i++) {

		scanf("%d",a+i);

		a[i]-=i;

	}

	sort(a+1,a+n+1);

	num=a[(n+1)>>1];

	for(int i=1;i<=n;i++) 

		ans+=(ll)abs(num-a[i]);

	cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define MN 200005

using namespace std;

inline int in(){

    int x=0;bool f=0;char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

int a[MN],n,x;

ll res;

int main()

{

	n=in();

	for (int i=1;i<=n;++i) a[i]=in()-i;

	sort(a+1,a+n+1);x=a[(n+1)>>1];

	for (int i=1;i<=n;++i) res+=1ll*abs(a[i]-x);

	printf("%lld",res);return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

long long k,a[200001],i,n,s=0;

int main()

{

	cin>>n;

	for(i=1;i<=n;i++) cin>>a[i],a[i]-=i;

	sort(a+1,a+1+n);

	k=a[(n+1)/2];

	for(i=1;i<=n;i++) s+=abs(k-a[i]);

	cout<<s;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define MN 200005

using namespace std;

inline int in(){

    int x=0;bool f=0;char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

int a[MN],n,x;

ll res;

int main()

{

	n=in();

	for (int i=1;i<=n;++i) a[i]=in()-i;

	sort(a+1,a+n+1);x=a[(n+1)>>1];

	for (int i=1;i<=n;++i) res+=1ll*abs(a[i]-x);

	printf("%lld",res);return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<cmath>



using namespace std;



int main(void)

{

	int n;

	cin>>n;

	

	long long a[n], b[n];

	

	int i,j;

	for(i=0; i<n; i++)

	{

		cin>>a[i];

		b[i] = a[i] - i -1;

	}

	

	sort(b,b+n);

	i = n/2;

	long long t = b[i];

	

	long long SUM = 0;

	

	bool flag = 1;

	int d = 0;

	while(flag)

	{

		long long sum = 0;

		for(j = 0; j<n; j++)

		{

			sum = sum + abs(b[j] - t);

		}

		

		if(d == 0)

		{

			t++;

			d = 1;

			SUM = sum;

			continue;

		}

		if(d == 1 && sum < SUM)

		{

			t++;

			d = 2;

			SUM = sum;

			continue;

		}

		if(d == 1 && sum > SUM)

		{

			t=t-2;

			d = 3;

			continue;

		}

		if(d == 1 && sum == SUM)

		{

			cout<<SUM;

			return 0;

		}

		if(d == 2 && sum < SUM)

		{

			t++;

			SUM = sum;

			continue;

		}

		if(d == 2 && sum >= SUM)

		{

			cout<<SUM;

			return 0;

		}

		if(d == 3 && sum < SUM)

		{

			t--;

			SUM = sum;

			continue;

		}

		if(d == 3 && sum >= SUM)

		{

			cout<<SUM;

			return 0;

		}	

	}

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define MN 200005

using namespace std;

inline int in(){

    int x=0;bool f=0;char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

int a[MN],n,x;

ll res;

int main()

{

	n=in();

	for (int i=1;i<=n;++i) a[i]=in()-i;

	sort(a+1,a+n+1);x=a[(n+1)>>1];

	for (int i=1;i<=n;++i) res+=1ll*abs(a[i]-x);

	printf("%lld",res);return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

long long int a[200009];

int main()

{

    long long int n,sum=0;

    scanf("%lld",&n);

    for(long long int i=1; i<=n; i++)

    {

        scanf("%lld",&a[i]);

        a[i]-=i;

    }

    sort(a+1,a+n+1);

    long long int ans=a[n/2+1];

    for(long long int i=1; i<=n; i++)

        sum+=abs(a[i]-ans);

    printf("%lld\n",sum);

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define MN 200005

using namespace std;

inline int in(){

    int x=0;bool f=0;char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

int a[MN],n,x;

ll res;

int main()

{

	n=in();

	for (int i=1;i<=n;++i) a[i]=in()-i;

	sort(a+1,a+n+1);x=a[(n+1)>>1];

	for (int i=1;i<=n;++i) res+=1ll*abs(a[i]-x);

	printf("%lld",res);return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl

#define all(x) (x).begin(),(x).end()

#define mem(x, n) memset(x, n, sizeof(x))



using namespace std;



typedef pair<int, int> pii;

typedef long long ll;

typedef unsigned long long ull;



const int SIZE = 2e5+10;



const ll MOD = 1e9 + 7;

ll n;

ll A[SIZE];



ll check(ll b) {

	ll s = 0;

	for(int i=0;i<n;i++) {

		s += abs(A[i] - (b + i + 1));

	}

	return s;

}



int main() {

	scanf("%lld", &n);

	for(int i=0;i<n;i++) {

		scanf("%lld", &A[i]);

	}

	ll l = -2e9, r = 2e9, m1, m2, c1, c2, ans;

	for(int i=0;i<200;i++) {

		m1 = l + (r-l)/3;

		m2 = l + (r-l)*2/3;

		c1 = check(m1);

		c2 = check(m2);

		if(c1 < c2) {

			ans = c1;

			r = m2;

		} else {

			ans = c2;

			l = m1;

		}

	}

	printf("%lld\n", ans);

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define MN 200005

using namespace std;

inline int in(){

    int x=0;bool f=0;char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

int a[MN],n,x;

ll res;

int main()

{

	n=in();

	for (int i=1;i<=n;++i) a[i]=in()-i;

	sort(a+1,a+n+1);x=a[(n+1)>>1];

	for (int i=1;i<=n;++i) res+=1ll*abs(a[i]-x);

	printf("%lld",res);return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long

#define ld double

using namespace std;

inline int read(){

    int x=0,f=1;char ch=getchar();

    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}

    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}

    return x*f;

}

int a[2000005],n;

ll s[2000005],ans=1e18;

int main(){

	n=read();

	for(int i=1;i<=n;++i)a[i]=read()-i;

	sort(a+1,a+n+1);

	for(int i=1;i<=n;++i)s[i]=s[i-1]+a[i];

	for(int i=1;i<=n;++i)ans=min(1ll*a[i]*i-s[i]+s[n]-s[i]-1ll*a[i]*(n-i),ans);

	printf("%lld",ans);

} 

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define MN 200005

using namespace std;

inline int in(){

    int x=0;bool f=0;char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

int a[MN],n,x;

ll res;

int main()

{

	n=in();

	for (int i=1;i<=n;++i) a[i]=in()-i;

	sort(a+1,a+n+1);x=a[(n+1)>>1];

	for (int i=1;i<=n;++i) res+=1ll*abs(a[i]-x);

	printf("%lld",res);return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<stdlib.h>

#include<time.h>

#include<math.h>

#include<string.h>

#include<algorithm>

#include<queue>

using namespace std;

int color[100050];

int cnt;

vector<int> G[100050];

#define WHITE 0

#define GRAY 1

#define BLACK 2



class UnionFind{

 public:

  //親の番号を格納する。親だった場合は-(その集合のサイズ）

  vector<int> Parent;

  

  //作るときはParentの値を全て-1になる

  //こうするとすべてバラバラになる。

  UnionFind(int N){

   Parent = vector<int>(N+1,-1);

  }



  int root(int A){

   if(Parent[A] <0)return A;

   return Parent[A]=root(Parent[A]);

  }



  int size(int A){

   return - Parent[root(A)];//親をとっていきたい

  }



  //AとBをくっ付ける

  bool connect(int A, int B){

   //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける

   A = root(A);

   B = root(B);

   if(A==B){

    return false;

   }

   //大きい方（A)に小さいほう（B)をくっ付けたい

   //大小が逆だったらひっくり返す。

   if(size(A) <size(B))swap(A,B);



   //Aのサイズを更新する。

   Parent[A] +=Parent[B];

   //Bの親をAに変更する

   Parent[B]=A;

   return true;

  }

};



int main(void){

 int N,M;

 cin>>N>>M;

 vector<int> A(M),B(M);

 for(int i=0; i<M; i++){

  cin>>A[i]>>B[i];

 }



 vector<long long int > ans(M);

 ans[M-1]=(long long int)N*(N-1)/2;

 

 UnionFind Uni(N);

 for(int i=M-1; i>=1; i--){

  ans[i-1]=ans[i];

  if(Uni.root(A[i])!=Uni.root(B[i])){

   ans[i-1]-=(long long int)Uni.size(A[i])*Uni.size(B[i]);

   Uni.connect(A[i],B[i]);

  }

 }



 for(int i=0; i<M; i++)cout<<ans[i]<<endl;



 return 0;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<vector>

#include<stdlib.h>

#include<time.h>

#include<math.h>

#include<string.h>

#include<algorithm>

#include<queue>



using namespace std;



class Union_find{

 public:

  vector<int> Parent;



  Union_find(int N){

   Parent=vector<int>(N+1,-1);

  }



  int root(int A){

   if(Parent[A]< 0)return A;

   return  Parent[A]=root(Parent[A]);

  }



  int size(int A){

   return - Parent[root(A)];

  }

  

  bool connect(int A,int B){

   A=root(A);

   B=root(B);

   if(A==B)return false; 



 //  cout<<"c"<<endl;

   if(size(A)<size(B))swap(A,B);

   Parent[A]+=Parent[B]; 

   Parent[B]=A;

   return true; 

  }

};



int main(void){

 int N,M;



 cin>>N>>M;

 vector<int> A(M);

 vector<int> B(M);

 vector<long long int>ans(M);



 for(int i=0; i<M;i++)cin>>A[i]>>B[i];

 Union_find Uni(N);  

 ans[M-1]=(long long int)N*(N-1)/2;



 for(int i=M-1; i>=1; i--){

  ans[i-1]=ans[i];

  //cout<<"b"<<endl;

  if(Uni.root(A[i])!=Uni.root(B[i])){

   ans[i-1]-=(long long int)Uni.size(A[i])*Uni.size(B[i]);

   Uni.connect(A[i],B[i]);

  }

 }

 for(int i=0; i<M; i++)cout<<ans[i]<<endl;

 return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;



#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'

#define mset(d,val) memset(d,val,sizeof(d))

#define setp(x) cout<<fixed<<setprecision(x)

#define forn(i,a,b) for(int i=(a);i<(b);i++)

#define fore(i,a,b) for(int i=(a);i<=(b);i++)

#define pb push_back

#define F first

#define S second

#define pqueue priority_queue

#define fbo find_by_order

#define ook order_of_key

typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<ll> vi;

typedef vector<ii> vii;

typedef long double ld;

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void amin(ll &a, ll b){ a=min(a,b); }

void amax(ll &a, ll b){ a=max(a,b); }

void SD(int t=0){ cout<<"PASSED "<<t<<endl; }

const ll INF = ll(1e18);

const int MOD = 1e9+7;



const int MAXN = 100005;



ll add(ll a,ll b)

{

	a%=MOD; b%=MOD;

	a+=b;a%=MOD;

	if(a<0) a+=MOD;

	return a;

}

ll mult(ll a, ll b)

{

	a%=MOD; b%=MOD;

	ll ans=(a*b)%MOD;

	if(ans<0) ans+=MOD;

	return ans;

}

ll pw(ll a, ll b)

{

	ll r=1;

	while(b){

		if(b&1) r=mult(r,a);

		a=mult(a,a);

		b>>=1;

	}

	return r;

}

ll add2(ll a,ll b)

{

	a%=13; b%=13;

	a+=b;a%=13;

	if(a<0) a+=13;

	return a;

}

ll mult2(ll a, ll b)

{

	a%=13; b%=13;

	ll ans=(a*b)%13;

	if(ans<0) ans+=13;

	return ans;

}

ll pw2(ll a, ll b)

{

	ll r=1;

	while(b){

		if(b&1) r=mult2(r,a);

		a=mult2(a,a);

		b>>=1;

	}

	return r;

}



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	

	string s; cin>>s; s='0'+s;

	int n=s.length();

	

	ll dp[n][13]{};

	dp[0][0]=1;

	

	forn(i,1,n){

		forn(j,0,13){

			forn(k,0,10){

				if(s[i]!='?' && s[i]-'0'!=k) continue;

				dp[i][j]=add(dp[i][j], dp[i-1][add2(j,-mult2(k, pw2(10,n-1-i)))]);

			}

		}

	}

	

	cout<<dp[n-1][5]<<'\n';

	

	return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define ll long long

#define pb push_back

#define mp make_pair

#define modulo 1000000007

#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;

int main(){

	fast_io;

	string s;

	cin>>s;

	ll n=s.length();

	ll a[n][13];

	memset(a,0,sizeof(a));

	if(s[0]=='?'){

		for (int i = 0; i <= 9; ++i){

			a[0][i]=1;

		}

	}

	else

		a[0][(s[0]-'0')]++;

	for (int i = 1; i < n; ++i){

		vector<ll>v;

		if(s[i]!='?')

			v.pb((s[i]-'0'));

		else{

			v.pb(0);v.pb(1);v.pb(2);v.pb(3);v.pb(4);v.pb(5);v.pb(6);v.pb(7);v.pb(8);v.pb(9);

		}

		for (int j = 0; j < v.size(); ++j){

			ll x=v[j];

			for (int k = 0; k < 13; ++k){

				a[i][(x+k*10)%13]=(a[i-1][k]+a[i][(x+k*10)%13])%modulo;

			}

		}

	}

	cout<<a[n-1][5]<<"\n";

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



using i32 = std::int_fast32_t;

using i64 = std::int_fast64_t;



#define REP(i, stop) FOR(i, 0, stop)

#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)

#define RREP(i, n) for (int i = n; i-- > 0;)



struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;



i64 dp[100010][13];

const i64 M = 1000000007;

signed main() {

	string S;

	cin >> S;

	i64 k = 0;

	dp[0][0] = 1;

	REP(i, S.size()) {

		char c = S[i];

		if (c == '?') {

			REP(r, 13) {

				i64 s = 0;

				REP(j, 10) {

					s += dp[k][(j - r + 13) * 9 % 13];

				}

				dp[k + 1][r] = s % M;

			}

		} else {

			i64 d = c - '0';

			REP(r, 13) {

				i64 s = dp[k][(d - r + 13) * 9 % 13];

				dp[k + 1][r] = s % M;

			}

		}

		k += 1;

	}

	cout << dp[k][5] << endl;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <utility>

using namespace std;



using i64 = long long;



#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)



i64 D[13];

i64 E[13];

const i64 M = 1000000007;

signed main() {

	D[0] = 1;

	while(true) {

		char c = getchar_unlocked();

		if (c == '\n') {

			break;

		} else if (c == '?') {

			REP(r, 13) {

				i64 s = 0;

				REP(j, 10) {

					s += D[(j - r + 13) * 9 % 13];

				}

				E[r] = s % M;

			}

		} else {

			i64 d = c - '0';

			REP(r, 13) {

				E[r] = D[(d - r + 13) * 9 % 13];

			}

		}

		swap(D, E);

	}

	printf("%d", D[5]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define all(x) (x).begin() , (x).end()

#define rall(x) (x).rbegin() , (x).rend()

#define fi first

#define se second

#define pb push_back

#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);



using namespace std;



template<typename T> void macro_scan(T& t){cin>>t;};

template<typename F, typename ...R>void macro_scan(F& f , R& ...r){

  cin>>f;macro_scan(r...);

}



void deb(){

    cerr<<endl;

}

template<typename T , typename... t>

void deb(T a , t...b){

    cerr<<a<<" ";

    deb(b...);

}

template<typename T>

void dev(vector<T>v){

    int c = 0;

    for(auto i : v){

        cerr<<i<<" ";

        c++;

    }

    cerr<<endl;

}

const int N = 1e5 + 2;

const int M = 1e9 + 7;

string s;

int dp[N][13];





void add_self(int &a , int b , int Mod){

    a += b;

    if(a >= Mod){

        a -= Mod;

    }

}

int rec(int pos , int rem ){

    if(pos >= s.size())return rem%13 == 5;

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

    int ans  = 0;

    if(s[pos] == '?'){

        for(int i = 0 ; i < 10; ++i){

            add_self(ans , rec(pos + 1 , (rem * 10 + i)%13) , M);

        }

    }else{

        add_self(ans , rec(pos + 1 , (rem * 10 + s[pos] - '0') % 13),M);

    }

    return dp[pos][rem] = ans;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    //int t; cin>>t;for(;t--;)done();

    cin>>s;

    memset(dp , -1 , sizeof(dp));

    cout<<rec(0 , 0)<<"\n";





}






// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define all(x) (x).begin() , (x).end()

#define rall(x) (x).rbegin() , (x).rend()

#define fi first

#define se second

#define pb push_back

#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);



using namespace std;



template<typename T> void macro_scan(T& t){cin>>t;};

template<typename F, typename ...R>void macro_scan(F& f , R& ...r){

  cin>>f;macro_scan(r...);

}



void deb(){

    cerr<<endl;

}

template<typename T , typename... t>

void deb(T a , t...b){

    cerr<<a<<" ";

    deb(b...);

}

template<typename T>

void dev(vector<T>v){

    int c = 0;

    for(auto i : v){

        cerr<<i<<" ";

        c++;

    }

    cerr<<endl;

}

const int N = 1e5 + 2;

const int M = 1e9 + 7;

string s;

int dp[N][13];





void add_self(int &a , int b , int Mod){

    a += b;

    if(a >= Mod){

        a -= Mod;

    }

}





int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    //int t; cin>>t;for(;t--;)done();

    cin>>s;

    int n = s.size();

    dp[0][0] = 1;

    for(int i = 1 ; i <= n; ++i){

        for(int j = 0 ; j < 13; ++j){

            if(s[i-1]=='?'){

                for(int k = 0 ; k < 10; ++k){

                   add_self( dp[i][(j * 10 + k)%13] , dp[i - 1][j] , M);

                }

            }else{

                add_self(dp[i][(j*10 + s[i - 1] - '0')%13] , dp[i - 1][j] , M);

            }

        }

    }

    cout<<dp[n][5]<<"\n";



}






// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define int long long

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

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

#define pb push_back

#define ALL(obj) (obj).begin(), (obj).end()

#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;

typedef long long ll;

const int MOD = 1000000007;

const double EPS = 1e-9;



signed main(){

  cin.tie(nullptr);

  ios::sync_with_stdio(false);



  string S;

  cin >> S;

  

  vector<int> dp(13);

  dp[0] = 1;



  for (auto c: S) {

    vector<int> dp_nxt(13);

    REP(i, 10) if (c == '?' || c == (char)('0' + i)) {

      REP(d, 13) (dp_nxt[(d * 10 + i) % 13] += dp[d]) %= MOD;

    }

    dp = dp_nxt;

  }

  

  cout << dp[5] << endl;

  return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

static const long long MOD = 1000000007LL;

int n;

char s[100005];

long long unsigned int dp[100005][13];

int main () {

int i, j, ki;

long long unsigned int res = 0;



 scanf("%s", s);

 n = strlen(s);



 dp[0][0] = 1;

 for (i = 0; i < n; i++) {

 int c;

 if (s[i] == '?') c = -1;

 else c = s[i] - '0';



 for (j = 0; j < 10; j++) {

 if (c != -1 && c != j) continue;

 for (ki = 0; ki < 13; ki++) {

 dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];

 }

 }

 for (j = 0; j < 13; j++) dp[i + 1][j] %= MOD;

 }

 res = dp[n][5];



 printf("%llu\n", res);

 return 0;

 }


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define int long long

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

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

#define pb push_back

#define ALL(obj) (obj).begin(), (obj).end()

#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;

typedef long long ll;

const int MOD = 1000000007;

const double EPS = 1e-9;



signed main(){

  cin.tie(nullptr);

  ios::sync_with_stdio(false);



  string S;

  cin >> S;

  int n = S.length();



  vector<int> dp(13);

  dp[0] = 1;

  

  REP(i, n) {

    vector<int> dp_nxt(13);

    int c;

    if (S[i] == '?') c = -1;

    else c = S[i] - '0';



    REP(j, 10) {

      if (c != -1 && c != j) continue;

      REP(ki, 13) {

        (dp_nxt[(ki * 10 + j) % 13] += dp[ki]) %= MOD;

      }

    }

    dp = dp_nxt;

  }



  cout << dp[5] << endl;

  return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

static const long long MOD = 1000000007LL;

int n;

char s[100005];

long long unsigned int dp[100005][13];

int main () {

  int i, j, ki;

  long long unsigned int res = 0;



  scanf("%s", s);

  n = strlen(s);



  dp[0][0] = 1;

  for (i = 0; i < n; i++) {

    int c;

    if (s[i] == '?') c = -1;

    else c = s[i] - '0';



    for (j = 0; j < 10; j++) {

      if (c != -1 && c != j) continue;

      for (ki = 0; ki < 13; ki++) {

        dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];

      }

    }

    for (j = 0; j < 13; j++) dp[i + 1][j] %= MOD;

  }

  res = dp[n][5];



  printf("%llu\n", res);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



string s;

int mod = 1e9 + 7;

int mem[100005][15];

int fact[100005];



int solve(int ind, int rem){

    if(ind == s.size()) return rem == 5;

    int &ret = mem[ind][rem];

    if(~ret) return ret;

    ret = 0;

    if(s[ind] != '?')

        return ret = solve(ind+1, (rem + fact[ind] * (s[ind]-'0')) % 13);



    for(int i=0; i<10; i++){

        ret += solve(ind + 1, (rem + fact[ind] * i) % 13);

        ret %= mod;

    }

    return ret;

}





int main() {

#ifndef ONLINE_JUDGE

//	freopen("input.in", "r", stdin);

//	freopen("output.out", "w", stdout);

#endif

    cin >> s;

    memset(mem, -1, sizeof(mem));

    fact[s.size()-1] = 1;

    for(int i=(int)s.size()-2; i>=0; i--){

        fact[i] = fact[i+1] * 10;

        fact[i] %= 13;

    }

    printf("%d", solve(0, 0));

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#define N 13

#define M 1000000007

#define L 10



char s[111111];

int g[N][L];



int main()

{		

	long long d[2][N] = {1};

	int i, j, x, p0, p1;

	

	for(i = x = 0; i < N; i++, x += L){

		for(j = 0; j < L; j++){

			g[i][j] = (x + j) % N;

		}

	}

	

	scanf("%s", s);

	for(i = 0, p0 = 0, p1 = 1; s[i]; i++, p0 = !p0, p1 = !p1){

		if(s[i] != '?'){

			x = s[i] - 48;

			for(j = 0; j < N; j++){

				d[p1][g[j][x]] = d[p0][j];

			}

		}

		else{

			for(j = 0; j < N; j++) d[p1][j] = 0;

			for(x = 0; x < L; x++){

				for(j = 0; j < N; j++) d[p1][g[j][x]] += d[p0][j]; 

			}

			for(j = 0; j < N; j++) d[p1][j] %= M;

		}

	}

	printf("%lld\n", d[p0][5]);

		

				

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;

const int N = 1e5+5;

const int MOD = 1e9+7;

long long dp[N][15];

int main()

{

    string s;

    cin >> s;

    int n = s.length();

    if (s[0] == '?')

        for (int i = 0; i<10; i++)

            dp[0][i] = 1;

    else

        dp[0][s[0]-'0'] = 1;

    for (int i = 1; i<n; i++)

    {

        if (s[i] == '?')

        {

            for (int j = 0; j<10; j++)

                for (int k = 0; k<13; k++)

                {

                    dp[i][((k*10)+j)%13]+=dp[i-1][k];

                    dp[i][((k*10)+j)%13]%=MOD;

                }

        }

        else

        {

            for (int k = 0; k<13; k++)

            {

                dp[i][((k*10)+(s[i]-'0'))%13]+=dp[i-1][k];

                dp[i][((k*10)+(s[i]-'0'))%13]%=MOD;

            }

        }

    }

    cout << dp[n-1][5];

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#define N 13

#define M 1000000007

#define L 10



char s[111111];

int g[N][L];



int main()

{		

	long long d[2][N] = {1};

	int i, j, x, p0, p1;

	

	for(i = x = 0; i < N; i++, x += L){

		for(j = 0; j < L; j++){

			g[i][j] = (x + j) % N;

		}

	}

	

	scanf("%s", s);

	for(i = 0, p0 = 0, p1 = 1; s[i]; i++, p0 = !p0, p1 = !p1){

		if(s[i] != '?'){

			x = s[i] - 48;

			for(j = 0; j < N; j++){

				d[p1][g[j][x]] = d[p0][j];

			}

		}

		else{

			for(j = 0; j < N; j++) d[p1][j] = 0;

			for(x = 0; x < L; x++){

				for(j = 0; j < N; j++) d[p1][g[j][x]] += d[p0][j]; 

			}

			for(j = 0; j < N; j++) d[p1][j] %= M;

		}

	}

	printf("%lld\n", d[p0][5]);

		

				

	return 0;

}

// Fastest known solution for this problem: