akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

mat mul(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++){
        for (int k = 0; k < B.size(); k++){
            for (int j = 0; j < B[0].size(); j++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n){
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];


vector<int> cnt;
void dfs(int v){
    if(visited[v]) return;
    visited[v] = true;
    cnt[v/V]++;
    for (int u : to[v]) dfs(u);
}


int main(){
    int n;
    cin >> n;
    rep(i, n){
        int x, y;
        cin >> x >> y;
        y += V;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    ll ans = 0;
    rep(i, V*2){
        if(visited[i]) continue;
        cnt = vector<int>(2);
        dfs(i);
        ans += (ll)cnt[0]*cnt[1];
    }
    ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 13572
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int func(int sum, int depth)
{
	if (sum < 0)
	{
		return 0;
	}
	if (sum == 0)
	{
		return 1;
	}
	if (depth == 3)
	{
		if (sum < 10)
			return 1;
		else
			return 0;
	}
	int ans = 0;
	for (int i = 0; i < 10 && i <= sum; i++)
	{
		ans += func(sum - i, depth+1);
	}
	return ans;
}

int main(int argc, char const *argv[])
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		if (n > 36)
		{
			printf("0\n");
			continue;
		}
		int num = func(n, 0);
		printf("%d\n", num);
	}
	return 0;
}

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

using namespace std;

using T = long long;

bool QUERY;
struct Line {
	mutable T a, b, p;
  T Eval(T x) const { return a * x + b; }
	bool operator<(const Line& o) const {
		return QUERY ? p < o.p : a < o.a;
	}
};

struct LineContainer : multiset<Line> {
	// for doubles, use kInf = 1/.0, div(a, b) = a / b
	const T kInf = numeric_limits<T>::max();
	T div(T a, T b) { // floored division
		return a / b - ((a ^ b) < 0 && a % b); }
	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = kInf; return false; }
		if (x->a == y->a) x->p = x->b > y->b ? kInf : -kInf;
		else x->p = div(y->b - x->b, x->a - y->a);
		return x->p >= y->p;
	}
	void InsertLine(T a, T b) {
		auto nx = insert({a, b, 0}), it = nx++, pv = it;
		while (isect(it, nx)) nx = erase(nx);
		if (pv != begin() && isect(--pv, it))
      isect(pv, it = erase(it));
		while ((it = pv) != begin() && (--pv)->p >= it->p)
			isect(pv, erase(it));
	}
	T EvalMax(T x) {
		assert(!empty());
		QUERY = 1; auto it = lower_bound({0,0,x}); QUERY = 0;
		return it->Eval(x);
	}
};

int main() {
    int n; long long c; cin >> n >> c;
    LineContainer lc;
    
    long long dp = 0;
    for (int i = 0; i < n; ++i) {
        int h; cin >> h;
        if (i > 0) {
            long long now = -lc.EvalMax(h);
            dp = now + c + 1LL * h * h;
        }
        lc.InsertLine(2 * h, -dp - 1LL * h * h);
    }
    cout << dp << endl;

    return 0;
}


Measured memory_bytes: 12800
# https://atcoder.jp/contests/abs/tasks/abc087_b



A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

ans = 0
y500 = [X / 500, A].min
(0..y500).each do |a|
  y100 = [(X - 500 * a) / 100, B].min
  (0..y100).each do |b|
    if (X - 500 * a - 100 * b) / 50 <= C
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n+1);
    FOR(i,1,n+1) cin>>a[i];
    int l=1,r=1,now=0;
    ll ans=0;
    bool flag=true;
    while(true){
      //cout<<l<<' '<<r<<' '<<now<<endl; 
      if(l==n && r==n){
        ans++;
        break;
      }
      //if(l>=n+1 || r>=n+1) break;
      if((now&a[r])==0){
        if(r>=n){
          l++;
          ans+=r-l+1;
          now^=a[l-1];
        }else{
          ans++;
          now^=a[r];
          r++;
        }
      }else{
        l++;
        ans+=r-l;
        now^=a[l-1];
      }
      //cout<<l<<' '<<r<<' '<<now<<endl; 
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    vll a(n);
    forn(i, n) cin >> a[i];
    ll ans = a[0] - 1;
    ll x = 2;
    forn1(i, n){
        if (a[i] == x) x++;
        ans += (a[i] - 1) / x;
    }
    cout << ans << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int n;
	cin >> n;

	vector<int> a(n);
	cin >> a;

	sort(all(a));

	int ans = 0;
	rep(i, a.size()) {
		range(j, i + 1, a.size()) {
			auto mini = lower_bound(all(a), a[j] - a[i] + 1);
			auto maxi = upper_bound(all(a), a[i] + a[j] - 1);

			int l = max<int>(distance(a.begin(), mini), j + 1);
			int r = distance(a.begin(), maxi);

			// cout << a[i] << ' ' << a[j] << endl;
			// cout << l << ' ' << r << endl;
			if (l < r) {
				int tmp = r - l;
				// show(tmp)
				ans += tmp;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define X first
#define Y second
const int inf=0x3f3f3f3f3f3f3f3f;
const int N=200000;
int n,m;
vector<pair<int,int> > rg[N+1];
struct segtree{
	struct node{int l,r,mx,lz;}nd[N<<2];
	#define l(p) nd[p].l
	#define r(p) nd[p].r
	#define mx(p) nd[p].mx
	#define lz(p) nd[p].lz
	void bld(int l=1,int r=n,int p=1){
		l(p)=l;r(p)=r;mx(p)=lz(p)=0;
		if(l==r)return;
		int mid=l+r>>1;
		bld(l,mid,p<<1);bld(mid+1,r,p<<1|1);
	}
	void init(){bld();}
	void sprdwn(int p){
		if(lz(p)){
			mx(p<<1)+=lz(p);mx(p<<1|1)+=lz(p);
			lz(p<<1)+=lz(p);lz(p<<1|1)+=lz(p);
			lz(p)=0;
		}
	}
	void sprup(int p){mx(p)=max(mx(p<<1),mx(p<<1|1));}
	void _add(int l,int r,int v,int p=1){
		if(l<=l(p)&&r>=r(p)){mx(p)+=v;lz(p)+=v;return;}
		sprdwn(p);
		int mid=l(p)+r(p)>>1;
		if(l<=mid)_add(l,r,v,p<<1);
		if(r>mid)_add(l,r,v,p<<1|1);
		sprup(p);
	}
	void add(int l,int r,int v){if(l<=r)_add(l,r,v);}
	int _mx(){return mx(1);}
}segt;
int dp[N+1][2];
signed main(){
	cin>>n>>m;
	while(m--){
		int l,r,a;
		scanf("%lld%lld%lld",&l,&r,&a);
		rg[r].pb(mp(l,a));
	}
	segt.init();
	for(int i=1;i<=n;i++){
		vector<pair<int,int> > &v=rg[i];
		v.pb(mp(i,inf));
		sort(v.begin(),v.end());
		int sum=0;
		for(int j=0;j+1<v.size();j++){
			sum+=v[j].Y;
			segt.add(v[j].X,v[j+1].X-1,sum);
		}
		dp[i][1]=max(dp[i-1][0],dp[i-1][1])+sum;
		dp[i][0]=segt._mx();
		segt.add(i,i,dp[i][1]);
	}
	cout<<max(dp[n][0],dp[n][1]);
	return 0;
}
/*1
5 3
1 3 10
2 4 -10
3 5 10
*/

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
char a[1001][1001];
int b[3][1001][1001];
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,t;cin >> n >> m >> t;
    rep(i,0,1001){
        rep(j,0,1001){
            rep(k,0,3)b[k][i][j]=0;
            //cout << b[0][i][j];
        }
    }
    rep(i,1,n+1){
        rep(j,1,m+1){
            char c;cin >> c;
            if(c=='J'){
                b[0][i][j]=1;
            }else if(c=='O'){
                b[1][i][j]=1;
            }else{
                b[2][i][j]=1;
            }
        }
    }
    rep(i,1,n+1){
        rep(j,1,m+1){
           rep(k,0,3){b[k][i][j]+=(b[k][i-1][j]+b[k][i][j-1]-b[k][i-1][j-1]);}
           //cout << b[0][i][j];
        }
       // cout << endl;
    }
    rep(i,0,t){
        int x1,y1,x2,y2;cin >> x1 >> y1 >>x2 >> y2;
        int d=0;
        rep(j,0,3){
            d=b[j][x2][y2];
            d+=b[j][x1-1][y1-1];
            d-=b[j][x1-1][y2];
            d-=b[j][x2][y1-1];
            cout << d;
            if(j!=2)cout << " ";
            d=0;
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
    long long a, b;
    cin >> a >> b;

    if ((a == 0 || b == 0) || (a < 0 && b > 0)) {
        cout << "Zero" << endl;
        return 0;
    }

    if (a > 0 && b > 0)
        cout << "Positive" << endl;
    else // a < 0 && b < 0
        cout << ((b - a) % 2 == 0 ? "Negative" : "Positive") << endl;
}

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

int main() {
  int A, B, C1, C2, C3, C4, C5, N=0;
  cin >> A >> B;
  int i=A;
  while(i<B+1){
    C1=i/10000;
    C2=i%10000/1000;
    C3=i%1000/100;
    C4=i%100/10;
    C5=i%10;
    if(C1==C5&&C2==C4)
      N++;
    i++;
  }
  cout << N << endl;
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  int tmp = 1, cnt = 0;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    if(a==tmp){
      tmp++;
      cnt++;
    }
  }
  int ans;
  if(cnt==0) ans = -1;
  else ans = n-cnt;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

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

  string k;
  ll d;
  cin >> k >> d;

  ll n = k.size();

  vector<vvll> dp(2, vvll(n + 1, vll(d, 0)));
  dp[0][0][0] = 1;
  dp[1][0][0] = 0;
  repLRE(i, 1, n) {
    rep(j, d) {
      ll kid = k[i-1] - '0';
      dp[0][i][(j + kid) % d] = dp[0][i-1][j];
      rep(l, 10) {
        ll nj = (j + l) % d;
        dp[1][i][nj] = (dp[1][i][nj] + dp[1][i-1][j]) % mod;
      }  // d
      if (kid == 0) continue;
      repLRE(l, 0, kid - 1) {
        ll nj = (j + l) % d;
        dp[1][i][nj] = (dp[1][i][nj] + dp[0][i-1][j]) % mod;
      }  // d
    }    // j
  }      // i

  cout << ((dp[0][n][0] + dp[1][n][0])%mod + mod - 1)%mod << endl;

  return 0;
}


Measured memory_bytes: 24832
# -*- coding:utf-8 -*-
a,b = map(int,input().split())

if  b==1:
    print(0)
elif a >= b:
    print(1)
else:
    SumPowerSocket = a
    NumUsePowerTap = 1
    while True:
        if b > SumPowerSocket:
            SumPowerSocket += a - 1
            NumUsePowerTap += 1
        else:
            print(NumUsePowerTap)
            break

Measured memory_bytes: 9104
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)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 mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
#define mx 100000
char ar[mx+2];
int main(){
    ll n,m,k;
    ll x;
    int ak[4];
    for(int i=1;i<=3;i++)cin>>ak[i];
    cin>>k;
    vector<ll>v[5];
    for(int i=1;i<=3;i++){
        for(int j=1;j<=ak[i];j++){
            ll l;
            cin>>l;
            v[i].PB(l);
        }
        sort(v[i].begin(),v[i].end());
        reverse(v[i].begin(),v[i].end());
    }
    vector<ll>ans;
    for(int i=0;i<ak[1];i++){
        for(int j=0;j<ak[2];j++){
            ans.PB(v[1][i]+v[2][j]);
        }
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());


   // cout<<"lol"<<endl;
    vector<ll>sum;

    for(int i=0;i<ak[3];i++){
        for(int j = 0;j<min((int)k, (int)ans.size());j++){
            sum.PB(v[3][i] + ans[j]);
        }
    }
    sort(sum.begin(),sum.end());
    reverse(sum.begin(),sum.end());
    for(int i=0;i<k;i++)cout<<sum[i]<<endl;



    return 0;
}

Measured memory_bytes: 43384
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b,c;
    int pa=0,pb=0,pc=0;
    int rem;
    int ram;
    int yes=1;
    for (int i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        rem=(max(b-pb,pb-b)+max(c-pc,pc-c));
        ram=a-pa;
        if (rem>ram)
        {
            yes=0;
        }
        else
        {
            if ((ram-rem)%2==1)
            {
                yes=0;
            }
        }
        pa=a;
        pb=b;
        pc=c;
    }
    if (yes==1)printf ("Yes\n");
    else printf ("No\n");
}

Measured memory_bytes: 764
package main

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

func main() {
	io := newIo()
	defer io.Flush()
	S := []rune(io.Next())
	K := io.NextInt64()
	zRune := rune('z')
	aRune := rune('a')
	for i, s := range S {
		if s == aRune {
			continue
		}
		if int64(zRune-s+1) <= K {
			S[i] = aRune
			K -= int64(zRune + 1 - s)
			if K <= 0 {
				break
			}
		}
	}
	if K > 0 {
		lastRune := S[len(S)-1]
		K = K % 26
		if int(lastRune)+int(K) > int(zRune) {
			fmt.Println("AA")
			S[len(S)-1] = rune(int(aRune) - 1 + int(lastRune) - int(zRune) + int(K))
		} else {
			S[len(S)-1] = rune(int(lastRune) + int(K))
		}
	}
	fmt.Println(string(S))
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextInt64() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}


Measured memory_bytes: 1920
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int ketasum(int n){
    int ret = 0;
    while(n > 0){
        ret += n % 10;
        n /= 10;
    }
    return ret;
}
int main() {
    int n;
    cin >> n;

    cout << (n % ketasum(n) == 0 ? "Yes" : "No")<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

map<ll, map<ll, ll> > G;
ll N, M;
ll INF = (ll)pow(10, 9);

void dijkstra(ll st, vvl &dist){
  priority_queue<pll> que;
  ll x, y, w;

  rep2(i, 1, N + 1) que.push(make_pair(dist[st][i], i));
  
  while(!(que.empty())){
    w = que.top().first;
    x = que.top().second;
    
    que.pop();
    
    for(auto itr = G[x].begin(); itr != G[x].end(); itr++){
      y = itr->first;
      ll alt = dist[st][x] + G[x][y];

      if(dist[st][y] > alt){
        dist[st][y] = alt;
        que.push(make_pair(alt, y));
      }
    }
  }
}

int main(){
  cin >> N >> M;
  
  ll a, b, c;
  vpll edge(M);
  rep(i, M){
    cin >> a >> b >> c;

    G[a][b] = c;
    G[b][a] = c;
    edge[i] = make_pair(a, b);
  }

  vvl dist(N + 1, vl(N + 1, INF));
  rep2(i, 1, N + 1) dist[i][i] = 0;
  
  rep2(i, 1, N + 1) dijkstra(i, dist);
  
  ll cnt = 0;

  rep(i, M){
    a = edge[i].first;
    b = edge[i].second;
    c = G[a][b];
    
    rep2(j, 1, N + 1){      
      if(dist[j][a] + c == dist[j][b]){
        cnt++;
        break;
      }
    }
  }

  cout << M - cnt << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	if(s1[0]!=s2[2]||s1[2]!=s2[0]||s1[1]!=s2[1]){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
}


Measured memory_bytes: 256
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():

    W = int(input())
    N = int(input())
    AB = [[int(x)-1 for x in input().split(',')] for i in range(N)]
    
    ans = list(range(1, W+1))

    for ab in AB:
        ans[ab[0]], ans[ab[1]] = ans[ab[1]], ans[ab[0]]

    for i in ans:
        print(i)

if __name__ == '__main__':
    main()




Measured memory_bytes: 5744
// In the name of god
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
using ll = long long;
const ll N = 1e5 + 5, inf = 4e18;
ll n, k = 2, a[N], ans;  
int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n ;
	for(ll i = 0; i < n; i++){
		cin >> a[i] ;
		if(i == 0){
			ans += a[i] - 1;
			continue;
		} 
		if(a[i] < k)continue;
		if(a[i] == k)
			k ++;
		else{
			ll z = (a[i] - 1) / k;
			ans += z; 
			continue;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;

    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }

    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }

    modint operator+=(const modint &r) { return *this = *this + r; }
    modint operator-=(const modint &r) { return *this = *this - r; }
    modint operator*=(const modint &r) { return *this = *this * r; }
    modint operator/=(const modint &r) { return *this = *this / r; }

    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }

    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }

    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)


int main(void){
    int Y, X;
    cin >> Y >> X;
    vector<int> max_y(Y+1),max_x(X+1); 
    rep(y,Y) cin >> max_y[y];
    rep(x,X) cin >> max_x[x];
    sort(all(max_y),greater<int>());
    sort(all(max_x),greater<int>());

    modint res = 1;
    int yi = 0, xi = 0;
    for (int yx = Y*X; yx > 0; yx--) {
        if (max_y[yi] == yx && max_x[xi] == yx) {
            yi++;
            xi++;
        } else if (max_y[yi] == yx) {
            res *= modint(xi);
            yi++;
        } else if (max_x[xi] == yx) {
            res *= modint(yi);
            xi++;
        } else {
            res *= modint((xi)*(yi)-(Y*X-yx));
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  map<char, char> m;
  m['A'] = 'T';
  m['T'] = 'A';
  m['G'] = 'C';
  m['C'] = 'G';
  cout << m[s[0]] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

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

using namespace std;

void KMP_build(const char *pttn,int *fail){
	int n=strlen(pttn);
	fail[0]=-1;
	for(int i=1,j=-1;i<=n;i++){
		while(j>=0 && pttn[j]!=pttn[i-1]) j=fail[j];
		fail[i]=++j;
	}
}

void KMP_search(const char *s,const char *pttn,const int *fail,bool *res){
	int m=strlen(s),n=strlen(pttn),j=0;
	rep(i,m){
		while(j>=0 && s[i]!=pttn[j]) j=fail[j];
		j++;
		if(j==n){
			res[i-n+1]=true;
			j=fail[j];
		}
	}
}

int L; // s の長さ

int n,len[12];
bool check[12][5000]; // check[i][j] := ( s[j..j+len[i]) == key[i] )

char dp[5000][1<<12]; // メモリ節約のため char
bool dfs(int x,int S){
	if(S==(1<<n)-1) return true;
	if(x>=L) return false;

	if(dp[x][S]!=-1) return dp[x][S];

	rep(i,n) if(check[i][x] && (S>>i&1)==0 && dfs(x+len[i],S|1<<i)) return dp[x][S]=true;
	return dp[x][S]=false;
}

int main(){
	for(int m;scanf("%d%d",&n,&m),n;){
		char key[12][32];
		rep(i,n) scanf("%s",key[i]), len[i]=strlen(key[i]);

		L=0;
		char s[5001];
		rep(i,m){
			scanf("%s",s+L);
			L+=strlen(s+L);
		}

		rep(i,n){
			rep(x,L) check[i][x]=false;
			int fail[5001];
			KMP_build(key[i],fail);
			KMP_search(s,key[i],fail,check[i]);
		}

		int ans=0;
		memset(dp,-1,sizeof dp);
		rep(x,L) if(dfs(x,0)) ans++;
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 21116
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

int main()
{
    char str[11];
    cin >> str;
    int num[10];
    int length=strlen(str);
    for (int i=0; i<length; i++){
        num[i]=int(str[i])-48;
    }
    int comb[length+1];
    long int dp[length+1];//dp[i]とは先頭からi番目までの数を使った時の和、jはその組み合わせ
    comb[0]=1;
    for (int i=1; i<length+1; i++){
        comb[i]=pow(2, i-1);
    }
    dp[0]=0;

    for (int i=1; i<=length; i++){
        long int sum=0;
        for (int j=i; j>0; j--){
            long int tmp=0;
            for (int k=0; k<j; k++){
                tmp+=num[i-k-1]*pow(10, k);
            }
            sum+=dp[i-j]+tmp*comb[i-j];
        }
        dp[i]=sum;
    }
    cout << dp[length];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin>>a;
  //D=25 なら Christmas,D=24 なら Christmas Eve,D=23 なら Christmas Eve Eve,D=22 なら Christmas Eve Eve Eve
  if(a==25){
    cout<<"Christmas";
  }
    if(a==24){
    cout<<"Christmas Eve";
  }
    if(a==23){
    cout<<"Christmas Eve Eve";
  }
    if(a==22){
    cout<<"Christmas Eve Eve Eve";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int ans = Y + 2 * Z, ans1 = 1;
  while(true){
    ans += Y + Z;
    if(ans <= X){
      ans1++;
    }
    else break;
  }
  cout << ans1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int aaa(int a){
  int i,ans=1;
  FOR(i,1,a+1)ans*=i;
  return ans;
}

int main(){
  int N,i,j,p=0,q=0,pp,qq,ans=0;
  scanf("%d",&N);
  int P[N],Q[N],pflag[9]={0},qflag[9]={0};
  FOR(i,0,N)scanf("%d",&P[i]);
  FOR(i,0,N)scanf("%d",&Q[i]);
  FOR(i,0,N){
    pp=P[i],qq=Q[i];
    pflag[P[i]]=1;
    FOR(j,1,P[i])if(pflag[j]==1)pp--;
    p+=pp*aaa(N-i-1);
    qflag[Q[i]]=1;
    FOR(j,1,Q[i])if(qflag[j]==1)qq--;
    q+=qq*aaa(N-i-1);
  }

  printf("%d\n",abs(p-q));
	return 0;
}


Measured memory_bytes: 128
#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>;

vector<string> BubbleSort(vector<int>& A, vector<string> C, int N){
    for (int i=0; i<N; i++){
        for (int j=N-1; j>0; j--){
            if (A[j]<A[j-1]){
                int Aj_tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = Aj_tmp;
                                
                string Cj_tmp = C[j];
                C[j] = C[j-1];
                C[j-1] = Cj_tmp;
            }
        }
    }
    return C;
}

vector<string> SelectionSort(vector<int>& A, vector<string> C, int N){
    for(int i=0; i<N;i++){
        int minj = i;
        for (int j=i; j<N;j++) {
            if(A.at(minj) > A.at(j)) minj = j;
        }
        if (A.at(i) != A.at(minj)){
            int Ai_tmp = A.at(i);
            A.at(i) = A.at(minj);
            A.at(minj) = Ai_tmp;

            string Ci_tmp = C.at(i);
            C.at(i) = C.at(minj);
            C.at(minj) = Ci_tmp;
        }
    }
    return C;
}

bool isStable(vector<string> in, vector<string> out, int N){
    for (int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            for (int a=0; a<N; a++){
                for (int b=a+1; b<N; b++){
                    if (in.at(i).at(1)==in.at(j).at(1) && in.at(i)==out.at(b) && in.at(j) == out.at(a)){
                        return false;
                    }
                }
            }       
        }
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    vector<string> Card(N),Card_out(N); 
    vector<char> Char(N);
    vector<int> Num_1(N), Num_2(N);
    for (int i=0;i<N;i++) {
        cin >> Card.at(i);
        Char.at(i) = Card.at(i).at(0);
        Num_1.at(i) = (int)(Card.at(i).at(1) - '0');
        Num_2.at(i) = (int)(Card.at(i).at(1) - '0');
    }

    Card_out = BubbleSort(Num_1, Card, N);
    for (int i=0; i<N; i++){
        cout << Card_out.at(i);
        if (i==N-1) break;
        cout << ' ';
    }
    cout << endl;
    if (isStable(Card, Card_out, N)) cout << "Stable" << endl;
    else cout << "Not Stable" << endl;

    Card_out = SelectionSort(Num_2, Card, N);
    for (int i=0; i<N; i++){
        cout << Card_out.at(i);
        if (i==N-1) break;
        cout << ' ';
    }
    cout << endl;
    if (isStable(Card, Card_out, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <cstdlib>
#include <cctype>
#include <cstdio>

using namespace std;

int main() {
    string s;
    stack<double> St;
    double a, b;
    while (getline(cin, s)) {
        stringstream ss(s);

        while (ss >> s) {
            if (s == "+") {
                b = St.top(); St.pop();
                a = St.top(); St.pop();
                St.push(a+b);
            }
            else if (s == "-") {
                b = St.top(); St.pop();
                a = St.top(); St.pop();
                St.push(a-b);
            }
            else if (s == "*") {
                b = St.top(); St.pop();
                a = St.top(); St.pop();
                St.push(a*b);
            }
            else if (s == "/") {
                b = St.top(); St.pop();
                a = St.top(); St.pop();
                St.push(a/b);
            }
            else {
                St.push(atoi(s.c_str()));
            }
        }
        printf("%.6f\n", St.top());
        St.pop();
    }
    return 0;
}

Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
//再帰関数
void f(string s,string t,int a,bool &flag){
  int n,b,i;
  string u="",v;
  n=s.length();
  if(n==0){
    if(a==7 && flag==false) {
      cout<<t<<"="<<a<<endl;
      flag=true;
    }
  }
  else if(t==""){
    t=s.at(0);
    a=s.at(0)-'0';
    for(i=1;i<n;i++) u+=s.at(i);
    f(u,t,a,flag);
  }
  else {
    for(i=1;i<n;i++) u+=s.at(i);
    v=t+'+';
    v+=s.at(0);
    b=a+(s.at(0)-'0');
    f(u,v,b,flag);
    v=t+'-';
    v+=s.at(0);
    b=a-(s.at(0)-'0');
    f(u,v,b,flag);
  }
}
int main(){
  string s;
  bool flag;
  cin>>s;
  f(s,"",0,flag);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  string a = "";
  string b = "";
  bool isreverse = false;

  int Q;
  cin >> Q;
  for (int loop = 0; loop < Q; ++loop) {
    int t;
    cin >> t;
    if (t == 1) {
      isreverse = !isreverse;
    } else {
      int f;
      char t;
      cin >> f >> t;
      if (f == 1 && !isreverse) a = a + t;
      else if (f == 1 && isreverse) b = b + t;
      else if (f == 2 && !isreverse) b = b + t;
      else if (f == 2 && isreverse) a = a + t;
    }
  }
  string ans = "";
  if (!isreverse) {
    reverse(a.begin(), a.end());
    ans = a + s + b;
  } else {
    reverse(b.begin(), b.end());
    reverse(s.begin(), s.end());
    ans = b + s + a;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n),c(n);
    rep(i,n){
        ll x;
        cin >> x;
        p[i] = x-1;
    }
    rep(i,n) cin >> c[i];

    ll sum=0;
    rep(i,n) sum += c[i];

    vector<vector<ll>> sim(n,vector<ll>(n+1));
    rep(i,n)rep(j,n+1) sim[i][j] = 0;

    //最初iマス目に置いた場合
    rep(i,n){
        //j回操作を繰り返した場合
        ll pos=i;
        for(ll j=0;j<n;j++){
            pos = p[pos];
            sim[i][j+1] = sim[i][j] + c[pos];
        }
    }
/*
  	rep(i,n){
        for(ll j=1;j<n+1;j++){
            cout << sim[i][j] << " ";
        }
      cout << endl;
    }
*/

    ll ans=-1e18;
    rep(i,n){
        // 頂点iから始まるサイクルを1周分調べる
        int pos = i;
        vector<ll> s;
        ll sum=0;
        while(true){
            pos = p[pos];
            s.push_back(c[pos]);
            sum += c[pos];
            if(pos == i) break;
        }

        //サイクルをどこまで進めるべきかを探索
        int len=s.size();
        ll tmp=0;
        rep(j,len){
            tmp += s[j];
            //サイクルの個数 > kならループしない
            if(j+1 > k) break;
            ll now = tmp;
            if(sum > 0){
                ll times = (k-(j+1))/len;
                now += times * sum;
            }
            ans = max(ans,now);
        }

    }

    cout << ans << endl;

    return(0);
}

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


int g[15][15];
int main() {
  int n;
  cin >> n;
  rep(i,n) rep(j,n) g[i][j] = -1;
  rep(i,n) {
    int m;
    cin >> m;
    rep(j,m) {
      int a, x;
      cin >> a >> x;
      --a;
      g[i][a] = x;
    }
  }
  int ans = 0;
  rep(i,1<<n) {
    std::vector<int> d(n);
    rep(j,n) if (i>>j&1) {
      d[j] = 1;
    }
    bool ok = true;
    rep (j,n) {
      if (d[j]) {
        rep(k,n) {
          if (g[j][k] == -1) continue;
          if (g[j][k] != d[k]) ok = false;
        }
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
  return 0;
}


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

bool check(char a){return (a=='a'||a=='i'||a=='u'||a=='e'||a=='o');}

string mk_code(string a){
  string res;
  res+=a[0];
  for(int i=1;i<(int)a.size();i++)if(check(a[i-1]))res+=a[i];
  return res;
}

int main(){
  int n;
  while(cin>>n,n){
    string str[101];
    int size=0;
    for(int i=0;i<n;i++){
      cin>>str[i];
      str[i]=mk_code(str[i]);
      size=max(size,(int)str[i].size());
    }
    
    int ans=0;
    for(int i=1;i<=size&&!ans;i++){
      set <string> S;
      ans=i;
      for(int j=0;j<n;j++){
	string a=str[j].substr(0,min(i,(int)str[j].size()));
	ans*=!S.count(a);
	S.insert(a);
      }
    }
    cout <<(ans? ans:-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll max = a*c;
  if(max < a*d) max = a*d;
  if(max < b*c) max = b*c;
  if(max < b*d) max = b*d;
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		if(s.equals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}

		sc.close();

	}

}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


int main() {
    long long X;
    scanf("%lld", &X);
    long long N;
    scanf("%lld", &N);

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

    else {
        std::vector<long long> p(N);
        for (ll i = 0; i < N; i++) {
            cin >> p.at(i);
        }

        set<ll> set;

        for (ll i = 0; i < N; i++) {
            set.insert(p.at(i));
        }

        for (ll i = 0; i <= N; i++) {
            if (set.count(X - i) == 0 || set.count(X + i) == 0) {
                if (set.count(X - i) == 0 && i != 0) {
                    cout << X - i << endl;
                    break;
                }

                else if (set.count(X + i) == 0 && i != 0) {
                    cout << X + i << endl;
                    break;
                }

                else if (i == 0) {
                    cout << X << endl;
                    break;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long n,i,c=0;
 cin>>n;
 int j=1;
while(n--)
{
  cin>>i;
  if(i%2==1 && j%2==1) c++;
  j++;
}
cout<<c<<endl;

}


Measured memory_bytes: 3568
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final long N = Long.parseLong(sc.next());
        final long A = Long.parseLong(sc.next());
        final long B = Long.parseLong(sc.next());
        sc.close();

        long ans = 0;
        if (A%2==B%2) {
            ans = (B-A)/2;
        } else {
            ans = Math.min(A-1, N-B) + 1 + (B-A)/2;
        }

        System.out.println(ans);
    }
}

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

ans = [-1, -1, -1]
for i in range(n+1):
    for j in range(n+1-i):
        if 10000 * i + 5000 * j + 1000 * (n-i-j) == y:
            ans = [i, j, n -i-j]
            
print(' '.join(map(str, ans)))

Measured memory_bytes: 3060