akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define ps(ch) printf("%s",ch)
#define Afridi 0
#define NL printf("\n")
#define debug(x) printf("wow  %d !!\n",x)
#define Max 100005
#define INF (LL)1e18
#define mod 1000000007

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;


LL bigmod(LL b,LL p,LL m)
{
    if(p == 0)return 1;
    LL my = bigmod(b,p/2,m);
    my*=my;my%=m;
    if(p & 1)my*=b,my%=m;
    return my;
}
int setb(int n,int pos){return n=n | (1 << pos);}
int resb(int n,int pos){return n=n & ~(1 << pos);}
bool checkb(int n,int pos){return (bool)(n & (1 << pos));}

vector <LL> g[Max],cost[Max];
LL n,k;
LL visit[Max];
LL dis[Max];

void dfs(LL u,LL d)
{
	visit[u] = 1;
	dis[u] = d;
	LL len = sz(g[u]),i;
	Rep(i,len)
	{
		LL v = g[u][i];
		if( visit[v] == 0 )
		{
			dfs(v,d+cost[u][i]);
		}
	}
}

LL calc(LL x,LL y)
{
	LL ret = dis[x] + dis[y];
	return ret;
}

int main()
{
	//FI;
	LL i,j,x,y,w,q;
	sl(n);
	rep(i,n-1)
	{
		slll(x,y,w);
		g[x].pb(y);
		g[y].pb(x);
		cost[x].pb(w);
		cost[y].pb(w);
	}
	sll(q,k);
	dfs(k,0);
	rep(i,q)
	{
		sll(x,y);
		LL ret = calc(x,y);
		pl(ret); NL;
	}
	return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int h, w; cin >> h >> w;
    vector<string> s(h);
    vector<vi> dp(h, vi(w));
    rep(i, 0, h) cin >> s[i];
    dp[0][0] = s[0][0] == '#';
    rep(i, 0, h) rep(j, 0, w) {
        if (i != 0 || j != 0) dp[i][j] = 0x3f3f3f3f;
        if (i != 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i][j] != s[i - 1][j] && s[i][j] == '#'));
        if (j != 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j] != s[i][j - 1] && s[i][j] == '#'));
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  int r = 0;
  rep(i,n) if(s[i] == 'R') r++;
  int cnt = 0;
  rep(i,r) if(s[i] == 'R') cnt++;
  cout << min(r,r-cnt);
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a=1;
    for(int i=0;i<n;i++){
        if(a>k){a+=k;}
        else{a*=2;}}
    cout<<a<<endl;
    return 0;}

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

int main() {
  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<vector<ll>> dp(n + 1, vector<ll>(1000000, W + 1));
  dp[0][0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 1000000; j++) {
      if (j >= v[i]) {
        ll tmp = dp[i][j - v[i]] + w[i];
        if (tmp > W) {
          dp[i + 1][j] = dp[i][j];
        } else {
          dp[i + 1][j] = min(tmp, dp[i][j]);
        }
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i <= 100000; i++) {
    if (dp[n][i] <= W) { ans = max(ans, i); }
  }
  cout << ans << endl;
}

Measured memory_bytes: 797440
#include<bits/stdc++.h>
#define maxn 600005
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
#define mod 924844033
using namespace std;

int n,sz[maxn],A[maxn],B[maxn];
vector<int>G[maxn];

void dfs(int u,int ff){
	sz[u] = 1;
	int v;
	rep(i,0,G[u].size()-1) if((v=G[u][i]) ^ ff){
		dfs(v,u);
		sz[u] += sz[v];
		A[sz[v]] -- , A[n-sz[v]]--;
	}
}

int Wl,Wl2,w[maxn],lg[maxn],inv[maxn],invf[maxn],fac[maxn];
int Pow(int b,int k){ int r=1;for(;k;k>>=1,b=1ll*b*b%mod) if(k&1) r=1ll*r*b%mod; return r; }
void init(int n){
	for(Wl=1;n>=Wl<<1;Wl<<=1);int pw=Pow(5,(mod-1)/(Wl2=Wl<<1));
	w[Wl] = inv[0] = inv[1] = fac[0] =fac[1] = invf[0] = invf[1] = 1;
	rep(i,Wl+1,Wl2) w[i] = 1ll * w[i-1] * pw % mod;
	per(i,Wl-1,1) w[i] = w[i<<1];
	rep(i,2,Wl2) lg [i] = lg[i>>1] + 1, inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod,
		fac[i] = 1ll * fac[i-1] * i % mod ,invf[i] = 1ll * invf[i-1] * inv[i] % mod;
}

int upd(int x){ return x += x >> 31 & mod; }
void NTT(int *A,int n,int tp){
	static int r[maxn]={};
	static unsigned long long ar[maxn];
	if(tp ^ 1) reverse(A+1,A+n);
	rep(i,0,n-1) r[i] = r[i>>1] >>1|(i&1)<<lg[n]-1 , ar[i] = upd(A[r[i]]);
 	for(int L=1;L<n;L<<=1) for(int s=0,L2=L<<1;s<n;s+=L2) for(int k=s,x=L,t;k<s+L;k++,x++)
 		t = ar[k+L] * w[x] % mod , ar[k+L] = ar[k] - t + mod , ar[k] += t;
 	rep(i,0,n-1) A[i] = ar[i] % mod;
	if(tp ^ 1) rep(i,0,n-1) A[i] = 1ll * A[i] * inv[n] % mod;
}

int main(){
	scanf("%d",&n);
	rep(i,1,n-1){
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(1,0);
	init(n << 1);
	rep(i,0,n) A[i] = 1ll * A[i] * fac[i] % mod , B[i] = invf[i];
	reverse(A,A+n+1);
	NTT(A,Wl2,1),NTT(B,Wl2,1);
	rep(i,0,Wl2-1) A[i] = 1ll * A[i] * B[i] % mod;
	NTT(A,Wl2,-1);
	rep(i,1,n){
		int ans = (1ll * fac[n] * invf[i] % mod * invf[n-i] % mod * n + A[n-i] * 1ll * invf[i]) % mod;
		printf("%d\n",(ans+mod)%mod);
	}
}

Measured memory_bytes: 58580
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, M;
    while(cin >> N >> M && N){
        int d, p, dp[11];
        for(int i=0; i<11; ++i) dp[i] = 0;
        for(int i=0; i<N; ++i){
            cin >> d >> p;
            dp[p] += d;
        }
        int ex = 0;
        for(int i=10;i>0;--i){
            if(M >= dp[i]) M -= dp[i];
            else{
                ex += (dp[i] - M) * i;
                M = 0;
            }
        }
        cout << ex << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#%%
n = int(input())
x = [0] * n
l = [0] * n
a = [[0, 0] for _ in range(n)]
for i in range(n):
    x[i], l[i] = map(int, input().split())
    a[i] = [x[i]-l[i], x[i]+l[i]]

a.sort(key=lambda x: x[1])
#print(a)

ans = 0
t = -(10**10)
for i in range(n):
    if a[i][0] >= t:
        ans += 1
        t = a[i][1]
print(ans)

Measured memory_bytes: 29224
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int main() {
    ll a[7];
    for (int i = 0; i < 7; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    ans += a[1];
    if (a[0] >= 1 && a[3] % 2 == 1 && a[4] % 2 == 1) {
        ans += 3;
        a[0]--;
        a[3]--;
        a[4]--;
    } else if (a[0] % 2 == 1 && a[3] >= 1 && a[4] % 2 == 1) {
        ans += 3;
        a[0]--;
        a[3]--;
        a[4]--;
    } else if (a[0] % 2 == 1 && a[3] % 2 == 1 && a[4] >= 1) {
        ans += 3;
        a[0]--;
        a[3]--;
        a[4]--;
    }
    ans += (a[3] / 2) * 2;
    ans += (a[4] / 2) * 2;
    ans += (a[0] / 2) * 2;
    cout << ans << endl;
}


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

int main()
{
	int m, f, r;
	
	while (cin >> m >> f >> r)
	{
		if (m == -1 && f == -1 && r == -1)
		{
			break;
		}

		else if (m == -1 || f == -1)
		{
			cout << "F" << endl;
		}

		else if (m + f >= 80)
		{
			cout << "A" << endl;
		}

		else if (m + f >= 65 && m + f < 80)
		{
			cout << "B" << endl;
		}

		else if (m + f >= 50 && m + f < 65)
		{
			cout << "C" << endl;
		}

		else if (m + f >= 30 && m + f < 50)
		{
			if (r >= 50)
			{
				cout << "C" << endl;
			}
			else
			{
				cout << "D" << endl;
			}
		}

		else if (m + f < 30)
		{
			cout << "F" << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;    
int main() {
    string s; int n, count;
    cin >> n >> s;
    count = 0;
    //check all 999 combs
    for (int i = 0; i < 1000; i++) {
        int combs[3] = {i / 100, (i / 10) % 10, i % 10};
        int filled = 0;
        for (int j = 0; j < n; j++) {
            if (s[j] == combs[filled] + '0') filled++;
            //cout << filled;
            if (filled == 3) break;
        }
        if (filled == 3) count++;
    }
    cout << count;
}


Measured memory_bytes: 256
using System;

	public class Class1
	{
		public static void Main(String[] args)
		{
			int n=0;
			while((n=int.Parse(Console.ReadLine()))!=0)
	      {
			string line=Console.ReadLine();
			string[] data=line.Split();
			double[] score=new double[n];
			double sum=0;
			double square=0;
			for(int i=0;i<n;i++)
			{
				score[i]=double.Parse(data[i]);
				sum+=score[i];
			}
			double aver=sum/n;
			for(int j=0;j<n;j++)
			{
				square+=Math.Pow((aver-score[j]),2);
			}
			Console.WriteLine(Math.Sqrt(square/n));
		  }
			
		}
	}

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

int main() {
    int N, A;
    cin >> N >> A;

    if (N < 500) {
        if (N < A) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (N % 500 == 0) {
            cout << "Yes" << endl;
        } else if (N % 500 < A) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

int main(){
    int m,f,r;

    while(1){
        cin >> m >> f >> r;

        if (m == -1 && f == -1 && r == -1){ break; }

        if (m == -1 || f == -1){
            cout << "F" << endl;
        }
        else if(m+f >= 80){
            cout << "A" << endl;
        }
        else if(m+f < 80 && 65 <= m+f){
            cout <<"B"<<endl;
        }
        else if(m+f >= 50 && m+f < 65){
            cout << "C" << endl;
        }
        else if(30 <= m+f && m+f < 50){
            if(r >= 50){
                cout << "C" << endl;
            }
            else{
                cout << "D" << endl;
            }
        }
        else if(m+f < 30){
            cout << "F" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
int main()
{
   // ios;
    ll n ;
    vl v;
    cin >> n ;
    forn(i , 1 , n ){
       ll x;
       cin >> x;
       v.pb(x) ;
    }
    multiset<ll> s;
    forn(i , 0 , n-1){
       if(i == 0){
        s.insert(v[i] ) ;
        con ;
       }
       ll curr = v[i] ;
       auto it = s.lower_bound(curr) ;
       if(it == s.begin()){
         s.insert(curr) ;
         con ;
       }
       else {
         --it ;
         ll ele = *it ;
        s.erase(it);
        s.insert(curr);
       }
    }
    cout << ll(s.sz ) << el ;
    ro ;

}



Measured memory_bytes: 5748
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		// int MAX = 1000;
		Scanner sc = new Scanner(System.in);
		String input = "";
		String Alpha = "abcdefghijklmnopqrstuvwxyz ";
		int count_Empty = 0;
		int output[] = new int[26];
		int index = 0;
		String line = "";
		String each_mozi = "";
		int mozi_length = 0;

		do {
			input = sc.nextLine();
			line += input.toLowerCase();
		} while (sc.hasNext());

		for (int j = 0; j < line.length(); j++) {
			each_mozi = "" + line.charAt(j);
			index = Alpha.indexOf(each_mozi);
			if (index == 26) {
				count_Empty++;
			} else if (index != -1) {
				output[index]++;
			}

		}
		mozi_length += line.length() - count_Empty;

		if (mozi_length < 1200 && mozi_length != 0) {

			for (int k = 0; k < output.length; k++) {
				System.out.println("" + Alpha.charAt(k) + " : " + output[k]);

			}
		}

	}

}



Measured memory_bytes: 26364
#include<bits/stdc++.h>
using namespace std;
#define pb  					push_back
#define mp 						make_pair
#define all(v) 					((v).begin()) ,((v).end())
#define let(o,v)				memset(o,v,sizeof (o))
typedef long long 				ll;
typedef vector<int>				vi;
typedef vector<vi>				vvi;
typedef vector<string>			vs;

const int MOD = (int)1e9 + 7;
const int oo = (int)1e9;
const ll OO = (ll)1e18;
const double PI = acos(-1.0);
const int N = (int)1e6 + 9;

bool isprime(int n) {
	if (n <= 1)
		return 0;
	for (int i = 2; i*i <= n; i++)
		if (n%i == 0)
			return false;
}
ll intlog(ll base, ll x) {
	return (log(x) / log(base));
}
bool prime[N];
void primee()
{

	for (int p = 2; p*p <= N; p++)
	{

		if (prime[p] == true)
		{
			for (int i = p * 2; i < N; i += p)
				prime[i] = false;
		}
	}

}
string decToBinary(ll n)
{
	string z = "";
	int i = 0;
	while (n > 0) {

		z += (n % 2) + 48;
		n = n / 2;
		i++;
	}
	reverse(all(z));
	return z;
}
int main()
{
	int a, b;
	scanf("%d%d",&a,&b);
	if ((a*b * 1) % 2 == 1 || (a*b * 2) % 2 == 1 || (a*b * 3) % 2 == 1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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



int main() {
  int N;
  scanf(" %d ", &N);
  std::map<std::string, int> m;
  for (int i = 0; i < N; ++i) {
    char buf[1024];
    scanf(" %s ", buf);
    m[buf]++;
  }
  printf("%s x %d\n", "AC", m["AC"]);
  printf("%s x %d\n", "WA", m["WA"]);
  printf("%s x %d\n", "TLE", m["TLE"]);
  printf("%s x %d\n", "RE", m["RE"]);
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n;
	cin>>n;
	vi v(n), pre(n);
	int mn = INF, s=0;
	for(int i = 0; i < n; i++)cin>>v[i];
	pre[0]=v[0];
	for(int i = 1; i < n; i++)pre[i]=v[i]+pre[i-1];
	for(int i = n-1; i >= 1; i--){
		s+=v[i];
		mn=min(mn, abs(pre[i-1]-s));
	}
	cout<<mn;
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

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

int main() {
  
  string N; cin >> N;
  
  int sum = 0;
  
  for (int i = 0; i < N.size(); i++) {
    
    string tmp = N.substr(i, 1);
    
    sum += stoi(tmp);
    
  }
  
  if (sum % 9 == 0) cout << "Yes" << endl;
  
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define z 500000000000000000
#define sh 100000
ll dp[101][sh+1];
int main()
{

	
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,w,i,j;
	cin>>n>>w;
	ll ar[n+1][2];
	for(i=1;i<=n;i++)
		cin>>ar[i][0]>>ar[i][1];
	for(i=0;i<=sh;i++)
		dp[0][i]=0;
	for(i=0;i<101;i++)
		dp[i][0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=w;j++)
		{
			if(j-ar[i][0]<0)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=max(dp[i-1][j-ar[i][0]]+ar[i][1],dp[i-1][j]);
		}
	}
	cout<<dp[n][w];

}

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

using namespace std;

long long n,i,j,ans,sum,num[100005];
string s[100005],tmp[100005],now;

int main()
{
	scanf("%lld\n",&n);
	for(i=0;i<n;i++)
	{
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s,s+n);
	for(i=0;i<n;i++)
	{
		if(now!=s[i])
		{
			now=s[i];
			num[sum]=1;
			sum++;
		}
		else num[sum-1]++;
	}
	for(i=0;i<sum;i++)
		ans+=(num[i]*(num[i]-1))/2;
	printf("%lld",ans);
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int n,d;
	cin>>n>>d;
	int l=2*d+1;
	cout<<(n+l-1)/l<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, mm, xx, ll = 0, hh = 0, tmp;
	cin >> nn >> mm >> xx;
	for(int64 ii = 0;ii < mm;ii++)
	{
		cin >> tmp;
		if(tmp < xx)
		{
			ll++;
		}
		else
		{
			hh++;
		}
	}
	cout << min(ll, hh) << endl;
	return 0;
}

Measured memory_bytes: 3540
A,B,C,D = list(input())

ops = ["+","-"]

ans = []
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            tmp = 0
            if op1 == "+":
                tmp = int(A)+int(B)
            else:
                tmp = int(A)-int(B)

            if op2 == "+":
                tmp = tmp + int(C)
            else:
                tmp = tmp - int(C)

            if op3 == "+":
                tmp = tmp + int(D)
            else:
                tmp = tmp - int(D)

            if tmp == 7:
                ans.append(str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D) + "=7")

print(ans[0])


Measured memory_bytes: 3064
n=int(input())
 
a=list(map(int,input().split()))
b=list(map(int,input().split()))
 
num=sum(b)-sum(a)
if num<0:
    print("No")
    exit()
 
need=0
for i in range(n):
    aa=a[i]
    bb=b[i]
    if aa>bb:
        need+=aa-bb
    elif aa<bb:
        need-=(bb-aa)//2
 
if need<=0:print("Yes")
else:print("No")

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

using namespace std;

#define MAX 510
#define MAX_E 50010

int par[MAX],rnk[MAX];
void init(int N){
  for(int i = 0 ; i < N ; i++){
    par[i] = i;
    rnk[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }
  return par[x] = find(par[x]);
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y){ return; }
  if(rnk[x] < rnk[y]){
      par[x] = y;
  }else{
    par[y] = x;
    if(rnk[x] == rnk[y]){
      rnk[x]++;
    }
  }
}

bool same(int x,int y){
  return (find(x) == find(y));
}

struct Edge{ int u,v,cost; };

bool comp(const Edge &e1,const Edge &e2){
  return e1.cost < e2.cost;
}

int V,E;
Edge es[MAX_E];

bool equals(const Edge &e1,const Edge &e2){
  return (e1.u == e2.u && e1.v == e2.v);
}

vector<Edge> vec;

int kruskal(int ne){
  sort(es,es+E,comp);
  init(V);
  int res = 0;
  for(int i = 0 ; i < E ; i++){
    Edge e = es[i];
    if(ne != -1 && equals(e,vec[ne])){
      continue;
    }
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res += e.cost;
    }
  }
  return res;
}

int kruskal(){
  sort(es,es+E,comp);
  init(V);
  int res = 0;
  for(int i = 0 ; i < E ; i++){
    Edge e = es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res += e.cost;
      vec.push_back(e);
    }
  }
  return res;
}

int main(){
  int a,b,c;
  cin >> V >> E;
  for(int i = 0 ; i < E ; i++){
    cin >> a >> b >> c; a--; b--;
    es[i] = (Edge){a,b,c};
  }
  vec.clear();
  int cnt = 0, sum = 0;
  int res = kruskal();
  for(int i = 0 ; i < (int)vec.size() ; i++){
    int r = kruskal(i);
    bool check = true;
    for(int j = 0 ; j < V ; j++){
      if(!same(0,j)){
        check = false;
        break;
      }
    }
    if((check && r > res) || !check){
      cnt++;
      sum += vec[i].cost;
    }
  }
  cout << cnt << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,ans=100000000000000000,i;
  cin>>n;
  for(i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
     {
	 if(ans>i+(n/i)-2)
     ans=i+(n/i)-2;
     }
  }
  cout<<ans;
  return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;

void BubbleSort(int*,int);
void output(int*,int,int);

int main(void){

  int  datanum;
  int* databuff;

  cin >> datanum;

  databuff = (int *)malloc(datanum * sizeof(int));

  if ( databuff != NULL){

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

    BubbleSort(databuff,datanum);

    free(databuff);
  }
}

void BubbleSort(int* databuff,int datanum){
  int flag;
  int exchangetimes;

  exchangetimes = 0;

  do{
    flag = 0;

    for (int i = datanum - 1 ; i > 0 ; i--){
      if ( databuff[i] < databuff[i-1]){
        int temp;
        temp = databuff[i-1];
        databuff[i-1] = databuff[i];
        databuff[i] = temp;
        flag = 1;
        exchangetimes++;
      }
    }
  }while(flag == 1);

  output(databuff,datanum,exchangetimes);
}

void output(int *databuff,int datanum,int exchangetimes){
  for ( int i = 0 ; i < datanum ; i++){
    cout << databuff[i];

    if ( i < datanum - 1){
      cout << " ";
    }else{
      cout << endl;
    }
  }
  cout << exchangetimes << endl;
}

Measured memory_bytes: 3064
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h,w; cin >> h >> w;
    vector<string> s(h); rep(i,h) cin >> s[i];
    int visited[h][w]; rep(i,h) rep(j,w) visited[i][j] = -1;
    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
    queue<tuple<int,int,int>> que;
    que.emplace(0,0,1);
    int goal = 0;
    while(!que.empty()){
        int y = get<0>(que.front()), x = get<1>(que.front()), ncnt = get<2>(que.front());
        que.pop();
        visited[y][x] = ncnt;
        if(y == h-1 && x == w-1){ goal = ncnt; break; }
        rep(i,4){
            int ny = y + dy[i], nx = x + dx[i];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(visited[ny][nx] >= 0 || s[ny][nx] != '.') continue;
            visited[ny][nx] = ncnt+1;
            que.emplace(ny,nx,ncnt+1);
        }
    }
    if(goal == 0){
        cout << -1 << endl;
        return 0;
    }

    // 全体の移動可能マス集計
    int all_white = 0;
    rep(i,h) rep(j,w) if(s[i][j] == '.') all_white++;

    cout << all_white - goal << endl;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    if(S.at(K-1) == 'A'){
        S.at(K-1) = 'a';
    }else if(S.at(K-1)== 'B'){
        S.at(K-1) = 'b';
    }else{
        S.at(K-1) = 'c';
    }

    cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using Int = long long;
#define P(range) do{for(auto&i:range){cout<<i<<' ';}cout<<endl;}while(0)
int main()
{
    int N, T; cin >> N >> T;
    vector<int> A(N); for(auto& x : A) cin >> x;
    vector<int> M(N);
    M[N-1] = A[N-1];
    for (int i = N-2; i >= 0; i--) {
        M[i] = max(M[i+1], A[i]);
    }
    int t = 0;
    for (int i = 0; i < N; i++) {
        t = max(t, M[i] - A[i]);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += t == M[i] - A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <iomanip>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define tle ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int mod = 998244353;
const int mxn = 2e5 +7;
int _,n,m,t,k,u,v,ans,cnt,ok,lim;
ll w[mxn] , cost[mxn] ,  far[mxn] , siz[mxn];
char ch;
#define lc now<<1
#define rc now<<1|1
string str ;
struct node {ll l,r,val,lazy,mx,mn;}p[mxn<<4];
int lmx1[mxn] , rmx1[mxn] , lmx0[mxn] , rmx0[mxn] , num1[mxn] , num0[mxn] , lazy[mxn];
int calc()
{

}
int main()
{tle;
    int Case = 1 ;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b/a,c)<<endl;
}

Measured memory_bytes: 2304
import itertools

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
# 多分1~4で3!の順列になる
ls = list(itertools.permutations(range(1,n+1))) #順列生成
# 絶対値absで辞書順のpからqをひく
print(abs(ls.index(p)-ls.index(q)))

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long h = sc.nextLong();
		long w = sc.nextLong();
		long n = sc.nextLong();
		//long l = sc.nextLong();
		//String buff="Christmas";
		long countw=0;
		long buff=0;
		long[] array=new long[3];

		for(long i=0;i<Math.max(h, w);i++) {
			buff+=Math.max(w, h);
			if(buff>=n) {
				System.out.println(i+1);
				System.exit(0);
			}
			countw=i+1;
		}
		for(long i=0;i<Math.min(h, w);i++) {
			buff+=Math.min(w, h)-countw;
			if(buff>=n) {
				System.out.println(i+1);
				System.exit(0);
			}
			countw=i+1;
		}
		Arrays.sort(array);

		/*if() {
			System.out.println("TBD");
		}else {
			System.out.println("Heisei");
		}*/
		//System.out.println(n*m-k*m-l*(n-k));
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




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

#define int long long int 
int coe[2];
int dp[1000];

void find(int n)
{
    coe[0]=4;
    coe[1]=7;
    memset(dp,0,sizeof(dp));

    dp[0]=1;

    for(int i=0;i<2;i++)
        for(int j=coe[i];j<=n;j++)
                dp[j]+=dp[j-coe[i]];

}
int32_t main()
{
    int n;
    cin>>n;
    find(n);
     cout<<(dp[n]?"Yes":"No")<<endl;
}

Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;

int main(void){
    ll n,ans=0;
    string s,t;
    cin>>n>>s;
    t=s;
    sort(t.begin(),t.end());
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans/2<<endl;
}

Measured memory_bytes: 3840
//O(NlogN)解法
//高速化は典型
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <functional>
#include <tuple>
using namespace std;
typedef tuple<int, int, int> T;
typedef pair<int, int> P;

const int DEPTH = 17;
const int INF = 11451419;

class SegTree {
public:
	int data[1 << (DEPTH + 1)];
	SegTree() { for (int i = 0; i < (1 << (DEPTH + 1)); i++) data[i] = INF; }
	void update(int pos, int x) {
		pos += (1 << DEPTH) - 1;
		data[pos] = x;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			data[pos] = min(data[pos * 2 + 1], data[pos * 2 + 2]);
		}
	}
	int getMin(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return INF;
		if (l <= a && b <= r) return data[id];
		int u = getMin(l, r, a, a + (b - a) / 2, id * 2 + 1);
		int v = getMin(l, r, a + (b - a) / 2, b, id * 2 + 2);
		return min(u, v);
	}
};

int n;
int p[200000];
SegTree a[2];
int toPos[200001];
vector<P> ans;

//p[l]～p[r-1]を一つの数列(a[0], a[1], …)とみなすとき, 偶数番目の最小値を返す
int getEvenMin(int l, int r) {
	if (l >= r) return INF;
	return a[l % 2].getMin(l / 2, (r - 1 - (l % 2)) / 2 + 1);
}

//p[l]～p[r-1]を一つの数列(a[0], a[1], …)とみなすとき, 奇数番目の最小値を返す
int getOddMin(int l, int r) {
	if (l + 1 >= r) return INF;
	return a[(l + 1) % 2].getMin((l + 1) / 2, (r - 1 - ((l + 1) % 2)) / 2 + 1);
}

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> p[i];
	for (i = 0; i < n; i++) toPos[p[i]] = i;
	for (i = 0; i < n / 2; i++) a[0].update(i, p[2 * i]);
	for (i = 0; i < n / 2; i++) a[1].update(i, p[2 * i + 1]);
	
	priority_queue<T, vector<T>, greater<T> > que;
	que.push(T(getEvenMin(0, n), 0, n));
	
	while (!que.empty()) {
		T t = que.top(); que.pop();
		if (get<1>(t) >= get<2>(t)) continue;
		
		int x = get<0>(t);
		int y = getOddMin(toPos[x], get<2>(t));
		ans.push_back(P(x, y));
		
		que.push(T(getEvenMin(get<1>(t), toPos[x]), get<1>(t), toPos[x]));
		que.push(T(getEvenMin(toPos[x] + 1, toPos[y]), toPos[x] + 1, toPos[y]));
		que.push(T(getEvenMin(toPos[y] + 1, get<2>(t)), toPos[y] + 1, get<2>(t)));
	}
	
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second;
		if (i + 1 < ans.size()) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 10032
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, m = map(int, input().split())
    d = [-1] * n
    for i in range(m):
        s, c = map(int, input().split())
        if d[s-1] != -1 and d[s-1] != c:
            print(-1)
            return
        d[s-1] = c
    ans = ''
    if n > 1 and (d[0] == -1 or d[0] == 0):
        if(d[0] == -1):
            d[0] = 1
        else:
            print(-1)
            return
    for i in range(n):
        if d[i] == -1:
            d[i] = 0
        ans += str(d[i])

    print(ans)


main()


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL h(n);
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	LL i = 0;
	bool counted = false;
	while (true) {
		bool all_zero = true;
		if (i < n and h[i] != 0 ) {
			h[i]--;
			i++;
			counted = true;
		}
		else {
			if (counted) {
				ans++;
				counted = false;
			}
			for (int j = 0; j < n; j++) {
				if (h[j] != 0) {
					i = j;
					all_zero = false;
					break;
				}
			}
			if (all_zero) {
				break;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main()
{
	ll N, K, L, R;
	cin >> N >> K >> L >> R;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	ll n1 = N / 2, n2 = N - N / 2;
	vector<vector<ll>> b(n1 + 1), c(n2 + 1);
	for (int i = 0; i < (1 << n1); i++) {
		ll cnt = 0, val = 0;
		for (int j = 0; j < n1; j++) {
			if (i & (1 << j)) {
				cnt++;
				val += a[j];
			}
		}
		b[cnt].push_back(val);
	}
	for (int i = 0; i < (1 << n2); i++) {
		ll cnt = 0, val = 0;
		for (int j = 0; j < n2; j++) {
			if (i & (1 << j)) {
				cnt++;
				val += a[j + n1];
			}
		}
		c[cnt].push_back(val);
	}
	for (int i = 0; i <= n2; i++) {
		sort(c[i].begin(), c[i].end());
	}
	ll res = 0;
	for (int i = max(0ll, K - n2); i <= n1 && i <= K; i++) {
		for (auto v : b[i]) {
			auto ub = upper_bound(c[K - i].begin(), c[K - i].end(), R - v);
			auto lb = lower_bound(c[K - i].begin(), c[K - i].end(), L - v);
			res += ub - lb;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 23316
/*
in the name of ALLAH
author: Sepehr_Noori
*/
#include <bits/stdc++.h>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define pp pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef map<int,int> mpii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef double db;
typedef long double ld;
const int mod = 1e9+7;
////////////////////////



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int h,n,x,s=0;
    cin>>h>>n; 
    for (int i = 0;i<n;i++){
        cin>>x;
        s+=x;
    }
    if(s>=h){
        cout<<"Yes"<<endl;
        return 0;
    }else
    {
        cout<<"No"<<endl;
        return 0;
    }
    
}
    /*db h,a;
    cin>>h>>a;
    cout<<ceil(h/a)<<endl;;

    return 0;
}*/

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int ball,bal,n,a,flg;
  cin>>n;
  for(int i=0;i<n;i++){
    flg=0;
    ball=0;
    bal=0;
    for(int k=0;k<10;k++){
      cin>>a;
      if(ball<a){
	ball=a;
      }else if(bal<a){
	bal=a;
      }else{
	flg=1;
      }
    }
    if(flg==0){
      cout<<"YES"<<endl;
    }if(flg==1){
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

	       

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

#define MAX 26

typedef struct node{
  int p;
  int l;
  int r;
} Tree;

int Height(int);

int n;
Tree T[MAX];

int main(){
  int i,j,id,left,right;
  int s[MAX],deg[MAX],dep[MAX],h[MAX];

  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
    s[i]=-1;
    deg[i]=0;
    dep[i]=0;
    h[i]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);

    if(left!=-1){
      T[left].p=id;
      deg[id]++;
    }

    if(right!=-1){
      T[right].p=id;
      deg[id]++;
    }

    T[id].l=left;
    T[id].r=right;
    s[left]=right;
    s[right]=left;
  }

  for(i=0;i<n;i++){
    j=i;
    
    while(T[j].p!=-1){
      j=T[j].p;
      dep[i]++;
    }  

    h[i]=Height(i);
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
	   ,i,T[i].p,s[i],deg[i],dep[i],h[i]);

    if(T[i].p==-1){
      printf("root\n");
    }else if(T[i].l==-1 && T[i].r==-1){
      printf("leaf\n");
    }else{
      printf("internal node\n");
    }
  }

  return 0;
}

int Height(int i){
  int j,count=0,max=0;

  for(j=0;j<n;j++){
    if(T[j].p==i){
      count=Height(j)+1;

      if(count>max){
	max=count;
      }
    }
  }

  return max;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
int i,j,k,n,t,s,ans,a[3001],b[3001],dp[3002][3001];
int main(void)
{
	cin >> n >> t >> s;
	for(i=0;i<=n;i++){
		for(j=0;j<=t;j++){
			if(j==0) dp[0][j]=0;
			else dp[i][j]=-1;
		}
	}
	for(i=1;i<=n;i++) cin >> a[i] >> b[i];
	
	for(i=0;i<=n;i++){
		for(j=0;j<=t;j++){
			if(dp[i][j]!=-1){
				if(dp[i+1][j]<dp[i][j])dp[i+1][j]=dp[i][j];
				if(j+b[i+1]>s && j<s){
					if(t>=s+b[i+1]) dp[i+1][s+b[i+1]]=max(dp[i+1][s+b[i+1]],dp[i][j]+a[i+1]);
				}
				else if(t>=j+b[i+1]) dp[i+1][j+b[i+1]]=max(dp[i+1][j+b[i+1]],dp[i][j]+a[i+1]);
			}
		}
	}
	ans=0;
	for(i=0;i<=t;i++) ans=max(ans,dp[n][i]);
	cout << ans << endl;
}

Measured memory_bytes: 38296
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

const int N=55;
const int MAX_S=4000;
vector<tuple<int,int,int>>edges[N];
int n,m,S;
vector<pair<int,int>>_exchange;

void dijkstra(int s)
{
  vector<vector<ll>>dist(n,vector<ll>(MAX_S,1e15));
  dist[s][S]=0;
  priority_queue< pair<ll,pair<int,int>>, vector<pair<ll,pair<int,int>>>,greater< pair<ll,pair<int,int>> > >pq; //{dist,{src,silver_coins}}
  pq.push({0,{s,S}});

  while(!pq.empty()){
    int curr_dist=pq.top().first;
    int node=pq.top().second.first;
    int silver=pq.top().second.second;
    pq.pop();
    if(dist[node][silver]<curr_dist)  continue;

    for(auto x:edges[node]){
      if(get<1>(x)<=silver){
        if( dist[get<0>(x)][silver-get<1>(x)] > dist[node][silver]+get<2>(x) ){
          dist[get<0>(x)][silver-get<1>(x)] = dist[node][silver]+get<2>(x);
          pq.push({dist[get<0>(x)][silver-get<1>(x)],{get<0>(x),silver-get<1>(x)}});
        }
      }
    }
    int new_s=min(MAX_S-1,silver+_exchange[node].first);
    if(dist[node][new_s]>dist[node][silver]+_exchange[node].second){
      dist[node][new_s]=dist[node][silver]+_exchange[node].second;
      pq.push({dist[node][new_s],{node,new_s}});
    }
  }

  for(int i=1;i<n;i++){
    int ans=1e15;
    for(int k=0;k<MAX_S;k++){
      ans=min(ans,dist[i][k]);
    }
    cout<<ans<<"\n";
  }
}
signed main(){
  fastio
  cin>>n>>m>>S;
  S=min(S,MAX_S);  //check with bigger limits
  for(int i=0;i<m;i++){
    int u,v,cost_req,time_req;cin>>u>>v>>cost_req>>time_req;
    u--;v--;
    edges[u].emplace_back(v,cost_req,time_req);
    edges[v].emplace_back(u,cost_req,time_req);
  }
  for(int i=0;i<n;i++){
    int silver,time;cin>>silver>>time;
    _exchange.emplace_back(silver,time);
  }
  dijkstra(0);
  return 0;
}

Measured memory_bytes: 7976
import java.util.*;

class Main {
    private static Scanner sc;

    public static void main(final String[] args) {
        sc = new Scanner(System.in);
        String a = sc.next(),b = sc.next();
        if(a.equals(b.substring(0,a.length()))) System.out.println("Yes");
        else System.out.println("No");
    }
}








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

int N, P[200000], Q[200000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
		Q[P[i] - 1] = i;
	}
	int cnt = 0;
	int l = intmax;
	for (int i = 0; i < N; i++) {
		if (Q[i] < l) {
			cnt++;
			l = Q[i];
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int H, N;
    cin >> H >> N;
    int A = 0;
    rep(i, N) {
        int a;
        cin >> a;
        A += a;
    }
    write(A < H ? "No" : "Yes");
}

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

N = int(input())
A = list(map(int, input().split()))

guusuu = []
kisuu = []

for i in range(N):
    if i % 2 == 0:
        guusuu.append(A[i])
    else:
        kisuu.append(A[i])

ret = []
if N % 2 == 0:
    ret = kisuu[::-1] + guusuu
else:
    ret = guusuu[::-1] + kisuu

print(' '.join(map(str, ret)))


Measured memory_bytes: 31300
#include <cstdio>

int main()
{
  const int MAX_NUM = 123456*2+1;
  bool prime[MAX_NUM];
  for (int i = 0; i < MAX_NUM; ++i)
    prime[i] = true;
  prime[0] = prime[1] = false;

  for (int i = 2; i*i <= MAX_NUM; ++i) {
    if (prime[i]) {
      for (int j = i+i; j < MAX_NUM; j += i)
	prime[j] = false;
    }
  }

  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    int ans = 0;
    for (int i = n+1; i <= 2*n; ++i) {
      if (prime[i])
	++ans;
    }

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

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#define endl '\n'
#define ll long long

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> arr;
	for (int i = 0; i < N; i++)
	{
		int temp; cin >> temp;
		arr.push_back(temp);
	}
	sort(arr.begin(), arr.end());
	cout << arr[arr.size() - 1] - arr[0];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < (int) s.size(); i++) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN




ll gcd(ll a, ll b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
ll power(ll x, ll y) {
  ll res = 1;
  while (y > 0) {
    if (y % 2 == 1) {
      res = ((res) * (x));
    }
    x = ((x) * (x));
    y = y / 2;
  }
  return res;
}
ll seg[800005],dp[200005];

 

void update(ll i,ll st,ll end,ll val,ll ind){
    if(st==end){
        
        seg[i]=val;
        dp[ind]=val;
       
    }
    else{
        ll mid=(st+end)/2;
        if(ind>=st&&ind<=mid){
           update(2*i+1,st,mid,val,ind); 
        }
        else{
            update(2*i+2,mid+1,end,val,ind);
        }
        seg[i]=max(seg[2*i+1],seg[2*i+2]);
    }
}
ll query(ll i,ll st,ll end,ll l,ll r){
    if(st>r||end<l){
        return 0;
    }
    if(st>=l&&end<=r){
        return seg[i];
    }
    ll mid=(st+end)/2;
    return max(query(2*i+1,st,mid,l,r),query(2*i+2,mid+1,end,l,r));
}


int main() {

/*#ifndef ONLINE_JUDGE

  freopen("input.txt", "r", stdin);

  freopen("output.txt", "w", stdout);
#endif*/

  ll n,i;
  sfl(n);
  ll h[n],a[n];

  f(i,0,n)sfl(h[i]);
  f(i,0,n)sfl(a[i]);

  f(i,0,n){
    ll x=query(0,0,n,0,h[i]-1);

    if(x+a[i]>dp[h[i]]){
        update(0,0,n,x+a[i],h[i]);
    }
  }
  pfl(query(0,0,n,0,n));


  return 0;




}

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





int main(){
long long i,j=-9223372036854775807,k;
long long a,b,c,d,ans[4];

scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
ans[0]=a*c;
ans[1]=a*d;
ans[2]=b*c;
ans[3]=b*d;
for (i=0;i<4;i++){
  if(j<ans[i])
    j=ans[i];
}
printf("%lld",j);
return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<setprecision(6)<<fixed<<w*h/2;
	if(w/2==x&&h/2==y){
		cout<<" "<<1;;
	}
	else cout<<" "<<0;
	return 0;
}

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

typedef long long ll_t;

#define PERR(fmt, ...) \
    do { \
        fprintf(stderr, fmt, ##__VA_ARGS__); \
    } while (0) 

int K, T;
priority_queue<int> q;


int main() {
    scanf("%d%d", &K, &T);
    for (int i = 0; i < T; i++) {
        int x;
        scanf("%d", &x);
        q.push(x);
    }
    while (q.size() > 1) {
        int x = q.top();
        q.pop();
        int y = q.top();
        q.pop();
        if (x > 1) q.push(x-1);
        if (y > 1) q.push(y-1);
    }
    int r = q.top();
    printf("%d\n", r < 2 ? 0 : r - 1);
    return 0;
}

Measured memory_bytes: 256