akhauriyash/Code-Regression huggingface dataset:
import math

a, b, x = map(int, input().split())

def calc(theta):
    h = math.tan(theta) * a
    if h <= b:
        s = 1 / 2 * a * a * h
    else:
        c = h - b
        s = 1 / 2 * a * a * h
        s = s - s * ((c / h) ** 2)
    return s

l, r = 0.0, math.pi / 2
while abs(r - l) > 1e-12:
    m = (l + r) / 2
    rem = a * a * b - calc(m)
    if rem >= x:
        l = m
    else:
        r = m
print(l * 180 / math.pi)

Measured memory_bytes: 38512
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
vector<pair<string, pair<ll, ll>>> V;
string S = "";
ll val = 0;

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		cin >> S;
		scanf("%lld", &val);
		V.push_back(make_pair(S, make_pair(-val, i + 1)));
	}
	sort(V.begin(), V.end());
	for(int i = 0; i < V.size(); i++) {
		cout << V[i].second.second << "\n"; 
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

class Main {
	static final String YES = "YES";
	static final String NO = "NO";

	public static void main(String[] args) {
		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			int[] ball = new int[10];
			while (sc.hasNextInt()) {
				int dataset = sc.nextInt();

				for (int i = 0; i < dataset; i++) {
					for (int j = 0; j < 10; j++) {
						ball[j] = sc.nextInt();
					}

					System.out.println(push(ball));
				}
			}
		} finally {
			sc.close();
		}
	}

	public static String push(int[] ball) {
		Stack<Integer> stack1 = new Stack<Integer>();
		Stack<Integer> stack2 = new Stack<Integer>();

		for (int number : ball) {
			if (stack1.isEmpty() || stack1.peek() < number) {
				stack1.push(number);
			} else if (stack2.isEmpty() || stack2.peek() < number) {
				stack2.push(number);
			} else {
				return NO;
			}
		}
		return YES;
	}
}

Measured memory_bytes: 26460
/*
  セグメント木
  コンストラクタには要素数を渡す
  * 根 : 1
  * 左からx番目の葉 : x+N
  * iの親のindex : i/2
  * iの子のindex : i*2+0, i*2+1
  * iの兄弟(sibling) : i^1
  * iの深さ(depth) : log_2 iの整数部分
  * iの区間幅(width) : N/highest(i)
  * iの区間の左端 : (i-highest(i))*width(i)
  */

#include <vector>
#include <iostream>

using namespace std;
typedef long long ll;

typedef ll dat_t;
dat_t const init = 0;
struct segment_tree {
    vector<dat_t> dat;
    int n;
    segment_tree(int n_){
        n = 1;
        while(n < n_) n<<=1;
        dat.resize(n*2);
        for(int i=n; i<n+n; i++){
            dat[i] = init; // initをdat[i]にするとvectorからのコンストラクタになる
        }
        for(int i=n-1; i>=1; i--){
            dat[i] = dat[i<<1] + dat[i<<1|1];
        }
    }
    // bottom-up
    void add(int k, dat_t x){
        int i = n+k; // leaf
        dat[i] += x;
        while(i != 1){ // 1 is root
            dat[i>>1] = dat[i] + dat[i^1];
            i>>=1;
        }
    }
    // top-down
    dat_t get(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return dat[k];
        dat_t v1 = get(a,b,k<<1,l,(l+r)/2);
        dat_t v2 = get(a,b,k<<1|1,(l+r)/2,r);
        return v1 + v2;
    }
    dat_t get(int a, int b){
        return get(a,b,1,0,n);
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    segment_tree t(n);
    while(q--){
        ll a,b,c;
        cin >> a >> b >> c;
        if(a==0){
            b--;
            t.add(b,c);
        } else {
            b--; c--;
            cout << t.get(b,c+1) << endl;
        }
    }
}

Measured memory_bytes: 3108
#include <iostream>

using namespace std;
using int64 = long long;

int main() {
    int n,k;
    cin >> n >> k;

    int64 ans = 0;
    for (int i=1; i<=n; i++) {
        if (i <= k) continue;
        ans += (n/i) * (i-k);
        ans += max(0, n%i - k + 1);
        if (k == 0) ans--;
    }

    cout << ans << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<char> D(N);

    REP(i, N){
        cin >> D[i];
    }

    for(ll i=N; i<=N*10; i++){
        string s = to_string(i);

        bool check = true;
        REP(j, s.length()){
            for(auto d: D){
                if(s[j] == d){
                    check = false;
                    break;
                }
            }
            if(check == false) break;
        }
        if(check){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
res = 0
for i in range(0,n):
    res += b[a[i]-1]
    if i != 0 and a[i-1]==a[i]-1:
        res += c[a[i-1]-1]

print(res)

Measured memory_bytes: 3064
gcd(int i, int j) {
    return j == 0 ? i : gcd(j, i % j);
}
main() {
    int a, b, c, k, ans = 0;
    scanf("%d", &k);
    for(a = 1; a <= k; ++a)
    for(b = 1; b <= k; ++b)
    for(c = 1; c <= k; ++c) 
    ans += gcd(gcd(a, b), c);
    printf("%d\n", ans);
}


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

int main() {
  int n,m,x,y;
  cin >>n>>m>>x>>y;
  vector<int>a(n),b(m);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0;i<m;i++)cin>>b[i];
  sort(b.begin(),b.end());
  for(int i=x+1;i<=y;i++){
    if(a[n-1]<i&&i<=b[0]){
      //cout<<a[n-1]<<" "<<i<<" "<<b[0]<<endl;
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>
#include <cstdio>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

int n;

void solve(){
  cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;i++)cin >> x[i];
  int mx=*max_element(x.begin(),x.end());
  int mn=*min_element(x.begin(),x.end());
  int ans=10000;
  int t,tmp;
  for(int i=mn;i<=mx;i++){
    t=0;
    tmp=-1;
    for(int j=0;j<n;j++){
      t=abs(i-x[j]);
      tmp=max(t,tmp);
    }
    ans=min(ans,tmp);
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}



Measured memory_bytes: 3124
n, a, b, c = map(int, input().split())
s = [input() for _ in range(n)]

can = 'Yes'
ans = []
val = {'A': a, 'B': b, 'C': c}
if a+b+c == 0:
    can = 'No'
elif a+b+c == 1:
    for ss in s:
        v1, v2 = ss[0], ss[1]
        if val[v1] == val[v2] == 0:
            can = 'No'
            break
        val[v1], val[v2] = val[v2], val[v1]
        ans.append(v1) if val[v1] else ans.append(v2)
else:
    for i in range(n):
        v1, v2 = s[i][0], s[i][1]
        if val[v1] == val[v2] == 0:
            can = 'No'
            break
        if a+b+c == 2 and val[v1] == val[v2] == 1 and i != n-1 and s[i] != s[i+1]:
            if v1 in s[i+1]:
                val[v1] += 1
                val[v2] -= 1
                ans.append(v1)
            else:
                val[v2] += 1
                val[v1] -= 1
                ans.append(v2)
        else:
            if val[v1] < val[v2]:
                val[v1] += 1
                val[v2] -= 1
                ans.append(v1)
            else:
                val[v2] += 1
                val[v1] -= 1
                ans.append(v2)

print(can)
if can == 'Yes':
    print('\n'.join(ans))


Measured memory_bytes: 17432
/*
	0015:National Budget
*/
#include	<iostream>
#include	<string>
#include	<iterator>

using namespace std;

int main(void) {
	int n;
	
	cin >> n;
	for(int i = 0; i < n; i++) {
		string num1, num2, result;
		bool isMoveUp = false;
		
		cin >> num1 >> num2;
		string::reverse_iterator st1 = num1.rbegin();
		string::reverse_iterator st2 = num2.rbegin();
		while( st1 != num1.rend() || st2 != num2.rend()) {
			char buf1 = st1 != num1.rend() ? (*st1) : '0';
			char buf2 = st2 != num2.rend() ? (*st2) : '0';
			int buf3 = (buf1 - '0') + (buf2 - '0');
			
			isMoveUp = false;
			if(buf3 >= 10) {
				isMoveUp = true;
				(*(st1+1))++; buf3 -= 10;
			}
			result += (buf3 + '0');
			if(st1 != num1.rend()) { st1++; }
			if(st2 != num2.rend()) { st2++; }
		}
		if(isMoveUp) { result += '1'; }
		if(result.size() > 80) { cout << "overflow" << endl; continue; }
		string::reverse_iterator rt = result.rbegin();
		while(rt != result.rend()) {
			cout << (*rt);
			rt++;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
def gcd(m, n):
    if n == 0:
        return m

    return gcd(n, m%n)


if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))


    l = [0]*(n+1)
    r = [0]*(n+1)
    m = [0]*n

    for i in range(n):
        l[i+1] = gcd(l[i], a[i])
    a = list(reversed(a))
    for i in range(n):
        r[i+1] = gcd(r[i], a[i])
    r = list(reversed(r))
    for i in range(n):
        m[i] = gcd(r[i+1], l[i])

    print(max(m))


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int freq[128];
int len;
char str[200005];
long long ans;

int main(){
	scanf("%s", str);
	len = strlen(str);
	ans = 1;
	for(int i = 0; i < len; i++){
		ans += i - freq[str[i]];
		freq[str[i]]++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i==0 || j==0 || i==H-1 || j==W-1){
                        System.out.printf("#");
                    }else{
                    System.out.printf(".");
                    }
                }
                System.out.printf("\n");
        }
        System.out.printf("\n");
    }
}
}


Measured memory_bytes: 60104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(ll a, ll b){
    cout << a << " " << b << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    ll n = SZ(s);
    rep(i, n-1){
        if(s[i] == s[i+1]){
            pr(i+1, i+2);
        }
    }
    rep(i, n-2){
        if(s[i] == s[i+2]){
            pr(i+1, i+3);
        }
    }
    pr(-1, -1);
    return 0;
}

Measured memory_bytes: 512
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var S = input[1].split(" ")[0];
  var K = parseInt(input[2].split(" ")[0]);

  var S_n = [];
  var S_K = S[K-1];

  for(var i=0; i<N ; i++){
    if(S[i] == S_K){
      S_n[i]=S_K;
    }else{
      S_n[i]="*";
    }
  }
  console.log(S_n.join(""));

}

var input=Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// var input=`6
// eleven
// 5`
// Main(input);


Measured memory_bytes: 7372
A, B, C, X, Y = map(int, input().split())

price = 0

m = min(A + B , C * 2)
n = min(X, Y)
price += m * n

d = max(X, Y) - min(X, Y)
if d != 0:
    if X > Y:
        price += min(A, C * 2) * d
    else:
        price += min(B, C * 2) * d

print(price)

Measured memory_bytes: 9104
// ダイクストラのアルゴリズム
package main

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

type color int

const (
	white color = iota // 未訪問
	mst                // MSTとして確定
)

// 頂点
type node struct {
	num       int         // 頂点の番号
	weights   map[int]int // 重みMAP
	parent    *node       // MSTへの重み最小の親
	distFromS int         // 始点からの距離
	color     color
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	n := eGetInt(scanner)

	nodes := make([]*node, n)
	for i := 0; i < n; i++ {
		weights := eAtoi((strings.Fields(eGetline(scanner))))
		v := &node{weights[0], make(map[int]int, weights[1]), nil, math.MaxInt32, white}
		for j := 0; j < weights[1]; j++ {
			k := weights[j*2+2] // 相手の頂点名
			w := weights[j*2+3] // 重み
			v.weights[k] = w
		}
		nodes[i] = v
	}

	// 初回はnode[0]がMSTに入るように
	nodes[0].distFromS = 0

	for { // 全部チェックするまで

		// どの頂点を新たにMSTに取り込むか

		var minNode *node
		min := math.MaxInt32
		for _, v := range nodes {
			if v.color == mst {
				continue
			}
			if v.distFromS < min {
				min = v.distFromS
				minNode = v
			}
		}
		if minNode == nil {
			// すべて完了している.
			break
		}

		// MSTに追加する頂点決定
		minNode.color = mst

		// fmt.Printf(">[%v]\n", minNode)
		// MSTに属していない頂点それぞれについて,Startからの最小の重みの距離を更新
		for i, v := range nodes {
			if v.color == mst {
				continue
			}
			w, ok := minNode.weights[i]
			if !ok {
				// minNodeと接してない
				continue
			}

			if minNode.distFromS+w < v.distFromS {
				// minNode経由の距離がもっとも重みが少ないので親を変更
				v.distFromS = minNode.distFromS + w
				v.parent = minNode
				// fmt.Printf("[%v %v]\n", v, minNode)
			}
		}
		// fmt.Printf("<\n")
	}

	for i, v := range nodes {
		fmt.Printf("%d %d\n", i, v.distFromS)
	}
}

func eGetInt(scanner *bufio.Scanner) int {
	t := eAtoi(strings.Fields(eGetline(scanner)))
	return t[0]
}

func eGetline(p *bufio.Scanner) string {
	if !p.Scan() {
		if err := p.Err(); err != nil {
			log.Fatal(err.Error())
		}
		return ""
	}
	return p.Text()
}

func eAtoi(s []string) []int {
	ints := make([]int, len(s))
	var err error
	for i, e := range s {
		ints[i], err = strconv.Atoi(e)
		if err != nil {
			log.Fatal(err.Error())
		}
	}
	return ints
}



Measured memory_bytes: 1664
#include <stdio.h>

int main(void){
  int i,n;
  int mon;

  scanf("%d",&n);
  mon=100000;
  for(i=0;i<n;i++){
    mon *= 1.05;
    if(mon % 1000 != 0){
      mon /= 1000;
      mon *= 1000;
      mon += 1000;
    }
  }

  printf("%d\n",mon);

  return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long


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

    int Y = 5 * 20 + 5 * 19;
    int Y_3 = 10 * 20;
    int ml = 0;
    for(int i=1; i<=999; ++i) {
        if(i%3==0) ml += Y_3;
        else ml += Y;
    }
    ml += 1;
    while(n--) {
        int y, m, d;
        cin >> y >> m >> d;
        int cur = 0;
        for(int i=1; i<y; ++i) {
            if(i%3==0) cur += Y_3;
            else cur += Y;
        }
        if(y%3!=0) {
            for(int j=1; j<m; ++j) {
                if(j%2==1) cur += 20;
                else cur += 19;
            }
        } else cur += (m-1)*20;
        cur += d;
        cout << ml-cur << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	ll b = 0, c = 0;
	int k = 0;
	REP(i, n-1) {
		if (a[i] == a[i + 1]) {
			b = a[i];
			k = i;
			break;
		}
	}
	for (int i = k + 2; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			c = a[i];
			break;
		}
	}
	cout << b * c << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }
  sort(all(p));

  vector<int> q(n);
  rep(i,n){
    q[i]=abs(n-1-2*i);
  }
  sort(all(q));

  if(p!=q){
    cout << 0 << endl;
    return 0;
  }

  cout << jou(2,n/2) << endl;

}

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

int main(void) {
	string str;
	int start, end, x;
	int sum = 0;
	
	while(cin >> str) {
		int i = 0;
		while(i < str.length()) {
			if('0' <= str[i] && str[i] <= '9') {
				start = i;
				while('0' <= str[i] && str[i] <= '9') {
					end = i;
					++i;
				}
				x = 1;
				for(int j = end; j >= start; --j) {
					sum += (str[j] - '0') * x;
					x *= 10;
				}
			}
			++i;
		}
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] d = new int[N];
		for (int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}
		
		Arrays.sort(d);
		
		int cnt = 0;
		int prev = 0;
		for (int i : d) {
			if (prev < i) {
				cnt++;
			}
			prev = i;
		}
		
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;
const int MAX_N = (1 << 17)+1;
struct Node{
	int mini,lazy;
	Node():mini(INT_MAX),lazy(INT_MAX){
	}
};
struct RUQ{
	int n;
	Node dat[MAX_N*2 - 1];
	//n?????????????????¨?????¨????????????
	void init(int n_){
		n = 1;
		while(n<n_)n*=2;//n????????????????????§????????¨update????????°???
	}
	//?????¶??????????????????
	inline void push(int k){
		if(dat[k].lazy == -1)return;
		dat[k].mini = dat[k].lazy;
		if(k<n-1){
			dat[2*k+1].lazy = dat[k].mini;
			dat[2*k+2].lazy = dat[k].mini;
		}
		dat[k].lazy = -1;
	}
	//?????§?°???????????????????
	inline void update_node(int k){
		dat[k].mini = min(dat[2*k+1].mini,dat[2*k+2].mini);
	}
	//[a,b)?????????x????????´(c)
	inline void update(int a,int b,int x,int k,int l,int r){
		push(k);
		if(r <= a || b <= l)return;
		if(a <= l && b >= r){
			dat[k].lazy = x;
			push(k);return;
		}else{
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
			update_node(k);
		}
	}
	//[a,b)???????°?????????????
	int query(int a,int b,int k,int l,int r){
		push(k);
		if(r<=a||b<=l)return INT_MAX;
		if(a <=l&&b>=r)return dat[k].mini;
		int lb = query(a,b,k*2+1,l,(l+r)/2);
		int rb = query(a,b,k*2+2,(l+r)/2,r);
		update_node(k);
		return min(lb,rb);
	}
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,q;
	cin >> n >> q;
	RUQ ruq;ruq.init(n);
	REP(i,q){
		int q;
		cin >> q;
		if(q){
			int a,b;cin >>a>>b;
			cout << ruq.query(a,b+1,0,0,ruq.n) << endl;
		}else{
			int a,b,x;
			cin >> a>>b>>x;
			ruq.update(a,b+1,x,0,0,ruq.n);
		}
	}
  return 0;
}

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

int main() {
    /* Input */
    int s, w;
    cin >> s >> w;

    if (s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t;
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[maxn],ma,vis[maxn];
bool flag;
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)scanf("%d",&a[i]),vis[a[i]]++,ma=max(ma,a[i]);
    if(ma%2==0)
    {
        rep(i,1,ma/2-1)if(vis[i])flag=true;
        rep(i,ma/2,ma)
        {
            if(i==ma/2)
            {
                if(vis[i]!=1)flag=true;
            }
            else if(vis[i]<2)flag=true;
        }
    }
    else
    {
        rep(i,1,(ma+1)/2-1)if(vis[i])flag=true;
        rep(i,(ma+1)/2,ma)
        {
            if(i<(ma+1)/2&&vis[i])flag=true;
            if(i==(ma+1)/2)
            {
                if(vis[i]!=2)flag=true;
            }
            else if(vis[i]<2)flag=true;
        }
    }
    if(flag)puts("Impossible");
    else puts("Possible");
    //system("Pause");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  lint ten = 1;
  lint nine = 1;
  lint eight = 1;
  REP(i, N) ten = ten * 10 % MOD;
  REP(i, N) nine = nine * 9 % MOD;
  REP(i, N) eight = eight * 8 % MOD;
  lint ans = (ten - 2 * nine + eight + 2 * MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<int> nums;
vector<int> use;
/* function */
void rec(int n, int d) {
    if (d == 6) { return ; }
    nums.push_back(n);
    int x = n * 10;
    for (int u : use) { rec(x + u, d + 1); }
}
/* main */
int main(){
    int N, K, k;
    cin >> N >> K;
    vector<int> can(10, 1);
    for (int i = 0; i < K; i++) { cin >> k; can[k] = 0; }
    for (int i = 0; i < 10; i++) if (can[i]) use.push_back(i);

    rec(0, 0);
    sort(nums.begin(), nums.end());
    cout << *lower_bound(nums.begin(), nums.end(), N) << '\n';
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	if(n < 10) {
		if(n == 2||n==4||n==5||n==7||n==9)
			cout << "hon" << endl;
		else if(n ==0||n==1||n==6||n==8)
			cout << "pon" << endl;
		else cout << "bon" << endl;
		return 0;
	}
	n = n%10;
 	if(n == 2||n==4||n==5||n==7||n==9)
			cout << "hon" << endl;
	else if(n ==0||n==1||n==6||n==8)
			cout << "pon" << endl;
	else cout << "bon" << endl;
	
	return 0;
}



Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 300100;
const ll MOD = 1e9 + 7;

int n;
ll arr[MAXN], ans;
ll dig[100];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= 61; j++)
			dig[j] += (bool)(arr[i] & (1ll << j));
	}
	for(int i = 0; i <= 61; i++)
		ans = (ans + (((dig[i] * (n - dig[i])) % MOD) * ((1ll << i) % MOD)) % MOD) % MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#from pprint import pprint
#import itertools
#from collections import deque
#
#list(map(int,input().split()))
#int(input())

a,b,c,k = map(int,input().split())

#print(a,b,c,k)

#abc = [1]*a + [0]*b + [-1]*c
#print(abc)

result = 0

if k <= a:
    print(k)
elif a < k <= a+b:
    print(a)
elif a+b <= k:
    print(a-(k-a-b))





Measured memory_bytes: 61596
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto abc = readints;
    int k = readint;

    abc.sort();
    int x = abc[$-1];
    int sum = abc[0] + abc[1] + x * (2 ^^ k);
    writeln(sum);
}


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

using Lint=long long;

int main()
{
        int N; cin>>N;
        vector<int> a(N);
        for(int i=0;i<N;i++) cin>>a[i];

        Lint ans=a[0]-1;
        int mx=1;
        for(int i=1;i<N;i++){
                if(a[i]==mx+1){
                        mx++;
                }else{
                        ans+=(a[i]-1)/(mx+1);
                }
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 640
x = int(input())
max_x = 100003
f = [0 for _ in range(max_x+1)]
f[0] = -1
f[1] = -1
primes = []
for i in range(2, max_x+1):
    if f[i]:
        continue
    primes.append(i)
    f[i] = i
    for j in range(i*i, max_x+1, i):
        if f[j] == 0:
            f[j] = i

for p in primes:
    if x <= p:
        print(p)
        break


Measured memory_bytes: 4228
#include <cstdio>
#define R(i, n) for(int i = 0;i < n;i++)
#define RR(i, n) for(int i = n;i >= 0;i--)
#define F(i, m, n) for(int i = m;i < n;i++)
#define FR(i, m, n) for(int i = m; i >= n; i--)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
using namespace std;


int H, A;

int main() {
	S2(H, A);
	int a = H / A;
	int amari = H % A;
	if (amari == 0) P(a);
	else P(a + 1);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int n; cin>>n;
    int a[n][26]={};

    rep(i,n){
        string s; cin>>s;
        int m=s.size();
        rep(j,m){
            a[i][s[j]-'a']++;
        }
    }

    rep(i,26){
        int ans=a[0][i];
        rep(j,n){
            if(ans>a[j][i]) ans=a[j][i];
        }
        rep(j,ans){
            char c=i+'a';
            cout<<c;
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

bool compare(pair<P, int> a, pair<P, int> b){
    if(a.first.first != b.first.first){
        return a.first.first > b.first.first;
    }
    return a.first.second < b.first.second;
}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }

    vector<P> aa, bb;
    rep(i, n){
        aa.emplace_back(a[i] + b[i], i);
    }
    sort(ALL(aa), greater<P>());

    int ans = 0;
    rep(i, n){
        if(i % 2 == 0){
            ans += a[aa[i].second];
        }else{
            ans -= b[aa[i].second];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3956
//Largest Square
#include <iostream>
#include <stack>
#include <algorithm>

using namespace std;

static const int MAX = 1400;

struct Rectangle {
public:
    int height, pos;
    Rectangle(int height, int pos): height(height), pos(pos) {}
};

int G[MAX][MAX];
int H, W;

int getLargestRectangle() {
    stack<Rectangle> S;
    int dp[H][W];
    int maxArea = 0;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            dp[i][j] = (G[i][j] + 1) % 2;
            if(i != 0 && dp[i][j] != 0) dp[i][j] += dp[i - 1][j];
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            Rectangle rect = Rectangle(dp[i][j], j);
            if(S.empty()) S.push(rect);
            else {
                if(S.top().height < rect.height) {
                    S.push(rect);
                } else if(S.top().height > rect.height) {
                    int target = j;
                    while(!S.empty() && S.top().height > rect.height) {
                        maxArea = max(maxArea, (j - S.top().pos) * S.top().height);
                        target = S.top().pos;
                        S.pop();
                    }
                    S.push(Rectangle(rect.height, target));

                }
            }
        }
        while(!S.empty()) {
            maxArea = max(maxArea, (W - S.top().pos) * S.top().height);
            S.pop();
        }
    }
    return maxArea;

}

int main() {
    int c;
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) cin >> G[i][j];
    }

    cout << getLargestRectangle() << endl;
}



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

struct Node{
   int key;
   Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
   Node *y=NIL;
   Node *x=root;
   Node *z=new Node;

   z->key=k;
   z->left=NIL;
   z->right=NIL;

   while(x!=NIL){
      y=x;
      if(z->key < x->key) x=x->left;
      else x=x->right;
   }
   
   z->parent=y;
   if(y==NIL) root=z;
   else{
      if(z->key<y->key) y->left=z;
      else y->right=z;
   }
}

Node *find(Node *u, int k){
   while(u!=NIL && k!=u->key){
      if(k<u->key) u=u->left;
      else u=u->right;
   }
   return u;
}

void inorder(Node *u){
   if(u==NIL) return;
   inorder(u->left);
   cout << " " << u->key;
   inorder(u->right);
}

void preorder(Node *u){
   if(u==NIL) return;
   cout << " " << u->key;
   preorder(u->left);
   preorder(u->right);
}

int main(){
   int n, x;
   string com;
   cin >> n;

   for(int i=0; i<n; i++){
      cin >> com;
      if(com=="insert"){
         cin >> x;
         insert(x);
      }
      else if(com=="print"){
         inorder(root);
         cout << endl;
         preorder(root);
         cout << endl;
      }
      else if(com[0]=='f'){
         cin >> x;
         Node *t=find(root, x);
         if(t!=NIL) cout << "yes" << endl;
         else cout << "no" << endl;
      }
   }

   return 0;
}


Measured memory_bytes: 21764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] p = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
        int[] dp = new int[n+1];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < p.length; j++) {
                if (i+p[j] > n) {
                    break;
                }

                if (dp[i+p[j]] == 0) {
                    dp[i+p[j]] = dp[i]+1;
                } else {
                    dp[i+p[j]] = Math.min(dp[i+p[j]], dp[i]+1);
                }
            }
        }

        System.out.println(dp[n]);
    }
}


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

using namespace std;

typedef long long int lli;

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

    int n, h[100000];

    cin >> n;
    for (int i=0; i<n; i++) cin >> h[i];

    int cont = 0, ans = 0;
    for (int i=0; i<n-1; i++) {
        if (h[i] >= h[i+1]) ans = max(ans, ++cont);
        else cont = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll h;
  cin>>h;
  ll ans=0,cnt=0;
  while(h>=1){
    ans+=pow(2,cnt);
    cnt++;
    h/=2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4036
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char S[2000020];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fread(S, 1, 2000020, stdin);

	char* c = S, ct;
	int N = 0;
	
	while ((ct = *c++) >= '0') N = N * 10 + ct - '0';

	int L = 0, R = 2000001;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (*(c + M) >= ' ') L = M;
		else R = M;
	}

	if (*c == '0') {
		printf("0\n");
		return 0;
	}

	for (char* d = c; d < c + R - 8; d += 7) {
		ll tmp = *(ll*)(d);
		tmp += 0x1010101010101010;
		tmp ^= 0xcfcfcfcfcfcfcfcf;

		ll tmp2 = tmp + 0x0001000100010001;
		if ((tmp2 << 1 ^ tmp2) & 0x2000200020002000) {
			printf("0\n");
			return 0;
		}
		tmp2 = tmp + 0x0000010001000100;
		if ((tmp2 << 1 ^ tmp2) & 0x0020002000200000) {
			printf("0\n");
			return 0;
		}
	}

	for (char* d = c + max(0, R - 10); d < c + R; d++) {
		if (*d == ' ' && *(d + 1) == '0') {
			printf("0\n");
			return 0;
		}
	}

	if (R >= N * 2 + 18) {
		printf("-1\n");
		return 0;
	}

	ll kotae = 1;
	auto owa = c + R;
	while (c < owa) {
		ll tmp = *(ll*)(c);
		if (tmp != 0x2031203120312031) {
			ll k = 0;
			while ((ct = *c++) >= '0') k = k * 10 + ct - '0';
			if (ll(1e18) / kotae < k) {
				printf("-1\n");
				return 0;
			}
			else kotae *= k;
		}
		else c += 8;
	}

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

	Would you please return 0;
}

Measured memory_bytes: 3256
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main() {
	int n, a, b, cnt=0 , b_cnt=0;
	string s;
	cin >> n >> a >> b >> s;
	for (int i = 0;i < n;i++) {
		if (s[i] == 'a' && cnt < a + b) {
			cnt += 1;
			cout << "Yes" << endl;
		}
		else if (s[i] == 'b' && cnt < a + b && b_cnt < b) {
			cnt += 1;
			b_cnt += 1;
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>

int mas[3][3];
int cpy[3][3];

void input() {
  int i, j;
  for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++)
      scanf("%d", &mas[i][j]);
}

void output() {
  int i, j;
  for(i = 0; i < 3; i++) {
    for(j = 0; j < 3; j++) printf("%3d", mas[i][j]);
    puts("");
  }
}

void copy(int m[3][3], int t[3][3]) {
  int i, j;

  for(i = 0; i < 3; i++)
    for(j = 0; j < 3; j++) m[i][j] = t[i][j];
}

int calc() {
  int i, sum = 0;
  for(i = 0; i < 9; i++) {
    int v = mas[i/3][i%3];
    if(v) {
      v--;
      sum += abs(i/3-v/3)+abs(i%3-v%3);
    }
  }
  return sum;
}

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

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int is_in(int x, int y) {
  return 0<=x&&x<3&&0<=y&&y<3;
}

int dfs(int x, int y, int p, int dep, const int lim) {
  int i, h = calc();
  //output();
  if(h == 0) return dep;
  //printf("%d %d %d\n", h, lim, p);
  if(dep+h > lim) return -1;

  for(i = 0; i < 4; i++) {
    int nx = x+dx[i], ny = y+dy[i], res;
    if(~p && i == (p+2)%4) continue;
    if(!is_in(nx, ny)) continue;
    swap(&mas[y][x], &mas[ny][nx]);
    res = dfs(nx, ny, i, dep+1, lim);
    if(~res) return res;
    swap(&mas[y][x], &mas[ny][nx]);
  }

  return -1;
}

void get_empty(int *x, int *y) {
  int i, j;
  for(i = 0; i < 3; i++) {
    for(j = 0; j < 3; j++) {
      if(!mas[i][j]) {
        *x = j;
        *y = i;
        return;
      }
    }
  }
}

int solve() {
  int x, y, lim, ans;
  get_empty(&x, &y);
  for(lim = 0; lim < 50; lim++) {
    copy(cpy, mas);
    if((ans = dfs(x, y, -1, 0, lim)) != -1) return ans;
    copy(mas, cpy);
  }
  return -1;
}

int main() {
  input();
  printf("%d\n", solve());
  return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int fl[300005];
int a[300005];
int main()
{
	int n;
	cin>>n;
	memset(fl,0,sizeof(fl));
	memset(a,0,sizeof(a));
	char d;
	scanf("%c",&d);
	for (int i=1;i<=n;i++)
	{
		char c;
		scanf("%c",&c);
		fl[i]=fl[i-1];
		if (c=='W')
		{
			fl[i]++;
		}
	}
	for (int i=1;i<=n;i++)
	{
		a[i]+=fl[i-1];
		a[i]+=(n-i)-(fl[n]-fl[i]);
	}
	
	int minl;
	minl=1;
	for (int i=2;i<=n;i++)
	{
		if (a[minl]>a[i])
		{
			minl=i;
		}
	}
	cout<<a[minl];
	return 0;
}

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

ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a,b);
    return a/g * b;
}

int main(){
    int n;
    cin>>n;
    ll ans = 1;
    rep(i,n){
        ll t;
        cin>>t;
        ans = lcm(ans,t);
    }
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
    int H, W, N;
    scanf("%d %d %d", &H, &W, &N);
    
    if(W >= H){
    for(int i = 1; i <= H; i++) {
        if (W * i >= N) {
            printf("%d", i);
            break;        
			}
    	}
	} 
	else {
    for(int i = 1; i <= W; i++){
        if (H * i >= N) {
            printf("%d", i);
            break;
        	}
   	 	}
	}
    return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    ll A[200200], B[200200];
    LP work[200200];
    rep(i, N) {
        cin >> A[i] >> B[i];
        work[i] = make_pair(B[i], A[i]);
    }
    ll time = 0;
    sort(work, work + N);
    rep(i, N) {
        time += work[i].sc;
        if(time > work[i].fr) {
            No();
        }
    }
    Yes();
	return 0;
}

Measured memory_bytes: 6528
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, m, a, b; cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	int t; cin >> t; rep(i, t)solve();
	//solve();
    return 0;
}

Measured memory_bytes: 3692