akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()

int main() {
	set<int> A, B;
	int n;
	cin >> n;
	Rep(i, n) {
		int a;
		cin >> a;
		A.insert(a);
	}
	int m;
	cin >> m;
	Rep(i, m) {
		int b;
		cin >> b;
		B.insert(b);
	}
	set<int> res;
	set_union(All(A), All(B), inserter(res, res.end()));
	for (auto v : res) {
		cout << v << endl;
	}
	return 0;
}


Measured memory_bytes: 40584
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926535
 
 
int main()
 {
	int a,b,h,m;
	double answer,deg,adeg,bdeg,rad;
	
	scanf("%d%d%d%d",&a,&b,&h,&m);

	adeg=30*h+m*0.5;
	
	bdeg=6*m;

	deg=fabs(adeg-bdeg);

	rad=deg*(PI/180);
	
	answer=sqrt(a*a+b*b-2*a*b*cos(rad));

	printf("%.10lf",answer);

			return 0;
	}


	







Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s;
	string a,b;
	cin>>a>>b;
	int zh(string x);
	s=zh(a+b);
	int n;
	n=sqrt(s);
	if(n*n==s)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

int zh(string x)
{
	int s=0,i;
	for(i=0;i<x.size();i++)s=s*10+(x[i]-'0');
	return s; 
}

Measured memory_bytes: 256
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n, m = map(int, input().split())
    ans = []
    for i in range(1, (m+1)//2+1):
        if len(ans) == m:
            break
        ans.append([i, m+2-i])

    for i in range(1, (m+1)//2+1):
        if len(ans) == m:
            break
        ans.append([m+1+i, 2*m+2-i])

    for x in ans:
        print(x[0], x[1])

main()


Measured memory_bytes: 22768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A;
	cin >> A;
	
	co((A - 2) * 180);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ull MOD = 1e9+7;

int H,W,A,B;
ll cnt;
ll fact[2*100010];
ll frev[2*100010];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}

ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

ll square(int x0, int y0, int x1, int y1){
    int xx = x1 - x0;
    int yy = y1 - y0;
    return comb(xx+yy, min(xx,yy)) % MOD;
}

int main(){
    cin >> H >> W >> A >> B;

    fact[0] = frev[0] = 1;
    for(int i = 1; i <= 200000; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    for(int w = B; w < W; w++){
        cnt += square(0,0,w,H-A-1) * square(w,H-A,W-1,H-1) % MOD;
    }
    //cnt = square(0,0,4,4);
    //cnt = comb(8,4);
    cout << cnt % MOD << endl;
    return 0;
}


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

typedef long long ll;
const int maxn = 2e5 + 5, mod = 998244353;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

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

int n, rt, len, fa[maxn], ch[maxn];

struct edge
{
	int to, next;
} e[maxn * 2];
int h[maxn], tot;
int md[maxn], f[maxn][3][3], g[3][3];

inline void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]}; h[u] = tot;
	e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}

void dfs1(int u, int d)
{
	if (d > len) rt = u, len = d;
	md[u] = d;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa[u]) fa[v] = u, dfs1(v, d + 1), md[u] = max(md[u], md[v]);
}

void dfs2(int u, int d)
{
	(md[u] == d ? f[u][1][1] : f[u][0][0]) = 1;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa[u]) {
			fa[v] = u; dfs2(v, d + 1);
			memset(g, 0, sizeof(g));
			for (int a = 0; a <= 2; ++a)
				for (int b = 0; b <= 2; ++b)
					if (f[u][a][b])
						for (int c = 0; c <= 2; ++c)
							for (int d = 0; d <= 2; ++d)
								if (f[v][c][d])
									for (int t = -1; t <= 1; ++t)
										inc(g[min(2, a + (md[v] == md[u] && t == 1) * c)][min(2, b + (md[v] == md[u] && t == -1) * d)], (ll)f[u][a][b] * f[v][c][d] % mod);
			memcpy(f[u], g, sizeof(f[u]));
		}
}

int main()
{
	n = gi();
	for (int i = 1; i < n; ++i) add(gi(), gi());

	dfs1(1, 0);
	fa[rt] = 0; len = 0; dfs1(rt, 0);
	for (int i = 0, x = rt; x; x = fa[x]) ch[i++] = x;

	if (~len & 1) {
		int x = ch[len >> 1];
		fa[x] = 0, dfs1(x, 0);
		dfs2(x, 0);
		printf("%lld\n", (ll)f[x][1][1] * (mod + 1) / 2 % mod);
	}
	else {
		int x = ch[len >> 1], y = ch[len + 1 >> 1];
		fa[x] = y; fa[y] = x;
		dfs1(x, 0); dfs2(x, 0);
		dfs1(y, 0); dfs2(y, 0);
		printf("%lld\n", ((ll)f[x][1][0] + f[x][1][1] + f[x][1][2]) * ((ll)f[y][1][0] + f[y][1][1] + f[y][1][2]) % mod);
	}
	
	return 0;
}



Measured memory_bytes: 19584
#![allow(unused)]

use std::io::{Read, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

pub fn read_bytes<T: FromIterator<char>>(s: &mut StdinLock) -> T {
    s.bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<T>()
}

pub fn reads(s: &mut StdinLock) -> String {
    read_bytes::<String>(s)
}

pub fn read<T: FromStr>(s: &mut StdinLock) -> T {
    reads(s).parse().ok().unwrap()
}

fn main() {
    let sin = std::io::stdin();
    let mut sin = sin.lock();

    let n = read::<i64>(&mut sin);
    let m = read::<i64>(&mut sin);

    let ee = if n == 0 { 0 } else { n * (n - 1) / 2 };
    let oo = if m == 0 { 0 } else { m * (m - 1) / 2 };

    println!("{}", ee + oo);
}

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

ll solve() {
    string S;
    cin >> S;
    ll ans = 0;
    int l,r;
    char c;
    if ( S.size() & 1 ) {
        l = S.size() / 2;
        r = S.size() / 2;
    } else {
        l = S.size() / 2 - 1;
        r = S.size() / 2;
    }
    c = S[l];
    while ( l >= 0 && S[l] == c && S[r] == c ) {
        l--;
        r++;
    }
    return r;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		int d = in.nextInt();
		long res = 0;
		for(int i=4;i<=m;i++) {
			for(int j=22;j<=d;j++) {
				int d1 = j%10;
				int d2 = j/10;
				if(d1>=2 && d2>=2 && i==d1*d2) {
					res++;
				}
			}
		}
		System.out.print(res);
		
		in.close();

	}

}


Measured memory_bytes: 21844
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#define in inline
#define re register
using namespace std;
in long long read(){
	re long long t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int a[82][82],b[82][82],n,m,f[82][35002],g[82][35002];
int main(){
	n=read();
	m=read();
	for(re int i=1;i<=n;++i)
	for(re int j=1;j<=m;++j)a[i][j]=read();
	for(re int i=1;i<=n;++i)
	for(re int j=1;j<=m;++j)b[i][j]=read();
	f[1][abs(a[1][1]-b[1][1])]=f[1][abs(b[1][1]-a[1][1])]=1;
	for(re int i=2;i<=m;++i){
		for(re int j=0;j<=(i-1)*80;++j){
			if(f[i-1][j])f[i][abs(j+abs(a[1][i]-b[1][i]))]=1,f[i][abs(j-abs(a[1][i]-b[1][i]))]=1;
		}
	}
	for(re int i=2;i<=n;++i){
		for(re int j=1;j<=m;++j){
			for(re int k=0;k<=(i+j-1)*80;++k){
				if(f[j][k]||g[j-1][k]){//cout<<f[j][k]<<" "<<g[j-1][k]<<" "<<i<<" "<<j<<" "<<k<<endl;
				g[j][abs(k+abs(a[i][j]-b[i][j]))]=1,g[j][abs(k-abs(a[i][j]-b[i][j]))]=1;
				}
				
			}
			
		}
		for(re int j=1;j<=m;++j){
			for(re int k=0;k<=(i+j-1)*80;++k){
				f[j][k]=g[j][k];
				g[j][k]=0;
			}
			
		}
	}
	int tmp=0;
	while(!f[m][tmp])++tmp;
	printf("%d",tmp);
}

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

int main(void){
    
    int n;
    
    cin >> n;
    
    if(n/100==7){
        
        cout << "Yes" << endl;
        return 0;
        
    }
    
    n %= 100;
    
    if(n/10==7){
        
        cout << "Yes" << endl;
        return 0;
        
    }
    
    n %= 10;
    
    if(n==7){
        
        cout << "Yes" << endl;
        return 0;
        
    }
    
    cout << "No" << endl;
    
    return 0;
    
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void PRINT(T container, bool withSize) { if(withSize) cout<<container.size()<<endl; for(auto it : container) cout<<it<<" "; cout<<endl; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

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

    int h,w,n;
    cin>>h>>w>>n;

    int black=0;
    int op=0;
    if(h>w)
        swap(h,w);

    FOR(i,h) {
        black += w;
        op++;
        if(black >= n)
            EXIT(op);
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n; cin >> n;
	ll cnt = 0;
	rep(i,1,n){
		rep(j,1,n){
			if(i * j <= n - 1){
				cnt++;
			}else{
				break;
			}
		}
	}
	cout << cnt << endl;
}


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

using ll=long long;
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

int main(){
  int t;cin>>t;
  while(t--){
    int n,ans=0;cin>>n;
    vector<ll>v(n),now;
    for(int i=0;i<n;i++)cin>>v[i];
    string s;cin>>s;
    for(int i=n-1;i>=0;i--){
      for(ll p:now)chmin(v[i],v[i]^p);
      if(v[i]){
        if(s[i]=='0')now.push_back(v[i]);
        else ans=1;
      }
    }
    cout<<ans<<endl;
  }
}


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

using namespace std;

#define pb push_back
#define ll long long

ll a, b, c, n;
ll mn, md, mx;

int main () {

cin >> a >> b >> c;
mn = min(a, min(b, c));
mx = max(a, max(b, c));
md = a + b + c - mx - mn;
cout << abs(mn * md * ((mx + 1) / 2) - (mn * md * (mx - ((mx + 1) / 2))));

return 0;

}


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

using namespace std;

struct State{
  int h, w;

  State(){}
  State(int h, int w) : h(h), w(w) {}
  
  int area(){
    return h*w;
  }
  int perimeter(){
    return 2*(h+w);
  }
};

int main(){
  int N, W, D;

  while(cin >> N >> W >> D, (N | W | D)){
    int p, s;
    vector<State> cakes;
    cakes.push_back(State(W,D));
    for(int i = 0 ; i < N ; i++){
      cin >> p >> s; p--;
      State cake = cakes[p], a, b;
      cakes.erase(cakes.begin()+p);
      int pos = s % (cake.perimeter()/2);

      if(pos < cake.h){
        a = State(pos,cake.w);
        b = State(cake.h-pos,cake.w);
      }else{
        pos -= cake.h;
        a = State(cake.h,pos);
        b = State(cake.h,cake.w-pos);
      }     
      if(a.area() < b.area()){
        cakes.push_back(a);
        cakes.push_back(b);
      }else{
        cakes.push_back(b);
        cakes.push_back(a);
      }
    }
    vector<int> area;
    int len = cakes.size();
    for(int i = 0 ; i < len ; i++){
      area.push_back(cakes[i].area());
    }
    sort(area.begin(), area.end());
    for(int i = 0 ; i < len ; i++){
      if(i != len-1) cout << area[i] << " ";
      else cout << area[i] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int cn = 1;
    while (true){
        if (cn == 1){
            c -= b;
            cn *= -1;
        }
        else {
            a -= d;
            cn *= -1;
        }
        if (a * c <= 0) break;
    }
    if (a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int a, b; cin >> a >> b;
    for(int i = 0; i <= a; i++){
        int d = a-i;
        if(i*2 + d*4 == b){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;



    system("pause");
}

Measured memory_bytes: 3696
#include"bits/stdc++.h"
using namespace std;
int n;
vector<int> d;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		d.push_back(t);
	}
	sort(d.begin(),d.end());
	cout<<d[d.size()-1]-d[0]<<endl;
	return 0;
}

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

int main(){
  string S;cin>>S;
  int ans=1000;
  int l=S.size();
  for(int i=0;i<l-2;i++){
    int X=0;
    int m=100;
    for(int j=i;j<=i+2;j++){
      X+=(S.at(j)-'0')*m;
      m/=10;
    }
    int Y=abs(X-753);
    if(ans>Y) ans=Y;
  }
  cout<<ans<<endl;
}
      


Measured memory_bytes: 3632
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll k,n,m_dis=0;
  cin >> k >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=1;i<n;i++){
    m_dis = max(a[i]-a[i-1],m_dis);
  }
  m_dis = max(m_dis,k-a.back()+a.front());
  cout << k - m_dis<<endl;
}


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

using namespace std;

int N, M;
int a[55][55];
int b[1111][1111];

vector<int> sw[1111];

void print()
{
  for(int i = 0; i < N+M; i++) {
    for(int j = 0; j < N+M; j++) cout << b[i][j] << " ";
    cout << endl;
  }
}

int main()
{
  while(cin >> N, N) {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for(int i = 0; i < 55; i++) sw[i].clear();
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
	cin >> a[i][j];
	b[i][j] = a[i][j];
      }
    }
    M = 0;
    sw[0].push_back(0);
    for(int i = 0; i < a[0][1]-2; i++) {
      sw[M].push_back(N+M+1);
      sw[M+1].push_back(N+M);
      M++;
    }
    sw[M].push_back(1);
    M++;
    for(int i = 0; i < M; i++) {
      b[0][N+i] = b[N+i][0] = i+1;
      b[1][N+i] = b[N+i][1] = a[0][1]-i-1;
      for(int j = 0; j < M; j++) b[N+i][N+j] = b[N+j][N+i] = abs(i-j);
    }
    for(int i = 2; i < N; i++) {
      bool judge = false;
      for(int j = 0; j < M; j++) {
	bool flag = false;
	for(int k = 0; k < i; k++) {
	  if(b[N+j][k] + 1 != b[k][i]) flag = true;
	}
	if(flag) continue;
	sw[j].push_back(i);
	for(int k = 0; k < M; k++) b[i][N+k] = b[N+k][i] = b[N+j][N+k] + 1;
	judge = true;
	break;
      }
      if(!judge) {
	for(int j = 0; j < M; j++) {
	  bool check = false;
	  for(int k = 0; k < i-1; k++) {
	    if(b[i][k] - b[N+j][k] != b[i][k+1] - b[N+j][k+1]) check = true;
	  }
	  if(check) continue;
	  int m = M;
	  sw[j].push_back(N+M);
	  sw[M].push_back(j);
	  for(int k = 0; k < b[i][0]-b[N+j][0]-2; k++) {
	    sw[M].push_back(N+M+1);
	    sw[M+1].push_back(N+M);
	    M++;
	  }
	  sw[M].push_back(i);
	  M++;
	  for(int k = m; k < M; k++) {
	    for(int l = 0; l < i; l++) b[l][N+k] = b[N+k][l] = b[l][N+j] + k-m+1;
	    for(int l = m; l < M; l++) b[N+k][N+l] = b[N+l][N+k] = abs(k-l);
	  }
	  for(int k = m; k < M; k++) {
	    b[N+j][N+k] = b[N+k][N+j] = k-m+1;
	    b[i][N+k] = b[N+k][i] = M-k;
	    for(int l = 0; l < m; l++) b[N+l][N+k] = b[N+k][N+l] = b[N+j][N+l] + b[N+j][N+k];
	  }
	  for(int k = 0; k < m; k++) b[i][N+k] = b[N+k][i] = b[N+j][N+k] + b[N+j][N+M-1] + 1;
	  break;
	}
      }
    }
    vector<int> ans;
    for(int i = 0; i < M; i++) ans.push_back(sw[i].size());
    sort(ans.begin(), ans.end());
    for(int i = 0; i < M; i++) cout << ans[i] << (i==M-1 ? '\n' : ' ');
  }  
  return 0;
}

Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n; cin >> n;
    int ans = -(1e9+1);
    vector<vector<int>> f(n, vector<int>(10, 0));
    vector<vector<int>> p(n, vector<int>(11, 0));

    rep(i, n) rep(j, 10) cin >> f[i][j];
    rep(i, n) rep(j, 11) cin >> p[i][j];

    repr(bit, 1, 1<<10){
        vector<int> cnt(n, 0);
        rep(i, n){
            rep(j, 10) if(f[i][j]==1 && bit&1<<j) ++cnt[i];
        }
        int tmp = 0;
        rep(i, n) tmp += p[i][cnt[i]];
        chmax(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(I, LIM) for (int I = 0; I < (LIM); I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;

constexpr int MOD = 10000007;

vector<long> divisor(long n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

void execute();

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

  execute();

  return (0);
}

void execute() {
  long a,b;
  cin >> a >> b;
  long mini = min(a, b), maxi = max(a, b);

  if (mini <= 0 && 0 <= maxi) {
    cout << "Zero" << endl;
    return;
  }

  if(0 <= mini){
    cout << "Positive" << endl;
    return;
  }

  if(abs((mini-maxi-1)) % 2 == 1){
    cout << "Negative" << endl;
    return;
  }else{
    cout << "Positive" << endl;
    return;
  }
}


Measured memory_bytes: 3136
import copy as cp

K = int(input())

ans = ["1","2","3","4","5","6","7","8","9"]
old = cp.copy(ans)
num = len(ans)
while True:
    new = []
    for elem in old:
        if elem[-1] != "0":
            new.append(elem + str(int(elem[-1])-1))
        new.append(elem + elem[-1])
        if elem[-1] != "9":
            new.append(elem + str(int(elem[-1])+1))
    ans += new
    old = cp.copy(new)
    num = len(ans)
    if num >= 100000:
        break
print(ans[K-1])

Measured memory_bytes: 20676
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10;

void recurse(string& s, int i, int n, char c);

int main() {
	fast_cin();
	int n; cin >> n;
	string s(n, 'a');
	recurse(s, 0, n, 'a');
}

void recurse(string& s, int i, int n, char c) {
	if (i == n) {
		cout << s << '\n';
	} else {
		for (char letter = 'a'; letter < c; ++letter) {
			s[i] = letter;
			recurse(s, i + 1, n, c);
		}
		s[i] = c;
		recurse(s, i + 1, n, min(char(c + 1), 'z'));
	}
}

Measured memory_bytes: 1536
#include <cstdio>
using namespace std;

int main(){
    int h,w;
    while(1){
        scanf("%d %d", &h , &w);
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 1; i <= h; i++){
            if(i % 2 == 1){
                for(int j = 1; j <= w; j++){
                    if( j % 2 == 1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
                printf("\n");
            }else{
                for(int j = 1; j <= w; j++){
                    if( j % 2 == 1){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }
}



Measured memory_bytes: 2684
#include <stdio.h>
  
int main(){
  
int a,b;
  
scanf("%d",&a);
scanf("%d",&b);

if(a<b){
  printf("a < b\n");
}

else if(a==b){
          printf("a == b\n");
}
        else{
          printf("a > b\n");

}
     
}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int l, r, d;
	cin >> l >> r >> d;
	int ans{};
	for (int i = l; i <= r; i++) ans += !(!!(i%d));
	cout << ans;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
	int n,a,b,c,d,m;
	while(cin>>n){
		m=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(n==a+b+c+d){
							m+=1;
						}
					}
				}
			}
		}
		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#define int long long
using namespace std;

int n;
int a[10];

signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		string b;cin>>b;
		char ch=b[0];
		if(ch=='M') a[1]++;
		if(ch=='A') a[2]++;
		if(ch=='R') a[3]++;
		if(ch=='H') a[4]++;
		if(ch=='C') a[5]++;
	}
	int ans=0;
	if(a[1]&&a[2]&&a[3]) ans+=a[1]*a[2]*a[3];
	if(a[1]&&a[2]&&a[4]) ans+=a[1]*a[2]*a[4];
	if(a[1]&&a[2]&&a[5]) ans+=a[1]*a[2]*a[5];
	if(a[1]&&a[3]&&a[4]) ans+=a[1]*a[3]*a[4];
	if(a[1]&&a[3]&&a[5]) ans+=a[1]*a[3]*a[5];
	if(a[1]&&a[4]&&a[5]) ans+=a[1]*a[4]*a[5];
	if(a[2]&&a[3]&&a[4]) ans+=a[2]*a[3]*a[4];
	if(a[2]&&a[3]&&a[5]) ans+=a[2]*a[3]*a[5];
	if(a[2]&&a[4]&&a[5]) ans+=a[2]*a[4]*a[5];
	if(a[3]&&a[4]&&a[5]) ans+=a[3]*a[4]*a[5];
	printf("%lld",ans);
	return 0;
}

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

int main(){
  ll n; cin >>n;
  ll ans = 0;
  for(int i = 1; i<=n; i++){
    for(int j = i; j<=n; j+=i) ans += j;
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll bit[2005];

void add(ll x) {
  while(x<2005) {
    bit[x]++;
    x += x&-x;
  }
}

ll sum(ll x) {
  ll ans = 0;
  while(x>0) {
    ans += bit[x];
    x -= x&-x;
  }
  return ans;
}

int main() {
  ll N, K;
  cin>>N>>K;
  ll A[N];
  vector<ll> arr;
  map<ll, ll> amap;
  for(ll i=0;i<N;++i) {
    cin>>A[i];
    if(amap[A[i]]==0) arr.push_back(A[i]);
    amap[A[i]]++;
  }
  ll ans = 0;
  for(ll i=0;i<N;++i) {
    ans += i-sum(A[i]);
    ans %= mod;
    add(A[i]);
  }
  ans *= K;
  ans %= mod;
  sort(arr.begin(), arr.end());
  ll tmp = N-amap[arr[0]];
  for(ll i=0;i<arr.size()-1;++i) {
    ans += (K-1)*K/2%mod*tmp%mod*amap[arr[i]]%mod;
    ans %= mod;
    tmp -= amap[arr[i+1]];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  rep1(i,n){
    if((i+1)*(i+1)>n){
      cout << i*i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(q)]
combs = list(itertools.combinations_with_replacement(list(range(1, m + 1)), n))
ans = 0
for i, comb in enumerate(combs):
    tmp = 0
    for a, b, c, d in arr:
        if comb[b - 1] - comb[a - 1] == c:
            tmp += d
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 21504
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut v = vec![];
    for _ in 0..n {
        input! {
            a: u32,
            b: usize,
        }
        v.push((a, b));
    }
    v.sort();
    let mut current_idx = 0;
    for i in 0..v.len() {
        current_idx += v[i].1;
        if current_idx >= k {
            println!("{}", v[i].0);
            return;
        }
    }
}


Measured memory_bytes: 5508
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <array>

template<class T>
class UnionFindTree{
public:
    UnionFindTree(const T N){
        const T zero = static_cast<T>(0);
        const T one = static_cast<T>(1);

        tree = std::vector<T>(N);
        std::iota(tree.begin(),tree.end(),zero);

        sizes = std::vector<T>(N,one);

        nGroup = N;
    }

    T root(const T idx){
        T tmp = idx;
        std::stack<T> stack;
        while(tree[tmp] != tmp){
            stack.push(tmp);
            tmp = tree[tmp];
        }
        while(!stack.empty()){
            tree[stack.top()] = tmp;
            stack.pop();
        }
        return tmp;
    }

    void merge(const T idx1, const T idx2){
        if(!same(idx1, idx2)){
            sizes[root(idx2)] = size(idx1) + size(idx2);
            tree[root(idx1)] = root(idx2);
            --nGroup;
        }
    }

    bool same(const T idx1, const T idx2){
        return root(idx1) == root(idx2);
    }

    T size(const T idx){
        return sizes[root(idx)];
    }

    T groups(){
        return nGroup;
    }

private:
    std::vector<T> tree; //parents of each nodes
    std::vector<T> sizes; //size of the group which includes the node
    T nGroup;
};

int main(int argc, char *argv[]){
    int N, M;
    std::cin >> N >> M;
    std::array<int,(1<<17)> A, B;
    for(int i=0; i<M; ++i){
        std::cin >> A[M-1-i] >> B[M-1-i];
        --A[M-1-i]; --B[M-1-i];
    }

    UnionFindTree<int> tree(N);
    std::stack<long long> stack;
    long long inconvenience = (static_cast<long long>(N)*(static_cast<long long>(N)-1LL))/2LL;
    long long size;
    for(int i=0; i<M; ++i){
        stack.emplace(inconvenience);
        if(!tree.same(A[i],B[i])){
            size = tree.size(A[i]);
            inconvenience += (size*(size-1LL))/2LL;
            size = tree.size(B[i]);
            inconvenience += (size*(size-1LL))/2LL;
            tree.merge(A[i],B[i]);
            size = tree.size(A[i]);
            inconvenience -= (size*(size-1LL))/2LL;
        }
    }
    while(!stack.empty()){
        std::cout << stack.top() << std::endl;
        stack.pop();
    }
    return 0;
}


Measured memory_bytes: 3484
#include <bits/stdc++.h>
using ll = long long;
constexpr int DEBUG = 0;
using namespace std;

int bitCount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    vector<int> x(n, -1);
    for (int j = 0; j < ai; j++) {
      int xj, yj;
      cin >> xj >> yj;
      x[xj - 1] = yj;
    }
    a.push_back(x);
  }
  if(DEBUG >= 1) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cout << a[i][j] << " ";
      }
      cout << endl;
    }
  }
  
  int max = 0;
  for (unsigned int check = 0b0000000000000000; check < (1 << n); check++) {
    if (DEBUG >= 1)
      cout << "check" << check << endl;
    bool isOK = true;
    for (int i = 0; i < n && isOK; i++) {
      bool is1 = (check & (1 << i)) != 0;
      if (DEBUG >= 1) {
        cout << i << ":";
        for (int k = 0; k < n; k++)
          cout << a[i][k] << " ";
        cout << endl;
      }
      for (int j = 0; j < n; j++) {
        if (is1 && (((a[i][j] == 0) && ((check & (1 << j)) != 0)) || ((a[i][j] == 1) && ((check & (1 << j)) == 0)))) {
            isOK = false;
          if (DEBUG >= 1)
         	 cout << "  NG";
          break;
        }
        if (DEBUG >= 1)
          cout << "  OK";
      }
      if (DEBUG >= 1)
        cout << endl;
    }
    if (isOK) {
      int num = bitCount(check);
      if (num > max)
        max = num;
    }
  }
            
  cout << max << endl;  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        var set = new HashSet<int>();
        for (int i = 0; i < n; i++)
        {
            int a = sc.NextInt();
            if (!set.Add(a))
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine("YES");
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    static long Lcm(long a, long b)
    {
        long d = Gcd(a, b);
        return a / d * b;
    }

    static long RepeatedSquare(long n, long p, long m)
    {
        if (p == 0) return 1;
        if (p % 2 != 0) return n * RepeatedSquare(n, p - 1, m);
        long t = RepeatedSquare(n, p / 2, m);
        return (t * t) % m;
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 33116
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
#define why(n, x)                                                              \
  int n;                                                                       \
  while (cin >> n, n != x)
#define iFOR(i, x, n) for (int i = x; i < n; i++)
#define fin << '\n'
#define __ << " " <<
#define ___ << " "
#define bash push_back
#define ALL(x) x.begin(), x.end()
#define SWAP(a, b) ((a != b) && (a += b, b = a - b, a -= b))
//#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vit;
typedef map<string, int> mstit;
typedef vector<pii> vpi;
typedef greater<pii> gpi;
typedef priority_queue<pii, vpi, gpi> dijk;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
static const signed int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

bool inside(int x, int y, int w, int h) {
  return (x >= 0 && y >= 0 && x < w && y < h);
}
template <class T> T abs(T &x) { return x < 0 ? -x : x; }
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 (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int qp(int a, ll b, int mo) {
  int ans = 1;
  do {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

inline void solve() {

  int n;
  int sum = 0;
  cin >> n;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    sum += __builtin_ctz(a);
  }

  cout << sum << endl;
}
struct xyz {
  xyz() {
    cin.tie(0), ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
  };
} xyzzy;
signed main() {
  solve();
  return 0;
}


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

int main(){

char s[4];cin>>s[0]>>s[1]>>s[2]>>s[3];
sort(s,s+4);
int check=0;
if(s[0]==s[1] and s[2]==s[3] and s[1]!=s[2])
	check=1;
if(check)
	cout<<"Yes";
else cout<<"No";




	
return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int n;
    cin >> n;
    int ans = n;
    for(int i = 0 ; i <= n ; i++){
        int cnt = 0, tmp = i;
        while(tmp > 0){
            cnt += tmp % 6;
            tmp /= 6;
        }
        tmp = n - i;
        while(tmp > 0){
            cnt += tmp % 9;
            tmp /= 9;
        }
        if(ans > cnt){
            ans = cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

    int N;
    cin >> N;
    int ans = 0;
    if (N <= 9){
        ans = N;
    }
    else if (N <= 99) {
        ans = 9;
    }
    else if (N <= 999) {
        ans = N - 90;
    }
    else if (N <= 9999) { 
        ans = 909;
    }
    else if (N <= 99999) {
        ans = N - 9090;
    }
    else { 
        ans = 90909;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a,b,c,k = map(int,input().split())
count = k

if (a > k):
    a = k
    b = 0
    c = 0
elif (a + b > k):
    c = 0
    b = k - a 
elif a + b + c > k:
    c = k - (a + b)

print(a*1 + b*0 + c*(-1)) 

Measured memory_bytes: 9152
import math
import heapq

N,M = map(int,input().split())
A = [0]*N
A = list(map(lambda x: int(x)*(-1),input().split()))
if (N == 1):
    print((-1 * A[0])//(2**M))
else:
    """
    while (M != 0):
        A.sort(reverse=True)
        y = min(math.floor(log2(A[0]/A[1])+1),M)
        A[0] //= 2**y
        M -= y
    """
    """
    A.sort(reverse=True)
    for i in range(N):
        y = min(A[i] // 2,M)
        A[i] //= 2**y
        M -= y
        if (M <= 0):
            break
    """
    heapq.heapify(A)

    for i in range(M):
        m = heapq.heappop(A) * -1
        heapq.heappush(A,(m//2 * -1))

    print(-sum(A))


Measured memory_bytes: 72984
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#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 _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int k;cin>>k;
    string s;cin>>s;
    if(s.size()>k){
        _for(i,0,k)cout<<s[i];
        cout<<"...";
    }else cout<<s;
	return 0;
}

Measured memory_bytes: 3656
def main():
    N, C = map(int, input().split())
    stc = [[0] * (10 ** 5) for _ in range(C)]
    for _ in range(N):
        s, t, c = map(int, input().split())
        stc[c - 1][s - 1:t] = [1] * (t - s + 1)
    print(max(map(sum, zip(*stc))))


main()


Measured memory_bytes: 26484
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

LL n,x,W,v,w;
LL dp[105][100005] = {0};

int main(){
	memset(dp,0x3f,sizeof(dp));
	dp[0][0] = 0;
	scanf("%lld %lld",&n,&W);
	x = n * 1000;
	for(LL i = 1;i <= n;i ++){
		scanf("%lld %lld",&w,&v);
		for(LL j = 0;j <= x;j ++){
			dp[i][j] = dp[i - 1][j];
			if(j >= v) dp[i][j] = min(dp[i][j],dp[i - 1][j - v] + w);
		}
	}
	for(LL i = x;i >= 0;i --){
		if(dp[n][i] <= W){
			printf("%lld\n",i);
			break;
		}
	}
	return 0;
}
//

Measured memory_bytes: 82304
n = int(input())
a = list(map(int,input().split()))
count = 0
ans = 10000
for i in range(n):
    while True:
        if a[i]%2 == 0:
            count += 1
            a[i] = a[i]//2
        else:
            ans = min(ans,count)
            count = 0
            break
print(ans)

Measured memory_bytes: 3060
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


n,m=map(int, input().split())

s=primes(10**5)
t=[]

for i in range(len(s)):
    if m%s[i]==0:
        t.append(1)
        m//=s[i]
    while True:
        if m % s[i] == 0:
            t[-1]+=1
            m //= s[i]
        else:
            break
if m!=1:
    t.append(1)

ans=1
for i in range(len(t)):
    for j in range(t[i]):
        ans*=j+n
    for j in range(t[i]):
        ans//=j+1
    ans%=(10**9+7)

print(int(ans))


Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<int> a;
vector<vector<int>> edge;
vector<int> dp;
vector<int> res;

void dfs(int i = 0, int p = -1) {
    int l = LB(dp, a[i]);
    int tmp = dp[l];
    dp[l] = a[i];
    res[i] = LB(dp, INT_MAX);
    for (auto &j : edge[i]) {
        if (j == p) continue;
        dfs(j, i);
    }
    dp[l] = tmp;
}

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

    int N;
    cin >> N;
    a.resize(N);
    REP(i, N) cin >> a[i];
    edge.resize(N);
    REP(i, N - 1) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dp.resize(N, INT_MAX);
    res.resize(N);
    dfs();
    REP(i, N) cout << res[i] << endl;

    return 0;
}

Measured memory_bytes: 27972
#include<bits/stdc++.h>
using namespace std;
long long mypow(long a,long long b,long long mod) {
  long long c;
  if (b==0) return 1;
  else {
    c=mypow(a,b/2,mod)*mypow(a,b/2,mod)%mod;
    if (b%2==1) c=c*a%mod;
    return c;
  }
}
long long mycomb(long n,long r,long long mod) {
  long i;
  long long c;
  c=1;
  for(i=n;i>n-r;i--) c=c*i%mod;
  for(i=1;i<=r;i++) c=c*mypow(i,mod-2,mod)%mod;
  return c;
}
int main() {
  long n,a,b,i;
  long long mod,nca,ncb,k;
  cin>>n>>a>>b;
  mod=1000000007;
  nca=mycomb(n,a,mod);
  ncb=mycomb(n,b,mod);
  k=mypow(2,n,mod);
  k=k-1-nca-ncb;
  k%=mod;
  if (k<0) k+=mod;
  cout<<k<<endl;
}

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

typedef long long ll;

int n, m;
int x[100010];
int d[100010];

int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> x[i];
    }

    sort(x, x+m);

    for (int i = 0; i < m-1; i++){
        d[i] = x[i+1] - x[i];
    }

    sort(d, d+m-1);

    
    int sum = 0;
    for (int i = 0; i < m-n; i++){
        sum += d[i];
    }

    cout << sum << endl;

}

Measured memory_bytes: 1024
while True:
	n = input()
	if n == 0 : break

	calorieSet = []
	for _ in xrange(n):
		num,protein,lipid,carbohydrate = map(int,raw_input().split())
		sumCalorie = protein * 4 + carbohydrate * 4 + lipid * 9
		calorieSet.append((num, protein, lipid, carbohydrate, sumCalorie))
	
	limmit = map(int,raw_input().split())
	good = []
	for var in calorieSet:
		judge = True
		for cal,lim in zip(var[1:], limmit):
			if cal > lim:
				judge = False
				break
		if judge:
			good.append(var[0])
			
	if good == []:
		print "NA"
	else:
		for var in good:
			print var

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

using namespace std;
using ll = long long int;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    for(ll i=0; i<=n; i++) {
        bool ok = true;
        for(ll j=0; j<n && i+j<n; j++)
            ok &= s[i+j] == t[j];
        if(ok) {
            cout << i+n << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256