akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long cf(long long x){
	long long s=0;
	while(x){
		s+=x%10;
		x/=10;
	}
	return s;
}
int main(){
	long long ans=1,p=1,k;
	scanf("%lld",&k);
	for(long long i=1;i<=k;i++){
		printf("%lld\n",ans);
		long long a1=ans+p,a2=ans+p*10;
		if(a1*cf(a2)<=a2*cf(a1))
			ans=a1;
		else{
			ans=a2;
			p*=10;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//nani?
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const int inf=1e7;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 1e5+5;
#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;}
 
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
//---------------------------


int main(){
    fastio;
    string a;
  	cin>>a;
  	if(a[2]==a[3] && a[4]==a[5]) cout<<"Yes";
      else cout<<"No";

}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    char S[1001] = {}, hoge[1001] = {};
    int w, i, len = 0;
    scanf(" %s %d", &S, &w);

    for(i = 0; i < 1001; i++)
    {
        if(S[i] != 0){len++;}
    }

    for(i = 0; i < len; i++)
    {
        if((i+w)%w == 0){hoge[i/w] = S[i];}
    }
    printf("%s", hoge);

    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
vector<int>v;
vector<int>w;
vector<int>x;
int main(){
	cin>>N;
	if(N==3){
		cout<<2<<" "<<5<<" "<<63<<endl;
	}else if(N==4){
		cout<<2<<" "<<5<<" "<<20<<" "<<63<<endl;
	}else{
		vector<int>ans;
		if(N%2==1){
			ans.push_back(6);
		}
		ans.push_back(3);
		ans.push_back(9);
		REP(i,30001){
			if(i==0)continue;
			if(i%2==0&&i%3!=0){
				ans.push_back(i);
			}
		}
		//cout<<ans.size()<<endl;
		REP(i,30001){
			if(i==0)continue;
			if(i==3)continue;
			if(i==9)continue;
			if(i%3==0&&i%2!=0){
				ans.push_back(i);
			}
		}
		REP(i,30001){
			if(i==0)continue;
			if(i==6)continue;
			if(i%6==0){
				ans.push_back(i);
			}
		}
		ans.push_back(6);
		//cout<<ans.size()<<endl;
		REP(i,N){
			cout<<ans[i];
			if(i==N-1){
				cout<<endl;
			}else{
				cout<<" ";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 2000003;
const int MOD = 1000000007;

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

// 二項係数計算
int 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;
}

        signed main() {
    cout<<fixed<<setprecision(10);
        int n;
        cin>>n;
        string s;
        cin>>s;
        int ans1=0;
        for(int i=0;i<n;i++)if(s[i]=='E')ans1++;
        int ans2=n;
        for(int i=0;i<n;i++){
                if(s[i]=='E')ans1--;
                ans2=min(ans2,ans1);
                if(s[i]=='W')ans1++;
        }
        cout<<ans2;
       

        }


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int t;
  int n;
  cin>>n;
  if(!(n%1000)) cout<<0<<endl;
  else cout<<1000-n%1000<<endl;
  return 0;
}


Measured memory_bytes: 3620
S = [input() for _ in range(int(input()))]
from collections import Counter
ctr = Counter(S)
n = ctr.most_common()[0][1]#一番頻度の高い
ans = []

for k,v in ctr.items():
    if v == n:ans.append(k)
ans.sort()
print(*ans,sep="\n")

Measured memory_bytes: 45072
#include<set>
#include<map>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<algorithm>
#define endl '\n'
#define rtl rt<<1
#define rtr rt<<1|1
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define maxx(a, b) (a > b ? a : b)
#define minn(a, b) (a < b ? a : b)
#define zero(a) memset(a, 0, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define _test printf("============\n")
using namespace std;
typedef long long ll;
typedef pair<int, char> P;
typedef pair<ll, ll> P2;
const double pi = acos(-1.0);
const double eps = 1e-7;
const ll MOD =  1000000007LL;
const int INF = 0x3f3f3f3f;
const int NIL = -1;
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
const int maxn = 1e5+10;
inline ll f(ll x) {
    return x*x*x*x*x;
}
int main() {
    ll x; cin >> x;
    for (ll i = -1000; i<=1000; ++i)
        for (ll j = -1000; j<=1000; ++j) {
            if (f(i)-f(j)==x) {
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_V 101
#define MAX_E 10000
#define INF 1e9
 
int N, M, L;
struct edge{
    int to, dist, enemy;
    edge(int to, int dist, int enemy) : to(to), dist(dist), enemy(enemy) {}
};
 
struct State{
    int v, dist, l;
    State(int v, int dist, int l) : v(v), dist(dist), l(l) {}
 
    bool operator < (const State &s)const{
	return dist > s.dist;
    }
};
 
vector<edge> G[MAX_E];
int d[MAX_V][MAX_V];
 
int dijkstra(){
    int res = INF;
    priority_queue<State> Q;
    fill(d[0], d[N], INF);
    d[0][L] = 0;
    Q.push(State(0,0,L));
 
    while(!Q.empty()){
	State st = Q.top(); Q.pop();
	int v = st.v;
 
	if(v == N-1){
	    res = min(res, st.dist);
	    continue;
	}
 
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    edge e = G[v][i];
	    if(d[e.to][st.l] > d[v][st.l] + e.enemy){
		d[e.to][st.l] = d[v][st.l] + e.enemy;
		Q.push(State(e.to, d[e.to][st.l], st.l));
	    }
	}
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    edge e = G[v][i];
	    if(st.l - e.dist >= 0 && d[e.to][st.l-e.dist] > d[v][st.l]){
		d[e.to][st.l-e.dist] = d[v][st.l];
		Q.push(State(e.to, d[e.to][st.l-e.dist], st.l-e.dist));
	    }
	}
    }
    return res;
}
 
int main(){
    int a, b, d, e;
    while(cin >> N >> M >> L, (N | M | L)){
	for(int i = 0 ; i < MAX_E ; i++){
	    G[i].clear();
	}
	for(int i = 0 ; i < M ; i++){
	    cin >> a >> b >> d >> e;
	    a--, b--;
	    G[a].push_back(edge(b,d,e));
	    G[b].push_back(edge(a,d,e));
	}
	cout << dijkstra() << endl;
    }
    return 0;
}

Measured memory_bytes: 3720
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b,c,d,n; cin >> a >> b >> c >> d >> n;
  
  ll k = min({8*a,4*b,2*c,d});
  
  if(n % 2 == 0){
    cout << n / 2 * k << endl;
  }
  else {
    cout << n / 2 * k + min({4*a,2*b,c}) << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,m=0;
    cin >> n;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        m+=a;
    }
    if (m%2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}
 
 

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

const int N = 2e5 + 7;

int n;
vector<int> pos[N];
int cnt[N], res[N];
set<int> have_a, have_b;
set<pair<int, int>> st;

int get(int i) {
    return (int)pos[i].size() + cnt[i];
}

void pairup(int i, int j) {
    res[pos[i].back()] = j;
    pos[i].pop_back();
    --cnt[j];
}

void add(int i) {
    if (get(i) > 0) st.insert({get(i), i});
    if (!pos[i].empty()) have_a.insert(i);
    if (cnt[i] > 0) have_b.insert(i);
}

void del(int i) {
    if (get(i) > 0) st.erase({get(i), i});
    if (!pos[i].empty()) have_a.erase(i);
    if (cnt[i] > 0) have_b.erase(i);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        pos[a].push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        int b;
        cin >> b;
        ++cnt[b];
    }
    for (int i = 0; i < N; ++i) {
        if (get(i) > n) {
            cout << "No\n";
            return 0;
        }
        add(i);
    }
    int cur_n = n;
    while (!st.empty()) {
        int cur = st.rbegin()->second;
        del(cur);
        if (!st.empty() && st.rbegin()->first == cur_n) {
            int who = st.rbegin()->second;
            del(who);
            if (!pos[cur].empty() && cnt[who] > 0) pairup(cur, who); else pairup(who, cur);
            add(who);
        } else {
            if (!pos[cur].empty() && !have_b.empty()) {
                int who = *have_b.begin();
                del(who);
                pairup(cur, who);
                add(who);
            } else {
                int who = *have_a.begin();
                del(who);
                pairup(who, cur);
                add(who);
            }
        }
        add(cur);
        --cur_n;
    }
    cout << "Yes\n";
    for (int i = 0; i < n; ++i) cout << res[i] << " ";
    return 0;
}


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

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

  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());

  int leng = 0;
  for (int i = 0; i < k; ++i) {
    leng += l.at(n - 1 - i);
  }
  cout << leng << endl;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    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;
    }
}
#define comuse Comuse()
ll combi(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;
}

int main() {
  ll n,a;
  cin>>n>>a;
  ll b=2*a+1;
  if(n/b==0){
    co(1);
  }
  else if(n%b==0){
    co(n/b);
  }
  else{
    co(n/b+1);
  }
}
        

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

using namespace std;

int main() {
	int a,b,c;
	
	//入力
	cin >> a >> b >> c;

	int maxCandy = max({ a, b, c });

	//出力
	if (maxCandy==a) {
		if (a == (b + c)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (maxCandy == b) {
		if (b == (a + c)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (maxCandy == c) {
		if (c == (a + b)) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}


}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,x,a[MAXN];
ll sum[MAXN];
int main()
{
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    ll ans=LONG_LONG_MAX;
    for(int k=1;k<=n;k++)
    {
        ll res=1LL*(n+k)*x;
        int cur=n,now=5;
        int len=min(k*2,cur);
        res+=1LL*now*(sum[cur]-sum[cur-len]);
        cur-=len;
        if(res>=ans) continue;
        while(cur>0)
        {
            now+=2;
            int len=min(k,cur);
            res+=1LL*now*(sum[cur]-sum[cur-len]);
            cur-=len;
            if(res>=ans) break;
        }
        ans=min(ans,res);
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10;

int main(void) {
    for (int i = 1; i <= 5; ++i) {
        int in; cin >> in;
        if (!in) 
            cout << i << endl;
    }
}

Measured memory_bytes: 3612
import java.util.*;

class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int ans[] = new int[6];
		for(int i=0; i<n; i++){
			double d = in.nextDouble();
			ans[(d<165)?0:(d<170)?1:(d<175)?2:(d<180)?3:(d<185)?4:5]++;
		}
		for(int i=0; i<6; i++){
			System.out.print((i+1) + ":");
			for(int j=0; j<ans[i]; j++)
				System.out.print('*');
			System.out.println();
		}
	}
	
}

Measured memory_bytes: 12000
#include <stdio.h>

int main() {
  long long X;
  scanf("%lld", &X);

  long long year = 0;
  long long amount = 100;

  while (amount < X) {
    amount = amount + amount / 100;
    year = year + 1;
  }

  printf("%lld\n", year);

  return 0;
}

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

int main() {

	int x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> x1 >> y1 >> x2 >> y2;

	int vec1, vec2, wec1, wec2;
	vec1 = x2 - x1;
	vec2 = y2 - y1;
	wec1 = -vec2;
	wec2 = vec1;
	x3 = x2 + wec1;
	y3 = y2 + wec2;
	x4 = x3 - vec1;
	y4 = y3 - vec2;
	cout << x3 << " " << y3 << " " << x4 << " " << y4;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
ll a[N];
int main(int argc, char const *argv[]) {
  int n = read();
  for (int i = 1; i <= n; ++ i) {
    a[i] = read();
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++ i) {
    ans += a[i] >> 1;
    if ((a[i] & 1) && a[i + 1]) {
      -- a[i + 1];
      ++ ans;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
w, h = map(int, raw_input().split())
p = []
q = []
for i in xrange(w):
    p.append(int(raw_input()))
for i in xrange(h):
    q.append(int(raw_input()))

wl = w
hl = h

cost = 0

p.sort()
q.sort()

p.append(10 ** 8 + 1)
q.append(10 ** 8 + 1)

pc = 0
qc = 0

while(wl + hl - pc - qc> 0):
    if p[pc] < q[qc]:
        cost += (hl - qc + 1) * p[pc]
        pc += 1
    else:
        cost += (wl - pc + 1) * q[qc]
        qc += 1

print cost



Measured memory_bytes: 9536
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void calc(int n, string s) {
    auto t = s;
    for (int i = 0; i < n; i++) {
        t = t.group.map!(e => "%s%s".format(e[1], e[0])).join;
    }
    writeln(t);
}

void main() {
    int n;
    while ((n = readint()) > 0) {
        auto s = readln.chomp;
        calc(n, s);
    }
}

Measured memory_bytes: 3484
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        es: [(usize1, usize1); 3],
    }

    let f =
        |u: usize, v: usize| -> bool { es.iter().find(|&&e| e == (u, v) || e == (v, u)).is_some() };

    let mut ok = false;

    for i in 0..4 {
        for j in 0..4 {
            for k in 0..4 {
                for l in 0..4 {
                    if i == j || i == k || i == l || j == k || j == l || k == l {
                        continue;
                    }
                    if f(i, j) && f(j, k) && f(k, l) {
                        ok = true;
                        // println!("{} {} {} {}", i, j, k, l);
                    }
                }
            }
        }
    }

    let ans = if ok { "YES" } else { "NO" };

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


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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    ll X,K,D,a,b,ans;

    cin >>X>>K>>D;
    if(X<0)X*=-1;
       a=X%D;
       b=X/D;
       if(b<K){ 
           if((K-b)%2==0)ans=a;
       else ans=D-a;

       } 
      
       else ans=X-D*K;

    cout<<ans ;
    return 0;
}

Measured memory_bytes: 3612
#pragma warning(disable:4996)
#include <stdio.h>

int main(void) {
	int a;
	scanf("%d", &a);
	int i = 0;
	int num;
	double num_;
	double ans = 0;
	while (i<a) {
		scanf("%d", &num);
		num_ = (double)1 / num;
		ans += num_;
		++i;
	}
	ans = 1 / ans;
	printf("%f\n", ans);
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++) cin>>l[i];
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){
                    if((l[i]+l[j])>l[k]&&(l[i]+l[k])>l[j]&&(l[k]+l[j])>l[i])
                        ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll K, X; cin >> K >> X;
  if (K * 500 >= X) {
    cout << "Yes\n";
  }else {
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{

    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//----------------------------------------------------------------

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for (int i = 0; i < m; i++)
    {
        cin >> x[i];
    }
    if (n >= m)
    {
        cout << "0" << endl;
    }
    else
    {
        sort(x.begin(), x.end());
        vector<ll> dist(m - 1);
        ll sum = 0;
        for (int i = 0; i < m - 1; i++)
        {
            dist[i] = x[i + 1] - x[i];
        }
        sum = x[m - 1] - x[0];
        sort(dist.begin(), dist.end(), greater<ll>());
        ll save = 0;
        for (int i = 0; i < n - 1; i++)
        {
            save += dist[i];
        }
        cout << seinomi(sum - save) << endl;
    }
}

Measured memory_bytes: 1792
N = int(input())
dp = [0] * (N+1)
dp[0] = 1
ans = 0

P = [float(x) for x in input().split()]

for i, p in enumerate(P):
    a = dp[0]
    dp[0] *= 1 - p
    for j in range(1, i+2):
        b = dp[j]
        dp[j] = a * p + b * (1 - p)
        a = b

        if j > N // 2:
            ans += dp[j]
            dp[j] = 0
            break

print(ans)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    SORT(a);
    vector<pair<int,int>> p(m);
    rep(i,m){
        int b,c;
        cin >> b >> c;
        p[i] = MP(c,b);
    }
    SORT(p);
    int q = 0;
    rep(i,m){
        int C = p[m-1-i].fi;
        int B = p[m-1-i].se;
        int x = 0;
        rep(i,B){
            if(a[q] < C){
                a[q] = C;
                q++;
            }else{
                x = 1;
            }
        }
        if(x)break;
    }

    int s = 0;
    rep(i,n)s += a[i];
    cout << s << endl;
    

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc127.contest.atcoder.jp/tasks/abc127_a

Measured memory_bytes: 2560
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
             line = Console.ReadLine().Trim().Split(' ');
            var p = Array.ConvertAll(line, int.Parse);
            Array.Sort(p);
            if (p[0] == 1) { Console.WriteLine(0); goto exit; }
            var smaLL = getSMALL(p);
            var big = 0;
            var w = n - 1;
            while (w >= 1)
            {
                if (checkBIG(p,w)) { big = w; break; }
                w--;
            }
            Console.WriteLine((smaLL + big)/2d);
            exit:;
        }
    }
    static int getSMALL (int [] p)
    {
        return Min(1, p[0]);
    }
    static bool  checkBIG (int [] p , int t)
    {
        foreach (var x in p)
            if (t % x != 0) return true;
        return false;
    }
}



Measured memory_bytes: 15992
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = sc.nextInt();
		for (int i = 1; i < n; i++) {
		    ans = gcd(ans, sc.nextInt());
		}
		System.out.println(ans);
   }
   
   static int gcd(int x, int y) {
       if (x % y == 0) {
           return y;
       } else {
           return gcd(y, x % y);
       }
   }
}


Measured memory_bytes: 48300
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	p := r.nextStringArray().toInts()

	mp := []int{300000, 200000, 100000}

	ans := 0
	ct := 0
	for _, v := range p {
		pt := v - 1
		if pt < len(mp) {
			ans += mp[pt]
			if pt == 0 {
				ct++
			}
		}
	}
	fmt.Fprintln(stdout, ans+[]int{0, 400000}[b2i(ct >= 2)])
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template <int COL_SIZE> class mat {
private:
    // (or, and) の意味での積(正方かつ対称行列に限る(重みなし無向グラフの隣接行列とか))
    mat operator*(const mat& m) const {
        mat ans;
        for(int i = 0; i < COL_SIZE; i++){
            for(int j = 0; j < COL_SIZE; j++){
                if(this->a[i][j] == 0) continue;
                ans.a[i] |= m.a[j];
            }
        }
        return ans;
    }
    
public:
    bitset<COL_SIZE>* a;
    int r;
    // 正方行列の場合
    mat(){ a = new bitset<COL_SIZE>[COL_SIZE]; }
    // 一般の行列の場合
    mat(int row_size) : r(row_size){ a = new bitset<COL_SIZE>[r]; }
    int rank() const {
        int res = 0;
//        mat<COL_SIZE> b(r);
//        for(int i = 0; i < r; i++) b[i] = a[i];
        auto b = a;
        for(int i = 0; i < COL_SIZE; i++){
            if(res == r) return res;
            int pivot = res;
            if(!b[pivot][i]){
                for(int j = res + 1; j < r; j++){
                    if(b[j][i]){
                        pivot = j;
                        break;
                    }
                }
                if(!b[pivot][i]) continue;
                swap(b[pivot], b[res]);
            }
            for(int j = res + 1; j < r; j++){
                if(b[j][i]) b[j] ^= b[res];
            }
            res++;
        }
        return res;
    }
    inline const bitset<COL_SIZE>& operator[](size_t index) const {
        return a[index];
    }
    inline bitset<COL_SIZE>& operator[](size_t index){
        return a[index];
    }
    friend mat pow(mat m, long long cnt){
        mat res;
        for(int i = 0; i < COL_SIZE; i++) res[i][i] = 1;
        while(cnt){
            if(cnt & 1){
                res = res * m;
            }
            m = m * m;
            cnt >>= 1;
        }
        return res;
    }
};
ll mod = 998244353;
ll mod_pow(ll a, ll b){
    if(b==0)return 1;
    if(b==1)return a;
    ll res = mod_pow(a,b/2);
    res = res * res % mod;
    if(b%2)res = res * a % mod;
    return res;
}
int main(){
    int n,m;
    cin >> n >> m;
    mat<305>a(m+5);
    rep(i,n){
        rep(j,m){
            int x;
            cin >> x;
            a[i][j] = x;
        }
    }
    int r = a.rank();
    cerr << r << endl;
    cout << (mod_pow(2,n+m-1) - mod_pow(2,n+m-r-1) + mod ) % mod << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n1, n2, n3;

  scanf("%d", &n1);
  scanf("%d", &n2);
  scanf("%d", &n3);

  if (n1 < n2 && n2 < n3)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}



Measured memory_bytes: 1728
r_dict = {"I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000}
while True:
    try:
        s = 0
        b = 0
        r = input()
        for i in range(len(r))[::-1]:
            a = r_dict[r[i]]
            if b <= a:
                s += a
            else:
                s -= a
            b = a
        print(s)
    except:
        break



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

const int MOD = 1000000007;
#define p(var)  std::cout<<var<<std::endl
#define pp(var) std::cout<<#var" = "<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for (int i = 0; i <  (n); i++)
#define repeq(i, n) for (int i = 1; i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
using ll = long long;
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
inline double isint(double a) { return a>=0 && ceil(a)==floor(a); }

/*-----8<-----8<-----*/


int main(){
    int N,K;
    string S;
    cin >> N >> S >> K;

    string aaa="";
    char r=S[K-1];
    rep(i,S.size()){
        if(r==S[i]){aaa+=S[i];}
        else{aaa+='*';}
    }


    cout << aaa << endl;
    return 0;
}



Measured memory_bytes: 256
import numpy as np
n, m = list(map(int, input().split()))
xl = list(map(int, input().split()))

xl.sort()
xd = np.diff(xl)
sxd = sorted(xd)

if n > m :
    ans = 0
else :
    ans = sum(sxd[:m-n])

print(ans)

Measured memory_bytes: 23048
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,m=n1()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

div=make_divisors(m)
i=bisect_right(div,m//n)
print(div[i-1])

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=3000;
const int INF=1e9+10;

int n,k,q,m,a[N];
vector<int> vc;

int cal(int x) {
	vector<int> u,v;
	//printf("x=%d\n",x);
	for(int i=1;i<=n;i++) {
		if(a[i]<x) {
			if(u.size()>=k) {
				sort(u.begin(),u.end());
				for(int j=0;j<u.size()-k+1;j++) {
					v.push_back(u[j]);
				}
			}
			u.clear();
		}
		else {
			u.push_back(a[i]);
		}
	}
	if(u.size()>=k) {
		sort(u.begin(),u.end());
		for(int j=0;j<u.size()-k+1;j++) {
			v.push_back(u[j]);
		}
	}
	if(v.size()<q) return INF;
	sort(v.begin(),v.end());
	//printf("val=%d\n",v[q-1]-v[0]);
	return v[q-1]-v[0];
}

int main() {
	scanf("%d %d %d",&n,&k,&q);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		vc.push_back(a[i]);
	}
	sort(vc.begin(),vc.end());
	m=unique(vc.begin(),vc.end())-vc.begin()+1;
	vc.resize(m);
	int ans=INF;
	//printf("m=%d\n",m);
	for(int i=0;i<m;i++) {
		ans=min(ans,cal(vc[i]));
	}
	printf("%d\n",ans);
}

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

int main(){
  string s;
  cin >> s;
  string ans = "No";
  for(int i = 0; i < 3; i ++){
    if(s.at(i) == '7')
      ans = "Yes";
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 3600
import java.util.*;

public class Main {
	static int N;
	static long A, B;
	static long[] S;
	static BinaryIndexedTree bitA;
	static BinaryIndexedTree bitB;
	static final long MOD = 1_000_000_000 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextLong();
		B = sc.nextLong();
		S = new long[N];
		bitA = new BinaryIndexedTree(N);
		bitB = new BinaryIndexedTree(N);
		Stack<Query> stackA = new Stack<>();
		Stack<Query> stackB = new Stack<>();
		for (int i = 0; i < N; ++i) {
			S[i] = sc.nextLong();
		}
		Arrays.sort(S);

		bitA.addVal(0 + 1, 1);
		bitB.addVal(0 + 1, 1);
		stackA.push(new Query(0 + 1, 1));
		stackB.push(new Query(0 + 1, 1));
		int leftA = -1;
		int leftB = -1;
		for (int i = 0; i + 1 < N; ++i) {
			long sA = 0;
			long sB = 0;
			while (S[i + 1] - S[leftA + 1] >= A)
				++leftA;
			while (S[i + 1] - S[leftB + 1] >= B)
				++leftB;
			sB = bitA.getVal((leftB + 1) + 1);
			sA = bitB.getVal((leftA + 1) + 1);
			if (S[i + 1] - S[i] < A) {
				while (!stackA.isEmpty()) {
					Query q = stackA.pop();
					bitA.addVal(q.pos, MOD - q.val);
				}
			}
			if (S[i + 1] - S[i] < B) {
				while (!stackB.isEmpty()) {
					Query q = stackB.pop();
					bitB.addVal(q.pos, MOD - q.val);
				}
			}
			bitA.addVal((i + 1) + 1, sA);
			bitB.addVal((i + 1) + 1, sB);
			stackA.add(new Query((i + 1) + 1, sA));
			stackB.add(new Query((i + 1) + 1, sB));
		}
		System.out.println((bitA.getVal(N) + bitB.getVal(N)) % MOD);
	}

	static class BinaryIndexedTree {
		int n;
		long[] val;

		public BinaryIndexedTree(int n) {
			this.n = n;
			val = new long[n + 1];
		}

		void addVal(int k, long v) {
			while (k <= n) {
				val[k] += v;
				if (val[k] >= MOD)
					val[k] -= MOD;
				k += k & -k;
			}
		}

		long getVal(int k) {
			long s = 0;
			while (k > 0) {
				s += val[k];
				if (s >= MOD)
					s -= MOD;
				k -= k & -k;
			}
			return s;
		}

		void clear() {
			val = new long[n + 1];
		}
	}

	static class Query {
		int pos;
		long val;

		public Query(int pos, long val) {
			this.pos = pos;
			this.val = val;
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 52008
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string S; cin >> S;
    int len = S.length();
    ll sum = 0;

    for (int mask = 0; mask < 1 << (len-1); mask++) {
        ll num = S[0] - '0';
        for (int i = 0; i < len-1; i++) {
            if (mask & 1 << i) {
                sum += num;
                num = 0;
            }
            num = num * 10 + (S[i+1] - '0');
        }
        sum += num;
    }

    cout << sum << "\n";


    return 0;
}


Measured memory_bytes: 256
def find_land(areas)
  (0...@h).each do |y|
    (0...@w).each do |x|
      return [x, y] if areas[y][x] == '1'
    end
  end
  nil
end

def incheck(x, y)
  0 <= x && x < @w && 0 <= y && y < @h
end

def bfs(areas, x, y)
  q = []
  q << [x, y]
  areas[y][x] = '0'
  until q.empty?
    x, y = q.shift
    (-1..1).each do |dy|
      (-1..1).each do |dx|
        next if dy == 0 && dx == 0
        xx = x + dx; yy = y + dy
        next unless incheck(xx, yy)
        if areas[yy][xx] == '1'
          areas[yy][xx] = '0'
          q << [xx, yy]
        end
      end
    end
  end
  areas
end

def solve(areas, depth)
  x, y = find_land(areas)
  return depth unless x
  solve(bfs(areas, x, y), depth + 1)
end

loop do
  @w, @h = gets.split.map(&:to_i)
  break if @w == 0 && @h == 0
  areas = @h.times.map { gets.chomp.split }
  puts solve(areas, 0)
end

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

int main() {
  string t;
  cin >> t;
  rep(i,t.length()){
    if(t[i]=='P') cout << 'P';
    if(t[i]=='D') cout << 'D';
    if(t[i]=='?') cout << 'D';
  }

}

Measured memory_bytes: 3648
s = input().split()
if s[0]==s[1] and s[0]!=s[2]:
  print("Yes")
elif s[0]==s[2] and s[0]!=s[1]:
  print("Yes")
elif s[2]==s[1] and s[0]!=s[2]:
  print("Yes")
else:
  print("No")

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

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

	for(int i = 0; i <= n;i++){
		for(int j = 0; j <= n-i; j++){
			int n1000 = n - i - j;
			if(10000*i + 5000*j + 1000*n1000 == y){
				cout << i << " " << j << " " << n1000 << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

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

int main() {
  
  string s, t;
  int a, b;
  string u;
  
  cin >> s >> t >> a >> b >> u;
  
  if (s == u) {
    cout << a - 1 << ' ' << b;
  } else {
    cout << a << ' ' << b - 1;
  }
  
}


Measured memory_bytes: 256
/*input
whbrjpjyhsrywlqjxdbrbaomnw
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;
map<int,int> mp[150];
string s;
int solve(char c){
	int ret=0,prev=0;
	for(auto p:mp[c]){
		ret=max(ret,p.first-prev);
		prev=p.first+1;
	}
	return ret;
}
int main(){
	ios_base::sync_with_stdio(0);
	int q,m,k,h,ans=10000,sum=0,p,x,y;
	cin>>s;
	for(int i=0;i<s.size();++i)
		mp[s[i]][i]=1;
	for(int i='a';i<='z';++i)
		mp[i][s.size()]++;
	// for(auto p:mp['s'])
	// 	cout<<p.first<<" ";
	for(char c='a';c<='z';++c){
		ans=min(ans,solve(c));
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long sum,oth=0,RS=0,GS=0,BS=0;
    char str[4005];
    scanf("%d",&n);
    scanf("%s",str);
    for(int i=0;i<n;i++){
        if(str[i]=='R') RS++;
        if(str[i]=='G') GS++;
        if(str[i]=='B') BS++;
    }
    sum=RS*GS*BS;
    for(int i=0;i<n-2;i++){
        for(int j=1;j*2+i<n;j++)
            if(str[i]!=str[i+j]&&str[i]!=str[i+2*j]&&str[i+j]!=str[i+2*j]) oth++;
    }
    printf("%lld",sum-oth);
    return 0;
}

Measured memory_bytes: 3832