akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int cnt=0;
  for(int i=0; i<sz(s)/2; i++){
    if(s[i]!=s[sz(s)-1-i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

vector<int> s2iv(string str){
  vector<int> res;
  foreach(i,str){
    res.emplace_back(i-'0');
  }
  return res;
}

ll func(string str){
  vector<int> line = s2iv(str);
  vector<ll> dp(11,0);
  ll ans = 0;
  foreach(c,line){
    vector<ll> dp2(11,0);
    rep(i,11){
      int nx = (i*10 + c) % 11;
      dp2[nx] += dp[i];
    }
    if(c){
      ++dp2[c];
    }
    ans += dp2[0];
    dp = dp2;
  }
  return ans;
}

int main(){
  string str;
  while(true){
    str = in<string>();
    if(str=="0")break;
    cout << func(str) << endl;
  }
  return 0;
}



Measured memory_bytes: 3872
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  string s; in(s);
  int n = s.size();
  ll p = 2019;
  reverse(s.begin(), s.end());
  ll rem = 0;
  ll ten = 1;
  vector<ll> C(p+1, 0);
  C[rem]++;
  loop(i,0,n) {
    ll d = s[i]-'0';
    rem = (rem + (d * ten)) % p;
    C[rem]++;
    ten = (ten * 10) % p;
  }
  
  ll ans = 0;
  loop(i,0,p) {
    ans += (C[i]*(C[i]-1)) / 2;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 3704
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }
bool solve(vector<int>A, vector<int>B) {
	int N = A.size();
	auto a = A, b = B;
	sort(all(a)); sort(all(b));
	bool f = true;
	rep(i, 0, N) {
		if (a[i] > b[i])f = false;
	}
	if (not f) {
		return false;
	}
	f = false;
	rep(i, 0, N - 1) {
		if (b[i] >= a[i + 1]) {
			f = true;
		}
	}
	if (f) {
		return true;
	}
	vector<pii>w;
	rep(i, 0, N) {
		w.eb(B[i], A[i]);
	}
	sort(all(w));
	rep(i, 0, N) {
		A[i] = w[i].second;
		B[i] = w[i].first;
	}
	vector<pii>v;
	rep(i, 0, N) {
		v.eb(A[i], i);
	}
	sort(all(v));
	vector<int>P(N);
	rep(i, 0, N) {
		P[v[i].second] = i;
	}
	vector<int>visited(N);
	int cnt = 0, cur = 0;
	while (not visited[cur]) {
		visited[cur] = 1;
		cnt++;
		cur = P[cur];
	}
	dump(cnt);
	return cnt != N;
}


signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	vector<int>B(N); rep(i, 0, N) { cin >> B[i]; }

	Yes(solve(A, B));


	return 0;
}


Measured memory_bytes: 9584
#include <iostream>
using namespace std;

int main() {

	int H, W;
	char a[110][110];

	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {

			cin >> a[i][j];

		}
	}

	for (int j = 0; j <= W + 1; j++) {

		a[0][j] = '#';
		a[H + 1][j] = '#';

	}
	for (int i = 1; i <= H; i++) {

		a[i][0] = '#';
		a[i][W + 1] = '#';

	}
	
	for (int i = 0; i <= H + 1; i++) {
		for (int j = 0; j <= W + 1; j++) {

			cout << a[i][j];

		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

#define INF (1LL<<62)

using namespace std;

typedef long long ll;

ll g[101][101],n,m;

ll rec(set<int> S,int mx){
  
  if(mx<0)return 0;

  ll res=0;
  set<int>::iterator it=S.begin();
  for(;it!=S.end();it++){
    set<int>::iterator j=S.begin();
    ll t=INF;
    for(;j!=S.end();j++){
      if(it==j)continue;
      t=min(t,g[*it][*j]);
    }
    res+=t;
  }
  
  if(mx>=n-1)return res;

  int id=-1;
  ll cost=0;
  for(int v=mx+1;v<n;v++){
    if(S.count(v))continue;

    bool fg=true;
    set<int>::iterator it=S.begin();
    for(;it!=S.end();it++){
      fg&=(g[v][*it]<INF);
    }
    if(!fg)continue;
    /*
    ll tmp=INF;
    it=S.begin();
    for(;it!=S.end();it++){
      tmp=min(tmp,g[v][*it]);
    }
    //    if(cost<tmp)cost=tmp,id=v;
    */
    set<int>T=S;
    T.insert(v);
    cost=max(cost,rec(T,v));
  }
  
  //S.insert(id);
  return max(res,cost);
  //return max(rec(S,id),res);
}

int main(void){

  fill(g[0],g[101],INF);
  for(int i=0;i<101;i++)g[i][i]=0;

  cin >> n >> m;

  for(int i=0;i<m;i++){
    ll a,b,f;
    cin >> a >> b >>f;
    g[a-1][b-1]=g[b-1][a-1]=f;
  }
  
  ll ans=0;

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(g[i][j]<INF){
	set<int>S;
	S.insert(i);
	S.insert(j);
	ans=max(ans,rec(S,max(i,j)));
      }
    }
  }

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

Measured memory_bytes: 1284
P[100];M(int*a){return*1[&a]-*a;}main(n,i,p,d){for(;~scanf("%d",&n);printf("%d\n",p)){for(i=n;p=d=i--;)scanf("%d",P+i);for(qsort(P,i=n,4,M);i--;)p+=d+=P[i];}}

Measured memory_bytes: 0
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
let [H, W, M] = lines[0].split(' ').map(Number)

const h = Array(H + 1).fill().map((_, i) =>  [0, i])
const w = Array(W + 1).fill().map((_, i) =>  [0, i])

const b = {}

for (let i = 1; i <= M; i++) {
    const p = lines[i].split(' ').map(Number)
    h[p[0]][0]++
    w[p[1]][0]++
    b[p[0] + ':' + p[1]] = 1
}

h.sort((a, b) => b[0] - a[0])
w.sort((a, b) => b[0] - a[0])

const hm = h[0][0]
const hp = []
for (let i = 0; i <= H; i++) {
    if (h[i][0] === hm) {
        hp.push(h[i][1])
    } else {
        break
    }
}

const wm = w[0][0]
const wp = []
for (let i = 0; i <= H; i++) {
    if (w[i][0] === wm) {
        wp.push(w[i][1])
    } else {
        break
    }
}

let c = 1
for (let i = 0; i < hp.length; i++) {
    for (let j = 0; j < wp.length; j++) {
        const index = hp[i] + ':' + wp[j]
        if (!b[index]) {
            c = 0
            break
        }
    }
    if (c === 0) break
}
console.log(hm + wm - c)


Measured memory_bytes: 201576
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

long long modPow(long long a, long long x, long long p) {
    long long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

long long modInverse(long long a, long long p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}

long long modFactorial(long long a, long long p) {
    long long fact = 1;
    for (long long i=2; i<=a; i++) {
        fact *= i;
        fact %= p;
    }
    return fact;
}

long long combination(long long n, long long k, long long p) {
    // calculates C(n,k) mod p (assuming p is prime).

    long long numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    long long denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}


class DBouquet {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll n, a, b;
        in >> n >> a >> b;
        ll answer = 0;
        answer += modPow(2, n, MOD);
        answer = (answer + MOD) - 1;
        answer %= MOD;
        answer = answer + MOD - combination(n, a, MOD);
        answer %= MOD;
        answer = answer + MOD - combination(n, b, MOD);
        answer %= MOD;
        out << answer << endl;
    }
};


signed main() {
    DBouquet solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    string s;
    cin >> N;
    if (N % 1000 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1000 - (N % 1000);
    }
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
    int N[100];
    int x,flag,t,c=0;
    
    scanf("%d",&x);
    for(int i=0;i<x;i++){
        scanf("%d",&N[i]);
    }
	
	flag=1;
	while(flag==1){
		flag=0;
		for(int j=x-1;j>0;j--){
			if(N[j] < N[j-1]){
				t=N[j];
				N[j]=N[j-1];
				N[j-1]=t;
				c++;
				flag=1;
			}
		}
	}
	
	printf("%d",N[0]);
    for(int i=1;i<x;i++){
        printf(" %d",N[i]);
    }
	printf("\n");
	printf("%d\n",c);
	
    return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int A,P;
  cin >> A >> P;
  cout << (A * 3 + P) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=eval('list(input()),'*n)
if all(t.count('#')<1for t in a):
  print(-1)
  exit()
f=sum(n==t.count('#')for t in zip(*a))
c=10**18
for i,b in enumerate(a):
  v=b.count('#')
  t=0
  if b[i]!='#':
    for j in range(n):
      if a[j][i]=='#':
        break
    else:
      t+=1
    t+=n-v
  else:
    t+=n-v
  c=min(c,t+n-f)
print(c)

Measured memory_bytes: 5808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  if(S=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(S=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else{
    cout<<"Sunny"<<endl;
  }
}


Measured memory_bytes: 3604
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main() {
  int n,x; cin >> n >> x;
  vector<int>m(n);
  rep(i,n) cin >> m[i];
  sort ( m.begin(), m.end() );
  int g = 0;
  rep(i,n) g += m[i];
  int h = 0;
  h = (x-g)/m[0];
  cout << n+h << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())


def max2(s):
    return max(map(lambda c: ord(c) - ord('a'), s))


ans = ['a']
for _ in range(n - 1):
    ans2 = []
    for a in ans:
        for i in range(max2(a) + 2):
            ans2.append(a + chr(i + ord('a')))
    ans = ans2

for a in ans:
    print(a)


Measured memory_bytes: 12984
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, m;
int num;
int head[100010], to[300010], nxt[300010], ind;
inline void addedge (int u, int v) { ind++, to[ind] = v, nxt[ind] = head[u], head[u] = ind; }
int cnt, root[100010];
struct T { int num, ch[2]; } t[6000010];
inline void build_tree (int p, int l, int r) {
	t[p].num = 0;
	if (l == r) return;
	int mid = (l + r) >> 1;
	t[p].ch[0] = ++cnt;
	build_tree (cnt, l, mid);
	t[p].ch[1] = ++cnt;
	build_tree (cnt, mid + 1, r);
}
inline int add (int p, int l, int r, int x) {
	if (l == r) { cnt++, t[cnt] = t[p], t[cnt].num++; return cnt; }
	int mid = (l + r) >> 1;
	int pos = ++cnt;
	t[pos] = t[p]; t[pos].num++;
	if (x <= mid) t[pos].ch[0] = add(t[p].ch[0], l, mid, x);
	else t[pos].ch[1] = add (t[p].ch[1], mid + 1, r, x);
	return pos;
}
int ans[100010];
inline int query (int p, int l, int r, int ll, int rr) {
	if (l >= ll && r <= rr) return t[p].num;
	int mid = (l + r) >> 1;
	int res = 0;
	if (ll <= mid) res += query (t[p].ch[0], l, mid, ll, rr);
	if (rr > mid) res += query (t[p].ch[1], mid + 1, r, ll, rr);
	return res;
}
int main () {
	scanf ("%d%d", &n, &m);
	root[0] = 1; cnt = 1; build_tree (1, 1, m);
	for (int i = 1; i <= n; i++) {
		int l, r;
		scanf ("%d%d", &l, &r);
		if (l == 0) num++, n--, i--;
		else addedge (l, r);
	}
	for (int i = 1; i <= m; i++) {
		root[i] = root[i - 1];
		for (int e = head[i]; e; e = nxt[e]) {
			int v = to[e];
			root[i] = add (root[i], 1, m, v);
		}
	}
	for (int i = 2; i <= m; i++)
		for (int j = i; j <= m; j += i)
			ans[i] += query (root[j], 1, m, j, m) - query (root[j - i], 1, m, j, m);
	printf ("%d\n", n + num);
	for (int i = 2; i <= m; i++) printf ("%d\n", ans[i] + num);
	return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>

	int main(){
	
	int a,b,c,x,y,z,X,Y;
		
		while( scanf("%d",&a) != EOF){
			scanf("%d",&b);
			if(a>=b){
				x=a;
				y=b;
			}
			else if(a<b){
				x=b;
				y=a;
			}
			
			X=x;
			Y=y;
			
			while(1){
				c=x%y;
				x=y;
				y=c;
				if(y==0){
					z=a/x*b;
					printf("%d %d\n",x,z);
					break;
				}
			}
		}
	
	return 0;
}

Measured memory_bytes: 596
N = int(input())
ans = 0
if(N < 10):
    ans = N
elif(N < 1000):
    ans = 9 + max(N - 100 + 1, 0)
elif(N < 100000):
    ans = 9 + 900 + max(N - 10000 + 1, 0)
else:
    ans = 90909
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n;
    cin >> n;
    map<string,int>ma;
    for(int i=0;i<n;i++){
        string s;
        cin >>s;
        if(ma.count(s))continue;
        ma[s]=1;
    }
    ll ans = ma.size();
    cout<<ans<<endl;
}
    



Measured memory_bytes: 19236
#include<iostream>
#include<array>
#include<algorithm>

int main() {
	int n;
	std::array<int, 4> ar;

	for (int& x:ar){
		std::cin >> x;
	}

	for (int i = 0; i < ar[3]; i++) {
		int buf = 0;
		for (int j = 0; j < ar.size() - 1; j++) {
			if (buf < ar[j]) {
				buf = ar[j];
				n = j;
			}
		}
		ar[n] *= 2;
	}

	std::cout << ar[0] + ar[1] + ar[2] << std::endl;

	return 0;
}

Measured memory_bytes: 256
N, K, L = [int(_) for _ in input().split()]


def find(a, x):
    if a[x] != x:
        a[x] = find(a, a[x])
    return a[x]


def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    if x != y:
        a[x] = min(x, y)
        a[y] = a[x]


a_road = [i for i in range(N)]
for _ in range(K):
    p, q = [int(_) - 1 for _ in input().split()]
    unite(a_road, p, q)
a_railway = [i for i in range(N)]
for _ in range(L):
    r, s = [int(_) - 1 for _ in input().split()]
    unite(a_railway, r, s)
memo = {}
for i in range(N):
    memo[find(a_road, i), find(a_railway, i)] = memo.get(
        (find(a_road, i), find(a_railway, i)), 0) + 1

print(' '.join(str(memo[a_road[i], a_railway[i]]) for i in range(N)))


Measured memory_bytes: 55056
#include <iostream>
using namespace std;


int main()
{
	int N;
	cin >> N;

	N = N % 10;

	if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon";
	}
	else if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
		cout << "hon";
	}
	else {
		cout << "bon";
	}

}

Measured memory_bytes: 3600
from numpy import int32, searchsorted

N, *AB = map(int, open(0).read().split())
A, B = int32(AB[:N]), int32(AB[N:])

state = 1 << 28
mask = 2 * state - 1
ans = 0
while state:
    A &= mask
    B &= mask
    A.sort()
    B.sort()

    a, b, c = (searchsorted(B, i * state - A).sum() for i in range(1, 4))
    M = a + (c - b)
    if (N - M) % 2 == 1:
        ans += state

    state >>= 1
    mask >>= 1

print(ans)

Measured memory_bytes: 56272
#include<iostream>
using namespace std;

int main()
{
	int n,m,i,j,k=0;	// n は太郎のカードの枚数，m は花子のカードの枚数
	int ANSn[1000];	//i,jは繰り返しに使う変数、kは答えを入れる配列のための変数
	int ANSm[1000];
	for(i=0;i<100;i++) ANSn[i]=ANSm[i]=101;

	while(1){
		int Sn[100]={0};	//Snは太郎のカードの数字
		int Sm[100]={0};
		int SUMn=0,SUMm=0,gap=0;//SUMnは太郎のカードの数字の合計、gapは（太郎）−（二人の平均

		cin>>n>>m;
		for(i=0;i<n;i++) cin>>Sn[i];
		for(i=0;i<m;i++) cin>>Sm[i];

		for(i=0;i<n;i++) SUMn+=Sn[i];
		for(i=0;i<m;i++) SUMm+=Sm[i];
		if((SUMn+SUMm)%2==1){	//2人の合計が奇数のときは絶対に等しくならないので答えは-1
			ANSn[k]=-1;
			ANSm[k]=-1;
		}else{
			gap=SUMn-((SUMn+SUMm)/2); //太郎と花子でいくつ差があるカードを交換すればよいか
			for(i=0;i<n;i++){
				for(j=0;j<m;j++){
					if(Sn[i]-Sm[j]==gap && ANSn[k]+ANSm[k]>Sn[i]+Sm[j]){		
						ANSn[k]=Sn[i];
						ANSm[k]=Sm[j];
					}
				}
			}
			if(ANSn[k]==101){		//答えがなかった場合
				ANSn[k]=-1;
				ANSm[k]=-1;
			}
		}
		k++;
		if(n==0 && m==0) break;
	}

	for(i=0;i<k-1;i++){
		if(ANSn[i]==-1){
			 cout<<"-1"<<endl;
		}else{
			cout<<ANSn[i]<<" "<<ANSm[i]<<endl;
		}
	}
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e5+9;
const int mod=10000;
const double ep=1e-7;
using namespace std;
const double pi=acos(-1);
int main()
{
	double n;
	scanf("%lf",&n);
	printf("%.20f\n",2*pi*n);
}

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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

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

    long long n;
    cin >> n;

    vector<vector<long long>> v(10, vector<long long>(10, 0));

    for (int i = 0; i < 10; i++) {
        if (i <= n) {
            v[i][i]++;
        }
    }

    for (int i = 10; i <= n; i++) {
        int b = i % 10;
        string t = to_string(i);
        int a = t[0] - '0';

        if (a != 0 && b != 0) {
            v[a][b]++;
        }
    }

    long long cnt = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            cnt += v[i][j] * v[j][i];
        }
    }

    cout << cnt << endl;
}

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

// Binary Indexed Tree (BIT)
// Verified: AOJ DSL_2_B: Range Sum Query (int??????)

template <typename T>
struct BIT{
private:
    vector<T> array;
    const int n;

public:
    // ?????????
    BIT(int _n) : array(_n + 1, 0), n(_n) {}

    // 1???????????? i???????????§????´???????????±???????
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;      // LSB ??????
        }
        return s;
    }

    // [i, j] ???????´??????????
    T sum(int i, int j) {
        T ret_i = sum(i-1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // i ????????? ????´? x ?????????
    void add(int i, T x) {
        while(i <= n) {
            array[i] += x;
            i += i & -i;      // LSB ??????
        }
    }
};

signed main() {
    int n; cin >> n;
    BIT<int> b(n);
    vector<int> a(n);
    map<int, int> m;
    rep(i,0,n) {
        cin >> a[i];
        m[a[i]];
    }

    int newnum = 1;
    for(auto &x : m) x.second = newnum++;
    rep(i,0,n) a[i] = m[a[i]];

    int ans = 0;
    rep(j,0,n) {
        ans += j - b.sum(a[j]);
        b.add(a[j], 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18380
#include <stdio.h>

typedef struct{
  int n;
  char c;
  int status;
} Card;

void swap(Card *,Card *);
int partition(Card *,int,int);
void Quicksort(Card *,int,int);
int isStable(Card *,int);

int main(int argc, char const *argv[]) {

  int i;
  int num;
  int p = 0;
  Card A[100001];

  scanf("%d",&num);

  for( i = 0 ; i < num ; i++ ){
    scanf(" %c %d",&A[i].c,&A[i].n);
    A[i].status = i;
  }

  Quicksort(A,p,num-1);

  if( isStable(A,num) ){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }



  for( i = 0 ; i < num ; i++ ){
    printf("%c %d\n",A[i].c,A[i].n);
  }

  return 0;
}

void Quicksort(Card *A, int p, int r){

  int q;

  if( p < r ){
      q = partition(A,p,r);
      Quicksort(A,p,q-1);
      Quicksort(A,q+1,r);
  }

}



int partition(Card *A, int p, int r){

  int x;
  int i,j;

  x = A[r].n;
  i = p-1;

  for( j = p ; j < r ; j++ ){
    if( A[j].n <= x ){
      i++;
      swap(&A[i],&A[j]);
    }
  }

  swap(&A[i+1],&A[r]);

  return i+1;

}

int isStable(Card *A,int n){
  int i;
  for( i = 1 ; i < n ; i++ ){
    if( A[i-1].n == A[i].n ){
      if( A[i-1].status > A[i].status ){
        return 0;
      }
    }
  }
  return 1;
}

void swap(Card *x, Card *y){

  Card temp;

  temp = *x;
  *x = *y;
  *y = temp;

}

Measured memory_bytes: 1780
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=500;

int n;
int Icst[N+3][N+3];
ll Esum1[N+3][N+3],Esum2[N+3][N+3],Ef[N+3][N+3];

ll Calc1(int La,int Ra,int Lb,int Rb){
	if(La>Ra || Lb>Rb) return 0;
	return Esum1[Ra][Rb]-Esum1[Ra][Lb-1]-Esum1[La-1][Rb]+Esum1[La-1][Lb-1];
}
ll Calc2(int La,int Ra,int Lb,int Rb){
	if(La>Ra || Lb>Rb) return 0;
	return Esum2[Ra][Rb]-Esum2[Ra][Lb-1]-Esum2[La-1][Rb]+Esum2[La-1][Lb-1];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)
				scanf("%d",&Icst[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			Esum1[i][j]=Esum1[i-1][j]+Esum1[i][j-1]-Esum1[i-1][j-1]+(i>j? Icst[i][j]:0);
			Esum2[i][j]=Esum2[i-1][j]+Esum2[i][j-1]-Esum2[i-1][j-1]+(i<j? Icst[i][j]:0);
		}
	n++;
	memset(Ef,0x3f,sizeof Ef);
	const ll INF=Ef[0][0];
	ll Vans=INF;
	Ef[0][0]=0;
	for(int i=1;i<n;i++)
		for(int j=0;j<i;j++){
			for(int k=0;k<=j;k++)
				Ef[i][j]=min(Ef[i][j],Ef[j][k]+Calc1(i+1,n-1,k+1,j)+Calc2(j+1,i,j+1,i));
			if(i==n-1)
				Vans=min(Vans,Ef[i][j]);
		}
	printf("%lld\n",Vans);
	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
 int l;
 int r;
 int x = 0;
  
 cin >> n; 
  
  for(int i = 0; i < n; i++){
  	cin >> l >> r;
    x += r - l + 1;
  }
  cout << x << endl;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(3 * n);
	rep(i, 3 * n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	ll sum = 0;
	REP(i, n) {
		sum += a[2 * i - 1];
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	int la=0;
	int ma=0;
	for(int i=0;i<a;i++){
		if(i+1<a&&p[i]==p[i+1]){
			la=ma;ma=p[i];p[i+1]=-1;
		}
	}
	long long ret=(long long)la*ma;
	printf("%lld\n",ret);
}

Measured memory_bytes: 512
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
 
const int N = 3e3 + 5;
long long dp[N][N][2];
int n, a[N];
 
inline void readInput() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
}
 
inline void solve() {
	for (int i = n - 1; ~i; i--)
		for (int j = i; j < n; j++) {
			dp[i][j][0] = max(dp[i][j - 1][1] + a[j], dp[i + 1][j][1] + a[i]);
			dp[i][j][1] = min(dp[i][j - 1][0] - a[j], dp[i + 1][j][0] - a[i]);
		}
	cout << dp[0][n - 1][0] << endl;
}
 
int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


Measured memory_bytes: 139648
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] A = nextIntArray(sc, N + 1);
		int[] B = nextIntArray(sc, N);

		sc.close();

		long ans = 0;

		for (int i = 0; i < N; i++) {
			if (A[i] >= B[i]) {
				//iの街のモンスターのみ倒す
				ans += B[i];

			} else {
				//iの街のモンスターを倒したあと、余力でi+1の街のモンスターを倒す
				ans += A[i];
				B[i] -= A[i];

				ans += Math.min(A[i + 1], B[i]); //i+1のモンスターの数 と 余力の小さいほうを倒した数に加算
				A[i + 1] = Math.max(A[i + 1] - B[i], 0);

			}
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 64568
import numpy as np

a, b, x = map(int, input().split())

bottom = 2 * x / a**2 - b

if bottom == b:
    print(0)

else:    
    if bottom > 0:
        tan =  a / (b -  bottom)

    else:
        bottom = 2 / (a * b) * x
        tan = bottom / b

    theta = np.arctan(tan)
    ret = 90 - np.rad2deg(theta)

    print(ret)

Measured memory_bytes: 12488
#include <iostream>
using namespace std;
int main(void){
    int i,x;
    i=0;
    cin>>x;
    while(x != 0){
       if (x != 0){
           i++;
       }
       if (x == 0){
           break;
       }
           cout<<"Case "<<i<<":"<<" "<<x<<endl;
           cin>>x;
    }
    return 0;
}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define N 100002
using namespace std;

int n, h[N], dp[N];

int main() {
	cin>>n;
	for (int i=0; i<n; i++) cin>>h[i];
	dp[0]=0, dp[1]=abs(h[1]-h[0]);
	for (int i=2; i<n; i++) {
		dp[i] = min(
			dp[i-1]+abs(h[i-1]-h[i]),
			dp[i-2]+abs(h[i-2]-h[i])
		);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
l = []
 
for _ in range(n):
    a = int(input())
    l.append(a)

l.sort()

ans = 0
cnt = 1
tmp = l[0]
for i in range(1,len(l)):
    if tmp == l[i]:
        cnt += 1
        tmp = l[i]
    else:
        if cnt%2 != 0:
            ans += 1
            cnt = 1
            tmp = l[i]
        else:
            cnt = 1
            tmp = l[i]
if cnt%2 != 0:
    ans += 1

print(ans)

Measured memory_bytes: 50392
const main = (input) => {
  const args = input.trim().split("\n");
  const Ai = args[1]
    .trim()
    .split(" ")
    .map((n) => parseInt(n, 10));

  const MAX = 10 ** 6;
  const checkMarks = new Array(MAX + 1).fill(0);
  for (const a of Ai) {
    if (checkMarks[a] !== 0) {
      checkMarks[a] = 2;
      continue;
    }
    for (const i of checkMarks.keys()) {
      const position = (i + 1) * a;
      if (position > MAX) break;
      checkMarks[position] += 1;
    }
  }

  const isNotDivided = (n) => checkMarks[n] === 1;
  const answer = Ai.filter(isNotDivided).length;

  console.log(answer);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 66884
#include <iostream>;
#include <string>

using namespace std;

int main(void) {
  int n;
  cin >> n;
  string str[n];
  int count[4] = {0, 0, 0, 0};
  for (int i=0; i<n; i++) {
    cin >> str[i];
    if (str[i] == "AC")
      count[0]++;
    else if (str[i] == "WA")
      count[1]++;
    else if (str[i] == "TLE")
      count[2]++;
    else if (str[i] == "RE")
      count[3]++;
  }
  
  cout << "AC x " << count[0] << endl;
  cout << "WA x " << count[1] << endl;
  cout << "TLE x " << count[2] << endl;
  cout << "RE x " << count[3] << endl;
  
  return 0;
}

Measured memory_bytes: 6716
#include <algorithm>
#include <iostream>

int main(int argc, char *argv[]) {
  long a, b, c, d;
  std::cin >> a >> b >> c >> d;
  long ans = a * c;
  ans = std::max(a * d, ans);
  ans = std::max(b * d, ans);
  ans = std::max(b * c, ans);

  std::cout << ans << std::endl;
}


Measured memory_bytes: 3192
#include<iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    switch(n%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9: cout << "hon\n"; break;
        case 0:
        case 1:
        case 6:
        case 8: cout << "pon\n"; break;
        case 3: cout << "bon\n"; break;
    }
return 0;
}

Measured memory_bytes: 3588
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	int n;
	cin>>n;
	
	vector<int>vec(n);
	for(int &x: vec) cin>>x;
	
	for(int i=0;i<n;i++) vec[i]-=(i+1);
	
	sort(vec.begin(),vec.end());
	
	debug(vec);
	
	if(n%2)
	{
		int x=vec[n/2];
		for(int i=0;i<n;i++) vec[i]-=x;
	}
	else
	{
		int x=vec[n/2-1]+vec[n/2];
		x/=2;
		for(int i=0;i<n;i++) vec[i]-=x;
	}
	
	debug(vec);
	
	ll ans=0;
	
	for(int x: vec) ans+=abs(x);
	
	cout<<ans;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 3936
using System;

namespace AGC027A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int N = int.Parse(input1[0]);
            int x = int.Parse(input1[1]);

            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(a); //昇順に並び替え
            int ans = 0; //喜ぶ子供の人数

            for(int i = 0; i < N && x >= a[i]; i++)
            {
                x -= a[i];
                ans++;
            }
            //お菓子を余らせてはいけない、ans==Nでお菓子余っているときは1人に余りを渡さないといけない
            if (ans == N && x > 0)
            {
                ans--;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

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

    if(m%n == 0){
        cout << m/n << endl;
        return 0;
    }
    ll mx = (ll)m/n;

    // vector<ll> div;
    ll ans = 1;
    for(ll i = 2; i <= m/n; i++){
        if(m%i == 0)ans = i;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
n,m = map(int, input().split())
h = list(map(int, input().split()))

ref = [1 for i in range(n)]
for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] <= h[b-1]:
    ref[a-1] = 0
  if h[a-1] >= h[b-1]:
    ref[b-1] = 0

print(sum(ref))

Measured memory_bytes: 20112
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int n;
    cin >> n;
    multiset<string> store;
    char e;
    rep(i, n){
        string s;
        cin >> s;
        store.emplace(s);
        if(i == 0) {
            e = s.back();
            continue;
        }
        if(e != s.front() || store.count(s)>1){
            cout << "No" <<endl; return 0;
        }
        e = s.back();
    }
    cout << "Yes" <<endl;
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

int main(){
  int sn,tn,count=0,i,j,t;
  int s[10000];
  scanf("%d",&sn);
  for(i=0;i<sn;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&tn);
  for(i=0;i<tn;i++){
    scanf("%d",&t);
    for(j=0;j<sn;j++){
      if(s[j]==t){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long N, M;
vector<vector<int>> G;
vector<long long> dp;

long long dfs(int cur, int prv){
    if(dp[cur] != 0) return dp[cur];
    long long ans = 1;
    for(int nxt : G[cur]){
        if(nxt == prv) continue;
        ans *= 1 + dfs(nxt, cur);
        ans %= M;
    }
    dp[cur] = ans;
    return ans;
}

void bfs(){
    queue<tuple<int, int, long long>> que;
    que.push(make_tuple(0, -1, 1));
    while(!que.empty()){
        int cur, prv;
        long long mul;
        tie(cur, prv, mul) = que.front();
        que.pop();

        vector<int> chs;
        for(int nxt : G[cur]){
            if(nxt == prv) continue;
            chs.push_back(nxt);
        }
        int K = chs.size();
        vector<long long> cm0(K+2, 1), cm1(K+2, 1);
        for(int i=0; i<K; i++) cm0[i+1] = (cm0[i] * (dp[chs[i]] + 1)) % M;
        for(int i=K-1; i>=0; i--) cm1[i+1] = (cm1[i+2] * (dp[chs[i]] + 1)) % M;
        REP(i, K){
            long long tmp = ((mul * ((cm0[i] * cm1[i+2]) % M)) % M + 1) % M;
            dp[chs[i]] *= tmp;
            dp[chs[i]] %= M;
            que.push(make_tuple(chs[i], cur, tmp));
        }
    }
}

int main(){
    cin >> N >> M;
    G.resize(N);
    dp.resize(N);
    REP(i, N-1){
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(0, -1);
    bfs();
    for(auto x : dp)
        cout << x << endl;
    return 0;
}

Measured memory_bytes: 11904
#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++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// UnionFind 解説：https://youtu.be/TdR816rqc3s?t=8424
struct UnionFind {
	vi d;
	UnionFind(int n = 0) : d(n, -1) {}

	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}

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

		if (x == y) return false;

		if (d[x] > d[x]) swap(d[x], d[x]);
		d[x] += d[y];
		d[y] = x;
		return true;
	}

	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};
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;
    }
};

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

mint power(int u, int v) {
    if (v == 0) return 1;

    mint x;
    x = power(u, v / 2);
    x *= x;

    if (v % 2 == 1) x *= u;

    return x;
}

int main() {
	int n, m;
	cin >> n >> m;

    cout << power(n, m).x << endl;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li x,k,d;

    cin>>x>>k>>d;
    x=abs(x);

    	li quo=x/d;

    	if(k>quo)
    	{
    		if((k-quo)%2==0)
    		{
    			cout<<x%d;	
    		}
    		else
    		{
    			cout<<d-x%d;
    		}
    	}
    	else
    	{
    		x-=k*d;

    		cout<<x;
    	}
}

int main()
{    
    

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3648