akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int find_root(vector<int> &parent, int i){
    vector<int> path_nodes;
    int temp=i;
    while(true){
        if(parent[temp] == temp){
            for(int k=0;k<path_nodes.size();k++){
                parent.at(path_nodes.at(k))=temp;
            }
            return temp;
        }else{
            path_nodes.push_back(temp);
            temp=parent[temp];
        }
    }
}

signed merge_trees(vector<int> &parent,int i, int j, vector<int> &tree_size){
    int i_root = find_root(parent, i);
    int j_root = find_root(parent, j);
    if(i_root==j_root){
        return 0; // do nothing
    }else{
        int i_size = tree_size.at(i_root);
        int j_size = tree_size.at(j_root);
        if((i+j)%2==0){
            parent.at(i_root) = j_root;
            tree_size.at(j_root) = tree_size.at(j_root) + tree_size.at(i_root);
        }else{
            parent.at(j_root) = i_root;
            tree_size.at(i_root) = tree_size.at(j_root) + tree_size.at(i_root);
        }
        return j_size*i_size;
    }
}



signed main(){
    int N, M; cin>>N>>M; //N人の人, Mこの情報
    vec_int A(M), B(M);// AとBは友達
    rep(i,M)cin>>A.at(i)>>B.at(i);

    //最大のグループの人数個のグループを作る必要がある
    // union-find木でグループを作って、最大のグループを数える

    vec_int unionfind(N+1);
    rep(i,N+1){
        unionfind.at(i) = i;
    }

    vec_int tree_size(N+1);
    rep(i,N+1){
        tree_size.at(i) = 1;
    }

    for(int i=0;i<M;i++){
        int a = A.at(i);
        int b = B.at(i);
       int temp = merge_trees(unionfind, a,b, tree_size);
    }
    // 最大のツリーサイズを探す
    int max_size = 0;
    for(int i=0;i<N+1;i++){
        if(max_size<tree_size.at(i))max_size = tree_size.at(i);
    }
    cout<<max_size<<endl;
    

 
    

    return 0;
}

Measured memory_bytes: 9524
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> h(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}

	int h_max = *max_element(h.begin(), h.end());

	int ans = 0;
	for (int i = h_max; i >= 1; i--) {
		for (int j = 0; j < N; j++) {
			if (h[j] == i) {
				ans += 1;
				h[j] -= 1;
				while (j < (N - 1) && h[j + 1] == i) {
					j++;
					h[j] -= 1;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}



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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


int main() {
  ll l,r;
  cin >> l >> r;
  ll dif =r-l;
  ll modl=l%2019;
  ll modr=r%2019;
  if(dif>2018-modl){cout << 0;return 0;}
  int ans=2018;


  for(int i=modl;i<=modr;i++){
    for(int j=i+1;j<=modr;j++){
      int mm=(i*j)%2019;
      ans=min(ans,mm);
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100
#define INF 10000000

void Matrix_Chain_Order(int *);
int Min(int , int );

int r[N],c[N];
int p[N];
int m[N][N];
int n ;

int main() {
  
  int i,j; 
  
  scanf("%d",&n);
  if(n < 0 || N < n) return 0;
  
  for(i=0;i < n;i++){
    scanf("%d %d",&r[i],&c[i]);
  }

  for(i=0;i < n;i++){
    if(i == 0) {
      p[i] = r[i];
      p[i+1] = c[i];
    }
    else p[i+1] = c[i];
  }
  
  Matrix_Chain_Order(p);
  
   printf("%d\n",m[1][n]);
  
  return 0;
}


void Matrix_Chain_Order(int *p){
  int i,j,k;
  int l,q=0;
  
  for(i=1;i <= n;i++) m[i][i] = 0;
  
  for(l=2;l <= n;l++){
    for(i=1;i <= n-l+1;i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i+1;k <= j;k++){
	q = m[i][k-1]+m[k][j]+p[i-1]*p[k-1]*p[j];
	if(q < m[i][j]) m[i][j]=q;
      }
    }
  }
}

Measured memory_bytes: 636
#include<iostream>
using namespace std;
long long N;
long long h,n,w;
int main()
{
	cin>>N;
	for(int h=1;h<=3500;h++)
	  for(int n=1;n<=3500;n++)
	  {
	  	if(4*n*h-n*N-N*h>0){
	  			if((N*h*n)%(4*n*h-n*N-N*h)==0)
	 	 	{
	  			cout<<h<<" "<<n<<" "<<(N*h*n)/(4*n*h-n*N-N*h)<<endl;
		  		return 0;
	  		}
	  	}
	  
	  }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>


using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;

const int mod = 1e9 + 7;
const int nax  = 2e5 + 5;
int fac[nax], inv_fac[nax];

int mul(int a, int b){
    return (ll) a * b % mod;
}

int mpow(int a, int b){
    int r  = 1;
    while(b) {
        if(b % 2){
            r = mul(r, a);
        }
        a = mul(a, a);
        b /= 2;
    }
    return r;
}

int minv(int a){
    return mpow(a, mod - 2);
}

int binomial(int a, int b){
    if(a < 0 || b < 0 || b > a){
        return 0;
    }
    return mul(fac[a], mul(inv_fac[b], inv_fac[a - b]));
}

int f(int a, int b){
    int tmp = binomial(a + b, b);
    return tmp;
}

int sub(int a, int b){
    return (a - b + mod) % mod;
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    fac[0] = inv_fac[0] = 1;
    for(int i = 1; i < nax; i++){
        fac[i] = mul(fac[i - 1], i);
        inv_fac[i]  = minv(fac[i]);
    }
    int h, w, n;
    
    cin >> h >> w >> n;
    vector<pair<int, int>> in(n);
    for(int i = 0; i < n; i++){
        cin >> in[i].first >> in[i].second;
    }
    sort(in.begin(), in.end(), [&](pair<int, int> a, pair<int, int> b) {
        return a.first + a.second < b.first + b.second;
        
    });
    
    //dp[i] number of paths to vertex in[i]such that it's the first forbidden vertex
    
    in.emplace_back(h, w);
    
    vector<int> dp(n + 1);
    for(int i = 0; i <= n; i++){
        int tmp = f(in[i].first - 1, in[i].second - 1);
        
        for(int j = 0; j < i; ++j) {
            if(in[j].first <= in[i].first && in[j].second <= in[i].second) {
                tmp = sub(tmp, mul(dp[j], f(in[i].first - in[j].first, in[i].second-in[j].second)));
            }
        }
        
        dp[i] = tmp;
    }
    printf("%d\n", dp[n]);
}



Measured memory_bytes: 1920
import sys
input = sys.stdin.readline
INF = 1001001001
from collections import deque

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def pad(mxy, wall="#"):
	w = len(mxy[0])
	gp = wall*(w+2)
	re = [gp,]
	re_app = re.append
	for vx in mxy:
		re_app(wall+vx+wall)
	re_app(gp)
	return re

vD = [(0,1),(1,0),(0,-1),(-1,0)]
vQ = deque([])
vQ_app, vQ_popl = vQ.append, vQ.popleft

def main():
	H,W = linput()
	mM = [input().rstrip() for _ in [0,]*H]
	mM = pad(mM)
	
	res = 0
	cnt = 0
	
	for sr in range(1,H+1):
		for sc in range(1,W+1):
			if mM[sr][sc]=="#":
				continue
			mV = [[INF,]*(W+2) for _ in [INF,]*(H+2)]
			mV[sr][sc] = 0
			vQ_app((sr,sc))
			while vQ:
				r,c = vQ_popl()
				now_cost = mV[r][c]
				for dr,dc in vD:
					nr,nc = r+dr, c+dc
					if mM[nr][nc]=="#":
						continue
					if now_cost + 1 < mV[nr][nc]:
						vQ_app((nr,nc))
						mV[nr][nc] = now_cost + 1
						res = max(now_cost+1, res)
		
				cnt += 1
				#print(res,cnt,X,Y,H)
				if cnt>999999: break
	
	print(res)

if __name__ == "__main__":
	main()


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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){

    bool flag=false;

    ll ans=0,sum=0;
    
    int a,b;
    cin >>a>>b;
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << max(0,a-2*b) << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int t1=0,t2,x1=0,x2,y1=0,y2;
    int i;
    string ans="Yes";

    for(i=0; i<N; i++){
        cin >> t2 >> x2 >> y2;
        if(ans=="Yes"){
            if((t2+x2+y2)%2==0 && abs(t2-t1)>=abs(x2-x1)+abs(y2-y1)){
            x1=x2;
            t1=t2;
            y1=y2;
        }
            else ans="No";
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  vector<int> x(5);
  for(int i=0;i<5;i++){
    cin >> x.at(i);
  }
  
  int ans = 0;
  for(int i=0;i<5;i++){
    if(x.at(i) == 0){
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int N = sc.nextInt();
    int[] A = new int[N];
    int min = Integer.MAX_VALUE;

    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }

    for (int i = 0; i < N; i++) {
      int tokeiEnd = (i == 0 ? N-1 : i);
      int hantokeiEnd = (i == N-1 ? 0 : i+1);

      int tokei = tokei(A[i], A[tokeiEnd], K);
      if (tokei < min) {
        min = tokei;
      }

      int hantokei = hantokei(A[i], A[hantokeiEnd], K);
      if (hantokei < min) {
        min = hantokei;
      }
    }

    System.out.println(min);

  }

  public static int tokei(int begin, int end, int K) {
    if (begin < end) {
      return end - begin;
    } else {
      return K - begin + end;
    }
  }

  public static int hantokei(int begin, int end, int K) {
    if (begin > end) {
      return begin - end;
    } else {
      return begin + (K - end);
    }
  }

}

Measured memory_bytes: 65284
local PairingHeap={}

PairingHeap.merge=function(self,a,b)
	if not a then
		return b
	elseif not b then
		return a
	elseif a[1]<b[1] then
		b[4]=a[3]
		a[3]=b
		return a
	else
		a[4]=b[3]
		b[3]=a
		return b
	end
end

PairingHeap.twopassmerge=function(self,a)
	local b=a and a[4]
	if b then
		local newnode=b[4]
		a[4]=false
		b[4]=false
		return self:merge(self:merge(a,b),self:twopassmerge(newnode))
	else
		return a
	end
end

PairingHeap.empty=function(self)
	return not self.root
end

PairingHeap.pop=function(self)
    local root=self.root
    local value=root[2]
	self.root=self:twopassmerge(root[3])
    for i=1,4 do
        root[i]=false
	end
	table.insert(self,root)
    return value
end

PairingHeap.push=function(self,key,value)
    local root=self.root
	if root and root[1]<key then
		root[3]={
            key,
            value,
            false,
            root[3],
        }
    else
		self.root={
            key,
            value,
            root,
            false,
        }
	end
end

PairingHeap.join=function(self,other)
	local a=self.root
	local b=other.root
	if a[1]<b[1]then
		b[4]=a[3]
		a[3]=b
	else
		a[4]=b[3]
		b[3]=a
		self.root=b
	end
	return self
end

PairingHeap.new=function(self)
    local obj={}
    setmetatable(obj,{__index=PairingHeap})
    return obj
end

----------

local xyz={io.read("n","n","n")}
local k=io.read("n")
local abc={}
for i=1,3 do
    abc[i]={}
    for j=1,xyz[i] do
        abc[i][j]=io.read("n")
    end
    table.sort(abc[i],function(a,b)
        return a>b
    end)
end

local pq=PairingHeap:new()
local map={}

local frstky=abc[1][1]+abc[2][1]+abc[3][1]
pq:push(-frstky,{1,1,1,frstky})

for i=1,k do
    local pop=pq:pop()
    print(pop[4])
    for j=1,3 do
        if pop[j]<xyz[j] then
            local key=pop[4]-abc[j][pop[j]]+abc[j][pop[j]+1]
            local val={pop[1],pop[2],pop[3],key}
            val[j]=val[j]+1
            local mapkey=tostring(key)
            for l=1,3 do
                mapkey=mapkey.." "..val[l]
            end
            if not map[mapkey] then
                map[mapkey]=true
                pq:push(-key,val)
            end
        end
    end
end

Measured memory_bytes: 6232
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++)
    cin >> a[i];
  int ans = 1000000010;
  for (int i = -100; i <= 100; i++)
  {
    int tmp = 0;
    for (int j = 0; j < N; j++)
    {
      tmp += (a[j] - i) * (a[j] - i);
    }
    if (tmp < ans)
      ans = tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>

typedef long long ll;
#define min_3(a, b, c) min(a, min(b, c))
#define INF 1e9

using namespace std;

int n, a, b, c;
vector<int> l;

int dfs(int cur, int A, int B, int C){ //合成を考える
    if(cur == n){ //全部竹を使ったら
        return (min_3(A, B, C) > 0 ? abs(A - a) + abs(B - b) + abs(C - c) - 30: INF);
    }

    //パターン
    int do_nothing = dfs(cur + 1, A, B, C); //使わない
    int add_a = dfs(cur + 1, A + l[cur], B, C) + 10; //aの材料
    int add_b = dfs(cur + 1, A, B + l[cur], C) + 10; //bの材料
    int add_c = dfs(cur + 1, A, B, C + l[cur]) + 10; //cの材料

    int min_adding = min_3(add_a, add_b, add_c);
    int minimum_MP = min(do_nothing, min_adding);
    
    return minimum_MP;
}

int main()
{
    cin >> n >> a >> b >> c;
    l.resize(n);
    for (int i = 0; i < n; i++) cin >> l[i];

    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> p(n), c(n);
  rep(i, n){
    cin >> p[i];
    p[i]--;
  }
  rep(i, n) cin >> c[i];
  ll ans = -1000000000;
  rep(i, n){
    ll loop_num = k;
    ll loop_score = -1000000000;
    ll score = 0;
    vector<ll> scores;
    ll next = p[i];
    rep(j, k){
      score += c[next];
      next = p[next];
      scores.push_back(score);
      if (next == p[i]){
        loop_num = j+1;
        loop_score = score;
        break;
      }
    }
    ll a1 = 0, a2 = 0;
    if (loop_num > 0){
      a1 = k / loop_num; // 一周できる回数
      a2 = k % loop_num; // 一周繰り返した後の余り
    }
    if (a1 > 0 && loop_score > 0){
      rep(j, loop_num){
        ll p = 0;
        if (j >= a2) p = -1;
        ans = max(ans, scores[j] + loop_score * (a1+p));
      }
    }
    else {
      rep(j, loop_num){
        ans = max(ans, scores[j]);
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3748
#include <cstdio>

const int MOD = 1e9 + 7, MAX_N = 2e5 + 5;
typedef long long LL;

LL factorial[MAX_N + 1];
LL inverse_factorial[MAX_N + 1];

LL power_mod(LL x, LL power, LL MOD)
{
    LL answer = 1;

    while(power)
    {
        if(power%2 == 1)
            answer = (answer*x)%MOD;

        x = (x*x)%MOD;
        power = power >> 1;
    }

    return answer;
}

LL choose(LL n, LL r, LL MOD)
{
    LL numerator = factorial[n];
    LL denominator_inverse = (inverse_factorial[r]*inverse_factorial[n - r])%MOD;

    return (numerator*denominator_inverse)%MOD;
}

int main()
{
    const int MOD = 1e9 + 7;

    factorial[0] = 1;
    for(int i = 1; i <= MAX_N; i++)
        factorial[i] = (i*factorial[i - 1])%MOD;

    inverse_factorial[MAX_N] = power_mod(factorial[MAX_N], MOD - 2, MOD);
    for(int i = MAX_N - 1; i >= 0; i--)
        inverse_factorial[i] = ( (i + 1)*inverse_factorial[i + 1] )%MOD;

    int no_of_factors, n;
    scanf("%d %d", &no_of_factors, &n);

    LL answer = 1;
    for(int i = 2; i*i <= n; i++)
    {
        int exponent = 0;

        while(n%i == 0)
        {
            n = n/i;
            exponent++;
        }

        LL no_of_ways_of_placing_this_prime = choose(exponent + no_of_factors - 1, exponent, MOD);
        answer = (answer*no_of_ways_of_placing_this_prime)%MOD;
    }

    if(n > 1)
    {
        int exponent = 1;

        LL no_of_ways_of_placing_this_prime = choose(exponent + no_of_factors - 1, exponent, MOD);
        answer = (answer*no_of_ways_of_placing_this_prime)%MOD;
    }

    printf("%lld\n", answer);
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<double, double> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

//ll bit[200010];
ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		t = max(bit[i], t);
		i -= i & -i;
	}
	return t;
}

void update(ll i, ll x)
{
	i += 1;
	while (i <= 200005)
	{
		bit[i] = max(bit[i], x);
		i += i & -i;
	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 3004; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}

ll N, dp[3010][3010];
string S;

void solve() {
	cin >> N >> S;
	ll b = 1, e = N;
	rep(i, N) dp[0][i + 1] = 1;
	rep(i, N) {
		ll num = 0;
		if (S[i] == '<') {
			b++;
			for (ll j = b; j <= e; j++) {
				(num += dp[i][j - 1]) %= mod;
				(dp[i + 1][j] += num) %= mod;
			}
		}
		else {
			e--;
			for (ll j = e; j >= b; j--) {
				(num += dp[i][j + 1]) %= mod;
				(dp[i + 1][j] += num) %= mod;
			}
		}
	}
	cout << dp[N - 1][b] << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 70016
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	int H, A;
	cin >> H >> A;
	cout << H / A + bool(H % A) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll ans = 0;
    int r = 0;
    ll sum = 0;
    rep(l, N)
    {
        while(r < N && (sum + a[r]) == (sum ^ a[r]))
        {
            sum += a[r++];
        } 
        ans += r-l;
        if(l == r) r++;
        else sum -= a[l];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int64_t N;
  cin>>N;
  int64_t ans=0;
  for(int64_t i=1;i*i<=N;i++){
    if(N%i==0){
      int64_t m=N/i-1;
      if(m>0&&N/m==N%m){ans+=m;}
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3576
#include <cstdio>

int main(){
  int x,y,tmp;

  while(true){
    scanf("%d", &x);
    scanf("%d", &y);
    if(x || y){
      if(x > y){
	tmp = y;
	y = x;
	x = tmp;
      }
    printf("%d %d\n",x,y);
    }else{
      break;
    }
  }
}

Measured memory_bytes: 2528
#include <iostream>

int main(){
    int A, B, C, K, ans;
    std::cin >> A >> B >> C >> K;

    if(K - A > 0){
        ans = A;
        K -= A;
        
        if(K - B > 0){
            K -= B;

            ans -= K;
        }
    }
    else{
        ans = K;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60;
const ll mod=1e9+7 ;
struct edge{int to;ll cap;int rev;};
int main(){
    ll N;
    cin>>N;
    vector<ll> a(N+5),b(N+5),c(N+5);
    vector< vector<ll> > dp(N+5,vector<ll>(3));
    rep(i,N) cin>>a[i]>>b[i]>>c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    if(N<=1) {
        cout<<max(max(dp[0][0],dp[0][1]),dp[0][2])<<endl;
    } else{
        REP(i,1,N) {
            dp[i][0] = max(dp[i-1][1] + a[i],dp[i-1][2] +a[i]);
            dp[i][1] = max(dp[i-1][2] + b[i],dp[i-1][0] +b[i]);
            dp[i][2] = max(dp[i-1][0] + c[i],dp[i-1][1] +c[i]);
        }
        cout<<max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2])<<endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  deque<int64_t> dq;
  for(int i=0;i<N;i++){
    int64_t A;
    cin >> A;
    dq.push_back(A);
  }
  sort(dq.begin(),dq.end());
  int ans=N;
  int64_t x=dq.front();
  dq.pop_front();
  while(true){
    if(dq.empty()){
      break;
    }
    if(x*2<dq.front()){
      ans=dq.size();
    }
    x+=dq.front();
    dq.pop_front();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long M=100000007;
ll ans[M],n,k;
int main(){
	cin >> n >> k;
	if(k >= (1<<n)){cout<<"-1\n";return 0;}
	if (n == 1) {
		if(k == 1) {
			cout << -1 << endl;
			return 0;
		}
		cout << "0 0 1 1" << endl;
		return 0;
	}
	for(ll i=0;i<(1<<n);i++) if(i!=k) cout << i << " ";
	cout << k << " ";
	for(ll i=(1<<n)-1;i>=0;i--) if(i!=k)cout<< i << " ";
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	map<char,ll> mp;
	vector<char> id={'M','A','R','C','H'};
	vector<int> num={0,0,1,1,1};
	rep(i,n){
		string s;
		cin>>s;
		mp[s[0]]++;
	}
	ll ans=0;
	do{
		ll now=1;
		rep(i,5){
			if(num[i]){
				now*=mp[id[i]];
			}
		}
		ans+=now;
	}while(next_permutation(begin(num),end(num)));
	cout<<ans<<endl;
}

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

int x,y;

int main(void){
	scanf("%d%d",&x,&y);
	bool flag=false;
	for(int i=0;i<=x;i++){
		if(i*2+(x-i)*4==y){
			flag=true;
		}
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}


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

int main(){
  
  int a, b;
  char op;
  cin >> a >> op >> b;
  int ans = (op == '+') ? (a+b) : (a-b);
  cout << ans << endl;

}

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

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

class Sol{
	public void Solve(){
		if(X == 1 || X == 2*N-1){
			Console.WriteLine("No");
			return;
		}
		Console.WriteLine("Yes");
		
		if(X != N*2-2){
			int[] A = new int[N*2-1];
			A[N-1] = 1;
			
			int[] l = new int[N-1];
			int[] r = new int[N-1];
			
			for(int i=0;i<N-1;i++){
				l[i] = (X + 2*i);
				if(l[i] > 2*N-1 ) l[i] -= 2*N - 2;
			}
			for(int i=0;i<N-1;i++){
				r[i] = (X + 2*i + 1);
				if(r[i] > 2*N-1) r[i] -= 2*N - 2;
			}
			
			Array.Reverse(l);
			for(int i=0;i<N-1;i++)A[i] = l[i];
			for(int i=0;i<N-1;i++)A[i+N] = r[i];
			
			Console.WriteLine(String.Join("\n",A));
		}else{
			int[] A = new int[N*2-1];
			for(int i=0;i<N;i++)A[i] = 1+2*i;
			for(int i=N;i<2*N-1;i++) A[i] = 2*N - 2*(i-N+1);
			
			Console.WriteLine(String.Join("\n",A));
		}
	}
	int N,X;
	public Sol(){
		var d = ria();
		N = d[0]; X = d[1];
	}

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


Measured memory_bytes: 17368
#include <bits/stdc++.h>
using namespace std;
int main(){
  double A, B, H, M; cin >> A >> B >> H >> M;
  const double pi = 3.141592653589793;
  cout << fixed << setprecision(10) << sqrt(pow(A, 2.0) + pow(B, 2.0) - 2 * A * B * cos(H * pi / 6 - M * 5.5 * pi / 180));
  return 0;
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)
#define COUT(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================
// Template End =========================

constexpr int MOD=1e9+7;
locale LOCATE=locale::classic();

int main(void){
  int r; cin>>r;
  cout<<r*r;
}











Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<map>
#include<functional>
#include<queue>
#include<string.h>
#include <sstream>
#include<stdio.h>
#include<iomanip>
#include<stdlib.h>
#include<math.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<bitset>
#include<assert.h>
#include<fstream>
#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair<int,int>P;
map<ll,int>mp;
int main()
{
int n;
scanf("%d",&n);
ll ret=0,sum=0;
mp[0]++;
for(int i=0;i<n;i++)
{
ll a;
scanf("%lld",&a);
sum+=a;
ret+=mp[sum];
mp[sum]++;
}
printf("%lld\n",ret);
return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k,pos = 0;
  vector<int> v(5),d(10,0);
  for (ll i = 0; i < 5; ++i) cin >> v[i];
  cin >> k;
  for (ll i = 0; i < 4; ++i) {
    for (ll j = i+1; j < 5; ++j) {
      d[pos] = abs(v[i] - v[j]);
      pos += 1;
    }
  }
  int m = *max_element(d.begin(), d.end());
  if (m > k) cout << ":(" << endl;
  else cout << "Yay!" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
 
double r,x,y;
 
scanf("%lf",&r);
 
x=3.14159265359*r*r;
 
y=2*3.14159265359*r;
 
printf("%lf %lf\n",x,y);
 
return 0;
 
}

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

long ret(long N){
  if(N%4==0) return N;
  else if(N%4==1) return 1;
  else if(N%4==2) return N+1;
  else return 0;
}

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

long a=ret(A-1);
long b=ret(B);

cout<<(a^b)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	double sum = 0;
	for (int i = 1; i < n + 1; i++) {
		double d = 1.0 / n;
		for (int j = i; j < k; j *= 2) {
			d *= 0.5;
		}
		sum += d;
	}
	cout << setprecision(10) << sum << endl;
}

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

int main() {
    string s;
    int tot = 0;
    cin >> s;
    for (char c : s) {
        tot += c-'0';
        if (tot>=9)tot-=9;
    }
    if (tot==0)cout << "Yes";
    else cout << "No";
}

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

int main(){
    double a,b,C;
    cin >> a >> b >> C;
    double S,L,h;
    double pi=M_PI;
    S=0.50*a*b*sin(C/180.0*pi);
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(C/180.0*pi));
    h=2*S/a;
    printf("%.12lf\n%.12lf\n%.12lf\n",S,L,h);
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <map>
#include <cmath>
typedef long long int ll;
using namespace std; 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n;cin>>n;
	int ans = pow(n,3);
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    int a;
    cin >>a;
    cout << a+a*a+a*a*a <<endl;
    return 0;
}

Measured memory_bytes: 3636
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
    a:i64,
        }
    println!("{}", if a == 0 { 1 } else { 0 });
}
pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static P[] p;
	static Map<Long, Long> map = new HashMap<>();
	static int N, W;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			N = in.nextInt();
			W = in.nextInt();
			p = new P[N];
			for (int i = 0; i < N; i++) {
				int w = in.nextInt(), v = in.nextInt();
				p[i] = new P(w, v);
			}

			out.println(func(0, 0));

		}
	}

	static long func(int d, int j) {
		long key = (long)d << 32 | j;
		if (d == N) {
			map.put(key, 0L);
			return 0;
		}
		if (map.containsKey(key)) {
			return map.get(key);
		}

		long ret = 0;
		long r1 = 0;
		long r2 = 0;

		if (j + p[d].w <= W) {
			r1 = func(d + 1, j + p[d].w) + p[d].v;
		}
		r2 = func(d + 1, j);
		ret = Math.max(r1, r2);
		map.put(key, ret);
		return ret;
	}

	static class P {
		int w,v;
		P (int w, int v) {
			this.w = w;
			this.v = v;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 66928
N, M = map(int, input().split())
drink = []
for i in range(N):
    AB = list(map(int, input().split()))
    drink.append(AB)
drink.sort()

ans = 0

while(M > 0):
    for j in range(N):
        ans += drink[j][0] * min(M, drink[j][1])
        if M >= drink[j][1]:
            M -= drink[j][1]        
        else:
            M = 0
print(ans)

Measured memory_bytes: 27760
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;


int main(){
    ll N,count=1;
    cin >> N;
    ll A[N+10]={},B[N+10]={};
    for(ll i=0; i<N-1; i++){
        cin >> A[i];
    }
    sort(A,A+N-1);
        for(ll i=0; i<N-1; i++){
            B[A[i]]++;
    }
    for(ll i=1; i<=N; i++){
            cout << B[i] << endl;
    }
    }


Measured memory_bytes: 6768
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  string s; cin >>s;
  cout <<s[0] <<s.size()-2 <<s[s.size()-1] <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a[101010];
map<ll, ll> mp;
int main() {
    cin>>n;
    REP(i, 0, n){
        cin>>a[i];
        mp[a[i]]++;
    }

    if(mp.size()==1 && mp.count(0)){
        cout<<"Yes"<<endl;
    }
    else if(n%3==0 && mp.size()==2 && mp.count(0) && mp[0]==n/3){
        cout<<"Yes"<<endl;
    }
    else if(n%3==0 && mp.size()==3){
        bool flag=true;
        ll sum=0;
        for(auto itr:mp){
            sum^=itr.first;

            if(itr.second!=n/3) flag=false;
        }

        if(flag && sum==0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

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

bool solve(vector<vector<int> > state, vector<vector<int> >& ans)
{
  for (int i = 0; i < SIZE; ++i) {
    for (int j = 0; j < SIZE; ++j) {
      if ((i == 0 && ans[i][j]) || (i > 0 && state[i-1][j])) {
	ans[i][j] = 1;
	for (int d = 0; d < 5; ++d) {
	  int xx = j + dx[d];
	  int yy = i + dy[d];
	  if (0 <= xx && xx < SIZE && 0 <= yy && yy < SIZE)
	    state[yy][xx] ^= 1;
	}
      }
    }
  }

  for (int i = 0; i < SIZE; ++i) {
    for (int j = 0; j < SIZE; ++j) {
      if (state[i][j])
	return false;
    }
  }
  return true;
}

int main()
{
  int n;
  while (cin >> n) {
    while (n--) {
      vector<vector<int> > state(SIZE, vector<int>(SIZE));
      for (int i = 0; i < SIZE; ++i) {
	for (int j = 0; j < SIZE; ++j)
	  cin >> state[i][j];
      }

      for (int i = 0; i < (1 << SIZE); ++i) {
	vector<vector<int> > ans(SIZE, vector<int>(SIZE, 0));
	for (int j = 0; j < SIZE; ++j) {
	  if (i & (1 << j))
	    ans[0][j] = 1;
	}
	if (solve(state, ans)) {
	  for (int i = 0; i < SIZE; ++i) {
	    for (int j = 0; j < SIZE-1; ++j) 
	      cout << ans[i][j] << " ";
	    cout << ans[i][SIZE-1] << endl;
	  }
	  break;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 912
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<n;i++)
#define reps(i,s,n) for(long long i=s;i<n;i++)
#define vec vector
#define inf (1LL<<60)
using namespace std;
using ll = long long;
vec<ll> h;
vec<ll> dp;
ll k;

ll cost(ll n) {
	if (n == 0) return 0;
	if (n < 0) return inf;
	if (dp[n] != inf ) return dp[n];
	ll tmp = inf;
	reps(i, 1, k + 1) {
		if (n - i < 0) break;
		tmp = min(tmp, cost(n - i) + abs(h[n] - h[n - i]));
	}
	return dp[n] = tmp;
}

int main(void) {
	ll n;
	cin >> n >> k;
	h.resize(n);
	dp.assign(n, inf);
	rep(i, n) cin >> h[i];
	cout << cost(n - 1) << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

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

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

#define ll long long
typedef pair<int, int> P;

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

	ll x;	cin >> x;
	ll start = 100, years = 0;

	while(start < x) {
		start += start/100;
		years ++;
	}
	cout << years;
}


Measured memory_bytes: 3652
from bisect import bisect_left as bl

def main():
  s = list(map(ord, list(input())))
  k = int(input())
  used = []
  used_index = []
  pos_dict = {}
  as_a = ord("a")
  as_z = ord("z")
  for i, v in enumerate(s):
    if v in pos_dict:
      pos_dict[v].append(i)
    else:
      pos_dict[v] = [i]
  keys = sorted(pos_dict.keys())
  for key in keys:
    pos_dict[key].reverse()
  
  while k:
    for key in keys:
      init = pos_dict[key][-1]
      pre_used = bl(used_index, init)
      cost = init - pre_used
      if cost <= k:
        k -= cost
        used.append(key)
        ins = bl(used_index, init)
        used_index.insert(ins, init)
        pos_dict[key].pop()
        if not pos_dict[key]:
          keys.remove(key)
        break
    else:
      break
  
  used_index.sort(reverse=True)
  for i in used_index:
    s.pop(i)
  print("".join(map(chr, used + s)))

main()


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int gcd(ll a, ll b){
    if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> zahyo(n);
    REP(i, n) cin >> zahyo[i];
    zahyo.push_back(x);

    sort(zahyo.begin(), zahyo.end());
    int mae = zahyo[1] - zahyo[0];
    int ans = mae;

    REPN(i, 1, n) {
        int ato = zahyo[i+1] - zahyo[i];
        ans = gcd(ans, ato);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll x, a, b;
  cin >> x >> a >> b;
  if (b - a <= 0) {
    cout << "delicious" << "\n";
    return 0;
  }
  if (b - a <= x) {
    cout << "safe" << "\n";
  }
  else {
    cout << "dangerous" << "\n";
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split(" "))
C=[]
for _ in range(N):
    a,b=map(int, input().split(" "))
    C.append((a,b))
#C = [(6,18),(2,5),(3,10),(7,9)]

C.sort(key=lambda x:x[0])
a = 0
n = 0
for c in C:
    if n + c[1] >= M:
        a += (M-n) * c[0]
        #n += 
        break
    else:
        a += c[0] * c[1]
        n += c[1]
print(a)


Measured memory_bytes: 18184
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

H, W = LI()
c = []
for i in range(10):
    c.append(LI())

A = []
for i in range(H):
    A = A + LI()

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for a in A:
    if a != -1:
        ans += c[a][1]

print(ans)

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

int main(){
	int a,b;
	cin>>a>>b;
	int ans=1;
	int x=a;
    if(b==1)cout<<0;
  else{
	while(x<b)
	{
		x=x-1+a;
		ans++;
	}
	cout<<ans;}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    map<int, int> mp;
    mp[a]++; mp[b]++; mp[c]++;
    for (auto [k, v] : mp) if (v == 1) {
        cout << k << endl; exit(0);
    }
    return 0;
}

Measured memory_bytes: 3556
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define REPR(i, x, n) for(int i = n - 1 ; i >= x ; i--)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) REPR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    VI a(n);
    rep(i, n){
        cin >> a[i];
    }
    lint ans = 0;
    rep(i, n-1){
        int t = max(a[i] + a[i+1] - x, 0);
        ans += t;
        a[i+1] = max(a[i+1] - t, 0);
    }
    cout << ans << endl;
    return 0;
}

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

#define MODNUMBER 1000000007

long long pow_mod(long long a, long long n) {  // a^n mod MODNUMBER
	long long result = 1;
	long long a_i = a;
	long long n_tmp = n;
	while (n_tmp > 0) {
		if (n_tmp & 0b1) {
			result = (result * a_i) % MODNUMBER;
			// cout << result << "\n";
		}
		a_i = a_i * a_i % MODNUMBER;
		n_tmp = n_tmp >> 1;
	}
	return result;
}

long long fact_mod(long long k) {  // k! mod MODNUMBER

	long long result = 1;
	for (int i = 1; i <= k; i++) {
		result = (result * i) % MODNUMBER;
	}
	return result;
}

long long inv_mod(long long k) {  // k^(-1) mod MODNUMBER

	return pow_mod(k, MODNUMBER - 2);
}

/* TODO: fact_mod()の途中経過を使いまわす実装にすれば早くなるらしい */
long long comb_mod(long long n, long long k) {  // nCk mod MODNUMBER

	if (k < 0 || k > n) {
		return 0;
	}
	return (fact_mod(n) *
	        inv_mod((fact_mod(k) * fact_mod(n - k)) % MODNUMBER)) %
	       MODNUMBER;
}

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

	long long N, K;
	scanf("%lld %lld", &N, &K);
	// N-K-1Ci + N-K-1Ci-1 *2 +N-K-1Ci-2

	for (int i = 1; i <= K; i++) {
		cout << comb_mod(N - K + 1, i) * comb_mod(K - 1, i - 1) % MODNUMBER
		     << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
o = str(input())
e = str(input())
x = []
if len(o) == len(e):
  for i in range(len(o)):
    x.append(o[i]+e[i])
else:
  for i in range(len(e)):
    x.append(o[i]+e[i])
  x.append(o[-1])
print(*x,sep="")
    

Measured memory_bytes: 38384
A, B, C, X, Y = map(int, input().split())

m = 5000 * 200001
for k in range(200001):
    i = max(0, X - int(k / 2))
    j = max(0, Y - int(k / 2))
    m = min(m, A * i + B * j + C * k)
print(m)

Measured memory_bytes: 3060