akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;


int main () {
	int A, B, C;
	cin >> A >> B >> C;
	int maxnum = max(max(A, B ), C);
	int diff = 3*maxnum - (A+B+C);
	if (diff%2 == 0){
		cout << diff / 2;	
	}
	else cout << (diff+3) /2;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int a,b,k;
bool c[1000000000];
int main()
{
	scanf("%d%d%d",&a,&b,&k);
	int t=k;
	for(int i=a;i<=b&&t--;i++)
		c[i]=1;
	for(int i=b;i>=a&&k--;i--)
		c[i]=1;
	for(int i=a;i<=b;i++)
		if(c[i])
			printf("%d\n",i);
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m, x[100000], y[100000];
const LL MOD = 1000000007;

int main() {
	cin >> n >> m;
	inc(i, n) { cin >> x[i]; }
	inc(j, m) { cin >> y[j]; }
	
	LL sum_x = 0;
	inc(i, n) { (sum_x += x[i] - x[0]) %= MOD; }
	LL sum2_x = sum_x;
	inc(i, n - 1) {
		(sum_x += MOD - (x[i + 1] - x[i]) * (n - 1 - i)) %= MOD;
		(sum2_x += sum_x) %= MOD;
	}
	
	LL sum_y = 0;
	inc(j, m) { (sum_y += y[j] - y[0]) %= MOD; }
	LL sum2_y = sum_y;
	inc(j, m - 1) {
		(sum_y += MOD - (y[j + 1] - y[j]) * (m - 1 - j)) %= MOD;
		(sum2_y += sum_y) %= MOD;
	}
	
	cout << (sum2_x * sum2_y) % MOD << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#define endl '\n'
#define range 200010
#endif

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}
int n;
vi a,b;
int completed[range];
int main(){

	//freopen("input.txt","r",stdin);
	clock_t clk = clock();
	cin>>n;
	a.resize(n),b.resize(n);
	forn(i,n)cin>>a[i];
	forn(i,n)cin>>b[i];

	ll cnt = 0;

	while(true){
		int change = 0;
		forn(i,n){
			ll x = b[(i-1+n)%n],y = b[(i+1+n)%n];
			if(completed[i])continue;
			if(x+y>b[i])continue;
			change++;
			ll t = b[i]%(x+y);
			if(t<a[i]){
				ll p = b[i]-a[i];
				if(p%(x+y) != 0){
					cnt = -1;
				}
				else{
					cnt += p/(x+y);
					b[i] = a[i];
					completed[i] = 1;
				}
			}
			else{
				cnt += (b[i])/(x+y);
				b[i] = t;
				if(b[i] == a[i]){
					completed[i] = 1;
				}
			}
		}
		/*forn(i,n)cout<<b[i]<<" ";cout<<endl;
		forn(i,n)cout<<a[i]<<" ";cout<<endl;
		cout<<change<<endl;*/
		if(change == 0 || cnt == -1)break;
	}
	bool pos = true;
	forn(i,n){
		if(a[i] != b[i])pos = false;
	}
	if(pos)
		cout<<cnt;
	else
		cout<<-1;



    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}





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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int a;
  scanf("%d", &a);

  printf("%d\n", 48 - a);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

string S, T, U;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
	int N;cin >> N;
	vi A(N);rep(i,N) cin >> A[i];
	bool flag = true;
	rep(i,N) {
		if(A[i]%2==0) {
			if(A[i]%3 != 0 and A[i]%5!=0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e5+11;
const ll INF=~0u>>2,mod=1e9+7;
ll ans,a,b;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
ll calc(int x){
	int ret=1;
	for(ll i=1;i<=x;++i) ret=(ret*i)%mod;
	return ret;
}
int main(){
//	freopen("ex.in","r",stdin);
	a=read();b=read();
	if(a<b){
		int t=a;a=b;b=t;
	}
	if(a==b){
		ll tmp=calc(a);
		ans=(tmp*tmp*2)%mod;
	}
	else if(a==b+1){
		ans=(calc(a)*calc(b))%mod;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"yes":"no");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using p = pair<ll,ll>;
const ll linf = 1e18l + 1;
const int inf = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,m,k; cin >> n >> m >> k;
  vector<ll> a(n+1), b(m+1);
  rep(i, n) cin >> a[i+1];
  rep(i, n) a[i+1] += a[i];
  rep(i,m) cin >> b[i+1];
  rep(i,m) b[i+1] += b[i];
  // rep(i,a.size()) printf("%lld%c", a[i], i==a.size()-1?'\n':' ');
  // rep(i,b.size()) printf("%lld%c", b[i], i==b.size()-1?'\n':' ');
  int ans = 0;
  rep (i,n+1) {
    if (a[i] > k) break;
    int now = i;
    int rest = k-a[i];
    auto it = lower_bound(b.begin(), b.end(), rest);
    if (it == b.end()) it--;
    if (rest >= *it) now++;
    now += it - b.begin()-1;
    int ad = it - b.begin()-1;
    // cout << ad << endl;
    // cout << *it << endl;
    // if (rest < *it) now--;
    chmax(ans, now);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6420
#A1 ~ Aiまでの和 O(logN)
def BIT_query(idx):
    res_sum = 0
    while idx > 0:
        res_sum += BIT[idx]
        idx -= idx&(-idx)
    return res_sum

#Ai += x O(logN)
def BIT_update(idx,x):
    while idx <= n:
        BIT[idx] += x
        idx += (idx&(-idx))
    return

n,q=map(int,input().split())
A=list(map(int,input().split()))
#A1 ... AnのBIT(1-indexed)
BIT = [0]*(n+1)
for i,e in enumerate(A):
   BIT_update(i+1,e)
for i in range(q):
  B=list(map(int,input().split()))
  if B[0]==0:
    BIT_update(B[1]+1,B[2])
  else:
    print(BIT_query(B[2])-BIT_query(B[1]))

Measured memory_bytes: 132492
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    vi a2 = a;
    rep(i,n) a2.at(i) -= i+1;
    sort(a2.begin(), a2.end());
    ll res = 0;
    if(n%2==1){
        ll b = a2.at(n/2);
        rep(i,n) res += abs(a.at(i) - (b+i+1));
    }else{
        ll b1 = a2.at(n/2);
        ll res1 = 0;
        rep(i,n) res1 += abs(a.at(i) - (b1+i+1));
        ll b2 = a2.at(n/2-1);
        ll res2 = 0;
        rep(i,n) res2 += abs(a.at(i) - (b2+i+1));
        res = std::min(res1,res2);
    }
    cout << res << endl;
}

Measured memory_bytes: 6312
N = int( input())
H = list( map( int, input().split()))
dp = [0]*N
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    dp[i] = min( dp[i-1]+abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2]) )
print(dp[-1])


Measured memory_bytes: 52208
# ABC 110 D - Factorization
def factorization(n):
    retlist = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            retlist.append(cnt)

    if temp!=1:
        retlist.append(1)

    if retlist==[]:
        retlist.append(1)

    return retlist

def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a
 
def comb_mod(n, k, mod):
    if k > n or k < 0:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod

n,m=map(int,input().split())

if m==1:
    print(1)
    exit()
f=[]
f=factorization(m)
mod=10**9+7
ans=1
for ff in f:
    t=comb_mod(ff+n-1,ff,mod)
    ans*=t
    ans%=mod
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i=int(a); i<int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define y0 snowy0
#define y1 snowy1
#define rank snowrank
#define next snownext
#define prev snowprevc

template<class T> bool chmax(T& a, const T& b) { if (a<b) { a=b; return 1; } return 0; } 
template<class T> bool chmin(T& a, const T& b) { if (b<a) { a=b; return 1; } return 0; } 
template<class T = int> T in() { T x; cin >> x; return x; }

#ifdef LOCAL
  #define db cout << "L" << __LINE__ << ": "
  #define dv(v) << #v << "->" << v << " "
  #define de << endl
#else
  #define db
  #define dv(v)
  #define de
#endif

int n;
int q;
ll a[100000];
int sqrtn = 512;
int K;
ll b[100000*2];

void update(int idx, ll x) {
  a[idx] = x;
  int bidx = idx/sqrtn;
  b[bidx] = ((ll)1<<31) - 1;
  rep(i, bidx*sqrtn, (bidx+1)*sqrtn) {
    chmin(b[bidx], a[i]);
  }
}

ll find(int x, int y) {
  ll result = ((ll)1<<31) - 1;
  rep(k, K) {
    int l = k*sqrtn;
    int r = (k+1)*sqrtn;
    if (r <= x || y <= l) continue;
    if (x <= l && r <= y) {
      chmin(result, b[k]);
    } else {
      rep(i, max(x, l), min(y, r)) {
        chmin(result, a[i]);
      }
    }
  }
  return result;
}

int main() {
  ios::sync_with_stdio(false);
  n = in();
  q = in();
  K = (n+sqrtn-1)/sqrtn;
  rep(i, n) a[i] = ((ll)1<<31) - 1;
  rep(i, n*2) b[i] = ((ll)1<<31) - 1;
  rep(i, q) {
    int c = in();
    int x = in();
    int y = in();
    if (c == 0) { // update
      update(x, y);
    } else { // find
      cout << find(x, y+1) << endl;
    }
  }
}




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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  int a,b;
  string s;
  cin >> a >> b >> s;
  bool flag = true;
  if(s[a] != '-')flag = false;
  REP(i,a+b+1)if(i != a)if(s[i] < '0' || s[i] > '9')flag = false;
  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;


  



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=(1<<18)+5;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int getinv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	void math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=getinv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

int n,a[N],ans[N],id[N][2],m;
bool cmp(int x,int y) {return a[x]>a[y];}

void work(int p,int x,int y)
{
	vi tmp;tmp.clear();
	tmp.pb(x);tmp.pb(y);
	tmp.pb(id[p][0]);tmp.pb(id[p][1]);
	sort(tmp.begin(),tmp.end(),cmp);
	unique(tmp.begin(),tmp.end());
	id[p][0]=tmp[0];id[p][1]=tmp[1];
}

int main()
{
	n=read();m=(1<<n)-1;
	rep(i,0,m) a[i]=read();
	id[0][0]=0;id[0][1]=m+1;
	rep(i,1,m)
	{
		id[i][0]=i;
		rep(j,0,n-1)
			if ((i>>j)&1)
			{
				int pre=i^(1<<j);
				work(i,id[pre][0],id[pre][1]);
			}
	}
	rep(i,1,m) ans[i]=a[id[i][0]]+a[id[i][1]];
	rep(i,1,m) ans[i]=max(ans[i-1],ans[i]);
	rep(i,1,m) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

void solve(std::vector<long long> x){
    for(int i=0;i<5;i++){
        if(x[i] == 0){
            cout << i+1 << endl;
            return;
        }
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3692
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
//Constant
const int M=100;
//Quick Read
int Read(){
	int x=0;
	bool neg=false;
	char c=getchar();
	while(isdigit(c)==false)neg^=c=='-',c=getchar();
	while(isdigit(c)==true)x=x*10+c-'0',c=getchar();
	return neg==true?-x:x;
}
inline void Read(int &x){x=Read();}
//Main
int a[M+1],b[M+1],odd[M+1];
int main(){
	// freopen("AGC001D.in","r",stdin);
	// freopen("AGC001D.out","w",stdout);
	int n=Read(),m=Read(),num=0;
	for(int i=1;i<=m;++i){
		Read(a[i]);
		if(a[i]%2==1)odd[++num]=i;
	}
	if(m==1){
		printf("%d\n",a[1]);
		if(a[1]==1)printf("%d\n%d\n",1,1);
		else printf("%d\n%d %d\n",2,1,a[1]-1);
		return 0;
	}
	if(num>2){
		printf("Impossible\n");
		return 0;
	}
	std::sort(odd+1,odd+num+1);
	if(num>=1)std::swap(a[odd[1]],a[m]);
	if(num>=2)std::swap(a[odd[2]],a[1]);
	for(int i=1;i<=m;++i)printf("%d%c",a[i]," \n"[i==m]);
	for(int i=1;i<=m;++i)b[i]=a[i];
	++b[1],--b[m];
	if(b[m]==0)--m;
	printf("%d\n",m);
	for(int i=1;i<=m;++i)printf("%d%c",b[i]," \n"[i==m]);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n; cin >> n;
    vector<int> A(n); cin >> A;
    ll ans = 0;
    REP(i, n-1) {
        if (A[i] && A[i+1] && A[i]%2 == 1) {
            --A[i];
            --A[i+1];
            ++ans;
        }
    }
    REP(i, n) {
        ans += A[i]/2;
        A[i] %= 2;
    }
/*
    REP(i, n) {
        ans += A[i]/2;
        A[i] %= 2;
    }
    REP(i, n-1) {
        if (A[i] && A[i+1]) {
            --A[i];
            --A[i+1];
            ++ans;
        }
    }
*/
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n, k, ans;
vector<Int> p;
vector<Int> q;
template <class M> class sliding_window{
public:
	vector<M> v;
	Int k, pos = -1;
	function<bool(M, M)> fn;
	deque<Int> dq;
	sliding_window(vector<M> _v, Int _k, function<bool(M, M)> _fn) : v(_v), k(_k), fn(_fn) {};
	M get(Int p){
		assert(pos <= p);
		for(; pos<p; ++pos){
			Int t = pos + 1;
			while(!dq.empty() && fn(v[t], v[dq.front()])) dq.pop_front();
			while(!dq.empty() && fn(v[t], v[dq.back()])) dq.pop_back();
			dq.push_back(t);
		}
		while(!dq.empty() && dq.front() < p-k) dq.pop_front();
		assert(!dq.empty());
		return v[dq.front()];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	p.resize(n);
	for(auto &i:p) cin >> i;
	q.resize(n);
	q[0] = 1;
	for(Int i=1; i<n; ++i) q[i] = p[i] > p[i-1] ? q[i-1] + 1 : 1;
	ans = 1;
	bool f = (q[k-1] < k);
	sliding_window<Int> a(p, k, [](Int x, Int y){return x<y;}), b(p, k, [](Int x, Int y){return x>y;});
	for(Int i=k; i<n; ++i){
		bool g, h;
		g = a.get(i) == p[i-k];
		h = b.get(i) == p[i];
		if(q[i] >= k){
			if(f) ++ans;
			f = false;
		}else if(!g || !h){
			++ans;
		}
//		cout << i << "\n";
//		for(auto i:a) cout << i << " ";
//		cout << "\n";
//		cout << i << " " << "01"[g] << " " << "01"[h] << "\n";
	}
	cout << ans << "\n";
}

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

using namespace std;

int N, M, Q;
int color[100001];
vector<int> G[100001];
int v[100001],d[100001],c[100001];
int dp[100001][11];

void solve(int v,int d,int c) {
  if(dp[v][d]) return;
  dp[v][d] = 1;
  if(color[v] == 0) color[v] = c;
  if(d == 0) return;

  solve(v,d-1,c);

  for(int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    solve(u,d-1,c);
  }
  
  
}


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

  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  cin >> Q;

  for(int i = 0; i < Q; i++) {
    int vv,dd,cc;
    cin >> vv >> dd >> cc;
    vv--;
    v[i] = vv;
    d[i] = dd;
    c[i] = cc;
  }

  for(int i = Q-1; i >= 0; i--) {
    solve(v[i],d[i],c[i]);
  }


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


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

using namespace std;

int main(void){
    int N;
    cin>>N;
    int digit[3];
    for(int i=N;i<=999;i++){
        bool flag=false;
        string num=to_string(i);
        if(num[0]==num[1]&&num[1]==num[2]) flag=true;
        if(flag){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}



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

int main()
{
	int i,N,n,d;

	cin>>N;
	while(N!=0){
		int x[200],y[200];
		x[0]=0; y[0]=0;
		int MAXx=-1000,MINx=1000,MAXy=-1000,MINy=1000;
		int height,width;

		for(i=1;i<N;i++){
			cin>>n>>d;
			x[i]=x[n]; y[i]=y[n];
			if(d==0) x[i]--;
			if(d==1) y[i]--;
			if(d==2) x[i]++;
			if(d==3) y[i]++;
		}
		for(i=0;i<N;i++){
			if(MAXx < x[i]) MAXx=x[i];
			if(MINx > x[i]) MINx=x[i];
			if(MAXy < y[i]) MAXy=y[i];
			if(MINy > y[i]) MINy=y[i];
		}
		width=MAXx-MINx+1;
		height=MAXy-MINy+1;

		cout<<width<<" "<<height<<endl;
		cin>>N;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>

int main(){
	char a[15],b[15],c[15];
	scanf("%s%*c%s%*c%s",&a,&b,&c);
	if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
	printf("YES");
	else
	printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a="CODEFESTIVAL2016",b;
	cin>>b;
	int jsq=0;
	for(int i=0;i<a.length();i++){
		if(a[i]!=b[i])
			jsq++;
	}
	cout<<jsq;
}

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

int main()
{
	long long int k,n;
	cin>>k>>n;
	long long int i;
	long long int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	long long int maxs=0;
	for(i=1;i<n;i++)
		maxs=max(a[i]-a[i-1],maxs);
	cout<<min((a[n-1]-a[0]),k-maxs);
}	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

string s,t;

int l=-1;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s >> t;
    for(int i=0;i<s.lg;i++){
        int gd=1; if(i+t.lg>s.lg) break;
        for(int j=0;j<t.lg;j++){
            if(s[i+j]!=t[j] && s[i+j]!='?') gd=0;
        }
        if(gd) l=i;
    }
    if(l==-1){
        cout << "UNRESTORABLE";
        return 0;
    }
    for(int i=l;i<l+t.lg;i++){
        s[i]=t[i-l];
    }
    for(int i=0;i<s.lg;i++){
        if(s[i]=='?') s[i]='a';
    }
    cout << s;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    cin>>n;
    long long int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        c[i]=a[i]+b[i];
    }
    sort(c,c+n,greater<int>());
    long long ans=0;
    for(int i=0;i<n;i++){
        ans=ans-b[i];
    }
    for(int i=0;i<n;i=i+2){
        ans=ans+c[i];
    }
  cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
building = Array.new(4){ Array.new(3){ Array.new(10){0} } }
  tenants = gets.chomp.to_i

  tenants.times do
    b,f,r,v = gets.split.map(&:to_i)
    building[(b-1)][(f-1)][(r-1)] += v
  end

  building.each_with_index do |build,buildnum|
    for bud in build
      puts " " + bud.join(" ")
    end
    puts "#" * 20 if buildnum < 3
  end


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

using namespace std;

int main()
{
  int x,n;
  cin>>x>>n;
  
  int arr[n],diff=200;
  set<int>m;
  
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    m.insert(arr[i]);
  }
  
  int ans,found=0,i=0;
  while(!found)
  {
    if(m.count(x-i)==0)
    {
      ans=x-i;
      found=1;
    }
    
    else if(m.count(x+i)==0)
    {
      ans=x+i;
      found=1;
    }
    
    i++;
  }
  
  
  cout<<ans;
  
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) { cin >> p[i]; p[i]--; }
    vector<int> idx(n);
    rep(i, n) idx[p[i]] = i;
    
    set<int> s;
    ll ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        int id = idx[i];
        s.insert(id);
        ll c = 0;
        {
            vector<int> l(2, -1), r(2, n);
            {
                auto it = s.find(id); // 必ず入ってる
                rep(j, 2) {
                    if (it == s.begin()) break;
                    --it; // if文の前だと, もともとs.begin()ならs.begin() - 1になってif文通らずに*itで事故
                    l[j] = *it;
                }
            }
            {
                auto it = s.find(id); // 必ず入ってる
                rep(j, 2) {
                    ++it;
                    // if文の前じゃないとbad access?
                    // あとならs.end()になる可能性あって*itが事故
                    if (it == s.end()) break;
                    r[j] = *it;
                }
            }
            vector<int> ls(2), rs(2);
            ls[0] = id - l[0]; ls[1] = l[0] - l[1];
            rs[0] = r[0] - id; rs[1] = r[1] - r[0];
            c = (ll)ls[0] * rs[1] + (ll)rs[0] * ls[1];
        }
        ans += c * (i + 1);
    }
    cout << ans << '\n';
}


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

main() {
  int N; cin >> N;
  vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i];
  int ans = 1;
  for (int i = 0; i < N; i++) ans *= 3;
  int odd = 1;
  for (int i = 0; i < N; i++) {
    odd *= (A[i] % 2 == 0) ? 2 : 1;
  }
  cout << ans - odd << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define int long long
#define gc getchar()
#define t(i) edge[i].to
#define w(i) edge[i].wei
#define ri register int
#define rb register bool
#define rc register char
#define lowbit(x) (x&(-x))
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt)

const int N=1e5+10,inf=1e9;
int head[N],ed_cnt,n,sz[N],mxsz[N],rt,d[N],as;
bool flg;
struct ed{int to,nxt,wei;}edge[N<<1];

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}
il void ad(ri x,ri y,ri z)
{edge[++ed_cnt]=(ed){x,head[y],z};head[y]=ed_cnt;edge[++ed_cnt]=(ed){y,head[x],z};head[x]=ed_cnt;}
void dfs(ri nw)
{
	sz[nw]=1;mxsz[nw]=0;
	e(i,nw)if(!sz[t(i)])d[t(i)]=w(i),dfs(t(i)),mxsz[nw]=max(mxsz[nw],sz[t(i)]),sz[nw]+=sz[t(i)];
	mxsz[nw]=max(mxsz[nw],n-sz[nw]);
	if(mxsz[nw]<mxsz[rt])rt=nw;
}

signed main()
{
	//freopen("king.in","r",stdin);freopen("king.out","w",stdout);
	n=read();rp(i,1,n-1){ri x=read(),y=read(),z=read();ad(x,y,z);}mxsz[0]=inf;dfs(1);
	rp(i,2,n){ri l=sz[i],r=n-sz[i];if(l==r)flg=1,as+=(2ll*l-1)*d[i];else as+=2ll*min(l,r)*d[i];}
	if(!flg){ri tmp=inf;e(i,rt)tmp=min(tmp,w(i));as-=tmp;}
	printf("%lld\n",as);
	return 0;
}


Measured memory_bytes: 10752
n, m, k = map(int, input().split())

MOD = 10 ** 9 + 7

class ModCmb:
    def __init__(self, size):
        self.inv = [1] * (size + 1)
        self.fact = [1] * (size + 1)
        temp_inv = [1] * (size + 1)
        for i in range(2, size + 1):
            temp_inv[i] = ( -(MOD // i) * temp_inv[MOD%i] ) % MOD
        for i in range(2, size + 1):
            self.fact[i] = self.fact[i-1] * i % MOD
            self.inv[i] = self.inv[i-1] * temp_inv[i] % MOD

    def cmb(self, n, r):
        if n <= 1 or n == r:
            return 1
        elif r == 1:
            return n
        else:
            return  (self.fact[n] * self.inv[r] % MOD ) * self.inv[n-r] % MOD

mc = ModCmb(n*m)

temp = mc.cmb(n*m-2, k-2)

ans = 0

for h in range(n):
    for w in range(m):
        if h != 0 and w != 0:
            ans += (h + w) * temp * (n - h) * (m - w) * 2
        else:
            ans += (h + w) * temp * (n - h) * (m - w)
        ans %= MOD

print(ans)

Measured memory_bytes: 26740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans = 0;
int h, w;
vector<string> s;

bool can(pair<int, int> a, vector<vector<int>> dist) {
  int x = a.first;
  int y = a.second;

  return x >= 0 && x < h && y >= 0 && y < w && s[x][y] == '.' &&
         dist[x][y] == -1;
}

int vectormax(vector<vector<int>> dist) {
  int ans = 0;
  for (int i = 0; i < dist.size(); i++) {
    for (int j = 0; j < dist[i].size(); j++) {
      ans = max(ans, dist[i][j]);
    }
  }
  return ans;
}
int main() {
  cin >> h >> w;
  s.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
  queue<pair<int, int>> que;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      vector<vector<int>> dist(h, vector<int>(w, -1));
      if (s[i][j] == '.') {
        que.push(make_pair(i, j));
        dist[i][j] = 0;  //始点は0

        while (!que.empty()) {
          pair<int, int> temp = que.front();
          que.pop();
          for (int k = 0; k < 4; k++) {
            pair<int, int> tmp;
            tmp.first = temp.first + dx[k];
            tmp.second = temp.second + dy[k];
            if (can(tmp, dist)) {
              dist[tmp.first][tmp.second] = dist[temp.first][temp.second] + 1;
              que.push(tmp);
            }
          }
        }
      }
      ans = max(ans, vectormax(dist));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int x; cin>>x;
   if(x>=400 && x<=599) cout<<"8"<<endl;
   else if(x<=799) cout<<"7"<<endl;
   else if(x<=999) cout<<"6"<<endl;
   else if(x<=1199) cout<<"5"<<endl;
   else if(x<=1399) cout<<"4"<<endl;
   else if(x<=1599) cout<<"3"<<endl;
   else if(x<=1799) cout<<"2"<<endl;
   else if(x<=1999) cout<<"1"<<endl;

    return 0;
}

Measured memory_bytes: 3568
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n,k;cin>>n>>k;
	int cnt=0;
	while(n--){
		int x;cin>>x;
		if(x>=k)
			cnt++;
	}
	cout<<cnt;
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = I()
G = [[] for i in range(N+1)]

for i in range(N-1):
    a,b,c = map(int,S().split())
    G[a].append((b,c))
    G[b].append((a,c))

Q,K = map(int,S().split())

from collections import deque

distance = [-1]*(N+1)  # arrive[i] = 頂点Kからの最短距離
distance[K] = 0

q = deque([K])
while q:
    a = q.pop()
    for b,c in G[a]:
        if distance[b] != -1:
            continue
        distance[b] = distance[a] + c
        q.appendleft(b)

for i in range(Q):
    x,y = map(int,S().split())
    print(distance[x] + distance[y])

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

int k, n, s;

int main() {
  scanf("%d%d%d", &n, &k, &s);
  vector<int> ans(n);
  if (s == 1e9) {
    fill(all(ans), 1);
    REP(i, k) ans[i] = 1e9;
  } else {
    fill(all(ans), 1e9);
    REP(i, k) ans[i] = s;
  }
  for (auto x : ans) printf("%d ", x);
}


Measured memory_bytes: 1664
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define REPV(i,a,b) for(int i = a; i>= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define with_tests int t; cin>>t; while(t--){ solve(); }
#define without_tests solve();
#define ll long long
#define INF 100000
#define ff first
#define ss second
const int M=1e9+7;

void solve()
{
	int n;
	cin>>n;
	vector<int> H(n);
	for(auto&e : H)
	{
		cin>>e;
	}
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(H[1] - H[0]);
	REP(i,2,n)
	{
		dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]));
	}
	cout<<dp.back()<<"\n";
}

int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  //with_tests;
  without_tests;
  return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

bool dp[2][2501][2501];

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

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

    int n;
    cin >> n;

    vector<int> t(n);
    int sum = 0;
    rep(i, n){
        cin >> t[i];
        sum += t[i];
    }

    rep(i, 2){
        rep(j, sum + 1){
            rep(k, sum + 1){
                dp[i][j][k] = false;
            }
        }
    }
    dp[0][0][0] = true;

    rep(i, n){
        rep(j, sum + 1){
            rep(k, sum + 1){
                if(j + t[i] <= sum){
                    dp[(i + 1) % 2][j + t[i]][k] |= dp[i % 2][j][k];
                }
                if(k + t[i] <= sum){
                    dp[(i + 1) % 2][j][k + t[i]] |= dp[i % 2][j][k];
                }
                dp[(i + 1) % 2][j][k] |= dp[i % 2][j][k];
            }
        }
    }

    int ans = IINF;
    rep(j, sum + 1){
        rep(k, sum + 1){
            if(dp[n % 2][j][k]){
                chmin(ans, max({j, k, sum - j - k}));
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;


int main(void) {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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

    fill_n(dp, n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j <= i+k; ++j) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(a[i]-a[j]));
            }
        }
    }
    cout << dp[n-1] << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    decp(10);
    int n;cin>>n;
    vector<double> v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));
    double sum=v[0]/pow(2,n-1);
    rep2(i,1,n){
        sum+=v[i]/pow(2,n-i);
    }
    cout<<sum<<endl;
}

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

typedef long long int ll;
#define size 100005
ll a[size],dp[size],n,k;

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> k;
	ll i,j;
	for(i=0;i<n;i++)
	{
		cin >> a[i];	
		dp[i]=-1;
	}
	dp[0]=0;
	for(i=1;i<k;i++)
	{
		ll ma=1e18;
		for(j=1;j<=k;j++)
		{
			if(i-j>=0)
				ma = min(ma,dp[i-j]+abs(a[i]-a[i-j]));
		}
		dp[i]=ma;
	}
	for(i=k;i<n;i++)
	{
		ll ma=1e18;
		for(j=1;j<=k;j++)
			ma = min(ma,dp[i-j]+abs(a[i]-a[i-j]));
		dp[i]=ma;		
	}
	ll ans = dp[n-1];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

#define MAX_N 1000010

//2〜MAX_N-1のすべての数の素因数分解を計算(O(MAX_N log(MAX_N)))
vector<int> pr[MAX_N],id[MAX_N];
bool is_prime[MAX_N];

void all_fac()
{
    fill(is_prime,is_prime+MAX_N,true);
    for(int i=2;i<MAX_N;i++){
        if(is_prime[i]){
            pr[i].push_back(i);
            id[i].push_back(1);
            for(int j=2*i;j<MAX_N;j+=i){
                is_prime[j] = false;
                int cnt = 0;
                int nw = j;
                while(nw % i == 0){
                    nw /= i;
                    cnt++;
                }
                pr[j].push_back(i);
                id[j].push_back(cnt);
            }
        }
    }
}

template<typename T>
T gcd(T a, T b)
{
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a,T b)
{
    return  a / gcd(a,b) * b;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> p(1000010);
    all_fac();
    rep(i,n){
        for(auto x:pr[a[i]]){
            p[x]++;
            // cerr << x << endl;
        }
    }
    bool flag = 1;
    rep(i,1000010){
        if(p[i]>=2){
            flag = 0;
        }
    }
    int g = a[0];
    rep(i,n){
        g = gcd(g,a[i]);
    }
    if(flag){
        cout << "pairwise coprime\n";
    }else if(g==1){
        cout << "setwise coprime\n";
    }else{
        cout << "not coprime\n";
    }
    return 0;
}

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

char x[105][105];

int main()
{
	int a, b;
	cin >> a >> b;
	for(int i = 1; i <= 50; i++) 
		for(int j = 1; j <= 100; j++)
			x[i][j] = '#';
	for(int i = 51; i <= 100; i++)
		for(int j = 1; j <= 100; j++)
			x[i][j] = '.';
	a--, b--;
	for(int i = 1; i <= 50 && a; i += 2)
		for(int j = 1; j <= 100 && a; j += 2)
			x[i][j] = '.', a--;
	for(int i = 100; i > 50 && b; i -= 2)
		for(int j = 1; j <= 100 && b; j += 2)
			x[i][j] = '#', b--;
	puts("100 100");
	for(int i = 1; i <= 100; i++, puts(""))
		for(int j = 1; j <= 100; j++)
			cout << x[i][j];
	return 0;
}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
S = rs()
N = len(S)
ans = 'AC'
if S[0] != 'A' or S[2:-1].count('C') != 1:
    ans = 'WA'
for i in range(N):
    if not S[i] in ascii_lowercase:
        if not (i == 0 and S[i] == 'A') and not (2 <= i < N - 1 and S[i] == 'C'):
            ans = 'WA'
print(ans)

Measured memory_bytes: 63340
#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 pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

int a[61];
int main(){
    int n;
    cin>>n;
    int mx=-1000100010,cnt=0,cur=0;
    int c=-1,c1=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0){
            ++cnt;
            if(mx<=a[i]) mx=a[i],cur=i;
            if(a[i]==-1) c=c==-1?i:c,++c1;
        }
    }
    if(cnt%2==0) cur=-1;
    if(c1>0){
        if((cnt-c1)%2==0) c=-1;
    }
    vector<int> v;
    rep(i,n){
        if(a[i]>=2) v.pb(i+1);
        if(c1==0&&a[i]<0&&cur!=i) v.pb(i+1);
        else if(c1>0&&c==-1&&a[i]<-1) v.pb(i+1);
        else if(c1>0&&(a[i]<-1||c==i)) v.pb(i+1);
    }
    cout<<v.size()<<endl;
    for(auto it:v) cout<<it<<endl;
    return 0;
}


Measured memory_bytes: 3168
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
//
int main(){
	int k;
	string s;
	cin>>k>>s;
	if(s.size()<=k){
		cout<<s<<endl;
	}else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628