akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 500001
int total;
int left(int i){
  i*=2;
  if(i>total)return N;
  else return i;
}
int right(int i){
  i=2*i+1;
  if(i>total)return N;
  else return i;
}
void maxheap(int A[],int i){
  int hidari,migi,max,comp;
  hidari=left(i);
  migi=right(i);
  if(hidari<=total&&A[hidari]>A[i])
    max=hidari;
  else max=i;
  if(migi<=total&&A[migi]>A[max])
    max=migi;
  if(max!=i){
    comp=A[i];
    A[i]=A[max];
    A[max]=comp;
    maxheap(A,max);
  }
}
void maxheap2(int A[]){
  int i;
  for(i=total/2;i>=1;--i){
    maxheap(A,i);
  }
}
int main(){
  int i,papa,l,r,key[N];
  scanf("%d",&total);
for(i=1;i<=total;++i){
  scanf("%d",&key[i]);
 }
maxheap2(key);
for(i=1;i<=total;++i){
  printf(" %d",key[i]);
 }
printf("\n");
return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
vector<ll> g[ohara];
ll vi[ohara];
unordered_map<ll,ll> used;
ll ha[ohara];
ll ha_cou=0;
ll dp[ohara];
vector<ll> gyaku[ohara];

//-------------------------↓↓↓↓↓↓------------------------

ll dfs(ll now){
    ll depth=0;
    rep(i,Size(g[now])){
        depth=max(dfs(g[now][i]),depth);
    }
    //cerr<<now+1<<" "<<depth<<"\n";
    if(depth==k-1){
        int ok=0;
        rep(i,Size(gyaku[now])){
            if(gyaku[now][i]==0)ok=1;
        }
        if(!ok&&now!=0){
        used[now]=1;
        return 0;
        }
        else{
            return depth+1;
        }
    }
    return depth+1;
}

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

    cin>>n>>k;
    rep(i,n)cin>>a[i];
    if(a[0]!=1)ans=1;
    rep(i,n){
        if(i==0)continue;
         g[a[i]-1].push_back(i);
         gyaku[i].push_back(a[i]-1);
    }
    dfs(0LL);
    rrep(i,1,n){
        if(used[i]==1)ans++;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 68516
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int x=0;
   long long int n;
   cin>>n;
   string s;
   cin>>s;
   int l[n+2];
   l[0]=0;
   long long int c=1;
   for(long long int i=0;i<n;i++)
   {
       if(s[i]=='I')
       {
        x+=1;
       }
        else if(s[i]=='D')
        x-=1;
        l[c++]=x;
   }
   l[c++]=x;
   sort(l,l+c);
   cout<<l[c-1];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define REP(type,i,n) for(type i=0;i<(n);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> Pi;

const int INF=100000000;
const long long int INF_=1000000000000000000;

string str="AIDUNY";
int t[6]={2,1,1,1,2,1};

int main(){
	string Z;
	cin >> Z;
	vector<map<char,int> > s(Z.size());
	REP(int,i,Z.size()){
		if(i!=0) REP(int,j,6) s[i][str[j]]=s[i-1][str[j]];
		int idx=str.find(Z[i]);
		if(idx!=string::npos){
			++s[i][str[idx]];
		}
	}
	vector<map<char,int> > s_(Z.size());
	for(int i=7; i<Z.size(); ++i){
		REP(int,j,6){
			if(i==7) s_[i][str[j]]=s[i][str[j]];
			else s_[i][str[j]]=s[i][str[j]]-s[i-8][str[j]];
		}
	}
	for(int i=7; i<Z.size(); ++i){
		bool flag=true;
		REP(int,j,6){
			if(s_[i][str[j]]!=t[j]){
				flag=false;
				break;
			}
		}
		if(flag){
			Z.replace(i-7,8,"AIZUNYAN");
		}
	}
	cout << Z << endl;
	return 0;
}

Measured memory_bytes: 1844
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N; cin >> N;
    vector<pair<string, int>>A(N); rep(i, N)cin >> A[i].first >> A[i].second;
    vector<pair<pair<string, int>, int>>T(N);
    rep(i, N) {
        T[i].first.first = A[i].first;
        T[i].first.second = -A[i].second;
        T[i].second = i + 1;
    }
    sort(all(T));
    for (int i = 0; i < N; i++) {
        cout << T[i].second << endl;
    }
}




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

int main() {
  int n, m;
  while (cin >> n >> m, n) {
    vector<int> cs(m), x(n);
    for (int i = 0; i < m; i++) cin >> cs[i];
    for (int i = 0; i < n; i++) cin >> x[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(256, 1e15));
    dp[0][128] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 256; j++) {
        for (auto c : cs) {
          int v = min(255, max(0, j + c));
          dp[i + 1][v] = min(dp[i + 1][v], dp[i][j] + (x[i] - v) * (x[i] - v));
        }
      }
    }
    ll ans = *min_element(begin(dp[n]), end(dp[n]));
    cout << ans << endl;
  }
}



Measured memory_bytes: 43896
#include <iostream>

using namespace std;

const int MAX_N = 1e5 + 5;

int cnt [MAX_N];
int red [MAX_N];

void put (int from, int to) {
  cnt[from]--;
  cnt[to]++;
  red[to] |= red[from];
  if (cnt[from] == 0) red[from] = 0;
}

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

  for (int i = 1; i <= n; i++) {
    cnt[i] = 1;
  }
  red[1] = 1;

  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;

    put(u, v);
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += red[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4312
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int w,h,x,y;
	int flag=0;
	cin>>w>>h>>x>>y;
	double ans=(double)w*h/2;
	if(x*2==w&&y*2==h)
	{
		flag=1;
	}
	printf("%.10f %d\n",ans,flag);
	return 0;
}





Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
typedef long long ll;
typedef long double ld;
#define trace(x)  cerr << #x << ": " << x << endl;
#define rep(i,a)  for(ll i=0; i< a; i++)
#define pb push_back
#define vl vector<ll>
const ll N=5*1e5+5;
vector<ll> tree(4*N);
void update(ll cur, ll l,ll r,ll pos)
{
	if(l> pos || r<pos)return;
	if(l==r && r==pos)
	{
		tree[cur]=1;return;
	}
	ll m=(r+l)/2;
	update(2*cur,l,m,pos);
	update(2*cur+1,m+1,r,pos);
	tree[cur]=tree[2*cur]+tree[2*cur+1];
}
ll sum(ll i,ll l,ll r,ll x,ll y)
{
	if(l> y || r<x)return 0;
	if(x<=l && r<=y)return tree[i];
	ll m=(r+l)/2;
	return sum(2*i,l,m,x,y)+sum(2*i+1,m+1,r,x,y);
}
bool comp(pair<pair<ll,ll>,ll> a,pair<pair<ll,ll>,ll> b)
{
	return a.first.second<b.first.second;
}
int main()
{
	fast;
	ll n;cin>>n;
	ll q;cin>>q;
	vector<ll> a(n);
	for(ll i=0;i<n;i++)
		cin>>a[i];
	vector<ll> nxt(n);
	map<ll,ll> occ;
	vector<pair<ll,ll>> toup;
	for(ll i=n-1;i>=0;i--)
	{
		if(occ.count(a[i])==0)
			nxt[i]=n+1;
		else
			nxt[i]=occ[a[i]];
		occ[a[i]]=i;
		toup.push_back({nxt[i],i});
	}
	vector<pair<pair<ll,ll>,ll>> query;
	for(ll i=0;i<q;i++)
	{
		ll l,r;
		cin>>l>>r;l--;r--;
		query.push_back({{l,r},i});
	}
	sort(query.begin(),query.end(),comp);
	reverse(query.begin(), query.end());
	sort(toup.begin(), toup.end());reverse(toup.begin(), toup.end());
	vector<ll> ans(q);ll j=0;
	for(ll i=0;i<q;i++)
	{
		while(j<n && toup[j].first> query[i].first.second)
			update(1,0,n-1,toup[j++].second);
		ans[query[i].second]=sum(1,0,n-1,query[i].first.first,query[i].first.second);
	}
	for(ll i=0;i<q;i++)cout<<ans[i]<<"\n";

}

Measured memory_bytes: 84248
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define mod 1000000007
using namespace std;

int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
int n,num[1000009]; char ch[1000009];
int main(){
	scanf("%d%s",&n,ch+1);
	int i,j; ll ans=1;
	for (i=1; i<=n; i++) num[ch[i]]++;
	for (i=0; i<=200; i++)
		ans=(ll)ans*(num[i]+1)%mod;
	printf("%lld\n",(ans-1+mod)%mod);
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<map>
#include<queue>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 1000000
struct mzls
{
	int to,cost;
}as;
vector<mzls>g[N+5];
inline void insert(int x,int y,int z) 
{
	as.to=y,as.cost=z;
	g[x].push_back(as);
	as.to=x;
	g[y].push_back(as);
}
queue<int>q;
int dist[N+5];
bool f[N+5];
inline void SPFA(int s) 
{
	memset(dist,0x3f3f3f,sizeof(dist));
	q.push(s);
	f[s]=1,dist[s]=0;
	while(!q.empty()) 
	{
		int x=q.front();
		q.pop();
		f[x]=0;
		for(int i=0;i<g[x].size();i++) 
		{
			int v=g[x][i].to;
			if(dist[v]>dist[x]+g[x][i].cost) 
			{
				dist[v]=dist[x]+g[x][i].cost;
				if(!f[v]) 
				{
					f[v]=1;
					q.push(v);
				}
			}
		}
	}
}
map<pair<int,int>,int>fa;
int n,m,t;
inline int X(int x,int y) 
{
	if(fa[make_pair(x,y)])
		return fa[make_pair(x,y)];
	return fa[make_pair(x,y)]=++t;
}
int main()
{
	scanf("%d%d",&n,&m);
	t=n;
	for(int i=1;i<=m;i++) 
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		int t1=X(x,z);
		int t2=X(y,z);
		insert(t1,t2,0);
		insert(x,t1,1);
		insert(y,t2,1);
	}
	SPFA(1);
	printf("%d\n",dist[n]>=0x3f3f3f?-1:dist[n]/2);
	return 0;
}

Measured memory_bytes: 71552
import numpy as np
n=int(input())
ans=0
a=list(map(int,input().split()))
now=max(a)
noww=now
k=n+2*now
matc=[0]*(n+2)
mat2=[0]*(n+2)
for i in range(n):
  neg=i-a[i]
  pos=i+a[i]
  if neg>=0:
    matc[neg]+=1
  if pos<=n:
    mat2[pos]+=1
  now+=1
#print(matc)
for j in range(n+2):
  ans+=matc[j]*mat2[j]
print(ans)
       
       




Measured memory_bytes: 51032
import sys

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

rows, cols, k = inp[ii:ii+3]; ii += 3
items = [[] for _ in range(rows+1)]
best = [0]*(cols+1)
for _ in range(k):
	r, c, v = inp[ii:ii+3]; ii += 3
	items[r].append([c, v])
for i in range(rows+1):
	items[i].sort()
ans = 0
for r in range(1, rows+1):
	dp = []
	best1, best2 = 0, 0
	Row = items[r]
	for c, v in Row:
		v1 = best[c] + v
		v2 = best1 + v
		v3 = best2 + v
		V = v1
		if V < v2:
			V = v2
		if V < v3:
			V = v3
		dp.append(V)
		if v1 > best1:
			best1 = v1
		if v2 > best2:
			best2 = v2
		if ans < V:
			ans = V
	for j in range(len(dp)):
		if best[Row[j][0]] < dp[j]:
			best[Row[j][0]] = dp[j]
	for j in range(2, cols+1):
		if best[j] < best[j-1]:
			best[j] = best[j-1]
print(ans)


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

#define LL long long

int main(){
	

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

	int a,b;
	cin>>a>>b;

	for(int i=1;i<=998;i++){
		int x = i*(i+1);
		x/=2;
		int y = (i+1)*(i+2);
		y/=2;
		if(x>=a && y>=b && (x-a)==(y-b)){cout<<(x-a)<<endl;return 0;}
	}
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        List<List<Integer>> list = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            list.add(new ArrayList<>());
        }
        for (int i = 0; i < M; ++i) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            list.get(a).add(b);
            list.get(b).add(a);
        }

        List<Integer> route = new ArrayList<>();
        route.add(0);
        _out.println(search(0, N, list, route, new HashSet<>()));
    }
    private int search(int cur, int N, List<List<Integer>> list, List<Integer> route, Set<List<Integer>> set) {
        if (route.size() >= N) {
            if (route.size() == N && !set.contains(route)) {
                set.add(new ArrayList<>(route));
                return 1;
            }
            return 0;
        }

        int res = 0;

        for (int next : list.get(cur)) {
            if (!route.contains(next)) {
                route.add(next);
                res += search(next, N, list, route, set);
                route.remove(route.size() - 1);
            }
        }

        return res;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 23892
// ABC096-A
// OrangeStar

#include<stdio.h>

int main(void){
  int a, b;

  scanf("%d %d", &a, &b);

  if(a<=b){
    printf("%d\n", a);
  }else{
    printf("%d\n", a-1);
  }

  return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	ns := nextLine()
	s := 0
	for _, r := range ns {
		a, _ := strconv.Atoi(string(r))
		s += a
	}
	ni, _ := strconv.Atoi(ns)

	if ni%s == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
w,h,n=map(int,input().split())
width=[0,w]
height=[0,h]
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    if width[0]<x:
      width[0]=x
  elif a==2:
    if width[1]>x:
      width[1]=x
  elif a==3:
    if height[0]<y:
      height[0]=y
  elif a==4:
    if height[1]>y:
      height[1]=y
X=width[1]-width[0]
Y=height[1]-height[0]
if X>0 and Y>0:
  print(X*Y)
else:
  print(0)


Measured memory_bytes: 3064
#include<iostream>
#define I(i,n)for(int i=0;i<n;i++)
long long M=1e9+7,n,a[2],s[100000],w[2][100001],e[2],l[2][100000],p,v[2];
int main(){
	std::cin>>n>>a[0]>>a[1];
	I(i,n)std::cin>>s[i];
	I(k,2){
		p=0;
		I(i,n){
			while(s[i]-s[p]>=a[k]&&p<i-1)p++;
			l[k][i]=p;
		}
	}
	I(k,2){e[k]=-1;w[k][0]=1;}
	I(i,n){if(i){
		I(k,2)v[k]=(e[1-k]<l[k][i]?w[1-k][l[k][i]]:0);
		I(k,2)if(s[i]-s[i-1]<a[k]){e[k]=i-1;}else{(v[k]+=w[k][i-1])%=M;}
		I(k,2)w[k][i+1]=w[k][i]=v[k];
	}
	}
	std::cout<<(w[0][n-1]+w[1][n-1])%M<<"\n";
	return 0;
}

Measured memory_bytes: 4096
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
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 mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// head

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

ll mod_inverse(ll a, ll m)
{
	ll x, y;
	exgcd(a, m, x, y);
	return (m + x % m) % m;
}

ll dp[8005][4005];

int main()
{
	ios::sync_with_stdio(false);
#ifdef RG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vi a(n), b(n);
	rep(i, 0, n) cin >> a[i] >> b[i];

	int ma = 0;
	rep(i, 0, n) ma = max(ma, max(a[i], b[i]));

	rep(i, 0, n) {
		dp[ma - a[i]][ma - b[i]] += 1;
	}

	rep(i, 0, 2 * ma + 1) {
		rep(j, 0, 2 * ma + 1) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= mod;
			dp[i][j + 1] += dp[i][j];
			dp[i][j + 1] %= mod;
		}
	}

	ll ans = 0;
	rep(i, 0, n) {
		ans += dp[ma + a[i]][ma + b[i]];
		ans %= mod;
	}

	memset(dp, 0, sizeof(dp));
	rep(i, 0, 4 * ma + 1) {
		dp[i][0] = 1;
		rep(j, 1, min(2*ma+1, i+1)) {
			dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
		}
	}

	rep(i, 0, n) {
		ans -= dp[(a[i] + b[i]) * 2][a[i] * 2];
		ans = (ans + mod) % mod;
	}

	ans = ans * mod_inverse(2, mod) % mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 252288
using System;
using System.Globalization;

namespace ITP_4_A{
    public class Program{
        public static void Main(string[] args){
            string[] temp = Console.ReadLine().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);

            Console.WriteLine((a/b) +" "+ (a%b) +" "+ (((double)a)/b).ToString("F5",CultureInfo.InvariantCulture));
        }
    }
}

Measured memory_bytes: 9140
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

int main(){
  int n,l;
  cin >> n >> l;
  vs s(n);
  rep(i,n) cin >> s[i];
  sort(all(s));
  cout << accumulate(all(s),string()) << endl;
}


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

using namespace std;

# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;

# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)

int f(int a)
{
	int res = 0;
	while (a)
	{
		res += a % 10;
		a /= 10;
	}
	return res;
}

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

	int n;
	cin >> n;
	int ans = INT_MAX;
	for (int i = 1; i < n; i ++)
		smin(ans, f(i) + f(n - i));
	cout << ans << endl;

	return 0;
}






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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var n = long.Parse(ReadLine());
            var name = new StringBuilder();

            while(n > 0)
            {
                var mod = n % 26L;
                if(mod == 0)
                {
                    mod = 26;
                }
                name.Append((char)('a' - 1L + mod));
                n--;
                n /= 26L;
            }

            var answer = new StringBuilder();
            foreach(var c in name.ToString().Reverse())
            {
                answer.Append(c);
            }
            WriteLine(answer);
        }
    }
}


Measured memory_bytes: 18876
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int n,d;
  cin >> n >> d;
  int m = 2*d+1;
  if(n%m==0) cout << n/m << endl;
  else cout << n/m + 1 << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    if all([a == b for a, b in ab]):
        print(0)
        return 0
    min_b = min([b for a, b in ab if a > b])
    sum_a = sum([a for a, b in ab])
    print(sum_a-min_b)


main()

Measured memory_bytes: 8056
import java.util.*;
import java.math.BigDecimal;

public class Main {
  public static void main (String args[]) {
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    String A[] = new String[N];
    BigDecimal C = new BigDecimal("1000000000000000000");
    String B = "";
    
    for(int i=0; i<N; i++) {
      A[i] = sc.next();
    }
    Arrays.sort(A);
    BigDecimal z = new BigDecimal("0");
    BigDecimal b = new BigDecimal("1");
    for(int j=0; j<N; j++) {
      BigDecimal b1 = new BigDecimal(A[j]);
      b= b.multiply(b1);
      if(b.compareTo(z) == 0) {
        break;
      } else if(b.compareTo(C) > 0) {
        b = new BigDecimal("-1");
        break;
      }
    }
    System.out.println(b);
  }
}

Measured memory_bytes: 66436
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = InputNumList();
            WriteLine(a[0] % 3 == 0 || a[1] % 3 == 0 || (a[0] + a[1]) % 3 == 0 ? "Possible" : "Impossible");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
  
  return (0);
}

Measured memory_bytes: 3636
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		char[] s = br.readLine().toLowerCase().toCharArray();
		char[] p = br.readLine().toLowerCase().toCharArray();
		boolean isExist = false;
		boolean isCheck;

		for (int i = 0; i < s.length; i++) {
			isCheck = false;
			
			if (p[0] == s[i]) isCheck = true;
			
			for (int j = i, ip = 0; isCheck && j <= s.length && ip < p.length; j++, ip++) {
				if (j == s.length)		j = 0;
				if (s[j] != p[ip])		break;
				if (ip == p.length - 1)	isExist = true;
			}
		}
		
		System.out.println(isExist ? "Yes" : "No"); 
	}
}

Measured memory_bytes: 24360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		long N = Long.parseLong(lines[0]);
		long K = Long.parseLong(lines[1]);

		long t = N % K;

		System.out.println(Math.min(t, K-t));
	}

}


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

int main(){
 long long N;
 cin >> N;
 set<int> a;
 for(long long i = 1; i * i <= N; i++){
   if(N % i == 0){
     long long digit, digit2;
     digit = (int)log10(i);
     digit2 = (int)log10(N / i);
     a.insert(max(digit, digit2) + 1);
   }
 }
 cout << *begin(a) << endl;
}


Measured memory_bytes: 3864
#include<iostream>
#include<vector>

using namespace std;

void insertsort(vector<int> &A,int n){
	
	for(int i = 0;i < n;i++){
		int v = A[i];
		int j = i-1;
		while(j >= 0 && v < A[j]){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		for(j=0;j<n-1;j++)cout << A[j] << " ";
		cout << A[j] << endl;
	}
}

int main(){
	int n,a;
	cin >> n;
	vector<int> A;
	for(int i = 0 ; i < n;i++){
		cin >> a;
		A.push_back(a);
	}
	insertsort(A,n);
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    double r; cin >> r;
    cout << fixed << setprecision(12) << (2*M_PI*r) << '\n';
    return 0;
}


Measured memory_bytes: 3804
def compute(S, X): 
  if (S-X)%2==1:
    print(-1)
    return
  A = (S - X)//2
  a = 0
  ambiguous=[0]*64
  for i in range(63,-1,-1): 
    Xi = (X & (1 << i)) 
    Ai = (A & (1 << i)) 
    if (Xi == 0 and Ai == 0): 
      pass
    elif (Xi == 0 and Ai > 0): 
      a = ((1 << i) | a)
    elif (Xi > 0 and Ai == 0): 
      ambiguous[i]=1
    else:
      print(-1) 
      return
  for i in range(63,-1,-1):
    if ambiguous[i]==1:
      R=((1 << i) | a) 
      if R<=a1[0]:
        a=R
      else:
        a = ((0 << i) | a)
  if a>a1[0]:
    print(-1)
  else:
    if a==0 and a1[0]!=0:
      print(-1)
    else:
      print(a1[0]-a)
    
  
import sys
n=int(input())
a1=list(map(int,input().split()))
nimsum=0
for i in range(2,n):
  nimsum=a1[i]^nimsum
compute(a1[0]+a1[1],nimsum)



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

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

    ll even = 0;
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum >= 0) {
                even += abs(sum)+1;
                sum = -1;
            }
        } else {
            if (sum <= 0) {
                even += abs(sum)+1;
                sum = 1;
            }
        }
    }

    ll odd = 0;
    sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += a[i];
        if (i % 2 != 0) {
            if (sum >= 0) {
                odd += abs(sum)+1;
                sum = -1;
            }
        } else {
            if (sum <= 0) {
                odd += abs(sum)+1;
                sum = 1;
            }
        }
    }

    cout << min(even, odd) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
/*
13
0 3 1 4 10
1 2 2 3
2 0
3 0
4 3 5 6 7
5 0
6 0
7 2 8 9
8 0
9 0
10 2 11 12
11 0
12 0
*/
using namespace std;
struct Node {
	int hasChild;
	int parent;
	int leftChild;
	int rightSib;
	int depth;
};

// use top-down
void depth(Node* arr, int id, int d) {
	arr[id].depth = d;
	if (arr[id].leftChild != -1) depth(arr, arr[id].leftChild, d + 1);
	if (arr[id].rightSib != -1) depth(arr, arr[id].rightSib, d);
}

int main() {
	int len;
	cin >> len;
	Node* arr = new Node[len];
	for (int i = 0; i < len; i++)
		arr[i].parent = arr[i].leftChild = arr[i].rightSib = -1;
	int id;
	for (int i = 0; i < len; i++) {
		cin >> id;
		cin >> arr[id].hasChild;
		int m,n;
		for (int j = 0; j < arr[id].hasChild; j++) {
			cin >> m;
			if (j == 0)
				arr[id].leftChild = m;
			else
				arr[n].rightSib = m;
			arr[m].parent = id;
			n = m;
		}
	}

	for (int i = 0; i < len; i++)
		if (arr[i].parent == -1) {
			depth(arr, i, 0);
			break;
		}

	for (int i = 0; i < len; i++) {
		cout << "node " << i << ": parent = " << arr[i].parent << ", depth = " << arr[i].depth << ", ";
		if (arr[i].hasChild) {
			if (arr[i].depth == 0)
				cout << "root";
			else
				cout << "internal node";
			cout << ", [";
			for (int j = arr[i].leftChild, cnt = 0; cnt < arr[i].hasChild;cnt++,j=arr[j].rightSib) {
				if (cnt == arr[i].hasChild - 1)
					cout << j << "]\n";
				else
					cout << j << ", ";
			}
		}
		else if (arr[i].depth != 0)
			cout << "leaf, []\n";
		else
			cout << "root, []\n";
	}
	return 0;
}


Measured memory_bytes: 5012
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut itr = is.split_whitespace().map(|e| e.parse::<usize>().unwrap());
    let n: usize = itr.next().unwrap();
    let k: usize = itr.next().unwrap();
    is.clear();
    stdin().read_line(&mut is).ok();
    let mut a = is
        .split_whitespace()
        .map(|e| e.parse::<i64>().unwrap())
        .collect::<Vec<i64>>();

    for _ in 0..k {
        let mut b = vec![0; n + 1];
        for i in 0..n {
            let l = i.saturating_sub(a[i] as usize);
            let r = min(i + a[i] as usize + 1, n);
            b[l] += 1;
            b[r] += -1;
        }
        for i in 1..n {
            b[i] += b[i - 1];
        }

        a = b;
        a.pop();
        if a.iter().all(|e| e == &(n as i64)) {
            break;
        }
    }

    let mut flg = false;
    for e in a {
        if flg {
            print!(" ");
        }
        print!("{}", e);
        flg = true;
    }
    println!();
}


Measured memory_bytes: 6364
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  cout << (n+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[200100];
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	
	int n, gate;
	while (cin >>n>>gate)
	{			
		int no = 0;
		int left, right;
		int L = 0, R = 10e5+10;
		while (gate--)
		{
			cin >> left >> right;
			L = max(left, L);
			R = min(right, R);
		}
		if (R - L < 0)
			cout << 0 << '\n';
		else
			cout << R - L + 1<< '\n';
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        MCandies solver = new MCandies();
        solver.solve(1, in, out);
        out.close();
    }

    static class MCandies {
        public final int MOD = (int) 1e9 + 7;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            long[][] dp = new long[n + 1][k + 1];
            dp[0][0] = 1;
            for (int i = 0; i < n; i++) {
                long syakSum = 0;
                for (int j = 0; j < a[i]; j++) {
                    syakSum = add(syakSum, dp[i][j]);
                    dp[i + 1][j] = syakSum;
                }
                for (int j = a[i]; j <= k; j++) {
                    syakSum = add(syakSum, dp[i][j]);
                    // 尺取り
                    dp[i + 1][j] = syakSum;
                    syakSum = sub(syakSum, dp[i][j - a[i]]);
                }
            }

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

        long add(long a, long b) {
            return (a + b) % MOD;
        }

        long sub(long a, long b) {
            return (a - b + MOD) % MOD;
        }

    }
}



Measured memory_bytes: 127056
#include<bits/stdc++.h>
using namespace std;
#define ll long  long 
#define pb push_back
#define test int t; cin >>t; while(t--)
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define f first
#define s second
#define mp make_pair
#define fo(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
void dummy(int n)
{
    for(int i=0;i<n;i++)
    {
        cout<<"";
    }
}
ll int power(ll int a,ll int b)
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		result*=a;
		a*=a;
		b=b/2;
	}
	return result;
}
int main() 
{
    dummy(100);
    fast
	long double a,b;
	cin >>a>>b;
	long double k=a*b;
	ll int k1=k;
	cout<<k1;

    return 0;
}


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

int a[21],n;
bool tansaku(int i,int m){
	if(m == 0)return true;
	if(i >= n)return false;
	bool res = tansaku(i + 1,m) || tansaku(i + 1, m - a[i]);
	return res;
}

int main(){
	int q,m;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	cin >> q;
	for(int i = 0;i < q;i++){
		cin >> m;
		if(tansaku(0,m)){
			cout << "yes" <<endl;
		}
		else cout << "no" <<endl;
	}
	return 0;
}

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

# define ll long long 

int main(){
    ll n, temp, sum=0; 
    cin>>n;
    map<ll, ll> counts;
    for(ll i = 0; i < n; i++){
        cin>>temp;
        if(counts.count(temp)>0){
            counts[temp]++;
        }
        else counts[temp] = 1;
    }
    for(auto i: counts){
        if(i.first<i.second) sum+=(i.second - i.first);
        if(i.first>i.second) sum+=i.second;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 6272
module BinaryTree = struct
  let nil = -1

  type t = {
    mutable parent : int;
    mutable left : int;
    mutable right : int;
    mutable depth : int;
    mutable height : int;
  }

  let make () = {
    parent = nil;
    left = nil;
    right = nil;
    depth = nil;
    height = nil
  }
end

module T = BinaryTree

let _ =
  let n = read_int () in
  let t = Array.init n (fun _ -> T.make ()) in
  Array.iteri (fun i _ ->
    let id, l, r = Scanf.scanf "%d %d %d\n" (fun id l r -> id, l, r) in
    t.(id).T.left <- l;
    t.(id).T.right <- r;
    if l <> T.nil then t.(l).T.parent <- id;
    if r <> T.nil then t.(r).T.parent <- id
  ) t;
  let rec search_root i =
    if i = n then T.nil
    else if t.(i).T.parent = T.nil then i
    else search_root (i + 1)
  in
  let root = search_root 0 in
  let rec set_depth i d =
    t.(i).T.depth <- d;
    if t.(i).T.left <> T.nil then set_depth t.(i).T.left (d + 1);
    if t.(i).T.right <> T.nil then set_depth t.(i).T.right (d + 1);
  in
  set_depth root 0;
  let rec set_height i =
    let hl = ref 0 in
    let hr = ref 0 in
    if t.(i).T.left <> T.nil then (set_height t.(i).T.left; hl := t.(t.(i).T.left).T.height + 1);
    if t.(i).T.right <> T.nil then (set_height t.(i).T.right; hr := t.(t.(i).T.right).T.height + 1);
    let h = max !hl !hr in
    t.(i).T.height <- h;
  in
  set_height root;
  let get_sibling i =
    if t.(i).T.parent = T.nil then T.nil
    else if t.(t.(i).T.parent).T.left <> i && t.(t.(i).T.parent).T.left <> T.nil then t.(t.(i).T.parent).T.left
    else if t.(t.(i).T.parent).T.right <> i && t.(t.(i).T.parent).T.right <> T.nil then t.(t.(i).T.parent).T.right
    else T.nil
  in
  let get_degree i =
    0 + (if t.(i).T.left <> T.nil then 1 else 0) + (if t.(i).T.right <> T.nil then 1 else 0)
  in
  let print i =
    print_string "node "; print_int i;
    print_string ": parent = "; print_int t.(i).T.parent;
    print_string ", sibling = "; print_int (get_sibling i);
    print_string ", degree = "; print_int (get_degree i);
    print_string ", depth = "; print_int t.(i).T.depth;
    print_string ", height = "; print_int t.(i).T.height;
    print_string (if t.(i).T.parent = T.nil then ", root" else if t.(i).T.left = T.nil && t.(i).T.right = T.nil then ", leaf" else ", internal node");
    print_newline ()
  in
  Array.iteri (fun i _ -> print i) t

Measured memory_bytes: 2368
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0; i<N; i++) cin >> h.at(i);
  
  long ans = 0;
  for(int i=0; i<N; i++){
    if(h.at(i) >= K) ans++;
  }
  
  cout << ans << endl;
  //printf("%lf", ans);
 
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    long long int ans=0;
    for(int n=0; n<N; n++) {
        long long int l, r;
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;


    return 0;
    
}

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

using namespace std;

#define int long long

const int mod = 1e9 + 7;

int bp(int a, int b) {
    if (b == 0) return 1;
    int val = bp(a, b / 2);
    if (b % 2) return (val * ((val * a) % mod)) % mod;
    return (val * val) % mod;
}

int divv(int a, int b) {
    return a * bp(b, mod - 2) % mod;
}

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    int val = bp(2, n);
    int a1 = 1, a2 = 1;
    for (int i = n; i > n - a; --i) {
        a1 = (a1 * i) % mod;
        a1 = divv(a1, a - (n - i));
    }
    for (int i = n; i > n - b; --i) {
        a2 = (a2 * i) % mod;
        a2 = divv(a2, b - (n - i));
    }
    cout << ((val - a1 - a2 - 1) % mod + mod) % mod;
}

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


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

int main() {
	double x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(5);
	cout << pow((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2),0.5) << endl;
	return 0;
}

Measured memory_bytes: 3404
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=100005;
const int maxm=31;
int n,k,cur;
ll ans;
int a[maxn],b[maxn];
vector<int>pos;

void solve(int i){
	cur+=(1<<pos[i]);
	ll now=0;
	rep(j,n){
		if(a[j]&(1<<pos[i]))a[j]^=(1<<pos[i]);
		if(a[j]>(i==pos.size()-1?0:(1<<pos[i+1])))continue;
		now+=b[j];
	}
	ans=max(ans,now);
}

int main(){
	scanf("%d%d",&n,&k);
	rep(i,n)scanf("%d%d",&a[i],&b[i]);
	if(!k){
		rep(j,n)if(a[j]==0)ans+=b[j];
		printf("%lld",ans);
		return 0;
	}
	for(int i=maxm-1;i>=0;i--)
	if(k&(1<<i))pos.push_back(i);
	ll now=0;
	rep(i,n){
		if(a[i]>=(1<<pos[0]))continue;
		now+=b[i];
	}
	ans=now;
	rep(i,pos.size())solve(i);
	printf("%lld",ans);
	return 0;
}

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

int main()
{
    int n, w;
    cin >> n >> w;
    int a[n] = {};
    long long v[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i] >> v[i];
    }
    long long dp[n+1][n*1000 + 1] = {};
    fill(dp[0], dp[0]+n*1000 + 1, 1e15);
    dp[0][0] = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<=n*1000; j++){
            if(j < v[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + a[i]);
            }
        }
    }
    int ans = 0;
    for(int i=0; i<=n*1000; i++){
        if(dp[n][i] <= w){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = 3.1415926535897932;
const ll mod = 1000000007;

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 {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= 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 {
        mint res(*this);
        return res /= a;
    }
};

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()
{
    ll x, y;
    cin >> x >> y;
    // 対称性より、x < yとしても良い
    if (x > y) {
        ll tmp = x;
        x = y;
        y = tmp;
    }

    ll sum = x + y;
    ll diff = y - x;
    if (sum % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll n = sum / 3;
    ll r = (n - diff) / 2;

    combination c(n);
    mint ans = c(n, r);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 10624