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

#include<iostream>

#include<algorithm>

#include<cstring>

using namespace std;

const int maxn = 2e5;



char s[maxn + 5];

char t[maxn + 5];

char a[maxn + 5];

char b[maxn + 5];

bool flag;



int main(){

	memset(a, '#', sizeof(a));

	memset(b, '#', sizeof(b));

	scanf("%s", s);

	scanf("%s", t);

	int len = strlen(s);

	for(int i = 0; i <= len - 1; i++){

		if(a[s[i] - 'a'] == '#' || a[s[i] - 'a'] == t[i]){

			a[s[i] - 'a'] = t[i];

		}

		else flag = 1;

		if(b[t[i] - 'a'] == '#' || b[t[i] - 'a'] == s[i]){

			b[t[i] - 'a'] = s[i];

		}

		else flag = 1;

		if(flag){

			printf("No\n");

			return 0;

		}

	}

	printf("Yes\n");

	return 0;

}

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

#include <sstream>

#include <algorithm>

#include <cstdio>

#include <math.h>

#include <set>

#include <map>

#include <queue>

#include <string>

#include <string.h>

#include <bitset>

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

#define PER(i,a,n) for(int i=n;i>=a;--i)

#define hr putchar(10)

#define pb push_back

#define lc (o<<1)

#define rc (lc|1)

#define mid ((l+r)>>1)

#define ls lc,l,mid

#define rs rc,mid+1,r

#define x first

#define y second

#define io std::ios::sync_with_stdio(false)

#define endl '\n'

#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

const int P = 1e9+7, INF = 0x3f3f3f3f;

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}

ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}

inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}

//head







const int N = 1e6+10;

char s[N],t[N];

int f[222],n,cnt;

void solve(int x, int y) {

	REP(i,1,cnt) {

		if (s[i]==x) s[i]=y;

		else if (s[i]==y) s[i]=x;

	}

}



int main() {

	scanf("%s%s", s+1, t+1);

	n = strlen(s+1);

	REP(i,1,n) {

		if (f[s[i]]&&f[s[i]]!=t[i]) return puts("No"),0;

		f[s[i]] = t[i];

	}

	REP(i,'a','z') if (f[i]) { 

		s[++cnt]=i;

		t[cnt]=f[i];

	}

	REP(i,1,cnt) if (s[i]!=t[i]) solve(s[i],t[i]);

	REP(i,1,cnt) if (s[i]!=t[i]) return puts("No"),0;

	puts("Yes");

}
















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

using namespace std;

const int maxn=1e5+7;

int num[maxn];

int main()

{

    string stra;

    string strb;

    cin>>stra>>strb;

    int len=stra.size();

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

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

    {

        if(num[stra[i]]==-1)

        {

            num[stra[i]]=strb[i];

        }

        else

        {

            if(num[stra[i]]!=strb[i])

            {

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

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

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

    {

        if(num[strb[i]]==-1)

        {

            num[strb[i]]=stra[i];

        }

        else

        {

            if(num[strb[i]]!=stra[i])

            {

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    cout<<"Yes"<<endl;

    return 0;

}

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

using namespace std;

int fr1[150];

int fr2[130];

int main()

{

   string s,t;

   cin>>s>>t;int y=1;

   map<char,int> mp;

   for(int i=0;i<s.size();i++)

   {

       fr1[s[i]]++;

       fr2[t[i]]++;

       if(fr1[s[i]]!=fr2[t[i]])

       {

           y=0;

           break;

       }

   }

   if(y==0)

    cout<<"No\n";

    else

        cout<<"Yes\n";



}




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

#include<stdlib.h>

#include<string>

using namespace std;

int cnt[30],ans[30],alpha_cnt;//alphabetの個数をカウント

int check_s[300010],check_t[300010];

int main(){

    string s,t;

    cin>>s>>t;

    for(int i=0;i<s.length();i++){

        ans[t[i]-'a']++;

        cnt[s[i]-'a']++;

    }

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

        if(cnt[i]!=0)alpha_cnt++;

        check_s[cnt[i]]++;

        check_t[ans[i]]++;

    }

    bool flag=true;

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

        if(check_s[i]!=check_t[i]){

            flag=false;

            break;

        }

    }

   if(flag)cout<<"Yes"<<endl;

   else cout<<"No"<<endl;



    return 0;

}




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

#include<stdlib.h>

#include<string>

#include<vector>

using namespace std;

int main(){

    string s,t;

    cin>>s>>t;

    int a,b;

    vector<int>start(26,-114514),end(26,-114514);

    for(int i=0;i<s.length();i++){

        a=s[i]-'a';

        b=t[i]-'a';

        if(start[a]!=-114514||end[b]!=-114514){

            if(start[a]!=b||end[b]!=a){

                cout<<"No"<<endl;

                return 0;

            }

        }

        else{

            start[a]=b;

            end[b]=a;

        }

    }

    cout<<"Yes"<<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 fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key



typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<int> vi;

typedef long double ld; 

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

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;



ll a[100001];

ll b[100001];



ll getmin(ll a, ll b)

{

	if(a%b==0) return 0;

	return (((a+b-1)/b)*b - a);

}

int main()

{

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

	int n; cin>>n;

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

	{

		cin>>a[i]>>b[i];

	}

	ll sum = 0;

	for(int i = n - 1; i >= 0; i--)

	{

		a[i]+=sum;

		sum+=getmin(a[i],b[i]);

	}

	cout<<sum<<'\n';

}


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

#include<algorithm>

#include<cstring>

using namespace std;

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

int main()

{

	scanf("%lld",&n);

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

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

	long long t;

	for(long long i=n;i>=1;i--)

	{

		a[i]+=ans;

		long long j;

		for(j=a[i]/b[i];;j++)

			if(j*b[i]>=a[i])

				break;

		t=j*b[i]-a[i];

		ans+=t;

	}

	printf("%lld",ans);

}

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

#include <cstring>

#include <vector>

using namespace std;

const int NICO = 100000 + 10;

typedef long long Long;

Long a[NICO], b[NICO], n;

int main()

{

    cin >> n;

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

    {

        cin >> a[i] >> b[i];

    }

    Long tmp = 0;

    for(int i=n;i>=1;i--)

    {

        a[i] += tmp;

        tmp += (b[i] - a[i]%b[i]) % b[i];

    }

    cout << tmp << endl;

}

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



#define MAXN 100000

int N;

long long A[MAXN+5],B[MAXN+5];



int main(){

    scanf("%d",&N);

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

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

    long long Ans=0;

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

        A[i]+=Ans;

        Ans+=(B[i]-(A[i]%B[i]))%B[i];

    }

    printf("%lld",Ans);

}


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

using namespace std;

typedef long long ll;

const size_t MAX_N = (size_t) 1e5 + 5;

ll a[MAX_N], b[MAX_N];

int main() {

    int n;

    cin >> n;

    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    ll res = 0;

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

        res += (b[i] - (a[i] + res) % b[i]) % b[i];

    cout << res;

}

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



#define MAXN 100000

int N;

long long A[MAXN+5],B[MAXN+5];



int main(){

    scanf("%d",&N);

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

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

    long long Ans=0;

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

        A[i]+=Ans;

        Ans+=(B[i]-(A[i]%B[i]))%B[i];

    }

    printf("%lld",Ans);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
/*  ***  In The Name of God ... ***  */

#include <bits/stdc++.h>



using namespace std ;

 

typedef long long ll ;

typedef long double ld ;





#define int long long

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



template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}

template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}



const int N = ( int ) 1e5 + 10 ;



int n , a [ N ] , b [ N ] ;



int32_t main()                     

{

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

	cin >> n ;

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

		cin >> a [ i ] >> b [ i ] ;

	int added = 0 , res = 0 ;

	for ( int i = n - 1 ; i >= 0 ; -- i ) {

		a [ i ] += added ;

		if ( a [ i ] % b [ i ] == 0 ) continue ; 

		int reach = a [ i ] + ( b [ i ] - ( a [ i ] % b [ i ] ) ) ;

		added += reach - a [ i ] ; 

	}

	cout << added << endl ; 

}


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



#define MAXN 100000

int N;

long long A[MAXN+5],B[MAXN+5];



int main(){

    scanf("%d",&N);

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

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

    long long Ans=0;

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

        A[i]+=Ans;

        Ans+=(B[i]-(A[i]%B[i]))%B[i];

    }

    printf("%lld",Ans);

}


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

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <climits>

#include <ctime>

#include <cassert>

using namespace std;



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

#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)

#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

#define all(v) begin(v), end(v)

#define pb(a) push_back(a)

#define fr first

#define sc second

#define INF 2000000000

#define int long long int



#define X real()

#define Y imag()

#define EPS (1e-10)

#define EQ(a,b) (abs((a) - (b)) < EPS)

#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )

#define LE(n, m) ((n) < (m) + EPS)

#define LEQ(n, m) ((n) <= (m) + EPS)

#define GE(n, m) ((n) + EPS > (m))

#define GEQ(n, m) ((n) + EPS >= (m))



typedef vector<int> VI;

typedef vector<VI> MAT;

typedef pair<int, int> pii;

typedef long long ll;



typedef complex<double> P;

typedef pair<P, P> L;

typedef pair<P, double> C;



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

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

int const MOD = 1000000007;



namespace std {

    bool operator<(const P& a, const P& b) {

        return a.X != b.X ? a.X < b.X : a.Y < b.Y;

    }

}



signed main() {

    int n; cin >> n;

    ll a[100010], b[100010];

    rep(i,0,n) {

        cin >> a[i] >> b[i];

    }

    ll ans = 0;

    repr(i,n-1,0) {

        ll k;

        a[i] += ans;

        if(a[i] == 0) k = 0;

        else if(a[i] < b[i]) k = b[i] - a[i];

        else {

            if(a[i] % b[i] == 0) k = 0;

            else k = b[i] - (a[i] % b[i]);

        }

        // printf("k = %lld\n", k);

        ans += k;

    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;



long long int A[100010], B[100010];

int main() {

    int N; scanf("%d", &N);

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

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

    }



    long long int ofs = 0;

    for(int i=N-1; i>=0; i--) {

        A[i] += ofs;

        if(A[i] == 0) continue;

        if(A[i] <= B[i]) ofs += B[i] - A[i];

        else {

            long long int mo = A[i] % B[i];

            ofs += (B[i] - mo) % B[i];

        }

    }

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

    return 0;

}

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

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

int n,m,x;

const int maxn = 1e5+10;

long long gcd(long long a, long long b){

    return a == 0 ? b : gcd(b % a, a);

}

long long a[maxn],b[maxn];

int main(){

    long long i,j,k;

    long long ans;

    long long now;

    long long comm;

    while(~scanf("%d",&n)){

        ans = 0;

        now = 0;

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

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

        }

        

        for(i=n;i>=1;i--){

            a[i] += ans;

            for(j=a[i]/b[i];;j++){

                if(j*b[i]>=a[i]){

                    break;

                }

            }

            comm = j*b[i] - a[i];

            ans += comm;

        }

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

    }

    

}

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

using namespace std;

const int maxn=1e5+10;

#define LL long long

LL n,ans;

LL a[maxn],b[maxn];

int main()

{

	LL i,j;

    scanf("%d",&n);

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

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

	for(i=n;i>=1;i--)

	{

		a[i] += ans;

		for(j=a[i]/b[i];;j++)

			if(j*b[i]>=a[i])

				break;

		LL comm = j*b[i] - a[i];

		ans += comm;

	}

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

}

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

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

int n,m,x;

const int maxn = 1e5+10;

long long a[maxn],b[maxn];

int main(){

    long long i,j,k;

    long long ans;

    long long now;

    long long comm;

    scanf("%d",&n);

        ans = 0;

        now = 0;

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

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

        }

        

        for(i=n;i>=1;i--){

            a[i] += ans;

            for(j=a[i]/b[i];;j++){

                if(j*b[i]>=a[i]){

                    break;

                }

            }

            comm = j*b[i] - a[i];

            ans += comm;

        }

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

    

    

}

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

using namespace std;

const int maxn=1e5+10;

#define LL long long

LL n,ans;

LL a[maxn],b[maxn];

int main()

{

	LL i,j;

    scanf("%d",&n);

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

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

	for(i=n;i>=1;i--)

	{

		a[i] += ans;

		for(j=a[i]/b[i];;j++)

			if(j*b[i]>=a[i])

				break;

		LL comm = j*b[i] - a[i];

		ans += comm;

	}

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

}

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

#include <cstring>

#include <algorithm>

#include <iostream>

using namespace std;



typedef long long ll;

const int maxn = 100000;



int n;

long long a[maxn], b[maxn];



int main(void) {

	cin >> n;

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

		cin >> a[i] >> b[i];

	}

	long long add = 0;

	for(int i = n-1; i >= 0; --i) {

		a[i] += add;

		if(a[i] % b[i]) {

			add += b[i] - a[i] % b[i];

		}

	}

	cout << add << endl;

	return 0;

}

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

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long li;



const int maxn = 1e5;

int n, a[maxn], b[maxn];



int main(void) {

  scanf("%d", &n);

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

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

  }

  li ans = 0;

  for (int i = n - 1; i >= 0; --i) {

    li cur = a[i] + ans;

    li tar = (cur + b[i] - 1) / b[i] * b[i];

    ans += tar - cur;

  }

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

}


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



using namespace std;



int main()

{

    //freopen("04.txt","r",stdin);

    int mod,n,i,a[100001]={0},b[100001]={0};

    long long tim[100001]={0};

    long long mul,done=0;

    cin>>n;

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

        cin>>a[i]>>b[i];

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

    {

        mod=a[i]%b[i];

        if(mod)

            tim[i]=b[i]-mod;

    }

    for(i=n-2;i>=0;i--)

    {

        if(tim[i]>=tim[i+1])

            continue;

        mul=(tim[i+1]-tim[i])/b[i];

        tim[i]+=mul*b[i];

        if(tim[i]<tim[i+1])

            tim[i]+=b[i];

    }

    done=tim[n-1];

    for(i=n-2;i>=0;i--)

    {

        done+=(long long)(tim[i]-tim[i+1]);

    }

    cout<<done;

    return 0;

}


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

//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;

using namespace std;

typedef long long ll;

//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;

template<class T1, class T2>

ostream &operator <<(ostream &os, pair<T1,T2>&p);

template <class T>

ostream &operator <<(ostream &os, vector<T>&v);

template <class T>

ostream &operator <<(ostream &os, set<T>&v);

#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;

#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)

#define INPUT freopen("input.txt","r",stdin)

#define OUTPUT freopen("output.txt","w",stdout)

#define ERROR  1e-9

#define pi (2*acos(0))

const ll mod = 998244353;

const int N = 2e5 +5;



void SOLVE(int cas)

{

    ll n;

    scanf("%lld",&n);

    vector< pair<ll,ll> >pii(n);

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

    {

        scanf("%lld %lld",&pii[i].first,&pii[i].second);

    }

    ll now =0;

    for(ll i=n-1;i>=0;i--)

    {

        ll ff = pii[i].first + now;

        ll ss = pii[i].second;

        if(ff%ss ==0)

            continue;

        ll d = ff/ss;

        d++;

        now+= ss*d - ff;

    }

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



















}





/*





*/







int main()

{

    //INPUT;

    //OUTPUT;

    int t=1,cas=0;

    //scanf("%d",&t);

    while(t--)

    {

        SOLVE(++cas);

    }



    return 0;

}







//os.order_of_key(v): returns how many elements strictly less than v

//os.find_by_order()



template<class T1, class T2>

ostream &operator <<(ostream &os, pair<T1,T2>&p)

{

    os<<"{"<<p.first<<", "<<p.second<<"} ";

    return os;

}

template <class T>

ostream &operator <<(ostream &os, vector<T>&v)

{

    os<<"[ ";

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

    {

        os<<v[i]<<" " ;

    }

    os<<" ]";

    return os;

}



template <class T>

ostream &operator <<(ostream &os, set<T>&v)

{

    os<<"[ ";

    for(T i:v)

    {

        os<<i<<" ";

    }

    os<<" ]";

    return os;

}


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

using namespace std;

const int maxn = 2e5+10;

typedef long long ll;

ll n, a[maxn];

ll f(ll x){

	ll sum = 0;

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

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

	return sum;

}

int main() {

	cin>>n;

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

		cin>>a[i];

	ll l = -1e9, r = 1e9, ans = -1;

	while(l < r-1){

		ll mid = (l+r)>>1;

		ll mmid = (r+mid)>>1;

		if(f(mid) < f(mmid)) r = mmid;

		else l = mid;

	}

	ans = f(l) > f(r)? r:l;

	cout<<f(ans)<<endl;

	return 0;

}

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

#include<algorithm>

using namespace std;

long long n,a[200005],cnt,f;

int main(){

	scanf("%lld",&n);

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

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

		a[i]-=i;

	}

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

	if(n%2==1)f=a[(n+1)/2];

	else f=a[n/2];

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

		cnt+=abs(a[i]-f);

	printf("%lld",cnt);

}

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

#include<algorithm>

#include<string>

using namespace std;

typedef long long ll;

int n;

ll ans, b;

ll a[200005];

ll f(ll x) { return x > 0 ? x : -x; }

int main()

{

	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;

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

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

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

	for (int i = 1; i <= n; i++)ans += f(a[i] - b);

	cout << ans;

	return 0;

}

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

#include<algorithm>

int n,a[200001];

long long sum=0;

int Abs(int a){return a>0?a:-a;}

using namespace std;

int main(){

	scanf("%d",&n);

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

		scanf("%d",&a[i]);a[i]-=i;

	}

	sort(a,a+n);

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

		sum+=1ll*Abs(a[i]-a[n/2]);

	}

	printf("%lld",sum);

}

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

#include<vector>

#include<algorithm>

using namespace std;

int main(){

	long long int a,b,i,d,res=0;

	

	cin>>a;

	vector<int> c(a);

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

		cin>>c[i];

		c[i]-=i;

	}

	sort(c.begin(),c.end());

	b=c[a/2];

	for(i=0;i<a;i++)res+=abs(c[i]-b);

	cout<<res;

}

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

#include<algorithm>

int n,a[200001];

long long sum=0;

int Abs(int a){return a>0?a:-a;}

using namespace std;

int main(){

	scanf("%d",&n);

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

		scanf("%d",&a[i]);a[i]-=i;

	}

	sort(a,a+n);

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

		sum+=1ll*Abs(a[i]-a[n/2]);

	}

	printf("%lld",sum);

}

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

#include<cstdio>

#include<algorithm>

using namespace std;

#define Min(_A,_B) ((_A)<(_B)?(_A):(_B))

#define Abs(_A) ((_A)>0?(_A):(-(_A)))

#define INF 0x3f3f3f3f



int n;

int a[200005];

void init(){

    scanf("%lld",&n);

    long long sm=0,b;

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

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

        a[i]-=i;

    }

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

    if(n&1){

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

    }else{

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

    }

    long long ans=0;

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

        ans+=Abs(a[i]-b);

    }

    printf("%lld",ans);

}

int main(){

    init();

    return 0;

}

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

#include<algorithm>

int n,a[200001];

long long sum=0;

int Abs(int a){return a>0?a:-a;}

using namespace std;

int main(){

	scanf("%d",&n);

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

		scanf("%d",&a[i]);a[i]-=i;

	}

	sort(a,a+n);

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

		sum+=1ll*Abs(a[i]-a[n/2]);

	}

	printf("%lld",sum);

}

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

#include<algorithm>

#include<cmath>

using namespace std;

int main(){

	long long n,a[200000],i,z=0;

	cin>>n;

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

		cin>>a[i];

		a[i]-=i;

	}

	sort(a,a+n);

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

		z+=abs(a[n/2]-a[i]);

	}

	cout<<z;

}

// Optimized solution to the same problem (faster):
//------(▼皿▼#) fxxk vjudge-------

#include <algorithm>

#include <cstdio>



const int Maxv = 200010; 



int num[Maxv], n; 

long long ans; 



int main() {

    scanf("%d", &n); 

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

        scanf("%d", &num[i]); 

        num[i] -= i + 1; 

    }

    

    std::sort(num, num + n); 

    int tmp = num[(n >> 1)]; 



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

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



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



    return 0; 

}

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

#include<cstdio>

#include<cstring>

#include<climits>

#include<algorithm>

#include<cmath>

#define LL long long 

using namespace std;

const int M=10e5;

LL a[2*M];

int  n;

int main()

{

	while(cin>>n)

	{

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

		{

			scanf("%d",&a[i]),a[i]-=i;

		}

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

	    LL k;

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

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

	    LL sum=0;

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

	    {

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

		}

		cout<<sum<<endl;

	}

}

// Optimized solution to the same problem (faster):
//------(▼皿▼#) fxxk vjudge-------

#include <algorithm>

#include <cstdio>



const int Maxv = 200010; 



int num[Maxv], n; 

long long ans; 



int main() {

    scanf("%d", &n); 

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

        scanf("%d", &num[i]); 

        num[i] -= i + 1; 

    }

    

    std::sort(num, num + n); 

    int tmp = num[(n >> 1)]; 



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

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



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



    return 0; 

}

// Fastest known solution for this problem: