akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }    
    let MOD = 1_000_000_007;
    let mut dp:Vec<Vec<i64>> = vec![vec![0;13];s.len()+1];
    dp[0][0]=1;
    for i in 0..s.len() {
        let n = if s[i] == '?' {-1}else{s[i] as i32 - 48};
        for j in 0..10 {
            if n!=-1 && n!=j {
                continue;
            }
            for k in 0..13 {
                dp[i+1][((10*k+j)%13) as usize]+=dp[i][k as usize];
            }
        }
        for j in 0..13 {
            dp[i+1][j]%=MOD;
        }
    }
    let ans = dp[s.len()][5];

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

Measured memory_bytes: 18684
#!/usr/bin/python3

def find(id, V, d, dist):
    i = id - 1
    dist[i] = d
    for v in V[i]:
        if dist[v - 1] == -1 or dist[v - 1] > d + 1:
            find(v, V, d + 1, dist)
    
n = int(input())
# [isFind, d, f]
A = [[False, 0, 0] for i in range(n)]
U = []
V = []
dist = [-1] * n
for i in range(n):
    l = list(map(int, input().split()))
    U.append(l[0])
    V.append(l[2:])

find(1, V, 0, dist)

for u in U:
    print(u, dist[u - 1])

Measured memory_bytes: 7776
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
//#include <unordered_set>
#include <set>

using namespace std;
char field[1001][1001];
bool used[1001][1001];

int main(){
  int H,W;
  while(cin>>H>>W&&(H|W)){
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
	cin>>field[i][j];
    vector<string> vs;
    for(int dy=-1;dy<=1;dy++){
      for(int dx=-1;dx<=1;dx++){
	if(dy==0&&dx==0)continue;
	memset(used,0,sizeof(used));
	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))continue;
	    int cx=j;
	    int cy=i;
	    string s;
	    if(used[cy][cx])continue;
	    while(1){
	      used[cy][cx]=true;
	      s+=field[cy][cx];
	      cy+=dy;cx+=dx;
	      cy=(cy+H)%H;
	      cx=(cx+W)%W;
	      if(used[cy][cx])break;
	    }
	    vs.push_back(s);
	    //cout<<s<<endl;
	  }
	}
      }
    }
    //unordered_set<string> us;
    set<string> us;
    string cand;
    for(int i=0;i<(int)vs.size();i++){
      for(int j=0;j<(int)vs[i].size();j++){
	for(int k=1;k<=(int)vs[i].size();k++){
	  string s;
	  for(int l=0;l<k;l++){
	    s+=vs[i][(j+l)%vs[i].size()];
	  }
	  if(us.count(s)==1){
	    if(cand==""||cand.size()<s.size())
	      cand=s;
	    else if(cand.size()==s.size()&&cand>s)
	      cand=s;
	  }
	  else if(us.count(s)==0)
	    us.insert(s);
	}
      }
    }
    if(cand.size()>1)cout<<cand<<endl;
    else cout<<0<<endl;
  }

  return 0;
}

Measured memory_bytes: 28000
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;
vector<vector<int>>adj(N);


bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}

void fun(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        vi dp(2001,0);
        dp[0]=1;

        for(int i=3;i<=2000;i++){
            dp[i]=(dp[i-1]+dp[i-3])%mod;
            dp[i]%=mod;
        }
        cout<<dp[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 7712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    int w=count(s.begin(),s.end(),'W'),r=n-w,wc=0;
    for(i=0;i<n;i++)
    {
        int c=0;
        if(s[i]=='W')
        {
            for(int j=n-1;j>=i;j--)
            {
                if(s[j]=='R')
                {
                    wc++;swap(s[i],s[j]);c=1;break;
                }

            }
            if(c==0)
                break;
        }
    }
    cout<<min(w,min(r,wc));

}



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

#define int long long
#define x first
#define y second

int n;
vector<int> a;
vector<int> x;

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

	cin >> n;
	a.resize(n);

	for(int i = 0; i < n; i++)
		cin >> a[i];
	vector<int> b(n);
	for(int i = 0; i < n; i++) {
		b[i] = a[(i+n-1)%n];
	}
	for(int i = 0; i < n; i++)
		a[i] = b[i];

	x.resize(n);

	x[n-1] = 0;
	int s = 1;
	for(int i = n-1; i >= 0; i--) {
		x[n-1] += s * a[i];
		s = -s;
	}
	x[n-1] /= 2LL;

	x[0] = a[0] - x[n-1];
	for(int i = 1; i < n - 1; i++)
		x[i] = a[i] - x[i-1];

	for(int i : x) cout << 2LL * i << " ";
	cout << endl;
}




















































Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1LL<<60;
const int MOD = 1e9+7;

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

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int P = 1e9 + 7;
const int maxn = 2e5 + 5;
ll fac[maxn], inv[maxn], facinv[maxn];
ll C(int n, int m) {
	if(n < m) {
		return 0;
	}
	return fac[n] * facinv[m] % P * facinv[n - m] % P;
}
int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	fac[0] = 1;
	inv[1] = 1;
	facinv[0] = 1;
	for(int i = 1; i < maxn; ++i) {
		fac[i] = fac[i - 1] * i % P;
		if(i != 1) {
			inv[i] = (P - P / i) * inv[P % i] % P;
		}
		facinv[i] = facinv[i - 1] * inv[i] % P;
	}
	ll ans = 0;
	for(int i = b + 1; i <= w; ++i) {
		ll delta = C(h - a + i - 2, i - 1) * C(a + w - i - 1, a - 1) % P;
		ans = (ans + delta) % P;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#define SIZE 1000005

using namespace std;
struct DoublyLinked
{
  int list[SIZE];
  int head,tail;
 
  void init(){ head=-1; tail=0; }
  void insert(int x){ head++; list[head]=x; }
  void delFirst(){ head--; while(list[head]<0) head--; }
  void delLast(){ tail++; while(list[tail]<0) tail++; }
  void del(int x){
    for(int i=head; i>=tail; i--){
      if(list[i]==x){
	if(i==tail){ delLast(); }
	else if(i==head){ delFirst(); }
	else{ list[i]=-1; }
	break;
      }
    }
  }
};

void print(DoublyLinked& dl){
  for(int i=dl.head; i>=dl.tail; i--){
    if(dl.list[i]>0){
      if(i==dl.tail) cout<<dl.list[i]<<endl;
      else cout<<dl.list[i]<<' ';
    }
  }
}
int main()
{
  int n,x;
  string cmd;
  DoublyLinked dl;
  //input,initialize,process
  dl.init();
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>cmd;
    if(cmd=="insert"){ cin>>x; dl.insert(x); }
    else if(cmd=="delete"){ cin>>x; dl.del(x); }
    else if(cmd=="deleteFirst"){ dl.delFirst(); }
    else if(cmd=="deleteLast"){ dl.delLast(); }
  }
  
  print(dl);
  return 0;
}


Measured memory_bytes: 6904
#include <stdio.h>

int main()
{
  int n;
 
  scanf("%d",&n);
  
  char s[n];
  int i;
  
  for(i=0;i<n;i++)
  {
    scanf(" %c",&s[i]);
  }
  
  for(i=0;i<n;i++)
  {
    if(s[i]=='Y')
    {
      printf("Four\n");
      return 0;
    }
  }
  
  printf("Three\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

//void C_117()
int main()
{
  int N, M;
  cin >> N >> M;

  if (N < M)
  {
    vector<int> X(M);
    for (int i = 0; i < M; ++i) cin >> X[i];
    sort(X.begin(), X.end());

    vector<int> diff(M - 1);
    for (int i = 0; i < M - 1; ++i) diff[i] = X[i + 1] - X[i];
    sort(diff.begin(), diff.end());

    int sum = 0;
    for (int i = 0; i < diff.size() - (N - 1); ++i)
    {
      sum += diff[i];
    }

    cout << sum << endl;
  }
  else
  {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define MAX 101
#define VISITED 0;
#define UNVISITED -1
#define NO_POSSIBLE_VERTICE -3


int d[MAX], f[MAX];
int timeStamp = 0;
vector<int> adj[MAX];
stack<int> S;

bool isAdjacentVerticeUnvisited(int currVertice, int i){
	if (f[adj[currVertice][i]] == UNVISITED) 
		return true;
	else
		return false;
}

int getNextPossibleVertice(int currVertice) {
	int i = 0;
		
	for (i = 0; i < adj[currVertice].size(); i++){
		if (isAdjacentVerticeUnvisited(currVertice, i)){
			return adj[currVertice][i];
		}
	}

	return NO_POSSIBLE_VERTICE;

}

void dfs() {

	while (!S.empty()) {
		int currVertice = S.top();

		int nextNode = getNextPossibleVertice(currVertice);

		// cout << "dfs " << currVertice << " nt:" << nextNode << "\n";

		if (nextNode == NO_POSSIBLE_VERTICE) {
			f[currVertice] = ++timeStamp;
			S.pop();
		} else {
			d[nextNode] = ++timeStamp;
			f[nextNode] = VISITED;
			S.push(nextNode);
		}
	}

}


int main() {
	int n, i, j, vertice, id, degree;
	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> id;
		cin >> degree;
		for (j = 0; j < degree; j++) {
			cin >> vertice;
			if (id != vertice){
				adj[id].push_back(vertice);
			}
		}
	}
	// init
	for (i = 1; i <= n; i++) {
		f[i] = UNVISITED;
	}

	for (i = 1; i <= n; i++) {
		if (f[i] == UNVISITED) {
			S.push(i);
			d[i] = ++timeStamp;
			f[i] = VISITED;
			dfs();
		}
	} 
	

	// for (i = 1; i <= n; i++) {
	// 	for (j = 0; j < adj[i].size(); j++)
	// 		cout << " " << adj[i][j];
	// 	cout << "\n" << i <<" size : " << adj[i].size() << "\n";
	// }

	for (i = 1; i <= n; i++) 
		cout << i << " " << d[i] << " " << f[i] <<"\n";

}

Measured memory_bytes: 3136
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
#include<stack>
typedef long long LL;
using namespace std;
const int Maxn = 1e6;
const int Inf = 1e9 + 7;
int main()
{
	int N;
	LL A[3010];
	LL Max = 0; 
	while( cin >> N ){
		for( int i = 1 ; i <= N ; i++ ){
			scanf(" %lld",&A[i]);
		}
		Max = 0;
		for( int j = 1 ; j <= N ; j++ ){
			Max += ( A[j] - 1 );
		}
		cout << Max << endl;
	}
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll a = 0, n;
    cin >> n;
    string s;
    REP(i, 1, n+1) {
        s = to_string(i);
        if (s.size()%2)
            a++;
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

typedef struct {
  ll to;
  ll cost;
} S_Edge;

const ll MAX_N = 1e5;
std::vector< ll > vcol(MAX_N, -1);
std::vector< S_Edge > vpath[MAX_N];

void dfs(ll v, ll par, ll cost)
{
  if (cost % 2 == 0) {
    vcol[v] = vcol[par];
  } else {
    vcol[v] = vcol[par] == 1 ? 0 : 1;
  }

  //print(v, par, cost, vcol[v]);

  for (auto edge : vpath[v]) {
    if (edge.to != par) dfs(edge.to, v, edge.cost);
  }
}

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

  ll N;
  std::cin >> N;

  for (ll i = 0; i < N-1; i++) {
    ll u, v, w;
    std::cin >> u >> v >> w;
    u--; v--;
    vpath[u].push_back({v, w});
    vpath[v].push_back({u, w});
  }

  ll root = 0;
  vcol[root] = 0;
  dfs(root, root, 0);

  for (ll i = 0; i < N; i++) {
    print(vcol[i]);
  }

  return 0;
}


Measured memory_bytes: 10240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scannerS = new Scanner(System.in);
		int N = scannerS.nextInt();
		int X = scannerS.nextInt();
		int T = scannerS.nextInt();

		int a = 0;
		int b = N % X;
		int c = N / X;

		if (b == 0) {
			a = (N / X) * T;
		} else if (b != 0) {
			a = (c + 1) * T;
		}

		System.out.println(a);

	}

}

Measured memory_bytes: 27008
#include<bits/stdc++.h>
using namespace std;
#define int int64_t

signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,i,ans;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++)
        cin>>a[i];

    ans=0;
    for(int i=0;i<n;i++)    
    {
        for(int j=i+1;j<n;j++)    
        {
            if(i==j)
                continue;
            for(int k=j+1;k<n;k++)    
            {
                if(k == i or k==j)
                    continue;
                int temp[3];
                temp[0]=a[i];
                temp[1]=a[j];
                temp[2]=a[k];

                set<int> s;
                s.insert(temp[0]);
                s.insert(temp[1]);
                s.insert(temp[2]);
                if(s.size() < 3)
                    continue;
                sort(temp,temp+3);
                if(temp[0] + temp[1] > temp[2])
                {
                     // cout<<i<<' '<<j<<' '<<k<<endl;
                    ans++;
                }
            }
        }
        
    }
    
    cout<<ans<<endl;
    

    return 0;
}




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

int main () {
	int a, b;
	cin >> a >> b;
	int k = b;
	int l=0;
	while (k%10>0) {
		k = k / 10;
		l++;
	}
	int x=1;
	for (int i=0; i<l; i++) x*=10;
	int s = a*x+b;
	cout << (sqrt(s)==int(sqrt(s))?"Yes":"No");
	return 0;
} 

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353 
const int N = 100001; 


void solve(){
    char c;cin>>c;
    if(c-'a'<=26&&c-'a'>=0)cout<<'a';
    else cout<<"A";
    return;
}
     
signed main(){
    IOS;
  
    int t=1;
    // cin>>t;
    rep(i,0,t){
        solve();
        cout<<"\n";
    //   cout<<" * "<<t<<"\n";
    }
//    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node {
	int key;
	struct Node* parent;
	struct Node* left;
	struct Node* right;
	struct Node* sibling;
	int degree;
	int depth;
	int height;
	char type[15]; 
};
typedef struct Node * NodePointer;


void serach_depth (NodePointer ,int );

int main (){
	int n;
	scanf("%d\n",&n);
	
	//setting part
	NodePointer array [n];
	for (int i = 0; i < n;i++)
	{
		array[i] = (NodePointer) malloc (sizeof(struct Node));
		array[i]->parent = NULL;
		array[i]->sibling = NULL;
		array[i]->left = NULL;
		array[i]->right = NULL;
		array[i]->degree = 0;
		strcpy(array[i]->type,"internal node");
	}
	
	//input part
	for (int i = 0; i < n;i++)
	{
		int id ,left_id,right_id;
		scanf("%d %d %d\n",&id,&left_id,&right_id);
		
		array[id]->key = id;
		if (left_id != -1){
			array[id]->left = array[left_id];
			array[left_id]->parent =  array[id];
			array[id]->degree++;
		}
		if (right_id != -1){
			array[id]->right = array[right_id];
			array[right_id]->parent =  array[id];
			array[id]->degree++;
		}
		if (left_id != -1 && right_id != -1){
			array[left_id]->sibling =  array[right_id];
			array[right_id]->sibling =  array[left_id];
		}
		if (left_id == -1 && right_id == -1){
			strcpy(array[id]->type ,"leaf");
		}
	}
	
	//search part
		for (int i = 0; i < n;i++)
	{
		if(array[i]->parent == NULL) {
			strcpy(array[i]->type ,"root");
			serach_depth(array[i],0); break;
		}
	}
	
	//print part
	for (int i=0; i<n ;i++){
		printf("node %d: ",i);
		if (array[i] -> parent != NULL){
		printf("parent = %d, ",array[i]->parent->key);
		}else {
			printf("parent = -1, ");
		}if (array[i] -> sibling != NULL){
		printf("sibling = %d, ",array[i]->sibling->key);
		}else {
			printf("sibling = -1, ");
		}
		printf("degree = %d, depth = %d, height = %d, %s\n",array[i]->degree,array[i]->depth,array[i]->height,array[i]->type );
	}
	
	return 0;
}

void serach_depth (NodePointer tag,int dep){
	tag->depth = dep;
	if(tag->left == NULL && tag->right == NULL){tag->height = 0; return;}
	if ( tag->left != NULL){serach_depth(tag->left , dep+1);}
	if ( tag->right != NULL){serach_depth(tag->right , dep+1);}
	if ( tag->left == NULL ){
		tag->height = tag->right->height + 1;
	}
	if ( tag->right == NULL){
		tag->height = tag->left->height + 1;
	}
	if ( tag->left != NULL && tag->right != NULL){
		if ( tag->left->height > tag->right->height){
			tag->height = tag->left->height + 1;
		}else {
			tag->height = tag->right->height + 1;
		}
	}
}



Measured memory_bytes: 2048
B=[0]*2**19;s=->i{r=0;(r=[r,B[i]].max;i-=i&-i)while i>0;r}
n,*a=`dd`.split.map &:to_i;
a.pop(n).zip(a){|a,h|a+=s[h];(B[h]=[B[h],a].max;h+=h&-h)while h<2**19}
p s[n]

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
// using ll = long long;
// using vi = vector<int>;
// using vvi = vector<vi>;
// using vl = vector<long long>;
// using vvl = vector<vl>;
// using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main () {
  int N = si();
  std::vector<int> H(N);
  int max=0,num=0;
  for (size_t i = 0; i < N; i++) {
    cin >> H[i];
    if(max <= H[i]) {
      max =  H[i];
      num++;
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
  int N,Y;
  cin>>N>>Y;
  for(int i=0;i<=N;i++){
     for(int j=0;j<=N-i;j++){
        int c=N-i-j;
        if(10000*i+5000*j+1000*c==Y){cout<<i<<" "<<j<<" "<<c<<endl;return 0;}
     }
  }
  cout<<"-1 -1 -1"<<endl;
return 0;}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  int i,j;
  char s[101],t[101];
  char b;
  int ls,lt;
  int x=0;
  
  scanf("%s",s);
  scanf("%s",t);
  
  ls=strlen(s);
  lt=strlen(t);
  
  for(i=0;i<ls;i++){
    for(j=i;j<ls;j++){
      if(s[i]>s[j]){
        b=s[i];
        s[i]=s[j];
        s[j]=b;
      }
      else{}
    }
  }
  
  for(i=0;i<lt;i++){
    for(j=i;j<lt;j++){
      if(t[i]<t[j]){
        b=t[i];
        t[i]=t[j];
        t[j]=b;
      }
      else{}
    }
  }
  
  for(i=0;i<101;i++){
    if(s[i]==t[i]){}
    if(s[i]<t[i]){
      x=1;
      break;
    }
    if(s[i]>t[i]){
      x=0;
      break;
    }
  }
  
  if(x==0)printf("No\n");
  if(x==1)printf("Yes\n");
  
  return 0;
}


Measured memory_bytes: 1648
#include<stdio.h>
int main(){
  int a,b,c,d,e;
  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
  a=a*60+b;
  b=c*60+d;
  a=b-a;
  if(a<=e)printf("0");
  else
    printf("%d",a-e);
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(0)==S.at(1) || S.at(1)==S.at(2) || S.at(2)==S.at(3)) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    map<int, int> a;
    rep(i, N){
        ll tmp; cin >> tmp;
        if (a.find(tmp) != a.end()){
            a[tmp] += 1;
        } else {
            a[tmp] = 1;
        }
    }
    ll cnt = 0;
    for (auto v: a){
        if (v.second > v.first){
            cnt += v.second - v.first;
        } else if (v.second < v.first){
            cnt += v.second;
        }
    }
    cout << cnt << endl;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4736
# -*- coding: utf-8 -*-
import numpy as np
N = int(input())
p = np.zeros(N, dtype=int)
for i in range(N):
  p[i] = int(input())

p_sort = np.sort(p)
sum = p_sort[-1]*0.5
for i in range(N-1):
  sum += p_sort[i]
print(int(sum))


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


using namespace std;

#define MAXN 200010

char s[MAXN];
long long n;


int main() {
    scanf("%s", s+1);
    n = strlen(s+1);
    long long ans = 0;
    long long i, j;
    long long beg = 0;
    long long ca;
    for (i=1; i<=n; i++) {
        if (beg==0) {
            if (s[i]=='A') {
                beg = 1;
                ca = 1;
            }
        }
        else {
            if (s[i]=='A') {
                ca++;
            }
            else {
                if (s[i]=='B' && i+1<=n && s[i+1]=='C') {
                    ans+=ca;
                }
                else if (s[i]=='C' && s[i-1]=='B') {
                    continue;
                }
                else {
                    beg = 0;
                    ca = 0;
                }
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}








Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = c-a+b;
    if(ans>=0)cout << ans << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))

def avg2(x):
  result = 0
  if (x == 0):
    result = 0
  elif(x == 1):
    result = 1 * 2
  else:
    result = (1 + x)
  return result

check_ary = P[0:K]
avg2_ary = list(map(avg2, check_ary))  # 整数で扱いたいので*2している。
max2_value = sum(avg2_ary)
current_value = max2_value

for index in range(1,N - K + 1):
  # print(avg2(P[index-1 + K]))
  # print(avg2(P[index-1]))

  next_value = current_value - avg2(P[index-1]) + avg2(P[index-1 + K])
  if (max2_value < next_value):
    max2_value = next_value
  current_value = next_value # 値の更新ができていなかった。

print(max2_value/2)

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

int N;
const int MAXN = 105, mod = 1e9+7;

char S[3][MAXN];
int f[MAXN][8][8];

int main()
{
	scanf("%d", &N);
	scanf("%s%s", S[1]+1, S[2]+1);
	f[1][7][7] = 1;
	int nxt, ans = 0;
	for (int i = 1; i <= N; i = nxt) {
		if (S[1][i] == S[2][i]) 
			nxt = i+1;
		else nxt = i+2;
		for (int j = 0; j < 8; j++) {
			for (int t = 0; t < 8; t++) {
				// cerr << f[i][j] << " ";
				if (S[1][i] == S[2][i]) {
					for (int k = 0; k < 3; k++)
						if ((j&(1<<k)) && (t&(1<<k)))
							(f[nxt][7^(1<<k)][7^(1<<k)] += f[i][j][t]) %= mod;
				} else
					for (int k = 0; k < 3; k++)
						for (int p = 0; p < 3; p++) {
							if (k == p) continue;
							if ((j&(1<<k)) && (t&(1<<p)))
								(f[nxt][7^(1<<k)][7^(1<<p)] += f[i][j][t]) %= mod;
						}
			}
		}
		// cerr << endl;
	}
	for (int j = 0; j < 8; j++)
		for (int k = 0; k < 8; k++)
			(ans += f[nxt][j][k]) %= mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Two Colors Card Game
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef map<string,int> msi;

/* global variables */

msi ss, ts;

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    ss[s]++;
  }

  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    ts[s]++;
  }

  int maxc = 0;
  for (msi::iterator mit = ss.begin(); mit != ss.end(); mit++) {
    msi::iterator mit1 = ts.find(mit->first);
    int c = mit->second - (mit1 != ts.end() ? mit1->second : 0);
    if (maxc < c) maxc = c;
  }

  printf("%d\n", maxc);
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    bool flag = false;
    if (S[2]==S[3] && S[4]==S[5]){
        flag = true;
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int X = sc.nextInt();
			final int Y = sc.nextInt();
			final int Z = sc.nextInt();
			
			System.out.println(Z + " " + X + " " + Y);
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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;}

int main(){
  double n,m;cin>>n>>m;
  double a = 1.0-pow(0.5,m);
  double b = pow(0.5,m);
  double c = 1900.0*m + 100.0 * (n-m);
  double ans = 0.0;
  double k = 1.0;
  bool ok = true;
  while(ok){
    ans += pow(a,k-1)*b*c*k;
    k = k + 1.0;
    //cout<<k;
    if(pow(a,k-1)*b*c*k<0.001) ok = false;
  }
  int res;
  res = ans;
  cout<<res+1;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char ss[][4]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
int main(){
	char s[10];
	int i,flag;
	scanf("%s",s);
	for( i = 0;i <= 6;i++)
	  if(strcmp(s,ss[i])==0){
	  flag = 6-i; 
	  }
	  if(flag)printf("%d",flag);
	  else printf("7");
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1), B(N+1), C(N+1);
    for(int i = 1; i <= N ; i++) cin >> A.at(i);
    for(int i = 1; i <= N ; i++) cin >> B.at(i);
    for(int i = 1; i <= N ; i++) cin >> C.at(i);
    sort(all(A));
    sort(all(B));
    sort(all(C));
    A.at(0) = INF;
    B.at(0) = INF;
    C.at(0) = INF;
    A.push_back(INF);
    B.push_back(INF);
    C.push_back(INF);

    vector<ll> C_B(100010), B_A(100010), B_A_sum(100010);
    for(int i = 1; i <= N ; i++){
        int count = C_B.at(i-1);
        while(C.at(i) > B.at(count + 1)) count++;
        C_B.at(i) = count;
    }

    for(int i = 1; i <= N ; i++){
        int count = B_A.at(i-1);
        while(B.at(i) > A.at(count + 1)) count++;
        B_A.at(i) = count;
    }
    
    for(int i = 1; i <= N ; i++){
        B_A_sum.at(i) = B_A_sum.at(i - 1) +  B_A.at(i);
    }

    ll ans = 0;
    for(int i = 1; i <= N ; i++){
        int tmp = C_B.at(i);
        ans += B_A_sum.at(tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3816
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n;
		int s[];
		int result;
		int max_i;
		int min_i;

		while (true){
			n = sc.nextInt();
			if (n == 0){
				break;
			}

			s = new int[n];
			result = 0;
			max_i = 0;
			min_i = 0;

			for (int i = 0; i < n; i++){
				s[i] = sc.nextInt();

				if (s[i] > s[max_i]){
					max_i = i;
				}else if (s[i] < s[min_i]){
					min_i = i;
				}
			}

			for (int i = 0; i < n; i++){
				if (i != max_i && i != min_i){
					result += s[i];
				}
			}

			System.out.println("" + (result / (n - 2)));
		}

	}
}

Measured memory_bytes: 20944
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main()
{
	long long n,k;
	cin>>n>>k;
	long long ans=0;
	long long q=0;
	for(long long i=k;i<=n+1;i++)
	{
		q=((i*n)%mod-(i-1)*i%mod)%mod;
		ans=(ans+q+1)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), w = sc.nextInt();
        long[] s = new long[a + 2], t = new long[b + 2], x = new long[w];
        s[0] = t[0] = -100000000;
        s[a+1] = t[b+1] = 100000000;
        s[0] *= 1000;
        t[0] = s[0];
        s[a+1] *= 1000;
        t[b+1] = s[a+1];
        for(int i = 1; i <= a; i++){
            s[i] = sc.nextLong();
        }
        for(int i = 1; i <= b; i++){
            t[i] = sc.nextLong();
        }
        for(int i = 0; i < w; i++){
            x[i] = sc.nextLong();
        }
        
        for(int i = 0; i < w; i++){
            int p = -Arrays.binarySearch(s, x[i]) - 1;
            int q = -Arrays.binarySearch(t, x[i]) - 1;
            long ans = Math.max(s[p] - x[i], t[q] - x[i]);
            ans = Math.min(ans, Math.max(x[i] - s[p-1] , t[q] - x[i]) + 2 * Math.min(x[i] - s[p-1] , t[q] - x[i]));
            ans = Math.min(ans, Math.max(x[i] - t[q-1] , s[p] - x[i]) + 2 * Math.min(x[i] - t[q-1] , s[p] - x[i]));
            ans = Math.min(ans, Math.max(x[i] - s[p-1], x[i] - t[q-1]));
            System.out.println(ans);
        }
    }
}
 

Measured memory_bytes: 96228
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int n;
void make(double x1, double y1, double x2, double y2, int m);

int main()
{
    cin >> n;
    make(0.000000, 0.000000, 100.000000, 0.000000, n);
    //cout << 100.000000 << " " << 0.000000 << endl;
    printf("%f %f\n", 100.000000, 0.000000);
}

void make(double x1, double y1, double x2, double y2, int m)
{
    if (m == 0) {
        printf("%f %f\n", x1, y1);
    } else {
        double dx = x2 - x1;
        double dy = y2 - y1;
        double px1 = x1 + dx / 3.0;
        double py1 = y1 + dy / 3.0;
        double px2 = x1 + dx / 2.0 - (sqrt(3.0) / 6.0) * dy /*/ sqrt(dx * dx + dy * dy)*/;
        double py2 = y1 + dy / 2.0 + (sqrt(3.0) / 6.0) * dx /*/ sqrt(dx * dx + dy * dy)*/;
        double px3 = x1 + dx * 2.0 / 3.0;
        double py3 = y1 + dy * 2.0 / 3.0;
        m--;
        make(x1, y1, px1, py1, m);
        make(px1, py1, px2, py2, m);
        make(px2, py2, px3, py3, m);
        make(px3, py3, x2, y2, m);
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll div_c = b/c - (a-1)/c; 
    ll div_d = b/d - (a-1)/d; 
    ll count = div_c + div_d - ( b/(c*d/(__gcd(c,d))) ) + ( (a-1)/(c*d/(__gcd(c,d))) );
    
    ll ans = abs(b-a+1-count);
    
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int a = 0, b = 0;
		var sb = new StringBuilder();
		foreach(var c in S){
			switch(c){
				case 'c' : {
					sb.AppendLine("No");
				} break;
				case 'a' : {
					if(a + b < A + B){
						sb.AppendLine("Yes");
						a++;
					} else {
						sb.AppendLine("No");
					}
				} break;
				case 'b' : {
					if(a + b < A + B && b < B){
						sb.AppendLine("Yes");
						b++;
					} else {
						sb.AppendLine("No");
					}
				} break;
			}
		}
		
		Console.Write(sb.ToString());
		
	}
	int N,A,B;
	String S;
	public Sol(){
		var d = ria();
		N = d[0]; A = d[1]; B = d[2];
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int64_t gcd(int64_t a,int64_t b){return b?gcd(b,a%b):a;}

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

int64_t N, M; cin>> N >> M;

// Mの約数
int64_t maxi = 0;
for (int64_t i = 1; i * i <= M; ++i){
    if (M % i == 0) {
        if (i <= M/N) maxi = max(maxi, i);
        if (M/i <= M/N) maxi = max(maxi, M/i);
    }
}

cout << maxi << "\n";
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    string S; cin >> S;
    const int n = S.length();
    rep(i, n-1) {
        if(S[i] == S[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }
    rep(i, n-2) {
        if(S[i] == S[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> x(100009);
  for(int i=1;i<=N;i++)cin >> x[i];
  long long q=2000000000;
  for(int i=1;i+K-1<=N;i++){
    long long w=x[i+K-1]-x[i]+min(abs(x[i+K-1]),abs(x[i]));
    q=min(q,w);
  }
  cout << q << endl;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    int state = 0;
    for(int i=0; i<N; i++){
        if(S[i] == 'A'){
            state = 1;
        }
        else if(S[i] == 'B' && state == 1){
            state = 2;
        }
        else if (S[i] == 'C' && state == 2){
            state = 0;
            cnt ++;
        }
        else{
            state = 0;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())   
l = []
for i in range(1, 10):
    for j in range(1, 10):
        if n == i * j:
            l.append("Yes")
        else:
            l.append("No")   
if l.count("Yes") >= 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

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

signed main()
{
    ios::sync_with_stdio(false);
        string s;
        cin >> s;
        bool c = false;
        bool f = false;
        REP(i,0,s.size())
        {
                if(c){
                        if(s[i] == 'F'){

                                f = true;
                                break;
                        }
                }
                else if(s[i] == 'C')
                        c = true;
        }
        cout << (f ? "Yes" : "No") << '\n';

}


Measured memory_bytes: 256
#include<iostream>

#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

void func(int N,int S){

	int table[N],index = N-1,tmp;

	priority_queue<int> Q;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		Q.push(tmp);
	}

	while(!Q.empty()){
		table[index--] = Q.top();
		Q.pop();
	}

	int sum = 0,left,right,m,tmp_min;

	for(int i = 0; i < N-1; i++){
		left = i+1,right = N-1,m = (left+right)/2;

		tmp_min = N;

		while(left <= right){
			if(table[i] + table[m] > S){
				tmp_min = min(tmp_min,m);
				right = m-1;
			}else{
				left = m+1;
			}
			m = (left+right)/2;
		}
		if(tmp_min != N){
			sum += N - tmp_min;
		}
	}

	printf("%d\n",sum);
}

int main(){

	int N,S;

	while(true){
		scanf("%d %d",&N,&S);
		if(N == 0 && S == 0)break;

		func(N,S);
	}

	return 0;
}

Measured memory_bytes: 2796
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10**8
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064