stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.302640232180103x):
#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;

}
// Slower C++ solution:
#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;

		}	

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.316820438974785x):
#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;

}
// Slower C++ solution:
#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);

}


// Faster C++ solution for the same problem (measured speedup: 5.246897708631785x):
#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;

}
// Slower C++ solution:
#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);

}

// Faster C++ solution for the same problem (measured speedup: 5.277557655337247x):
#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;

}
// Slower C++ solution:
#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);

} 

// Faster C++ solution for the same problem (measured speedup: 5.229559911819066x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 3.5040618910966037x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 1.1738385641155071x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.295570548799884x):
#include <cstdio>

using namespace std;



using i64 = long long;



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



i64 dp[100010][13];

const i64 M = 1000000007;

signed main() {

	i64 k = 0;

	dp[0][0] = 1;

	while(true) {

		char c = getchar();

		if (c == '\n') {

			break;

		} else 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;

	}

	printf("%d", dp[k][5]);

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.303698013217471x):
#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();

		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) {

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

				E[r] = s % M;

			}

		}

		swap(D, E);

	}

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

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.344202224929037x):
#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]);

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.2856105616848765x):
#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];

char s[100001];

const i64 M = 1000000007;

signed main() {

	D[0] = 1;

	scanf("%s", s);

	i64 i = 0;

	while(true) {

		char c = s[i];

		if (c == 0) {

			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];

			}

			*/

			E[d] = D[0];

			E[(d + 10) % 13] = D[1];

			E[(d + 7) % 13] = D[2];

			E[(d + 4) % 13] = D[3];

			E[(d + 1) % 13] = D[4];

			E[(d + 11) % 13] = D[5];

			E[(d + 8) % 13] = D[6];

			E[(d + 5) % 13] = D[7];

			E[(d + 2) % 13] = D[8];

			E[(d + 12) % 13] = D[9];

			E[(d + 9) % 13] = D[10];

			E[(d + 6) % 13] = D[11];

			E[(d + 3) % 13] = D[12];

		}

		swap(D, E);

		++i;

	}

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

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.283605211925993x):
#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];

char s[100001];

const i64 M = 1000000007;

signed main() {

	D[0] = 1;

	scanf("%s", s);

	i64 i = 0;

	while(true) {

		char c = s[i];

		if (c == 0) {

			break;

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

			/*

			REP(r, 13) {

				i64 s = 0;

				REP(j, 10) {

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

				}

				E[r] = s % M;

			}

			*/

			E[0] = (D[0] + D[9] + D[5] + D[1] + D[10] + D[6] + D[2] + D[11] + D[7] + D[3]) % M;

			E[1] = (D[4] + D[0] + D[9] + D[5] + D[1] + D[10] + D[6] + D[2] + D[11] + D[7]) % M;

			E[2] = (D[8] + D[4] + D[0] + D[9] + D[5] + D[1] + D[10] + D[6] + D[2] + D[11]) % M;

			E[3] = (D[12] + D[8] + D[4] + D[0] + D[9] + D[5] + D[1] + D[10] + D[6] + D[2]) % M;

			E[4] = (D[3] + D[12] + D[8] + D[4] + D[0] + D[9] + D[5] + D[1] + D[10] + D[6]) % M;

			E[5] = (D[7] + D[3] + D[12] + D[8] + D[4] + D[0] + D[9] + D[5] + D[1] + D[10]) % M;

			E[6] = (D[11] + D[7] + D[3] + D[12] + D[8] + D[4] + D[0] + D[9] + D[5] + D[1]) % M;

			E[7] = (D[2] + D[11] + D[7] + D[3] + D[12] + D[8] + D[4] + D[0] + D[9] + D[5]) % M;

			E[8] = (D[6] + D[2] + D[11] + D[7] + D[3] + D[12] + D[8] + D[4] + D[0] + D[9]) % M;

			E[9] = (D[10] + D[6] + D[2] + D[11] + D[7] + D[3] + D[12] + D[8] + D[4] + D[0]) % M;

			E[10] = (D[1] + D[10] + D[6] + D[2] + D[11] + D[7] + D[3] + D[12] + D[8] + D[4]) % M;

			E[11] = (D[5] + D[1] + D[10] + D[6] + D[2] + D[11] + D[7] + D[3] + D[12] + D[8]) % M;

			E[12] = (D[9] + D[5] + D[1] + D[10] + D[6] + D[2] + D[11] + D[7] + D[3] + D[12]) % M;

		} else {

			i64 d = c - '0';

			/*

			REP(r, 13) {

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

			}

			*/

			E[d] = D[0];

			E[(d + 10) % 13] = D[1];

			E[(d + 7) % 13] = D[2];

			E[(d + 4) % 13] = D[3];

			E[(d + 1) % 13] = D[4];

			E[(d + 11) % 13] = D[5];

			E[(d + 8) % 13] = D[6];

			E[(d + 5) % 13] = D[7];

			E[(d + 2) % 13] = D[8];

			E[(d + 12) % 13] = D[9];

			E[(d + 9) % 13] = D[10];

			E[(d + 6) % 13] = D[11];

			E[(d + 3) % 13] = D[12];

		}

		swap(D, E);

		++i;

	}

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

}