akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

int main(){
  int N, count= 0;
  cin >> N;

  int j = 0;

  vector<int> vec(N);

  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  for(int i = 0; i < N;){
    if(vec.at(i) == 0) {
      i++;
      continue;
    }

    for(j = i; j < N; ){
      if(vec.at(j) == 0){
        break;
      }
      j++;
      continue;
    }

    for(int k = i; k < j; k++){
      vec.at(k)--;
    }
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
ll ans = 0, k = 100, x;
int main()
{
	cin >> x;
	if (x < ans)
	{
		cout << 0;
		return 0;
	}
	while (k < x-k/100)
	{
		k = k + (k / 100);
		ans++;
	}
	cout << ans+1;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
using namespace std;
 
char a[100][101];
int H,W,res;
int  dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
 
void dfs(int x,int y,char ch){
    a[y][x]='.';
    for(int i=0;i<4;i++){
        int nx=x+dx[i],ny=y+dy[i];
        if(0<=nx&&nx<W&&0<=ny&&ny<H&&a[ny][nx]==ch)dfs(nx,ny,ch);
    }
}
 
int  solve(){
    res=0;
    for(int i=0;i<H;i++){
        scanf("%s",a[i]);
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j]=='@'||a[i][j]=='#'||a[i][j]=='*'){
                dfs(j,i,a[i][j]);
                res++;
            }
        }
    }
    return res;
}
 
int main() {
    while(1){
            cin>>H>>W;
        if(!H&&!W)break;
        cout<<solve()<<endl;
    }
        return 0;
}

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

struct range {
	int left;
	int right;
};

bool cmpr(const range& a, const range& b) {
	return a.right < b.right;
}

int main() {
	int n;
	cin >> n;
	vector<int> x(n), l(n);
	for (int i = 0; i < n; i++)
		cin >> x[i] >> l[i];
	vector<range> r(n);
	for (int i = 0; i < n; i++) {
		r[i].left = x[i] - l[i];
		r[i].right = x[i] + l[i];
	}
	sort(r.begin(), r.end(), cmpr);
	int ri = r[0].right;
	int count = 0;
	for (int i = 1; i < n; i++) {
		if (ri <= r[i].left) {
			count++;
			ri = r[i].right;
		}
	}
	cout << count + 1 << endl;
	return 0;
}


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n;
  	ci(n);
  ll sum=0;
  ll ans=0;
  oFOR(i,1,n+1){
    FOR(j,1,i+1){
    if(i%j==0) sum+=1;
    }
    if(sum==8) ans+=1;
    sum=0;
  }
  co(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

enum { START, END, QUERY };

int N,Q;
vector<tuple<int,int,int>> E;

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

	cin>>N>>Q;
	rep(i,0,N) {
		int s,t,x;
		cin>>s>>t>>x;
		E.emplace_back(s-x,START,x);
		E.emplace_back(t-x,END,x);
	}
	
	rep(i,0,Q) {
		int d;
		cin>>d;
		E.emplace_back(d,QUERY,i);
	}
	
	sort(E.begin(),E.end());
	
	multiset<int> cur;
	vector<int> res(Q,-1);
	for (auto e:E) {
		int time,type,x;
		tie(time,type,x)=e;
		switch (type) {
			case START:
				cur.insert(x);
				break;
			case END:
				cur.erase(cur.find(x));
				break;
			case QUERY:
				if (!cur.empty()) res[x]=*cur.begin();
				break;
			default:
				assert(false);
		}
	}
	
	rep(i,0,Q) cout<<res[i]<<"\n";
}


Measured memory_bytes: 19176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

ll w[100],v[100],ar[100][100000],sum;

int main()
{
	string a,b;
	cin>>a>>b;
	ll n=a.length(),m=b.length(),i,j,dp[m+1][n+1];
	for(i=0;i<=m;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(b[i-1] == a[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string s="";
	i=m,j=n;
	while(i>0 && j>0)
	{
		if(b[i-1] == a[j-1])
		{
			s=a[j-1]+s;
			i--,j--;
		}
		else if(dp[i][j-1] > dp[i-1][j])
			j--;
		else
			i--;
	}
	cout<<s;
} 

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=2e5+100,inf=1e18,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int n, a[maxn], cnt, mx1, mx2, pos2, pos1, m1, m2, ps1, ps2;
int was[maxn][3];

main()
{
  IOS
	cin >> n;
	forn(1, i, n)
	{
		cin >> a[i];
		was[a[i]][i % 2]++;
	}
	mx1 = 0;
	pos1 = 0;
	pos2 = 0;
	mx2 = 0;
	forn(1, i, 1e5)
	{
		if(mx1 < was[i][0])
		{
			mx2 = mx1;
			pos2 = pos1;
			mx1 = was[i][0];
			pos1 = i;
		}
		else
		if(mx2 < was[i][0])
		{
			mx2 = was[i][0];
			pos2 = i;
		}
	}
	m1 = 0;
	ps1 = 0;
	ps2 = 0;
	m2 = 0;
	forn(1, i, 1e5)
	{
		if(m1 < was[i][1])
		{
			m2 = m1;
			ps2 = ps1;
			m1 = was[i][1];
			ps1 = i;
		}
		else
		if(m2 < was[i][1])
		{
			m2 = was[i][1];
			ps2 = i;
		}
	}
	if(ps1 == pos1)
	{
		cout << n - max(mx1 + m2, mx2 + m1);
		return 0;
	}
	cout << n - (mx1 + m1);
}

Measured memory_bytes: 6400
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,i,j;
	cin>>n;
	ll a[n+3],cnt[n+3]={0};
	for(i=1;i<=n;i++)
		cin>>a[i];
	ll ans=0;
	for(i=1;i<=n;i++){
		if(i-a[i]>0)
			ans+=cnt[i-a[i]];
		if(i+a[i]<=n)
			cnt[i+a[i]]++;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;

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(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    bool ok = true;
    for (int i = 0; i < N; i++) {
        int x = A[i];
        if (x % 2 == 0 ) {
            if (x % 5 != 0 && x % 3 != 0) {
                ok = false;
                break;
            }
        }
    }

    if (ok) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 2e5 + 10;
const ll INF = 1e18;

ll dp[MAXN][2], n, v ,u;
vl g[MAXN];
void DFS(ll v, ll p = -1){
	for (auto u:g[v]){
		if (u == p) continue;
		DFS(u, v);
		dp[v][0] *= dp[u][1];
		dp[v][1] *= (dp[u][0] + dp[u][1]);
		dp[v][0] %= MOD;
		dp[v][1] %= MOD;
	}
	
}


int main(){
	IOS;
	cin >> n;
	for (int i = 1; i <= n; i++) dp[i][0] = 1, dp[i][1] = 1;
	if (n == 1) kill(2);
	for (int i = 0; i < n - 1; i++){
		cin >> v >> u;
		g[v].pb(u), g[u].pb(v);
	}
	ll ans = 1;
	DFS(1);
	cout << (dp[1][0] + dp[1][1]) % MOD;
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S.at(i);
    map<string, int> mp;
    rep(i,N) mp[S.at(i)] = 1;
    cout << mp.size() << endl;
}

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

constexpr int mod = 998244353;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    ll d = n / (a + b);
    ll r = n % (a + b);
    cout << a * d + min(r, a) << endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    long long x[n] = {};
    long long y[n] = {};
    long long z[n] = {};
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    
    vector<long long> sum(n);
    long long ans = 0;
    for(int b=0; b<8; b++){
        for(int i=0; i<n; i++){
            sum[i] = x[i] + y[i] + z[i];
            if(b & 1)  sum[i] -= x[i]*2;
            if(b & 2)  sum[i] -= y[i]*2;
            if(b & 4)  sum[i] -= z[i]*2;
        }
        sort(sum.rbegin(), sum.rend());
        long long t = 0;
        for(int i=0; i<m; i++) t += sum[i];
        ans = max(ans, t);
    }
  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

bool cmp(P a, P b) {
    return a.fi+a.se < b.fi+b.se;
}

signed main() {
    int n;
    cin >> n;
    V(P) rb(n);
    rep(i, n) {
        int x, l;
        cin >> x >> l;
        rb[i] = P(x, l);
    }
    sort(ALL(rb), cmp);

    int prev = -1e9, res = 0;
    rep(i, n) {
        int l = rb[i].fi-rb[i].se;
        int r = rb[i].fi+rb[i].se;
        if(l >= prev) {
            res++;
            prev = r;
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int cnt = 0;

    while (1) {

        rep(i, n) {
            if (a[i] % 2 == 1) {
                cout << cnt << endl;
                return 0;
            }
            a[i] /= 2;
        }
        cnt++;
    }

    return 0;
}



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

using namespace std;

using LL = long long;
using PII = pair<int, int>;
using ll = long long;
using DBL = double;
using VI = vector<int>;
using VD = vector<DBL>;
using VVI = vector<VI>;
using VVD = vector<VD>;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define ST first
#define ND second

//#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
//template<typename Arg> void __f(const char* name, Arg&& arg) {
//  cerr << name << " = " << arg << 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...); }
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; // OST: find_by_order, order_of_key
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#pragma GCC optimize("Ofast")
//optimize("unroll-loops")
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
///*** RNGS ***/
//SEED=chrono::steady_clock::now().time_since_epoch().count();
//// or high_resolution_clock
//mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
//uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
//struct chash {int operator()(int x) const {return x^SEED;}};
//gp_hash_table<int,int,chash>m;//use cc if very less updates
///*** FAST IO ***/
//inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
//while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();}
//while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
//return y?-x:x; }

const int MAXN = 512;
int a[MAXN];
long long dp[MAXN][MAXN], psum[MAXN];

long long calc(int l, int r) {
    auto &y = dp[l][r];
    if(y != -1) return y;
    if(l == r) return y = 0;
    y = 1e16;
    for(int i=l; i<r; ++i) {
        y = min(y, psum[r] - psum[l-1] + calc(l, i) + calc(i+1, r));
    }
    return y;
}

int main() {
    #ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
//    freopen("sample.out", "w", stdout);
    #else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #endif
    int n;
    cin >> n;
    for(int i=1; i<=n; ++i) {
        cin >> a[i];
        psum[i] = a[i] + psum[i-1];
    }
    memset(dp, -1, sizeof(dp));
    cout << calc(1, n) << endl;
	return 0;
}


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

int main() {
  int x;
  cin>>x;
  for(int i=1;;i++){
    if((i-1)*i/2<x and (i+1)*i/2>=x) {
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


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

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

  int x;
  cin >> x;
  int res = 1;
  for (int i = 2; i < floor(sqrt(x)) + 1; i++) {
    int lo = 0; 
    int hi = 11;
    while (lo + 1 < hi) {
      int m = (lo + hi) / 2;
      (pow(i, m) <= x) ? lo = m : hi = m;
    }
    res = max(res, (int)pow(i, lo));
  }  
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//桁数
/*LLI GetDigit(LLI num) {
	LLI digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, B, K;
	cin >> A >> B >> K;
	if (A <= K) {
		K -= A;
		A = 0;
	}
	else {
		A -= K;
		K = 0;
	}
	if (B <= K) {
		B = 0;
	}
	else {
		B -= K;
	}
	cout << A << endl << B << endl;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, s.size()){
        if(s[i] != t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3912
def resolve():
	n = int(input())
	cnt = 0
	for i in range(1, n+1):
		div_cnt = 0
		for j in range(1, i+1):
			if i % 2 == 0:
				continue
			if i % j == 0:
				div_cnt += 1
		if div_cnt >= 8:
			cnt += 1
	print(cnt)
resolve()

Measured memory_bytes: 38640
#!/usr/bin/env python3
import sys


def solve(X: int, A: int, B: int):
    if B - A <= 0:
        return "delicious"
    elif B - A <= X:
        return "safe"
    else:
        return "dangerous"


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(X, A, B))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <string>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    long long a[n], b[n];
    long long c[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        c[i] = a[i] * 1000000 + b[i];
    }   
    sort(c, c + n); 
    for (int i = 0; i < n; i++) {
        a[i] = c[i] / 1000000;
        b[i] = c[i] - a[i] * 1000000;
    }   
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (m - b[i] < 0) {
            ans += a[i] * m;
            break;
        }
        ans += a[i] * b[i];
        m -= b[i];
    }   
    cout << ans;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <climits>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
  char c = getchar();x = 0;
  int neg = 0;
  for(; ((c<48 || c>57) && c != '-'); c = getchar());
  if(c=='-'){neg = 1;c = getchar();}
  for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
  if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
  long long ret = 1;
  for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 16;
int n;
LL A[N][N];
LL dp[1<<N];
LL v[1<<N];

int main()
{
  in(n);
  for(int i=0;i<n;i++){
    for(int j = 0; j < n; j ++) {
      in(A[i][j]);
    }
  }
  for(int i = 0; i < 1 << n; i ++) {
    for(int j = 0; j < n; j ++){
      for(int k = j + 1; k < n; k ++) {
        if((i&(1<<j)) && (i&(1<<k))) v[i] += A[j][k];
      }
    }
  }


  for(int i = 0; i < 1 << n; i ++) {
    for(int j = i; j > 0; j = i&(j-1)) {
      dp[i] = max(dp[i], v[j] + dp[i ^ j]);
    }
  }
 cout << dp[(1<<n) - 1] << endl;

}


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

// B - Postdocs
int main() {
    string T;
    cin >> T;

    int size = T.size();
    for (int i = 0; i < size; i++) {
        if (T[i] == '?') {
            if (i > 0) {
                if (T[i - 1] == 'P') {
                    T[i] = 'D';
                    continue;
                }
            }
            if (i < size && 
                (T[i + 1] == 'D' || T[i + 1] == '?')) {
                T[i] = 'P';
            } else {
                T[i] = 'D';
            }
        }
    }
    cout << T;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  x -= 400;
  x /= 200;
  cout << 8-x << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef pair<int, int> Pi;

struct BIT {
  
  vector<int> sum;
  
  BIT (int sz)
  {
    sum.assign(++sz, 0);
  }
  
  int query(int k)
  {
    int ret = 0;
    for (; k > 0; k -= k & -k) ret += sum[k];
    return ret;
  }

  void add(int k, int x)
  {
    for (; k < sum.size(); k += k & -k) sum[k] += x;
  }
  
};

int main()
{
  int N, M;
  int A[300005], B[300005];
  Pi pmt[300005];
  
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i]; B[i]++;
    pmt[i] = Pi(B[i] - A[i], i);
  }
  sort (pmt, pmt + N);
  
  int now = 0;
  BIT tree(M);
  for (int i = 1; i <= M; i++) {
    while (pmt[now].fi <= i && now < N) {
      int sec = pmt[now].se;
      int a = A[sec], b = B[sec];
      tree.add(a, 1); tree.add(b, -1);
      now++;
    }
    int ans = 0;
    for (int j = i; j <= M; j += i) ans += tree.query(j);
    cout << (N - now) + ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6016
import numpy as np
import math

n = int(input())
a=list(map(int, input().split()))
out=[0]*len(a)

temp = 0
for i in range(n):
    temp += ((-1)**i) * a[i]

out[0]=int(temp)

for i in range(1,n):
    out[i] = int(2*a[i-1] - out[i-1])

print((" ").join([str(int(o)) for o in out]))


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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

const int N = 15;
int c[N];
bool ans;

void dfs(int a, int b) {
	if(!a && !b) {
		ans = 1;
		return;
	}
	int i = find_if(c, c + N, [](int i) { return i > 0; }) - c;
	if(a) {
		if(c[i] >= 3) {
			c[i] -= 3;
			dfs(a - 1, b);
			c[i] += 3;
		}
		if(c[i] && c[i + 1] && c[i + 2]) {
			c[i] --; c[i + 1] --; c[i + 2] --;
			dfs(a - 1, b);
			c[i] ++; c[i + 1] ++; c[i + 2] ++;
		}
	}
	if(b && c[i] >= 2) {
		c[i] -= 2;
		dfs(a, b - 1);
		c[i] += 2;
	}
}

int main() {
	ios :: sync_with_stdio(0);

	for(string s; cin >> s; ) {
		memset(c, 0, sizeof c);
		for(char i : s)
			c[i - '0'] ++;
		vector <int> v;
		for(int i = 1; i <= 9; i ++) if(c[i] < 4) {
			c[i] ++;
			ans = 0;
			dfs(4, 1);
			if(ans)
				v.pb(i);
			c[i] --;
		}
		if(v.size() == 0)
			cout << "0\n";
		else {
			for(int i = 0; i < v.size(); i ++)
				cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
		}
	}

	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
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;
}

/* define const */
const long long INF = (1LL << 60);
/* end defineing */

int main()
{
    string S;
    cin >> S;
    int count_a = 0;
    int count_b = 0;

    for (int i = 0; i < S.length(); i++)
    {
        if (i % 2 == 0)
        {
            if (S[i] != '0')
            {
                count_a++;
            }
        }
        else
        {
            if (S[i] != '1')
            {
                count_a++;
            }
        }
    }
    for (int i = 0; i < S.length(); i++)
    {
        if (i % 2 == 1)
        {
            if (S[i] != '0')
            {
                count_b++;
            }
        }
        else
        {
            if (S[i] != '1')
            {
                count_b++;
            }
        }
    }

    if (count_a < count_b)
    {
        cout << count_a << endl;
    }
    else
    {
        cout << count_b << endl;
    }
}


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

int main() {
	int A; int B;
	cin >> A >> B;
	if (A >= 13) {
		cout << B << endl;
	} else if (A >= 6 && A <= 12) {
		cout << B / 2 << endl;
	} else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;    
  
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define mp make_pair
#define all(x) x.begin(), x.end()
#define ll long long
#define ull unsigned long long
#define sz(x) (int)x.size()
/*
string lower(string a) {
    for(int i=0;i<a.size();i++) {
        a[i]=tolower(a[i]);
    }
    return a;
}
ll nod(ll a,ll b) {
    if(a==0)
        return b;
    else if(b==0)
        return a;
    if(a>=b)
        return nod(a%b,b);
    else if(a<=b)
        return nod(a,b%a);
}
ll nok(ll x, ll y) {
    return x/nod(x,y)*y;
} 
*/
const ll INF = 1e9+7;
int main() {
//  freopen("measurement.in", "r", stdin);
//  freopen("measurement.out", "w", stdout);
    IOS	
    ll mx = -INF;
    map<string, ll> mp;
	ll n;
	cin >> n;
    while(n--) {
    	string s;
    	cin >> s;
    	mp[s]++;
    	if(mp[s] > mx) {
    		mx = mp[s];
    		string ch = s;
		}
	}
	for(map<string, ll>:: iterator it = mp.begin(); it != mp.end(); it++) {
		if(it -> second == mx) {
			cout << it -> first << endl;
		}
	}
	return 0;
} 	 

Measured memory_bytes: 23808
using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    public static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var vals = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
        vals.Sort();
        vals.Reverse();
        var min = (double)vals.Sum() / (4.0 * nm[1]);
        if (vals.Take(nm[1]).Count(x => x < min) > 0)
            Console.Write("No");
        else
            Console.Write("Yes");
    }
}

Measured memory_bytes: 19088
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
using pp = pair<p,p>;
using ll = long long;
const auto INF =(ll)1e5;
int main(){
  string s;
  cin >>s;
  auto ss = set<char>();
  for(auto i:s){
  	ss.insert(i);
  }
 	
  int j=0;
  bool f=true;
  for (auto i:ss)
  {
    if(i!='a'+j){
      f=false;
      char u='a'+j;
      cout << u;
      break;
    }
    j++;
  }
  
  if(f&&j=='z'-'a'+1){
  	cout << "None";
  }else if(f&&j<'z'-'a'+1){
  	cout << (char)('a'+j);
  }
  return 0;
}

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

string a, b, c;

int main(void){
    cin >> a >> b;
    c = a + b;
    int v = stoi(c);
    for(int i = 1; i <= 1000; i++){
        if(i*i == v){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

func Comb(F, Finv *[]int, A ...int) int {
  S := SumInt(A...)
  C := (*F)[S]
  for _, a := range A {
    C *= (*Finv)[a]
    C %= p
  }
  return C
}

const p = 1000000007

func Solve() {
  var B, W int
  NextInt(&B, &W)
  F, Finv, _ := Factorial(B + W)
  A := make([]int, B + W)
  A[0] = 1
  for i := range A[1:] {
    A[i + 1] = A[i] * Finv[2] % p
  }
  P := make([]int, B + W)
  PB, PW := 0, 0
  for i := 0; i < B + W; i ++ {
    if B <= i {
      PB = (PB + Comb(&F, &Finv, B - 1, i - B) * A[i]) % p
    }
    if W <= i {
      PW = (PW + Comb(&F, &Finv, i - W, W - 1) * A[i]) % p
    }
    P[i] = (p + 1 - PB + PW) * Finv[2] % p
    Write(P[i])
  }
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define N 101000

int n,t[N],x[N],y[N],Time,dis;
int flag=1;

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
		Time=t[i]-t[i-1];
		dis=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if (dis>Time || (Time-dis)&1)
		{
			flag=0;
			break;
		}
	}
	if (flag) puts("Yes"); else puts("No");
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, p;
  cin >> n >> p;
  V a(n);
  bool flg = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= 2;
    if (a[i] == 1) flg = true;
  }
  if (flg) {
    dump((ll)pow(2.0, (double)(n-1)));
  }
  else {
    p == 1 ? dump(0) : dump((ll)pow(2.0, (double)n));
  }
  
  return 0;
}


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

const int MAX_N = (int)100 + 5;

int n;
string s;

int l, r;
int x, whole;

int main(void) {
  // Here your code !
	scanf("%d", &n);
	cin >> s;

	x = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '(') l += 1;
		else r += 1;
		x = min(x, l - r);
	}

	whole = l - r;

	for (int i = 0; i < -x; ++i) {
		s.insert(0, "(");
	}

	for (int i = 0; i < whole - x; ++i) {
		s.push_back(')');
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
//
// Created by 佐竹俊哉 on 2019/11/12.
//

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

const int maxn = 310;
const int INF = TEN(9) + 10;
int d[maxn][maxn];
int t[maxn][maxn];

int main() {
    int N, M, L; cin >> N >> M >> L;
    rep(i, N) {
        rep(j, N) {
            t[i][j] = d[i][j] = INF;
        }
        t[i][i] = d[i][i] = 0;
    }
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        chmin(d[a][b], c);
        chmin(d[b][a], c);
    }

    rep(k, N) rep(i, N) rep(j, N) chmin(d[i][j], d[i][k] + d[k][j]);
    rep(i, N) rep(j, N) t[i][j] = (d[i][j] <= L ? 1 : INF);
    rep(k, N) rep(i, N) rep(j, N) chmin(t[i][j], t[i][k] + t[k][j]);

    int Q; cin >> Q;
    while (Q--) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        int ans = t[a][b];
        if (ans >= N + 1) {
            ans = -1;
        } else {
            ans--;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={-1,0,1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int x=0;
    rep(i,n) {
        cin>>a[i];
        x^=a[i];
    }
    
    int ans=0;
    RFOR(k,31,1) {
        if(!(x&(1<<(k-1)))) continue;
        rep(i,n) {
            if((a[i]^(a[i]-1))==((int)pow(2,k)-1)) {
                x^=(a[i]^(a[i]-1));
                ans++;
                break;
            }
        }
    }
    
    if(x==0) cout<<ans<<endl;
    else cout<<-1<<endl;
}



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

using namespace std;

typedef vector<int> vi;

#define PB push_back
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define all(a) a.begin(),a.end()

int P[1001];

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

	int N, M;
	
	while (cin >> N >> M, N || M) {
		rep1(i, N) cin >> P[i];

		vi A;

		A.PB(0);

		rep(i, N + 1) rep(j, N + 1) if (P[i] + P[j] <= M) A.PB(P[i] + P[j]);

		sort(all(A));

		int ma = 0;

        int l = 0, r = A.size() - 1;

        while (l < r) {
            while (A[l] + A[r] > M) r--;
            ma = max(ma, A[l] + A[r]);
            l++;
        }

		cout << ma << endl;
	}
}

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b; cin >> n >> a >> b;
  int x=0,y=0,z=0;
  for(int i = 0; i < n; i++){
    int p; cin >>p;
    if(p <= a) x++;
    else if(p <= b) y++;
    else z++;
  }
  cout << min(x,min(y,z));
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	printf("%d\n", min(a, b) + min(c, d));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    string s,t;
    for(int i=0;i<b;i++) s+='0'+a;
    for(int i=0;i<a;i++) t+='0'+b;
    cout << min(s,t) << endl;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n = ni()
bbb = na()
ans = bbb[0]
for i in range(n-2):
    ans += min(bbb[i], bbb[i + 1])
print(ans + bbb[-1])


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int n , i , j;
  scanf("%d", &n);
  int date[n];
  for(j = 0 ; j <= n - 1 ; j++){
    scanf("%d", &date[j]);
  }
  for(i = n - 1 ; i >= 0 ; i--){
    if(i != n - 1){
      printf(" ");
    }
    printf("%d", date[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2036
/* Don't quit suffer now and live the rest of your live as a champion */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
const long long MOD = 1e9 + 7;
ll powmod(ll base, ll exp , ll moduluse = MOD){
    base%=moduluse;
    ll result = 1;
    while(exp > 0){
        if(exp & 1) result = (result * base) % moduluse;
        base = (base * base) % moduluse;
        exp >>= 1;
    }
    return result;
}
ll combination(ll n, ll k){
    ll res = 1;
    if( k > n - k ) k = n - k;
    for (int i = 0; i < k; ++i){
        res = res * (n - i) % MOD;
        res = res * powmod(i + 1 ,MOD - 2) % MOD;
    }
    return res % MOD;
}
int main(){
    FAST
    ll n , a , b;
    cin >> n >> a >> b;
    ll N = powmod(2 , n);
    N--;
    N = N % MOD;
    ll A = combination(n , n - a) % MOD , B = combination(n , n - b) % MOD;
    N =(N - A + MOD) % MOD;
    N =(N - B + MOD) % MOD;
    cout << N << endl;
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

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;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

int main() {
    int64_t n;
    cin >> n;
    int64_t ans = 0;
    if (n >= 30) ans = 1;
    cout << ( ans ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 3628
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()

xls = []
for _ in range(n):
    xi, li = na()
    xls.append([xi, li, xi-li, xi+li])
xls.sort(key=lambda x:x[3])
#print(xls)

ans = 0
f = -10**10
for i in range(n):
    if f <= xls[i][2]:
        ans += 1
        f = xls[i][3]
print(ans)



Measured memory_bytes: 35496
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
using ll = long long int;

int n, ret = 0;
vector<int> p;

void pswap(int i, int j) {
	int tmp = p[i] + 1;
	p[i] = p[j] - 1;
	p[j] = tmp;
}

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int pi;
		cin >> pi;
		p.push_back(pi - i - 1);
	}

	for (int i = 0; i < n; i++) {
		if (p[i] == 0) {
			pswap(i, i+1);
			ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E17
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	ll n, k, ans=0;
	cin >> n >> k;
	ans = (n / k)*(n / k)*(n / k);
	if (k % 2 == 0) {
		ans += ((n+k/2)/k)*((n + k / 2) / k)*((n + k / 2) / k);
	}
	cout << ans << endl;
}


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

int n, k;
vector<int> a, b;
int ans = 1e9+7;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		if(t < 0) b.push_back(-t);
		else a.push_back(t);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for(int i=0; i<=k; ++i){
		// from a i, from b k-i
		if(a.size() < i || b.size() < k-i) continue;
		if(i == 0) ans = min(ans, b[k-1]);
		else if(i == k) ans = min(ans, a[k-1]);
		else ans = min({ans, 2*a[i-1]+b[k-i-1], a[i-1]+2*b[k-i-1]});
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,from,to) for (int i=(from);i<=(to);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define MOD 1000000007

int box[100000];
bool red[100000];

int main () {
  int n, m;
  while (cin >> n >> m) {
    REP(i, n) box[i] = 1;
    memset(red, 0, sizeof(red));
    red[0] = true;

    REP(i, m) {
      int x, y; scanf("%d%d", &x, &y);
      x--;
      y--;
      if (red[x] && box[x] == 1) {
        red[x] = false;
        red[y] = true;
      }
      else if (red[x] && box[x] > 1) red[y] = true;
      box[x]--;
      box[y]++;
    }

    int ans = 0;
    REP(i, n) ans += red[i];
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 768