akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

using namespace std;

typedef long long Int;
const Int mod = 1000000007;
const Int INF = mod * mod;

Int gcd(Int x, Int y) {
	if (y == 0)return x;
	else return gcd(y, x % y);
}

Int f(Int n, Int c, Int d) {
	Int x = n;
	x -= n / c;
	x -= n / d;
	Int l = c * d / gcd(c, d);
	x += n / l;
	return x;
}
int main() {
	Int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << f(b, c, d) - f(a - 1, c, d) << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	a := getStdinInt()
	s := getStdin()

	if a >= 3200 {
		fmt.Printf("%s\n", s)
	} else {
		fmt.Printf("red\n")
	}
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

int N;
vector<vector<int>> g;
vector<double> dis;
double dfs(int now){
  if(dis[now])return dis[now];
  double res=0,f=0;
  for(int next:g[now]){
    if(next==-1){
      f=1;
      continue;
    }
    res+=dfs(next);
  }
  res/=g[now].size()-f;
  return dis[now]=res+1;
}
int main(){
  startupcpp();
  int i,j,M,f=-1;
  double ans;
  cin>>N>>M;
  g.resize(N);
  dis.resize(N,0);
  dis[N-1]=1;
  while(M--){
    cin>>i>>j;
    g[--i].eb(--j);
  }
  ans=dfs(0);
  rep(i,N)if(g[i].size()>1){
    sort(all(g[i]),[](int l,int r){return dis[l]>dis[r];});
    swap(g[i][0],f);
    rep(j,i+1)dis[j]=0;
    chmin(ans,dfs(0));
    swap(g[i][0],f);
  }
  print(ans-1);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N,H, n,m , M, K,a;

vector<ll> v;
int main(){
    cin >> N >> K;
    vector<ll> h(N+1);
    vector<ll> dp(N+1);
    vector<ll> cost(K+1);
    for(int i = 1; i <= N; ++i){
        ll he; cin >>he; h[i] = he;
    }
  	dp[0] = 1e12;
  	dp[1] = 0;
  	cost[0] = 1e12;
    for(int i = 2;  i <= N; ++i){
        for(int j = 1; j <= K; ++j){
            cost[j] = i - j >0 ? dp[i-j] + abs(h[i] - h[i-j]) : 1e12; 
        }
        dp[i] = *min_element(cost.begin(), cost.end());
    }
    cout << dp[N];
    return 0;

}



Measured memory_bytes: 1792
#include<iostream>
#include<string.h>
using namespace std;

int main() 
{
	int K;

	cin >> K;

	char S[110];

	cin >> S;

	int size_S;
	size_S = strlen(S);

	if (size_S <= K) {
		cout << S;
	}
	else {
		for (int i = 0; i < K; i++) {
			cout << S[i];
		}
		cout << "..."<<endl;
	}

	return 0;
}

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

#include <cstdio>
#include <cmath>
using namespace std;

typedef double D;
const D EPS = 1e-8;
const D INF = 1e10;
const D PI = M_PI;

struct P {
    D x, y;
    P(D xs, D ys) : x(xs), y(ys) { }
    P() { }
};

P operator +(P a, P b) { return P(a.x + b.x, a.y + b.y); }
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
P operator *(P p, D s) { return P(p.x * s, p.y * s); }

D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D outp(P a, P b) { return a.x*b.y - a.y*b.x; }

D norm(P p) { return inp(p, p); }
D abs(P p) { return sqrt(norm(p)); }

bool eq(P a, P b) { return abs(a - b) < EPS; }

D arg(P p) { return atan2(p.y, p.x); }

P rot90(P p) {
    return P(-p.y, p.x);
}

P rot(P p, D radian) {
    P q;
    q.x = cos(radian)*p.x - sin(radian)*p.y;
    q.y = sin(radian)*p.x + cos(radian)*p.y;
    return q;
}

struct L : vector<P> {
    L(P a, P b) { push_back(a); push_back(b); }
    L() { this->resize(2); }
};

struct C {
    P p; D r;
    C(P ps, D rs) : p(ps), r(rs) { }
    C() { }
};

// ??´???l???????????????p?????????
// (l??????p??????????????????????????¨????????????????±???????)
// norm??§?????£?????????(abs??§??????????????????)
P projection(L l, P p) {
    P a = l[1] - l[0];
    P b = p - l[0];
    D t = inp(b, a) / norm(a);
    return l[0] + a * t;
}

// ??´???l???????????????p???????°?
// (l????????????????§°???p??????)
P reflection(L l, P p) {
    return p + (projection(l, p) - p) * 2;
}

int ccw(P a, P b, P c) {
    b = b - a; c = c - a;

    // a - b - c ????????????????????¨???
    if(outp(b, c) > EPS)  return +1; // ???????¨???????
    if(outp(b, c) < -EPS) return -1; // ????¨???????

    // a - b - c ??´??????????????¶??¨???
    if(inp(b, c) < 0)     return +2; // c - a - b
    if(norm(b) < norm(c)) return -2; // a - b - c
    return 0;                        // a - c - b
}

/* intersect Segment Segment */
bool iSS(L s, L t) {
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
        ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

/* crosspoint Line Line */
P cLL(L s, L t) {
    D d = outp(t[1] - t[0], s[1] - s[0]);
    if(abs(d) < EPS) throw "s // t !";
    return s[0] + (s[1] - s[0]) * outp(t[1] - t[0], t[1] - s[0]) * (1.0 / d);
}

int main() {
    int Q; cin >> Q;
    while(Q--) {
        D x[4], y[4];
        for(int i = 0; i < 4; i++) {
            cin >> x[i] >> y[i];
        }

        L s(P(x[0], y[0]), P(x[1], y[1])), t(P(x[2], y[2]), P(x[3], y[3]));

        P p = cLL(s, t);
        printf("%.9f %.9f\n", p.x, p.y);
    }
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template <class T>
class Lazy_Segment_Tree{
	private:
	int n;
	vector<T> date,lazy;
	void Set_Lazy(int k,T x){
		date[k]+=x;
		lazy[k]+=x;
	}
	void Push(int k){
		Set_Lazy(k*2+1,lazy[k]);
		Set_Lazy(k*2+2,lazy[k]);
		lazy[k]=0;
	}
	void Fix(int k){
		date[k]=min(date[k*2+1],date[k*2+2]);
	}
	void Add_func(int a,int b,int k,int l,int r,T x){
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b){
			Set_Lazy(k,x);
			return;
		}
		Push(k);
		int m=(l+r)/2;
		Add_func(a,b,k*2+1,l,m,x);
		Add_func(a,b,k*2+2,m,r,x);
		Fix(k);
	}
	public:
	Lazy_Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=lazy=vector<T>(2*n-1);
		for(int i=0;i<n_;i++) date[i+n-1]=n_-i-1;
		for(int i=n-2;i>=0;i--) date[i]=min(date[i*2+1],date[i*2+2]);
	}
	void Add(int a,int b,T x){
		Add_func(a,b,0,0,n,x);
	}
	T Min(){
		return date[0];
	}
};

int n,m;
vvi a;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	a=vvi(m+1);
	for(int i=0;i<n;i++){
		int l,r;
		cin>>l>>r;
		a[l].push_back(r);
	}
	Lazy_Segment_Tree<int> st(m+1);
	priority_queue<int> q;
	int t=0;
	for(int l=0;l<=m;l++){
		for(auto r:a[l]){
			q.push(r);
			st.Add(0,r,-1);
			t++;
		}
		while(t>m||st.Min()<0){
			int r=q.top();
			st.Add(0,r,1);
			t--;
		}
		st.Add(0,m+1,1);
	}
	cout<<n-t<<endl;
}

Measured memory_bytes: 13820
def gcd(a, b):
	"""Compute the greatest common divisor of a and b"""
	while b > 0:
		a, b = b, a % b
	return a

def resolve():
	n, x = map(int, input().split())
	pos = list(map(int, input().split()))
	diff = [0]*n
	for i in range(n):
		diff[i] = abs(x - pos[i])
	ans = diff[0]
	for i in range(1, n):
		ans = gcd(ans, diff[i])
	print(ans)
resolve()

Measured memory_bytes: 62576
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=55,M=125005,inf=1e9+9;
struct node{
	ll s,v;
	friend bool operator < (node a,node b){
		return a.v*b.s<b.v*a.s;
	}
} x[N];
int m[N],n,p,sum;
ll f[M],X,D,ans;
vi e[N];

void dfs(int u){
	x[u].s=1,x[u].v=m[u];
	for(auto v:e[u]){
		dfs(v);
		x[u].s+=x[v].s;
		x[u].v+=x[v].v;
	}
	sum+=x[u].s*n;
}

int main(){
	read(n),read(X),read(D);
	rep(i,1,n){
		read(m[i]);
		if(i>=2) read(p),e[p].pb(i);
	}
	dfs(1);
	sort(x+1,x+n+1);
	memset(f,0x3f,sizeof f);
	f[0]=0;
	rep(i,1,n){
		int rem=(x[i].s==n?n:min((ll)n,D));
		for(int k=1;k<=rem;k<<=1){
			ll a=x[i].s*k,b=x[i].v*k;
			for(int s=sum;~s;s--) if(f[s]>=0)
				f[s+a]=min(f[s+a],f[s]+b);
			rem-=k;
		}
		if(!rem) continue;
		ll a=x[i].s*rem,b=x[i].v*rem;
		for(int s=sum;~s;s--) if(f[s]>=0)
			f[s+a]=min(f[s+a],f[s]+b);
	}
	rep(i,0,sum){
		ll rem=X-f[i],res=0;
		if(rem<0) continue;
		rep(j,1,n){
			ll owo=min((x[j].s==n?(ll)inf:D-min((ll)n,D)),rem/x[j].v);
			res+=owo*x[j].s,rem-=owo*x[j].v;
		}
		ans=max(ans,i+res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a.at(i);
    vector<vector<ll>> dp(n,vector<ll>(5,-INF));
    dp.at(0).at(0)=a.at(0);
    dp.at(1).at(1)=a.at(1);
    if(n>2)dp.at(2).at(2)=a.at(2);
    int yutori;
    if(n%2==0){yutori=1;}
    else{yutori=2;}
    rep(i,n){
        rep(j,3){
            if(i+2<=n-1)chmax(dp.at(i+2).at(j),dp.at(i).at(j)+a.at(i+2));
            if(i+3<=n-1)chmax(dp.at(i+3).at(j+1),dp.at(i).at(j)+a.at(i+3));
            if(i+4<=n-1)chmax(dp.at(i+4).at(j+2),dp.at(i).at(j)+a.at(i+4));
        }
    }
    ll ans=dp.at(n-1).at(yutori);
    chmax(ans,dp.at(n-2).at(yutori-1));
    if(yutori==2)chmax(ans,dp.at(n-3).at(yutori-2));
    cout<<ans<<endl;
}


Measured memory_bytes: 18840
<?php
/**
 * 動作確認：abc137_4
 */
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$m = (int)$input[1];

$tasks = [];
for ($i=0; $i < $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$a = (int)$input[0];
	$b = (int)$input[1];
	if ($a > $m) {
		continue;
	}
	if (isset($tasks[$a])) {
		$tasks[$a][] = $b;
	}else{
		$tasks[$a] = [$b];
	}
}
ksort($tasks);
$pq = new PriorityQueue();

$sum = 0;
for ($i=0; $i < $m; $i++) { 
	$rem_day = $i+1;
	if (isset($tasks[$rem_day])) {
		foreach ($tasks[$rem_day] as $t) {
			$pq->insert($t);
		}
	}
	$max = $pq->pop();
	if ($max !== NULL) {
		$sum += $max;
	}
}

echo $sum;

/**
 * priority queue
 * 優先度設定を変更するときは、compareメソッドを変更する
 */
class PriorityQueue
{
	// 1-idxedな配列
	private $data = [];

	public function insert($d){
		$size = count($this->data);
		$this->increaseKey($size+1, $d);
	}

	// $this->data[$idx]に値$dを追加し、priorityを満たす位置まで上昇させる
	private function increaseKey($idx, $d){
		$this->data[$idx] = $d;
		$parent_idx = (int)floor($idx/2);
		while ($idx > 1 && $this->compare($this->data[$idx], $this->data[$parent_idx])) {
			$tmp = $this->data[$idx];
			$this->data[$idx] = $this->data[$parent_idx];
			$this->data[$parent_idx] = $tmp;
			$idx = $parent_idx;
			$parent_idx = (int)floor($idx/2);
		}
	}

	public function pop(){
		$result = null;
		$size = count($this->data);
		if ($size > 0) {
			$result = $this->data[1];
			$this->data[1] = $this->data[$size];
			unset($this->data[$size]);
			if ($size !== 1) {
				$this->heapify(1);
			}
		}
		return $result;
	}

	// $this->data[$idx]を、priorityを満たす位置まで降下させる
	private function heapify($idx){
		$size = count($this->data);
		$l_idx = 2 * $idx;
		$r_idx = $l_idx + 1;
		$heighest_priority_idx = $idx;
		if ($l_idx <= $size && $this->compare($this->data[$l_idx], $this->data[$idx])) {
			$heighest_priority_idx = $l_idx;
		}
		if ($r_idx <= $size && $this->compare($this->data[$r_idx], $this->data[$heighest_priority_idx])) {
			$heighest_priority_idx = $r_idx;
		}

		if ($heighest_priority_idx !== $idx) {
			$tmp = $this->data[$heighest_priority_idx];
			$this->data[$heighest_priority_idx] = $this->data[$idx];
			$this->data[$idx] = $tmp;
			$this->heapify($heighest_priority_idx);
		}
	}

	// targetのpriorityがfromより真に高い場合にtrueを返す
	private function compare($target, $from){
		return ($target > $from);
	}

}

Measured memory_bytes: 47604
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  char *s; // to input 
  char *t; // to input 

  s = (char *)malloc(sizeof(char) * 10);
  t = (char *)malloc(sizeof(char) * 11);
  scan = scanf("%s", s);
  scan = scanf("%s", t);

  int lens = strlen(s);
  int lent = strlen(t);
  if (strncmp(s, t, lens) == 0) {
    if (lent - lens == 1) {
      printf("Yes");
      return (0);
    } else {
      printf("No");
      return (0);
    }
  }
  printf("No");
  return (0);

}


Measured memory_bytes: 1740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] h = new int[n];
		for ( int i = 0; i < h.length; i++ ) {
			h[i] = in.nextInt();
		}

		int base = h[0];
		for ( int i = 0; i < h.length; i++ ) {
			if ( base < h[i] ) base = h[i];

			if ( base - 1 > h[i] ) {
				System.out.println("No");
				in.close();
				return;
			}
		}

		System.out.println("Yes");
		in.close();

	}
}

Measured memory_bytes: 50952
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double
#define M 100000008

ll n;
ll a[3001];
ll dp[3001][3001];
ll o[3001][3001];

void pro(ll i, ll j)
{
	if((i - j + 1) == 2)
		dp[i][j] = abs(a[i] - a[j]);
	else if(i == j)
		dp[i][j] = a[i];
	else
	{
		ll t1, t2;
		if(o[i+1][j] == 0)
			pro(i+1, j);
		t1 = a[i] - dp[i+1][j];
		if(o[i][j-1] == 0)
			pro(i, j-1);
		t2 = a[j] - dp[i][j-1];
		dp[i][j] = max(t1, t2);
	}
	o[i][j] = 1;
}

int main()
{
	FAST;
	ll i, j;
	cin >> n;
	fr(i,0,n)
		cin >> a[i];
	pro(0, n-1);
	cout << dp[0][n-1];
}


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

#define int int_fast64_t

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int n; cin >> n;
  map<string, int> cnt;
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    cnt[s] += 1;
  }

  for (auto s : {"AC", "WA", "TLE", "RE"}) {
    cout << s << " x " << cnt[s] << '\n';
  }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans=0;
  int flg=0;
  for(auto s : S){
    if(s=='A') flg=1;
    else if(s=='B'&&flg==1) flg=2;
    else if(s=='C'&&flg==2) flg=3;
    else flg=0;
    if(flg==3) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
  if ( !v.empty() ) {
    out << '[';
    copy (v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.precision(16);
    
    long long n;
    cin >> n;

    auto itoslen = [=](int x) { return to_string(x).length(); };
    int ans = itoslen(n);
    int limit = sqrt(n) + 1;
    for(int i = 1; i < limit; i++) {
        if(n % i == 0) {
            ans = min(ans, (int)max(itoslen(i), itoslen(n/i)));
        }
    }
#if DEBUG
	cout << "** RESULT **" << endl; // debug
#endif
    cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    char a, b, c;
    cin >> a >> b >> c;

    if (a == b && b == c) {
        cout << "No" << "\n";
    } else {
        cout << "Yes" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

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

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(string, s);
  int mmin = 1e9;
  for (int i = 0; i < sz(s) - 2; ++i) {
    string ss = s.substr(i, 3);
    mmin = min(mmin, abs(stoi(ss) - 753));
  }

  cout << mmin << endl;
  return;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int d,e;
  while(1){
    cin>>d>>e;
    if(d+e==0)break;
    double a,min=1000000;
    for(int i=0;i<=d/2;i++){
      a=sqrt((d-i)*(d-i)+i*i);
      if(min>abs(e-a))min=abs(e-a);
    }
    printf("%f\n",min);
  }
  return 0;
}

Measured memory_bytes: 3148
def bubble_sort(A, N):
    flag = True
    i, c = 0, 0
    while flag:
        flag = False
        for j in range(1, N-i):
              if A[j] < A[j-1]:
                  A[j],  A[j-1] = A[j-1], A[j]
                  flag = True
                  c += 1
        i += 1
    
    print " ".join(map(str, A))
    print c


N = int(raw_input())
A = map(int, raw_input().split())
 
bubble_sort(A, N)

Measured memory_bytes: 6464
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, long long H, vector<long long> a, vector<long long> b) {
  sort(ALL(a));
  ll ma = a.back();

  sort(ALL(b));
  reverse(ALL(b));

  ll ans = 0;
  REP(i, b.size()) {
    if (H <= 0)
      break;
    if (b[i] > ma) {
      H -= b[i];
      ans++;
    } else {
      break;
    }
  }

  if (H > 0)
    ans += (H + ma - 1) / ma;
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long H;
  long long N;
  cin >> N;
  vector<long long> b(N - 1 + 1);
  vector<long long> a(N - 1 + 1);
  cin >> H;
  for (int i = 0; i <= N - 1; i++) {
    cin >> a[i];
    cin >> b[i];
  }
  solve(N, H, a, b);
  return 0;
}


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

const int inf = 1e18;

bool dfs(int u, auto& vis, const auto& g) {
    bool f = true;
    for (auto p : g[u]) {
        int v = p.first;
        int d = p.second;

        if (vis[v] != inf) {
            f &= (vis[v] == vis[u] + d);
            continue;
        }

        vis[v] = vis[u] + d;
        f &= dfs(v, vis, g);
    }
    return f;
}
signed main() {
    int N, M;
    cin >> N >> M;

    vector<vector<pair<int, int>>> G(N);
    for (int i = 0; i < M; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;

        G[l].push_back({r, d});
        G[r].push_back({l, -d});
    }

    vector<int> vis(N, inf);
    bool f = true;
    for (int i = 0; i < N; i++) {
        if (vis[i] != inf) continue;
        vis[i] = 0;
        f &= dfs(i, vis, G);
    }
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 18304
using System;
using System.Collections.Generic;
using System.Text;

namespace ABC158
{
    class A
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string ans = "Yes";
            if (s[0] == s[1] && s[1] == s[2]) { ans = "No"; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

li = []
seen = [False]*n
for i in range(n):
    if seen[i]:
        continue
    q = deque([i])
    seen[i] = True
    cnt = 1
    while q:
        node = q.popleft()
        for i in graph[node]:
            if seen[i]:
                continue
            seen[i] = True
            cnt += 1
            q.append(i)
    li.append(cnt)
print(max(li))

Measured memory_bytes: 45108
import math
N,K=map(int,input().split())
A=[0]*N
A=list(map(int,input().split()))

da=[0 for i in range(N)]
for k in range(K):
    B=[0 for i in range(N)]
    for i in range(N):
        l=max(0,i-A[i])
        r=min(N-1,i+A[i])
        B[l]=B[l]+1
        if(r+1<N):
            B[r+1]=B[r+1]-1
    for i in range(1,N):
        B[i]=min(N,B[i]+B[i-1])
    if(A==B):
        break
    A=B
b=[str(i) for i in B]
b=" ".join(b)
print(b)


Measured memory_bytes: 169832
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,m;
char s[SZ],t[SZ];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s%s",s,t);
	int g=__gcd(n,m);
	for(int i=0,j=0;i<n;i+=n/g,j+=m/g)
	{
		if(s[i]!=t[j])
		{
			puts("-1");
			return 0;
		}
	}
	printf("%lld\n",(ll)n/g*m);
}


Measured memory_bytes: 768
#include<iostream>
#include<stdlib.h>
using namespace std;
int main() {
	long long int n, k;
	cin >> n;
	cin >> k;
	if (k % 2 == 0) {
		long long int x, x_;
		x = n / k;
		x_ = n / (k / 2) - x;
		cout << x*x*x + x_*x_*x_ << endl;
	}
	else {
		long long int x = n / k;
		cout << x*x*x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll l, w, x, y;
    cin >> l >> w >> x >> y;
    cout << fixed << setprecision(6) << (l * w) / 2.0 << ' ';
    cout << (x * 2 == l && y * 2 == w);
    return 0;
}


Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a, b, c = MAP()
k = INT()

count = 0
while a >= b:
    b *= 2
    count += 1
while b >= c:
    c *= 2
    count += 1
if count <= k:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Measured memory_bytes: 10292
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

long long calc(long long x,long long y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){
	long long int a1,a2,a3,m1,m2,m3,min_x,min_y,min_z,x,y,z,pre,ans;

	while(true){
		scanf("%lld %lld %lld %lld %lld %lld",&a1,&m1,&a2,&m2,&a3,&m3);
		if(a1 == 0 && m1 == 0 && a2 == 0 && m2 == 0 && m3 == 0 && m3 == 0)break;

		x = 1;
		for(min_x = 1; min_x <= m1;min_x++){
			x = a1*x%m1;
			if(x == 1)break;
		}

		y = 1;
		for(min_y = 1; min_y <= m2; min_y++){
			y = a2*y%m2;
			if(y == 1)break;
		}

		z = 1;
		for(min_z = 1; min_z <= m3; min_z++){
			z = a3*z%m3;
			if(z == 1)break;
		}

		if(min_x > min_y){
			pre = ((min_x/(calc(min_x,min_y)))*min_y);
		}else{
			pre = ((min_y/(calc(min_y,min_x)))*min_x);
		}

		if(pre > min_z){
			ans = ((pre/(calc(pre,min_z)))*min_z);
		}else{
			ans = ((min_z/(calc(min_z,pre)))*pre);
		}
		printf("%lld\n",ans);
	}
    return 0;
}

Measured memory_bytes: 2620
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int i,x;
        for(i=0;;i++){ 
            x=sc.nextInt();
            if(x==0){
                break;
            }
            System.out.println("Case "+(i+1)+": "+x);                
        }
    }
}




Measured memory_bytes: 44992
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define x  first
#define y  second
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifndef ONLINE_JUDGE
	// #include "debug.h"
#else
// #define debug(...) 42
#endif

const int mxN=100;
const ld PI=acos(-1);
const int MD=1e9+7;

int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		ll n,d,cnt=0;
		cin>>n>>d;
		for(int i=0;i<n;i++){
			ll a,b;
			cin>>a>>b;
			if(a*a+b*b<=d*d) cnt++;
		}
		cout<<cnt;
	}
	return 0;	
}

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

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

    long long h, w;
    cin >> h >> w;
    long long c[10][10];
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> c[i][j];
        }
    }

    long long a[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == -1) continue;
            ans += c[a[i][j]][1];
        }
    }

    /*
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cout << c[i][j] << ' ';
        }
        cout << endl;
    }
    */

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
/**
 * Title: C - One-stroke Path
 * Url: https://atcoder.jp/contests/abc054/tasks/abc054_c
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>
#include<queue>

using namespace std;

#define ll long long

struct to {int node; int len; vector<int> used; };

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> es(n+1, vector<int>());
    for(int i=0; i<m; i++) {
        int ai, bi; cin >> ai >> bi;
        es[ai].push_back(bi);
        es[bi].push_back(ai);
    }
    int ans = 0;
    queue<to> q;
    to t = {1, 1, vector<int>()};
    t.used.push_back(1);
    q.push(t);
    while(!q.empty()) {
        to tmp = q.front();
        q.pop();
        if(tmp.len==n) {
            ans++;
            continue;
        }
        for(int i=0; i<es[tmp.node].size(); i++) {
            if(count(tmp.used.begin(), tmp.used.end(), es[tmp.node][i]) == 0) {
                vector<int> c = tmp.used;
                c.push_back(es[tmp.node][i]);
                to t = {es[tmp.node][i], tmp.len+1, c};
                q.push(t);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
/*

*/
#include<bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)
#define repe(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> ans(10050,0);
  rep2(i,1,105){
    rep2(j,1,105){
      rep2(k,1,105){
        int v=i*i+j*j+k*k+i*j+j*k+k*i;
        if(v<10050)ans[v]+=1;
      }
    }
  }
  rep(i,n)cout<<ans[i+1]<<endl;
}

Measured memory_bytes: 3616
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

def dv(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N,M = I()
ans = 0
for d in dv(M):
    if M//d >= N:
        ans = max(ans,d)
print(ans)

Measured memory_bytes: 77900
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<math.h>
using namespace std;
#define N 100000
#define MP make_pair
typedef pair<int, int> P;
int h, w, n, in, pi, pj;
int ans[100][100];
void paint(int time, int color)
{
	int i, j;
	for (i = pi; i < h; i++)
	{
		pi = 0;
		
		for (j = pj  ; j < w && j >= 0; i % 2 ? j--: j++)
		{
			pj = i % 2 ? 0 : w-1;
			if (!time)
			{
				pi = i; pj = j;
				return;
			}
			ans[i][j] = color;
			--time;
		}
	}

}
int main() 
{
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> in;
		paint(in, i + 1);
	}
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        long K = sc.nextLong();

        int maxLength = (int) Math.min(S.length(), K);
        for (int i = 0; i < maxLength; i++) {
            if (S.charAt(i) != '1') {
                System.out.println(S.charAt(i));
                return;
            }
        }
        System.out.println(1);
    }
}


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

ll N, Q, ctr=0;
vector<ll> S, T;
signed main(){
    cin >> N;
    S.resize(N);
    for(int i=0;i<N;i++) cin >> S[i];
    sort(S.begin(), S.end());
    cin >> Q;
    T.resize(Q);
    for(int i=0;i<Q;i++) {
        cin >> T[i];
        if(*lower_bound(S.begin(), S.end(), T[i])==T[i]) ctr++;
    }
    cout << ctr << endl;
    return 0;
}
    


Measured memory_bytes: 3820
import qualified Data.IntMap as IM

solve :: Int -> [[Int]] -> (Int,Int,Int)
solve n xyhs =
  case [(x,y,h) | [x,y,h] <- xyhs, h > 0] of
    pos : _ -> solve1 pos xyhs
    [] -> solve2 xyhs

solve1 :: (Int,Int,Int) -> [[Int]] -> (Int,Int,Int)
solve1 (x0,y0,h0) xyhs = head $ foldr f initCands xyhs
  where
    initCands = [(cx, cy, h0 + (abs (x0 - cx)) + (abs (y0 - cy)))
                   | cx <- [0..100], cy <- [0..100]]
    f :: [Int] -> [(Int,Int,Int)] -> [(Int,Int,Int)]
    f [x,y,h] = filter ff
      where ff (cx, cy, ch) = height cx cy ch x y == h

solve2 :: [[Int]] -> (Int,Int,Int)
solve2 xyhs = head $ [(x,y,1) | x <- [0..100], y <- [0..100],
                                IM.notMember (enc (x,y)) mp]
  where mp = foldr f IM.empty xyhs
          where f [x,y,_] imap = IM.insertWith (+) (enc (x,y)) 1 imap

enc (x,y) = 101*x + y

height cx cy ch x y = max (ch - (abs (x - cx)) - (abs (y - cy))) 0


main = do
  cont <- getContents
  let [n] : xyhs = map (map read . words) (lines cont)
      (cx, cy, ch) = solve n xyhs
  putStrLn (show cx ++ " " ++ show cy ++ " " ++ show ch)


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n;
    vector<int> x,p,dp;
    vector<vector<int>> ch;
    Problem(LL n):n(n),x(n),p(n),dp(n),ch(n){};
    void fail() {cout << "IMPOSSIBLE"<< "\n"; exit(0);};
    void solve(){
        for(int i=1; i<n; ++i){
            cin >> p[i];
            p[i]--;
            ch[p[i]].push_back(i);
        }
        for(int i=0; i<n; ++i){
            cin >> x[i];
        }
        dfs(0);
        DBG(dp)
        cout << "POSSIBLE"<<"\n";
    }
    void dfs(int cur){
        if((int)ch[cur].size()==0){
            return;
        }
        vector<int> tmp(x[cur]+1);
        tmp[0]=1;
        LL sum =0;
        for(auto &&y: ch[cur]){
            vector<int> tmp2(x[cur]+1);
            dfs(y);
            sum+=dp[y]+x[y];
            for(int i=0; i<(int)tmp.size(); ++i){
                if((i>=dp[y] and tmp[i-dp[y]]>0)or(i>=x[y] and tmp[i-x[y]]>0)) tmp2[i]=1;
            }
            tmp.swap(tmp2);
        }
        for(int i=(int)tmp.size()-1; i>=0; --i){
            if(tmp[i]>0){
                dp[cur]=sum-i;
                break;
            }
            if(i==0)fail();
        }
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



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

using namespace std;
string s;
int main(){
    cin >> s;
    int sum = 0;
    for(int i=0; i<s.length(); i++){
        char a = s[i];
        sum += ( (int)(a - '0') );
    }
    cout << ((sum % 9 == 0 ) ? "Yes" : "No") << endl; 
    return 0;
}


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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }



    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var x = sc.intarr;
        wr.wri(x[0] - x[1] + 1);
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 11348
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;
		int[] a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		int ans = 1<<30;
		for (int i=0; i<n-1; i++) {
			ans = Math.min(ans, a[i+1] - a[i]);
		}
		out.println(ans);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 47980
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}

vector<ll>v[Max+10];

int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


      cin>>l>>r;

      ans=2018;

      for(i=l; i<=l+2019 && i<r; i++)
      {
          for(j=i+1; j<=l+2019 && j<=r; j++)
          {
              a=i*j;

              a=a%2019;

            ans=min(ans,a);
          }
      }

      cout<<ans<<endl;





}



Measured memory_bytes: 50516