akhauriyash/Code-Regression huggingface dataset:
s = input()
t = input()
slen = len(s)
tlen = len(t)
dp = [[0 for j in range(tlen + 1)] for i in range(slen + 1)]
for i in range(slen):
  for j in range(tlen):
    if s[i] == t[j]:
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1])
    else:
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j], dp[i][j + 1])
result = ''
i = slen
j = tlen
while i > 0 and j > 0:
  if dp[i - 1][j] == dp[i][j]:
    i -= 1
  elif dp[i][j - 1] == dp[i][j]:
    j -= 1
  else:
    result = s[i - 1] + result
    i -= 1
    j -= 1
print(result)

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#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--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

class graph
{
    private:
        const size_t number_of_nodes;
        const bool is_directed;
    public:
        vector<size_t> *edges;
        graph(size_t number_of_nodes, bool is_directed = true): number_of_nodes(number_of_nodes), is_directed(is_directed) {
            edges = new vector<size_t>[number_of_nodes];
        }
        ~graph() {
            delete [] edges;
        }
        size_t size() const {
            return number_of_nodes;
        }
        void make_edge(size_t u, size_t v) {
            edges[u].push_back(v);
            if (!is_directed) {
                edges[v].push_back(u);
            }
        }
};

size_t * longest_path(graph &g)
{
    size_t *lp = new size_t[g.size()]();
    function<int(size_t, int)> f = [&](size_t u, int depth) -> int {
        if (lp[u] != 0) {
            return lp[u];
        }
        if (g.edges[u].size() == 0) {
            return lp[u] = 1;
        }
        if (depth == g.size()) {
            return lp[u] = -1;
        }
        int x_max = 0;
        for (size_t v: g.edges[u]) {
            int x = f(v, depth + 1);
            if (x == -1) {
                return lp[u] = -1;
            }
            x_max = max(x_max, x);
        }
        return lp[u] = x_max + 1;
    };
    for (size_t v = 0; v < g.size(); ++v) {
        if (f(v, 0) == -1) {
            delete [] lp;
            return nullptr;
        }
    }
    return lp;
}

int main(void)
{
    int N, M;
    cin >> N >> M;
    graph g(N);
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g.make_edge(x, y);
    }
    size_t* lp = longest_path(g);
    int result = *max_element(lp, lp + N) - 1;
    cout << result << endl;

    return 0;
}



Measured memory_bytes: 10624
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
n=ii1()
arr=iia()
ans=0
for i in range(n):
    ans^=arr[i]
for i in range(n):
    print(ans^arr[i],end=' ')
print()



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

int ft[200005];

void gnk(int i) {
	while(i <= 200001) {
		++ft[i];
		i += (i & -i);
	}
}

int pj(int i) {
	int tp = 0;
	while(i) {
		tp += ft[i];
		i -= (i & -i);
	}
	return tp;
}

int n, a[100005], b[100005], fp;
long long rr, N;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	N = n;
	N *= n + 1;
	N /= 4;
	++N;
	for(int i = 1; i  <= n; ++i) {
		cin >> a[i];
	}
	int l = 1, r = 1e9, m;
	while(l <= r) {
		for(int i = 1; i <= 200001; ++i) {
			ft[i] = 0;
		}
		m = (l + r) / 2;
		for(int i  = 1; i <= n; ++i) {
			if(a[i] <= m) {
				b[i] = 1;
			} else {
				b[i] = 0;
			}
		}
		gnk(1 + 1e5);
		rr = 0;
		int g = 0;
		for(int i = 1; i <= n; ++i) {
			if(b[i]) {
				++g;
			} else {
				--g;
			}
			rr += pj(g + 1e5);
			gnk(g +1e5 + 1);
		}
		if(rr >= N) {
			fp = m;
			r = m - 1;
		} else {
			l = m + 1;
		}
	}
	cout << fp << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 205;
const int MAX_R = 1005;

int sd[MAX_N][MAX_N];
int ld[MAX_N][MAX_N];
int dp[MAX_R][MAX_N];

int main()
{
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0){
            break;
        }
        rep(i,n){
            rep(j,n){
                sd[i][j] = INF;
                ld[i][j] = INF;
            }
        }
        rep(i,m){
            int p,q,r;
            string s;
            cin >> p >> q >> r >> s;
            if(s == "L"){
                ld[p-1][q-1] = r;
                ld[q-1][p-1] = r;
            }else{
                sd[p-1][q-1] = r;
                sd[q-1][p-1] = r;
            }
        }
        rep(i,n){
            ld[i][i] = 0;
            sd[i][i] = 0;
        }
        for(int k=0;k<n;k++){
    		for(int i=0;i<n;i++){
    			for(int j=0;j<n;j++){
    				ld[i][j] = min(ld[i][j],ld[i][k]+ld[k][j]);
                    sd[i][j] = min(sd[i][j],sd[i][k]+sd[k][j]);
    			}
    		}
    	}
        int R;
        cin >> R;
        vector<int> vec(R);
        rep(i,R){
            cin >> vec[i];
            vec[i]--;
        }
        rep(i,R){
            rep(j,n){
                dp[i][j] = INF;
            }
        }
        dp[0][vec[0]] = 0;
        rep(i,R-1){
            rep(j,n){
                rep(k,n){
                    if(k == j){
                        dp[i+1][j] = min((ll)dp[i+1][j],(ll)dp[i][j]+ld[vec[i]][vec[i+1]]);
                    }else{
                        dp[i+1][j] = min((ll)dp[i+1][j],(ll)dp[i][k]+ld[vec[i]][k]+sd[k][j]+ld[j][vec[i+1]]);
                    }
                }
            }
        }
        int ans = INF;
        rep(i,n){
            ans = min(ans,dp[R-1][i]);
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 4116
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
typedef long long ll;

using namespace std;

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

int main(){
    ll a,b;
    while(cin>>a>>b){
        ll ans1=gcd(a,b);
        ll ans2=a/ans1*b;
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    V<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    V<int>cal;
    int cnt=1,pre=a[0];
    for(int i=1;i<n;i++){
        if(a[i]==pre){
            cnt++;
        }
        else{
            cal.pb((cnt));
            cnt=1;
            pre=a[i];
        }
    }
    if(cnt)cal.pb((cnt));
    int ans=0;
    for(int i=0;i<cal.size();i++){
            ans+=cal[i]/2;
    }
    cout<<ans<<Endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	while( n-- > 0 ){
		double x[3], y[3];		// three points
		for( int i = 0; i < 3; i++ ){
			cin >> x[i] >> y[i];
		}
		double a[2];		// the slope of a line
		double b[2];		// the intersept of a line
		double ax, ay;
		int s = 0;
		for( int i = 0; i < 2; i++ ){
			if( y[i] == y[i+1] ){
				s = i+1;
			}else{
				a[i] = -(x[i] - x[i+1]) / (y[i] - y[i+1]);
				b[i] = (y[i] + y[i+1]) / 2.0 - a[i] * (x[i] + x[i+1]) / 2.0;
			}
		}
		if( a[0] == 0 ){
			ay = b[0];
			ax = ( ay - b[1] ) / a[1];
			if( s == 2){
				ax = ( x[1] + x[2] ) / 2;
				ay = a[0] * ax + b[0];
			}else if( s == 1 ){
				ax = ( x[0] + x[1] ) / 2;
				ay = a[1] * ax + b[1];
			}else{
				ax = ( b[1] - b[0] ) / ( a[0] - a[1] );
				ay = a[0] * ax + b[0];
			}
		}else if( a[1] == 0 ){
			ay = b[1];
			ax = ( ay - b[0] ) / a[0];
			if( s == 2){
				ax = ( x[1] + x[2] ) / 2;
				ay = a[0] * ax + b[0];
			}else if( s == 1 ){
				ax = ( x[0] + x[1] ) / 2;
				ay = a[1] * ax + b[1];
			}else{
				ax = ( b[1] - b[0] ) / ( a[0] - a[1] );
				ay = a[0] * ax + b[0];
			}
		}else{
			if( s == 2){
				ax = ( x[1] + x[2] ) / 2;
				ay = a[0] * ax + b[0];
			}else if( s == 1 ){
				ax = ( x[0] + x[1] ) / 2;
				ay = a[1] * ax + b[1];
			}else{
				ax = ( b[1] - b[0] ) / ( a[0] - a[1] );
				ay = a[0] * ax + b[0];
			}
		}
		double r = sqrt( pow( x[0] - ax, 2 ) + pow( y[0] - ay, 2 ) );
		printf("%.3f %.3f %.3f\n", ax, ay, r );
	}
}

Measured memory_bytes: 1244
#include <iostream>
using namespace std;
int main()
{
  long A, B, C;
  cin >> A >> B >> C;
  long V1 = abs(((A / 2) * B * C) - ((A - A / 2) * B * C));
  long V2 = abs((A * (B / 2) * C) - (A * (B - B / 2) * C));
  long V3 = abs((A * B * (C / 2)) - (A * B * (C - C / 2)));
  cout << min(V1, min(V2, V3)) << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	int h = read.to!int;
	int w = read.to!int;
	int n = read.to!int;
	int[] as = readln.split.map!(to!int).array;
	
	int[] qs;
	foreach(i, a; as) foreach(j; 0 .. a) qs ~= cast(int) (i + 1);
	
	foreach(x; 0 .. h){
		int[] ks = qs[w * x .. w * x + w];
		int[] us;
		if(x % 2 == 0) us = ks;
		else foreach_reverse(k; ks) us ~= k;
		us.map!(to!string).array.join(" ").writeln;
		}
	}

Measured memory_bytes: 1020
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    int cnt = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'x') cnt++;
    }
    if(cnt <= 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return

def main():
    n = read(int)
    a = read_list(int)

    ans = 0
    l = r = 0
    cur_sum = 0

    for l in range(0, n):
        if r < l:
            r = l
        while r < n and (cur_sum | a[r]) == cur_sum + a[r]:
            cur_sum += a[r]
            r += 1
        ans += r - l
        if l < r:
            cur_sum -= a[l]
    
    print(ans)


if __name__ == "__main__":
    main()


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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep (i, n - 1) {
    if (s[i] != s[i + 1]) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 512
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

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

int main() {
    ll N;
    cin >> N;
    vector<ll> d(N);
    REP(i,N){
        cin >> d[i];
    }
    sort(d.begin(),d.end());

    ll result = d[N/2] - d[(N/2)-1];

    cout << result << endl;
}


Measured memory_bytes: 1024
package main

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

func main() {
	buf := make([]byte, 0, 5000000)
	scan := bufio.NewScanner(os.Stdin)
	scan.Buffer(buf, 5000000)
	scan.Scan()
	scan.Scan()
	var in []int
	for _, c := range strings.Split(scan.Text(), " ") {
		num, err := strconv.Atoi(c)
		if err == nil {
			in = append(in, num)
		}
	}
	scan.Scan()
	scan.Scan()
	var in2 []int
	for _, c := range strings.Split(scan.Text(), " ") {
		num, err := strconv.Atoi(c)
		if err == nil {
			in2 = append(in2, num)
		}
	}

	var sum int
	for _, n := range in2 {
		_, exist := BinarySearchV2(in, n)
		if exist {
			sum++
		}
	}

	fmt.Println(sum)
}

func BinarySearch(in []int, target int) (int, bool) {
	l := 0
	r := len(in) - 1

	for true {
		mid := (l + r) / 2
		if in[mid] == target {
			return mid, true
		}

		if in[l] == target {
			return l, true
		}

		if in[r] == target {
			return r, true
		}

		if mid == l {
			return -1, false
		}

		if in[mid] > target {
			r = mid
		} else if in[mid] < target {
			l = mid
		}
	}
	return -1, false
}

func BinarySearchV2(in []int, target int) (int, bool) {
	l := 0
	r := len(in)

	for l < r {
		mid := (l + r) / 2
		if in[mid] == target {
			return mid, true
		}

		if in[mid] > target {
			r = mid
		} else if in[mid] < target {
			l = mid + 1
		}
	}
	return -1, false
}




Measured memory_bytes: 11736
#include <iostream>

int main(){
    int N,T;
    std::cin >> N >> T;
    int min = 10000;
    for (int i=0;i<N;i++){
        int c,t;
        std::cin >> c >> t;
        if(t<=T && c<min){
            min = c;
        }
    }
    if(min < 10000){
        std::cout << min << std::endl;
    }else{
        std::cout << "TLE" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
from collections import defaultdict
from pprint import pprint
import math
import datetime
import sys
import fcntl
import time

N = int(input())
H = [int(x) for x in input().split()]

left_high = 0
ans = True
for i in range(N):
    if H[i] < left_high:
        ans = False
        break
    left_high = max(H[i] - 1, left_high)

if ans:
    print("Yes")
else:
    print("No")    



Measured memory_bytes: 15360
N = int(input())
A = list(map(int, input().split()))
L = [0] * N
for i in A:
    L[i] += 1
flag = 1
if N%2 == 1:
    for i in range(N):
        if i == 0:
            if L[i] != 1:
                flag = 0
        elif i%2 == 1:
            if L[i] != 0:
                flag = 0
        else:
            if L[i] != 2:
                flag = 0
else:
    for i in range(N):
        if i == 0:
            if L[i] != 0:
                flag = 0
        elif i%2 == 1:
            if L[i] != 2:
                flag = 0
        else:
            if L[i] != 0:
                flag = 0
if flag:
    print(2**(N//2)%(10**9+7))
else:
    print(0)

Measured memory_bytes: 53228
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define VL vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define what(A) cout<<#A<<" is "<<A<<endl;
int main()
{
    fastio
        ll l = 0;
        ll test = 1;
    //cin >> test;
    while (test--)
    {
        ll r,g,b,k,cnt=0;
        cin>>r>>g>>b>>k;
            while(g<=r)
            {
                g*=2;
                cnt++;
            }
       	while(b<=g)
            {
                b*=2;
                cnt++;
            }    
        if(cnt>k)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3636
N = int(input())
arr = []
for i in range(N-1):
    c, s, f = list(map(int, input().split()))
    arr.append([c, s, f])

ans = []
for i in range(N-1):
    time = arr[i][1]
    for j in range(i, N-1):
        if time > arr[j][1]:
            if time % arr[j][2] != 0:
                time = time + arr[j][2] - (time % arr[j][2]) + arr[j][0]
            else:
                time = arr[j][0] + time
        else:
            time += arr[j][1] - time
            time += arr[j][0]
    print(time)
print(0)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <=n; i++)
    {
       // cerr << i << endl;
        if (i % 15 == 0)
        {
            continue;
        }
        if(i%3==0){
            continue;
        }
         if(i%5==0){
             continue;
         }

         cnt += i;
        
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
from bisect import bisect


if __name__ == "__main__":
    n = int(input())
    nums = list(map(lambda x: int(x), input().split()))
    num_query = int(input())

    for _ in range(num_query):
        k = int(input())
        if nums[bisect(nums, k) - 1] == k:
            print(1)
        else:
            print(0)



Measured memory_bytes: 17220
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

string s ;
int n , m ; 

int calc ( int mask ) {
	int ret = 0 , now = 0 ;
	for ( int i = 0 ; i < n ; ++ i ) {
		now *= 10 ;
		now += ( s [ i ] - '0' ) ;
		if ( mask >> i & 1 ) {
			ret += now ;
			now = 0 ; 
		}
	}
	ret += now ; 
	return ret ;
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s ;
	n = ( int ) s . size ( ) ;
	m = n - 1 ;
	int res = 0 ; 
	for ( int mask = 0 ; mask < ( 1 << m ) ; ++ mask ) {
		res += calc ( mask ) ; 
	}
	cout << res << '\n' ;
}



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

int main()
{
	map <string,string> p;
	p["Sunny"] = "Cloudy";
	p["Cloudy"] = "Rainy";
	p["Rainy"] = "Sunny";
	
	string s;
	cin >> s;
	cout << p[s] << endl;
	return 0;
}

Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int mod = 1e9 + 7;
  const int mod2 = 998244353;
  const int N = 20005;
  const int INF = 1e16;
  const double PI = acos(-1);



int32_t main()
{
       

    IOS


    int n;
    cin >> n;

    priority_queue<double,vector<double>, greater<double>> pq;

    for(int i = 1; i <= n; i++)
    {
      double x;
      cin >> x; 
      pq.push(x);
    }

    int ops = n - 1;

    while(ops--)
    {
      double x = pq.top();
      pq.pop();
      double y = pq.top();
      pq.pop();

      pq.push((x+y)/2);
    }

    cout << pq.top();

  return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
int partition(int p,int r);
int A[N];
int main(){
  int i,n,c;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  c=partition(0,n-1);
  for(i=0;i<n;i++){
    if(c==i) printf("[%d] ",A[i]);
    else if(i<n-1)  printf("%d ",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}

int partition(int p,int r){
  int i,j,change,x;
  x = A[r];
  i = p-1;
  for(j = p;j<r;j++){
    if(A[j]<=x){
      i = i+1;
      change=A[i];
      A[i]= A[j];
      A[j]=change;
    }
  }
  change=A[i+1];
  A[i+1]=A[r];
  A[r]=change;
  return i+1;
}

Measured memory_bytes: 992
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int n,k,temp=0,sum=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]>a[j])
            {
                temp=a[j];
                a[j]=a[i];
                a[i]=temp;
            }
        }
    }
    for(int i=0;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum;
}


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

int parity(int n){
  if(n*n*n*n%10 == 1)
    return 1;
  else
    return 0;
}

long long power(int x, int y){
  if(y < 0)
    return 0;
  else{
    int64_t n = 1ll;
    for(int i = 0; i < y; i++)
      n *= x;
    return n;
  }
}
int digit(int x, int y){
  return x%power(10,y+1)/power(10,y);
}
int card(int n){
  int cnt = 0;
  while(n > 0){
    int n0 = n%10;
    n /= 10;
    if(n0 <= 3 && n%10 == 1){
      cnt++;
      n /= 10;
    }
  }
  return cnt;
}

long long bnps(int n, int a, int d){
  long long an = 0;
  for(int i = 0; i < d; i++){
    an += a%power(n,i+1)/power(n,i)*power(10,i);
  }
  return an;
}

int left(vector<int> vec, int k){
  int a = 0;
  int b = vec.size()-1;
  if(vec.at(a) > k)
    return 0;
  else if(vec.at(a) == k)
    return a;
  else if(vec.at(b) < k)
    return -1;
  else{
    bool bk = true;
    while(bk){
      int c = (a+b)/2;
      if(vec.at(c-1) < k && vec.at(c) == k){
        return c;
        bk = false;
      }
      else if(vec.at(c-1) >= k)
        b = c;
      else if(vec.at(c) < k)
        a = c;
      else{
        return c;
        bk = false;
      }
    }
  }
}

int right(vector<int> vec, int k){
  int a = 0;
  int b = vec.size()-1;
  if(vec.at(a) > k)
    return -1;
  else if(vec.at(b) == k)
    return b;
  else if(vec.at(b) < k)
    return b;
  else{
    bool bk = true;
    while(bk){
      int c = (a+b)/2;
      if(vec.at(c) == k && vec.at(c+1) > k){
        return c;
        bk = false;
      }
      else if(vec.at(c+1) <= k)
        a = c;
      else if(vec.at(c) > k)
        b = c;
      else{
        return c;
        bk = false;
      }
    }
  }
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n%2 != 0)
    cout << "No" << endl;
  else{
    for(int i = 0; i < n/2; i++){
      if(s.at(i) != s.at(i+n/2)){
        cout << "No" << endl;
        break;
      }
      else if(i == n/2-1)
        cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    int N, K; cin >> N >> K;
    int A[N];
    int indeg[N];
    int path[N];
    fill_n(path, N, 1);
    fill_n(indeg, N, 0);

    cin >> A[0];

    int result = 0;

    if (--A[0] != 0) {
        A[0] = 0;
        result++;
    }

    for (int i = 1; i < N; ++i) {
        cin >> A[i];
        A[i]--;
        indeg[A[i]]++;
    }

    vector<int> leafs;

    REP(i,0,N) {
        if (indeg[i] == 0) {
            leafs.push_back(i);
        }
    }



    while (leafs.back() != 0) {
        int v = leafs.back();
        leafs.pop_back();
        if (path[v] == K && A[v] != 0) {
            result++;
        } else {
            path[A[v]] = max(path[A[v]], path[v] + 1);
        }
        indeg[A[v]]--;
        if (indeg[A[v]] == 0) {
            leafs.push_back(A[v]);
        }
    }

    cout << result << endl;

	return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    cin>>s;
    ll n = s.size();
    ll ans = 0;
    int now = 0;
    for(int i=0;i<n;i++){
        if(s[i] == '1'){
            now++;
            ans += (now+1)/2;
        }
    }
    bool used[n]={};
    ll l[n+1] = {};
    ll x = 0;
    for(int i=0;i<n;i++){
        l[i+1]=l[i];
        if(s[i] == '1'){
            if(x%2==0)l[i+1]++;
            x++;
            now--;
            used[i] = 1;
        }
        else{
            if(x%2){
                ans += l[i+1] + (now+1)/2;
                x++;
                used[i] = 1;
            }
        }
    }
    ll r[2][2]={};
    int p = n%2;
    x=0;
    now = 0;
    for(int i=n-1;i>=0;i--){
        if(s[i] == '1'){
            r[x][now]++;
        }
        else if(!used[i]){
            x^=1;
            ans += l[i+1] + r[x][0^p] + r[x^1][1^p];
        }
        now^=1;
    }
    cout << ans << endl;
}

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

using namespace std;

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

    string s, t;
    cin >> s >> t;
    int sum = 0;
    for (int i = 0; i<s.length(); i++){
        if (s[i] != t[i]){
            sum++;
        }
    }
    cout << sum <<endl;
    return 0;
}

Measured memory_bytes: 3736
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val aList = (0 until n).map {
        readLine()?.toInt()!!
    }
    var pos = 1
    var count = 1
    while (aList[pos - 1] != 2 && count < n) {
        pos = aList[pos - 1]
        count++
    }
    println(if (aList[pos - 1] == 2) count else -1)
}

Measured memory_bytes: 37600
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;

long long binpow(long long a, long long b)
{
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long  gcd(long long a,long long b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}

int32_t main()
{

    long long  n;
    cin>>n;
    string ans = "";
    while(n)
    {
         long long k = n/26;
         long long z = n%26;
        if(z==0)
            {
                k--;
                ans=(char)('z')+ans;
            }
        else
        {

            ans=(char)(('a'+z-1)) + ans;
        }
        n = k;

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

}


Measured memory_bytes: 3576
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
from functools import reduce

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

def lcm_list(l):
    return reduce(lcm, l, 1)

N = i_i()
T = [i_i() for _ in range(N)]

print(lcm_list(T))

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	string S;
	cin >> S;
	int i;
	int count0=0, count1=0;
	for (i = 0; i < S.size(); i++) {
		if (S[i] == '0') {
			count0++;
		}
		else
			count1++;
	}
	int max = min(count0, count1);
	cout << 2 * max;
	return 0;
}


Measured memory_bytes: 512
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N, T = inpl()
A = [None]*N
B = [None]*N
for i in range(N):
    A[i], B[i] = inpl()

dp_intime = [0]*T
dp_total = [0]*T
for n in range(N):
    dp_intime_prev, dp_intime = dp_intime, [0]*T
    dp_total_prev, dp_total = dp_total, [0]*T
    for t in range(T):
        if A[n] > t:
            dp_intime[t] = dp_intime_prev[t]
            dp_total[t] = max(B[n]+dp_intime_prev[t], dp_total_prev[t])
        else:
            dp_intime[t] = max(dp_intime_prev[t], B[n]+dp_intime_prev[t-A[n]])
            dp_total[t] = max(B[n]+dp_intime_prev[t],
                              B[n]+dp_total_prev[t-A[n]],
                              dp_total_prev[t])
print(dp_total[-1])

Measured memory_bytes: 48464
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}

int a, b, ans;
signed main() {
	cin >> a >> b;
	ans = a * b;
	ans -= (a + b - 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n = list(input())

if len(n) == 1:
    k = int("".join(map(str,n)))
    print(k)
elif len(n) == 2:
    print(9)
elif len(n) == 3:
    k = int("".join(map(str,n)))
    print(9 + k -99)
elif len(n) == 4:
    print(909)
elif len(n) == 5:
    k = int("".join(map(str,n)))
    print(9 + 900 + k - 9999)
else:
    print(90909)





Measured memory_bytes: 38468
/*
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

struct chash
{
	int operator()(int x) const
	{
		x ^= (x >> 20) ^ (x >> 12);
		return x ^ (x >> 7) ^ (x >> 4);
	}
};

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename U> using hashtable = gp_hash_table<T, U, chash>;
random_device(rd);
mt19937 rng(rd());

template<class T>
void readi(T &x)
{
	T input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = input * 10 + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	x = input;
}
template<class T>
void printi(T output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
template<class T>
void ckmin(T &a, T b)
{
	a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
	a = max(a, b);
}
template<class T, class U>
T nmod(T &x, U mod)
{
	if (x >= mod) x -= mod;
}
template<class T>
T randomize(T mod)
{
	return (uniform_int_distribution<T>(0, mod - 1))(rng);
}

#define y0 ___y0
#define y1 ___y1
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;

#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 1013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

int N;
ll x;
ll arr[MAXN];
int ans;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	// cout << fixed << setprecision(10);
	// cerr << fixed << setprecision(10);
	// freopen ("file.in", "r", stdin);
	// freopen ("file.out", "w", stdout);
	cin >> N >> x;
	for (int i = 0; i < N; i++)
	{
		cin >> arr[i];
	}
	sort(arr, arr + N);
	for (int i = 0; i < N; i++)
	{
		ll v = arr[i];
		if (x < v)
		{
			break;
		}
		x -= v;
		ans++;
	}
	if (ans == N && x != 0)
	{
		ans--;
	}
	cout << ans << '\n';
	// cerr << "time elapsed = " << (clock() / (CLOCKS_PER_SEC / 1000)) << " ms" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}
ll h,w;
Vec<2,char> arr(1010,1010);

void solve(){
    ll n;
    cin>>n;
    Vec<1,double> p(n+1);
    fo(i,1,n){
        cin>>p[i];
    }
    Vec<2,double> dp(n+1,n+1,0);
    dp[1][1] = p[1];
    dp[1][0] = 1-p[1];
    fo(i,2,n){
        fo(j,0,i){
            dp[i][j] = p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j];
        }
    }
    double sm = 0;
    fo(h,(n+1)/2,n){
        sm+=dp[n][h];
    }
    cout<<setprecision(12)<<sm<<endl;
    return ;
}
int main()

{
    IO;
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase


Measured memory_bytes: 71808
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll N, M, Q;
ll A[100001];
ll B[100001];
ll ans;
string S;
ll K;
map<ll, ll> m;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
int main() {
	ll A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	ans = A * X + B * Y;
	if (X <= Y)
		ans = min(ans, C * 2 * X + B * (Y - X));
	else
		ans = min(ans, C * 2 * Y + A * (X - Y));
	ans = min(ans, C * 2 * max(X, Y));
	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 262411;
int N, dat[2 * MX], lazy[2 * MX];
int query(int a, int b, int k, int l, int r){
	if(b <= l || a >= r) return -inf;
	if(a <= l && r <= b) return dat[k] + lazy[k];
	return lazy[k] + max(
		query(a, b, 2 * k + 1, l, (l + r) / 2),
		query(a, b, 2 * k + 2, (l + r) / 2, r));
}
void add(int a, int b, int x, int k, int l, int r){
	if(b <= l || a >= r) return;
	if(a <= l && r <= b) {
		lazy[k] += x;
		return;
	}
	lazy[k * 2 + 1] += lazy[k];
	lazy[k * 2 + 2] += lazy[k];
	lazy[k] = 0;
	add(a, b, x, 2 * k + 1, l, (l + r) / 2);
	add(a, b, x, 2 * k + 2, (l + r) / 2, r);
	dat[k] = max(dat[k * 2 + 1] + lazy[k * 2 + 1], dat[k * 2 + 2] + lazy[k * 2 + 2]);
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m; cin >> n >> m; m++; //assert(n > 3);
	for(N = 1; N < m; N *= 2);
	rep(i, 2 * N) dat[i] = -inf;
	rep(i, m) dat[i + N - 1] = -i;
	for(int i = N - 2; i >= 0; i--) dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
	
	vector<pi> v;
	rep(i, n){
		int a, b; cin >> a >> b;
		v.emplace_back(-b, a);
	}
	sort(all(v));
	
	int ans = max(0, n - m + 1);
	for(pi i : v){
		add(i.second, m, 1, 0, 0, N);
		ans = max(ans, query(0, m, 0, 0, N) - m - i.first);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    int answer=0;
    REP(i,n)cin >> a[i];
    REP(i,n)cin >> b[i];
    REP(i,n-1)cin >> c[i];
    c[n-1]=0;
    REP(i,n){
        answer+=b[a[i]-1];
        if(a[i]+1==a[i+1])answer+=c[a[i]-1];
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256