akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int h, w;
  cin >> h >> w;
  string grid;
  vector<vector<int>> dp(h, vector<int>(w));
  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    cin >> grid;
    for (int j = 0; j < w; j++) {
      if (grid[j] == '.') {
        (dp[i][j] += (i > 0 ? dp[i - 1][j] : 0) + (j > 0 ? dp[i][j - 1] : 0)) %=
            mod;
      } else
        dp[i][j] = 0;
    }
  }
  cout << dp[h-1][w-1];
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-9
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define siz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define endl '\n'
typedef pair<int,int> pii;
typedef unsigned long long ull;
const long long linf=1LL<<62;
const int iinf=1000000009;
const double dinf=1e15;
const int Mod=1e9+9;
const int base=228;
typedef long long ll;
typedef long double ld;
int maxt[100005<<2],mint[100005<<2];
int a[100005],k;
struct Solver {
	int n;
	void solve(){
		iossy;
		cin>>n>>k;
		For(i,1,n) cin>>a[i];
		sort(a+1,a+1+n);
		int ans=1000000007;
		For(i,1,n-k+1) {
			if(i+k-1>n) continue;
			ans=min(ans,a[i+k-1]-a[i]);
		}
		cout<<ans<<endl;
	}
};
int main(){
//	p[0]=1;
//	For(i,1,500005) p[i]=p[i-1]*base;
//	while(scanf("%d",&n)!=EOF) solve();
	int t=1;
	Solver solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 640
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#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>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, M;
	cin >> N >> M;
	vector<double>a(N), b(N), c(M), d(M);
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> c[i] >> d[i];
	}
	for (int i = 0; i < N; i++) {
		int ans;
		double m = 1000000000;
		for (int j = 0; j < M; j++) {
			double x = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (m > x) {
				chmin(m, x);
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    string s;
    cin>>s;
    set<char> st;
    rep(i,3) st.insert(s[i]);
    if(st.size()==2) cout<<"Yes";
    else cout<<"No";
}

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


using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

struct UnionFind
{
    vector<int> par, sz;
    UnionFind(int n) : par(n), sz(n, 1) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) swap(x, y);
        par[y] = x;
        sz[x] += sz[y];
        sz[y] = 0;
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return sz[root(x)];
    }
};

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

  int n, m, k; cin >> n >> m >> k;
  UnionFind uf(n);
  vector<int> d(n);
  for(int i=0;i<m;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    d[a]++;
    d[b]++;
    uf.merge(a, b);
  }

  vvi g(n);
  for(int i=0;i<k;++i) {
    int c, d; cin >> c >> d;
    c--; d--;
    g[c].push_back(d);
    g[d].push_back(c);
  }

  for(int i=0;i<n;++i) {
    int res = uf.size(i)-1;
    for(int j=0;j<SZ(g[i]);++j) {
      int to = g[i][j];
      if(uf.issame(i, to)) res--;
    }
    cout << res - d[i];
    if(i == n-1) cout << endl;
    else cout << " ";
  }

}


Measured memory_bytes: 7168
s = input()
index = []
for i, c in enumerate(s):
    if c == "A":
        index.append(i)
        break

for i, c in enumerate(reversed(s)):
    if c == "Z":
        index.append(len(s)-i)
        break

count = len(s[index[0]:index[1]])
print(count)

Measured memory_bytes: 3516
#include <iostream>

using namespace std;

int main()
{
  
    int A , B,C ;
    cin >> A >> B >> C ;
    if ((A>=1 && A<=500) && (B>=1 && B <= 500)) {
            if (C>=1 && C<=1000){
                if (C<=(A+B)) {
                cout << "Yes" << endl ;
                }
                else
                cout << "No" << endl ;
            }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
  int n,d;
  cin >> n >> d;
  int a=d*2+1;
  if(n%a==0){
    cout << n/a << endl;
  }else{
    cout << n/a+1 << endl;
  }
}


Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let x: usize = parse_line().unwrap();
    let xs = x.to_string();
    let left: usize = xs[0..1].parse().unwrap();
    let mut maxv: Vec<usize> = vec![9; xs.len() - 1];
    maxv.insert(0, left);
    let max: usize = maxv.iter().fold(0, |x, y| x * 10 + y);
    let ans: usize = maxv.iter().fold(0, |x, y| x + y);

    if max <= x {
        println!("{}", ans);
    } else {
        println!("{}", ans - 1);
    }
}


Measured memory_bytes: 2192
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

int main(){
	string S;
	cin >> S;

	map<char, bool> D;
	rep(i, (int)(S.size())){
		if (S.at(i) == 'N') D['N'] = true;
		if (S.at(i) == 'W') D['W'] = true;
		if (S.at(i) == 'S') D['S'] = true;
		if (S.at(i) == 'E') D['E'] = true;
	}
	if (D['N'] && D['S'] && D['W'] && D['E']) cout << "Yes" << endl;
	else if (D['N'] && D['S'] && !D['W'] && !D['E']) cout << "Yes" << endl;
	else if (!D['N'] && !D['S'] && D['W'] && D['E']) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

const int INF = 0x3f3f3f3f;

int cnt[7507] = {1};

int main()
{
	int k, s;
	cin >> k >> s;
	Rep(i, k) cnt[i] = i + 1;
	Rep(i, k) cnt[k+i] = k - i + 1;
	int ans = 0;
	for(int i = max(0, s-k); i <= s; ++i) ans += cnt[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env perl
use 5.10.0;
use utf8;
use strict;
use warnings;
use open qw( :utf8 :std );
use Data::Dumper;

my $line = readline;
my( $s, $w ) = split m{\s}, $line;

say $w >= $s ? "unsafe" : "safe";


exit;



Measured memory_bytes: 6484
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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 REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 523450
#endif

int N,M;
vector<int> C(SIZE);

template<typename T> class ST {
    using F = function<T(T, T)>;
    int size;
    T init;
    F f;
    vector<T> seg;
    int depth = 0;
    
public: ST(int size, T init, F f): size(size), init(init), f(f) {
    while (1<<depth < size) depth++;
    seg.assign(2<<depth, init);
}
    
    void update(int k, T t) {
        k += 1 << depth;
        seg[k] = t;
        while(k>>=1) seg[k] = f(seg[2*k], seg[2*k+1]);
    }
    
    T query(int a, int b) {
        a += 1<<depth;
        b += 1<<depth;
        T l = init;
        T r = init;
        while(a < b) {
            if (a & 1) l = f(l, seg[a++]);
            if (b & 1) r = f(r, seg[--b]);
            a >>= 1;
            b >>= 1;
        }
        return f(l, r);
    }
    
    T operator[] (int k) {
        return seg[k + (1<<depth)];
    }
};

void solve(int _t) {
    int Q;
    cin>>N>>Q;
    REP(i,N) {
        cin>>C[i];
        C[i]--;
    }
    int l,r;
    vector<pair<int,int>> V,V2;
    REP(i,Q) {
        cin>>l>>r;
        V.push_back({--l,--r});
        V2.push_back({l,r});
    }
    sort(ALL(V));
    vector<int> last(N,-1), prev(N);
    RREP(i,N) {
        prev[i]=last[C[i]];
        last[C[i]]=i;
    }
    auto st = ST<int>(N,0,[](int a, int b){return a+b;});
    map<pair<int,int>,int> ans;
    RFOR(i,V[0].first,N) {
        st.update(i, 1);
        if (prev[i]>=0) {
            st.update(prev[i], 0);
        }
    }
    int s = V[0].first;
    for (auto p:V) {
        while(s<p.first) {
            st.update(prev[s], 1);
            s++;
        }
        ans[p] = st.query(p.first, p.second+1);
    }
    for (auto p:V2) {
        cout << ans[p] << endl;
    }
}
EXEC(1)



Measured memory_bytes: 70816
def main():
    a, b, c, k = map(int, input().split())
    ans = solve(a, b, c, k)
    print(ans)


def solve(a, b, c, k):
    ca, cb, cc = 0, 0, 0
    ca = min(a, k)
    k -= ca
    cb = min(b, k)
    k -= cb
    cc = min(c, k)
    k -= cc
    ans = ca * 1 + cb * 0 + cc * (-1)
    return ans


if __name__ == '__main__':
    main()

Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> S(N);
  for (int i = 0; i < N; i++) cin >> S[i];
  ll ans = 0;
  for (int d = 1; d <= N - 1; d++) {
    set<int> st;
    int l = 0;
    int r = N - 1;
    ll cost = 0;
    while (l < N - 1 && r > d) {
      if (!st.insert(l).second) break;
      if (!st.insert(r).second) break;
      cost += S[l] + S[r];
      l += d;
      r -= d;
      ans = max(ans, cost);
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 5376
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int dp[310];
int d[310];
int b;
vector<int> g[1100];
vector<int>h[310];
int to[1100];

int main(){
	int a,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%d",d+i);
	for(int i=0;i<a;i++)dp[i]=999999999;
	for(int i=0;i<b;i++)g[i].clear();
	for(int i=0;i<a;i++)h[i].clear();
	for(int i=0;i<b;i++){
		int p;
		scanf("%d%d",to+i,&p);
		to[i]--;
		h[to[i]].push_back(i);
		for(int j=0;j<p;j++){
			int q;scanf("%d",&q);
			q--;g[i].push_back(q);
		}
	}
	for(int i=0;i<a;i++)if(d[i])dp[i]=1;
	for(int i=0;i<310;i++){
		for(int j=0;j<b;j++){
			vector<int>res;
			for(int k=0;k<g[j].size();k++)res.push_back(dp[g[j][k]]);
			std::sort(res.begin(),res.end());
			int val=0;
			for(int k=0;k<g[j].size();k++)val=max(val,res[k]+(int)(g[j].size()-1-k));
			dp[to[j]]=min(dp[to[j]],val);
		}
	}
	c--;
	if(dp[c]>99999)printf("-1\n");
	else printf("%d\n",dp[c]);
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	string s,t;
	cin>>s>>t;
	int ls=(int)s.length();
	int lt=(int)t.length();
	int dp[ls+1][lt+1];
	for(int i=0;i<=ls;i++)
		for(int j=0;j<=lt;j++)dp[i][j]=0;
	for(int i=1;i<=ls;i++){
		for(int j=1;j<=lt;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=max(dp[i-1][j-1]+1,dp[i-1][j]);	
			}
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=ls,j=lt;
	vector<char>ans;
	while(i>0&&j>0){
		if(dp[i][j]>dp[i-1][j]&&dp[i][j]>dp[i-1][j-1]&&dp[i][j]>dp[i][j-1])	{
			ans.pb(s[i-1]);
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	for(int i=dp[ls][lt]-1;i>=0;i--){
		cout<<ans[i];	
	}
	cout<<endl;
}



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

using namespace std;

#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define endl '\n'

typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<si> vsi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vsi> vvsi;

const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;
ll mod = (int)pow(10,9)+7;
//**************************************************************
//int findSet(int i)
// {
// 	return (p[i]==i)? i:(p[i]=findSet(p[i]));
// }
// bool isSame(int i, int j)
// {
// 	return findSet(i)==findSet(j);
// }
// void unionSet(int i, int j)
// {
// 	if(!isSame(i,j))
// 	{
// 		int x = findSet(i);
// 		int y = findSet(j);
// 		if(ra[x]>ra[y])
// 			p[y] = i;
			
// 		else
// 		{
// 			p[x] = y;
// 			if(ra[x]==ra[y])
// 				ra[y]++;		
// 		}
// 	}
// }

// ***************************************************************************
// ll mulmod(ll a, ll b, ll mod) 
// { 
//     ll res = 0; // Initialize result 
//     a = a % mod; 
//     while (b > 0) 
//     { 
//         // If b is odd, add 'a' to result 
//         if (b % 2 == 1) 
//             res = (res + a) % mod; 
  
//         // Multiply 'a' with 2 
//         a = (a * 2) % mod; 
  
//         // Divide b by 2 
//         b /= 2; 
//     } 
  
//     // Return result 
//     return res % mod; 
// } 
// *****************************************************************************
// bool sieve[100005];

// void sieveoferat()
// {
// 	for(ll p = 2; p*p<100005 ; p++)
// 	{
// 		if(sieve[p])
// 		{
// 			for(int j = p*p; j<100005; j+=p)
// 				sieve[j] = false;
// 		}
// 	}
// }
//********************************************************************************
// void dp(sp_1, sp_2.....)
// {
// 	if()//exit statement
// 	if()//using the memoization 
// 	ll ans = //default/dummy answer
// 	//recursions
// 			//max/min
// 	return memo[][].. = ans;

// }
//*************************************************************************************
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 	cout.tie(NULL);
 	//memset(memo, -1, sizeof memo);
 	// memset(sieve, true, sizeof sieve);
 	// sieveoferat();
 	// for(int i = 1; i<100005 ;i++) UFDS
		// p[i] = i;
 	string s; cin>>s;
 	map<char, int> freq;
 	for(int i = 0; i < s.size(); i++)
 		freq[s[i]]++;
 	if(freq.size()==2)
 		cout<<"Yes\n";
 	else
 		cout<<"No\n";

 	
	return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/04/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w; cin>>h>>w;
  map<char, int> table;
  for (int i = 0; i < h*w; i++) {
    char c; cin>>c;
    table[c]++;
  }
  auto solve = [&]() {
    if (h%2==1 and w%2==0)
      swap(h,w);
    const int one_max = h%2==1 and w%2==1 ? 1 : 0;
    int one_cnt = 0;
    const int two_max = (h%2==1?w/2:0) + (w%2==1?h/2:0);
    int two_cnt = 0;
    for (auto p : table) {
      auto c = p.second;
      if (p.second%2==1) {
        if (++one_cnt > one_max)
          return false;
        c--;
      }
      if (c%4==2) {
        if (++two_cnt > two_max)
          return false;
      }
    }
    return true;
  };
  cout << (solve() ? "Yes" : "No") << endl;

  return 0;
}


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

int main(void){
    int N,M; cin >> N >> M;
    bool A[N], B[N];
    for(int i=0; i<N; i++){
        A[i]=false;
        B[i]=false;
    }
    for(int i=0; i<M; i++){

        int a,b; cin >> a >> b;
        if(a==1) A[b-1]=true;
        else if(b==N) B[a-1]=true;
    }

    for(int i=0; i<N; i++){
        if(A[i]==true and B[i]==true){
            cout << "POSSIBLE"  << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    int h, w = 0;
    cin >> h >> w;
    vector<string> grid(h);

    REP(i, h)
    {
        cin >> grid[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);

    REP (i, h)
    {
        REP(j, w)
        {
            if (grid[i][j] == '#')
            {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    REP(i, h)
    {
        if (row[i])
        {
            REP(j, w)
            {
                if (col[j])
                {
                    cout << grid[i][j];
                }
            }
            cout << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		List<Character> list = new ArrayList<Character>();
		char[] C = S.toCharArray();
		for (int i = 0; i < N; i++) {
			list.add(C[i]);
		}
		int count = 0;
		for (int i = 0; i < N-1;i++) {
			if (!(list.get(i).equals(list.get(i + 1)))){
				count++;
				i++;
			}
		}
		System.out.println(count);
		sc.close();

	}
}



Measured memory_bytes: 31112
N, X = map(int, input().split())
q = [1]*(N+1)
p = [1]*(N+1)
for i in range(1, N+1):
    q[i] = 2*q[i-1]+3
    p[i] = 2*p[i-1]+1

ans = 0
s = [(X, N)]
while s:
    x, n = s.pop()
    if n==0:
        if x:
            ans += 1
    if x:
        a = q[n-1] + 2
        b = p[n-1] + 1

        if x >= a:
            ans += b
            s += [(x-a, n-1)]
        else:
            s += [(x-1, n-1)]

print(ans)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

b = []
tmp = []

for i in range(N):
    if i % 2 == 0:
        b.append(A[i])
    else:
        tmp.append(A[i])
tmp.reverse()
tmp.extend(b)
if N % 2 == 1:
    tmp.reverse()
print(" ".join(map(str, tmp)))


Measured memory_bytes: 31480
#include <cstdio>  
#include <cstring>  
#include <cmath>  
using namespace std;  
const int maxn=1e2+10;   
int n;  
int a[maxn][maxn];  
int dp[maxn][maxn];  
  
int max(int a,int b)  
{  
    return a>b?a:b;  
 }   
  
void solve()  
{  
    dp[1][1]=a[1][1];  
    for(int i=1;i<=2;i++)  
    {  
        for(int j=1;j<=n;j++)  
        {  
            if(i==1)  
                dp[i][j]=dp[i][j-1]+a[i][j];  
            else  
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];   
        }  
    }  
}   
int main()  
{  
    while(~scanf("%d",&n))  
    {  
      
    memset(a,0,sizeof(a));  
    memset(dp,0,sizeof(dp));  
    for(int i=1;i<=2;i++)  
    {  
        for(int j=1;j<=n;j++)  
        {  
            scanf("%d",&a[i][j]);  
        }  
    }  
    solve();  
    printf("%d\n",dp[2][n]);  
}  
    return 0;  
}  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

istringstream lcin;
void rl()
{
    string s;
    getline(cin, s);
    lcin = istringstream(s);
}
// build: ctrl + f9

// run: shift + f10
// debug: shift + f9
// sanitize: shift + f11

ll mods(ll a, ll b, ll m) {
    return (a%m + b%m)%m;
}

ll modp(ll a, ll b, ll m) {
    return ((a%m)*(b%m))%m;
}

ll modd(ll a, ll b, ll m) {
    return ((a%m)/(b%m))%m;
}

ll Cnm(ll c, ll n, ll m) {
    ll tot = 1;
    R1(c) {
        tot = (tot * (n-i)%m)%m;
    }
    ll div = 1;
    R1(c) {
        div = (div * (i+1)%m)%m;
    }

    return (tot/div)%m;
    
}

ll cmin(ll i, ll N, ll m) {
    /*ll tot = 0;
    for(int j = 0; j < i; ++j) {
        tot = (tot + j%m)%m;
    }*/

    return ((i-1)*(i)/2);

    //return tot;
}

ll cmax(ll i, ll N, ll m) {
    /*ll tot = 0;
    for(int j = N + 1 - i; j <= N; ++j) {
        tot = (tot + j%m)%m;
    }*/

    //return tot;
    ll tot = ((N)*(N+1)/2) - ((N-i)*(N-i+1))/2;
    return tot;
}

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

    ll N, K;

    cin >> N >> K;

    ll m = 1000000007;

    ll tot = 0;

    for(ll i = K; i <= N + 1; ++i) {
        tot = (tot + (cmax(i, N, m) - cmin(i, N, m) + 1)%m)%m;        
    }

    cout << tot << endl;

}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    while (!s.empty()) {
        ans += s.back() - '0';
        s.pop_back();
    }
    cout << (ans % 9 == 0 ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int s;
  cin>>s;
  if(s==1 or s==2 or s==4){
    cout<<4<<endl;
    return 0;
  }
  for(int i=0;;i++){
    if(s%2==0) s/=2;
    else s=3*s+1;
    if(s==4){
      cout<<i+5<<endl;
      break;
    }
  }
  return 0;
}


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

int main(){
	string str;
	getline(cin, str);

	int offset = 'a' - 'A';

	int length = str.length();
	for(int i = 0; i < length; i++){
		if(str[i] >= 'a' && str[i] <= 'z'){
			str[i] -= offset;
		}else if(str[i] >= 'A' && str[i] <= 'Z'){
			str[i] += offset;
		}
	}
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 3204
import itertools

n, m, q = map(int, input().split())
lst = []
for _ in range(q):
  l = [int(i) for i in input().split()]
  lst.append(l)

lists = list(itertools.combinations_with_replacement(range(1, m+1), n))
#print(lists)
max_point = 0
for each in lists:
  point = 0
  for i in range(q):
    l = lst[i]
    a = l[0] - 1
    b = l[1] - 1
    c = l[2]
    if each[b] - each[a] == c:
      point += l[3]
  if point > max_point:
    max_point = point
print(max_point)

Measured memory_bytes: 21412
#include<iostream>
using namespace std;
int main() {
	while(1) {
		int h, w;
		cin >> h >> w;
		if(h == 0 && w == 0)
			return 0;
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				if(i == 0 || i == h - 1)
					cout << '#';
				if(i > 0 && i < h - 1) {
					if(j != 0 && j != w - 1)
						cout << '.';
					else cout << '#';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3088
import java.util.Arrays;
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			String[] S = new String[n];
			int[] ret = new int[26];
			Arrays.fill(ret, 51);
			
			for(int i=0;i<n;i++) {
				S[i] = sc.next();
			}
			
			for(int i=0;i<n;i++) {
				char[] s = S[i].toCharArray();
				int[] reti = new int[26];
				
				for(int j=0;j<s.length;j++) {
					reti[(int)s[j]-97]++;
				}
				
				for(int k=0;k<26;k++) {
					ret[k] = Math.min(ret[k], reti[k]);
				}
			}
			
			for(int i=0;i<26;i++) {
				for(int j=0;j<ret[i];j++) {
					System.out.print((char)(i+97));
				}
			}
	    }
				
	}
	


Measured memory_bytes: 35840
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		scanner.nextLine();
		String line = scanner.nextLine();
		int[] arr = strToIntArray(line);
		int sz = arr.length;

		for (int i=0; i<sz; i++) {
			if (arr[i] % 2 == 0) {
				if (arr[i] % 3 != 0 && arr[i] % 5 != 0) {
					System.out.println("DENIED");
					return;
				}
			}
		}

		System.out.println("APPROVED");
		return;
	}

	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}

}

class LCS {
    int[][] dp;
    public int lcs(String A, String B) {
        int sz_a = A.length(), sz_b = B.length();
        dp = new int[sz_a+1][sz_b+1];

        for (int i=0; i<=sz_a; i++) dp[i][0] = 0;
        for (int j=0; j<=sz_b; j++) dp[0][j] = 0;

        for (int i=1; i<=sz_a; i++) {
            for (int j=1; j<=sz_b; j++) {
                if (A.charAt(i-1) == B.charAt(j-1)) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }

        return dp[sz_a][sz_b];
    }

    public String getLCS(String X, String Y) {
		int m = X.length();
		int n = Y.length();
        // Following code is used to print LCS
        int index = dp[m][n];
        int temp = index;

        // Create a character array to store the lcs string
        char[] lcs = new char[index+1];
        lcs[index] = '\0'; // Set the terminating character

        // Start from the right-most-bottom-most corner and
        // one by one store characters in lcs[]
        int i = m;
		int j = n;
        while (i > 0 && j > 0) {
            // If current character in X[] and Y are same, then
            // current character is part of LCS
            if (X.charAt(i-1) == Y.charAt(j-1))
            {
                // Put current character in result
                lcs[index-1] = X.charAt(i-1);

                // reduce values of i, j and index
                i--;
                j--;
                index--;
            }

            // If not same, then find the larger of two and
            // go in the direction of larger value
            else if (dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
        }

        // // Print the lcs
        // System.out.print("LCS of "+X+" and "+Y+" is ");
        // for(int k=0;k<=temp;k++)
        //     System.out.print(lcs[k]);
        //

        return String.valueOf(lcs).substring(0, temp+2);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
	char str1[10],str2[10];
	scanf("%s%s",str1,str2);
	int flag=0;
	for(int i=0,j=2;i<3,j>=0;i++,j--)
	{
		if(str1[j]!=str2[i])
		flag=1;
	}
	if(flag) puts("NO");
	else
	puts("YES");
	
	return 0;
 } 

Measured memory_bytes: 128
#include <cstdio>
#define MAX_N 100001

bool IsPrime[MAX_N + 1];

// アトキンの篩
void get_primes() {
    for (int x = 1; x*x < MAX_N; x++) {
        for (int y = 1; y*y < MAX_N; y++) {
            int n = (4*x*x) + (y*y);
            if (n <= MAX_N && (n % 12 == 1 || n % 12 == 5)) {
                IsPrime[n] ^= true;
            }
            n = (3*x*x)+(y*y);
            if (n <= MAX_N && n % 12 == 7) {
                IsPrime[n] ^= true;
            }
            n = (3*x*x)-(y*y);
            if (x > y && n <= MAX_N && n % 12 == 11) {
                IsPrime[n] ^= true;
            }
        }
    }

    for (int r = 5; r*r < MAX_N; r++) {
        if (IsPrime[r]) {
            for (int i = r*r; i < MAX_N; i += r*r) {
                IsPrime[i] = false;
            }
        }
    }
    IsPrime[2] = IsPrime[3] = true;
}

int main() {
    int Q, l, r;
    int cnt[MAX_N + 1] = {0};

    get_primes();

    for (int i = 3; i <= MAX_N; i += 2) {
        if (IsPrime[i] && IsPrime[(i+1)/2]) { cnt[i]++; }
    }
    for (int i = 1; i <= MAX_N; i++) {
        cnt[i] += cnt[i-1];
    }

    scanf("%d", &Q);

    while (Q--) {
        scanf("%d %d", &l, &r);
        printf("%d\n", cnt[r] - cnt[l-1]);
    }

    return 0;
}

Measured memory_bytes: 1024
//  __/\\\\____________/\\\\______/\\\\\\\\\______/\\\________/\\\___/\\\\\\\\/\\____/\\\\\\\\\\_|
//   _\/\\\\\\________/\\\\\\____/\\\\\\\\\\\\\___\/\\\________/\\\__\/\\\____\/\\\__\////\\\///__|
//    _\/\\\//\\\____/\\\//\\\___/\\\/////////\\\__\/\\\________/\\\__\/\\\____\/\\\\____\/\\\_____|
//     _\/\\\\///\\\/\\\/_\/\\\__\/\\\_______\/\\\__\/\\\\\\\\\\\\\\\__\/\\\____\/\\\\____\/\\\_____|
//      _\/\\\__\///\\\/___\/\\\__\/\\\\\\\\\\\\\\\__\/\\\/////////\\\__\/\\\____\/\\\\____\/\\\_____|
//       _\/\\\____\///_____\/\\\__\/\\\/////////\\\__\/\\\_______\/\\\__\/\\\____\/\\\_____\/\\\_____|
//        _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\___/\\\\______\/\\\_____|
//         _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\\\\/\\_____/\\\\\\\\\\__|
//          _\///______________\///___\///________\///___\///________\///___\/////////_____\//////////___|
#include<bits/stdc++.h>
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< long long > vl;
#define hurry ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define setp setprecision
#define popp pop_back()
#define pb push_back
#define mp make_pair
#define beg begin()
#define end end()
#define sc second
#define sz size()
#define fr first
#define endl '\n'
//=======================================================================================================================
//GLOBAL
ll dp[100002][3];
ll ans;
//=======================================================================================================================
//FUNCTIONS
//=======================================================================================================================
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    for(int i=2;i<=n;i++)
    {
        dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
        dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c[i];
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
}
//========================================================================================================================


Measured memory_bytes: 3712
/*****************************************************

@author: vichitr
Compiled On: 13th Aug 2019

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;

int n;
vector<int> adj[N]; 
bool vis[N];
int ans[N];

void dfs(int v, int x)
{
    ans[v] += x;
    vis[v] = 1;
    for(auto i: adj[v])
    {
        if(!vis[i])
        {
            dfs(i, ans[v]);
        }
    }
}

void solve()
{
    string s, t; cin>>s>>t;
    int c = 0;
    int cur = 0, prev = -1;
    for(int i = 0; i<s.size();i++)
        adj[s[i]].pb(i);
    bool f = 1;
    for(int i=0;i<t.size();i++)
    {
        auto it = lower_bound(adj[t[i]].begin(), adj[t[i]].end(), prev+1);
        if(it==adj[t[i]].end())
        {
            c++;
            prev = -1;
            it = lower_bound(adj[t[i]].begin(), adj[t[i]].end(), prev+1);
            if(it==adj[t[i]].end())
            {
                f=0;
                break;
            }
            else{
                prev = *it;
            }
        }
        else{
            prev = *it;
        }
    }
    int ans = c*s.size() + prev + 1;
    if(!f)
        cout<<"-1";
    else
        cout<<ans;
}

signed main()
{
    // fast;
    int t=1;
    // cin >>t;
    while(t--){
        solve();
        
    }
    return 0;
}

/*****************************


****************************/

Measured memory_bytes: 6460
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

const std::string YES = "Yes";
const std::string NO = "No";
bool solve(long long D, long long T, long long S) {
  return D <= S * T;
  // TODO: edit here
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  long long D, T, S;
  std::cin >> D >> T >> S;
  auto ans = solve(D, T, S);
  std::cout << (ans ? YES : NO) << std::endl;
  return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 n,K;
    cin >> n >> K;
    vector<i64> a(n);
    rep(i,0,n) cin >> a[i];
    sort(a.begin(),a.end());

    static bool dp[5001];
    auto ok=[&](int x){
        if(a[x]>=K) return true;
        fill_n((bool*)dp,5001,false);
        dp[0]=true;
        if(x!=0 and a[0]<=K) dp[a[0]]=true;
        if(x==0 and n>=2 and  a[1]<=K) dp[a[1]]=true;
        rep(i,(x==0?2:1),n){
            if(i==x) continue;
            for(int j=K-1; j>=0; --j){
                if(!dp[j] or j+a[i]>K) continue;
                dp[j+a[i]]=true;
            }
        }
        rep(i,K-a[x],K) if(dp[i]) return true;
        return false;
    };

    int lb=-1,ub=n;
    while(ub-lb>1){
        int mid=(lb+ub)/2;
        if(ok(mid)) ub=mid;
        else lb=mid;
    }
    cout << ub << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

//for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//abbreviati
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//constant
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet**************************************
ifelse, isprime, torad, todeg, lcm, bfs
************************************************/

//adjacency list
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,k;cin >> a >> b >> c >> k;
    rep(i,0,k){
        if(b>=c) c=2*c;
        else if(a>=b) b=2*b;
    }

    //cout << a << b << c ENDL;
    if(a<b && b<c) cout << "Yes" ENDL;
    else cout << "No" ENDL;
    
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int
typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n;
  cin >> n;
  vector<int> v(n, 0);
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    cin >> v[i];
    mp[v[i]]++;
  }
  // for(auto i : mp){
  //   cout << i.first << " : " << i.second << endl;
  // }

  int res = 0;
  for(auto a : mp)
  {
    if(a.second % 2 == 1) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
int main() {
	ll n;
	cin >> n;
	ll k = n % 10;
	if (k == 3) {
		puts("bon");
	}
	else if (k == 0 || k == 1 || k == 6 || k == 8) {
		puts("pon");
	}
	else {
		puts("hon");
	}
	return 0;
}


Measured memory_bytes: 3628
#include"bits/stdc++.h"
using namespace std;

int main(){
  int n, i, ans=0;
  cin >> n;
  for(i=1; i<=n; i++){
    if((to_string(i).length())%2==1){
      ans+=1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
ans=0
for i in range(1<<n-1):#+を入れるかどうか
    num=s[0]
    for j in range(n-1):#+を入れるかどうか
        if i&(1<<j):#bitで考える,iと1<<jが同じ数字であれば実行
            num+="+"+s[j+1]
        else:
            num+=s[j+1]
    ans+=eval(num)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int S, W;
  cin >> S >> W;

  if(S <= W) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  
  return 0;
}


Measured memory_bytes: 3636