akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int TAM = 1000001;

vector<int> divs, counter(TAM), arr;
int n;

void divsisors(int n){

    for(int i=1; i<=sqrt(n); i++){
        if(n%i==0){
            if(n/i==i) // if divsisors are equal
                divs.push_back(i);
            else { //if divsisors aren't equal
                divs.push_back(i);
                divs.push_back(n/i);
            }
        }
    }
    
}

int main () {
    ios_base::sync_with_stdio(false);

    cin >> n;

    arr.resize(n);

    for(int &i : arr) cin >> i, counter[i]++;

    int ans = 0;

    for(int i : arr){
        divs.clear();
        
        if(counter[i]>1)
            continue;

        divsisors(i);

        int ok = 1;

        for(int j : divs)
            if(counter[j]>0 and j!=i)
                ok = 0;
        
        if(ok) {
            ans++;
            //cout << i << " ";
        }
    }
    //cout << endl;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7908
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int N;
  cin >>N;
  cout << N*(N+1)/2 << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()


# 前からDP
start = S.index("o")
dp1 = [-1] * N
dp1[start] = 1
i = start
while dp1[i] < K:
    tmp = dp1[i]

    i += C
    while i < N:
        i += 1
        if S[i] == "o":
            dp1[i] = tmp + 1
            break

# 後ろからDP
T = S[::-1]
start = T.index("o")
dp2 = [-1] * N
dp2[start] = K
i = start
while dp2[i] > 1:
    tmp = dp2[i]
    i += C
    while i < N:
        i += 1
        if T[i] == "o":
            dp2[i] = tmp - 1
            break
dp2.reverse()

ans = []
for i in range(N):
    if dp1[i] == -1 or dp2[i] == -1:
        continue
    if dp1[i] == dp2[i]:
        ans.append(i + 1)

if ans:
    print(*ans, sep="\n")

Measured memory_bytes: 31912
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}

void solve()
{
	int n;
	cin >> n;
	ll a[n];
	vector<ll> cnt(n + 1, 0);
	for(int i = 1; i <= n; ++i){
		int le = i - 1;
		int ri = n - i;
		cnt[abs(le - ri)]++;
		cin >> a[i];
	}
	ll res = 1;
	for(int i = 1; i <= n; ++i){
		res *= cnt[a[i]];
		res %= mod;
		cnt[a[i]]--;
	}
	cout << res;

}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 4712
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<bitset>
#include<cmath>
#include<complex>

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

// ??§????????°INF
const int INF = (1 << 30);
// ?¨±?????????????????
const double EPS = (1e-10);
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)

int main()
{
	cin.tie(0);
	ios::ios_base::sync_with_stdio(false);
	int D, N;
	vector<int> a(100), e(100), r(100);
	while (true) {
		cin >> D >> N; if (D == 0 && N == 0)break;
		for (int i = 0; i < N; ++i) {
			cin >> a[i] >> e[i] >> r[i];
		}
		vector<vector<int>>dp(D + 1, vector<int>(101, INF));
		dp[D][0] = 0;
		for (int i = D; i >= 0; --i) {
			for (int j = 0; j < 101; ++j) {
				if (dp[i][j] == INF)continue;
				for (int k = 0; k < N; ++k) {
					if (j < r[k])continue;
					int tmp_i = max(0, i - a[k]), tmp_j = min(100, j + e[k]);
					dp[tmp_i][tmp_j] = min(dp[tmp_i][tmp_j], dp[i][j] + 1);
				}
			}
		}
		int ans = INF;
		for (int i = 0; i < 101; ++i)ans = min(ans, dp[0][i]);
		if (ans == INF) {
			cout << "NA" << endl;
			continue;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i=0;i<N;i++) cin >> p[i];

  int ans=0;
  for(int i=0;i<N;i++){
    if(i+1==p[i]){ ans++; i++; }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Text.RegularExpressions;
					
public class Program
{
	public static void Main()
	{
		var S = Console.ReadLine();
		var T = Console.ReadLine();

		//　検索パターンを設定してRegexのインスタンス生成
        	Regex regex = new Regex(S+"[a-z]");

		if(regex.IsMatch(T)){
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
		
	}
}

Measured memory_bytes: 21700
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> A >> B;
  
  cout << max((ll)0, A-2*B) << endl;
  
  
   




}


Measured memory_bytes: 256
#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;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll s,c;
    cin>>s>>c;
    ll ans=0;
    ans+=min(2*s,c-(c&1));
    ans>>=1;
    if(ans==s){
        c-=2*s;
        ans+=(c/4);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	char s;
	cin >> s;
	cout << (char)(s+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;
int A[101][101];

int main(){
  int N;
  cin >> N;
  int cur_sum = 0;
  int ans;
  rep(i, 0, N) cin >> A[0][i];
  rep(i, 0, N){
    cin >> A[1][i];
    cur_sum += A[1][i];
  }
  cur_sum += A[0][0];
  ans = cur_sum;
  
  rep(i, 0, N-1){
    cur_sum = (cur_sum + A[0][i+1] - A[1][i]); 
    ans = max(ans, cur_sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)


using namespace std;
using ll = long long;
using P = pair<int, int>;
const int mod = 998244353;
// auto mod int
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

void Main() {
  int n, s;
  cin >> n >> s;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  mint ans = 0;
  vector<mint> q(s+1);
  rep(i, n) {
    q[0] += 1;
    vector<mint> q2(s+1);
    rep(j, s+1) {
      q2[j] += q[j];
      if (j+A[i] <= s) q2[j+A[i]] += q[j];
    }
    q = q2;
    ans += q[s];
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll n;
	cin >> n;
	n %= 10;
	if (n==2||n==4||n==5||n==7||n==9)
	{
		cout << "hon" << endl;
	}
	else if (n==0||n==1||n==6||n==8)
	{
		cout << "pon" << endl;
	}
	else
	{
		cout << "bon" << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
import java.util.*;

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

        int x = x2000;
        int ans;
        for(int i = 0; i < 10; i++) {
            ans = r*x - D;
            x = ans;
            System.out.println(ans); 
        }
        sc.close();
    }
}

Measured memory_bytes: 23124
n = gets.to_i
ary = gets.split.map(&:to_i)

n.times do |i|
  ary[i] = [ary[i], i]
end

ary = ary.sort_by{|a| a[0]}
ans = []
ary.each do |a|
  ans << a[1] + 1
end

puts ans.join(" ")

Measured memory_bytes: 19160
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
int N, a[MAX], b[MAX];
vector<int> num;

int calc(int i) {
	int sum = 0;
	for(int j = i; j <= N; j += i)
		sum += b[j];
	return sum;
}

int main(int argc, char ** argv) {
	scanf("%d", &N);
	REP(i, 1, N) scanf("%d", &a[i]);
	PER(i, N, 1) {
		int x = calc(i);
		if(x%2 != a[i]) b[i] = 1, num.pb(i);
	}
	printf("%d\n", num.size());
	rep(i, 0, num.size()) printf("%d\n", num[i]);
	return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

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

template<i64 M>
struct modint {
  i64 a;
  constexpr modint(const i64 x = 0) noexcept: a((x % M + M) % M) {}
  constexpr i64 value() const noexcept { return a; }
  constexpr modint pow(i64 r) const noexcept {
    modint ans(1);
    modint aa = *this;
    while(r) {
      if(r & 1) {
        ans *= aa;
      }
      aa *= aa;
      r >>= 1;
    }
    return ans;
  }
  constexpr modint& operator+=(const modint r) noexcept {
    a += r.a;
    if(a >= M) a -= M;
    return *this;
  }
  constexpr modint& operator=(const i64 r) {
    a = (r % M + M) % M;
    return *this;
  }
  constexpr modint& operator-=(const modint r) noexcept {
    a -= r.a;
    if(a < 0) a += M;
    return *this;
  }
  constexpr modint& operator*=(const modint r) noexcept {
    a = a * r.a % M;
    return *this;
  }
  constexpr modint& operator/=(modint r) noexcept {
    i64 ex = M - 2;
    while(ex) {
      if(ex & 1) {
        *this *= r;
      }
      r *= r;
      ex >>= 1;
    }
    return *this;
  }

  constexpr modint operator+(const modint r) const {
    return modint(*this) += r;
  }
  constexpr modint operator-(const modint r) const {
    return modint(*this) -= r;
  }
  constexpr modint operator*(const modint r) const {
    return modint(*this) *= r;
  }
  constexpr modint operator/(const modint r) const {
    return modint(*this) /= r;
  }
};
using fp = modint<(i64)(1e9 + 7)>;
fp dp[110][110][55 * 55 * 3];

int main() {
  i64 N, K;
  cin >> N >> K;

  /* { 
    vector<i64> vec(N);
    rep(i,0,N) vec[i] = i;
    do {
      i64 s = 0;
      rep(i,0,N) {
        s += abs(i - vec[i]);
        cout << vec[i] << " ";
      }
      cout << "= " << s;
      if(s == K) { cout << " here"; }
      cout << endl;
    } while(next_permutation(all(vec)));
  } */

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

  rep(i,0,N) {
    rep(j,0,N + 1) {
      rep(k,0,N * N + 1) {
        // after
        dp[i + 1][j + 1][k + (j + 1) * 2] += dp[i][j][k];
        // after and here
        dp[i + 1][j][k + j * 2] += dp[i][j][k] * fp(j + 1);
        // before
        if(j - 1 >= 0)
          dp[i + 1][j][k + j * 2] += dp[i][j][k] * fp(j);
        // before and here
        dp[i + 1][j - 1][k + (j - 1) * 2] += dp[i][j][k] * fp(j) * fp(j);
      }
    }
  }

  cout << dp[N][0][K].value() << endl;
}


Measured memory_bytes: 289024
#include<stdio.h>
int main(){
        int a,b,c;
        scanf("%d %d %d", &a,&b,&c);
	if(a<b && b<c){
		printf("%d %d %d\n",a,b,c);
	}else if(a>b && b>c){
		printf("%d %d %d\n",c,b,a);
	}else if(a<b && b>c && a<c){
		printf("%d %d %d\n",a,c,b);
	}else if(a<b && b>c && a>c){
		printf("%d %d %d\n",c,a,b);
	}else if(a>b && b<c && a<c){
		printf("%d %d %d\n",b,a,c);
	}else if(a>b && b<c && a>c){
		printf("%d %d %d\n",b,c,a);
	}else if(a<b && b==c){
		printf("%d %d %d\n",a,b,c);
	}else if(a>b && b==c){
		printf("%d %d %d\n",b,c,a);
	}else if(b<a && a==c){
		printf("%d %d %d\n",b,a,c);
	}else if(b>a && a==c){
		printf("%d %d %d\n",c,a,b);
	}else if(c<a && a==b){
		printf("%d %d %d\n",c,a,b);
	}else if(c>a && a==b){
		printf("%d %d %d\n",b,a,c);
	}else if(a<b && a==c){
		printf("%d %d %d\n",c,a,b);
	}else if(a>b && a==c){
		printf("%d %d %d\n",b,c,a);
	}else if(b<a && b==c){
		printf("%d %d %d\n",b,c,a);
	}else if(b>a && b==c){
		printf("%d %d %d\n",a,c,b);
	}else if(c<b && c==a){
		printf("%d %d %d\n",c,a,b);
	}else if(c>b && c==a){
		printf("%d %d %d\n",b,a,c);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;


const int MAXN = 2e3 + 5;
int dis[MAXN];

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    memset(dis, 0, sizeof(dis));
    for (int i = 1; i <= N - 1; ++ i){
        for (int j = i + 1; j <= N; ++ j){
            int d = min(j - i, abs(X-i) + 1 + abs(Y - j));
            ++ dis[d];
        }
    }

    for (int i = 1; i < N; ++ i) cout << dis[i] << endl;
    return 0;
}


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

int main() {
  int h, w;
  cin >> h>> w;
  
  string s;
  rep(i,h) {
    string si; 
    cin >> si;
    s += si;
  }
  
  rep(i,h) {
    rep(j,w) {
      int cnt=0;
      if (s.at(i*w+j) == '#') { 
        cout << '#';
        continue;
      }
      rep(k,3) {
        rep(l,3) {
          if (k-1==0 && l-1==0) { continue; }
          int nh=i+(k-1), nw=j+(l-1);
          if ((0 <= nh and nh < h) and (0 <= nw and nw < w)) {
            if (s.at((nh*w)+nw) == '#') { cnt++; }
          }
        }
      }
      cout << cnt;
    }
    cout << endl; 
  }  
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;


int main()
{
    SAM;
    int l,r,d,count=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            count++;
    }
    cout<<count;
    
    return 0;
}




Measured memory_bytes: 3644
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,a,b;cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }
    else if(b-a==1)
        cout<<min(b-1,n-a)<<endl;
    else{
        ll ans=0;
        ans+=a-1;
        
        ans+=1;
    
        ans+=(b-ans-1)/2;
        ll ans1=0;
        ans1+=n-b;
        ans1+=1;
        ans1+=(n-(a+ans1))/2;
        cout<<min(ans,ans1)<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>

#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define leps(j,n) for(int j=1; j<(n); j++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

#define return(Z) re:(Z)

long long h[10000010],x[10000010],z[10000010];

signed main(){

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

    int n,a;
    cin>>n>>a;

    cout<<(n*n)-a<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    vl c(n);
    rep(i, n) {
        cin >> c[i];
    }
    sort(rall(c));

    ll p = 1;
    rep(i, n-1) {
        p *= 4;
        p %= mod;
    }

    ll ans = 0;
    rep(i, n) {
        ans += c[i]*(i+2);
        ans %= mod;
    }
    ans *= p;
    ans %= mod;

    out(ans);
    re0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int t = scan.nextInt();
		System.out.println(X - t > 0 ? (X - t) : 0);
		scan.close();

	}

}


Measured memory_bytes: 23252
package main

import (
	"container/heap"
	"fmt"
)

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] } // max heap
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	h := &IntHeap{}
	heap.Init(h)

	var num int
	for i := 0; i < n; i++ {
		fmt.Scan(&num)
		heap.Push(h, num)
	}

	var max int
	for i := 0; i < m; i++ {
		max, _ = heap.Pop(h).(int)
		max /= 2
		heap.Push(h, max)
	}

	total := 0
	for h.Len() > 0 {
		n, _ := heap.Pop(h).(int)
		total += n
	}
	fmt.Println(total)
}


Measured memory_bytes: 5504
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	string s, t;
	cin >> s >> t;

	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0])
	{
		ANS("YES");
	}
	else
	{
		ANS("NO");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int a, b;

void solve()
{
    cin >> a >> b;
    nout((a<=9&&b<=9) ? (a*b) : -1);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
int N, a, ch=0;
char S[110];
scanf("%d%s", &N, S);
a=strlen(S)/2;
for(int i=0; i<a; i++){
    if(S[i]==S[a+i]){
    ch+=1;  
    }
}
if(ch == a && ch!=0 && strlen(S) %2 == 0){
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    set<string> s;
    cin >> n;
    int it = 0;
    for(int i = 0; i < n; i++) {
        string str;
        cin >> str;
        if (s.count(str) == 0) it++;
        s.insert(str);
    }

    cout << it;
    return 0;
}


Measured memory_bytes: 19248
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int c[256];
    c['a'] = c['b'] = c['c'] = 0;
    for(int i=0; i<3; i++) c[s[i]]++;
    if (c['a']==1 && c['b']==1 && c['c']==1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main()
{
  ll N;
  ll A[55];
  ll cnts[55] = {};
  
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  ll cnt = 0;
  bool flag = true;
  while(flag) {
    flag = false;
    for(int i = 0; i < N; i++) {
      if((A[i] + cnt - cnts[i]) / N > 0) {
	ll div = (A[i] + cnt - cnts[i]) / N;
	flag = true;
	cnt += div;
	cnts[i] += div;
	A[i] -= div * N;
      }
    }
  }

  cout << cnt << endl;
  
  return (0);
}

    
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  copy_n(istream_iterator<int>(cin), N, A.begin());
  const char* result = "No";
  if (H <= accumulate(A.begin(), A.end(), 0)) {
    result = "Yes";
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 640
def selectionSort(numbers):
    n = len(numbers)
    count = 0
    for i in range(n):
        min_j = i
        for j in range(i + 1, n):
            if numbers[j] < numbers[min_j]:
                min_j = j
        if min_j != i:
            temp = numbers[i]
            numbers[i] = numbers[min_j]
            numbers[min_j] = temp
            count += 1
    return (" ".join(list(map(str, numbers))), count)


def inputInline():
    int(input())
    numbers = list(map(int, input().split(" ")))
    return numbers


result = selectionSort(inputInline())
print(result[0])
print(result[1])

Measured memory_bytes: 7804
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

int main()
{

    int n, tmp, ans = 0;
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        tmp = 0;
        for (int j = 1; j <= n; j++)
        {
            if (i % j == 0 && i % 2 == 1)
            {
                tmp++;
            }
        }
        if (tmp == 8)
        {
            ans++;
        }
    }

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i > 0:
        if a[i] - a[i-1] == 1:
            ans += c[a[i-1]-1]
            
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N;
  set<int> S;
  cin >> N;

  bool flag = true;

  REP(n,N) {
    int A; cin >> A;
    if(!S.insert(A).second) {
      flag = false;
    }
  }

  cout << (flag ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    int a,b,k;
    cin >>a>>b>>k;
    for (int i = 0; i < k; ++i) {
        if(a+i<=b) {
            cout << a + i << endl;
        }
    }
    for (int i = 0; i < k; ++i) {
        if(b-k+i+1>=a+k) {
            cout << b - k + i + 1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  string s;
  long long k,cnt=0,cnt1=0;
  cin>>s>>k;
  int n=s.size();
  string t=s[n-1]+s;
  bool flg=false,flg1=false;
  for(int i=2;i<=n;i++){
    if(t[i]==t[i-1]){
      cnt++;
      if(i==n)flg=true;
      if(t[i]==t[i+1])i++;
    }
  }
  for(int i=1;i<=n;i++){
    if(t[i]==t[i-1]){
      cnt1++;
      if(i==n)flg1=true;
      if(t[i]==t[i+1])i++;
    }
  }

  if(flg){
    cout<<cnt*k<<endl;
  }
  else{
    if(flg1){
      cout<<(cnt+cnt1)*(k/2)+cnt*(k%2)<<endl;
    }
    else{
      cout<<cnt+cnt1*(k-1)<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int X;
	cin >> X;
	puts([&] {
		return X >= 30;
	}() ? "Yes": "No");
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int n,k[1000],p[1000],a[1000],i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>k[i]>>p[i];
		a[i]=k[i]%p[i];
		if(a[i]==0){
			a[i]=p[i];
		}
	}for(i=0;i<n;i++){
		cout<<a[i]<<endl;
	}
    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, R;
    cin >> n >> m >> R;
    vector<int> r(R);
    for (int i = 0; i < R;i++)
        cin >> r[i];
    sort(All(r));
    int d[222][222];
    for (int i = 0; i < 222;i++){
        for (int j = 0; j < 222;j++){
            d[i][j] = mod;
            d[j][j] = 0;
        }
    }
    for (int i = 0; i < m;i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    for (int k = 0; k < n;k++){
        for (int i = 0; i < n;i++){
            for (int j = 0;j<n;j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int res = inf;
    do{
        int dist = 0;
        for (int i = 0; i < R -1; i++)
        {
            dist += d[r[i]-1][r[i + 1]-1];
        }
        res = min(res, dist);
    } while (next_permutation(All(r)));
    cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;

	public static void main(String[] args) {
		int r=sc.nextInt();
		
		p(r*r);
		
		
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    vector<ll>wh;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='W'){
            wh.push_back(i);
        }
    }
    ll ans=0,ju=0;
    for(ll i=0;i<wh.size();i++){
        ans+=wh[i]-ju;
        ju++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5436
#include "bits/stdc++.h"
using namespace std;

int n;
long long ans;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0 or i%5==0) continue;
		ans+=i;
	}
	cout<<ans;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  char s[100010],t[100010];
  int i,j,c=0,m=1e9;
  scanf("%s %s",s,t);
  for(i=0;s[i];i++){
    c=0;
    for(j=0;t[j];j++){
      if(s[i+j]==0&&t[j])goto END;
      if(s[i+j]-t[j])c++;
    }
    if(m>c)m=c;
    //printf("%d\n",m);
  }
  if(m>c)m=c;
 END:;
  printf("%d\n",m);
  return 0;
}
  


Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
int main() {
    string b;
    cin >> b;
    string ans;
    if(b == "A") ans = "T";
    if(b == "C") ans = "G";
    if(b == "G") ans = "C";
    if(b == "T") ans = "A";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
/*int main(void){
    char o[51];
    char e[51];
    scanf("%s %s",o,e);
    int i,leno;
    leno=strlen(o);
    int lene;
    lene=strlen(e);
    if(leno-lene==0){
    for(i=0;i<2*leno;i++){
        if(i%2==0)printf("%c",o[i/2]);
        else printf("%c",e[i/2]);
    }
    }
    else if(leno-lene==1){
        for(i=0;i<2*leno-1;i++){
            if(i%2==0)printf("%c",o[i/2]);
            else printf("%c",e[i/2]);
    }
    }
    printf("\n");
    return 0;
}*/
int main(void){
    char o[51];
    char e[51];
    scanf("%s %s",o,e);
    int i,len;
    len=strlen(o);
    for(i=0;i<len;i++){
        printf("%c",o[i]);
        if(e[i]!='\0')printf("%c",e[i]);
    }
    printf("\n");
    return 0;
    }

Measured memory_bytes: 128
Q = int(input())
MIN, MAX = 10**18, 0
LR = []
for q in range(Q):
    l, r = map(int, input().split())
    MIN = min(MIN, l)
    MAX = max(MAX, r)
    LR.append((l, r))

from math import sqrt
from itertools import accumulate
lis = [0]*(MAX+1)
search = [2] + [i for i in range(2, MAX+1) if i%2!=0]
lim = sqrt(MAX)
prime = set()
while 1:
    n = search[0]
    if n>=lim:
        break
    prime.add(n)
    if (n+1)//2 in prime:
        lis[n] = 1
    search = [i for i in search if i%n!=0]
for s in search:
    prime.add(s)
    if (s+1)//2 in prime:
        lis[s] = 1
clis = list(accumulate(lis))
for l, r in LR:
    print(clis[r]-clis[l-1])


Measured memory_bytes: 64984
/****************************************
/ AUTHOR : ROHAN BAIJAL                  /  
/ ALIAS : rohanblueboybaijal             /
/ INSTITUTE : IIT KANPUR                 /
*****************************************/
//              TEMPLATE                //

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

#define MP make_pair
#define PB push_back
#define ll long long int
#define F first
#define S second
#define MAX(x,y) (x)>(y)?(x):(y)
#define MIN(x,y) (x)<(y)?(x):(y)
#define REP(i,a,n) for(i=a;i<(n);i+=1)
#define REPL(i,a,n) for(i=a;i<=(n); i+=1)
#define REPr(i,n) for(i=n-1;i>=0;i-=1)

typedef vector<ll> vll;
typedef set<int>::iterator sit;
typedef unordered_set<int>::iterator usit;
typedef multiset<int>::iterator msit;
typedef unordered_multiset<int>::iterator umsit;
typedef vector<ll>::iterator vllit;

//cin.ignore(numeric_limits<streamsize>::max(),'\n');


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, i;
    cin>>n;
    ll ans  = 0, H = 0;
    REP(i,0,n) {
        ll x;
        cin>>x;
        if(H>x) ans += (H - x);
        else H = x;
    }
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18 + 100;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, k;

	cin >> n >> k;

	vector<ll> data(n);
	rep(i, 0, n) {
		cin >> data[i];
	}

	ll ans = LINF;


	rep(i, 0, n - k+1) {
		ll left = abs(data[i]) + abs(data[i + k - 1] - data[i]);
		ll right = abs(data[i + k - 1]) + abs(data[i + k - 1] - data[i]);
		
		ans = min(ans, min(right, left));
	}

	cout << ans << endl;
	/*
	ll x;
	ll y;

	bool goodx[110] = { false };
	bool goody[110] = {false};

	string board[110];

	cin >> x >> y;
	rep(i, 0, x) {
		cin >> board[i];
	}
	rep(i, 0, x) {
		rep(j, 0, y) {
			if (board[i][j] == '#') {
				goodx[i] = true;
				goody[j] = true;
			}
		}
	}
	rep(i, 0, x) {
		if (goodx[i] == true) {
			rep(j, 0, y) {
				if (goody[j]) {
					cout << board[i][j];
				}
			}
			cout << endl;
		}
	}*/
	
}
	

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
	A[i] -= (i + 1)
A.sort()
if N % 2 == 0:
	center_num = A[int(N / 2)]
else:
	center_num = A[int((N - 1) / 2)]
ans = 0
for j in A:
	ans += abs(j - center_num)

print(ans)

Measured memory_bytes: 26836