akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<int>prime;
vector<int>prime_;
bool used[1000005];
ll x[505][505];
ll gcd(ll a,ll b){
    if(a<b) swap(a,b);
    if(b == 0) return a;
    return gcd(b,a%b);
}
int n;
int main(){
	for(int i=2;;i++){
		if(!used[i] && i > 1001){
		    prime.pb(i);
		    if(prime.size() == 1000) break;
		}
		for(int j=2;i*j<=100000;j++) used[i*j] = 1;
	}
	int beg = 2,en = 1001;
	for(int j=0;j<1000;j++){
	    if(j%2 == 0) prime_.pb(beg++);
	    else prime_.pb(en--);
	}
	beg = 0,en = 1000;
	for(int j=0;j<1000;j++){
	    if(j%2 == 0) prime_.pb(prime[beg++]);
	    else prime_.pb(prime[en--]);
	}
	prime = prime_;
	for(int i=0;i<500;i++){
		for(int j=0;j<500;j++){
			if(i%2 != j%2) continue;
			int f = i-j+499;
			int g = i+j;
			x[i][j] = 1LL * prime[f] * prime[1000+g];
		}
	}
	ll mxx = -1;
	ll mnn = 1e18;
	set<ll>S;
	for(int i=0;i<500;i++){
		for(int j=0;j<500;j++){
			if(i%2 != j%2) continue;
			S.insert(x[i][j]);
		}
	}
	for(int i=0;i<500;i++){
		for(int j=0;j<500;j++){
			if(i%2 == j%2) continue;
			ll gcdd = 1;
				int dx[4]={0,1,0,-1};
				int dy[4]={1,0,-1,0};
				rep(k,4){
					int nx = i+dx[k],ny = j+dy[k];
					if(0<=nx&&nx<500 && 0<=ny&&ny<500){
						gcdd = gcdd / gcd(gcdd,x[nx][ny]) * x[nx][ny];
					}
				}
				x[i][j] = gcdd+1;
				while(S.find(x[i][j]) != S.end()){
				    x[i][j] += gcdd;
				}
				S.insert(x[i][j]);
				mxx = max(mxx,x[i][j]);
				mnn = min(mnn,x[i][j]);
		}
	}
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) printf("%lld ",x[i][j]);
		puts("");
	}
}

Measured memory_bytes: 16768
use strict;
my $N=<>;
my @a=split(/ /,<>);
chomp @a;
my %t;
foreach (@a){
    $t{$_}++;
}
foreach (1..$N){
    if ($t{$_}) {
        print "$t{$_}\n"
    }else{
        print "0\n";
    }
}


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

int N;
ll C,X[101010],V[101010],a[101010],b[101010];

int main(){
  cin>>N>>C;
  ll ans=0;
  rep(i,N) cin>>X[i+1]>>V[i+1];

  rep(i,N) a[i+1]=a[i]+V[i+1]-(X[i+1]-X[i]);
  rep(i,N) a[i+1]=max(a[i+1],a[i]);

  X[N+1]=C;
  for(int i=N;i>=0;i--) b[i]=b[i+1]+V[i]-(X[i+1]-X[i]);
  for(int i=N;i>=0;i--) b[i]=max(b[i],b[i+1]);

  for(int i=1;i<=N;i++){
    ans=max(ans,a[i]);
    ans=max(ans,b[i]);
    ans=max(ans,a[i]+b[i+1]-min(X[i],(C-X[i+1])));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N, K;
    vi x;
    cin >> N >> K;
    x.resize(N);
    REP(i, N)
    cin >> x[i];
    int ans = 0;
    REP(i, N)
    {
        ans += min(x[i], abs(K - x[i]));
    }
    cout << ans * 2 << endl;
    // system("pause");
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::io::stdin as S;
use std::cmp::max;
use std::cmp::min;

fn read_input<T>() -> Vec<T>
where T: FromStr,<T as FromStr>::Err: Debug {
    let mut input = String::new();
    S().read_line(&mut input).unwrap();
    input.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main(){
    let n: Vec<usize> = read_input();
    let n: usize = n[0];
    let mut a: Vec<i64> = read_input();

    for i in 0..n{
        if i>0 {
            a[i] += a[i - 1];
        }
    }

    let mut l = 0;
    let mut r = 2;
    let mut ans:i64 = 100000000000000000;

    for i in 1..n-1{
//        println!("cur i is {}",i);
        while (a[l]*2 -a[i]).abs() > (a[l+1]*2 -a[i]).abs() {
            l += 1;
        }
        while (a[n-1]-a[r]*2 + a[i]).abs() > (a[n-1]-a[r+1]*2 + a[i]).abs(){
            r += 1;
        }
        let tot = [a[l],a[i]-a[l],a[r]-a[i],a[n-1]-a[r]];
        ans = min(ans,(tot.iter().max().unwrap() - tot.iter().min().unwrap()).abs());
    }
    println!("{:?}",ans);
}


Measured memory_bytes: 10492
#include <fstream>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int n,m,j,ge[100005],gi[100005],x,y,ct,s[100005],d[100005],mx;
bool viz[100005];
vector <int>v[100005];
queue<int>C;
void DFS(int nod)
{int i;

    for(i=0;i<ge[nod];i++)
    {if(viz[v[nod][i]]==0){viz[v[nod][i]]=1;
            DFS(v[nod][i]);
        }
    }
    C.push(nod);
}
int main()
{int i;
    //ifstream cin("longest.in");
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {cin>>x>>y;
        v[x].push_back(y);
        gi[y]++;
        ge[x]++;
    }
    for(i=1;i<=n;i++)
    {if(gi[i]==0)DFS(i);
    }
    while(!C.empty())
    {ct++;
        s[ct]=C.front();
        C.pop();
    }
    for(i=ct;i>=1;i--)
    {for(j=0;j<v[s[i]].size();j++) {
            d[v[s[i]][j]] = max(d[v[s[i]][j]], d[s[i]] + 1);
            //cout<<d[v[s[i]][j]]<<" ";
        }
        //cout<<" *"<<s[i]<<"\n";
     mx=max(mx,d[s[i]]);
    }
 cout<<mx;
}

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

using namespace std;

const int NMAX = 1e5+5;

vector<int> g[NMAX];
int dp[NMAX];
bool viz[NMAX];

inline void DFS(int node)
{
    viz[node] = 1;
    int maxim = 0;
    for(auto gnode : g[node])
    {
        if(viz[gnode] == 0)
            DFS(gnode);
        maxim = max(maxim , dp[gnode]);
    }
    dp[node] = maxim + 1;
}

int main()
{
    int N,i,j,M;

    cin>>N>>M;

    for(i = 1 ; i <= M ; ++i)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
    }

    for(i = 1 ; i <= N ; ++i)
    {
        if(!viz[i])
            DFS(i);
    }
    int maxim = 0;
    for(i = 1 ; i <= N ; ++i)
        if(dp[i] > maxim)
            maxim = dp[i];

    cout<<maxim-1;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  string a0 = "";
  for(int w = 0; w < W+2; w++){
    a0 += "#";
  }
  cout << a0 << endl;
  
  string a;
  for(int h = 0; h < H; h++){
    cin >> a;
    a = "#" + a + "#";
    cout << a << endl;
  }
  
  string af = "";
  for(int w = 0; w < W+2; w++){
    af += "#";
  }
  cout << af << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	map <string, int> mp;
	string s;
	int n;
	cin >> n;
	while(n--) {
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << '\n';
	cout << "WA x " << mp["WA"] << '\n';
	cout << "TLE x " << mp["TLE"] << '\n';
	cout << "RE x " << mp["RE"] << '\n';
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

struct UnionFind {
	std::vector<int> par;
	UnionFind(int N) 
		: par(N)
	{
		for (int i = 0; i < N; i++) {
			par[i] = i;
		}
	}
	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx != ry) {
			par[rx] = ry;
		}
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> E(m);
	rep(i, m) {
		cin >> E[i].first >> E[i].second;
		E[i].first--;
		E[i].second--;
	}

	int ans = 0;
	for (int i = 0; i < m; i++) {
		UnionFind uf(n);
		for (int j = 0; j < m; j++) {
			if (i != j && 
				!uf.same(E[j].first, E[j].second)) {
				uf.unite(E[j].first, E[j].second);
			}
		}
		
		set<int> s;
		for (int j = 0; j < n; j++) {
			if (uf.par[j] == j) {
				s.insert(uf.par[j]);
			}
		}
		if (sz(s) > 1) ans++;
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;
    cin>>N>>M;
    
    ll sum=0,cnt=pow(2,M);
    sum+=(N-M)*100;
    sum+=M*1900;
    sum*=cnt;
    cout1(sum)
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<iostream>

int main(){
    const long mod = 1000000007l;
    std::string L;
    std::cin >> L;
    long dp[L.length() + 2][2]; //dp[digit][smaller]
    dp[0][0] = 1; //一致している 上から0桁目は一致している場合が1通りある
    dp[0][1] = 0; //未満である場合は初めは0通りある
    for(int i = 1; i < L.length() + 1; i++){ //上からi-1桁目が確定したあと
        if(L[i - 1] == '0'){
            dp[i][0] = dp[i - 1][0] % mod;
            dp[i][1] = (dp[i - 1][1] * 3l )% mod;
        }else{
            dp[i][0] = (dp[i - 1][0] * 2l) % mod;
            dp[i][1] = (dp[i - 1][1] * 3l + dp[i - 1][0]) % mod;
        }
    }
    printf("%ld", (dp[L.length()][0] + dp[L.length()][1]) % mod);
}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>

int main()
{
  int N;
  std::cin >> N;

  if (N == 1) {
    std::cout << std::setprecision(10) << 1.0 << std::endl;
  }
  else if (N % 2 == 0) {
    std::cout << std::setprecision(10) << 0.5 << std::endl;
  }
  else {
    std::cout << std::setprecision(10) << ((N / 2 + 1) / (float)N) << std::endl;
  }

  return 0;

}



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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        llin(m);
        llin(k);
        ll nm=n*m-2;
        ll l=1;
        ll t=1;
        FOR(i,1,k-2){
                l=(l*nm)%MOD;
                t=(t*i)%MOD;
                nm--;
        }
        ll nn=MOD-2;
        ll r=1;
        while (nn > 0) {
        if (nn & 1) r =r*t%MOD;
        t=t*t%MOD;
        nn >>= 1;
        }
        l=l*r%MOD;
        ll a=0;
        ll b=0;
        ll p=0;
        FOR(i,1,n-1){
                a=(i*m*m*l)%MOD;
                p=(p+a*(n-i))%MOD;
        }
        FOR(i,1,m-1){
                b=(i*n*n*l)%MOD;
                p=(p+b*(m-i))%MOD;
        }
        sal(p);
}


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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    int m;
    cin >> m;
    vector<int> t(m);
    for(int i = 0; i < m; i++) cin >> t[i];

    map<int, int> problems;
    for(int i = 0; i < n; i++){
        if(problems.count(d[i])) problems[d[i]]++;
        else problems[d[i]] = 1;
    }

    string ans = "YES";
    for(int i = 0; i < m; i++){
        if(problems.count(t[i])){
            if(problems[t[i]] == 1) problems.erase(t[i]);
            else problems[t[i]]--;
        }else{
            ans = "NO";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13892
#include <iostream>
#include <string>
#include <vector>
#include <bitset>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int n, m;
vector<bitset<10>> s;
int f(int i, bitset<10> state) {
  if (i == n) {
    return state == 0;
  }
  return f(i + 1, state ^ s[i]) + f(i + 1, state);
}

int main() {
  int input(N, M);
  n = N;
  m = M;
  s = vector<bitset<10>>(n);
  REP(i, m) {
    int input(k);
    REP(j, k) {
      int input(switch_number);
      s[switch_number - 1][i] = 1;
    }
  }

  bitset<10> p;
  REP(i, m) {
    int input(pi);
    p[i] = pi;
  }

  cout << f(0, p) << endl;
}


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

struct node{
    struct node *right;
    struct node *left;
    struct node *p;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
    while(x->left != NIL) {
        x = x->left;
    }
    return x;
} 

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

Node treeSuccessor(Node x){
    Node y;

    if(x->right != NIL){
        return treeMinimum(x->right);
    }
    y = x->p;
    while(y != NIL && x == y->right) {
        x = y;
        y = y->p;
    }
    return y;
}

void treeDelete(Node z){
    Node y; // node to be deleted
    Node x; // child of y
    if(z->left == NIL || z->right == NIL) {
        y = z;
    }
    else {
        y = treeSuccessor(z);
    }
    if(y->left != NIL) {
        x = y->right;
    }
    else {
        x = y->right;
    }
    if(x != NIL) {
        x->p = y->p;
    }
    if(y->p == NIL) {
        root = x;
    }
    else if(y == y->p->left) {
        y->p->left = x;
    }
    else {
        y->p->right = x;
    }
} 

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

    z = malloc(sizeof(struct 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->p = y;
    if(y == NIL) {
        root = z;  
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else y->right = z;
}

void inorder(Node x){
    if(x->left != NIL){
        inorder(x->left);
    }

    printf(" %d",x->key);
    if(x->right != NIL){
        inorder(x->right);
    }

}

void preorder(Node x){
    printf(" %d",x->key);
    if(x->left!= NIL){
        preorder(x->left);
    }

    if(x->right!= NIL){
        preorder(x->right);
    }
}

int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'f' ){
            scanf("%d", &x);
            Node t = treeSearch(root, x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");
        } else if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if ( com[0] == 'd' ){
            scanf("%d", &x);
            treeDelete(treeSearch(root, x));
        } 
    }
    return 0;
}

Measured memory_bytes: 19364
#![allow(unused_imports)]

mod pcl {

}




struct WhiteCounter {
    sum: Vec<Vec<usize>>,
}

impl WhiteCounter {
    fn from_choco(choco: Vec<Vec<usize>>) -> WhiteCounter {
        let h = choco.len() + 1;
        let w = choco[0].len() + 1;
        let mut sum = vec![vec![0; w]; h];
        for i in 1..h {
            for j in 1..w {
                sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + choco[i - 1][j - 1];
            }
        }

        WhiteCounter { sum: sum }
    }

    fn width(&self) -> usize {
        self.sum[0].len() - 1
    }

    fn count(&self, ybegin: usize, xbegin: usize, yend: usize, xend: usize) -> usize {
        self.sum[yend][xend] + self.sum[ybegin][xbegin]
            - self.sum[ybegin][xend]
            - self.sum[yend][xbegin]
    }
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let (h, w, k) = {
        let sp: Vec<_> = s
            .trim()
            .split_whitespace()
            .map(|x| x.parse::<usize>().unwrap())
            .collect();
        (sp[0], sp[1], sp[2])
    };
    let mut choco = Vec::new();
    for _ in 0..h {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let row: Vec<_> = s.trim().bytes().map(|x| (x - b'0') as usize).collect();
        assert_eq!(row.len(), w);
        choco.push(row);
    }
    let counter = WhiteCounter::from_choco(choco);

    let mut minres = std::usize::MAX;
    for hline in 0..(1 << (h - 1)) {
        let mut hlines = vec![0];
        for i in 0..h {
            if hline & 1 << i != 0 {
                hlines.push(i + 1);
            }
        }
        hlines.push(h);

        let mut res = hlines.len() - 2;
        let mut xbegin = 0;
        let mut xend = 1;
        'main: loop {
            if xend > counter.width() {
                break;
            }

            for yrange in hlines.windows(2) {
                let (ybegin, yend) = (yrange[0], yrange[1]);
                if counter.count(ybegin, xbegin, yend, xend) > k {
                    if xbegin + 1 == xend {
                        res = std::usize::MAX;
                        break 'main;
                    }

                    res += 1;
                    xbegin = xend - 1;
                    xend = xbegin + 1;
                    continue 'main;
                }
            }

            xend += 1;
        }

        minres = std::cmp::min(minres, res);
    }

    println!("{}", minres);
}


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

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a(q);
  vector<int> b(q);
  vector<int> c(q);
  vector<int> d(q);
  for (int i = 0; i < q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  vector<int> arr(n, 1);
  int max_point = 0;
  while (true) {
    int point = 0;
    for (int i = 0; i < q; ++i) {
      if (arr[b[i] - 1] - arr[a[i] - 1] == c[i]) {
        point += d[i];
      }
    }
    if (point > max_point) {
      max_point = point;
    }
    if (arr[n - 1] == m) {
      int i = n - 2;
      while (i > 0 && arr[i] == m) {
          i--;
      }
      if (i == 0) {
        break;
      }
      arr[i]++;
      while (i < n - 1) {
        i++;
        arr[i] = arr[i - 1];
      }
    } else {
      arr[n - 1]++;
    }
  }
  cout << max_point << endl;
}


Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    lint N,X,M;
    cin >> N >> X >> M;
    lint las[M]={};
    rep(i,M) las[i]=-1;
    lint now=X,cnt=1;
    lint cb;
    lint syuki;
    las[X]=0;
    while(true){
        now=(now*now)%M;
        if(las[now]!=-1){
            syuki=cnt-las[now];
            cb=now;
            break;
        }
        else las[now]=cnt;
        cnt++;
    }
    lint ans=0;
    lint sim=X;
    lint rem=N;
    while(sim!=cb){
        ans+=sim;
        sim=(sim*sim)%M;
        rem--;
        if(rem==0) break;
    }
    sim=(sim*sim)%M;
    lint one=sim;
    while(sim!=cb){
        sim=(sim*sim)%M;
        one+=sim;
    }
    lint need=rem/syuki;
    ans+=need*one;
    rem%=syuki;
    rep(i,rem){
        ans+=sim;
        sim=(sim*sim)%M;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll mod=1e9+7;

mat mul(mat t,mat u){
  mat v(t.size());
  for(int i=0;i<(int)t.size();i++)
    v[i].resize(t.size());

  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      v[i][j]=0;
      for(int k=0;k<2;k++){
        v[i][j]+= t[i][k]*u[k][j];
        v[i][j]%=mod;
      }
    }
  }
  return v;
}


ll fib(ll x){
  if(x<=1)return 1;

  mat A( 2, vec(2,0));
  mat B( 2, vec(2,0));

  A[0][0]=1;
  A[1][1]=1;
  B[0][0]=1;
  B[0][1]=1;
  B[1][0]=1;

  ll n=x;
  while(n>0){
    if(n%2==1)A=mul(A,B);
    n/=2;
    B=mul(B,B);
  }

  return (A[1][0]+A[1][1])%mod;
}

ll solve(ll si,ll k){
  ll num=(si+1)/2;
  k--;
  //  cout<<si<<' '<<k<<endl;
  ll d;
  if( num/2+num%2 > k ){
    d=k*2;
  }else{
    ll nk= k - (num/2+num%2);
    if(num%2==0){
      d=num-1-nk*2;
    }else{
      d=num-2-nk*2;
    }
  }
  //  cout<<"d= "<<d<<endl;
  return fib(si-d)* fib(d+1) % mod;
}


ll func(ll si){
  ll base=si/2;
  ll res = (1+base)*base/2;
  res*=2;
  if(si%2==1)res+=(si+1)/2;
  return res;
}

int main(){
  ll K;
  cin>>K;

  if(K<=5){
    cout<<K<<endl;
    return 0;
  }

  ll left=1,right=2000000000LL,mid;

  while(left<right){
    mid=(left+right)/2;
    if( func(mid) < K ) left=mid+1;
    else right=mid;
  }

  cout<<solve(left, K-func(left-1))<<endl;
  /*
  ll total=0;
  for(ll i=1;;i++){
    if(K<=total+(i+1)/2){
      //      cout<<i<<' '<<K<<' '<<total<<endl;

      cout<<solve(i,K-total)<<endl;
      break;
    }
    total+=(i+1)/2;
  }
  */
  
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

vll yakusuu(ll n){
  	vector<ll> y; //sqrtまでの約数列挙
	for(ll i = 1; i * i <= n; i++){
		if(n % i == 0) y.push_back(i);
	}
  	ll len = y.size();
  	REP(i, len) y.push_back(n / y[i]);
    return y;
}
bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b;
    cin >> a >> b;

    vll ya = yakusuu(a), yb = yakusuu(b);
    ll la = ya.size(), lb = yb.size();
    vll p;
    REP(i, la){
        REP(j, lb){
            if(ya[i] == yb[j]) p.push_back(ya[i]);
        }
    }
    ll res = 1;
    for(auto v : p){
        if(IsPrime(v)) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
map<ll,ll>bit;
ll sum(ll x){
	ll s=0;for(;x>0;x-=x&(-x)) s+=bit[x];return s;
}
void add(ll x,ll val){
	for(;x<2e5+5;x+=x&(-x)) bit[x]+=val;
}
int main(){
	ll n,d,a,i,c=0;cin>>n>>d>>a;vpi v(n);map<ll,ll>mp;vi b(n);
	for(i=0;i<n;i++) cin>>v[i].fs>>v[i].se;sort(all(v));
	for(i=0;i<n;i++) b[i]=v[i].fs;
	for(i=0;i<n;i++){
		ll x=v[i].se+sum(i+1);
		if(x<1) continue;
		ll f=x/a+(x%a>0);c+=f;
		ll s=upper_bound(all(b),b[i]+2*d)-b.begin();
//		cout<<b[i]<<" "<<x<<" "<<s<<" "<<f<<endl;
		add(i+1,-f*a);add(s+1,f*a);
	}cout<<c<<endl;
}



Measured memory_bytes: 17408
// review
#include <iostream>

using namespace std;
typedef long long ll;
const ll INF = 1e16;
const int MAXD = 11;

int d;
ll g;
ll p[MAXD], c[MAXD];

void solve() {
  ll minCnt = INF;
  for (ll i=1;i<1<<(d+1);i++) {
    ll remain = g;
    ll cnt = 0;
    for (int j=0;j<d;j++) {
      if ((i >> j) & 1) {
        remain -= p[j] * 100 * (j+1) + c[j];
        cnt += p[j];
      }
    }
    for (int j=d-1;j>=0;j--) {
      if (!((i >> j) & 1)) {
        ll tmp = min((remain + 100 * (j+1) - 1) / (100 * (j+1)), p[j] - 1);
        if (tmp > 0) {
          cnt += tmp;
          remain -= tmp * 100 * (j+1);
        } else {
          break;
        }
      }
    }
    if (remain <= 0) {
      minCnt = min(minCnt, cnt);
    }
  }
  cout << minCnt << endl;
}

int main() {
  cin >> d >> g;
  for (int i=0;i<d;i++) {
    cin >> p[i] >> c[i];
  }
  solve();
}


Measured memory_bytes: 256
n,c,k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()

bus = 0
vis = [False for i in range(n)]
for i in range(n):
  if vis[i]:
    continue
  vis[i] = True
  x = i
  lim = t[i]+k
  cnt = 1
  bus += 1
  while x < n and cnt <= c:
    if t[x] > lim:
      break
    i = x
    vis[x] = True
    x += 1
    cnt += 1
print (bus)


Measured memory_bytes: 13880
export class Main {
  static main(input): string {
    const [n, a, b, c, d, e]: number[] = input.split("\n").map(s => Number(s.split(" ")[0]));
    const m: number = Math.min(a, b, c, d, e);
    const r: number = n % m;
    let result: number = 0;
    if (r == 0) {
      result = n / m;
    } else {
      result = (n - r) / m + 1;
    }
    return `${result + 4}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
import java.io.*;
import java.util.*;
public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		makePrimeList();
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			int sum = 0;
			for(int i = 0; i < n; i++) {
				int p = sc.nextInt();
				int m = sc.nextInt();
				if(m == 0) {
					if(Collections.binarySearch(list, p) < 0) {
						sum -= 1;
					}
					continue;
				}
				else  {
				
				int min = Collections.binarySearch(list, p-m);
				if(min < 0) {
					
					min *= -1;
					min -= 1;
				}
				int max = Collections.binarySearch(list, p+m);
				if(max < 0) {
					
					max *= -1;
					max -= 2;
				}
				sum += max - min;
				}
			}
			
			System.out.println(sum);
			
		}
	}
	
	static void makePrimeList() {
		boolean[] isntPrime = new boolean[1000000];
		int i = 2;
		for(; i*i < isntPrime.length; i++) {
			if(!isntPrime[i]) {
				list.add(i);
				for(int j = i + i; j < isntPrime.length; j += i) {
					isntPrime[j] = true;
				}
			}	
		}
		
		for(; i < isntPrime.length; i++) {
			if(!isntPrime[i]) {
				list.add(i);
			}
		}
	}
		
}

Measured memory_bytes: 31168
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,b) for(int i = b - 1; i >= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;

int dp[MAXN][2]; // dp[i][j] --> min cost to reach stone i with last leap of j+1
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int h[n];
	rep(i,n)cin>>h[i];
	rep(i,n) rep(j,2) dp[i][j] = INT_MAX;
	dp[0][0] = 0;
	dp[0][1] = 0;
	for(int i = 1; i < n; i++){
			dp[i][0] = min(dp[i-1][0],dp[i-1][1]) + abs(h[i] - h[i-1]);
			if( i > 1)
			dp[i][1] = min(dp[i-2][0],dp[i-2][1]) + abs(h[i] - h[i-2]);
	}
	int ans = min(dp[n-1][0],dp[n-1][1]);
	cout<<ans<<nl;
	return 0;

}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;
    int x;
    cin>>x;
    if(x<30) cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int n1, n2, n3, n4;
	cin >> n1 >> n2 >> n3 >> n4;

	bool f1 = false;
	bool f2 = false;
	bool f3 = false;
	bool f4 = false;

	if (n1 == 1 || n2 == 1 || n3 == 1 || n4 == 1) {
		f1 = true;
	}

	if (n1 == 9 || n2 == 9 || n3 == 9 || n4 == 9) {
		f2 = true;
	}

	if (n1 == 7 || n2 == 7 || n3 == 7 || n4 == 7) {
		f3 = true;
	}

	if (n1 == 4 || n2 == 4 || n3 == 4 || n4 == 4) {
		f4 = true;
	}

	if (f1 && f2 && f3 && f4) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


}


Measured memory_bytes: 3644
n = int(input())
s = input()

let = [chr(i) for i in range(97, 97 + 26)]

ans = 0
for i in range(1, n):
    l = s[:i]
    r = s[i:]
    cnt = 0
    for let_ele in let:
        if let_ele in l and let_ele in r:
            cnt += 1
    ans = max(ans, cnt)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline long long in(){long long x=0;char c=getchar();bool neg=false;while(c!='-'&&('0'>c||c>'9')) c=getchar();if(c=='-') neg=true,c=getchar();while('0'<=c&&c<='9') x=10*x+c-'0',c=getchar();if(neg) x=-x;return x;}
inline void out(long long x){if(x<0) putchar('-'),x=-x;if(x>9) out(x/10);putchar(x%10+'0');}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "h"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define _ putchar(' ')
#define __ putchar('\n')
const int N=5010;
int n;
double p;
double f[N][N];
main()
{
    fasty;
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    cin>>n;
    f[0][0]=1;
    forinc(i,1,n)
    {
        cin>>p;
        forinc(j,0,n)
        {
            f[i][j+1]+=f[i-1][j]*p;
            f[i][j]+=f[i-1][j]*(1.0-p);
        }
    }
    p=0;
    forinc(i,(n+1)/2,n) p+=f[n][i];
    cout<<setprecision(12)<<fixed<<p;
}



Measured memory_bytes: 118400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<vector<ll> > G(N);

    rep(i,N-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    vector<ll> dist(N,-1);
    queue<ll> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        ll v = que.front();
        que.pop();

        for(ll i : G[v]){
            if(dist[i] !=-1) continue;

            dist[i] = dist[v] + 1;
            que.push(i);
        }
    }

    vector<ll> dist2(N,-1);
    queue<ll> que2;

    dist2[N-1] = 0;
    que2.push(N-1);

    while(!que2.empty()){
        ll v = que2.front();
        que2.pop();

        for(ll i : G[v]){
            if(dist2[i] !=-1) continue;

            dist2[i] = dist2[v] + 1;
            que2.push(i);
        }
    }
    ll cnt1=0;
    ll cnt2=0;
    rep(i,N){
        if(dist[i]<=dist2[i]){
            cnt1++;
        }else{
            cnt2++;
        }
    }
    if(cnt1==cnt2){
        if(N%2==0){
            cout<<"Snuke"<<endl;
        }else{
            cout<<"Fennec"<<endl;
        }
    }else if(cnt1>cnt2){
        cout<<"Fennec"<<endl;
    }else{
        cout<<"Snuke"<<endl;
    }
   


    return 0;
    

}

Measured memory_bytes: 10900
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int aa[10000];
string ss[10000];
char cc[10000];
pair<int,string>pp[1000];
int a,b,c;
string s;
signed main()
{
	cin>>a>>b>>c;
	cout<<min(b,c)<<" ";
	if(b+c>a){
		cout<<b+c-a;
	}else{
		cout<<0;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue

#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 1005
int h, w;
char a[MN][MN];
int stat[MN][MN];
queue<pii> q;

int xdir[4] = {0, 1, 0, -1}, ydir[4] = {1, 0, -1, 0};

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

    memset(stat, 0x3f, sizeof stat);

    cin >> h >> w;
    F0R(i, h){
        F0R(j, w){
            cin >> a[i][j];
            if(a[i][j] == '#'){
                stat[i][j] = 0;
                q.push(mp(i, j));
            }
        }
    }

    int tim = 0;
    while(!q.empty()){
        pii top = q.front();
        q.pop();

        int ct = stat[top.f][top.s];
        tim = ct;
        //cout << top.f << " " << top.s << " " << tim << "\n";
        F0R(i, 4){
            pii nn = mp(top.f+xdir[i], top.s+ydir[i]);
            if(nn.f < 0 || nn.f >= h || nn.s < 0 || nn.s >= w) continue;
            if(stat[nn.f][nn.s] != INF) continue;
            stat[nn.f][nn.s] = ct+1;
            q.push(nn);
        }
    }

    cout << tim << "\n";

    return 0;
}


Measured memory_bytes: 13328
# 37
n, k, q = map(int, input().split())
start_point = k - q
list = [start_point for i in range(n)]
for i in range(q):
    list[int(input()) - 1] += 1

for i in range(n):
    if list[i] >= 1: print('Yes')
    else: print('No')

Measured memory_bytes: 11700
#include <iostream>
#include <string>
#include <map>

using namespace std;

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

    map<string, int> q;
    string as, bs;
    int a, b;
    cin >> as >> bs;
    cin >> a >> b;
    q[as] = a;
    q[bs] = b;
    string w;
    cin >> w;
    q[w]--;
    cout << q[as] << " " << q[bs] << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b; cin>>a>>b;
    if(a%2==1&&b%2==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final int rock = scanner.nextInt();
        final int scissors = scanner.nextInt();
        final int paper = scanner.nextInt();
        final String t = scanner.next();

        int answer = 0;
        for (int i = 0; i < k; i++) {
            char before = ' ';
            for (int j = i; j < n; j += k) {
                final char current = t.charAt(j);
                if (current == before) {
                    before = ' ';
                    continue;
                }

                switch (current) {
                    case 'r':
                        answer += paper;
                        break;
                    case 's':
                        answer += rock;
                        break;
                    case 'p':
                        answer += scissors;
                        break;
                }

                before = current;
            }
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 26648
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cassert>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=1E5+10;
const int OFFSET=1E5+10;

int t[MAXN<<4];
int n,a[MAXN];
int b[MAXN];
ll tot;

void insert(int x,int l,int r,int pos)
{
	t[x]++;
	if(l==r) return;
	int mid=(l+r)>>1;
	if(pos<=mid) insert(x<<1,l,mid,pos);
	else insert(x<<1|1,mid+1,r,pos);
}

int query(int x,int l,int r,int ql,int qr)
{
	if(ql<=l&&r<=qr) return t[x];
	int mid=(l+r)>>1,ret=0;
	if(ql<=mid) ret+=query(x<<1,l,mid,ql,qr);
	if(qr>mid) ret+=query(x<<1|1,mid+1,r,ql,qr);
	return ret;
}

bool check(int x)
{
	for(int i=1;i<=n;i++) b[i]=(a[i]>=x?1:-1);
	memset(t,0,sizeof t);
	ll S=0,Res=0;
	insert(1,1,OFFSET<<1,OFFSET);
	for(int i=1;i<=n;i++)
	{
		S+=b[i];
		Res+=query(1,1,OFFSET<<1,1,S+OFFSET);
		insert(1,1,OFFSET<<1,S+OFFSET);
	}
	return tot-Res<=tot/2;
}

int main()
{
	scanf("%d",&n);tot=1ll*n*(n-1)/2+n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int L=1,R=1E9+10,Ans=0;
	while(L<=R)
	{
		int mid=(L+R)>>1;
		if(check(mid)) Ans=mid,L=mid+1;
		else R=mid-1;
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 7296
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

string S;
map<char, int> memo;

int main(){
	cin >> S;
	bool cannot = true;
	for(int i = 1; i < S.size() - 1; i++){
		if(S[i-1] != S[i]){
			cannot = false;
		}
	}
	if(cannot){
		cout << "Second" << endl;
		return 0;
	}

	long long num;
	if(S[0] == S[S.size() - 1]){
		num = S.size() - 3;
	}else{
		num = S.size() - 2;
	}
	if(num % 2 == 1){
		cout << "First" << endl;
	}else{
		cout << "Second" << endl;
	}
}


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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string S = Console.ReadLine();

		if(S == "ABC"){
						Console.WriteLine("ARC");
		}
		else{
						Console.WriteLine("ABC");
		}

	}
}



Measured memory_bytes: 17332
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();

		}
		int ans=arr[0];
		for(int i=1;i<n;i++){
			ans=ans^arr[i];
		}
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++){
			int t = ans^arr[i];
			//System.out.println(t);
			sb.append(t+" ");
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 63232
#include <bits/stdc++.h>
using namespace std;
// B - Qualification simulator
// https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_b
int main()
{
    int N, A, B;
    string S;
    cin >> N >> A >> B >> S;
    vector<string> ans(N);

    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }

    int ab = 0, b = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'a')
        {
            if (ab < A + B)
            {
                ans[i] = "Yes";
                ab++;
            }else{
                ans[i] = "No";
                
            }
        }else if (S[i] == 'b')
        {
            if (ab < A + B && b <B)
            {
                ans[i] = "Yes";
                ab++;
                b++;
            }else{
                ans[i] = "No";
        } 

        }else
        {
                ans[i] = "No";
            
        }
    }

    for (string ai : ans)
        cout << ai << endl;
}


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

using namespace std;
int v[200000];
int main()
{
    int n,x;
    cin>>n;
    for(int i=2;i<=n;i++)
    {
        cin>>x;
        v[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<v[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4308
#!/usr/bin/env python3

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

cnts = [0 for _ in range(m + 1)]

for _ in range(n):
    for like_no in map(int, input().strip().split()[1:]):
        cnts[like_no] += 1

ans = 0
for cnt in cnts:
    if cnt == n:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a[300005];
int main()
{
    int n;
    ll ans=0,ans1 = 0,ans2=0,ans3=0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld",&a[i]);
        a[i] = a[i] - i - 1;
    }
    sort(a,a+n);
    int zho = (a[(n-1)/2]+a[n/2])/2;
    for(int i = 0; i < n; i++)
    {
        ans1 = ans1 + abs(a[i]-zho);
        ans2 = ans2 + abs(a[i]-zho-1);
        ans3 = ans3 + abs(a[i]-zho+1);
    }
    printf("%lld\n",min(ans1,min(ans2,ans3)));
    return 0;
}


Measured memory_bytes: 1792