akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------

int main(void){
    ll a;
    ld b;
    cin >> a >> b;
    ll bb = round(b * 100);
    cout << a * bb / 100 << endl;
}


Measured memory_bytes: 3784
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

using namespace std;

long long divide_count(long long a){
  long long count=0;
  while(a % 2 == 0){
    a /= 2;
    count ++ ;
  }
  return count;
}

int main(int argc, char* argv[]){
  int n,i;
  long long divide_minimum, div, a;
  cin >> n;

  cin >> a;
  divide_minimum = divide_count(a);

  for(i=0; i<n-1; i++){
    cin >> a;
    div = divide_count(a);
    if(divide_minimum > div){
      divide_minimum = div;
    }
  }

  cout << divide_minimum << endl;


  return 0;
}


Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#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;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
//#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

ll n;vector<pair<ll,ll>> vw;vector<vector<ll>> dp;
ll c1,c2;

void dfs(ll i){
    if(i==1){
        dp[i-1][vw[i-1].S]=vw[i-1].F;
    }else{
        ll j=i/2;
        FORD(k,c2,0){
            if(dp[j-1][k]!=0 or k==0){
                ll ne=k+vw[i-1].S;
                if(ne<=c2)dp[i-1][ne]=max(dp[j-1][k]+vw[i-1].F,dp[i-1][ne]);
            }
            dp[i-1][k]=dp[j-1][k];
        }
    }
    if(i*2<=c1 and i*2<=n)dfs(i*2);
    if(i*2+1<=c1 and i*2+1<=n)dfs(i*2+1);
}

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    cin>>n;
    vw.resize(n);
    REP(i,n)cin>>vw[i].F>>vw[i].S;
    c1=1<<10;c2=100000;
    dp.resize(c1);REP(i,c1)dp[i].resize(c2+1);
    dfs(1);//cout << 1 << endl;
    REP(i,c1)REP(j,c2)dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
    ll q;cin>>q;
    #if 1
    REP(i,q){
        ll v,l;cin>>v>>l;
        vector<ll> cand;
        while(v>c1){
            cand.PB(v);
            v=v/2;
        }
        ll r=SIZE(cand);//cout << r << endl;
        ll ans=0;
        REP(j,1<<r){
            ll v_sub=0;ll w_sub=0;
            REP(k,r){
                if((j>>k)&1){
                    v_sub+=vw[cand[k]-1].first;
                    w_sub+=vw[cand[k]-1].second;
                }
            }
            if(w_sub<=l)ans=max(ans,dp[v-1][l-w_sub]+v_sub);
        }
        cout<<ans<<endl;
    }
    #endif
}

Measured memory_bytes: 809836
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-22 16:39:48
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=1000010;
int n,lst[N],nex[N],cnt[N],Cnt[N]={'A','B','C'};
char s[N];
int _cmp(int a,int b){ return cnt[a]<cnt[b]; }
int del(int p){ nex[lst[p]]=nex[p]; lst[nex[p]]=lst[p]; return lst[p]; }
void solve(int A,int B,int C)
{
	if(!cnt[A]){ printf("\n"); return ; }
	for(int i=nex[0];i&&cnt[C]>cnt[B];i=nex[i]) if(s[i]==C&&s[lst[i]]!=s[nex[i]]){ cnt[C]--; i=del(i); }
	for(int i=nex[0];i&&cnt[C]>cnt[B];i=nex[i]) if(((s[i]==C&&s[nex[i]]==A)||(s[i]==A&&s[nex[i]]==C))&&s[lst[i]]!=s[nex[nex[i]]])
	{
		del(nex[i]); i=del(i); cnt[C]--; cnt[A]--;
	}
	if(!cnt[A]){ printf("\n"); return ; }
	for(int i=nex[0];i&&cnt[C]>cnt[A];i=nex[i]) if(((s[i]==C&&s[nex[i]]==B)||(s[i]==B&&s[nex[i]]==C))&&s[lst[i]]!=s[nex[nex[i]]])
	{
		del(nex[i]); i=del(i); cnt[C]--; cnt[B]--;
	}
	for(int i=nex[0];i;i=nex[i]) putchar(s[i]);
	putchar(10);
}
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	fr(i,1,n){ lst[i]=i-1; nex[i-1]=i; }
	fr(i,1,n) if(s[i]==s[i+1]) del(i);
	for(int i=nex[0];i;i=nex[i]) cnt[s[i]]++;
	std::sort(Cnt,Cnt+3,_cmp);
	solve(Cnt[0],Cnt[1],Cnt[2]);
	return 0;
}

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

int main(){
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i,d) cin >> p[i] >> c[i];
    ll ans(pow(10,6));
    for(int i(0); i < (1<<d); ++i){
        vector<int> target;
        rep(j,d){
            if(i>>j & 1){
                target.push_back(j);
            }
        }
        int n = target.size();
        ll score(0),cnt(0);
        //targetのn問を完全に解く
        if(n >= 1){
            sort(target.begin(),target.end());
            rep(j,n){
                score += 100 * (target[j] + 1) * p[target[j]];
                score += c[target[j]];
                cnt += p[target[j]];
            }
        }
        if(score >= g){
            ans = min(ans,cnt);
            continue;
        }
        //target以外の問題のうち配点が最高の問題を中途半端に解く
        if(n < d){
            int k;
            if(n == 0){
                k = d-1;
            }else{
                k = d-1;
                for(int r(n-1);r>=0;--r){
                    if(target[r] == k){
                        k--;
                    }else{
                        break;
                    }
                }
            }
            if(p[k] > 1){
                rep(j,p[k]-1){
                    if(score >= g) break;
                    cnt++;
                    score += 100 * (k + 1);
                }
                if(score >= g){
                    ans = min(ans,cnt);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define INF 100000

int min(int a, int b) {
	if (a > b)
		return b;

	return a;
}

void set(int array[128][128][2], int size) {
	int i, j, k;

	for(k = 0; k < 2; k++) {
		for(i = 0; i < size; i++) {
			for(j = 0; j < size; j++) {
				if(i == j)
					array[i][j][k] = 0;
				else
					array[i][j][k] = INF;
			}
		}
	}
}

int main() {
	int info[128][128][2];
	int n, m;
	int k;
	int p, q, r;
	int st_a, st_b, cost, time;

	int x, y, z; 
	int i;

	do {
		set(info, 128);
		scanf("%d %d", &n, &m);
		if(!n && !m)
			break;

		for(i = 0; i < n; i++) {
			scanf("%d %d %d %d", &st_a, &st_b, &cost, &time); 
			info[st_a - 1][st_b - 1][0] = cost;
			info[st_b - 1][st_a - 1][0] = cost;

			info[st_a - 1][st_b - 1][1] = time;
			info[st_b - 1][st_a - 1][1] = time;
		}

		scanf("%d", &k);

		for(i = 0; i < 2; i++) {
			for(x = 0; x < m; x++)
				for(y = 0; y < m; y++)
					for(z = 0; z < m; z++)
						info[y][z][i] = min(info[y][z][i], info[y][x][i] + info[x][z][i]);
		}

		for(i = 0; i < k; i++) {
			scanf("%d %d %d", &p, &q, &r);
			printf("%d\n", info[p - 1][q - 1][r]);
		}
	} while(1);

	return 0;
}

Measured memory_bytes: 728
N, Q = map(int, input().split())
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
counter = [0] * N

for i in range(N-1):
    if S[i:i+2] == 'AC':
        counter[i+1] += counter[i] + 1
    else:
        counter[i+1] += counter[i]

for i in range(Q):
    print(counter[r[i]-1] - counter[l[i]-1])

Measured memory_bytes: 15748
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long a, b, c;
    cin >> a >> b >> c;
    if(a == 0)
        cout << (b / c) + 1;
    else
        cout << (b / c) - ((a - 1) / c);
}

Measured memory_bytes: 3608
sub f{my$d=pop;
	$c[$_]//=$';
	if($d>$d[$_]&&$d>0){
		$d[$_]=$d;
		f($d-1)for@$_
	}
}
($N,$M)=glob<>;
map{push@$_,$_[--$|]for@_=split/\s/,<>}1..$M;
<>;
for(reverse<>){
	$_*=/ .* /;
	f$&
}
print$_+0,$/for@c[1..$N]


Measured memory_bytes: 106752
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  vector<int> v(S.size());
  rep(i,S.size()){
    v[i]=S[i]-'A';	// 文字を整数に変換
    v[i]=(v[i]+N)%26;
  }
  
  rep(i,S.size()){
    S[i]=char(v[i]+'A');	// 整数を文字に変換
  }
  
  cout<<S<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M, P[100001], Y[100001];
    vector<int> sorted[100001];
    cin >> N >> M;
    REP(i, M) {
        cin >> P[i] >> Y[i];
        sorted[P[i]].push_back(Y[i]);
    }
    REP(i, 100001) sort(ALL(sorted[i]));
    REP(i, M) {
        int index = lower_bound(ALL(sorted[P[i]]), Y[i]) - sorted[P[i]].begin();
        cout << setfill('0') << setw(6) << P[i];
        cout << setfill('0') << setw(6) << index + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 7808
n, x, y = map(int, input().split())


p = [0] * n
for i in range(n-1):
    for j in range(i+1, n):
        a = min(j-i, abs(x-1-i) + abs(y-1-j)+1)
        p[a] +=1

for i in range(1,n):
    print(p[i])

Measured memory_bytes: 47580
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


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


  int n;
  cin>>n;
  cout<<n*n<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
struct cor{
    int x, y, idx;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<cor> v;
    vector<tuple<int, int, int>> edge;
    REP(i,N){
        int x, y;
        cin >> x >> y;
        cor t;
        t.x = x, t.y = y, t.idx = i;
        v.emplace_back(t);
    }
    sort(v.begin(), v.end(), [&](cor x, cor y){return x.x < y.x;});
    REP(i, N-1){
        int cost = min(abs(v[i].x - v[i+1].x), abs(v[i].y - v[i+1].y));
        edge.emplace_back(cost, v[i].idx, v[i+1].idx);
    }
    sort(v.begin(), v.end(), [&](cor x, cor y){return x.y < y.y;});
    REP(i, N-1){
        int cost = min(abs(v[i].x - v[i+1].x), abs(v[i].y - v[i+1].y));
        edge.emplace_back(cost, v[i].idx, v[i+1].idx);
    }

    sort(edge.begin(), edge.end());
    UnionFind uf(N);
    ll ans = 0;
    for(auto e : edge){
        int x, y, cost;
        tie(cost, x, y) = e;
        if(uf.issame(x, y)) continue;
        uf.unite(x, y);
        ans += cost;
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
//#define TEST


int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    int A, B;
    cin >> A >> B;
    if (A>=13){
        cout << B << '\n';
    }
    else if (A>=6 && A<=12){
        cout << B/2 << '\n';
    }
    else{
        cout << 0 << '\n';
    }

    if (argc == 2 && atoi(argv[1]) == 123456789)
        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(ReadLine());

        static long GetPow(int n) => (n == 0) ? 1 : -2 * GetPow(n - 1);
        var pow = Enumerable.Range(0, 40).Select(i => GetPow(i)).ToArray();

        long GetValue(bool[] bits) => bits.Select((v, i) => v ? pow[i] : 0).Sum();

        var NIsMinus = (N < 0);
        var bits = pow.Select(v => NIsMinus ? (v < 0) : (0 < v)).ToArray();
        foreach (var (v, i) in pow.Select((v, i) => (v, i)).Reverse())
        {
            var vIsMinus = (v < 0);
            var value = GetValue(bits) * (NIsMinus ? -1 : 1);
            if (value == N * (NIsMinus ? -1 : 1))
                break;
            else if (value - (vIsMinus ? -v : v) >= N * (NIsMinus ? -1 : 1))
                bits[i] = vIsMinus ^ NIsMinus;
        }

        var ans = new string(bits.Reverse().Select(x => x ? '1' : '0').ToArray());
        ans = ans.TrimStart('0');
        ans = ans == "" ? "0" : ans;

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28436
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i =0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15408
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200 +10;
int c[maxn],c1,c2,c3;
char str[maxn];
int main(){
	int h,w;
	cin >> h >> w;
	for(int cas=1;cas<=h;cas++){
		scanf("%s",str);
		int len=strlen(str);
		for(int i=0;i<len;i++)c[(int)str[i]-'a']++;
	}
	for(int i=0;i<=25;i++)if(c[i]%4==0)++c1; else if(c[i]%2==0)++c2; else if(c[i])++c3;
	if(h%2==0&&w%2==0){
		if(c2||c3)printf("No");
		else printf("Yes");
	}
	if(h%2==0&&w%2!=0){
		if(c3)printf("No");
		else if(c2>h/2)printf("No");
		else printf("Yes");
	}
	if(h%2!=0&&w%2==0){
		if(c3)printf("No");
		else if(c2>w/2)printf("No");
		else printf("Yes");
	}
	if(h%2&&w%2){
		if(c3>1)printf("No");
		else if(c2>(w/2)+(h/2))printf("No");
		else printf("Yes");
	}
	return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//素数判定
bool issosu(int n){
    bool is=true;
    if(n==1)return false;
    if(n==2)return true;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            is=false;
            break;
        }
    }
    return is;
}

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int Q;
    cin >>Q;

    vector<int> l(Q),r(Q),rui(100001);
    vector<bool> ISs(100001);
    rep(i,Q) cin >> l[i]>>r[i];
    ISs[0]=0;
    repd(i,1,100001) ISs[i]=issosu(i);
    rui[0]=0;
    repd(i,1,100001){
        if(i%2) rui[i]=(ISs[i] && ISs[(i+1)/2]) ? rui[i-1]+1 : rui[i-1];
        else rui[i]=rui[i-1];
    }
    rep(i,Q){
        cout << rui[r[i]] - rui[l[i]-1] <<endl;
    }
    return (0);
}

Measured memory_bytes: 1792
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
near_temp = T - H[0]*0.006
near_index = 0
for i in range(N):
    temp = T - H[i]*0.006
    if abs(A - temp) < abs(A - near_temp):
        near_temp = temp
        near_index = i
        #print("check_i")
print(near_index+1)

Measured memory_bytes: 3064
using System;

namespace _0007
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = 100000;
            Int32 a = int.Parse(Console.ReadLine());
            for (int i = 0; i < a; i++)
            {
                A = A / 20 *21;
                if (A % 1000 != 0) { A = (((int)A / 1000) + 1) * 1000; }
            }
            if (A % 1000 == 0) { Console.WriteLine(A); }
            else
            {
                Console.WriteLine(A);
            }
        }
    }
}

Measured memory_bytes: 9228
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if max(l[i],l[j],l[k])<l[i]+l[j]+l[k]-max(l[i],l[j],l[k]):
                if l[i]!=l[j] and l[k]!=l[i] and l[j]!=l[k]:
                    ans+=1
print(ans)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b="",c="";
	cin>>a;
	int ans=0;
	for(int i=0;i<=a.size()-1;i++)
	{
		c+=a[i];
		if(b!=c)
		{
			ans++;
			b=c;
			c="";
		}
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch BuildStairs | diff BuildStairs.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address BuildStairs.cpp && ./a.out

/*
 
 8/6/2019
 
 11:55-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  A[0]--;
  FOR(i,1,N) if(A[i-1]<=A[i]-1) {
    --A[i];
  }
  bool ok=true;
  REP(i,N-1) if(A[i]>A[i+1]) ok=false;
  cout<<(ok?"Yes":"No")<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
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; }

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

    int N, M1, M2; cin >> N >> M1 >> M2;
    vei a(N), b(N), c(N); rep(i,N) cin >> a[i] >> b[i] >> c[i];
    int dp[42][402][402];
    rep(i,42) rep(j,402) rep(k,402) dp[i][j][k] = INF; 
    dp[0][0][0] = 0;
    rep(i,N) rep(j,401) rep(k,401) {
        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        dp[i+1][j + a[i]][k + b[i]] = min(dp[i+1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
    }
    int ans = INF;
    rep1(i,401) rep1(j,401) {
        if(i * M2 == j * M1) {
            chmin(ans, dp[N][i][j]);
        }
    }
    if(ans == INF) dame
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  ll out = 0;
  for (ll i = 1; i <= n; ++i)
  {
    for (ll j = 1; j <= n; ++j)
    {
      ll temp = __gcd(i, j);
      for (ll k = 1; k <= n; ++k)
      {
        out += __gcd(temp, k);
      }
    }
  }
  cout << out;

}


Measured memory_bytes: 3652
//In The Name of Beauty
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e5 + 8;
ll const delta = 1000000007;
ll last[30];
int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    ll ans = s.size() - 1;
    for(ll i = 0;i < 30;i++)last[i] = -1;
    for(ll i = 0;i < 30;i++){
        ll temp = 0;
        for(ll j = 0;j < s.size();j++){
            if(s[j] != 'a' + i)continue;
            if(last[i] == -1)temp = max((ll)temp,(ll)j);
            else temp = max((ll)temp,(ll)j - (ll)last[i] - (ll)1);
            last[i] = j;
        }
        if((ll)last[i] == (ll)-1)continue;
        temp = max((ll)temp,(ll)s.size() - (ll)last[i] - (ll)1);
        ans = min((ll)ans,(ll)temp);
    }
    cout << ans;
    return 0;
}
//Written by M_H_H_7


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int N,Y;
  cin >> N >> Y;
  Y /= 1000;

  REP(i,N+1)FOR(j,0,N+1-i){
    int k = N-i-j;
    if(i*10 + j*5 + k == Y){
      printf("%d %d %d\n",i,j,k);
      exit(0);
    }
  }
  cout << "-1 -1 -1" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[100001];
int main(void)
{
  int N;
  long long K;
  cin >> N >> K;
  

  for(int i=0;i<N;i++){
    long long A,B;
    cin >>A>>B;  
    a[A]+=B;
  }
  long long ans=K;
  for(int i=1;i<100001;i++){
    if(ans<=a[i]){
      cout <<i<< endl;
      return 0;
    }
    ans-=a[i];
  }
  return 0;
}





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

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    vector<int> x(5);
    x[0] = a;
    x[1] = b;
    x[2] = c;
    x[3] = d;
    x[4] = e;

    bool flag = true;
    for(int i = 0; i < 4; i++)
    {
        for(int j = i + 1; j < 5; j++)
        {
            if(x[j] - x[i] > k)
            {
                flag = false;
            }
        }
    }

    cout << (flag ? "Yay!" : ":(") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (100010)

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

	int sum_prev = 0;
	map<int, int> mods;
	mods[0] = 1;
	for (int i = 0; i < N; i++) {
		int A;
		scanf("%d", &A);

		int sum = (A + sum_prev) % M;
		mods[sum]++;
		sum_prev = sum;
	}

	ll res = 0;
	for (auto iter = mods.begin(); iter != mods.end(); iter++)
		res += (ll)iter->second * (ll)(iter->second - 1) / 2LL;

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

	return 0;
}


Measured memory_bytes: 3200
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;
int n, m, a, b;
vector<pair<int, int> > vec;
long long ans;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        vec.pb({a, b});
    }
    sort(vec.begin(), vec.end());
    vec.pb({0, 1});
    int cur = 0, cnt = 0;
    while (1) {
        if (cnt + vec[cur].se <= m) {
            cnt += vec[cur].se;
            ans += vec[cur].fi*1LL*vec[cur].se;
        }
        else {
            ans += vec[cur].fi*1LL*(m - cnt);
            break;
        }
        cur++;
    }
    cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n , k ; 
    string s ;
    //k文字目を小文字に書き換える　つまりk-1番目を小文字にする
    cin >> n >> k ;
    cin >>s ;
    if(s.at(k-1) =='A'){s.at(k-1)='a';}
    else if(s.at(k-1) =='B'){s.at(k-1)='b';}
    else if(s.at(k-1) =='C'){s.at(k-1)='c';}

        cout <<s <<endl; 
}


Measured memory_bytes: 256
/*
*/
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
#define MOD 1000000007LL
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    ll N, A, B, ans = 0;
    cin >> N >> A >> B;
    if(A == 0) ans = 0;
    else if(N <= A)
        ans = N;
    else if (A + B >= N)
        ans = A;
    else if(N%(A+B) < A) {
        ans = N % (A + B) + N / (A + B) * A;
    }
    else {
        ans = (N / (A + B) + 1) * A;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String[] words = sc.nextLine().split(" ");
		TreeMap<String, Integer> dic = new TreeMap<String, Integer>();
		String mode = "", longest = "";
		int max = 0, maxlen = 0;
		for(int i = 0; i < words.length; i++) {
			int cnt = 1;
			String key = words[i];
			if(dic.containsKey(key)) {
				cnt = dic.get(words[i]);
				dic.remove(words[i]);
			}
			dic.put(key, ++cnt);
			
			if(max < cnt) {
				max = cnt;
				mode = key;
			}
			if(maxlen < key.length()) {
				maxlen = key.length();
				longest = key;
			}
		}
		System.out.println(mode + " " + longest);
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;


int main() {
	ll N, X, Y;
	cin >> N >> X >> Y;
	cout << min(X, Y) << " " << max(0LL, X + Y - N) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  vector<int> a(n);
  float ave=0.0;
  for(int i=0; i<n; ++i){
    cin >> a[i];
    ave += a[i];
  }
  ave /= n;
  float min_dist=100.1;
  for(int i=0; i<n; ++i){
    if( min_dist > abs(a[i] -ave) ){
      min_dist = abs(a[i] - ave);
    }
  }
  for(int i=0; i<n; ++i){
    if ( abs(a[i]-ave) == min_dist){
      cout<< i <<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
s = input()
maxim = a + b
foreign = 1
through = 0
for c in s:
    if c == 'a' and through < maxim:
        print('Yes')
        through += 1
    elif c == 'b' and through < maxim and foreign <= b:
        print('Yes')
        through += 1
        foreign += 1
    else:
        print('No')


Measured memory_bytes: 4016
import java.util.Scanner;
public class Main
{
 	public static void main(String[] args)
    {
     	Scanner sc = new Scanner(System.in);
      	String[] sep = sc.nextLine().split("");
      	boolean judge = true;
      	for(int i = 0; i < (sep.length - 1) / 2; i++)
        {
         	if(!sep[i].equals(sep[((sep.length + 3) / 2) - 1 + i])) 
            {
             	judge = false; 
            }
        }
      	if(judge)
        {
          	System.out.println("Yes");
        }else{
          	System.out.println("No");
        }
    }
  
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin >> n;
  cin >> s;
  int count = n;
  string stock = "";
  for(int i = 0;i < n;i++) {
      if(stock[0] == s[i]) {
          count--;
      }
      stock[0] = s[i];    
  }
  cout << count << endl;
}

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

int main(){
	int N,K,a[5000];
	cin>>N>>K;
	rep(i,N) cin>>a[i];
	sort(a,a+N);

	int res=N;
	set<int> sum;
	sum.insert(0);
	for(int i=N-1;i>=0;i--){
		stack<int> temp;		
		for(auto s:sum){
			int next = s+a[i]; 
			if(K<=next){
				res=i;
				break;
			}
			else temp.push(next);
		}
		while(temp.size()){
			sum.insert(temp.top());
			temp.pop();
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

int main(){

  int i,a,b,c,k,x[3];
  scanf("%d %d %d %d",&a,&b,&c,&k);
  if(a>b&&a>c){
    x[0]=a; x[1]=b; x[2]=c;
  }
  else if(b>c){
    x[0]=b; x[1]=a; x[2]=c;
  }
  else{
    x[0]=c; x[1]=a; x[2]=b;
  }
  for(i=0;i<k;i++)x[0]*=2;
  printf("%d",x[0]+x[1]+x[2]);
}


Measured memory_bytes: 760
#pragma GCC optimize("trapv")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>

using namespace std;

#define int long long
typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 + 100, INF = 1e9 * 1e9 + 10, MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

char grid[502][502], ansBl[502][502], ansR[502][502];
bool usd[502];
ll col[SIZE], c[2];

vector<vector<ll>> gr;
ll dfs(int v, int par = -1) {
    ll cnt = 0;
    for (auto to : gr[v]) {
        if (to != par) {
            cnt += dfs(to, v);
        }
    }

    if (cnt >= 2) {
        cout << "First";
        exit(0);
    }
    cnt = !cnt;
    return cnt;
}
signed main()
{
    fastInp;

    ll n;
    cin >> n;

    gr.resize(n);
    for (int i = 0; i < n - 1; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        gr[u].push_back(v);
        gr[v].push_back(u);
    }

    if (dfs(0)) {
        cout << "First";
        return 0;
    }

    cout << "Second";
    return 0;
}

Measured memory_bytes: 9248
#include <bits/stdc++.h>
#define pb push_back
#define ll int 
#define int long long 
#define mp make_pair
using namespace std;
void solve()
{
    ll n,d;
    cin >> n >> d;ll count=0;
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin >> x >> y;
        x*=x;y*=y;
        if(x+y<=d*d)
        {
            count++;
        }
    }
    cout << count << endl;
 
}
signed main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
 
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory>
#include<cmath>
#include<algorithm>
#include<vector>
#include<unordered_map>
double min_double(double a,double  b){
    if(a<b) return a;
    else return b;
}
void swap(int *x,int *y){
    int tmp;
    tmp=*x;
    *x=*y;  
    *y=tmp;
}
int gcd(int a,int b){
    if(a<b) swap(&a,&b);
    if(b<1) return -1;

    if(a%b==0) return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a * b / gcd(a,b);
}

int main(){
    int N;
    std::cin>>N;
    std::string str;
    std::cin>>str;
    int ans=1;
    for(int i=0;i<N-1;i++){
        if(str[i]!=str[i+1]) ans++;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define int ll
const ll mod =1e18;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll maxn = 400000+10;
const int K = 31;
ll power(ll x, ll n) {
  ll res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
  }
  return res;
}

int32_t main()
{

   IOS
  int n,k;
  cin>>n>>k;
  int ans = 0;
  for(int b = 1;b<=n;b++){
    if(k>=b)
      continue;
    int rem = n%b;
    int completes = n/b;
    ans+=(b-k)*completes;
    if(k==0)
      ans--;
    ans+=(max(0ll,rem-k+1));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
ABs = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

uf = UnionFind(N)

for AB in ABs:
    uf.union(AB[0], AB[1])

print(uf.group_count()-1)

Measured memory_bytes: 89808
from itertools import product, repeat
import numpy as np

input_row = lambda : [int(_) for _ in input().split(' ')]

N, M = input_row()
C = np.zeros((M, N), dtype=np.int32)

for i in range(M):
    s = np.array(input_row()[1:]) # ignore k
    C[i, s-1] = 1 # s_ to zero index.

p = input_row()

all_on_num = 0
for S_ in product(*(repeat([1, 0], N))):
    S = np.array(S_)

    L = C.dot(S)%2 == p

    if len(L[L == True]) == M:
        all_on_num += 1
print(all_on_num)



Measured memory_bytes: 27148
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{ 
  int X,Y;
  cin>>X>>Y;
  int flg = 0;
  for (int i = 0; i <=X; i++)
  {
    int A = i;
    int B = X -i;
    if(A*2 + B*4 == Y)
    flg = 1;
  }
  if(flg)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    
    int answer = 0;
    
    answer = n/(2*d+1);
    if(n%(2*d+1)!=0){
      answer=answer+1;
    }
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 21844