akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 1; i < n+1; i++)
using namespace std;

int main()
{
    long n;
    cin >> n;
    string s;
    cin >> s;

    map<char, int> mp[n + 1];
    mp[0]['W'] = 0;
    mp[0]['E'] = 0;

    for (int i = 0; i < n; i++) {
        mp[i+1]['W'] = mp[i]['W'];
        mp[i+1]['E'] = mp[i]['E'];
        mp[i+1][s[i]] += 1;
    }

    int res = n;

    for (int i = 1; i < n + 1; i++) {
        res = min(res, mp[i-1]['W'] + mp[n]['E'] - mp[i]['E']);
    }
    cout << res << endl;
    return 0;
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol a,b;
  lol x,y;
  string s;
  cin >>s;
  if(s[1]=='B') s[1]='R';
  else s[1]='B';
  cout <<s<<'\n';
  return (0);
}


Measured memory_bytes: 3576
def gcd(x,y):
    if y == 0: return x
    else: return gcd(y,x%y)

def lcm(x,y): return x*y//gcd(x,y)

n = int(input())
a = [int(i) for i in input().split()]

ans = 0
mod = 10**9+7
l = a[0]
for i in range(1,n):
    l = lcm(l,a[i])

for i in range(n):
    ans += l//a[i]

print(ans%mod)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;
const ll mod = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { return mint(*this)+=a; }
  mint operator-(const mint a) const { return mint(*this)-=a; }
  mint operator*(const mint a) const { return mint(*this)*=a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this)/=a; }
  bool operator==(const mint a) const { return x == a.x; }
  bool operator!=(const mint a) const { return x != a.x; }
  friend ostream &operator<<(ostream &os, const mint &p) { return os << p.x; }
  friend istream &operator>>(istream &is, mint &a) {
    ll t;
    is >> t;
    a = mint(t);
    return (is);
  }
};

int main()
{
  ll n,s; cin>>n>>s;
  vector<ll> a(n);
  rep(i, n) cin>>a[i];
  sort(a.begin(),a.end());

  vector<vector<mint>> dp(n+1, vector<mint>(s+1));
  dp[0][0] = 1;
  for (int i=0; i<n; i++) {
    for (int j=0; j<=s; j++) {
      dp[i+1][j] += dp[i][j]*2;
      if (j+a[i] <= s) dp[i+1][j+a[i]] += dp[i][j];
    }
  }
  cout << dp[n][s] << endl;

  return 0;
}


Measured memory_bytes: 73744
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	class t implements Comparable<t> {

		int worth;

		int weight;



		t(String s) {

			Scanner sc = new Scanner(s.replace(',', ' '));

			worth = sc.nextInt();

			weight = sc.nextInt();

		}



		public int compareTo(t o) {

			return this.weight - o.weight;

		}

	}



	void run() {

		for (int casea = 1;; casea++) {

			int w = sc.nextInt();

			if (w == 0) {

				break;

			}

			w+=1;

			int n = sc.nextInt();

			t[] d = new t[n];

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

				d[i] = new t(sc.next());

			}

		//	Arrays.sort(d);

			int[] dp = new int[w];

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

				int[] dp2 = dp.clone();

				if (d[i].weight == 0) {

					for (int j = 0; j < w; j++) {

						dp[j] = dp2[j] + d[i].worth;

					}

					continue;

				}

				for (int j = 0; j + d[i].weight < w; j++) {

					dp[j + d[i].weight] = Math.max(dp2[j + d[i].weight], dp2[j]

							+ d[i].worth);

				}

			}

			int trig = 0;

			int max = 0;

			for (int i = 0; i < w; i++) {

				if (max < dp[i]) {

					max = dp[i];

					trig = i;

				} else if (max == dp[i]) {

					if (trig > i)

						trig = i;

				}

			}

			System.out.println("Case " + casea + ":");

			System.out.println(max);

			System.out.println(trig);

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 13000
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {
	int n;
	while (cin >> n && n != 0) {
		int hand_t[124];
		int num_flg[248];
		memset(num_flg, 0, sizeof(num_flg));

		for (int i = 0; i < n; ++i) {
			cin >> hand_t[i];
			num_flg[hand_t[i]] = 1;
		}
		sort(hand_t, hand_t + n);
		for (int i = 1; i <= 2 * n; ++i) {
			if (num_flg[i] != 1) {
				num_flg[i] = -1;
			}
		}

		int field = 0;
		int cnt_h = 0, cnt_t = 0;
		bool turn = true;
		while (cnt_t < n && cnt_h < n) {
			if (field == 0) {
				if (turn) {
					for (int i = 1; i <= 2 * n; ++i) {
						if (num_flg[i] == 1) {
							field = i;
							num_flg[i] = 0;
							++cnt_t;
							break;
						}
					}
					turn = false;
				}
				else {
					for (int i = 1; i <= 2 * n; ++i) {
						if (num_flg[i] == -1) {
							field = i;
							num_flg[i] = 0;
							++cnt_h;
							break;
						}
					}
					turn = true;
				}
			}
			else {
				int temp = field;
				for (int i = field + 1; i <= 2 * n; ++i) {
					if (turn) {
						if (num_flg[i] == 1) {
							field = i;
							num_flg[i] = 0;
							++cnt_t;
							break;
						}
					}
					else {
						if (num_flg[i] == -1) {
							field = i;
							num_flg[i] = 0;
							++cnt_h;
							break;
						}
					}
				}

				if (field == temp) {
					field = 0;
				}
				turn = !turn;
			}
		}

		cout << n - cnt_h << endl << n - cnt_t << endl;
	}

	return 0;
}

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

int main() {
	while(true){
	int N,M;
	int num[1001];
	vector<int> nums;
	cin >> N >> M;
	if(N==0)
	break;
	num[0]=0;
	for(int i=1;i<=N;i++){
		cin >> num[i];
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			if(i>=j){
			nums.push_back(num[i]+num[j]);
			
			}
		}
	}
	sort(nums.begin(),nums.end());
	int now=nums.size()-1,maxer=0;
	for(int i=0;i<nums.size();i++){
		if(nums[i]<=M){
	    while(nums[now]+nums[i]>M && now!=0)
		now--;
		
		maxer=max(nums[now]+nums[i],maxer);
		}
	}
	cout << maxer << endl;
	}
	return 0;
}

Measured memory_bytes: 5036
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    
    cout << z  << " " << x << " " << y << endl;;

    return 0;
}
// x y z
// y x z
// z x y

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	result := 2020
	for i := l; i <= r; i++ {
		for j := i + 1; j <= r; j++ {

			if result > (i*j)%2019 {
				result = (i * j) % 2019
			} else if result == 0 {
				fmt.Println(0)
				return
			}
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}


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

  ll n;
  cin >> n;
  printf("%.16f\n", (double)(ceil(n/2.0)/n));
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A.abc_of_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            Console.WriteLine(S.Contains('a') && S.Contains('b') && S.Contains('c') ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
#include<cstdio>
using namespace std;
const int INF=1e9;
struct node{
	int s,t;
}w1[200100],w2[200100];
int beg[200100],nex[400100],tto[400100],e;
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
int n;
void clear(){
	e=1;
	for(int i=0;i<=n;i++)
		beg[i]=0;
}
bool vis[200100];
int f[200100];
int dis[200100];
void getfa(int u){
	for(int i=beg[u];i;i=nex[i]){
		if(tto[i]==f[u]) continue;
		f[tto[i]]=u;
		dis[tto[i]]=dis[u]+1;
		getfa(tto[i]);
	}
}
int ans;
void dfs(int u,int fa,int dep){
	if(dis[u]>ans) ans=dis[u];
	if(dep>=dis[u]) return;
	for(int i=beg[u];i;i=nex[i]){
		if(tto[i]==fa) continue;
		if(vis[i>>1]){
			ans=INF;
			return;
		}
		dfs(tto[i],u,dep+1);
	}
}
int main(){
//	freopen("b.in","r",stdin);
//	freopen("b.out","w",stdout);
	int A,B;
	scanf("%d%d%d",&n,&A,&B);
	if(A==B){
		printf("0\n");
		return 0;
	}
	clear();
	for(int i=1;i<n;i++)
		scanf("%d%d",&w1[i].s,&w1[i].t);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&w2[i].s,&w2[i].t);
		putin(w2[i].s,w2[i].t);
		putin(w2[i].t,w2[i].s);
	}
	getfa(B);
	clear();
	for(int i=1;i<n;i++){
		if(f[w1[i].s]!=f[w1[i].t]&&f[f[w1[i].s]]!=w1[i].t&&
				w1[i].s!=f[f[w1[i].t]]&&f[w1[i].s]!=w1[i].t&&f[w1[i].t]!=w1[i].s)
			vis[i]=1;
		else
			vis[i]=0;
		putin(w1[i].s,w1[i].t);
		putin(w1[i].t,w1[i].s);
	}
	dfs(A,-1,0);
	if(ans==INF) printf("-1\n");
	else printf("%d\n",ans*2);
	return 0;
}


Measured memory_bytes: 14976
function Main(input) {
	var num = input.split("/");
	for(var n=0; n<num.length; n++){ num[n]=parseInt(num[n]); }
	var output;
	
	if(num[0]<2019){
		output="Heisei"
    }else{
		if(num[1]<5){
        	output="Heisei"
        }else{
        	output="TBD"
        }
      
	}
	
	//出力
	console.log(output);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    int n=s.length();
    int i;
    for(i=0;i<n;i++)
    {
        if(s[i]=='?')
        s[i]='D';
    }
    cout<<s<<"\n";
    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	
	while (n) {
		if (n % 10 == 9) {
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int n, t, a, x, i, d;
int res = 0;
int cc = 1000000;
    scanf("%d %d %d",&n, &t, &a);
      for(i=1; i<=n; i++){
    scanf("%d", &x);
    d = (t*1000 - x*6) - a*1000;

    if(d < 0){
      d = -d;
    }

    if(cc > d){
      res = i;
      cc = d;
    }
  }
  
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [int(i) for i in input().split()]

i = 0

abs_lst = []

while (i < n - 1):
	j = i + 1
	while (j < n):
		abs_lst.append(abs(a[i] - a[j]))
		j += 1
 
	i = i + 1
    
print(max(abs_lst))

Measured memory_bytes: 3188
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
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);
}

ll dp[2222][2222],sp[2222][2222],calc[2222];

int main(void){
	int x[3],i,j,k,n,t[3][2]={{1,2},{0,2},{0,1}};
	ll b = 0ll, ans=0ll;
	std::fill(dp[0],dp[2222],-INFLL);
	std::fill(calc,calc+2222,-INFLL);
	std::cin >> n;
	std::cin >> x[0] >> x[1];
	dp[x[0]][x[1]] = 0ll;
	for(k=0; k<2; ++k){
		calc[x[k]] = 0ll;
	}
	for(i=1; i<n; ++i){
		std::cin >> x[0] >> x[1] >> x[2];
		std::sort(x,x+3);
		if(x[0]==x[2]){
			++b; continue;
		}
		for(j=1; j<=n; ++j){
			for(k=0; k<3; ++k){
				sp[j][x[k]] = -INFLL;
			}
		}
		// 1つだけ残す
		for(k=0; k<3; ++k){
			for(j=1; j<=n; ++j){
				sp[j][x[k]] = std::max(sp[j][x[k]],calc[j]);
				if(x[t[k][0]] == x[t[k][1]]){
					sp[j][x[k]] = std::max(sp[j][x[k]],dp[x[t[k][0]]][j]+1);
					sp[j][x[k]] = std::max(sp[j][x[k]],dp[j][x[t[k][0]]]+1);
				}
			}
		}
		// 2つ残す
		for(k=0; k<3; ++k){
			sp[x[t[k][0]]][x[t[k][1]]] = std::max(sp[x[t[k][0]]][x[t[k][1]]],ans);
			sp[x[t[k][0]]][x[t[k][1]]] = std::max(sp[x[t[k][0]]][x[t[k][1]]],dp[x[k]][x[k]]+1);
		}
		for(j=1; j<=n; ++j){
			for(k=0; k<3; ++k){
				dp[j][x[k]] = std::max(dp[j][x[k]],sp[j][x[k]]);
				calc[x[k]] = std::max(calc[x[k]],sp[j][x[k]]);
				calc[j] = std::max(calc[j],sp[j][x[k]]);
				ans = std::max(ans,sp[j][x[k]]);
			}
		}
	}
	std::cin >> x[2];
	ans = std::max(ans,dp[x[2]][x[2]]+1);
	ans += b;
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 76920
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

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

  int ten = 10;
  int x = n;
  int a;
  int sum = 0;
  while (x > 0) {
    a = x % ten;
    sum += a;
    x /= 10;
  }
  if (!(n%sum)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define pi pair<int, int>
#define PI 3.14159265
#define all(x) x.begin(),x.end()
#define er(n) cout << "error " << n << endl;
#define pbds tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define mod 1000000007

void Abhay() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	//Abhay();
	int n; cin >> n;
	int a[n][3];
	for (int i = 0 ; i < n ; i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	for (int i = 1 ; i < n ; i++) {
		a[i][0] += max(a[i - 1][1], a[i - 1][2]);
		a[i][1] += max(a[i - 1][0], a[i - 1][2]);
		a[i][2] += max(a[i - 1][0], a[i - 1][1]);
	}
	cout << max(a[n - 1][0], max(a[n - 1][1], a[n - 1][2]));
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec[i];
    }

    vector<int> vecc = vec;
    sort(vecc.begin(), vecc.end());
    reverse(vecc.begin(), vecc.end());

    for(int i=0; i<N; i++){
        if(vec[i] == vecc[0]){
            cout << vecc[1] << endl;
        }
        else{
            cout << vecc[0] << endl;
        }
    }
}

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

int main(){
  long long int x;
  cin >> x;
  for(long long int i=-200;i<200;i++){
    for(long long int j=-200;j<200;j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
        cout << i << " " << j << endl;
        i=200;
        break;
      }
    }
  }
}

Measured memory_bytes: 3592
//author: Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define maxN 100007
using namespace std;
int main()
{
    fastio;
    ll n=0;
    cin>>n;
    ld ans=0;
    ld ar[n];
    for(ll i=0;i<n;++i) cin>>ar[i];
    sort(ar,ar+n);
    ll i=0,j=1;
    while(j<n){
        if(i==0)
            ans=(ar[i]+ar[j])/2;
        else
            ans=(ans+ar[j])/2;
        ++j;
        ++i;
    }
    cout<<fixed<<setprecision(6)<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int M[N][N];
  int n,u,k,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <set>
//#include <conio.h>
using namespace std;
 
int main(){
	vector<bool> stu(31);
	vector<int> ans(2);
	for(int i=0; i<31;++i){
		stu[i] = true;
	}
	stu[0] = false;
	for(int i=0; i<28; ++i){
		int tmp;
		cin >> tmp;
		stu[tmp] = false;
	}
	int h = 0;
	for(int i=1; i<31; ++i){
		if(stu[i] == true){
			ans[h] = i;
			++h;
		}
	}
	cout << min(ans[0],ans[1]) << endl;
	cout << max(ans[0],ans[1]) << endl;

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
#define fo(i,n) for( ll int i=0;i<n;++i)
#define fos(j,i,n) for(ll int j=i;j<n;++j)
#define N 100004
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define abs(x) ((x)<0?(-(x)):(x))
#define dis(k) cout << k << endl
#define forr(i,n) for( ll int i= n-1;i>=0;--i)
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define ve vector
#define fi first
#define se second
#define setzero(a) memset(a,0,sizeof(a))
#define setinf(a) memset(a,0x7F,sizeof(a))
typedef ve< ll > vi;
typedef ve< vi > vvi;
typedef pair< ll ,ll > ii;
void solve(){
	ll r,g,b;
  cin >> r >> g >> b;
  ll k;
  cin >> k;
  while(g<=r){g<<=1;k--;if(k<0){dis("No");return;}}
  while(b<=g){b<<=1;k--;if(k<0){dis("No");return;}}
  dis("Yes");
}
 
 
int main(){
	fast;
	int t=1;
	//cin >> t;
 
	while(t--){
		solve();
	}
	return 0;
}

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

typedef long long LL;

bool query(LL n) {char ch; std::cout << "? " << n << std::endl, std::cin >> ch; return ch == 'Y';}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	if (query(1e10)) {
		int l = 0, r = 8, ans = 9;
		while (l <= r) {
			int mid = l + r >> 1;
			if (query(pow(10, mid + 1) - 1))
				ans = mid, r = mid - 1;
			else l = mid + 1;
		}
		std::cout << "! " << (LL) pow(10, ans) << '\n';
	} else {
		int l = 1, r = 8, ans = 0;
		while (l <= r) {
			int mid = l + r >> 1;
			if (query(pow(10, mid)))
				ans = mid, l = mid + 1;
			else r = mid - 1;
		}
		l = pow(10, ans), r = l * 10 - 2, ans = r + 1;
		while (l <= r) {
			int mid = l + r >> 1;
			if (query(mid * 10LL))
				ans = mid, r = mid - 1;
			else l = mid + 1;
		}
		std::cout << "! " << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;


int main() {
 int64_t K,A,B;
 cin>>K>>A>>B;
 if(B-A<=2||K<=A-1){cout<<K+1<<endl;}
 else{
     int64_t ans=A+(K-(A-1))/2*(B-A)+(K-(A-1))%2;
     cout<<ans<<endl;
     }
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define re register
#define IL inline
using namespace std;
const int maxn=3e3+10;
template<typename T> void read(T &x){
	T f=1;x=0;
	char s=getchar();
	while(s<'0' || s>'9'){if(s=='-') f=-1;s=getchar();}
	while(s>='0' && s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();}
	x*=f;
}
double f[maxn][maxn];
double a[maxn];
int n;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(re int i=0;i<n;i++){
		cin>>a[i];
	}
	f[0][0]=1.0;
	for(re int i=1;i<=n;i++){
		for(re int j=0;j<i;j++){
			f[i][j+1]+=f[i-1][j]*a[i-1];
			f[i][j]+=f[i-1][j]*(1.0-a[i-1]);
		}
	}
	double ans=0.0;
	for(re int i=(n+1)/2;i<=n;i++){
		ans+=f[n][i];
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 69120
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int num[3],count=0;
  scanf("%d %d %d",&num[0],&num[1],&num[2]);
  qsort(num,3,sizeof(int),compare_up_int);
  if((num[2]-(num[0]+num[2]-num[1]))%2 == 0){
    int a = num[2]-num[1];
    printf("%d\n",a+(num[2]-num[0]-a)/2);
  }
  else{
    num[0]+=1;num[2]+=1;
    int a = num[2]-num[1];
    printf("%d\n",a+(num[2]-num[0]-a)/2 + 1);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int K; cin>>K;
	queue<ll> q;
	forn(i,1,10) q.push(i);
	
	while(K--){
		ll s=q.front(); q.pop();
		if(s%10>0) q.push(s*10+s%10-1);
		q.push(s*10+s%10);
		if(s%10<9) q.push(s*10+s%10+1);
		if(!K){ cout<<s<<'\n'; return 0; }
	}
	
	return 0;
}


Measured memory_bytes: 4764
#include <stdio.h>

int main(void){
        char a[4];
        scanf("%s", a);
        int count;
        int sum =0;

        for(int i=0;i<4;i++){
                for(int j=0;j<4;j++){
                        if(a[i] == a[j]){
                                sum++;
                        }

                }
        }
        if(sum == 8){
                printf("Yes\n");
        }else{
                printf("No\n");
        }
        return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORR(x, arr) for (auto& x : arr)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
//-------------------------------------------------------

int N;
ll dp[114514];

void solve() {
    cin >> N;

    REP(i, N) dp[i] = 1LL << 60;

    long int ans = 0;

    REP(i, N) {
        ll x;
        cin >> x;
        auto iter = lower_bound(dp, dp + N, x);
        *iter = x;

        ans = max(ans, (iter - dp) + 1);
    }

    cout << ans << endl;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 4004
import sys
a,b,c,d = input()

for i in range(2**3):
    l = ['+','+','+']
    for j in range(3):
        if (i>>j) & 1 == 1:
            l[j] = '-'
    if eval(a+l[0]+b+l[1]+c+l[2]+d) == 7:
        print(a+l[0]+b+l[1]+c+l[2]+d+'=7')
        sys.exit()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

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

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

int main()
{
    string s; cin >> s;
    vector<ll> A;
    int len = s.size();
    for (int i = 1; i < len; i++) {
        A.push_back(s[i] - '0');
    }
    int up_num = s[0] - '0'; // 最上位桁

    bool all_9 = true;
    for (auto a : A) {
        if (a != 9) all_9 = false;
    }

    // s以下の数値で各桁の和を最大化するには、最上位桁以外の数値を9にすればいい。
    // ↑になるようなs以下の数値をいちいち計算する必要はない。
    ll ans;
    if (all_9) {
        ans = (A.size() * 9) + up_num;
    }
    else {
        // ex: 1111 -> 999
        ans = (A.size() * 9) + up_num - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

N,K=map(int,input().split())
A=list(map(int,input().split()))

def calc_imos(arr):
  imos=[0]*(N+1)
  for i,a in enumerate(arr):
    l=max(0,i-a) #照らす範囲の左側インデックス、0が最小
    r=min(N-1,i+a) #照らす範囲右側インデックス,arrの長さ-1=Nが最大
    imos[l]+=1
    imos[r+1]-=1
    #print("imos",imos)
  imos=list(accumulate(imos))
  #print("imos",imos)
  return imos[:-1]

for k in range(min(50,K)):
  A=calc_imos(A)
print(*A,sep=" ")

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

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

    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

    int num = n / 2;
    if (n % 2 == 0){
        for (int i = 0; i < num; i++){
            cout << data.at(n - 1 - 2 * i) << " ";
        }

        for (int i = 0; i < num; i++){
            cout << data.at(2 * i) << " ";
        }
    }
    else{
        for (int i = 0; i < num + 1; i++){
            cout << data.at(n - 1 - 2 * i) << " ";
        }

        for (int i = 0; i < num; i++){
            cout << data.at(2 * i + 1) << " ";
        }
    }

    cout << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    std::map<char, int> map;
    for (int i=0;i<s.size();i++) {
        map[s[i]]++;
    }
    std::deque<char> alpha;
    for (int i=97;i<123;i++) {
        char c=i;
        alpha.emplace_back(c);
    }
    reverse(s.begin(),s.end());
    int flag=0;
    for (int i=0;i<alpha.size();i++) {
        if (map[alpha[i]]==0) {
            s=alpha[i]+s;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        while (s.size()!=0) {
            int tmp=s[0]-96;
            map[s[0]]--;
            s.erase(0,1);
            for (int i=tmp;i<alpha.size();i++) {
                if (map[alpha[i]]==0) {
                    s=alpha[i]+s;
                    flag=1;
                    break;
                }
            }
            if (flag==1) {
                break;
            }
        }
    }
    if (flag==1) {
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    } else {
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
int n;

int main(){
	cin >> n;
	vector<string> v(n);
	FOR(i,0,n-1){
		string s; cin >> s;
		sort(ALL(s));
		v[i] = s;
	}
	sort(ALL(v));
	//string cur = v[0];
	ll cnt = 0;
	ll left = 0;
	FOR(i,1,n-1){
		while(v[left]==v[i]){
			i++;
			if(i>=n) break;
		}
		//cout << i-left;
		if(i-left >= 2){
			cnt += (i-left)*(i-left-1)/2;
		}
		left = i;
	}
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=1e5+10;
int n,l,r,ans;
char s[N];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int ab(int a){return a>0?a:-a;}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	l=1;r=n;
	while(l<r)
	{
		if(s[l]==s[r])l++,r--;
		else if(s[l]=='x')l++,ans++;
		else if(s[r]=='x')r--,ans++;
		else {printf("-1");return 0;}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 5;
  vector<int> x(N);
  
  for(int i=0;i<N;i++){
    cin >> x.at(i);
  }
  int checker = 0;
  for(int i=0;i<N;i++){
    if(x.at(i)==0){
      checker = i+1;
    }
  }
  cout << checker << endl;
}

Measured memory_bytes: 3628
f::Int->Int->Int->Int->Bool
f a b c d
    |c<a=True
    |c==a && d<=b=True
    |otherwise =False

main = do
      x<-getLine
      let (a:b:[])=map read (words x)::[Int]
      putStrLn $ show $ length [1|y<-[1..12],f a b y y]

Measured memory_bytes: 508
#include<stdio.h>
#define MAX 500000
#define SENTINEL 1000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
  int i, j, k;

  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){
    cnt++;
    if ( L[i] <= R[j] ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right ){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main(){
  int A[MAX], n, i;
  scanf("%d", &n);
  cnt = 0;
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
    if (A[i] >= SENTINEL ){
      return 1;
    }
  }
  mergeSort(A, n, 0, n);

  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    printf("%d", A[i]);
    }
  printf("\n");

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

  return 0;
}

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

const long long INFF = 1e18;

const int MAX_N = 11000;
using TYPE = long long; // ?????¢???????????\??????
vector<pair<int, TYPE> > G[MAX_N];

vector<TYPE> A_star(int start){
	vector<TYPE> dist(MAX_N, INFF);
	dist[start] = 0;//dist[i] :=???start->i?????§??????????????¢
	priority_queue<pair<TYPE, int>, vector<pair<TYPE, int> >, greater<pair<TYPE, int> > >  que;
	que.push(make_pair(1, start));
	while(!que.empty()){
		TYPE cost; int u;//????????§???????????£????????? ?????¨?????????
		cost = que.top().first, u = que.top().second;
		que.pop();
		// if(dist[u] < cost) continue;
		for (auto tmp : G[u]){
			int v = tmp.first; TYPE time = tmp.second;//??£??\???????????? ?????????????????§????????????
			if(dist[v] > dist[u] + time){//u->v
				dist[v] = dist[u] + time;
				TYPE h = 1; // ??´???????????§?????¨??????
				// printf("%f\n", h);
				que.push(make_pair(dist[v] + h, v));
			}
		}
	}
	return dist;
}

int main(void) {
	int n; cin >> n;
	rep(q, n) {
		int u, k; cin >> u >> k;
		vector<int> v(k); vector<long long> c(k);
		rep(i, k) cin >> v[i] >> c[i];
		rep(i, k) G[u].push_back(make_pair(v[i], c[i]));
	}
	auto dist = A_star(0);
	rep(i, n) printf("%d %d\n", i, dist[i]);
	return 0;
}

Measured memory_bytes: 12068
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int A[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    A[0] = 0;
    rep(i, N) {
        cin >> A[i + 1];
    }
    A[N + 1] = 0;
    int ans = 0;
    rep(i, N + 1) {
        ans += abs(A[i + 1] - A[i]);
    }
    //cout << ans << endl;
    rep(i, N) {
        cout << ans - abs(A[i + 1] - A[i]) -abs(A[i + 2] - A[i + 1]) + abs(A[i + 2] - A[i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vel a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll K, S, ans = 0, z;
    cin >> K >> S;
    REP(x, K+1){
        REP(y, K+1){
            z = S - x - y;
            if(z >= 0 && z <= K) ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int[int] team, rank;
	while (1) {
		auto x = readln.chomp.split(",").map!(to!int);
		if (!x[0] && !x[1]) break;
		team[x[0]] = x[1];
		rank[x[1]] = 1;
	}

	foreach (line; stdin.byLine) {
		auto n = line.chomp.to!int;
		auto score = team[n];
		foreach (i, e; rank.keys.array.sort!("a>b").array) {
			if (e == score) {
				writeln(i+1);
				break;
			}
		}
	}
}

Measured memory_bytes: 1104
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{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());

		if(a < b && b < c){
			System.out.println("Yes");
		}else
			System.out.println("No");
		}

	}



Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
int main(){
    double k,r;
    long long int x;
    int i;
    cin>>x;
    r=1.01;
    k=100;
    i=1;
    while(1){
        k*=r;
        k=floor(k);
        if(k>=x){
          cout<<i;return 0;  
        }i++;
    }
    return 0;
}

Measured memory_bytes: 3648
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

kaijolist = [1]
kaijo = 1

j = list(itertools.permutations(list(range(1, N+1))))

for i, p in enumerate(j):
    if p == P:
        a = i + 1
                                  
for i, q in enumerate(j):
    if q == Q:
        b = i + 1

print(abs(a - b))

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

typedef long long LL;
#define MAXN 100003
#define MOD 100000000

int A[MAXN];

int main() {
#ifdef OJ
    //    freopen("input.txt", "rt", stdin);
    //    freopen("output.txt", "wt", stdout);
#endif

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

    for (int i = 1; i <= N; i++)
        scanf("%d", &A[i]);

    A[N + 1] = 0;

    int total = 0;
    for (int i = 1; i <= N + 1; i++) {
        total += abs(A[i] - A[i - 1]);
    }

    for (int i = 1; i <= N; i++) {
        printf("%d\n", total - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]));
    }

    return 0;
}


Measured memory_bytes: 1664
N,M=map(int, input().split())
S=list(input())
T=S[::-1]
D=[0]*N
if N<=M:
  print(N)
  exit()
r=0
renzoku,ma=0,0
for i in range(1,N+1):
  if S[i]=='1':
    renzoku+=1
  else:
    ma=max(ma,renzoku)
    renzoku=0
if ma>=M:
  print(-1)
  exit()

for i in range(1,M+1):
  if T[i]!='1':
    D[i]=1
    r=i
  else:
    D[i]=100000
ans=[r]

while r+M<N:
  for i in range(M,0,-1):
    if T[r+i]=='0':
      ans.append(i)
      r+=i
      break
  
ans.append(N-r)
print(*ans[::-1])

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

using namespace std;

typedef long long ll;



 
const int mx = 105;
const int mx1 = 1000001;
const ll mod = 1000000007;


void adds(int &a, int b){
    a+= b;
    if(a >= mod)
     a-=mod;
}

void subs(int &a, int b){
    a-= b;
    if(a < 0)
     a+=mod;
}

int main(){
   ll n, k, i, j, l, m;

   cin>>n>>k;
   vector<int> dp(k+1);

   ll a[n];

   for(i = 0;i < n;i++)
    cin>>a[i];
  // memset(dp, 0, sizeof(dp));


    dp[0] =1; 
   for(i = 1;i <= n;i++){

       vector<int> fake(k+1, 0);
       for(j = k;j >= 0;j--){
           ll l = j+1;
           ll r = min(j+a[i-1], k);

        //    for(m = l;m <= r;m++){
              if(l <= r){
               adds(fake[l], dp[j]);
               if(r+1 <= k)
               subs(fake[r+1], dp[j]);
              }

        //    }
       }
       int prefix_sum = 0;
       for(j = 0;j <= k;j++){
           adds(prefix_sum, fake[j]);
           adds(dp[j], prefix_sum);
       }
    //    if(i == 1){
    //     for(j = 0;j <= k;j++){
    //          cout<<fake[j]<<" ";
    //         }
    //    }
   } 
  // cout<<endl;
//    for(i = 0;i <= k;i++)
//     cout<<dp[i]<<" ";

  
   cout<<dp[k];


} 


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 998244353
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
ll p[3];
ll q[3];
int main(){
    ll res = 1;
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,3*n){
        int k;
        if(s[i]=='R'){
            k=0;
        }else if(s[i]=='G'){
            k=1;
        }else{
            k=2;
        }
        if(q[k]!=0){
            res *= q[k];
            res %= mod;
            q[k]--;
        }else{
            bool flag = 1;
            int t = 0;
            rep(j,3){
                if(p[j]!=0){
                    flag = 0;
                    t = j;
                }
            }
            if(flag){
                p[k]++;
            }else{
                if(t==k){
                    p[k]++;
                }else{
                    res *= p[t];
                    res %= mod;
                    p[t]--;
                    rep(j,3){
                        if(j!=t&&j!=k){
                            q[j]++;
                        }
                    }
                }
            }
        }
    }
    for(ll i=1;i<=n;i++){
        res *= i;
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

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

int main()
{
    int temp = 0;
    string str;
    cin>>str;

    int l = str.size();
    int p = l-1;
    for(int i = 0;i<l/2;i++){
        if(str[i] != str[p]){
           temp++;
        }
        p--;
    }
    cout<<temp<<endl;
}


Measured memory_bytes: 256
Module Program
  Sub Main
    Dim s=GetInts()
    Array.Sort(s)
    Dim a=StrConv(s(0),1),b=s(1),c=s(2)
    Dim ans=If(a=b,c,a)
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 22480
// AOJ DSL_2_C Range Search (kD Tree)
// 2018.5.17 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	if (c == '-') { c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define MAX_N  500005

typedef struct { int id; int p[2], child[2], min[2], max[2]; } NODE;
NODE kdTree[MAX_N];

int root;       // root of kd tree
int ans[102], len;
int s[2], t[2];

int mkKdTree(int l, int r, int k)
{
	int i, j, c;
	int m, x;
	NODE t;

	m = (l+r)>>1;
	t = kdTree[m], kdTree[m] = kdTree[r], kdTree[r] = t;
	i = l-1, x = kdTree[m].p[k];
	for (j = l; j < r; j++) {
		if (kdTree[j].p[k] < x) {
			if (++i != j) t = kdTree[++i], kdTree[i] = kdTree[j], kdTree[j] = t;
		}
	}
	t = kdTree[m], kdTree[m] = kdTree[r], kdTree[r] = t;

	kdTree[m].child[0] = (l == m)? 0: mkKdTree(l, m-1, k);
	kdTree[m].child[1] = (m == r)? 0: mkKdTree(m+1, r, k);

	for (i = 0; i < 2; i++) {
		kdTree[m].min[i] = kdTree[m].max[i] = kdTree[m].p[i];
		for (j = 0; j < 2; j++) if (c = kdTree[m].child[j]) {
			if (kdTree[m].min[i] > kdTree[c].min[i]) kdTree[m].min[i] = kdTree[c].min[i];
			if (kdTree[m].max[i] < kdTree[c].max[i]) kdTree[m].max[i] = kdTree[c].max[i];
		}
	}
	return m;
}

void printRange(int node)
{
	int c;

	if (kdTree[node].p[0] >= s[0] && kdTree[node].p[0] <= t[0] &&
		kdTree[node].p[1] >= s[1] && kdTree[node].p[1] <= t[1]) {
		ans[len++] = kdTree[node].id;
	}

	if ((c = kdTree[node].child[0]) &&
		kdTree[c].min[0] <= t[0] && s[0] <= kdTree[c].max[0] &&
		kdTree[c].min[1] <= t[1] && s[1] <= kdTree[c].max[1])
			printRange(c);

	if ((c = kdTree[node].child[1]) &&
		kdTree[c].min[0] <= t[0] && s[0] <= kdTree[c].max[0] &&
		kdTree[c].min[1] <= t[1] && s[1] <= kdTree[c].max[1])
			printRange(c);
}

int kdcmp(NODE *a, NODE *b) { return a->p[0] - b->p[0]; }
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }

int main()
{
	int n, q, i;

	n = in();
	for (i = 1; i <= n; i++) {
		kdTree[i].id = i-1, kdTree[i].p[0] = in(), kdTree[i].p[1] = in();
	}
	qsort(kdTree+1, n, sizeof(NODE), kdcmp);
	root = mkKdTree(1, n, 0);

	q = in();
	while (q--) {
		s[0] = in(), t[0] = in();
		s[1] = in(), t[1] = in();
		len = 0;
		printRange(root);
		qsort(ans, len, sizeof(int), cmp);
		for (i = 0; i < len; i++) out(ans[i]);
		pc('\n');
	}
}


Measured memory_bytes: 26136
//

fun main() {
    intro_heuristicsb()
}

fun intro_heuristicsb() {
    val d = readLine()!!.toInt()
    val c = readLine()!!.split(" ").map { it.toInt() }
    val s = MutableList(d) { listOf<Int>() }
    repeat(d) {
        s[it] = readLine()!!.split(" ").map { it.toInt() }
    }
    var score = 0
    val last = IntArray(26) { 0 }
    repeat(d) {
        val contest = readLine()!!.toInt()
        val day = it + 1
        score += s[it][contest - 1]
        last[contest - 1] = day
        score -= last.mapIndexed { index, i -> (day - i) * c[index] }.sum()
        println(score)
    }
}


Measured memory_bytes: 40148
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int a, b; cin >> a >> b;
	if (a < -b)cout << -1 << endl;
	else if (a > -b)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = 0;
    rep(i, 4) {
        if (S[i] == '2') ans++;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
var
	L,R,ans,tmp,M,i,j:Longint;
begin
	read(L,R);
	M:=2019;
	ans:=M;
	if L+2018<=R then begin
		writeln(0);
		exit;
	end;
	for i:=L to R do begin
		for j:=1 to 100 do begin
			if i+j>R then break;
			tmp:=i mod M*(i+j)mod M;
			if ans>tmp then ans:=tmp;
		end;
	end;
	writeln(ans);
end.


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int input = sc.nextInt();
        int diff = 25-input;
        //FIXME:no sanity check
        StringBuffer sb = new StringBuffer();
        sb.append("Christmas");
        for(int i = 0;i < diff;++i) {
            sb.append(" Eve");
        }
        System.out.println(sb.toString());
    }

}


Measured memory_bytes: 20820
#include <iostream>
#include <string>

int main() 
{
    std::string line;
    std::getline(std::cin, line);
    if (line == std::string("AAA") || line == std::string("BBB")) {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 888