akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  /* code */
  int n ;
  int ans = 0 ;
  cin >> n;

  vector<int> B(n-1) ;

  for (int i = 0; i < n-1; i++) {
    cin >> B[i];
  }


  ans += B[0];

  for (int i = 0; i < n-2; i++) {
    ans += min(B[i],B[i+1]);
  }

  ans += B[n-2];

  cout << ans << "\n" ;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
const int INF = 1e9+7;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int h, n;
long long a[MAXN], b[MAXN];
long long  dp[MAXN];
void solve(){
    cin >> h >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];

    for (int i = 1; i <= h; i++)
        dp[i] = INF;

    dp[h] = 0;
    long long  ans = INF;
    for (int i = h; i >= 1; i--){
        for (int j = 1; j <= n; j++){

            if (i - a[j] <= 0){
                ans = min(ans, dp[i] + b[j]);
                continue;
            }
            dp[i - a[j]] = min(dp[i - a[j]], dp[i] + b[j]);
        }
    }

    if (ans == INF)
        cout << 0 << endl;
    else
        cout << ans << endl;
}



int main() {
ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
cout.setf(ios::fixed), cout.precision(7);
 //freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
 int step;
 step = 1;
  for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    string s;
    cin >> s;
    int K;
    cin >> K;
    vector<string> subs;
    for(int i = 0; i < K; i++){
        for(int j = 0; j < s.size()-i; j++){
            subs.push_back(s.substr(j, i+1));
        }
    }

    sort(subs.begin(), subs.end());
    subs.erase(unique(subs.begin(), subs.end()), subs.end());

    cout << subs[K-1] << endl;


    return 0;
}

Measured memory_bytes: 1660
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	var r int
	var g int
	var b int
	fmt.Scan(&n)
	fmt.Scan(&s)
	l := []rune(s)
	for _, a := range l {
		switch a {
		case 'R':
			r++
		case 'G':
			g++
		case 'B':
			b++
		}
	}

	var NG int
	NG = 0

	for i := range l {
		for j := 1; i+j*2 < len(l); j++ {
			if s[i] != s[i+j] && s[i] != s[i+j*2] && s[i+j] != s[i+j*2] {
				NG++
			}
		}
	}
	fmt.Println(r*g*b - NG)
}

Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

ll st[11][11];

void solve() {
    ll N, M;
    cin >> N >> M;
    REP(i, M) {
        ll k;
        cin >> k;
        REP(j, k) {
            ll s;
            cin >> s;
            s--;
            st[i][s] = 1;
        }
    }
    vll p(M);
    ll ans = 0;
    for(auto &a:p) cin >> a;
    for(int i = 0; i < (1 << N); i++) {
        vll on(N);
        for(int j = 0; j < N; j++) {
            ll b = (i >> j) & 1;
            on[j] = b;
        } 
        ll sw = 0;
        REP(k, M) {
            ll o = 0;
            REP(j, N) {
                if(on[j] == 1 && st[k][j]==1) {
                    o++;
                }
            }
            if(o % 2 == p[k]) {
                sw++;
            }
        }
        if(sw == M) ans++;
    }
    out(ans);
}

int main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int l = 0;
  int r = n - 1;;
  int res = 0;
  while (l < r) {
    while (l < n && s[l] != 'W') ++l;
    while (r >= 0 && s[r] != 'R') --r;
    if (l >= r) break;
    ++res;
    ++l;
    --r;
  } 
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
const ld pi = 3.14159265358979323846;
//ll MOD = 1e9 + 7;
ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 1;
ll cnt[N];
void solve(){
    ll n;
    cin>>n;
    ll a[n];
    
    ll sum = 0;
    fo(i,n)cin>>a[i],sum+=a[i],cnt[a[i]]++;
    ll q;

    cin>>q;

    fo(i,q){
        ll b,c;
        cin>>b>>c;
        sum += cnt[b]*(c-b);
        cnt[c]+=cnt[b];
        cnt[b] = 0;
        cout<<sum<<nl;
    }

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";


}


Measured memory_bytes: 5308
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
	int N;
	cin >> N;
	cout << fixed;
	if(N==1) cout << "1.000000000";
	else if(N%2==0)cout << setprecision(8)<< (float)((N/2.0f)/N);
	else if(N%2==1) cout << setprecision(8)<< (float)((int(N/2.0f)+1.0f)/N) ;
        else cout << "out";
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool T=false;
int main(){
    long long N;cin>>N;
    vector<string> S(N);
    long long wa=0,ac=0,tle=0,re=0;
    for (int i = 0; i < N; i++)
    {
        cin>>S[i];
        if(S[i]=="WA")wa++;
        if(S[i]=="AC")ac++;
        if(S[i]=="TLE")tle++;
        if(S[i]=="RE")re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int cal(int val, int base)
{
  int ret = base;
  while (ret * base <= val) {
    ret *= base;
  }
  return ret;
}

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

  vector<int> dp(N + 5, INF);
  dp[0] = 0;
  for (int i = 1, a = 6, b = 9; a <= N and b <= N; ++i, a *= 6, b *= 9) {
    if (a <= N) { dp[a] = i; }
    if (b <= N) { dp[b] = i; }
  }

  for (int i = 1; i <= N; ++i) {
    dp[i] = dp[i - 1] + 1;
    for (int b : { 6, 9 }) {
      if (i >= b) {
        int c = cal(i, b);
        dp[i] = min(dp[i], dp[i - c] + 1);
      }
    }
  }
  int ans = dp[N];
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli f[N];

void solve()
{

    lli n, L;
    cin>>n >> L;
    lli a[n];
    lli idx = -1;
    for(int i = 0; i < n; i ++) {
        cin>>a[i];
        if(a[i] >= L) {
            idx = i;
        }
    }

    if(idx != -1 ) {
        cout<<"Possible\n";
        for(int i = 1; i <= idx; i ++) {
            cout<<i<<'\n';
        }
        for(int i = n - 1; i >= idx + 1; i --) {
            cout<<i<<'\n';
        }
        return ;
    }

    for(int i = 1; i < n; i ++) {
        if(a[i] + a[i - 1] >= L) {
            cout<<"Possible\n";
            for(int j = 1; j <= i - 1; j ++) {
                cout<<j<<'\n';
            }
            for(int j = n - 1; j >= i; j --) {
                cout<<j<<'\n';
            }
            return ;
        }
    }

    cout<<"Impossible";

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

typedef long lint;
typedef long long llint;

static const int MAX = 1e5;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.second > arg2.second; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


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

    vector<pair<int,int>> vodd(MAX+1);
    vector<pair<int,int>> veven(MAX+1);
    int vtmp;
    for(int in=0;in<n;in++) {
        cin >> vtmp;
        if(in%2==0) { 
            vodd.at(vtmp).first = vtmp;
            vodd.at(vtmp).second++;
        }
        else { 
            veven.at(vtmp).first = vtmp;
            veven.at(vtmp).second++;
        }
    }
    vodd.at(0).first = 0;
    vodd.at(0).second = -1;
    veven.at(0).first = 0;
    veven.at(0).second = -1;

    sort(vodd.begin(), vodd.end(), compPair);
    sort(veven.begin(), veven.end(), compPair);

    int o1=vodd.at(0).second, o2=vodd.at(1).second;
    int e1=veven.at(0).second, e2=veven.at(1).second;
    int o1num=vodd.at(0).first, o2num=vodd.at(1).first;
    int e1num=veven.at(0).first, e2num=veven.at(1).first;

    int ans;
    if(o1num!=e1num) ans = n - e1 - o1;
    else ans = min(n-e1-o2, n-e2-o1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
int dp[100100];
int cnt = 0;
signed main() {
  int n;
  cin >> n;
  int a[n];
  int b[n];
  int c[n-1];
  rep(i,n) {
    cin >> a[i];
    a[i]--;
    //cout << a[i] << endl;
  }
  rep(i,n) {
    cin >> b[i];
    //cout << b[i] << endl;
  }
  rep(i,n-1) cin >> c[i];
  
  int now = a[0];
  int pre = -100;
  int ans = 0;
  rep(i,n) {
    now = a[i];
    //cout << now << endl;
    if(now==pre+1) ans+=c[pre];
    ans+=b[now];
    pre = now;
    //cout << a[i]<<" "<<ans <<now<<b[now] << endl;
  }

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

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define re register
using namespace std;
char ss[10001001],tt[10001001];
int n,st[20001001],*h=st+10000001;
int main()
{
	re int x=0,y=0,x1=0;
	re long long ans=0;
	scanf("%d%s%s",&n,ss+1,tt+1);y=(ss[1]!=tt[1]);
	for(re int i=1;i<=n;i++)
	{
		h[x-y]++;x1+=(x>=y);ans+=(x>y)?x-y:y-x;
		if(ss[i]!=ss[i+1])x++;
		if(tt[i]!=tt[i+1])y++;
	}
	if(2*x1<n)
	for(re int i=-1;2*x1+h[i]<n;i-=2)
	{
		ans-=(n-2*x1-h[i])*2;x1+=h[i]+h[i-1];
	}else
	{
		x1-=h[0];
		for(re int i=1;2*x1>n+h[i];i+=2)
		{
			ans-=(2*x1-n-h[i])*2;x1-=h[i]+h[i+1];
		}
	}printf("%lld",ans);
}

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

int main() {
    string s;
    cin >> s;
    int x = stoi(s.substr(0, 2)); // "00"→0に変換される
    int y = stoi(s.substr(2, 2));
    if ((0 < x && x <= 12) && (0 < y && y <= 12)){
        cout << "AMBIGUOUS" << endl;
    }
    else if((0 < x && x <= 12) && (y > 12 || y == 0)){
        cout << "MMYY" << endl;
    }
    else if ((x > 12 || x == 0) && (0 < y && y <= 12)){
        cout << "YYMM" << endl;
    }
    else cout << "NA" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;

int main() {
  string s;
  cin>>s;
  ll ans=0;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]!=s[i+1]){
      ans++;
    }
  }
  cout<<ans;
}

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

int main(){
    int n; 
    cin >> n;
    vector<int>p(n),q(n);
    rep(i,n)cin >> p[i];
    rep(i,n)cin >> q[i];
    vector<int>a(n);
    rep(i,n) a[i] = i+1;

    map<vector<int>,int>mp;
    do{
        mp[a] = mp.size();
    }while(next_permutation(a.begin(),a.end()));
    
    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int m = s.nextInt();
    int f = s.nextInt();
    int r = s.nextInt();
    while (m != -1 || f != -1 || r != -1) {
      if (m == -1 || f == -1) {
        System.out.println("F");
      } else if (m + f >= 80) {
        System.out.println("A");
      } else if (m + f >= 65) {
        System.out.println("B");
      } else if (m + f >= 50) {
        System.out.println("C");
      } else if (m + f >= 30 && r >= 50) {
        System.out.println("C");
      } else if (m + f >= 30) {
        System.out.println("D");
      } else {
        System.out.println("F");
      }
      m = s.nextInt();
      f = s.nextInt();
      r = s.nextInt();
    }
    s.close();
  }
}



Measured memory_bytes: 26236
#include <stdio.h>
#include <math.h>
int main (void){
        long long int N,S=0,B;
        scanf("%lld",&N);
        B=N;
while(B!=0){
  S+=B%10;
  B/=10;
}
if (N%S==0) {
          printf("Yes");
}else{
          printf("No");
}

        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MOD 1000000007

/*
    NTL_1_B Power
*/

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

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

    int ans = mod_pow(m, n, MOD);

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



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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;

inline int mult(int a, int b) {
	return (ll)a * b % MOD;
}

int power(int a, int b) {
	if (!b) {
		return 1;
	}
	if (b % 2) {
		return mult(power(a, b - 1), a);
	}
	return power(mult(a, a), b / 2);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto &el : a) {
		cin >> el;
	}
	sort(a.begin(), a.end(), [&](int &x, int &y) {
		return abs(x) > abs(y);
	});
	bool any_zero = (a.back() == 0);
	while (a.size() && a.back() == 0) {
		a.pop_back();
	}
	n = a.size();
	if (a.size() < k) {
		cout << 0;
		return 0;
	}
	array<multiset<int>, 2> cur;
	int p = 1;
	for (int i = 0; i < k; i++) {
		cur[a[i] > 0].insert(abs(a[i]));
		p = mult(p, abs(a[i]));
	}
	if (cur[0].size() % 2 == 0) {
		cout << p;
		return 0;
	}
	vector<pair<int, int>> possib;
	for (int i = k; i < n; i++) {
		if (cur[a[i] < 0].size()) {
			possib.emplace_back(abs(a[i]), *cur[a[i] < 0].begin());
		}
	}
	if (!possib.size()) {
		if (any_zero) {
			cout << 0;
			return 0;
		}
		reverse(a.begin(), a.end());
		p = 1;
		for (int i = 0; i < k; i++) {
			p = mult(p, abs(a[i]));
		}
		cout << MOD - p;
		return 0;
	}
	sort(possib.begin(), possib.end(), [](pair<int, int> &a, pair<int, int> &b) {
		return (ll)a.first * b.second > (ll)b.first * a.second;
	});
	p = mult(p, mult(power(possib[0].second, MOD - 2), possib[0].first));
	cout << p;
}

Measured memory_bytes: 13480
from heapq import heappush, heappop

input = raw_input
N, M = map(int, input().split(" "))

prices = []
for price in map(int, input().split(" ")):
    heappush(prices, -price)


for i in range(M):
    max_p = - (heappop(prices))
    half_p = max_p // 2
    heappush(prices, - half_p)

out = - sum(prices)
print(out)

Measured memory_bytes: 45800
N, Y = list(map(int, input().split()))
f = 1
for i in range(N+1):
    for j in range(N-i+1):
        s = 10000*i + 5000*j + (N-i-j)*1000
        if s == Y:
            print(i,j,N-i-j)
            f-=1
            break
    if f==0:
        break
        
if f==1:
    print(-1,-1,-1)

Measured memory_bytes: 40812
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let h = i.read_vec::<isize>(n);

    writeln!(o, "{}", solve(&h)).unwrap();
}
fn solve(h: &[isize]) -> isize {
    let mut c: [isize; 2] = [0, (h[0] - h[1]).abs()];

    for i in 2..h.len() {
        c = [
            c[1],
            min(
                c[0] + (h[i] - h[i - 2]).abs(),
                c[1] + (h[i] - h[i - 1]).abs(),
            ),
        ];
    }
    c[1]
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define LL long long

namespace io {
    template <typename T> inline void read(T & _x) {
        int f = 0, ch; _x = 0;
        while(!isdigit(ch = getchar())) f |= ch == '-';
        while(isdigit(ch)) _x = _x * 10 + ch - '0', ch = getchar();
        if(f) _x = -_x;
    }
    template <typename T, typename ... Args> inline void read(T &_f, Args& ... args) {
        read(_f), read(args ...);
    }
    inline void _deal(char ch) { putchar(ch); }
    template <typename T> inline void _deal(T _x) {
        if (_x < 0) putchar('-'), _x = -_x;
        if (_x > 9) _deal(_x / 10);
        putchar(_x % 10 + '0');
    }
    inline void write() {}
    template <typename T, typename ... Args> inline void write(T _f, Args ... args) {
        _deal(_f), write(args...);
    }
}

const int N = 2e5 + 5;

int n, sum, a[N];

int32_t main() {
	io::read(n);
	for(int i = 1; i <= n; ++i) {
		io::read(a[i]);
		sum ^= a[i];
	}
	for(int i = 1; i <= n; ++i)
		printf("%d ", sum ^ a[i]);
    return 0;
}


Measured memory_bytes: 4540
import math

A, B, H, M = map(int, input().split())

theta_H = (2 * math.pi * H / 12) + 2 * math.pi *M / 60 / 12
theta_M = 2 * math.pi * M / 60

C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(abs(theta_H-theta_M)))

print(C)

Measured memory_bytes: 9488
H, W = map(int, input().split())
L = ['.' + input() + '.' for _ in range(H)]
L = ['.' * (W + 2)] + L + ['.' * (W + 2)]
for i in range(1, H + 1):
  for j in range(1, W + 1):
    if L[i][j] == "#":
      l = [L[i-1][j], L[i+1][j], L[i][j-1], L[i][j+1]]
      if '#' not in l:
        print('No')
        break
  else:
    continue
  break
else:
  print('Yes')

Measured memory_bytes: 9040
import java.util.Scanner;

public class Main {

  private int a;

  public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int a = 0;

        if(N % 2 == 1){
           a = (N / 2) + 1;
        }else{
          a = (N / 2);
        }
        System.out.print(a);
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<ll, ll> LP;
typedef long double ld;

#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

int n, m;

ll rsum[501];
//回数、前の位置([)
ld dp[502][501],cop[502][501];

void solve() {
	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
		rsum[i + 1] = rsum[i] + a[i];
	}
	rep(i, 502) {
		rep(j, 501) {
			dp[i][j] = -INF;
		}
	}
	dp[0][0] = 0;
	rep(i, n) {
		rep(j, n + 1) {
			rep(k, n + 1){
				cop[j][k] = -INF;
		    }
		}
		rep(j, i + 1) {
			rep(k, i+ 1) {
				//cut
				ld ad = (rsum[i + 1] - rsum[k]) / (ld)(i + 1 - k);
				cop[j + 1][i+1] = max(cop[j + 1][i+1], dp[j][k] + ad);
				//non cut
				cop[j][k] = max(cop[j][k], dp[j][k]);
			}
		}
		rep(j, n + 1) {
			rep(k, n + 1) {
				dp[j][k] = cop[j][k];
			}
		}
	}
	ld ans = 0;
	rep(i, m + 1) {
		//cout << dp[i][n] << endl;
		ans = max(ans, dp[i][n]);
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 11148
#include<stdio.h>
int main(){
  int a,b,x,k,i,j=0,m;
  scanf("%d%d%d/n",&a,&b,&k);
  if(a>b){
      m=b;
      b=a;
      a=m;
    }
  x=b%a;
  while(x!=0){
    b=a;
    a=x;
    x=b%a;
  }
  for(i=a;j<k;i--){
    if(a%i==0){
      j++;
    }
  }
  printf("%d",i+1);
  return 0;
}

Measured memory_bytes: 128
// --https://kenkoooo.com/atcoder/#/table/soma62jp

#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
 
using namespace std;
 
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
 
#define LL_MOD          (ll)1000000007
#define LL_INF          (ll)1 << 62
#define INT_INF         (int)1 << 30
 
#define rSort(a)        sort(a.rbegin(),a.rend())
#define Sort(a)         sort(a.begin(),a.end())
#define Reverse(a) int     reverse(a.begin(),a.end())
#define Sum(a)          accumulate(a.begin(), a.end(), 0)
#define REP(i, n)       for(ui i = 0;i < n;i++)
#define REPR(i, n)      for(ui i = n;i >= 0;i--)
#define FOR(i, m, n)    for(ui i = m;i < n;i++)
#define pb(i)           push_back(i)
#define mp              make_pair
#define SWAP(x,y)       ((x != y)&&(x ^= y,y ^= x,x ^= y))
 
 
int main(int argc, char* argv[]) {
 
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	int day = 0;

	cin >> S;

	if(S=="SUN"){
		day = 0;
	}if(S=="MON"){
		day = 1;
	}if(S=="TUE"){
		day = 2;
	}if(S=="WED"){
		day = 3;
	}if(S=="THU"){
		day = 4;
	}if(S=="FRI"){
		day = 5;
	}if(S=="SAT"){
		day = 6;
	}
	
	cout <<  7 - day << endl;

	return 0;
 
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    double W,H;
    int x,y;
    int f;

    scanf("%lf %lf %d %d",&W,&H,&x,&y);
    if(x == W/2 && y==H/2){
        f=1;
    } else {
        f=0;
    }

    printf("%.6f %d\n",H*W/2,f);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string.h>
#include<utility>
using namespace std;
int main() {
	string s1,s2;
	cin >> s1 >> s2;
	int m=s1.length();
	int n=s2.length();
	int dp[m+1][n+1];
	for(int i=0;i<m+1;i++){
		for(int j=0;j<n+1;j++){
			if(i==0 || j==0){
				dp[i][j]=0;
			}
			else if(s1[i-1]==s2[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int f=dp[m][n];
	char l[f+1];
	l[f]='\0';
	int i=m,j=n;
	while(i>0 && j>0){
		if(s1[i-1]==s2[j-1]){
			l[f-1]=s1[i-1];
			i--;j--;f--;
		}
		else if(dp[i-1][j]>=dp[i][j-1]){
			i--;
		}
		else if(dp[i][j-1]>=dp[i-1][j]){
			j--;
		}
		
	}
	for(int i=0;i<dp[m][n];i++){
		cout << l[i];
	}
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int k;
    string s;
    cin >> k >> s;
    int n = sz(s);
    combination c(n+k);
    mint ans = 0;
    rep(i, k+1) {
        mint now = mint(26).pow(k-i);
        now *= mint(25).pow(i);
        now *= c(i+n-1, i);
        ans += now;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 35540
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    // fn line(&mut self) -> String {
    //     self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
    //         .skip_while(|&c| c == '\n' || c == '\r')
    //         .take_while(|&c| !(c == '\n' || c == '\r'))
    //         .collect::<String>();
    //     self.buffer.clone()
    // }

    fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            // writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn partition(a: &mut[u32]) -> usize {
    let n = a.len();
    let mut i = 0;
    let x = *a.last().unwrap();
    for j in 0..n{
        if a[j] <= x {
            a.swap(i, j);
            i += 1;
        }
    }
    //a.swap(i, n-1);
    i - 1
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let n: usize = sc.read();
        let mut a = sc.vec(n);
        let q = partition(&mut a[..]);
        for (i, &x) in a.iter().enumerate() {
            if i == q {
                print!("[{}]", x);
            } else {
                print!("{}", x);
            }
            if i == n - 1 {
                print!("{}", '\n');
            } else {
                print!("{}", ' ');
            }
        }
    }
}



Measured memory_bytes: 9160
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  for(int tci = 0; ; tci++) {
    char s1[15];
    if(scanf(" %s", s1)<1) break;
    vector<int> oks;
    for(int num = 0; num < 9; num++) {
      int histo[9]; fill(histo, histo+9, 0);
      for(int i = 0; i < 13; i++) histo[s1[i]-'1']++;
      histo[num]++;
      for(int i = 0; i < 9; i++) if(histo[i]>4) goto fail;
      for(int num2 = 0; num2 < 9; num2++) {
        int histo2[9]; copy(histo, histo+9, histo2);
        if(histo2[num2]<2) continue;
        histo2[num2]-=2;
        //printf("%d,%d: ",num,num2);
        //for(int i = 0; i < 9; i++) printf("%d,",histo2[i]);printf("\n");
        for(int i = 0; i < 9; i++) {
          if(histo2[i]>=3) histo2[i]-=3;
          while(i<=6 && histo2[i]>0) histo2[i]--,histo2[i+1]--,histo2[i+2]--;
          if(histo2[i]!=0) goto subfail;
        }
        goto succ;
subfail:continue;
      }
fail:continue;
succ:oks.push_back(num);
    }
    if(oks.size()==0) {
      printf("0\n");
    } else {
      for(int i = 0; i < (int)oks.size(); i++) {
        printf("%d%c", oks[i]+1, " \n"[i+1==(int)oks.size()]);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

int n,sum;
int main() {
    cin>>n;
    int l[n];
    REP(i,n){
        cin>>l[i];
        sum+=l[i];
    }
    sort(l,l+n,greater<int>());
    sum-=l[0]*2;
    cout<<(sum>0?"Yes":"No")<<endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N, T;
    cin >> N >> T;
    vector<pair<int,int>> dish(N);
    REP(i, N) cin >> dish[i].first >> dish[i].second;

    if(T == 1){
        int ans = 0;
        REP(i, N) ans = max(ans, dish[i].second);
        cout << ans << endl;
        return 0;
    }
    
    sort(dish.begin(), dish.end());

    int ans = 0;
    vector<int> dp(T, 0);
    REP(i, N){
        int A = dish[i].first;
        int B = dish[i].second;
        ans = max(ans, dp[T-1]+B);
        for(int j = T-1; j >= A; --j) dp[j] = max(dp[j], dp[j-A]+B);
        // REP(i, T) cout << dp[i] << " ";
        // cout << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s; cin >> s;
  reverse(All(s));
  string t = "";
  bool f = true;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'm'){
      t = s.substr(i, 5);
      i += 4;
      if(t != "maerd"){
        f = false;
        break;
      }
      t = "";
    }
    else if(s[i] == 'e'){
      t = s.substr(i, 5);
      i += 4;
      if(t != "esare"){
        f = false;
        break;
      }
      t = "";
    }
    else if(s[i] == 'r'){
      if(s[i+2] == 'm'){
        t = s.substr(i, 7);
        i += 6;
        if(t != "remaerd"){
          f = false;
          break;
        }
        t = "";
      }
      else{
        t = s.substr(i, 6);
        i += 5;
        if(t != "resare"){
          f = false;
          break;
        }
        t = "";
      }
    }
    else break;
  }
  if(f)cout << "YES" << endl;
  else cout << "NO" << endl;
  system("pause");
}


Measured memory_bytes: 760
N = gets.to_i
As = gets.split.map(&:to_i)

def attack(arr)
  new_arr = []

  min = arr.min #1

  new_arr.push(min) #[1]

  arr.each do |i|
    next if min == i
    new_arr.push(i.modulo(min)) if i.modulo(min) != 0
  end
  
  return new_arr[0] if new_arr.length == 1

  return attack(new_arr)
end

puts attack(As)

Measured memory_bytes: 11396
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

void print1d(const vector<int>& vec) {
    for (auto val : vec) {
        cout << val << " ";
    }
    cout << endl;
}

void print2d(const vector<vector<int>>& vec) {
    for (auto row : vec) {
        for (auto val : row) {
            cout << val << " ";
        }
        cout << endl;
    }
}

void solve() {
    int x;
    cin >> x;

    int lim = 120;

    for (int i = -lim; i <= lim; i++) {
        for (int j = -lim; j <= lim; j++) {
            if (pow(i, 5) - pow(j, 5) == x) {
                cout << i << ' ' << j << endl;
                return;
            }
        }
    }
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
#endif
    crap;

    solve();

    return 0;
}

Measured memory_bytes: 4064
#include <stdio.h>

int main(void){
    int n, x, max=-1000000, min=1000000;
    long sum=0;

    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%d", &x);
        max = x>max ? x : max;
        min = x<min ? x : min;
        sum += x;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 1028
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int K = N / 2;
	int A[200000];
	rep(i, N) A[i] = getint() - i + N;

	pakuri_sort(N, A);

	ll kotae = 0;
	rep(i, N) kotae += abs(A[i] - A[K]);
	printf("%lld", kotae);

	Would you please return 0;
}

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

int main() {
  
  int n, k;
  cin >> n >> k; //n体 k = 必殺技の回数
  
  vector<int> vec(n);
  
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    vec.at(i) = x;
  }
  
  sort(vec.begin(), vec.end());
  long long total = 0;
  int p = 0;
  
  if(vec.size() > k){
    for(int i = vec.size(); i > k; i--){
      total += vec.at(p);
      p++;
    }
  }
  
  cout << total << endl;
  
  
  
  
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 2048;
int a[MAX_N];
int dp[MAX_N][MAX_N][2];

const int INF = 1001001001;

struct BITMAX {
  int n;
  int vs[MAX_N + 10];
  BITMAX() {
    this->n = MAX_N;
    clear();
  }
  void clear() {
    REP(i, MAX_N + 10) vs[i] = -INF;
  }
  void update(int idx, int val) {
    // for (int x = idx + 1; x <= n; x += x & -x) vs[x] = max(vs[x], val); // [idx, ∞] の範囲の最大値を val で更新しようと試みる
    for (int x = idx + 1; x > 0; x -= x & -x) vs[x] = max(vs[x], val); // [0, idx] の範囲の最大値を val で更新しようと試みる

  }
  
  int get(int idx) {
    int val = -INF;
    // for (int x = idx + 1; x > 0; x -= x & -x) val = max(val, vs[x]); // [idx, ∞] の範囲の最大値を取得
    for (int x = idx + 1; x <= n; x += x & -x)  val = max(val, vs[x]); // [0, idx] の範囲の最大値を取得
    return val;
  }
};

BITMAX max_y[MAX_N];
BITMAX min_x[MAX_N];

int main2() {
  REP(i, MAX_N) max_y[i].clear();
  REP(i, MAX_N) min_x[i].clear();

  int N = nextInt() + 2;
  REP(i, N) a[i] = nextInt();
  // REP(i, N) REP(j, N) REP(t, N) dp[i][j][t] = 0;

  for (int x = 0; x < N - 1; x++) { 
    dp[x][N-1][0] = abs(a[x] - a[N-1]);
    min_x[x].update(N-1, -dp[x][N-1][0]);
  }
  for (int y = 0; y < N - 1; y++) {
    dp[N-1][y][1] = abs(a[y] - a[N-1]);
    max_y[y].update(N-1, dp[N-1][y][1]);
  }
  for (int x = N - 2; x >= 0; x--) {
    for (int y = N - 2; y >= 0; y--) {
      for (int t = 0; t < 2; t++) {
        if (t == 0 && x < y) {
          // int m = -INF;
          // for (int k = y+1; k < N; k++) chmax(m, dp[k][y][1]);
          int m = max_y[y].get(y+1);
          min_x[x].update(y, -m);
          dp[x][y][0] = m;
        }
        if (t == 1 && y < x) {
          // int m = INF;
          // for (int k = x + 1; k < N; k++) chmin(m, dp[x][k][0]);
          int m = -min_x[x].get(x+1);
          max_y[y].update(x, m);
          dp[x][y][1] = m;
        }
      }
    }
  }
  int ans = dp[0][1][0];
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 65792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = unsigned long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
int const mod = 1e9+7;
#define END {cout<<(ans)<<'\n'; return 0;}
#define ALL(vec) vec.begin(),vec.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,s,n) for(int i=s; i<n; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,(n)-1)cout<<a[i]<<' '; cout<<a[(n)-1]<<'\n';
#define prip(p) cout<<(p).first<<' '<<(p).second<<'\n'
template<class T> inline bool cmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool cmax(T& a, T b) { if (a < b) { return a = b; } return false; }

int n,m,q,_,x,y;
string s,sb;
bool ok;
char ch;

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

  while(1){
    cin>>n>>m; if(!(n+m))return 0;
    bool ng[n][m]={}; int dp[n][m]={};
    cin>>q;
    rep(i,q){
      cin>>x>>y;
      ng[x-1][y-1]=1;
    }
    dp[0][0]=1;
    rep(i,n)rep(j,m){
      if(ng[i][j])continue;
      if(i)dp[i][j]+=dp[i-1][j];
      if(j)dp[i][j]+=dp[i][j-1];
    }
    pri1(dp[n-1][m-1]);
  }
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    ll n;
    cin>>n;
    ll ans=(1+n-1)*(n-1-1+1)/2;
    cout<<ans<<endl;
}

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

int grand(int x) {
  switch (x) {
  case 3: return 100000;
  case 2: return 200000;
  case 1: return 300000;
  }
  return 0;
}

int bonus(int x, int y) {
  if (x == 1 && y == 1) return 400000;
  return 0;
}

int main() {
  int x, y;
  cin >> x >> y;
  cout << grand(x) + grand(y) + bonus(x, y) << "\n";
  return 0;
}


Measured memory_bytes: 256
N = int(input())
x = list(map(int, input().split()))
y = [0] * N

odd = sum([n for i, n in enumerate(x) if i % 2 == 1])
even = sum([n for i, n in enumerate(x) if i % 2 == 0])
y[0] = even - odd

for i in range(N-1):
  y[i+1] = 2 * x[i] - y[i]


str_y = map(str, y)
output = " ".join(str_y)
print(output)

Measured memory_bytes: 19144
import java.util.Scanner;

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

		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();

		System.out.println(Math.max(Math.max(Math.abs(a1 - a2), Math.abs(a2 - a3)), Math.abs(a3 - a1)));

		sc.close();

	}
}



Measured memory_bytes: 21716
def resolve():
    a,b=map(int, input().split())
    ans=0
    if a >= b:
        ans+= a
        a = a-1
        if a >= b:
            ans+= a

        elif b > a:
            ans+= b

    elif b > a:
        ans+= b
        b = b-1
        if a >= b:
            ans+= a

        elif b>a:
            ans+= b
    print(ans)
resolve()

Measured memory_bytes: 3060