akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);		
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		int ans = 0;
		if(a+w<b){
			ans = b-(a+w);
		}else if(b+w<a){
			ans = a-(b+w);
		}
	
		System.out.println(ans);

	}

}

Measured memory_bytes: 22608
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int):
    cand = [1]
    a = 6
    while a < 10**5:
        cand.append(a)
        a *= 6
    a = 9
    while a < 10**5:
        cand.append(a)
        a *= 9
    cand.sort()
    M = len(cand)

    dp = [0]*(N+1)
    for i in range(1, N+1):
        dp[i] = min([dp[i-cand[j]]+1 for j in range(M) if i-cand[j] >= 0])
    print(dp[N])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
import sys
import math
import bisect
import atexit
import io
import heapq
from collections import defaultdict, Counter
MOD = int(1e9+7)



# n = map(int, raw_input().split())
# input = map(int, raw_input().split())
def main():
    k, x = map(int, raw_input().split())
    for i in range(-k+1, k):
        print x+i,

main()


Measured memory_bytes: 28012
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ll h, w;
    sf(h, w);
    ll s = 0;

    if (h == 1 || w == 1) {
        out(1);
        return 0;
    }

    if (h & 1) {
        ll a = h / 2 + 1;
        if (w & 1) {
            s += a * (w / 2 + 1);
        }else {
            s += a * (w / 2);
        }

        ll b = h - a;
        s += b * (w / 2);
    }else {
        ll a = h / 2;
        if (w & 1) {
            s += a * (w / 2 + 1);
        }else {
            s += a * (w / 2);
        }

        ll b = h - a;
        s += b * (w / 2);
    }

    out(s);
    return 0;
}

Measured memory_bytes: 256
while True:
    x = input().split(" ")
    a = int(x[0])
    b = int(x[2])
    op = x[1]
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    elif op == "?":
        break


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;

int main() {
	ll n; cin >> n;
	ll L[10] = {};

	ll max = 0;
	ll maxIndex = 0;
	rep(i, 0, n) {
		ll l; cin >> l;
		L[i] = l;
		if (max < l) {
			max = l;
			maxIndex = i;
		}
	}

	ll sum = 0;
	rep(i, 0, n) {
		if (maxIndex != i) {
			sum += L[i];
		}
	}
	cout << ((max < sum) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>

using namespace std;

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

int main() {
  int l, a, b, c, d;
  cin >> l >> a >> b >> c >> d;
  cout << l - max((a + c - 1) / c, (b + d - 1) / d) << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int n;
    cin>>n;

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

    int dp[n],mn;

    dp[0]=0;

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

        if(i==1)
            dp[i]=abs(a[i]-a[i-1])+dp[i-1];
        else
            dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);

    }

    /*for(int i=0; i<n; i++)
    {
        cout<<dp[i]<<endl;
    }*/

    cout<<dp[n-1]<<endl;




    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(string S, long long K){
    REP(i, min(K, (LL)S.size())) {
        if(S[i] != '1') {
            cout << S[i] << endl;
            return;
        } 
    }

    cout << 1 << endl;
}

int main(){
    string S;
    cin >> S;
    long long K;
    scanf("%lld",&K);
    solve(S, K);
    return 0;
}



Measured memory_bytes: 256
//g++でビルド

#include "bits/stdc++.h"

using namespace std;


int main(){

    int D;
    cin >> D;
    string result = "Christmas";
    int num = 25 - D;
    for(int i = 0; i < num; i++){
        result += " ";
        result += "Eve";
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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 M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int c=0,n;string s;cin>>n>>s;
  reps(i,0,10){
    reps(j,0,10){
      reps(k,0,10){
        bool f=false,ff=false;
        rep(d,n){
          if(f&&ff){
            if(s[d]==(char)('0'+k)){
              c++;break;
            }continue;
          }
          if(f&&!ff){
            if(s[d]==(char)('0'+j)){
              ff=true;
            }continue;
          }
          if(!f&&!ff){
            if(s[d]==(char)('0'+i)){
              f=true;
            }
          }
        }
      }
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int total,sum,n,i;
  while(1){
    sum=0;
    scanf("%d",&total);
    if(total==0)
      break;
    for(i=0; i<9; i++){
      scanf("%d",&n);
      sum+=n;
    }
    printf("%d\n",total-sum);
  }
  return 0;
}



Measured memory_bytes: 2044
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
idx = 0

ans = 0
def dfs(idx, st):
    global ans
    if idx==10:
        return
    if int(st)>N:
        return
    elif len(set(st))>=3:
        ans += 1
    for nx in ('3', '5', '7'):
        dfs(idx+1, st+nx)

for nx in ('3', '5', '7'):
    dfs(1, nx)
print(ans)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll tmp = k - (a + b);
  if(tmp > 0) {
    cout << a + tmp * -1 << endl;
  } else {
    cout << min(a,k) << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
a,b,m=map(int,input().split())
alist=tuple(map(int,input().split()))
blist=tuple(map(int,input().split()))

mlist=[]
for i in range(m):
    mlist.append(tuple(map(int,input().split())))

minimum=min(alist)+min(blist)

for i in range(m):
    tempx,tempy,tempc=mlist[i]
    discountsum=alist[tempx-1]+blist[tempy-1]-tempc
    if  discountsum < minimum:
        minimum=discountsum

print(minimum)


Measured memory_bytes: 28780
#include<stdio.h>
int main() {
  int w, h, x, y, r;
  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
  if (0 <= x - r && 0 <= y - r && w >= x + r && h >= y + r) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define fastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define scan(a) scanf("%d", &a)
#define scanll(a) scanf("%lld", &a)
#define scanD(a) scanf("%lf", &a)
#define print(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printD(a) printf("%lf\n", a)
#define printTwo(a) printf("%.2lf\n", a);
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */


void solve() {
	int k, n;
	scan(k), scan(n);
	int arr[n];
	rep(i, 0, n) {
		scan(arr[i]);
	}
	int endmark;
	int minDis = INT_MAX;

	rep(i, 0, n) {
		int start = arr[i];

		if (i != n - 1) {
			endmark = arr[i + 1];
			minDis = min(minDis, abs(start - 0) + abs(k - endmark));
		} else {
			endmark = arr[0];
			minDis = min(minDis, abs(start - endmark));
		}
	}
	print(minDis);
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif

	solve();

	// __test {
	// 	solve();
	// }

	showTime;
	return 0;
}




Measured memory_bytes: 4584
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,h[100005],dp[100005]={}; //={}は、０初期化
  cin >>n;
  for(int i=1; i<=n; i++){
    cin >>h[i];
  }
  dp[1]=0;
  for(int i=2; i<=n; i++){
    if(i!=2){
      dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    }else{
    dp[i]=abs(h[i]-h[i-1])+dp[i-1];
    }
  }
  cout <<dp[n]<<'\n';
  return(0);
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int x[110000];
int y[110000];
int sum[110000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		int p;scanf("%d",&p);
		p--;x[p]=i;y[p]=j;
	}
	for(int i=0;i<a*b;i++){
		if(i>=c){
			sum[i]=sum[i-c];
			sum[i]+=ABS(x[i]-x[i-c])+ABS(y[i]-y[i-c]);
		}
	}
	int d;scanf("%d",&d);
	while(d--){
		int l,r;scanf("%d%d",&l,&r);l--;r--;
		printf("%d\n",sum[r]-sum[l]);
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int T1,T2,A1,A2,B1,B2;
    int C1,C2;
    cin >> T1 >> T2;
    cin >> A1 >> A2;
    cin >> B1 >> B2;
    
    C1=T1*(A1-B1);
    C2=T2*(A2-B2);
    if(C1+C2==0){
        cout << "infinity" << endl;
        return 0;
    }
    
    if(abs(C1)>abs(C2) || (C1>0&&C2>0)|| (C1<0&&C2<0)){
        cout << 0 << endl;
        return 0;
    }
    if(C1+C2<0){C1*=-1;C2*=-1;}
    
    
    //cout << C1 MM C2 << endl;
    //cout << C1 + C2 << endl;
    //cout << C2/(C1 + C2) << endl;
    
    /*
    int K=0;
    REP(i,100){
        K+=C1;cout << 2*i+1 MM K << endl;
        K+=C2;cout << 2*i+2 MM K << endl;
    }*/
    int K=(-C1/(C1 + C2));
    cout << 2*K+1+((-C1)%(C1+C2)==0?-1:0) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	LL N, L;
	cin >> N >> L;
	deque<pair<LL, LL>>que;//first:体積 second:熱量
	LL Q = 0;//dequeに含まれる熱量の和
	LL V = 0;//dequeに含まれる体積の和
	cout.precision(15);
	for (int i = 0; i < N; ++i)
	{
		LL t, v;
		cin >> t >> v;
		LL q = t * v;
		//水の流入
		//過去で排出していたことにする(過去改変(いいえ))
		while (V + v > L)
		{
			auto fr = que.front();
			if (V + v - fr.first >= L)
			{
				V -= fr.first;
				Q -= fr.second;
				que.pop_front();
			}
			else
			{
				LL dif = V + v - L;
				LL tt = que[0].second / que[0].first;
				que[0].first -= dif;
				que[0].second -= dif * tt;
				V = L - v;
				Q -= dif * tt;
			}
		}
		que.push_back({ v,q });
		Q += q;
		V += v;
		//必要に応じて統合する
		while (que.size() > 1)
		{
			LL t1 = que[que.size() - 2].second / que[que.size() - 2].first;
			LL t2 = que[que.size() - 1].second / que[que.size() - 1].first;
			if (t1 > t2)
			{
				auto p1 = que[que.size() - 2];
				auto p2 = que[que.size() - 1];
				que.pop_back();
				que.pop_back();
				que.push_back({ p1.first + p2.first,p1.second + p2.second });
			}
			else
			{
				break;
			}
		}

		//今ある熱量/体積が答え
		assert(V == L);
		auto ans = (long double)Q / V;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 16656
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

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

    int a, b;
    cin >> a >> b;
    int keta = 0, c = b;
    while (c > 0)
    {
        keta++;
        c /= 10;
    }
    rep(i, keta) a *= 10;
    int d = a + b;
    for (int i = 0; i * i <= d; i++)
    {
        if (i * i == d)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
key = [100000,200000,300000]
ans = 0
if x==1 and y== 1:
  print(300000*2+400000)
else:
  if x<4:
    ans += key[-x]
  if y<4:
    ans += key[-y]
  print(ans)

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

const long long INF = 1LL << 60;

void solve() {
  int n; cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; ++i) cin >> h.at(i);
  vector<long long> dp(n,INF);
  dp[0] = 0;
  dp[1] = abs(h.at(1)-h.at(0));

  for(int i=0; i<n-2; ++i) {
    int a = dp.at(i) + abs(h.at(i)-h.at(i+2));
    int b = dp.at(i+1) + abs(h.at(i+1)-h.at(i+2));
    dp.at(i+2) = min(a,b);
  }
  cout << dp.at(n-1) << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 4504
#include <stdio.h>

int main(void)
{
 int n,S[10000],q,T[500],C=0,i=0,j=0;

 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%d",&S[i]);
 }

 scanf("%d",&q);
 for(i=0;i<q;i++){
  scanf("%d",&T[i]);
 }

 i=0;

 while( i < q ){

  while( S[j] != T[i] ){

   j++;

   if( j == n ) break;

  }

  if( S[j] == T[i] ) C++;

  i++;

  j=0;

 }

 printf("%d\n",C);

 return 0;

}

Measured memory_bytes: 1824
N = int(input())
A = list(map(int, input().split()))
factor = 1
X = [0] * N
for i in range(N):
  if i == 0:
    factor = 1
    for j in range(N):
      X[0] += A[j] * factor
      factor = -factor
  else:
    X[i] = 2 * A[i-1] - X[i-1]
print(' '.join(map(str, X))) 


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int n, ans = 0, mn = 1e9;
  cin >> n;
  for (int i = 0, a = 0; i < n; ++i) {
    cin >> a;
    if (a <= mn) ++ans;
    mn = min(a, mn);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
void dumpmat(VEC<VEC<int>> &m) {
  REP(i, 0, m.size()) {
    REP(j, 0, m[i].size()) { cout << m[i][j]; }
    cout << "\n";
  }
}
int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  auto M = MATINIT(int, max(H, W), max(H, W), 0);
  auto show = [&]() {
    REP(i, 0, H) {
      REP(j, 0, W) { cout << M[i][j]; }
      cout << '\n';
    }
  };
  auto check_invalid = [&]() -> bool {
    REP(i, 0, H) {
      int c = 0;
      REP(j, 0, W) {
        if (M[i][j]) c++;
      }
      if (min(c, W - c) != A) {
        // show();
        return 1;
      }
    }
    REP(j, 0, W) {
      int c = 0;
      REP(i, 0, H) {
        if (M[i][j]) c++;
      }
      if (min(c, H - c) != B) {
        // show();
        return 1;
      }
    }
    return 0;
  };
  REP(i, 0, H - B) {
    REP(j, 0, A) { M[i][j] = 1; }
  }
  REP(i, H - B, H) {
    REP(j, A, W) { M[i][j] = 1; }
  }
  if (check_invalid()) {
    cout << "No" << endl;
    // show();
    return 0;
  }
  show();
  return 0;
}


Measured memory_bytes: 5120
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut h: usize = read();
    let mut c: usize = 0;
    let mut d: usize = 1;

    while h > 0 {
        c += d;
        d *= 2;
        h /= 2;
    }

    println!("{}", c);
}


Measured memory_bytes: 4352
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] map = new int[n+1][n+1];
		for(int i=0;i<m;i++) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			int x = Integer.parseInt(sc.next());
			map[a][b] = x+1;
		}
		int cnt = 0;
		for(int i=1;i<=n;i++) for(int j=1;j<=i;j++) {
			map[i][j] = max(map[i][j], max(map[i-1][j-1]-1, map[i-1][j]-1));
//			debug(i, j, map[i][j]);
		}
		for(int i=1;i<=n;i++) for(int j=1;j<=i;j++)
			if(map[i][j]>0) cnt++;
//		for(int[] a: map)debug(a);
		System.out.println(cnt);
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int a[ N ];

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n;
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        for( int i = n - 1; i >= 1; i-- ) {
                if( a[i] > a[i+1] ) a[i]--;
        }
        bool f = true;
        for( int i = 1; i < n; i++ ) f &= ( a[i] <= a[i+1] );
        cout << ( f ? "Yes" : "No" ) << endl;
        return 0;
}










Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;

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

    if(n == 100) {
        n = 101;
    }

    int ans = 1;

    for(int i = 0; i < d; ++i) {
        ans *= 100;
    }

    ans *= n;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	vector<pair<string, char>> ans;
	ans.emplace_back("a", 'a');
	for(int i = 1; i < n; ++i) {
		vector<pair<string, char>> nxt;
		for(auto& e : ans) {
			string s = e.first;
			char c = e.second;
			for(char cc = 'a'; cc <= (char)(c + 1); ++cc) {
				nxt.emplace_back(s + cc, max(cc, c));
			}
		}
		ans = nxt;
	}
	sort(ans.begin(), ans.end());
	for(auto& s : ans) {
		cout << s.first << '\n';
	}
	return 0;
}

Measured memory_bytes: 10984
#include<iostream>
#include<vector>

using namespace std;

int main()
{
  int N,A,B;
  cin >> N >> A >> B;

  int x1=0, x2=0, x3=0;
  for( int i=0;i<N;i++)
    {
      int tmp;
      cin >> tmp;
      if( tmp<=A )
	x1 += 1;
      else if( tmp>=A+1 && tmp<=B )
	x2 += 1;
      else
	x3 += 1;
    }
  cout << min(x1, min(x2, x3)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
#define pb push_back
#define ins insert
#define pll pair<ll,ll>
#define fi first
#define se second
#define mpr make_pair
#define vtr vector
#define itor iterator 
#define N ll(1e9+7)
#define endl '\n'
#define cont continue
using namespace std;
//ll power(ll a,ll b,ll mod)
//{
//	if(b==0)return 1;
//	ll ans=1;
//	while(b>0)
//	{
//		if(b&1)ans=(ans*a)%mod;
//		a=(a*a)%mod;
//		b>>=1;
//	}
//	return ans;
//}
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;ll ans;
	if(k<=a)
	{
		ans=k;
	}
	else if(k<=a+b)
	{
		ans=a;
	}
	else
	{
		ans=a;
		ans-=(k-(a+b));
	}cout<<ans;
}

Measured memory_bytes: 3588
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run(){
	n := nextInt()
	s := next()
	
	if n >=3200 {
		Println(s)
	}else{
		Println("red")
	}
}
 
 
// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func readIntArray(n int) ([]int) {
	v := make([]int, 0)
	for i := 0; i < n; i++ {
		v = append(v, nextInt())
	}
	return v
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 300005
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

int n;

int main() {
	scanf("%d",&n);
	while(n--)
		printf("ACL");
	return 0;
}

Measured memory_bytes: 3712
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	static Scanner in;
	static PrintWriter out;

	static void solve() {
		String S = in.nextLine();
		out.print(S.charAt(0));
		int length = S.length();
		out.print(length-2);
		out.println(S.charAt(length-1));
	}

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
		out.close();
		in.close();
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   string s;
   cin>>s;

   if(s[0] == s[1] && s[1] == s[2])
   	cout<<"No";
   else
   	cout<<"Yes";
   return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main
{	
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
	
		long MOD = 1000000007;
		
		Map<Integer , Integer> map = new HashMap<Integer , Integer>();
		int n = scan.nextInt();
		for (int i = 1;i <= n;i ++)
		{
			int value = i;
			for (int j = 2;j <= n;j ++)
			{
				if (value % j == 0)
				{
					int cnt = 0;
					while (value % j == 0)
					{
						value /= j;
						cnt ++;
					}
					if (!map.containsKey(j))
						map.put(j , 0);
					map.put(j , map.get(j) + cnt);
				}
			}
		}
		
		long ans = 1;
		for (int value : map.values())
			ans = (ans * (value + 1)) % MOD;
		System.out.println(ans);
	}
    
}










Measured memory_bytes: 10924
s = input()
def kaibunn(a):
  for i in range(len(a)//2):
    if not a[i] == a[-1-i]:
      return 0
  return 1
n =len(s) 
if kaibunn(s) == 1 and kaibunn(s[:(n-1)//2]) == 1 and kaibunn(s[(n+3)//2-1:])==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int h,w,n;cin>>h>>w>>n;
	cout<<(n-1)/max(h,w)+1<<endl;
}


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

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

const long long inf = 1e18;
vector<long long> a;

//dp[i]:石の個数がi個の時の局面の勝敗のbool値

int main() {
    int N, K;
    cin >> N >> K;
    a.resize(N);
    bool dp[K+1];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= K; i++) dp[i] = false;

    for (int i = 1; i <= K; i++) {
        for (int j = 0; j < N; j++) {
            if (i-a[j] >= 0) dp[i] |= !dp[i-a[j]]; //遷移先が0であれば1、遷移先が1にしかできない場合は0
        }
    }

    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import timeit
import time
import sys
import io
import re
import math
#start = time.time()
#start = time.clock()
while True:
    l = []
    (n,x)=map(int, raw_input().split())
    if n==x==0:
        break
    ans=0
    for a in range(1,n+1):
        l.append(a)
    for i in l:
        if i > 98: break
        for j in l:
            if j > 99 or i+j>x: break
            p=0
            for k in l:
                p=i+j+k
                if (i != j and j != k and k != i) and p==x and i<j<k:
                    ans+=1
    print ans

#end = time.clock()
#print end - start

Measured memory_bytes: 4672
import sys

while True:
    count = 0
    n, x = list(map(int, input().split(' ')))
    if n == 0 and x == 0:
        sys.exit(0)
    for i in range(n+1):
        for j in range(n+1):
            for k in range(n+1):
                if i >= j or j >= k or i == 0:
                    continue
                if i + j + k == x:
                    count += 1
    print(count)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

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

    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<3;i++)if(s[i]=='1')ans++;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto a = RDR.split.to!(long[]);
	
	auto dp = new long[](100002);
	foreach (e; a)
	{
		++dp[e];
		++dp[e+1];
		++dp[e+2];
	}
	dp.sort();

	writeln(dp[$-1]);
	stdout.flush();
}

Measured memory_bytes: 4272
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  ll n,k; cin>>n>>k;
	ll ans = 0;
	while(n>=1){
		n /= k; ans++;
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

int main() {
    int X;
    cin >> X;
    if (X < 600)
        cout << 8 << endl;
    else if (X < 800)
        cout << 7 << endl;
    else if (X < 1000)
        cout << 6 << endl;
    else if (X < 1200)
        cout << 5 << endl;
    else if (X < 1400)
        cout << 4 << endl;
    else if (X < 1600)
        cout << 3 << endl;
    else if (X < 1800)
        cout << 2 << endl;
    else
        cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
src = []
for i in range(2*N):
    src.append((int(input()), i//N))

ans = 1
MOD = 10**9+7
mem = [0, 0]
for a,t in sorted(src):
    if mem[1-t] > 0:
        ans = (ans * mem[1-t]) % MOD
        mem[1-t] -= 1
    else:
        mem[t] += 1
print(ans)

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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL,LL> PLL;
typedef map<int,int> MII;
typedef queue<int> QI;
typedef queue<PII> QPII;
typedef stack<int> SI;
typedef stack<PII> SPII;
typedef deque<int> DI;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define PF push_front
#define POB pop_back()
#define POF pop_front()
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REPR(i,n) RFOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;
const LL MODD = 998244353;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

VI dx = {1,0,-1,0,1,1,-1,-1};
VI dy = {0,1,0,-1,1,-1,1,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(N == 0) {
    return 0;
  }
  
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int L;
  cin >> L;
  
  double B = (double)L/(double)3;
  
  cout << fixed << setprecision(9) << B*B*B << endl;
  
  return 0;
}


Measured memory_bytes: 384
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
p = 1

60.times do |k|
  p *= 2 if k!=0
  p %= 1000000007
  z = 0
  o = 0
  n.times do |i|
    if a[i][k] == 0
      z += 1
    else
      o += 1
    end
  end
  ans += z*o*p
  ans %= 1000000007
end

puts ans

Measured memory_bytes: 34820
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct a{
  int num;
  struct a *next,*prev;
}Node;

void insert(int n,Node* nil){
  Node* node = (Node*)malloc(sizeof(Node));
  node->num=n;
  nil->next->prev = node;
  node->next = nil->next;
  node->prev = nil;
  nil->next = node;
}

void delete(Node* node){
  node->next->prev = node->prev;
  node->prev->next = node->next;
  free(node);
}

void dsearch(Node* nil,int x){
  Node* node;
  for(node=nil->next;node!=nil;node = node->next){
    if(node->num==x){
      delete(node);
      break;
    }
  }
}

int main(void){
  int h,i,x;
  char str[16];
  Node *nil;
  Node *lac;
  nil = (Node*)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%s",str);
    if(strcmp(str,"deleteFirst")==0){
      delete(nil->next);
    }else if(strcmp(str,"deleteLast")==0){
      delete(nil->prev);
    }else if(strcmp(str,"insert")==0){
      scanf("%d",&x);
      insert(x,nil);
    }else if(strcmp(str,"delete")==0){
      scanf("%d",&x);
      dsearch(nil,x);
    }
  }
  for(lac=nil->next;lac!=nil;lac=lac->next){
    printf("%d",lac->num);
    if(lac->next!=nil){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}




Measured memory_bytes: 32984
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n,k;
  cin>>n>>k;
  veci v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  int sum=0;
  rep(j,k)sum+=v[j];
  cout<<sum<<endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	string a,b;
	ll i,j;
	cin>>a>>b;
	ll n=a.length();
	ll m=b.length();
	ll arr[n+1][m+1];
	for(i=0;i<n+1;i++)
	{
		for(j=0;j<m+1;j++)
			arr[i][j]=0;
	}
	for(i=1;i<n+1;i++)
	{
		for(j=1;j<m+1;j++)
		{
			if(a[i-1]==b[j-1])
			{
				arr[i][j]=arr[i-1][j-1]+1;
			}
			else
			{
				arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
			}
		}
	}
	string ans;
	i=n;
	j=m;
	while(arr[i][j]!=0)
	{
		if(arr[i][j]!=arr[i-1][j] && arr[i][j]!=arr[i][j-1])
		{
				ans+=a[i-1];
				i=i-1;
				j=j-1;
		}
		else if(arr[i][j]==arr[i-1][j])
		{
			i=i-1;
			j=j;
		}	
		else
		{
			i=i;
			j=j-1;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    vector<ll> c(120000, 0);
    ll MAX = 0;
    for(ll i = 0; i < n; i++){
        ll a; cin >> a;
        c[a]++;
        MAX = max(MAX,a);
    }
    ll ans = 0;
    ans = c[0]+c[1];
    for(ll i = 1; i <= MAX; i++){
        ll count = c[i-1]+c[i]+c[i+1];
        ans = max(ans, count);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N,A;
  cin >> N >> A;
  if (N%500-A<=0){
    cout << "Yes" <<endl;
  }
  else if (N<A){
    cout<< "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   int N;
   cin>>N;
   vector<int>A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   int countk=0;
   for(int i=0;i<N;i++){
   if(A[i]%2!=0){countk++;}
   }
   if(countk%2==0){cout<<"YES"<<endl;}
   else{cout<<"NO"<<endl;}
return 0;}

Measured memory_bytes: 640