akhauriyash/Code-Regression huggingface dataset:
// atcoder/abc078/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    cout << 1900.0 * m * (1 << m) + 100.0 * (n - m) * (1 << m) << endl;

    // const int N = 1e6;
    // static double dp[N];
    // const double p = double((1 << m) - 1.0) / (1 << m);
    // dp[1] = 1.0 / (1 << m);
    // for (int i = 2; i < N; ++i) {
    //   dp[i] = (1.0 - dp[i - 1]) / p;
    // }
    // lli sum = 0;
    // for (int i = 1; i < N; ++i) {
    //   sum += dp[i] * (m * 1900.0 + (n - m) * 100.0) * i;
    // }
    // cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string str,ans;
  cin>>str;
  n=str.size();
  ans="Yes";
  for(int i=0; i<(n-1)/2; i++){
    if(str.at(i)!=str.at(n-1-i)){
      ans="No";
      break;
    }
    if(str.at(i)!=str.at((n-1)/2-i-1)){
      ans="No";
      break;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	
	string s;
	cin>>s;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]==s[i+1])
		{cout<<i+1<<" "<<i+2;return 0;}
		 if(s[i]==s[i+2] && i<s.size()-2)
		{cout<<i+1<<" "<<i+3;return 0;}
	}
	cout<<"-1 -1";
	return 0;
}

Measured memory_bytes: 512
N,K=map(int,input().split())
score = {}
L = 0
Z = 0
for i in range(N):
  a,b = map(int,input().split())
  L += b
  if a in score:
    score[a] += b
  else:
    score[a] = b

score_sorted = sorted(score.items(), key=lambda x:x[0])
#print(score_sorted)

for k,v in score_sorted:
  Z += v
  if K <= Z:
    print(k)
    break

Measured memory_bytes: 15040
#include <iostream>
#include <algorithm>
using namespace std;
long long a[100000][3],f[100000][3];
int n;
int main()
{
    cin>>n;
    for (int i=0;i<n;++i) cin>>a[i][0]>>a[i][1]>>a[i][2];
    f[0][0]=a[0][0];
    f[0][1]=a[0][1];
    f[0][2]=a[0][2];
    for (int i=1;i<n;++i){
        for (int j=0;j<3;++j){
            f[i][j]=-10000000000;
            for (int z=0;z<3;++z){
                if (z!=j){
                    f[i][j]=max(f[i][j],f[i-1][z]+a[i][j]);
                }
            }
        }
    }
    cout<<max(max(f[n-1][0],f[n-1][1]),f[n-1][2]);
}


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

#define INF int(1e9)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
int n;
int L[maxn],R[maxn];
set<pii>sL,sR;

int main(){
	scanf("%d",&n);
	REP(i,n)scanf("%d%d",&L[i],&R[i]);
	ll ans=0;
	rep(tp,2){
		sL.clear();
		sR.clear();
		REP(i,n){
			sL.insert(mp(L[i],i));
			sR.insert(mp(R[i],i));
		}
		ll cur=0;
		int x=0;
		REP(i,n){
			if((i+tp)&1){
				assert(!sL.empty());
				set<pii>::iterator it=sL.end(); 
				it--;
				int id=(*it).snd;
				if(L[id]<=x)break;
				cur+=L[id]-x;
				x=L[id];
				sL.erase(sL.find(mp(L[id],id)));
				sR.erase(sR.find(mp(R[id],id)));
			}
			else{
				assert(!sR.empty());
				set<pii>::iterator it=sR.begin();
				int id=(*it).snd;
				if(R[id]>=x)break;
				cur+=x-R[id];
				x=R[id];
				sL.erase(sL.find(mp(L[id],id)));
				sR.erase(sR.find(mp(R[id],id)));
			}
		}
		cur+=abs(x);
		ans=max(ans,cur);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>

using namespace std;

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

    unsigned long A[N];
    for (int i=0; i<N; i++){ cin >> A[i]; }
    
    unsigned long min = 2, max = 2;
    bool res = 1;
    for (int i=(N-1); i>=0; i--){
	
	unsigned long newmin = min, newmax = max;
	
	unsigned long div1 = min/A[i];
	unsigned long div2 = max/A[i];
	unsigned long red1 = min%A[i];
	unsigned long red2 = max%A[i];
	
	if (div1 == div2 && red1 != 0 && red2 != 0){ res = 0; break; }
	else{
	    if (red1 == 0){ }
	    else{ min = A[i]*(div1+1); }
	    
	    max = A[i]*div2;
	}
	
	max += (A[i]-1);
	// cout << i << "  " << min << "  " << max << endl;
    }
    
    if (res){ cout << min << "  " << max << endl; }
    else { cout << -1 << endl; }
    
    return 0;
}

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

typedef pair<int, int> P;

int main() {
	int ck, k, n, m, csh, csm, ceh, cem, cs[100], ce[100];
	vector<P> teachers[100], students[100];
	cin >> ck;
	for(int i = 0; i < ck; ++i){
		scanf("%d:%d-%d:%d", &csh, &csm, &ceh, &cem);
		cs[i] = csh * 60 + csm;
		ce[i] = ceh * 60 + cem;
	}
	cin >> n;
	for(int i = 0; i < n; ++i){
		scanf("%d", &k);
		for(int j = 0; j < k; ++j){
			scanf("%d:%d-%d:%d ", &csh, &csm, &ceh, &cem);
			for(int l = 0; l < ck; ++l)
				if(csh * 60 + csm <= cs[l] && ce[l] <= ceh * 60 + cem)
					teachers[i].push_back(P(csh * 60 + csm, ceh * 60 + cem));
		}
	}
	cin >> m;
	for(int i = 0; i < m; ++i){
		scanf("%d", &k);
		for(int j = 0; j < k; ++j){
			scanf("%d:%d-%d:%d ", &csh, &csm, &ceh, &cem);
			for(int l = 0; l < ck; ++l)
				if(csh * 60 + csm <= cs[l] && ce[l] <= ceh * 60 + cem)
					students[i].push_back(P(csh * 60 + csm, ceh * 60 + cem));
		}
	}
	int ans = 0;
	for(int i = 0; i < ck; ++i){
		int tcnt = 0, scnt = 0;
		for(int j = 0; j < n; ++j){
			for(int l = 0; l < teachers[j].size(); ++l){
				if(teachers[j][l].first <= cs[i] && ce[i] <= teachers[j][l].second){
					tcnt++;
					break;
				}
			}
		}
		for(int j = 0; j < m; ++j){
			for(int l = 0; l < students[j].size(); ++l){
				if(students[j][l].first <= cs[i] && ce[i] <= students[j][l].second){
					scnt++;
					break;
				}
			}
		}
		ans += min(tcnt, scnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1308
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0052
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int cnt = 0;
                for (int i = 1 ; i <= n ; i++)
                {
                    int num = i;
                    while (num % 5 == 0) { cnt++; num /= 5; }
                }
                Console.WriteLine(cnt);
            }
        }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
    }

}



Measured memory_bytes: 15888
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    ans = a*x + b*y
    ans = min(ans, 2*c*max(x, y))
    if x < y:
        d = y - x
        d *= b
    else:
        d = x - y
        d *= a
    ans = min(ans, 2*c*min(x, y)+d)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>

using namespace std;

long long int gcd(long long int a,long long int b)
{
	if(b==0)return a;
	else return gcd(b,a%b);
}

long long int lcm(long long int a,long long int b)
{
	long long int g=gcd(a,b);
	return a/g*b;
}

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

	long long int ans=1;
	long long int t;
	for(int i=0;i<n;i++){
		cin>>t;
		ans=lcm(ans,t);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin>> s[i];
    int di[] = {1, -1, 0, 0}, dj[] = {0, 0, 1, -1};
    REP(i,h) REP(j,w){
        if (s[i][j] == '.') continue;
        bool ok = false;
        REP(k,4){
            int ii = i + di[k], jj = j + dj[k];
            if (ii >= 0 && jj >= 0 && ii < h && jj < w && s[ii][jj] == '#') ok = true;
        }
        if (!ok){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=5e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,m;
struct node{
	int a,b;
}a[maxn];
bool cmp(node a,node b){
	return a.a<b.a;
}
priority_queue<int,vector<int>, greater<int> > q;
signed main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++){a[i].a=read(),a[i].b=read();a[i].a=m-a[i].a+1;}
	sort(a+1,a+1+n,cmp);
	int sum=0,sz=0;
	for(int i=1;i<=n;i++){
		if(a[i].a<=0)continue;
		if(sz<a[i].a){
			q.push(a[i].b);
			sum+=a[i].b;
			sz++;
		}
		else{
			int alfa=q.top();
			if(alfa<a[i].b){
				q.pop();sum-=alfa;
				sum+=a[i].b;
				q.push(a[i].b);
			}
		}
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 2936
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vli vector<lli>
#define vi vector<int>
#define vs vector<string>
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

typedef long long int lli;
typedef long int li;

const lli mod=1000000007;
const lli limit=1000000;

using namespace std;

void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k;
    cin>>n;
    lli cnt[n+1]={0},ans[n+1]={0},arr[n];
    FOR(i,n)cin>>arr[i];
    FOR(i,n)cnt[arr[i]]++;
    temp=0;
    FOR(i,n+1){
        if(cnt[i]){
            ans[i]=(cnt[i]*(cnt[i]-1))/2;
            temp+=ans[i];
        }
    }
    FOR(i,n+1){
        if(cnt[i]){
            ans[i]=temp-ans[i]+(ans[i]*(cnt[i]-2))/cnt[i];
        }
    }
    FOR(i,n)cout<<ans[arr[i]]<<endl;

 
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define INF 1e9;
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(m), y(m);
    vector<vector<int>> work(n+1);
    rep(i, m) {
        cin >> p[i] >> y[i];
        work[p[i]].push_back(y[i]);
    }

    rep(i, n) {
        sort(work[i+1].begin(), work[i+1].end());
    }

    rep(i, m) {
        printf("%012lld\n", ll(p[i])*1000000 + int(lower_bound(all(work[p[i]]), y[i]) - work[p[i]].begin()) + 1);
    }

}

Measured memory_bytes: 7808
M = int(input())
digit_num = 0
digit_sum = 0
for i in range(M):
    d, c = map(int, input().split())
    digit_num += c
    digit_sum += d * c
tmp = 0
if digit_sum % 9 == 0:
    tmp = digit_sum // 9 - 1
else:
    tmp = digit_sum // 9
print((digit_num - 1) + tmp)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int divisor[1000000+10];
int p[1000000+1],pcnt;
void maked(int n){divisor[0]=-1;divisor[1]=1;rep(i,2,n+1){if(!divisor[i])p[pcnt++]=divisor[i]=i;for(int j=0;j<pcnt&&p[j]<=divisor[i]&&i*p[j]<=n;j++)divisor[i*p[j]]=p[j];}}
int divv(ll n,ll*a){//約数（div使用）
	ll cnt=1;a[0]=1;
	while(n!=1){ll num=1,i=divisor[n],temp=i;while(n%i==0){n/=i;num++;}rep(k,1,num){rep(j,0,cnt)a[k*cnt+j]=a[j]*temp;temp*=i;}cnt*=num;}
	//sortup(a,cnt);
	return cnt;
}

int n;
ll a[200010];
int aa[1000010];
ll yakusuu[1000];
int main(){
	maked(1000000+5);
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",a+i);
	rep(i,0,n)aa[a[i]]++;

	int ans=0;
	sortup(a,n);
	rep(i,0,n){
		if((i-1>=0&&a[i-1]==a[i])||(i+1<n&&a[i]==a[i+1]))continue;
		int cnt=divv(a[i],yakusuu);
		int flag=aa[a[i]]==1;
		rep(j,0,cnt)if(yakusuu[j]!=a[i])flag&=aa[yakusuu[j]]==0;
		if(flag)ans++;
	}
	
	printf("%d",ans);
}

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

P p[100];
double det(P a, P b) {
	return a.first*b.second - a.second*b.first;
}
P operator-(P a, P b) { return P(a.first - b.first, a.second - b.second); }
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n)scanf("%lf,%lf", &p[i].first, &p[i].second);
		sort(p, p + n);
		vector<P>a(n * 2);
		int k = 0;
		rep(i, n) {
			while (k > 1 && det(a[k - 1] - a[k - 2], p[i] - a[k - 2]) < 0)k--;
			a[k++] = p[i];
		}
		for (int i = n - 2, t = k; i >= 0; i--) {
			while (k > t && det(a[k - 1] - a[k - 2], p[i] - a[k - 2]) < 0)k--;
			a[k++] = p[i];
		}
		printf("%d\n", n - k + 1);
	}
}

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 - (y2 - y1) << ' ' << y2 + (x2 - x1) << ' '
         << x1 - (y2 - y1) << ' ' << y1 + (x2 - x1) << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

N, A, B, C, D = map(int, input().split())
inputs = list(input())

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-2, D-1):
        if inputs[index] != '#' and inputs[index+1] != '#' and inputs[index+2] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')


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

using namespace std;

int par[1001];

void init(int n)
{
    memset(par, -1, sizeof(par));
}

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

void merge(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return;
    
    if (-par[x] < -par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
}

bool same(int x, int y)
{
    return (find(x) == find(y));
}


int main()
{
    int n, m;
    
    while (scanf("%d %d", &n, &m) && n){
        vector<pair<int, pair<int, int> > > es(m);
        
        for (int i = 0; i < m; i++){
            int a, b, c;
            scanf("%d %d %d", &a, &b, &c);
            es[i] = make_pair(c, make_pair(a, b));
        }
        
        sort(es.begin(), es.end());
        
        int l = 1, r = 1000;
        
        while (l != r){
            int mid = l + r >> 1;
            init(n + 1);
            int ec = 0;
            int i = 0;
            while (ec != n - 1 && i != m){
                if (ec + 1 <= n / 2 && es[i].first > mid){
                    i++;
                    continue;
                }
                if (!same(es[i].second.first, es[i].second.second)){
                    merge(es[i].second.first, es[i].second.second);
                    ec++;
                }
                i++;
            }
            
            if (ec == n - 1) r = mid;
            else l = mid + 1;
        }
        
        printf("%d\n", l);
    }
    
    return (0);
}

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

int main()
{
    int K,N;
    cin >> K >> N;
    
    vector<int> a(N);
    for(int i = 0;i<N;i++)
    {
        cin >> a[i];
    }
    
    vector<int> b(N);
    for(int i = 0;i<N-1;i++)
    {
        b[i] = a[i+1] - a[i];
    }
    b[N-1] = K + a[0] - a[N-1];
    
    int temp = 0;
    for(int i=0;i<N;i++)
    {
        temp = max(temp,b[i]);
    }
    
    cout << K - temp << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

vector<long long> heights;
vector<long long> sums;

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

    for (int i = 1; i <= n; ++i) {
        int temp;
        cin >> temp;
        heights.emplace_back(temp);
    }
    sums.emplace_back(0);
    sums.emplace_back(abs(heights[1] - heights[0]));

    for (int i = 2; i < n; ++i)
        sums.emplace_back(min(abs(heights[i] - heights[i-1]) + sums[i-1], abs(heights[i] - heights[i-2]) + sums[i-2]));

    cout << sums[n-1];
}


Measured memory_bytes: 5504
# -*- coding: utf-8 -*-
N, D, A = map(int, input().split(' '))
X_H_pairs = [list(map(int, input().split(' '))) for _ in range(N)]

X_H_pairs.sort(key=lambda x: x[0])

import math
i, ans = 0, 0
powers = []
damage = 0
while i < N:
    x, h = X_H_pairs[i]
    if powers:
        while powers and x - powers[0][0] > 2*D:
            damage -= powers[0][1]
            powers.pop(0)

    h -= damage
    if h <= 0:
        i += 1
        continue
    else:
        times = int(math.ceil(h / A))
        ans += times

        dh = times * A
        damage += dh
        powers.append((x, dh))
        i += 1

print(ans)

Measured memory_bytes: 101848
#include<stdio.h>

int main(){
    
	int N = 0;//??\?????°(?????°)
	int i = 0;//??????????????°
	int D = 0;//??????
	int now_d = 0;//????????°
	int now_s = 0;//?????¨?????????
    int now_f = 0;//?????¨????????°(0????????????????????±???)
	int f_diff = 0;//f-now_f    
	long long total_s = 0;//?????????????????????
	int s = 0;//??\????§???°
	int f = 0;//??\????????°
	
	scanf("%d %d",&N,&D);
	for(i = 0;i < N;i++){
		scanf("%d %d",&s,&f);
	    if(total_s < 0) continue;//total_s???-1??§???N??????????´??????????????????????????????????
		f -= 1;//??\???????????????1????????????????????§0?????????????????±???
		f_diff = f - now_f;//?????°??????
	    if(f_diff < 0) f_diff *= (-1);//?????°???????????¶?????????
		if((s - now_s) >= (f + now_f)){//?????¶2
			total_s += 1LL * now_f * now_d;//??????
			now_s = s;
			now_f = f;
			now_d = 1;
		}
        else if(((s - now_s) >= f_diff)&&(now_d < D)){//?????¶3???????????¶1
			total_s += 1LL * (s - now_s) * now_d;
			now_s = s;
			now_f = f;
			now_d += 1;
		}
        else total_s = -1;
	}
	if(total_s < 0){ 
		printf("%d\n",total_s);//total_s = -1?????´??????-1?????????
	}
    else{
		total_s += 1LL * now_f * now_d;//??????????????????????¨?
		printf("%lld\n",total_s);
	}
    return 0;
}

Measured memory_bytes: 1860
import Control.Applicative

main = do
        [x,y] <- map read.words<$>getLine
        if x > y then print $ gcd' x y
                 else print $ gcd' y x

gcd' :: Int -> Int -> Int
gcd' x y
    | modXY == 0 = y
    | otherwise    = gcd' y modXY 
    where modXY = mod x y

Measured memory_bytes: 3612
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a,b;
  while(cin>>a>>b)
    cout<<a+b<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
bool Check(string S,int l,int r){
    
    l--;
    r--;
    
    while(1){
        
        if(S[l] != S[r]) return false;
        l++;
        r--;
        if(r < l) break;
    }
 
    return true;
}

int main(void){
    
  string S;
  cin >> S;
  int N = S.size();
  
  if(Check(S,1,N) && Check(S,1,(N-1)/2) && Check(S,(N+3)/2,N)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> E(n + 1), W(n + 1);
	E[0] = 0;
	W[0] = 0;
	rep(i, s.size()) {
		if (s[i] == 'E') {
			E[i + 1] = E[i] + 1;
			W[i + 1] = W[i];
		}
		else {
			E[i + 1] = E[i];
			W[i + 1] = W[i] + 1;
		}
	}
	int ans = s.size();
	rep(i, n) {
		int ansi;
		if (i == 0) {
			ansi = E[n] - E[1];
		}
		else if (i == s.size() - 1) {
			ansi = W[n - 1] - W[0];
		}
		else {
			ansi = W[i] - W[0] + E[n] - E[i];
		}
		ans = min(ans, ansi);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
#ifdef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
  boost::for_each(vc, [&os](T value) {
#else
  std::for_each(vc.begin(), vc.end(), [&os](T value) {
#endif
    os << value << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;
  ui N{}; cin >> N;
  vector<ull> v(N);
  rep(0, N) cin >> v[i];
  ull sum{};
  ull highest{};
  boost::for_each(v, [&sum, &highest](auto v) {
    if (v >= highest)
    {
      ++sum;
      highest = v;
    }
    });

  using std::cout;
  cout << sum << '\n';
  return;
}

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

  solve();

  return 0;
}


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

int main(){
  int n;
  double d;
  cin >> n;
  for (int i=0; i<n; ++i){
    double a;
    cin >> a;
    d+=1/a;
  }
  cout << setprecision(10) << 1/d << endl;
}

Measured memory_bytes: 256
import numpy as np
A, B, H, M = map(int, input().split())

deg = min(abs(H*360/12 + M*360/12/60 - M*360/60), 360 - abs(H*360/12 + M*360/12/60 - M*360/60))
theta = deg * np.pi /180
ans = np.sqrt(np.power(A,2)+np.power(B,2)-2*A*B*np.cos(theta))
 
print(ans)

Measured memory_bytes: 27328
N = int(input())
H = list(map(int, input().split()))
cnt = 0
maxc = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        maxc = max(maxc, cnt)
        cnt = 0
maxc = max(maxc, cnt)    
print(maxc)

Measured memory_bytes: 14252
#include "bits/stdc++.h"
#define   LF      '\n'
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f'3f3f3f3fLL;


signed main()
{
  int N, T;
  int ans = INF;

  cin >> N >> T;
  for (int i = 0; i < N; ++i) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      chmin(ans, c);
    }
  }

  if (ans >= INF) {
    puts("TLE");
  } else{
    cout << ans << endl;
  }
  return 0;
}



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

signed
main(){
		int a,b;
		while(cin >> a >> b && !(a==0 && b==0))
		{
				if(a<b) cout << a << " " << b << endl;
				else cout << b << " " << a << endl;
		}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;cin>>n;
  int h[100000];
  int ans=0,cnt=0;
  int prev=-10;
  rep(i,n){
    cin>>h[i];
    if(prev >= h[i]){
      prev=h[i];
      cnt++;
    }else{
      ans=max(ans,cnt);
      cnt=0;
      prev=h[i];
    }
  }
  ans=max(ans,cnt);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

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

int main()
{
  int S, W;
  cin >> S >> W;
  if (W >= S)
  {
    cout << "unsafe" << endl;
  }
  else
  {
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int n,x,a,r;
int cmmdc(int a,int b)
{ int r;
  if(a<b)
     r=a,a=b,b=r;
  r=a%b;
  while(r!=0)
  { a=b;
    b=r;
    r=a%b;
  }
  return b;
}
int main()
{ cin>>n>>x;
  for(int i=1;i<=n;i++)
  { cin>>a;
    if(a<x)
       a=x-a;
    else
       a=a-x;
    if(i==1)
    { r=a;
      continue;
    }
    if(a==1)
    { cout<<"1";
      return 0;
    }
    if(a>0)
       r=cmmdc(a,r);
  }
  cout<<r;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter, deque

INF = float('inf')

""" Input
S = input()
N = int(input())
N, A, B = map(int, input().split())
D = [int(input()) for _ in range(N)]
"""

def main():
    A = list(map(int, input().split()))
    if sum(A) > 21:
        print('bust')
    else:
        print('win')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
<?php

[$N] = fscanf(STDIN, "%d");
$map = fscanf(STDIN, str_repeat("%d", $N));

$neg = 0;
$pos = 0;
$neg_count = 0;
$pos_count = 0;

foreach($map as $key => $value){
    if($key % 2 === 1){
        $neg += $value;
        if($neg >= 0){
            $neg_count += $neg + 1;
            $neg = -1;
        }
        $pos += $value;
        if($pos <= 0){
            $pos_count += ($pos * -1) + 1;
            $pos = 1;
        }
    }else{
        $neg += $value;
        if($neg <= 0){
            $neg_count += ($neg * -1) + 1;
            $neg = 1;
        }
        $pos += $value;
        if($pos >= 0){
            $pos_count += $pos + 1;
            $pos = -1;
        }
    }

}

echo min($pos_count, $neg_count);

Measured memory_bytes: 22548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException{
        FastReader sc = new FastReader();
        String a = sc.next();
        String b = sc.next();
        if (a.length() > b.length()){
            boolean f = true;
            for (int i=0;i<b.length();i++){
                if (a.charAt(i) != b.charAt(i)){
                    f=false;
                    System.out.println("No");
                    break;
                }
            }
            if(f) System.out.println("Yes");

        }else {
            boolean f = true;
            for (int i=0;i<a.length();i++){
                if (a.charAt(i) != b.charAt(i)){
                    f=false;
                    System.out.println("No");
                    break;
                }
            }
            if(f) System.out.println("Yes");
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 32684
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int r;
	cin >> r;
	cout << (r*r) << 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 MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s;
    cin >> s;
    string ans = "No";
    if (s.substr(0, 4) == "YAKI") ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input())

import math

#ans = ['']*3

def p_m(num):
  if math.floor(num)%2 == 0:
    return '+'
  else :
    return '-'

for i in range(8):
  if a + ( (-1)**(math.floor(i/4)) )*b + ((-1)**(math.floor(i/2)))*c + ((-1)**(math.floor(i)))*d == 7:
#    ans = [p_m(i/4),p_m(i/2),p_m(i)]
    break

print(str(a)+p_m(i/4)+str(b)+p_m(i/2)+str(c)+p_m(i)+str(d)+'=7')

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

#define ll long long int

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

int main() {
    ll k;
    cin >> k;
    string s;
    cin >> s;

    ll res = 0;
    ll ncr = 1;
    ll m = s.size();
    for (ll i = 0; i <= k; ++i) {
        ll tmp = mpow(26, (k-i));
        tmp = tmp * ((ncr * mpow(25, i))%MOD);
        tmp %= MOD;
        //cerr << tmp << endl;

        res += tmp;
        res %= MOD;

        ncr = ncr * (i+m);
        ncr %= MOD;
        ncr = ncr * mpow((i+1), MOD-2);
        ncr = (ncr + MOD) % MOD;
    }
    cout << res << endl;



}


Measured memory_bytes: 5336
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pii pair<int,int>
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a); i>=(b);i--) 

const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;


string s[maxn];

int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   int n; cin >> n;
   rep(i,1,n){
      cin >> s[i];
      sort(s[i].begin(), s[i].end());
   }
   sort(s + 1 , s + 1 + n);
   ll ans = 0; int pos = 1;
   rep(i,2,n){
      if(s[i] == s[pos]) ans += (i - pos) * 1ll;
      else pos = i;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 5760
s = input()
l = list(s)
count = 0
ans = 0
for i in range(len(l)):
    if l[i] == "A" or l[i] == "T" or l[i] == "G" or l[i] == "C":
        count += 1
        continue
    ans = max(ans,count)
    count = 0
ans = max(ans,count)
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	W := sc.nextIntSlice(N)
	min := int(1e9)
	for t := 0; t < N-1; t++ {
		s1 := 0
		for i := 0; i <= t; i++ {
			s1 += W[i]
		}
		s2 := 0
		for i := t + 1; i < N; i++ {
			s2 += W[i]
		}
		if abs(s2-s1) < min {
			min = abs(s2 - s1)
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using maze = vector<string>;

const int NOT_VISITED = -1;

const char WALL = '#';
const char PATH = '.';

int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};

int main() {
  int h, w;
  cin >> h >> w;

  maze m(h);
  for (auto& x : m)
    cin >> x;

  int cnt = 0;

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (m[i][j] == WALL)
        continue;

      // bfs
      int tmp = 0;
      queue<pair<int, int>> q;
      vector<vector<int>> dist(h, vector<int>(w, NOT_VISITED));

      dist[i][j] = 0;
      q.emplace(i, j);

      while (!q.empty()) {
        int ch = q.front().first, cw = q.front().second;
        q.pop();

        for (int k = 0; k < 4; ++k) {
          int nh = ch + dh[k], nw = cw + dw[k];
          if (nh < 0 || h <= nh || nw < 0 || w <= nw || m[nh][nw] == WALL)
            continue;

          if (dist[nh][nw] == NOT_VISITED) {
            q.emplace(nh, nw);
            dist[nh][nw] = dist[ch][cw] + 1;
            tmp = max(tmp, dist[nh][nw]);
          }
        }
      }

      cnt = max(cnt, tmp);
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
# vim: set fileencoding=utf-8:
"""
X,Yの区間は[1, pow(10,18)]であり、全探索すると日が暮れる。
厳密には、区間[X, Y]のすべてを検証する必要はないはずで、
[X, 2*X]でいいはずである。たぶん。

"""


def main():
    X, Y = map(int, raw_input().split())
    ans = 0
    temp = 0

    X2 = 2 * X
    ct = 0
    for i, _ in enumerate(xrange(X2), X):
        ct += 1
        n = i
        while n <= Y:
            temp += 1
            n *= 2

        ans = max(ans, temp)
        temp = 0
        if ct == 400000:
            break

    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 2568
#include<bits/stdc++.h>
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


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

	
	ll A, B, X;
	cin >> A >> B >> X;

	ll kotae = B / X + 1;
	if (A > 0) kotae -= (A - 1) / X + 1;

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#ライブラリの点検
class Data():
    def __init__(self):
        self.power=1
        self.rev=1     
class Combi():
    def __init__(self,N,mod):
        self.lists=[Data() for _ in range(N+1)]
        self.mod=mod  
        for i in range(2,N+1):
            self.lists[i].power=((self.lists[i-1].power)*i)%self.mod
        self.lists[N].rev=pow(self.lists[N].power,self.mod-2,self.mod)
        for j in range(N,0,-1):
            self.lists[j-1].rev=((self.lists[j].rev)*j)%self.mod

    def combi(self,K,R):
        if K<R:
            return 0
        else:
            return ((self.lists[K].power)*(self.lists[K-R].rev)*(self.lists[R].rev))%self.mod

######################
h,w,a,b=map(int,input().split())
ans=0
mod=10**9+7
C=Combi(w+h+2,mod)
for i in range(h-a):
    ans+=C.combi(b+i-1,i)*C.combi(w+h-2-b-i,h-1-i)%mod
print(ans%mod)
######################

Measured memory_bytes: 50420
"use strict";
const main = arg => {
  let city = arg.split("\n")[0];
  let monster = arg.split("\n")[1].split(" ").map(n=> n*1);
  let yusya =  arg.split("\n")[2].split(" ").map(n=> n*1);
  let ans = 0;
  for(let i = 0; i < city; i++){
    // まずは左側にあるモンスターを全力で倒す
    let left = Math.min(monster[i],yusya[i]);
    ans += left;
    monster[i] -= left;
    yusya[i] -= left;
    
    // 残った戦力で右を全力で倒す
    let right = Math.min(monster[i+1],yusya[i]);
    ans += right;
    monster[i+1] -= right;
    yusya[i] -= right;
  }
  console.log(ans);
}

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


Measured memory_bytes: 32172
#include <bits/stdc++.h>
using namespace std;
double dp[305][305][305];
bool done[305][305][305];
int n;
double dfs(int a, int b, int c) {
    if (done[a][b][c]) return dp[a][b][c];
    if (a == 0 && b == 0 && c == 0) return 0;
    done[a][b][c] = true;
    double ret = 0;
    double n_p = (double)n;
    double a_p = (double)a / n_p, b_p = (double)b / n_p, c_p = (double)c / n_p;
    n_p = 1 / (1 - (double)(n - a - b - c) / n_p);
    ret += n_p;
    if (a > 0) ret += dfs(a-1, b, c) * n_p * a_p;
    if (b > 0) ret += dfs(a + 1, b - 1, c) * n_p * b_p;
    if (c > 0) ret += dfs(a, b + 1, c - 1) * n_p * c_p;
    // printf("%f, %f, %f\n", a_p, b_p, c_p);
    return dp[a][b][c] = ret;
}
int main() {
    cin >> n;
    int cnt[4] = {0, 0, 0, 0};
    for (int i = 0; i < 305; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++)
        done[i][j][k] = false;
    for (int i = 0; i < n; i++) {
        int a_temp;
        cin >> a_temp;
        cnt[a_temp]++;
    }
    // cout << cnt[1] << endl;
    // cout << cnt[2] << endl;
    // cout << cnt[3] << endl;
    // cout << dfs(1, 1, 1) << endl;
    cout << fixed << setprecision(20) << dfs(cnt[1], cnt[2], cnt[3]) << endl;
    return 0;
}


Measured memory_bytes: 140320
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int h=in(),w=in(),k=in();
    vector<vec> a(h,vec(w));
    rep(i,h){
        string s=stin();
        rep(j,w){
            if(s[j]=='#')a[i][j]=1;
            else a[i][j]=0;
        }
    }
    vector<vec> ans(h,vec(w));
    vec lack;
    int tmp=0;
    rep(i,h){
        tmp++;
        int cnt = 0;
        rep(j,w){
            if(a[i][j]==1){
                if(cnt > 0)tmp++;
                cnt++;
            }
            ans[i][j] = tmp;
        }
        if(cnt==0){
            lack.pb((int)i);
            tmp--;
        }
    }
    
    rep(i,lack.size()){
        int hh = lack[i];
        if(hh > 0){
            rep(j,w)ans[hh][j]=ans[hh-1][j];
        }
    }
    rep3(i,lack.size() - 1,0){
        int hh = lack[i];
        if(hh < h-1){
            rep(j,w)ans[hh][j]=ans[hh+1][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}


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

ll solve() {
    string S;
    cin >> S;
    ll g = 0, p = 0;
    for ( char c : S ) {
        if ( c == 'g' ) g++;
        else if ( c == 'p' ) p++;
    }
    return (g - p) / 2;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K;
    cin >> N >> K;
    deque<int> V(N);
    rep(i, 0, N) cin >> V[i];

    int ans = 0;
    rep(l, 0, K + 1) {
        rep(r, 0, K + 1) {
            int d = K - (l + r);
            if (d < 0) continue;
            auto deq = V;
            multiset<int> se;
            rep(i, 0, l) {
                if (sz(deq)) {
                    se.insert(deq.front());
                    deq.pop_front();
                }
            }
            rep(i, 0, r) {
                if (sz(deq)) {
                    se.insert(deq.back());
                    deq.pop_back();
                }
            }
            rep(i, 0, d) {
                if (sz(se)) {
                    auto itr = se.begin();
                    if (*itr < 0) {
                        se.erase(itr);
                    }
                }
            }
            int tmp = 0;
            for (int x : se) {
                tmp += x;
            }
            dump(l, r, d, tmp);
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



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

using namespace std;

int N;
int query;
set<int> mochi;

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

	for(int i = 0; i < N; i++)
	{
		scanf("%d", &query);
		mochi.insert(query);
	}

	int finalAns = mochi.size();
	printf("%d\n", finalAns);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc170/tasks/abc170_d

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

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2*1e5;
const int A_I_MAX = 1e6;

int N;
vector<int> A;
vector<bool> f;

int main() {
  cin >> N;
  A = vector<int>(N);
  REP(i, N) cin >> A[i];

  sort(A.begin(), A.end());
  A.push_back(A_I_MAX + 1);

  f = vector<bool>(A_I_MAX + 1, false);
  int ans = 0;
  REP(i, N) {
    int a = A[i];
    if (f[a]) continue;
    if (A[i + 1] != a) ans++;
    for (int j = a; j <= A_I_MAX; j += a) f[j] = true;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4848