akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 200005;
const int MM = 924844033;

struct BIT{
	int t[MX];
	int read(int x){
		int r = 0;
		while(x) r += t[x], x -= x&-x;
		return r;
	}
	void update(int x, int v){
		while(x < MX) t[x] += v, x += x&-x;
	}
}tree;

ll get_inv(vector<int> &L){
	ll ans = 0;
	for(int i = 0; i < MX; i++) tree.t[i] = 0;
	for(int i = (int)L.size()-1; i >= 0; i--){
		ans += tree.read(L[i]);
		tree.update(L[i], 1);
	}
	return ans;
}

bool check(vector<int> L)
{
	vector<int> O, E;
	int u = 0, v = 0;
	for(int i = 0; i < L.size(); i++){
		int ch = 0;
		if( L[i] < 0 ) ch = 1, L[i] = -L[i];
		if(i&1) O.push_back(L[i]), u += ch;
		else E.push_back(L[i]), v += ch;
	}
	if( get_inv(O)%2 == v%2 && get_inv(E)%2 == u%2 ) return true;
	return false;
}

int D[3][MX];

int main()
{
	int N, a;
	scanf("%d", &N);
	for(int i = 1; i <= 3; i++){
		for(int j = 1; j <= N; j++) scanf("%d", D[i] + j);
	}
	vector<int> L;
	for(int i = 1; i <= N; i++){
		int a = D[2][i];
		if( a%3 != 2 || a/3 %2 != (i+1)%2 ) return !printf("No\n");
		if( D[1][i] == a-1 && D[3][i] == a+1 ) L.push_back(a/3+1);
		else if( D[1][i] == a+1 && D[3][i] == a-1 ) L.push_back(-(a/3+1));
		else return !printf("No\n");
	}
	if( check(L)) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 3320
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

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

typedef long long LL;
#define int long long
const int N = (int) 1e6 + 6, mod = (int) 0;
int n, xm, need = 0, xl[N], xr[N], b[N], o[N];
int cmp(int x, int y) { return xl[x] * b[x] + (xm - b[x]) * xr[x] < xl[y] * b[y] + (xm - b[y]) * xr[y]; }
int check(int lim) {
	int can = lim / xm;
	int res = 0;
	for (int j = n - 1; j >= n - can - 1; --j) {
		int i = o[j];
		res += xl[i] * b[i] + (xm - b[i]) * xr[i];
	}
	int rem = lim - can * xm;
	for (int i = 0; i < n; ++i) {
		int j = o[i];
		int tmp = res;
		if (i >= n - can - 1) {
			res -= xl[j] * b[j] + (xm - b[j]) * xr[j];
		} else {
			int id = o[n - can - 1];
			res -= xl[id] * b[id] + (xm - b[id]) * xr[id];
		}
		int reach = b[j];
		int use = max(0LL, rem - reach);
		res += use * xr[j] + min(rem, reach) * xl[j];
		if (res >= need) return 1;
		res = tmp;
	}
	return 0;
}
int32_t main() {
	cin >> n >> xm;
	
	for (int j = 0; j < n; ++j) {
		cin >> b[j] >> xl[j] >> xr[j];
		need += b[j] * xl[j];
		o[j] = j;
	}
	sort(o, o + n, cmp);
	int bl = -1, br = n * xm;
	while (bl < br - 1) {
		int bm = bl + br >> 1;
		if (check(bm)) {
			br = bm;
		} else {
			bl = bm;
		}
	}
	cout << br << endl;
}



















Measured memory_bytes: 11264
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    ll n,m,l,r;
    cin>>n>>m>>l>>r;
    m=n-m;
    --l;
    mod_build(1234567);
    ll ans1 = comb(n+r,r)-comb(n+l,l)+mod;
    ll ans2 = 0;
    REP(i,1,r+1){
        ll cur = 0;
        rep(j,m+1){
            if((j+n-m)*i>r)break;
            if(j%2)cur+=mod-comb(r-(n-m+j)*i+n,n)*comb(m,j)%mod;
            else cur+=comb(r-(n-m+j)*i+n,n)*comb(m,j)%mod;
        }
        rep(j,m+1){
            if((j+n-m)*i>r)break;
            if(j%2==0)cur+=mod-comb(r-(n-m)*(i+1)-j*i+n,n)*comb(m,j)%mod;
            else cur+=comb(r-(n-m)*(i+1)-j*i+n,n)*comb(m,j)%mod;
        }
        ans2+=cur%mod;
    }
    REP(i,1,l+1){
        ll cur = 0;
        rep(j,m+1){
            if((j+n-m)*i>l)break;
            if(j%2==0)cur+=mod-comb(l-(n-m+j)*i+n,n)*comb(m,j)%mod;
            else cur+=comb(l-(n-m+j)*i+n,n)*comb(m,j)%mod;
        }
        rep(j,m+1){
            if((j+n-m)*i>l)break;
            if(j%2)cur+=mod-comb(l-(n-m)*(i+1)-j*i+n,n)*comb(m,j)%mod;
            else cur+=comb(l-(n-m)*(i+1)-j*i+n,n)*comb(m,j)%mod;
        }
        ans2+=cur%mod;
    }
    ans2%=mod;
    cout<<(ans1-ans2*comb(n,m)%mod+mod)%mod<<endl;
    return 0;
}

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

int main() {
  int N, A;
  cin >> N;
  int ans = 10000;
  for (int i=0; i < N; i++) {
    cin >> A;
    int exp = 0;
    while (A % 2 == 0) {
      A /= 2;
      exp++;
    }
    ans = min(ans, exp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::greater<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> k;
  vector<int> a(n);
  for (int& x : a) {
    cin >> x;
  }
  sort(begin(a), end(a));
  int64 ans = 0;
  for (int i = 0; i < n - k; ++i) {
    ans += a[i];
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 1024
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e5+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    if (n==m)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}


Measured memory_bytes: 256
N = int(input())
ten, notten = [], []
for i in range(N):
    s = int(input())
    ten.append(s) if s%10 == 0 else notten.append(s)

score = sum(notten)

while score % 10 == 0:
    if len(notten) == 0:
        break
    score -= min(notten)
    notten.remove(min(notten))

if score == 0:
    print(0)
else:
    print(score+sum(ten))

Measured memory_bytes: 9064
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;
	map<int,int> m;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		m[A]++;
	}
	int ans = 0;
	int n = m.size() - K;
	if (n > 0) {
		vector<int> v;
		for (auto& i : m) {
			v.push_back(i.second);
		}
		sort(v.begin(), v.end());
		for (int i = 0; i < n; i++)
			ans += v[i];
	}
	cout << ans << endl;
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100000
i64 N;
char S[MAX_N];

int main() {
  cin >> N;
  char c;
  REP(i, N) {
    cin >> c;
    if ('a' <= c && c <= 'z')
      S[i] = c;
  }

  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

  i64 cnt = 1;
  for (i64 i = 1; i < N; i++) {
    if (S[i] == S[i - 1]) {
      continue;
    } else {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> bool chmax(T &a,T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min({a+b,b+c,a+c})<<endl;
}


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

int main() {

  vector<vector<int>> data(3, vector<int>(3));

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }

  int N;
  cin >> N;
  
  vector<int> b(N);
  for (int i = 0; i < N; i++)
    cin >> b.at(i);
  
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < N; k++) {
    	if(b.at(k) == data.at(i).at(j))
          data.at(i).at(j) = 0;
      }
    }
  }
  
  bool bingo = false;
  
  for (int i = 0; i < 3; i++) {
    if(data.at(i).at(0) == 0 && data.at(i).at(1) == 0 && data.at(i).at(2) == 0)
      bingo = true;
  }
  for (int i = 0; i < 3; i++) {
    if(data.at(0).at(i) == 0 && data.at(1).at(i) == 0 && data.at(2).at(i) == 0)
      bingo = true;
  }
  if(data.at(0).at(0) == 0 && data.at(1).at(1) == 0 && data.at(2).at(2) == 0)
      bingo = true;
  if(data.at(0).at(2) == 0 && data.at(1).at(1) == 0 && data.at(2).at(0) == 0)
      bingo = true;
  
  if(bingo)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3600
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string cal(lint a,lint b,int c,int d){
	string ret="";
	if(a==b || a==b+1){
		REP(i,c,d){
			if(i%2==0) ret+='A';else ret+='B';
		}
		return ret;
	}
	if(a==b-1){
		REP(i,c,d){
			if(i%2==1) ret+='A';else ret+='B';
		}
		return ret;
	}
	lint A=max(a,b),B=min(b,a);
	lint len=(A+B)/(B+1);
	//cout<<len<<endl;
	lint lo=0,hi=a/len;
	//cout<<lo<<' '<<hi<<endl;
	while(hi>lo){
		lint mi=(hi+lo+1)/2;
		lint na=a-mi*len,nb=b-(mi-1);
		if(nb>(na+1)*len) hi=mi-1;else lo=mi;
	}
	//cout<<lo<<' '<<len<<endl;
	a-=lo*len;b-=lo;
	lint hoge=a-(b-1)/len;
	lint le2=(b-1)/len+1;
	lint ho2=(len*le2-b)/(len-1);
	lint huga=len-((len*le2-b)-ho2*(len-1));
	//cout<<hoge<<' '<<le2<<' '<<ho2<<' '<<huga<<endl;
	REP(i,c,d){
		lint x=i;
		if(x<(lo*(len+1))){
			if(x%(len+1)==len) ret+='B';else ret+='A';
			continue;
		}
		//if(i==1) cout<<"a"<<endl;
		x-=lo*(len+1);
		if(x<hoge){
			ret+='A';continue;
		}
		//if(i==1) cout<<"a"<<endl;
		x-=hoge;
		if(x<ho2*2){
			if(x%2==0) ret+='B';else ret+='A';
			continue;
		}
		x-=ho2*2;
		//if(i==1) cout<<"a"<<endl;
		if(x<huga){
			ret+='B';continue;
		}
		//if(i==1) cout<<"a"<<endl;
		x-=huga;
		if(x%(len+1)==0) ret+='A';else ret+='B';
	}
	return ret;
}
int main()
{
	int q,a,b,c,d;
	cin>>q;
	rep(i,q){
		cin>>a>>b>>c>>d;
		c--;
		cout<<cal(a,b,c,d)<<endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n,maxw;
long long dp[100100];
int main() {
	cin>>n>>maxw;
	for(int i=1; i<=n; i++) {
		int w,v;
		cin>>w>>v;
		for(int j=maxw-w; j>=0; j--)
			if(dp[j+w]<dp[j]+v)
				dp[j+w]=dp[j]+v;
	}
	cout<<dp[maxw]<<'\n';
	return 0;
}


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

using namespace std;
#define BUF (100005)
#define ll long long 

int n;
int mx=0;
vector<pair<int,int>> p;
map<pair<int,int> ,int> m;

typedef struct node{
	vector<int> from;
	vector<int> to;
} NODE;
vector<NODE> nodes(BUF);

void solve(int parent, int nd){
	if(parent==0){
		int i=1;
		for(auto x: nodes[nd].to){
			m.insert(make_pair(make_pair(nd,x), i));
			solve(nd, x);
			i++;
		}
	}else {
		int i=1;
		int c=m.at(make_pair(parent,nd));
		for(auto x: nodes[nd].to){
			if(c==i)i++;
			m.insert(make_pair(make_pair(nd,x), i));
			solve(nd, x);
			i++;
		}

	}
}

int main(void){
	cin >> n;
	for(int i=1;i<n;i++){
		int a,b;
		cin >> a >> b;
		p.push_back(make_pair(a,b));
		nodes[a].to.push_back(b);
		nodes[b].from.push_back(a);
	}

	for(int i=1;i<=n;i++){
		int s = nodes[i].to.size() +  nodes[i].from.size();
		mx = max(mx,s);
	}

	solve(0,1);

	cout << mx << endl;

	for(auto x : p){
		cout << m.at(x) << endl;
	}

	return 0;
}


Measured memory_bytes: 18296
using System;
using System.Collections.Generic;

namespace C
{
    class ElementCounter<T>
    {
        public Dictionary<T, long> Dic;

        public ElementCounter()
        {
            Dic = new Dictionary<T, long>();
        }
        public long this[T key]
        {
            get
            {
                if (Dic.ContainsKey(key))
                {
                    return Dic[key];
                }
                else
                {
                    return 0;
                }
            }
            set
            {
                if (Dic.ContainsKey(key))
                {
                    Dic[key] = value;
                }
                else
                {
                    Dic.Add(key, value);
                }
            }
        }
        public void Add(T item)
        {
            if (Dic.ContainsKey(item))
            {
                Dic[item] += 1;
            }
            else
            {
                Dic.Add(item, 1);
            }
        }
        public void Remove(T item)
        {
            if (Dic.ContainsKey(item))
            {
                Dic[item] = Dic[item] != 0 ? Dic[item] - 1 : 0;
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var counter = new ElementCounter<string>();
            for (int i = 0; i < N; i++)
            {
                var read = Console.ReadLine();
                counter.Add(read);
            }
            Console.WriteLine(counter.Dic.Keys.Count);
        }
    }
}

Measured memory_bytes: 49796
#include <iostream>
#include <stdexcept>
#include <string>
#include <ctype.h>
#include <stdlib.h>

template<class T>
class Stack
{
private:
  
  struct Node
  {
    Node *next;
    T data;
    
    Node(Node *next_=NULL, T data_=0) : next(next_), data(data_) {}
  };
  
  int size_;
  Node *top;
  
public:
  
  Stack() : size_(0) {}
  ~Stack() { while(!isEmpty()) pop(); }
  
  void push(T data)
  {
    Node *node = new Node(top, data);
    top = node;
    size_++;
  }
  
  T pop()
  {
    if(isEmpty()) throw std::runtime_error("nothing in stack");
    
    T data;
    Node *d = top;
    
    data = d->data;
    top  = d->next;
    delete d;
    size_--;
    
    return data;
  }
  
  bool isEmpty() {
    return size_ == 0;
  }
  
};

int main() {
  
  Stack<int> st;
  std::string str;
  
  while(std::cin >> str) {
    if(isdigit(str[0])) {
      st.push(atoi(str.c_str()));
    }
    else {
      int x = st.pop();
      int y = st.pop();
      if(str == "+") { st.push(y+x); }
      else if(str == "-") { st.push(y-x); }
      else if(str == "*") { st.push(y*x); }
      else throw std::runtime_error("undefined operator '" + str + "'");
    }
  }
  std::cout << st.pop() << '\n';
  
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  string s; cin >> s;
  int n = s.size();
  string ans = "AC";
  if(s[0] != 'A') ans = "WA";

  int cnt = 0;
  for (int i = 2; i < n-1; i++) {
    if(s[i] == 'C') cnt++;
  }
  if(cnt != 1) ans = "WA";

  cnt = 0;
  for (int i = 0; i < n; i++) {
    if(isupper(s[i])) cnt++; //isupper(char型文字)は文字が大文字ならtrueを返す
  }
  if(cnt != 2) ans = "WA";

  std::cout << ans << '\n';
}


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

int main(){
    int N;
    cin >> N;
    if (N < 10) cout << N << endl;
    else if (10 <= N && N < 100) cout << 9 << endl;
    else if (100 <= N && N < 1000) cout << N - 90 << endl;
    else if (1000 <= N && N < 10000) cout << 909 << endl;
    else if (10000 <= N && N < 100000) cout << 909 + N - 9999 << endl;
    else cout << 90909 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 3) {
		cout << 3 << endl;
	}
	else if(a+b == 4){
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <cmath>

using namespace std;

inline long gcd(long a, long b) {
    
    if(b){
        return gcd(b, a % b);
    }else{
        return a;
    }

}
 

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

    int N;
    cin >> N;
    vector<long> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];

    long gcd_A = A[0];

    for(int i = 1; i < N; ++i){
        gcd_A = gcd(gcd_A, A[i]);
    }

    cout << gcd_A << endl;

    return 0;
}


Measured memory_bytes: 1024
N = int(input())
s_t = [input().split() for _ in range(N)]
X = input()
#print(s_t)
ans = 0
for i in range(N):
  if s_t[i][0] == X:
    for j in range(i + 1, N):
      ans+=int(s_t[j][1])
    break
print(ans)

Measured memory_bytes: 3060
N = int(input())
p = list(map(float, input().split()))
dp = [[0 for i in range(N+1)] for j in range(N+1)]
dp[1][1] = p[0]
dp[1][0] = 1 - p[0]
for i in range(1, N):
    dp[i+1][0] = dp[i][0] * (1 - p[i])

#i枚中j枚が表
for i in range(1, N):
    for j in range(1, N+1):
        dp[i+1][j] = dp[i][j] * (1 - p[i]) + dp[i][j-1] * p[i]

ans = 0
for i in range(N//2+1, N+1):
    ans += dp[N][i]
print(ans)


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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int r = 0, g = 0, b = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == 'R') {
            r++;
        }
        else if (S.at(i) == 'G') {
            g++;
        }
        else {
            b++;
        }
    }
    ll sum = (ll)r * g * b;
    ll cnt = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (S.at(i) != S.at(j)) {
                int k = 2 * j - i;
                if (k <= N - 1) {
                    if (S.at(k) != S.at(i) && S.at(k) != S.at(j)) {
                        cnt++;
                    }
                }
            }
        }
    }
    ll ans = sum - cnt;
    cout << ans << endl;
}


Measured memory_bytes: 3600
n,X[100],Y[100],R[100];U,V,S,T;f,i,u,v,s,t,o,x,y;main(m){for(;~scanf("%d",&n);m=0){for(i=n;i--;)scanf("%d%d%d",X+i,Y+i,R+i);for(scanf("%d",&m);m--;f=!puts(f?"Safe":"Danger"))for(scanf("%d%d%d%d",&U,&V,&S,&T),i=n;i--;f+=(o=hypot(u,v)>R[i])&fabs(y*s+x*t)/hypot(x,y)<=R[i]&v*y<u*x&t*y>s*x||o^hypot(s,t)>R[i])u=U-X[i],v=V-Y[i],s=S-X[i],t=T-Y[i],x=U-S,y=T-V;}}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	long long X, K, D;
	scanf("%lld %lld %lld", &X, &K, &D);
	X = llabs(X);
	if ((X + D - 1) / D > K) X -= D * K;
	else if (X % D == 0) {
		if ((X / D + K) % 2 == 0) X = 0;
		else X = D;
	} else if ((X / D + K) % 2 == 0) X %= D;
	else X = D - X % D;
	printf("%lld\n", X);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1716
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    int ans = (3 * a + p) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int p, q, r ;
    cin >> p >> q >> r ;
    int res = p + q  ;
    res = min(res, q + r) ;
    res = min(res, r + p) ;
    cout << res << endl ;
}

Measured memory_bytes: 3640
n = int(input())
a = [int(i) for i in input().split()]
bl = []
br = []
for i in range(n):
    if i%2==0:
        br.append(a[i])
    else:
        bl.append(a[i])
bl.reverse()
if n%2 == 0:
    for i in bl+br:
        print(i)
else:
    for i in reversed(bl+br):
        print(i)

Measured memory_bytes: 26016
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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

const ll INF = 1LL << 60;


signed main() {

	ll h, a;
	cin >> h >> a;

	if (h % a == 0) {
		cout << h / a;
		return 0;
	}
	else {
		cout << h / a + 1;
	}
	
}


Measured memory_bytes: 256
//
#define _USE_MATH_DEFINES
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
#define PI  3.1415926535
//
#include <iomanip>
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll iA, iB, iH, iM;
    cin >> iA >> iB >> iH >> iM;
    ld A = ld(iA);
    ld B = ld(iB);
    ld H = ld(iH);
    ld M = ld(iM);
    ld dt = (H / 12.0L + M / (60.0L * 12.0L) - M / 60.0L) * 2.0L * M_PI;
    ld R2 = A * A + B * B - 2.0L * A * B * cosl(dt);
    ld R = sqrtl(R2);
    printf("%16.16Lf", R);
    return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s<t){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    set<string> se;
    se.insert(s[0]);
    for(int i = 0; i < n-1; i++)
    {
        string s1 = s[i];
        string s2 = s[i+1];
        if(s1[s1.size()-1] == s2[0])
        {
            if(!se.insert(s2).second)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}




Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<algorithm>
#include<functional>
#include<vector>
#include<numeric>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)


const int NMAX = 1000, MMAX = 20000, INF = 1e9;
vector<int> cookies;
vector<pair<int, int> > boxes; // first: capacity, second: cost
int dp[MMAX];
int N, M;

void init() {
  REP(i, M + 100) {
    dp[i] = INF;
  }

  dp[0] = 0;
}

void solve() {
  init();
  
  for (pair<int, int> box : boxes) {
    int capacity = box.first, cost = box.second; 
//    cout << "[" << capacity << " " << cost << "]" << endl;
    for (int m = M; m >= 1; m--) {
      if (m >= capacity) {
        dp[m] = min(dp[m], dp[m - capacity] + cost);
      } else {
        dp[m] = min(dp[m], cost);
      }

//      REP(i, 15) {
  //      cout << dp[i] << " ";
    //  }
      //cout << endl;
    }
  }
}

int maximum() {
  int ans = 0;
  
  sort(cookies.begin(), cookies.end(), greater<int>());
  cookies.insert(cookies.begin(), 0);

  for (int i = 1, len = cookies.size(); i < len; i++) {
    cookies[i] = cookies[i - 1] + cookies[i];
  }

  for (int i = 0, len = cookies.size(); i < len; i++) {
    ans = max(ans, cookies[i] - dp[i]);
  }

  return ans;
}

int main() {
  cin >> M >> N;
  REP(i, M) {
    int p;
    cin >> p;
    cookies.push_back(p);
  }

  REP(i, N) {
    int c, e;
    cin >> c >> e;
    boxes.push_back(make_pair(c, e));
  }

  solve();

  cout << maximum() << endl;
}

Measured memory_bytes: 1372
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj,n,m,a,b,c,d,e,f,g,h,r,w,l;
ll num,ans,sum,ok,ng;
ll x[500005],y[500005],z[500005];
ll dp[3][505];
char s[500005],t[500005],u[500005];
bool dame,flag;

void solve(ll bit,ll ans,bool flag){
	if(bit == -1){
		//p(ans);
		sum = max(ans,sum);
		return;
	}
	if(flag){
		//気にしなきゃダメ
		if(k & (1ll << bit)){
			solve(bit-1,ans + dp[1][bit],true);
			solve(bit-1,ans + dp[0][bit],false);
		}else{
			solve(bit-1,ans + dp[0][bit],true);
		}
	}else{
		//気にしなくていい
		solve(bit-1,ans + max(dp[0][bit],dp[1][bit]),false);
	}
	return;
}
int main(){
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> x[i];
		a = max(a,x[i]);
	}
	a = max(a,k);
	for(i=40;i>=0;i--){
		if(!(a & (1ll << i)) && !flag)continue;
		if((a & (1ll << i))){			
			num = i;
			break;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<=num;j++){
			if(x[i] & (1ll << j)){
				dp[0][j] += (1ll << j);
			}else{
				dp[1][j] += (1ll << j);
			}
		}
		
	}
	//p(num);
	//num := max bit
	solve(num,0,true);
	p(sum);

	return 0;
}

Measured memory_bytes: 26624
#include<iostream>
using namespace std;
int main(void)
{
  int k,x;
  cin>>k>>x;
  int a=x-k+1;
  int b=x+k-1;
  for(int i=a;i<=b;i++)
  {
    cout<<i<<" ";
  }
}
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

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

int main()
{
  int A, B;
  cin >> A >> B;
  if (A==B){
    cout << A + B << endl;
  }
  else if (A < B){
    cout << 2*B-1<<endl;
  }
  else {
    cout << 2*A-1<<endl;
  }
}

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

using namespace std;

const double EPS = 1e-7;
inline bool equals(double a, double b) { return fabs(a - b) < EPS; }

class Point
{
public:
    double x, y;
    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator+(Point & p) { return Point(x + p.x, y + p.y); }
    Point operator-(Point & p) { return Point(x - p.x, y - p.y); }
    Point operator*(double k) { return Point(x * k, y * k); }
    Point operator/(double k) { return Point(x / k, y / k); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator<(const Point & p) const { return x != p.x ? x < p.x : y < p.y; }

    bool operator==(const Point & p) const 
    { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; }
};

typedef Point Vector;

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

    double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    Point a(x1, y1), b(x2, y2);
    Vector v1(b.x - a.x, b.y - a.y);
    double len = v1.abs();

    int caseNum; cin >> caseNum;
    while (caseNum--) {
        double x, y; cin >> x >> y;
        Point p(x, y);
        Vector v2(p.x - a.x, p.y - a.y);
        double projection = (v1.x * v2.x + v1.y * v2.y) / len;
        double tx = projection * (b.x - a.x) / len;
        double ty = projection * (b.y - a.y) / len;
        tx += a.x; ty += a.y; //垂线与直线交点
        cout << fixed << setprecision(8) << (2 * tx - x) << ' ' << fixed << setprecision(8) << (2 * ty - y) << endl;
    }

    return 0;
}



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

using namespace std;

int main(int argc, char const *argv[]) {
	int A,B,C,D,E,F;
	std::cin >> A >> B >> C >> D >> E >> F;
	bool water[31];
	// waterの初期化
	for (size_t i = 0; i < 31; i++) {
		water[i] = false;
	}

	//waterの入ることのできうる量の取得
	int temp;
	for (size_t i = 0; i <= 30; i++) {
		for (size_t j = 0; j <= 30; j++) {
			temp = i * A + j * B;
			if (temp <= F / 100) {
				water[temp] = true;
			}
		}
	}
	water[0] = false;



	double maxcon = -1.0;
	int nowSugerAns = 0;
	int nowSugerWaterAns = 0;
	// 全ての入れることのできる水について全探索
	for (size_t i = 1; i < 31; i++) {
		if (water[i]) {
			// 水に入れることのできる砂糖の限界量
			int amount = i * E;
			double maxsuger = 0.0;
			// 全ての入れることのできる砂糖の量について全探索
			for (size_t j = 0; j <= amount / C; j++) {
				for (size_t k = 0; k <= amount / D; k++) {
					// 条件1 砂糖の量は全体限界量を超えてはならない
					// 条件2 砂糖の量は砂糖限界量を超えてはならない
					if (j * C + k * D <= F - i * 100 && j * C + k * D <= amount) {
						maxsuger = max(maxsuger , (double)j * C + (double)k * D);
						if (maxsuger / (i * 100.0 + maxsuger) > maxcon) {
							maxcon = maxsuger / (i * 100 + maxsuger);
							nowSugerAns = maxsuger;
							nowSugerWaterAns = i * 100 + nowSugerAns;
						}
					}
				}
			}
		}
	}

	std::cout << nowSugerWaterAns << " " << nowSugerAns << '\n';

	return 0;
}


Measured memory_bytes: 256
def main():
    class UnionFind:
        def __init__(self, N):
            """
            N:要素数
            root:各要素の親要素の番号を格納するリスト.
                ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
            rank:ランク
            """
            self.N = N
            self.root = [-1] * N
            self.rank = [0] * N

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

        def find(self, x):
            """頂点xの根を見つける"""
            if self.root[x] < 0:
                return x
            else:
                while self.root[x] >= 0:
                    x = self.root[x]
                return x

        def union(self, x, y):
            """x,yが属する木をunion"""
            # 根を比較する
            # すでに同じ木に属していた場合は何もしない.
            # 違う木に属していた場合はrankを見てくっつける方を決める.
            # rankが同じ時はrankを1増やす
            x = self.find(x)
            y = self.find(y)
            if x == y:
                return
            elif self.rank[x] > self.rank[y]:
                self.root[x] += self.root[y]
                self.root[y] = x
            else:
                self.root[y] += self.root[x]
                self.root[x] = y
                if self.rank[x] == self.rank[y]:
                    self.rank[y] += 1

        def same(self, x, y):
            """xとyが同じグループに属するかどうか"""
            return self.find(x) == self.find(y)

        def count(self, x):
            """頂点xが属する木のサイズを返す"""
            return - self.root[self.find(x)]

        def members(self, x):
            """xが属する木の要素を列挙"""
            _root = self.find(x)
            return [i for i in range(self.N) if self.find == _root]

        def roots(self):
            """森の根を列挙"""
            return [i for i, x in enumerate(self.root) if x < 0]

        def group_count(self):
            """連結成分の数"""
            return len(self.roots())

        def all_group_members(self):
            """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
            return {r: self.members(r) for r in self.roots()}


    import sys
    input = sys.stdin.readline
    n, q = map(int, input().split())
    ans = [0, 1]
    uf = UnionFind(n)
    for i in range(q):
        t, u, v = map(int, input().split())
        if t:
            print(ans[uf.same(u, v)])
        else:
            uf.union(u, v)

main()

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

int main() {
  string S;
  int ans = 0;

  cin >> S;
  for(int i=0;i<S.size();i++){
    ans += (S.at(i) - '0');
  }
  if(ans % 9 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3748
<>=~$";
@c=((($H=$`)-2)*(($W=$')-2),(0)x9);
map{$a=$`+$_%3;$b=$'+$_/3|0;$c[$d{$a}{$b}]--,$c[++$d{$a}{$b}]++if$H>=$a&&$a>2&&$W>=$b&&$b>2}!//..8for<>;
print"@c"

Measured memory_bytes: 155648
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;
#define matrix(T) vector<vector<T>>
#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define pqueue priority_queue
#define pushb push_back
#define fi first
#define se second
#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v,size) v.resize(size); for(auto &a__: v) cin>>a__
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

ll nPr(ll n, ll r) {
	if(n<r) return 0;

	ll result=1LL;
	for(ll i=0; i<r; i++) result*=n-i;
	return result;
}

ll nPrP(ll n, ll r, ll p) { // mod pにおけるnPr
	if(n<r) return 0;

	ll result=1LL;
	for(int i=0; i<r; i++) {
		result*=n-i;
		result%=p;
	}
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


int N;
intvec A;
ll res=0;

void input() {
	cin>>N;
	init(A,N);
}

void solve() {
	int prv=0;
	for(int i=0; i<N; i++) {
		if(prv && A[i]) {
			res++;
			A[i]--;
		}
		res+=A[i]/2;
		prv=A[i]%2;
	}
	cout<<res<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <deque>
#include <bitset>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i) = 0; (i) <= (n); (i)++)
using namespace std;

int N, A, B;

signed main()
{
	cin >> N >> A >> B;

	if (N < A || N < B)
	{
		cout << "-1" << endl;
		return 0;
	}
	if (A == 1)
	{
		if (B == N)
		{
			REP(i, N) cout << (i ? " " : "") << (N - i);
			cout << endl;
		}
		else
		{
			cout << -1 << endl;
		}
		return 0;
	}
	if (B == 1)
	{
		if (A == N)
		{
			REP(i, N) cout << (i ? " " : "") << (i + 1);
			cout << endl;
		}
		else
		{
			cout << -1 << endl;
		}
		return 0;
	}

	int need = A + B - 1;

	if (need > N)
	{
		cout << -1 << endl;
		return 0;
	}

	int crap = N - need;

	if (ceil(crap / (double)(A - 1)) <= B - 1)
	{
		for (int i = 0; i < crap; i++)
		{
			int t = i / (A - 1);
			int a = i % (A - 1);
			if (crap < (A - 1) * (t + 1))
			{
				int b = ((A - 1) * t);
				int n = A + i - b;
				cout << (i ? " " : "") << (n + 1);
			}
			else
			{
				int n = (N - (B - 1)) - ((A - 1) * t) - ((A - 1) - a);
				cout << (i ? " " : "") << (n + 1);
			}
		}
	}
	else if (ceil(crap / (double)(B - 1)) <= A - 1)
	{
		for (int i = 0; i < crap; i++)
		{
			int t = i / (B - 1);
			int a = i % (B - 1);
			if (crap < (A - 1) * (t + 1))
			{
				int r = crap - i;
				int n = (N - B) - r;
				cout << (i ? " " : "") << n;

			}
			else
			{
				int n = (A + 1) + ((B - 1) * t) + a;
				cout << (i ? " " : "") << n;
			}
		}
	}
	else
	{
		cout << "-1" << endl;
		return 0;
	}
	
	for (int i = 0; i < B - 1; i++)
	{
		cout << " " << (N - i);
	}

	for (int i = 0; i < A; i++)
	{
		cout << " " << (i + 1);
	}
}

Measured memory_bytes: 2176