akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
  	int64_t N;
  	cin >> N;
  	int res = 100000, res_a = 0, res_b = 0, res2 = 0;;
  	int64_t a, b;
  	for (int i = 1; i <= (int)sqrt(N) + 1; i++){
      	a = i;
      	if (N % a == 0){
          	b = N / a;
          	while(a > 0){
              	res_a++;
              	a /= 10;
            }
          	while(b > 0){
              	res_b++;
              	b /= 10;
            }
          	if (res_a >= res_b) res2 = res_a;
          	else res2 = res_b;
          	if (res2 < res) res = res2;
          	res2 = 0;
          	res_a = 0;
          	res_b = 0;
        }
    }
  	cout << res << endl;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
h = np.array(input().split(), dtype='int32')
dp = np.zeros(N, dtype='int32')

dp[1] = np.abs(h[1]-h[0])
if N > 2:
    for i in range(2, N):
        dp[i] = np.min(dp[i-2:i] + np.abs(h[i]-h[i-2:i]))

print(dp[-1])

Measured memory_bytes: 21180
input = $stdin.read.split("\n")

input.each do |line|
    a = line.split("")
    nx = a.select {|c| c!="x"}

    f = nx[0...nx.length/2]
    l = nx[(nx.length-nx.length/2)...(nx.length)].reverse

    if f==l
        n = 0
        i = 0
        j = a.length-1
        while i <= j
            # p [a[i], a[j]]
            if a[i] == a[j]
                i += 1
                j -= 1
            elsif a[i] == 'x'
                i += 1
                n += 1
            else
                j -= 1
                n += 1
            end
        end
        puts n
    else
        puts -1
    end
end


Measured memory_bytes: 10620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

const double PI = acos(-1.0);

int main()
{
	double r;
	cin >> r;
	cout << fixed << setprecision(8) << PI * r * r << " ";
	cout << fixed << setprecision(8) << 2.0 * PI * r << endl;
	return 0;
}



Measured memory_bytes: 3192
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d", &n);
	vector<vector<int> > g;
	g.resize(n);
	for (int i = 1, a, b; i < n; ++i) {
		scanf("%d%d", &a, &b);
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<int> q;
	vector<int> parent(n, -1);
	q.push(0);
	parent[0] = 0;
	vector<int> ord;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		ord.push_back(u);
		for (auto &v : g[u])
			if (parent[v] == -1) {
				parent[v] = u;
				q.push(v);
			}
	}
	reverse(ord.begin(), ord.end());
	const int M = 1000000007;
	vector<vector<int> > dp(n, vector<int>(2));
	for (auto u : ord) {
		for (int black = 0; black < 2; ++black) {
			int w = 1, b = 1;
			for (auto v : g[u])
				if (v != parent[u]) {
					w = (ll)w*dp[v][0] % M;
					b = (ll)b*dp[v][1] % M;
				}
			dp[u][black] = (w + b*(1 - black)) % M;
		}
	}
	printf("%d\n", dp[0][0]);
	return 0;
}

Measured memory_bytes: 12552
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
    ll x, k, d;
    cin >> x >> k >> d;
    if(!x) {
        if(k & 1) cout << d;
        else cout << 0;
        return;
    }
    if(x < 0) {
        ll f = -x / d;
        if(f >= k) {
            cout << abs(x + d * k);
            return;
        }
        ll cur = x + d * f;
        k -= f;
        multiset <pll> st;
        st.insert(mp(abs(cur), 0ll));
        for(ll i = 1; i <= min(k, 40ll); ++i) st.insert(mp(abs(cur - i * d), i)), st.insert(mp(abs(cur + i * d), i));
        ll ans = 1e18;
        for(auto v : st) {
            ll dif = k - v.s;
            if(dif & 1) ans = min({ans, abs(v.f + d), abs(v.f - d)});
            else ans = min(ans, v.f);
        }
        cout << ans;
        return;
    }
    ll f = x / d;
    if(f >= k) {
        cout << abs(x - d * k);
        return;
    }
    ll cur = x - d * f;
    k -= f;
    multiset <pll> st;
        st.insert(mp(abs(cur), 0ll));
        for(ll i = 1; i <= min(k, 40ll); ++i) st.insert(mp(abs(cur - i * d), i)), st.insert(mp(abs(cur + i * d), i));
        ll ans = 1e18;
        for(auto v : st) {
            ll dif = k - v.s;
            if(dif & 1) ans = min({ans, abs(v.f + d), abs(v.f - d)});
            else ans = min(ans, v.f);
        }
        cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=600+10;
struct point{int x,y;}li[maxn*maxn];
int tmp;
int co[2][maxn][maxn],n,d1,d2;
void dfs(int x,int y,int l){
	REP(i,1,tmp){
		int u=x+li[i].x,v=y+li[i].y;
		if(u>=2*n || v>=2*n || u<0 || v<0) continue;
		if(co[l][u][v]==-1) co[l][u][v]=co[l][x][y]^1,dfs(u,v,l);
	}
}
int main(){
	n=read(),d1=read(),d2=read();
	for(int i=0;i*i<=d1;++i){
		int j=sqrt(d1-i*i);
		while(j*j+i*i>d1) --j;
		while(j*j+i*i<d1) ++j;
		if(i*i+j*j!=d1) continue;
		li[++tmp]=(point){i,j};
		li[++tmp]=(point){-i,j};
		li[++tmp]=(point){i,-j};
		li[++tmp]=(point){-i,-j};
	}
	REP(l,0,1) REP(i,0,2*n-1) REP(j,0,2*n-1) co[l][i][j]=-1;
	REP(i,1,2*n-1) REP(j,0,2*n-1) if(co[0][i][j]==-1) co[0][i][j]=0,dfs(i,j,0);
	tmp=0;
	for(int i=0;i*i<=d2;++i){
		int j=sqrt(d2-i*i);
		while(j*j+i*i>d2) --j;
		while(j*j+i*i<d2) ++j;
		if(i*i+j*j!=d2) continue;
		li[++tmp]=(point){i,j};
		li[++tmp]=(point){-i,j};
		li[++tmp]=(point){i,-j};
		li[++tmp]=(point){-i,-j};
	}
	REP(i,0,2*n-1) REP(j,0,2*n-1) if(co[1][i][j]==-1) co[1][i][j]=0,dfs(i,j,1);
	REP(u,0,1) REP(v,0,1){
		int sum=0;
		REP(i,0,2*n-1) REP(j,0,2*n-1) if(co[0][i][j]==u && co[1][i][j]==v) ++sum;
		if(sum>=n*n){
			sum=n*n;
			REP(i,0,2*n-1) REP(j,0,2*n-1) if(co[0][i][j]==u && co[1][i][j]==v){
				printf("%d %d\n",i,j);
				--sum;
				if(!sum) return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 33024
import itertools
import math
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
X = sorted(itertools.permutations(range(1,N+1)))#1~Nの順列をソートしたもの
#itertools.permutations(range(n,m))ではリストの中にタプルが入った構造になる

qn = 0
num = 0
for i in X:
    num += 1
    if i == P:
        pn = num
    if i == Q:
        qn = num
print(abs(pn-qn))

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    vector<ll> L;
    ll count = 0;
    cin >> N;
    L.resize(2 * N);
    rep(i, 2 * N) cin >> L[i];
    sort(L.begin(), L.end());
    rep(i, N) count += L[2 * i];
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%s', $n);

// echo $n;

$array = explode("/", $n);

// echo $array[1];

if($array[0] < 2019){
  echo 'Heisei';
} else if( (int)$array[1] < 5) {
  echo 'Heisei';
} else{
  echo 'TBD';
}

Measured memory_bytes: 4728
#include <iostream>
#include <set>
#include <string>
#include <algorithm>

int main() {
	int m;
	std::cin >> m;
	for (int i = 0; i < m; i++) {
		//入力
		std::string base;
		std::cin >> base;
		//演算
		std::set<std::string> collection;
		for (int j = 1; j < (int) (base.size()); j++) {
			std::string L, R, L2, R2;
			L = L2 = base.substr(0, j);
			R = R2 = base.substr(j);
			reverse(L2.begin(), L2.end());
			reverse(R2.begin(), R2.end());
			collection.insert(L + R);
			collection.insert(L2 + R);
			collection.insert(L + R2);
			collection.insert(L2 + R2);
			collection.insert(R + L);
			collection.insert(R2 + L);
			collection.insert(R + L2);
			collection.insert(R2 + L2);
		}
		//出力
		std::cout << collection.size() << std::endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
int main()
{
    int n;
    string s;
    double nr;
    double sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> nr;
        cin >> s;
        if (s == "JPY")
        {
            sum += nr;
        }
        else if (s == "BTC")
        {
            sum = sum + (nr * 380000.0);
        }
    }
    cout << sum;
    return 0;
}


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

int main(void){
    int n,i,j,minj,count1=0;
    cin>>n;
    vector<int> a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n-1;i++){
        minj=i;
        for(j=i+1;j<n;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        if(minj!=i){
            swap(a[i],a[minj]);
            count1++;
        }
    }
    for(i=0;i<n-1;i++){
        cout<<a[i]<<" ";
    }
    cout<<a[n-1]<<endl<<count1<<endl;
}


Measured memory_bytes: 3088
a, b, c, d = map(int, input().split())
all_count = b - a + 1

def f(x, y, z):
    cnt = y // z - x // z
    if x % z == 0:
        cnt += 1
    return cnt

div_c_count = f(a, b, c)
div_d_count = f(a, b, d)

import fractions
lcm = c * d // fractions.gcd(c, d)
cm_count = f(a, b, lcm)

print(all_count - (div_c_count + div_d_count - cm_count))

Measured memory_bytes: 64236
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	items := map[string]struct{}{}
	for i := 0; i < n; i++ {
		var item string
		fmt.Scanf("%s", &item)
		items[item] = struct{}{}
	}

	fmt.Printf("%d\n", len(items))
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;
int s[10], c[10];

bool f(int x){
    std::string str = std::to_string(x);

    if(str.size() != N){
        return false;
    }

    for(int i=0;i<M;++i){
        if(s[i] >= str.size() || (str[s[i]] - '0') != c[i]){
            return false;
        }
    }

    return true;
}

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

  std::cin >> N >> M;

  for(int i=0;i<M;++i){
      std::cin >> s[i] >> c[i];
      s[i] -= 1;
  }

  int res = -1;

  for(int i=0;i<1000;++i){
      if(res == -1 && f(i)){
          res = i;
      }
  }

  std::cout << res << std::endl;
}


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

int main() {
	int n;
	long long A[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(A, A + n);
	int min = A[0];
	int max = A[n - 1];
	cout << max - min << endl;

	

	return 0;
}

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

struct Point{
  int x;
  int y;
};

bool operator<(Point a, Point b){
  return a.x+a.y<b.x+b.y;
}

long long mo=(long long)1e9+7;
long long fac[200000];
long long ifac[200000];

Point point[30001];
int H,W,N;

long long pow(long long a,long long n){
  long long ret=1;
  for(;n>0;n>>=1,a=a*a%mo){
    if(n%2==1){
      ret=ret*a%mo;

    }
  }
  return ret;
}

long long inv(long long a){
  return pow(a,mo-2);
}


void build(){
  fac[0]=1;
  ifac[0]=1;
  for(int i=1;i<200000;++i){
    fac[i]=fac[i-1]*i%mo;
    ifac[i]=inv(fac[i]);
  }
}

long long comb(int n,int k){
  return fac[n]*ifac[k]%mo*ifac[n-k]%mo;
}

long long dp[3001];

int main(){
  build();
  std::cin>>H>>W>>N;
  for(int i=0;i<N;++i){
    std::cin>>point[i].y>>point[i].x;
    --point[i].x;
    --point[i].y;
  }
  point[N].y=H-1;
  point[N].x=W-1;
  std::sort(point, point+N);
  for(int i=0;i<=N;++i){
    dp[i]=comb(point[i].y+point[i].x,point[i].x);
    for(int j=0;j<i;++j){
      int dx=point[i].x-point[j].x;
      int dy=point[i].y-point[j].y;
      if(dx<0||dy<0)continue;
      dp[i]=(dp[i]-dp[j]*comb(dx+dy,dx)%mo+mo)%mo;
    }
  }
  std::cout<<dp[N]<<std::endl;
  return 0;
}


Measured memory_bytes: 3456
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://atcoder.jp/contests/dp/tasks/dp_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,W; cin >> N >> W;
    vector<ll> w(N),v(N);
    for(int i = 0; i < N;i++) cin >> w[i] >> v[i];
    vector<ll> dp(1000*100+1,LINF);
    dp[0] = 0;
    for(int i = 0; i < N;i++){
        for(int j = 100000; j >= 0;j--){
            if(dp[j]==LINF) continue;
            if(dp[j]+w[i] <= W){
                dp[v[i]+j] = min(dp[v[i]+j],dp[j]+w[i]);
                res = max(res,v[i]+j);
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod009 = 1000000009;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, x[100000];
ll res;

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1)a = a*x%mod;
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	ll t = 0;
	for (int i = 1; i <= N - 1; i++) {
		t += modinv(i);
		t %= mod;
		res += t*(x[i] - x[i - 1]);
		res %= mod;
	}
	for (int i = 1; i <= N - 1; i++) {
		res *= i;
		res %= mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	string s; cin >>s;
	ll ans = 0;
	rep(i,0,s.size()){
		ans += (s[i]-'0');
	}
	cout << (ans % 9==0 ? "Yes":"No")<<endl;

	return 0;
}

Measured memory_bytes: 3724
#include<stdio.h>
int main(){
 int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b && a!=c){
    printf("Yes");
  }
  else if(a==c && a!=b){
    printf("Yes");
  }
  else if(c==b && a!=c){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

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

int main(){
  int A , B , K;
  cin >> A >> B >> K;

  set<int> s;
  for (int i = A; i <= A + K - 1; i++){
    if (i >= A && i <= B){
      cout << i << endl;
      s.insert(i);
    }
    
  }

  for (int i = B - K + 1; i <= B; i++)
  {
    if (!s.count(i) && i >= A && i <= B){
      cout << i << endl;
    }
    
  }
  


}

Measured memory_bytes: 3648
#include<stdio.h>

typedef struct {
  int node;
  int p;
  int type;
  int left;
  int right;
  int a;
} Node;

Node T[100000];
int A[100000];

int depth(int count,int p){
  count++;
  if(T[p].p == -1) return count;
  depth(count,T[p].p);
}

int main(){
  int n,i,j,k,l,m;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    T[i].a = 0;
    T[i].right = T[i].left = -1;
  }

  for(i = 0;i < n;i++){
    scanf("%d",&j);
    T[j].node = j;
    T[j].type = 2;
    scanf("%d",&k);
    if(k) T[j].type = 1;
    for(l = 0;l < k;l++){
      scanf("%d",&m);
      if(l == 0) T[j].left = m;
      A[l] = m;
      T[m].p = j;
      T[m].a = 1;
      if(l) T[A[l-1]].right = A[l];
    }
  }

  for(i = 0;i < n;i++){
    if(T[i].a == 0){
      T[i].p = -1;
      T[i].type = 0;
    }
  }

  for(i = 0;i < n;i++){
    k = 0;
    printf("node %d: parent = %d, depth = %d, ",T[i].node,T[i].p,depth(-1,T[i].node));
    if(T[i].type == 0) printf("root, ");
    else if(T[i].type == 1) printf("internal node, ");
    else printf("leaf, ");
    printf("[");
    for(j = T[i].left;j != -1;j = T[j].right){
        if(k) printf(", ");
        printf("%d",T[j].node);
        k++;
    }
    printf("]\n");
  }

  return 0;
}



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

int main() {
    int n;
    long long maxi = -1000001;
    long long mini = 1000001;
    long long sum = 0;
    cin >> n;
    vector<long long> vec(n);
    for(int i = 0; i < n; i++) {
        cin >> vec[i];
        if(vec[i] > maxi) maxi = vec[i];
        if(vec[i] < mini) mini = vec[i];
        sum += vec[i];
    }
    cout << mini << " " << maxi << " " << sum << endl;
}


Measured memory_bytes: 3176
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w) = (v[0], v[1]);
    let mut grid = vec![vec![]; h];
    for i in 0..h {
        grid[i] = read_vec::<i64>();
    }
    for i in 0..h {
        let b = read_vec::<i64>();
        for j in 0..w {
            grid[i][j] -= b[j];
            grid[i][j] = grid[i][j].abs();
        }
    }
    let mut u_grid = vec![vec![]; h];
    for i in 0..h {
        u_grid[i] = grid[i].iter().map(|&x| x as usize).collect::<Vec<_>>();
    }

    let max_val = 6400;
    let mut dp = vec![vec![vec![false; max_val]; w]; h];
    dp[0][0][u_grid[0][0]] = true;
    for y in 0..h {
        for x in 0..w {
            for v in 0..max_val {
                if x > 0 && dp[y][x - 1][v] {
                    let diff = (v as i64 - u_grid[y][x] as i64).abs() as usize;
                    dp[y][x][diff] = true;
                    if v + u_grid[y][x] < max_val {
                        dp[y][x][v + u_grid[y][x]] = true;
                    }
                }
                if y > 0 && dp[y - 1][x][v] {
                    let diff = (v as i64 - u_grid[y][x] as i64).abs() as usize;
                    dp[y][x][diff] = true;
                    if v + u_grid[y][x] < max_val {
                        dp[y][x][v + u_grid[y][x]] = true;
                    }
                }
            }
        }
    }
    let mut ans = std::usize::MAX;
    for v in 0..max_val {
        if dp[h - 1][w - 1][v] {
            ans = v;
            break;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 49404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

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

int main(void){
    int N; cin >> N;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    
    ll g = 0;
    for(int i = 0; i < N; i++){
        g = gcd(g, A[i]);
    }
    
    cout << g << endl;
}


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

void main() {
  auto S = [readln.chomp, readln.chomp, readln.chomp];

  auto current = 0;
  int[3] count;
  while (true) {
    if (count[current] == S[current].length) {
      writeln(current == 0 ? "A" : current == 1 ? "B" : "C");
      return;
    }
   auto next = S[current][count[current]] - 'a';
   count[current]++;
   current = next;
  }
}


Measured memory_bytes: 256
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        count=0
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        count=count+1
        print(count)


Measured memory_bytes: 5592
//file_name:ABC47_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,t;
    scanf("%d%d",&n,&t);
    ll a[n] = {};
    ll ma[n] = {};
    ll mi[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
        if(i==0){
            mi[i]=a[i];
        }else{
            mi[i]=min(mi[i-1],a[i]);
        }
    }
    ma[n-1] = a[n-1];
    drep(i,n-1){
        ma[i] = max(ma[i+1],a[i]);
    }
    ll m = 0;
    rep(i,n){
        m = max(m,ma[i]-mi[i]);
    }

    ll ans = 0;
    ll ma2;
    rep(i,n){
        if(ma[i]-mi[i]==m){
            if(ans==0){
                ma2 = ma[i];
                ans++;
            }else{
                if(ma[i]!=ma2){
                    ma2 = ma[i];
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**7)

N = int(input())
a = list(map(int, input().split()))
b = [0] * N
ans = 0

def dfs(v):
    global ans
    if v == N:
        tmp = 1
        for i in b:
            tmp *= i
        if tmp % 2 == 0:
            ans += 1
        return

    b[v] = a[v] - 1
    dfs(v + 1)
    b[v] = a[v]
    dfs(v + 1)
    b[v] = a[v] + 1
    dfs(v + 1)
    return

dfs(0)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void) {
  int A,B;
  scanf("%d %d",&A,&B);
  if (A == 1) A = 20;
  if (B == 1) B = 20;
  if (A > B) {
    printf("Alice");
  } else if (B > A) {
    printf("Bob");
  } else {
    printf("Draw");
  }
  return 0;
}

Measured memory_bytes: 128
//https://algospot.com/judge/problem/read/CLOCKSYNC
#include <iostream>
#include <cstdio>
#include <functional>
#include <algorithm>
#include <climits>
#include <utility>
#include <string>
#include <stack>
#include <vector>
#include <queue>
#include <map>

#define LF '\n';
#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

int main(void)
{
	ios::sync_with_stdio(false);
	int k, x;
	cin >> k >> x;
	for (int st = x - k + 1; st <= x + k - 1; st++) cout << st << ' ';
	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	bool ans=false;
	for(int i=0;i<=x;i++)
	{
		if(i*2+(x-i)*4==y){
			ans=true;
			break;
		}
	}
	if(ans){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(void){
  int A, B;
  int ans[100][100];
  // 0 が white (連結成分数が A)，1 が black (連結成分数が B)

  cin >> A >> B;

  for(int i = 0 ; i < 100 ; i++){
    for(int j = 0 ; j < 50 ; j++){
      ans[i][j] = 0;
    }
    for(int j = 50 ; j < 100 ; j++){
      ans[i][j] = 1;
    }
  }

  int ptrx = 0;
  int ptry = 0;
  int tmpA = 1;
  int tmpB = 1;

  bool writeBlack = false;
  while(tmpA != A){
    if(ptrx < 100){
      writeBlack = true;
      ans[ptrx + 1][ptry]     = 1;
      ans[ptrx][ptry + 1]     = 1;
      ans[ptrx + 1][ptry + 1] = 1;
      tmpA++;
      ptrx += 2;
    }else{
      ptrx = 0;
      ptry += 2;
    }
  }
  if(writeBlack){tmpB++;}
  ptrx = 0;
  ptry = 50;

  if(tmpB > B){
    cout << "100 50" << endl;
    for(int i = 0 ; i < 100 ; i++){
      for(int j = 0 ; j < 50 ; j++){
        if(ans[i][j] == 0){
          cout << ".";
        }else{
          cout << "#";
        };
      }
      cout << endl;
    }
    return 0;
  }else{
    bool writeWhite = false;
    while(tmpB != B){
      if(ptrx < 100){
        writeWhite = true;
        ans[ptrx + 1][ptry]     = 0;
        ans[ptrx][ptry + 1]     = 0;
        ans[ptrx + 1][ptry + 1] = 0;
        tmpB++;
        ptrx += 2;
      }else{
        ptrx = 0;
        ptry += 2;
      }
    }
  }

  cout << "100 100" << endl;
  for(int i = 0 ; i < 100 ; i++){
    for(int j = 0 ; j < 100 ; j++){
      if(ans[i][j] == 0){
        cout << ".";
      }else{
        cout << "#";
      };
    }
    cout << endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int num,i,j,flag,cnt;
	int prime[78498];

	for(i = 0;i < 78498;i++){
		prime[i] = 0;
	}
	prime[0] = 2;

	while(scanf("%d",&num) != EOF){
		if(num == 1){
			cnt = 0;
		}else{
			cnt = 1;
		}
		for(i = 3;i <= num;i += 2){
			flag = 1;
			for(j = 0;prime[j]*prime[j] <= i;j++){
				if(i % prime[j] == 0){
					flag = 0;
					break;
				}
			}
			if(flag){
				if(prime[cnt] == 0){
					prime[cnt] = i;
				}
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}

	return 0;
}

Measured memory_bytes: 904
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
    int f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

inline LL gl()
{
    LL f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, m;
bool ton[N];

int main()
{
    //File("");
    m = gi(), n = gi();
    int mx = INF, id = INF;
    for (int i = 1; i <= n; i+=1) 
    {
    	int x = gi();
    	ton[x] = true;
    }
    mx = m + 1, id = -1;
    for (int i = 0; i <= 1000; i+=1)
    {
    	if (ton[i]) continue;
    	int x = i;
    	int mxx = abs(x - m);
    	if (mxx < mx) mx = mxx, id = x;
    	else if (mxx == mx && x < id) id = x;
    }
    cout << id << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u)a=a-1;
  if(t==u)b=b-1;
  cout<<a<<" "<<b;
}

Measured memory_bytes: 256
#abc065_b
N = int(input())
A = [int(input()) for i in range(N)]
A.insert(0,0)
flg = [False]*(N+1)
idx = 1
ans = -1
cnt = 0
while not flg[2]:
#    print(A[idx],idx,flg[A[idx]])
    if flg[A[idx]]:
        break
    else:
        flg[A[idx]]=True
        idx = A[idx]
        cnt +=1
if flg[2]:
    ans = cnt
print(ans)


Measured memory_bytes: 7976
/*
 this->author = Fuad Ashraful Mehmet, CSE-UAP
 ToDo--
 https://atcoder.jp/contests/abc173/tasks/abc173_f
*/
#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<(int)n;++i)
#define all(o) (o).begin(),(o).end()
#define dbg(o)  cerr<<"at "<<__LINE__<<" response = "<<o<<endl;

using namespace std;

typedef long long ll;
int n,m,k;

void HalfDead()
{
      ll tot=0;
      ll node;
      cin>>node;
      for(ll i=0;i<node;++i)
      {
            tot+=(i+1)*(node-i);
      }
      ll u,v;
      ll run=node-1;
      
      while(run--)
      {
            cin>>u>>v;
            u--;
            v--;
            if(u>v)swap(u,v);
            tot-=(u+1)*(node-v);
      }
      cout<<tot<<endl;
}
int main()
{
      ios_base::sync_with_stdio(0); cin.tie(nullptr);
      HalfDead();

      return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int get(int y, int x, vector<vector<int> > &A, vector<int> &flip) {
    return (A.at(y).at(x) + flip.at(y)) % 2;
}

int calc(vector<vector<int> > &A, vector<int> &flip) {
    int R = A.size();
    int C = A.at(0).size();
    int ans = 0;
    for (int x = 0; x < C; ++x) {
        int res = 0;
        for (int y = 0; y < R; ++y) {
            res += get(y, x, A, flip);
        }
        ans += max(res, R - res);
    }
    return ans;
}

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

    while (true) {
        int R, C;
        cin >> R >> C;
        if (R == 0 && C == 0) break;
        vector<vector<int> > A(R, vector<int>(C));
        for (int i = 0; i < R; ++i) {
            for (int j = 0; j < C; ++j) {
                cin >> A.at(i).at(j);
            }
        }
        int ans = 0;
        for (int tmp = 0; tmp < (1 << R); ++tmp) {
            bitset<10> s(tmp);
            vector<int> flip(R);
            for (int i = 0; i < R; ++i) {
                flip.at(i) = (int)(s.test(i));
            }
            ans = max(ans, calc(A, flip));
        }
        cout << ans << endl;
    }

    return 0;
}


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

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

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

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

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

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

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

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int x, y;
    cin >> x >> y;
    if (2*y-x>=0 && (2*y-x)%3==0) {
        combination cb(x);
        int c = (2*y-x)/3;
        mint ans = cb((x+c)/2, c);
        cout << ans << endl;
    }
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 18792
k,n = map(int,input().split())
a = list(map(int,input().split()))
dis = [0]*n
dis[0] = a[0]+k-a[n-1]
for i in range(1,n):
    dis[i] = a[i] - a[i-1]
m = max(dis)
print(k-m)

Measured memory_bytes: 78668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=9;i++)
    {
        if(n%i==0)
        {
            if((n/i)>=1&&(n/i)<=9)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

typedef long long ll;
const int N=2e5+10;
int n;
int a[N],pre_xor[N];
int l,r;
ll ans,cur,pre_sum[N];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	pre_xor[1]=pre_sum[1]=a[1];
	for(int i=1;i<n;i++){
		pre_sum[i]=pre_sum[i-1]+a[i];
		pre_xor[i]=pre_xor[i-1]^a[i];
	}
	cur=0;
	for(l=0;l<n;l++){
		while(r<n&&!(cur&a[r])){
			cur^=a[r];
			r++;
		}
		ans+=(ll)r-l;
		cur^=a[l];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
from bisect import *
def solve():
    ans = 0
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))+[float('inf')]
    B = list(map(int, input().split()))+[float('inf')]
    cumA = [0]*(N+1)
    cumB = [0]*(M+1)
    for i in range(N):
        cumA[i+1] = cumA[i]+A[i]
    for i in range(M):
        cumB[i+1] = cumB[i]+B[i]
    for i in range(N+1):
        rest = K-cumA[i]
        if rest<0:
            break
        ind = bisect_right(cumB,rest)
        ans = max(ans,i+ind-1)
    return ans
print(solve())

Measured memory_bytes: 47436
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N;
        static long X;
        static long[] niku, pan;
        

        public static void Input()
        {
            var cin = new Scanner();
            var input = cin.SplitReaderL();
            N = (int)input[0];
            X = input[1];

            niku = new long[N + 1];
            pan = new long[N + 1];
            niku[0] = 1;
            pan[0] = 0;
            for (var i = 1; i <= N; i++)
            {
                niku[i] = 2 * niku[i - 1] + 1;
                pan[i] = 2 * pan[i - 1] + 2;
            }
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);


            Console.WriteLine(Dfs(X, N));


            //Console.Out.Flush();
        }

        public static long Dfs(long x, int N)
        {
            long res = x;
            long ret = 0;

            if (N == 0) { return 1; }
           
            res--; //下のパン

            if (res >= niku[N - 1] + pan[N - 1]) 
            {
                res -= niku[N - 1] + pan[N - 1];
                ret += niku[N - 1];
            }
            else if (res > 0)
            {
               ret += Dfs(res, N - 1);
               res = 0;
            }//下のバーガー


            if (res > 0)
            {
               res--;
               ret++;
            }//真ん中の肉

            if (res >= niku[N - 1] + pan[N - 1])
            {
                res -= niku[N - 1] + pan[N - 1];
                ret += niku[N - 1];
            }
            else if (res > 0)
            {
                ret += Dfs(res, N - 1);
                res = 0;
            }

            if (res > 0)
            {
                res--;
            }


            return ret;
        }

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

        public int[] MultiLineReader(int N)
        {
            int[] ret = new int[N];
            for(var i = 0; i < N; i++)
            {
                ret[i] = int.Parse(Console.ReadLine());
            }

            return ret;
        }
        public long[] MultiLineReaderL(int N)
        {
            long[] ret = new long[N];
            for (var i = 0; i < N; i++)
            {
                ret[i] = long.Parse(Console.ReadLine());
            }

            return ret;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13396
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    int N;
    ll A,B;
    cin >> N >> A >> B;
    ll inf = 1e18;
    vector<int> l(N+1,0),p(N+1,0);
    for(int i=1;i<=N;i++) cin >> p[i];
    vector<vector<ll>> dp(N+1,vector<ll>(N+1,inf));
    for(int i=1;i<=N;i++) for(int j=1;j<=N;j++){
        if(p[j]==i) break;
        if(p[j]>i) l[i]++;
    }
    for(int j=0;j<=N;j++) dp[0][j] = 0;
    for(int i=1;i<=N;i++) for(int j=0;j<=N;j++){
        if(j<=l[i]){
            dp[i][j] = min(dp[i][j],dp[i-1][j]+B);
            dp[i][l[i]] = min(dp[i][l[i]],dp[i-1][j]);
        }else dp[i][j-1] = min(dp[i][j-1],dp[i-1][j]+A);
    }
    cout << dp[N][0] << endl;
}

Measured memory_bytes: 195968
h,w = map(int, input().split())

grid = [[str(i) for i in input()]for _ in range(h)]
dxdy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
for i in range(h):
    for j in range(w):
        if grid[i][j]=="#":
            f = False
            for d in dxdy:
                if(i+d[0]>-1 and j+d[1]>-1 and j+d[1]<w and i+d[0]<h):
                    if grid[i+d[0]][j+d[1]]=="#":
                        f = True
                        continue
            if f==False:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string N;
        cin >> N;
        ll sm = 0;
        rep(i, 0, len(N)) {
                sm += (ll)(N[i] - '0');
        }

        if (sm % 9 == 0) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}


Measured memory_bytes: 3720
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long LL;

LL n,m,k,mxr,tot = 0;
struct node{
	LL l,r;
}s[500005];
bool cmp(node x,node y){
	return x.r < y.r;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= n;i ++){
		cin >> m >> k;
		s[i].l = m - k;
		s[i].r = m + k;
	}
	sort(s + 1,s + 1 + n,cmp);
	tot = 1; mxr = s[1].r;
	for(LL i = 2;i <= n;i ++){
		if(s[i].l >= mxr){
			mxr = s[i].r;
			tot ++;
		}
//		cout << i << ' ' << s[i].l << ' ' << mxr << endl;
	}
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 1792
s = str(input())
cnt = 0
lst = []

if s[0]=='A' and s.count('C', 2, -1)==1:

    for i in range(1,len(s)):
        if s[i] != s[s.find('C',2, -1)]:
            lst.append(s[i])

    t = ''.join(lst)

    if t== str(t.upper()).lower():
        print('AC')
    else:
        print('WA')

else:
    print('WA')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

void solve(void)
{
	int X;
	cin >> X;
	if (X == 3 || X == 5 || X == 7)
	{
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256